Skip to content

Commit

Permalink
fix: linting issues for JSDoc (#48)
Browse files Browse the repository at this point in the history
* fix: ignore private functions in tests
* fix: add @returns to all functions
* fix: node/no-unpublished-require in test and e2e folders
* fix: update README for new JSDoc
  • Loading branch information
shazron authored Jul 6, 2020
1 parent 9c90758 commit c1d40d3
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 94 deletions.
4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@adobe/eslint-config-aio-lib-config",
"settings": {
"jsdoc": {
"ignorePrivate": true
}
}
}
179 changes: 108 additions & 71 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"node/no-unpublished-require": 0
}
}
1 change: 0 additions & 1 deletion e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const sdk = require('../src/index')
const path = require('path')

// load .env values in the e2e folder, if any
/* eslint-disable-next-line node/no-unpublished-require */
require('dotenv').config({ path: path.join(__dirname, '.env') })

var sdkClient = {}
Expand Down
47 changes: 42 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ const ACCEPT_HEADERS = {
V3: 'application/vnd.adobe.target.v3+json'
}

/* globals Response */

/**
* Returns a Promise that resolves with a new TargetCoreAPI object.
*
* @param {string} tenant tenant Adobe Target tenant name
* @param {string} apiKey apiKey Your api key
* @param {string} token Valid auth token
* @returns {Promise<TargetCoreAPI>}
* @returns {Promise<TargetCoreAPI>} Promise resolving to a TargetCoreAPI instance
*/
function init (tenant, apiKey, token) {
return new Promise((resolve, reject) => {
Expand All @@ -53,10 +55,10 @@ function init (tenant, apiKey, token) {
class TargetCoreAPI {
/** Initialize sdk.
*
* @param tenant {string} Adobe Target tenant name
* @param apiKey {string} Your api key
* @param token {string} Valid auth token
* @returns {TargetCoreAPI}
* @param {string} tenant Adobe Target tenant name
* @param {string} apiKey Your api key
* @param {string} token Valid auth token
* @returns {TargetCoreAPI} a TargetCoreAPI instance
*/
async init (tenant, apiKey, token) {
const initErrors = []
Expand Down Expand Up @@ -96,6 +98,7 @@ class TargetCoreAPI {
* @param {number} [options.offset = 0] Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities.
* @param {string} [options.sortBy] Defines the sorting criteria on the returned items
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getActivities (options = { limit: 2147483647, offset: 0 }) {
const sdkDetails = options
Expand All @@ -117,6 +120,7 @@ class TargetCoreAPI {
* @param {object} body Activity JSON.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
createABActivity (body, options = {}) {
const sdkDetails = body
Expand All @@ -138,6 +142,7 @@ class TargetCoreAPI {
* @param {object} body Activity JSON.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
createXTActivity (body, options = {}) {
const sdkDetails = body
Expand All @@ -159,6 +164,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getABActivityById (id, options = {}) {
var params = {}
Expand All @@ -182,6 +188,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getXTActivityById (id, options = {}) {
var params = {}
Expand All @@ -206,6 +213,7 @@ class TargetCoreAPI {
* @param {object} body activity JSON
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
updateABActivity (id, body, options = {}) {
var params = {}
Expand All @@ -230,6 +238,7 @@ class TargetCoreAPI {
* @param {object} body activity JSON
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
updateXTActivity (id, body, options = {}) {
var params = {}
Expand All @@ -254,6 +263,7 @@ class TargetCoreAPI {
* @param {string} name New Activity name.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
setActivityName (id, name, options = {}) {
var params = {}
Expand Down Expand Up @@ -281,6 +291,7 @@ class TargetCoreAPI {
* @param {string} state New Activity state.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
setActivityState (id, state, options = {}) {
var params = {}
Expand Down Expand Up @@ -309,6 +320,7 @@ class TargetCoreAPI {
* @param {string} priority New Activity priority.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
setActivityPriority (id, priority, options = {}) {
var params = {}
Expand Down Expand Up @@ -337,6 +349,7 @@ class TargetCoreAPI {
* @param {string} schedule New Activity schedule.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
setActivitySchedule (id, schedule, options = {}) {
var params = {}
Expand Down Expand Up @@ -364,6 +377,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
deleteABActivity (id, options = {}) {
var params = {}
Expand All @@ -387,6 +401,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
deleteXTActivity (id, options = {}) {
var params = {}
Expand All @@ -410,6 +425,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getActivityChangeLog (id, options = {}) {
var params = {}
Expand All @@ -435,6 +451,7 @@ class TargetCoreAPI {
* @param {number} [options.offset = 0] Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
* @param {string} [options.sortBy] Defines the sorting criteria on the returned items.
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getOffers (options = { limit: 2147483647, offset: 0 }) {
const sdkDetails = options
Expand All @@ -456,6 +473,7 @@ class TargetCoreAPI {
* @param {number} id Offer id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getOfferById (id, options = {}) {
var params = {}
Expand All @@ -479,6 +497,7 @@ class TargetCoreAPI {
* @param {object} body Offer JSON.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
createOffer (body, options = {}) {
const sdkDetails = body
Expand All @@ -502,6 +521,7 @@ class TargetCoreAPI {
* @param {object} body Offer JSON
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
updateOffer (id, body, options = {}) {
var params = {}
Expand All @@ -525,6 +545,7 @@ class TargetCoreAPI {
* @param {number} id Offer id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
deleteOffer (id, options = {}) {
var params = {}
Expand All @@ -550,6 +571,7 @@ class TargetCoreAPI {
* @param {number} [options.offset = 0] Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
* @param {string} [options.sortBy] Defines the sorting criteria on the returned items.
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getAudiences (options = { limit: 2147483647, offset: 0 }) {
const sdkDetails = options
Expand All @@ -571,6 +593,7 @@ class TargetCoreAPI {
* @param {object} body Audience JSON.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
createAudience (body, options = {}) {
const sdkDetails = body
Expand All @@ -592,6 +615,7 @@ class TargetCoreAPI {
* @param {number} id Audience id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getAudienceById (id, options = {}) {
var params = {}
Expand All @@ -616,6 +640,7 @@ class TargetCoreAPI {
* @param {object }body audience JSON
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
updateAudience (id, body, options = {}) {
var params = {}
Expand All @@ -639,6 +664,7 @@ class TargetCoreAPI {
* @param {number} id Audience id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
deleteAudience (id, options = {}) {
var params = {}
Expand All @@ -661,6 +687,7 @@ class TargetCoreAPI {
*
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getProperties (options = {}) {
const sdkDetails = options
Expand All @@ -682,6 +709,7 @@ class TargetCoreAPI {
* @param {number} id Property id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getPropertyById (id, options = {}) {
var params = {}
Expand All @@ -704,6 +732,7 @@ class TargetCoreAPI {
*
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getMBoxes (options = {}) {
const sdkDetails = {}
Expand All @@ -725,6 +754,7 @@ class TargetCoreAPI {
* @param {string} name MBox name.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getMBoxByName (name, options = {}) {
var params = {}
Expand All @@ -747,6 +777,7 @@ class TargetCoreAPI {
*
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getMBoxProfileAttributes (options = {}) {
const sdkDetails = options
Expand All @@ -767,6 +798,7 @@ class TargetCoreAPI {
*
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getEnvironments (options = {}) {
const sdkDetails = options
Expand All @@ -788,6 +820,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getABActivityPerformance (id, options = {}) {
var params = {}
Expand All @@ -811,6 +844,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getXTActivityPerformance (id, options = {}) {
var params = {}
Expand All @@ -834,6 +868,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getActivityPerformance (id, options = {}) {
var params = {}
Expand All @@ -857,6 +892,7 @@ class TargetCoreAPI {
* @param {number} id Activity id.
* @param {object} [options] sdk options
* @param {object} [options.headers] headers to pass to API call
* @returns {Promise<Response>} a Promise resolving to a Response
*/
getOrdersReport (id, options = {}) {
var params = {}
Expand All @@ -879,6 +915,7 @@ class TargetCoreAPI {
* Multiple Admin APIs can be executed as a single batch request.
*
* @param {object} body json to execute batch
* @returns {Promise<Response>} a Promise resolving to a Response
*/
executeBatch (body) {
const sdkDetails = body
Expand Down
5 changes: 5 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"node/no-unpublished-require": 0
}
}
16 changes: 3 additions & 13 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
/* eslint-disable-next-line node/no-unpublished-require */

const fetchMock = require('fetch-mock')
const mock = require('./mock')
const sdk = require('../src')
Expand All @@ -23,11 +23,7 @@ const ACCEPT_HEADERS = {
}
var sdkClient = {}

/**
* @param url
* @param method
* @param response
*/
/** @private */
function mockResponseWithMethod (url, method, response) {
fetchMock.reset()
fetchMock.mock((u, opts) => u === url && opts.method === method, response)
Expand Down Expand Up @@ -1050,13 +1046,7 @@ test('test executeBatch', async () => {
res = await checkErrorResponse(api, url, method, new errorSDK.codes.ERROR_EXECUTE_BATCH(), [obj])
})

/**
* @param fn
* @param url
* @param method
* @param error
* @param args
*/
/** @private */
function checkErrorResponse (fn, url, method, error, args = []) {
const client = sdkClient
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit c1d40d3

Please sign in to comment.