@forge/api
Advanced tools
Comparing version 0.0.0-experimental-819498d to 0.0.0-experimental-906222c
# @forge/api | ||
## 0.0.0-experimental-819498d | ||
## 0.0.0-experimental-906222c | ||
### Minor Changes | ||
- 906222c: Add new resolvers | ||
## 2.2.0 | ||
### Minor Changes | ||
- 5dcb9bd: Routes can be passed to api.fetch. Routes can be partially-constructed using other Routes. | ||
## 2.2.0-next.0 | ||
### Minor Changes | ||
- 5dcb9bd: Routes can be passed to api.fetch. Routes can be partially-constructed using other Routes. | ||
## 2.1.0 | ||
### Minor Changes | ||
- 339a8ad: Export StorageAPI interface | ||
- 390e3d0: Add authorize API | ||
### Patch Changes | ||
- fef6d3a: Export Route as type for @forge/api | ||
- 85ce23a: Update error message and build config | ||
- Updated dependencies [5ff60ec] | ||
- Updated dependencies [4eda18e] | ||
- Updated dependencies [85ce23a] | ||
- Updated dependencies [2d3bec6] | ||
- @forge/storage@1.0.4 | ||
- @forge/auth@0.0.1 | ||
## 2.1.0-next.4 | ||
### Patch Changes | ||
- 85ce23a: Update error message and build config | ||
- Updated dependencies [85ce23a] | ||
- @forge/auth@0.0.1-next.2 | ||
## 2.1.0-next.3 | ||
### Minor Changes | ||
- 390e3d0: Add authorize API | ||
### Patch Changes | ||
- Updated dependencies [4eda18e] | ||
- @forge/auth@0.0.1-next.0 | ||
## 2.1.0-next.2 | ||
### Patch Changes | ||
- fef6d3a: Export Route as type for @forge/api | ||
## 2.1.0-next.1 | ||
### Minor Changes | ||
- 339a8ad: Export StorageAPI interface | ||
## 2.0.2-next.0 | ||
### Patch Changes | ||
- Updated dependencies [5ff60ec] | ||
- @forge/storage@1.0.4-next.0 | ||
## 2.0.1 | ||
### Patch Changes | ||
- d3d180e: Remove engines limitation | ||
## 2.0.1-next.0 | ||
### Patch Changes | ||
- d3d180e: Remove engines limitation | ||
## 2.0.0 | ||
### Major Changes | ||
- 4ae62248a: `@forge/api` requires usage of a new route helper when calling requestJira/requestConfluence | ||
## 1.2.0 | ||
### Minor Changes | ||
- 2ede277: Add new getWebTriggerUrl runtime API method | ||
- 78effb2: Remove engines.node declaration | ||
@@ -13,5 +104,4 @@ ### Patch Changes | ||
- b0ae6aa: Fix properties onConfluenceSpace for personal spaces | ||
- Updated dependencies [78effb2] | ||
- Updated dependencies [9b496aa] | ||
- @forge/storage@0.0.0-experimental-819498d | ||
- @forge/storage@1.0.3 | ||
@@ -18,0 +108,0 @@ ## 1.2.0-next.2 |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "transformResponse", { enumerable: true, get: function () { return polyfill_response_1.transformResponse; } }); | ||
const safeUrl_1 = require("../safeUrl"); | ||
const wrapRequestGraph = (requestGraphApi) => (query, variables) => requestGraphApi('/graphql', { | ||
@@ -12,15 +13,23 @@ method: 'POST', | ||
}); | ||
const wrapRequestProduct = (requestProduct) => (path, init) => { | ||
const safeUrl = safeUrl_1.requireSafeUrl(path); | ||
return requestProduct(safeUrl.value, init); | ||
}; | ||
const wrapWithRouteUnwrapper = (fetch) => (path, init) => { | ||
const stringPath = safeUrl_1.isRoute(path) ? path.value : path; | ||
return fetch(stringPath, init); | ||
}; | ||
exports.wrapFetchApiMethods = (api, wrapFetch) => { | ||
return { | ||
fetch: wrapFetch(api.fetch), | ||
requestJira: wrapFetch(api.requestJira), | ||
requestConfluence: wrapFetch(api.requestConfluence), | ||
fetch: wrapWithRouteUnwrapper(wrapFetch(api.fetch)), | ||
requestJira: wrapRequestProduct(wrapFetch(api.requestJira)), | ||
requestConfluence: wrapRequestProduct(wrapFetch(api.requestConfluence)), | ||
asUser: () => ({ | ||
requestJira: wrapFetch(api.asUser().requestJira), | ||
requestConfluence: wrapFetch(api.asUser().requestConfluence), | ||
requestJira: wrapRequestProduct(wrapFetch(api.asUser().requestJira)), | ||
requestConfluence: wrapRequestProduct(wrapFetch(api.asUser().requestConfluence)), | ||
requestGraph: wrapRequestGraph(wrapFetch(api.asUser().requestGraph)) | ||
}), | ||
asApp: () => ({ | ||
requestJira: wrapFetch(api.asApp().requestJira), | ||
requestConfluence: wrapFetch(api.asApp().requestConfluence), | ||
requestJira: wrapRequestProduct(wrapFetch(api.asApp().requestJira)), | ||
requestConfluence: wrapRequestProduct(wrapFetch(api.asApp().requestConfluence)), | ||
requestGraph: wrapRequestGraph(wrapFetch(api.asApp().requestGraph)) | ||
@@ -27,0 +36,0 @@ }) |
import { RequestInit, Response } from 'node-fetch'; | ||
import { QueryApi } from '@forge/storage'; | ||
import { authorize } from './authorization'; | ||
import { Route } from './safeUrl'; | ||
import { webTrigger } from './webTrigger'; | ||
import { QueryApi } from '@forge/storage'; | ||
export declare type APIResponse = Pick<Response, 'json' | 'text' | 'arrayBuffer' | 'ok' | 'status' | 'statusText' | 'headers'>; | ||
export declare type FetchMethod = (url: string, init?: RequestInit) => Promise<APIResponse>; | ||
export declare type FetchMethodAllowingRoute = (url: string | Route, init?: RequestInit) => Promise<APIResponse>; | ||
export declare type RequestProductMethod = (url: Route, init?: RequestInit) => Promise<APIResponse>; | ||
export declare type FetchOptions = RequestInit; | ||
export interface FetchMethods { | ||
requestJira: FetchMethod; | ||
requestConfluence: FetchMethod; | ||
export interface RequestProductMethods { | ||
requestJira: RequestProductMethod; | ||
requestConfluence: RequestProductMethod; | ||
} | ||
@@ -25,3 +29,3 @@ export interface GraphQLFetchMethods { | ||
} | ||
interface StorageAPI extends StorageMethods, QueryApi { | ||
export interface StorageAPI extends StorageMethods, QueryApi { | ||
} | ||
@@ -34,6 +38,6 @@ export interface StoreAPI extends PropertiesAPI { | ||
} | ||
export interface FetchAPI extends FetchMethods { | ||
asUser(): FetchMethods & GraphQLFetchMethods; | ||
asApp(): FetchMethods & GraphQLFetchMethods; | ||
fetch: FetchMethod; | ||
export interface FetchAPI extends RequestProductMethods { | ||
asUser(): RequestProductMethods & GraphQLFetchMethods; | ||
asApp(): RequestProductMethods & GraphQLFetchMethods; | ||
fetch: FetchMethodAllowingRoute; | ||
} | ||
@@ -43,7 +47,7 @@ export interface ForgeAPI extends FetchAPI { | ||
} | ||
declare const asUser: () => FetchMethods & GraphQLFetchMethods; | ||
declare const asApp: () => FetchMethods & GraphQLFetchMethods; | ||
declare const fetch: FetchMethod; | ||
declare const requestJira: FetchMethod; | ||
declare const requestConfluence: FetchMethod; | ||
declare const asUser: () => RequestProductMethods & GraphQLFetchMethods; | ||
declare const asApp: () => RequestProductMethods & GraphQLFetchMethods; | ||
declare const fetch: FetchMethodAllowingRoute; | ||
declare const requestJira: RequestProductMethod; | ||
declare const requestConfluence: RequestProductMethod; | ||
declare const store: PropertiesAPI; | ||
@@ -57,5 +61,6 @@ declare const storage: StorageAPI; | ||
export default API; | ||
export { asUser, asApp, fetch, requestJira, requestConfluence, store, storage, properties, webTrigger }; | ||
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, store, storage, properties, webTrigger }; | ||
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Value } from '@forge/storage'; | ||
export { startsWith } from '@forge/storage'; | ||
export { route, assumeTrustedRoute, Route } from './safeUrl'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestConfluence = exports.requestJira = exports.fetch = exports.asApp = exports.asUser = exports.privacy = void 0; | ||
exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0; | ||
const storage_1 = require("@forge/storage"); | ||
const api_1 = require("./api"); | ||
const authorization_1 = require("./authorization"); | ||
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } }); | ||
const properties_1 = require("./properties"); | ||
@@ -9,3 +12,2 @@ const privacy_1 = require("./privacy"); | ||
Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function () { return webTrigger_1.webTrigger; } }); | ||
const storage_1 = require("@forge/storage"); | ||
function withDeprecatedMessage(method, message) { | ||
@@ -50,1 +52,4 @@ const wrappedMethod = (...args) => { | ||
Object.defineProperty(exports, "startsWith", { enumerable: true, get: function () { return storage_2.startsWith; } }); | ||
var safeUrl_1 = require("./safeUrl"); | ||
Object.defineProperty(exports, "route", { enumerable: true, get: function () { return safeUrl_1.route; } }); | ||
Object.defineProperty(exports, "assumeTrustedRoute", { enumerable: true, get: function () { return safeUrl_1.assumeTrustedRoute; } }); |
@@ -1,8 +0,7 @@ | ||
import { FetchMethod } from '../index'; | ||
import { RequestProductMethod } from '../index'; | ||
import { ConfluenceVersionedStorage } from './confluence-versioned-storage'; | ||
export declare class ConfluencePageStorage extends ConfluenceVersionedStorage { | ||
private static readonly API_PATH; | ||
constructor(pageId: string, apiClient: FetchMethod); | ||
constructor(pageId: string, apiClient: RequestProductMethod); | ||
set(key: string, value: any): Promise<void>; | ||
} | ||
//# sourceMappingURL=confluence-page.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConfluencePageStorage = void 0; | ||
const safeUrl_1 = require("../safeUrl"); | ||
const confluence_versioned_storage_1 = require("./confluence-versioned-storage"); | ||
class ConfluencePageStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage { | ||
constructor(pageId, apiClient) { | ||
const storageApiPath = `${ConfluencePageStorage.API_PATH}${pageId}/property`; | ||
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/content/${pageId}/property/${key}`; | ||
super(storageApiPath, apiClient); | ||
@@ -15,2 +16,1 @@ } | ||
exports.ConfluencePageStorage = ConfluencePageStorage; | ||
ConfluencePageStorage.API_PATH = '/wiki/rest/api/content/'; |
@@ -1,8 +0,7 @@ | ||
import { FetchMethod } from '../index'; | ||
import { RequestProductMethod } from '../index'; | ||
import { ConfluenceVersionedStorage } from './confluence-versioned-storage'; | ||
export declare class ConfluenceSpaceStorage extends ConfluenceVersionedStorage { | ||
private static readonly API_PATH; | ||
constructor(spaceId: string, apiClient: FetchMethod); | ||
constructor(spaceId: string, apiClient: RequestProductMethod); | ||
set(key: string, value: any): Promise<void>; | ||
} | ||
//# sourceMappingURL=confluence-space.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConfluenceSpaceStorage = void 0; | ||
const safeUrl_1 = require("../safeUrl"); | ||
const confluence_versioned_storage_1 = require("./confluence-versioned-storage"); | ||
class ConfluenceSpaceStorage extends confluence_versioned_storage_1.ConfluenceVersionedStorage { | ||
constructor(spaceId, apiClient) { | ||
const storageApiPath = `${ConfluenceSpaceStorage.API_PATH}${spaceId}/property`; | ||
const storageApiPath = (key) => safeUrl_1.route `/wiki/rest/api/space/${spaceId}/property/${key}`; | ||
super(storageApiPath, apiClient); | ||
@@ -15,2 +16,1 @@ } | ||
exports.ConfluenceSpaceStorage = ConfluenceSpaceStorage; | ||
ConfluenceSpaceStorage.API_PATH = '/wiki/rest/api/space/'; |
@@ -8,3 +8,3 @@ "use strict"; | ||
async versionedSet(key, value) { | ||
const versionResponse = await this.apiClient(`${this.storageApiPath}/${key}`); | ||
const versionResponse = await this.apiClient(this.storageApiPath(key)); | ||
if (!versionResponse.ok && versionResponse.status !== 404) { | ||
@@ -21,3 +21,3 @@ throw storage_1.APIError.forStatus(versionResponse.status); | ||
}; | ||
await this.apiClient(`${this.storageApiPath}/${key}`, this.buildSetRequestOptions(requestBody, requestMethod)); | ||
await this.apiClient(this.storageApiPath(key), this.buildSetRequestOptions(requestBody, requestMethod)); | ||
} | ||
@@ -24,0 +24,0 @@ async getUpdatedVersion(versionResponse) { |
import { ProductScopedStorage } from './product-scoped-storage'; | ||
import { FetchMethod } from '../index'; | ||
import { RequestProductMethod } from '../index'; | ||
export declare class JiraIssueStorage extends ProductScopedStorage { | ||
private static readonly API_PATH; | ||
constructor(issueKey: string, apiClient: FetchMethod); | ||
constructor(issueKey: string, apiClient: RequestProductMethod); | ||
} | ||
//# sourceMappingURL=jira-issue.d.ts.map |
@@ -5,5 +5,6 @@ "use strict"; | ||
const product_scoped_storage_1 = require("./product-scoped-storage"); | ||
const safeUrl_1 = require("../safeUrl"); | ||
class JiraIssueStorage extends product_scoped_storage_1.ProductScopedStorage { | ||
constructor(issueKey, apiClient) { | ||
const storageApiPath = `${JiraIssueStorage.API_PATH}${issueKey}/properties`; | ||
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/issue/${issueKey}/properties/${key}`; | ||
super(storageApiPath, apiClient); | ||
@@ -13,2 +14,1 @@ } | ||
exports.JiraIssueStorage = JiraIssueStorage; | ||
JiraIssueStorage.API_PATH = '/rest/api/3/issue/'; |
import { ProductScopedStorage } from './product-scoped-storage'; | ||
import { FetchMethod } from '../index'; | ||
import { RequestProductMethod } from '../index'; | ||
export declare class JiraProjectStorage extends ProductScopedStorage { | ||
private static readonly API_PATH; | ||
constructor(projectKey: string, apiClient: FetchMethod); | ||
constructor(projectKey: string, apiClient: RequestProductMethod); | ||
} | ||
//# sourceMappingURL=jira-project.d.ts.map |
@@ -5,5 +5,6 @@ "use strict"; | ||
const product_scoped_storage_1 = require("./product-scoped-storage"); | ||
const safeUrl_1 = require("../safeUrl"); | ||
class JiraProjectStorage extends product_scoped_storage_1.ProductScopedStorage { | ||
constructor(projectKey, apiClient) { | ||
const storageApiPath = `${JiraProjectStorage.API_PATH}${projectKey}/properties`; | ||
const storageApiPath = (key) => safeUrl_1.route `/rest/api/3/project/${projectKey}/properties/${key}`; | ||
super(storageApiPath, apiClient); | ||
@@ -13,2 +14,1 @@ } | ||
exports.JiraProjectStorage = JiraProjectStorage; | ||
JiraProjectStorage.API_PATH = '/rest/api/3/project/'; |
import { StorageAdapter } from './storage-adapter'; | ||
import { FetchMethod } from '../index'; | ||
import { RequestProductMethod } from '../index'; | ||
import { Route } from '../safeUrl'; | ||
export declare class ProductScopedStorage implements StorageAdapter { | ||
protected storageApiPath: string; | ||
protected apiClient: FetchMethod; | ||
constructor(storageApiPath: string, apiClient: FetchMethod); | ||
protected storageApiPath: (key: string) => Route; | ||
protected apiClient: RequestProductMethod; | ||
constructor(storageApiPath: (key: string) => Route, apiClient: RequestProductMethod); | ||
get(key: string): Promise<any>; | ||
@@ -8,0 +9,0 @@ set(key: string, value: any): Promise<void>; |
@@ -11,3 +11,3 @@ "use strict"; | ||
async get(key) { | ||
const response = await this.apiClient(`${this.storageApiPath}/${key}`); | ||
const response = await this.apiClient(this.storageApiPath(key)); | ||
if (!response.ok) { | ||
@@ -23,3 +23,3 @@ if (/400|401|403|404/.test(response.status.toString())) { | ||
async set(key, value) { | ||
const response = await this.apiClient(`${this.storageApiPath}/${key}`, this.buildSetRequestOptions(value, 'PUT')); | ||
const response = await this.apiClient(this.storageApiPath(key), this.buildSetRequestOptions(value, 'PUT')); | ||
if (!response.ok) { | ||
@@ -30,3 +30,3 @@ throw storage_1.APIError.forStatus(response.status); | ||
async delete(key) { | ||
const response = await this.apiClient(`${this.storageApiPath}/${key}`, { method: 'DELETE' }); | ||
const response = await this.apiClient(this.storageApiPath(key), { method: 'DELETE' }); | ||
if (!response.ok) { | ||
@@ -33,0 +33,0 @@ throw storage_1.APIError.forStatus(response.status); |
interface WebTriggerAPI { | ||
getUrl: (webTriggerModuleKey: string) => Promise<string>; | ||
getApiUrl: (webTriggerModuleKey: string) => Promise<string>; | ||
} | ||
@@ -4,0 +5,0 @@ export declare const webTrigger: WebTriggerAPI; |
@@ -7,3 +7,7 @@ "use strict"; | ||
return global.api.webTrigger.getUrl(webTriggerModuleKey); | ||
}, | ||
getApiUrl: async (webTriggerModuleKey) => { | ||
const url = await exports.webTrigger.getUrl(webTriggerModuleKey); | ||
return url.replace('/x1', '/api'); | ||
} | ||
}; |
{ | ||
"name": "@forge/api", | ||
"version": "0.0.0-experimental-819498d", | ||
"version": "0.0.0-experimental-906222c", | ||
"description": "Forge API methods", | ||
@@ -18,3 +18,4 @@ "author": "Atlassian", | ||
"dependencies": { | ||
"@forge/storage": "^0.0.0-experimental-819498d", | ||
"@forge/auth": "^0.0.1", | ||
"@forge/storage": "^1.0.4", | ||
"@types/node-fetch": "^2.5.7", | ||
@@ -21,0 +22,0 @@ "node-fetch": "^2.6.1" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
41387
51
527
4
3
+ Added@forge/auth@^0.0.1
+ Added@forge/auth@0.0.1(transitive)
+ Added@forge/storage@1.6.0(transitive)
+ Addedtslib@1.14.1(transitive)
- Removed@forge/storage@0.0.0-experimental-f85f9b1(transitive)
Updated@forge/storage@^1.0.4