Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
module.exports = {
// "env": {
// "browser": true,
// "amd": true
// },
"extends": "standard",
// "globals": {
// "Atomics": "readonly",
// "SharedArrayBuffer": "readonly"
// },
// "parserOptions": {
// "ecmaFeatures": {
// "jsx": true
// },
// "ecmaVersion": 2015,
// "sourceType": "module"
// },
'plugins': [
'standard',
'promise'
],
"rules": {
}
};
// "env": {
// "browser": true,
// "amd": true
// },
extends: 'standard',
// "globals": {
// "Atomics": "readonly",
// "SharedArrayBuffer": "readonly"
// },
// "parserOptions": {
// "ecmaFeatures": {
// "jsx": true
// },
// "ecmaVersion": 2015,
// "sourceType": "module"
// },
plugins: [
'standard',
'promise'
],
rules: {
}
}
28 changes: 28 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Unit Test & Reports
on:
pull_request:
push:
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout the repo
- uses: actions/setup-node@v3
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci # install packages
- run: npm run test:unit:report:json # run tests (configured to use jest-junit reporter)
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Mocha Unit test # Name of the check run which will be created
path: report.json # Path to test results
reporter: mocha-json # Format of test results
- name: Coverage report
uses: lucassabreu/comment-coverage-clover@main
with:
name: Unit test Coverage report
file: coverage/clover.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jspm_packages/
mochawesome-report/
coverage/
test/utility/dataFiles/
report.json

# TypeScript v1 declaration files
typings/
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## [v1.7.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.7.0) (2023-04-04)
- Feature
- Marketplace API support added.
## [v1.6.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.6.1) (2022-12-09)
- Bug Fix
- SSO get stack details Latest

## [v1.6.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.6.0) (2022-10-19)
- Feature
- OAuth token refresh function added

## [v1.5.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.5.0) (2022-08-10)
- Feature
- App creation, fetch and update
- App configuration
- App Installation and getting installation details

## [v1.4.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.4.0) (2022-07-26)
- Bug Fix
- Delete: Set entry workflow and asset download
- Asset Download
- Set Entry workflow stages
- OAuth token authorisation

## [v1.2.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.2.4) (2021-07-19)
- Bug Fix
- Form data upload timeout on retrying rate limit error issue resolved
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012-2022 Contentstack
Copyright (c) 2012-2023 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
107 changes: 107 additions & 0 deletions lib/app/authorization/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import cloneDeep from 'lodash/cloneDeep'
import error from '../../core/contentstackError'

export function Authorization (http, data, params) {
http.defaults.versioningStrategy = undefined
this.params = params || {}
if (data) {
if (data.organization_uid) {
this.params = {
organization_uid: data.organization_uid
}
}
if (data.app_uid) {
this.urlPath = `/manifests/${data.app_uid}/authorizations`
/**
* @description List all user authorizations made to an authorized app under a particular organization
* @memberof Authorization
* @func findAll
* @returns {Promise<Response>}
*
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ authtoken: 'TOKEN'})
*
* client.organization('organization_uid').app('manifest_uid').authorization().findAll()
* .then((response) => console.log(response))
*/
this.findAll = async (param = {}) => {
try {
const headers = {
headers: { ...cloneDeep(this.params) },
params: {
...cloneDeep(param)
}
}

const response = await http.get(this.urlPath, headers)
if (response.data) {
return response.data
} else {
throw error(response)
}
} catch (err) {
throw error(err)
}
}
/**
* @description Revoke all users tokens issued to an authorized app for the particular organization
* @memberof Authorization
* @func revokeAll
* @returns {Promise<Response>}
*
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ authtoken: 'TOKEN'})
*
* client.organization('organization_uid').app('manifest_uid').authorization().revokeAll()
* .then((response) => console.log(response))
*/
this.revokeAll = async () => {
try {
const headers = {
headers: { ...cloneDeep(this.params) }
}

const response = await http.delete(this.urlPath, headers)
if (response.data) {
return response.data
} else {
throw error(response)
}
} catch (err) {
throw error(err)
}
}
/**
* @description Revoke user token issued to an authorized app for the particular organization
* @memberof Authorization
* @func revoke
* @returns {Promise<Response>}
*
* @example
* import * as contentstack from '@contentstack/management'
* const client = contentstack.client({ authtoken: 'TOKEN'})
*
* client.organization('organization_uid').app('manifest_uid').authorization().revoke('authorization_uid')
* .then((response) => console.log(response))
*/
this.revoke = async (authorizationUid) => {
try {
const headers = {
headers: { ...cloneDeep(this.params) }
}

const response = await http.delete(`${this.urlPath}/${authorizationUid}`, headers)
if (response.data) {
return response.data
} else {
throw error(response)
}
} catch (err) {
throw error(err)
}
}
}
}
}
Loading