@makeflow/cli
Advanced tools
Comparing version 0.1.0-wip.5 to 0.1.0-wip.6
@@ -62,3 +62,3 @@ "use strict"; | ||
async getUserId(username, password) { | ||
let result = await api.call('/account/list-users', { | ||
let result = await api.post('/account/list-users', { | ||
mobile: username, | ||
@@ -90,3 +90,3 @@ password, | ||
let userId = await this.getUserId(username, password); | ||
let accessToken = await api.call('/access-token/create', { | ||
let accessToken = await api.post('/access-token/create', { | ||
mobile: username, | ||
@@ -93,0 +93,0 @@ password, |
@@ -38,3 +38,3 @@ "use strict"; | ||
} | ||
return api.call('/power-app/publish', { | ||
return api.post('/power-app/publish', { | ||
definition, | ||
@@ -41,0 +41,0 @@ token, |
@@ -10,3 +10,3 @@ "use strict"; | ||
const DEFAULT_CONFIG = { | ||
api: 'https://makeflow.com/api/v1', | ||
api: 'https://www.makeflow.com/api/v1', | ||
}; | ||
@@ -13,0 +13,0 @@ exports.config = { ...DEFAULT_CONFIG }; |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import { BodyInit } from 'node-fetch'; | ||
export declare class API { | ||
@@ -7,3 +9,5 @@ private apiBaseURL; | ||
getURL(path: string): string; | ||
call<T>(path: string, data: unknown, ignoreAccessToken?: boolean): Promise<T>; | ||
post<T>(path: string, data: unknown, ignoreAccessToken?: boolean): Promise<T>; | ||
upload<T>(path: string, data: Buffer, type: string): Promise<T>; | ||
call<T>(method: string, path: string, body: BodyInit, ignoreAccessToken?: boolean, type?: string): Promise<T>; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const JSONContentType = 'application/json'; | ||
class API { | ||
@@ -24,9 +25,15 @@ constructor(apiBaseURL, _accessToken) { | ||
} | ||
async call(path, data, ignoreAccessToken = false) { | ||
async post(path, data, ignoreAccessToken = false) { | ||
return this.call('POST', path, JSON.stringify(data), ignoreAccessToken); | ||
} | ||
async upload(path, data, type) { | ||
return this.call('POST', path, data, false, type); | ||
} | ||
async call(method, path, body, ignoreAccessToken = false, type = JSONContentType) { | ||
let url = this.getURL(path); | ||
let response = await node_fetch_1.default(url, { | ||
method: 'POST', | ||
body: JSON.stringify(data), | ||
method, | ||
body, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Content-Type': type, | ||
...(ignoreAccessToken | ||
@@ -33,0 +40,0 @@ ? undefined |
{ | ||
"name": "@makeflow/cli", | ||
"version": "0.1.0-wip.5", | ||
"version": "0.1.0-wip.6", | ||
"description": "Command line interface for Makeflow.", | ||
@@ -23,2 +23,3 @@ "publishConfig": { | ||
"clime": "^0.5.14", | ||
"mime": "^2.4.6", | ||
"node-fetch": "^2.6.0", | ||
@@ -25,0 +26,0 @@ "prompts": "^2.3.2", |
@@ -92,3 +92,3 @@ import {Command, Options, command, metadata, option} from 'clime'; | ||
private async getUserId(username: string, password: string): Promise<string> { | ||
let result = await api.call<MFUserCandidate[]>( | ||
let result = await api.post<MFUserCandidate[]>( | ||
'/account/list-users', | ||
@@ -135,3 +135,3 @@ { | ||
let accessToken = await api.call<string>( | ||
let accessToken = await api.post<string>( | ||
'/access-token/create', | ||
@@ -138,0 +138,0 @@ { |
@@ -60,3 +60,3 @@ import { | ||
return api.call('/power-app/publish', { | ||
return api.post('/power-app/publish', { | ||
definition, | ||
@@ -63,0 +63,0 @@ token, |
@@ -13,3 +13,3 @@ import * as FS from 'fs'; | ||
const DEFAULT_CONFIG: SDKConfig = { | ||
api: 'https://makeflow.com/api/v1', | ||
api: 'https://www.makeflow.com/api/v1', | ||
}; | ||
@@ -16,0 +16,0 @@ |
import {ExpectedError} from 'clime'; | ||
import fetch from 'node-fetch'; | ||
import fetch, {BodyInit} from 'node-fetch'; | ||
const JSONContentType = 'application/json'; | ||
interface APISuccessResult { | ||
@@ -39,3 +41,3 @@ data: any; | ||
async call<T>( | ||
async post<T>( | ||
path: string, | ||
@@ -45,9 +47,23 @@ data: unknown, | ||
): Promise<T> { | ||
return this.call('POST', path, JSON.stringify(data), ignoreAccessToken); | ||
} | ||
async upload<T>(path: string, data: Buffer, type: string): Promise<T> { | ||
return this.call('POST', path, data, false, type); | ||
} | ||
async call<T>( | ||
method: string, | ||
path: string, | ||
body: BodyInit, | ||
ignoreAccessToken = false, | ||
type = JSONContentType, | ||
): Promise<T> { | ||
let url = this.getURL(path); | ||
let response = await fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify(data), | ||
method, | ||
body, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Content-Type': type, | ||
...(ignoreAccessToken | ||
@@ -54,0 +70,0 @@ ? undefined |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33084
38
744
5
+ Addedmime@^2.4.6
+ Addedmime@2.6.0(transitive)