New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@forge/api

Package Overview
Dependencies
Maintainers
2
Versions
382
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/api - npm Package Compare versions

Comparing version 0.0.0-experimental-3ab06ec to 0.0.0-experimental-4515339

out/api/errors.d.ts

387

CHANGELOG.md
# @forge/api
## 0.0.0-experimental-3ab06ec
## 0.0.0-experimental-4515339
### Minor Changes
- 3a1dd86: Move API errors to @forge/api package
- df3811d: Handle NeedsAuthError returned from the proxy for Runtime v2
### Patch Changes
- dfab69c: Add NodeJS runtime support for Events API
- Updated dependencies [aa19308]
- @forge/egress@0.0.0-experimental-4515339
## 2.11.0-next.2
### Minor Changes
- 3a1dd86: Move API errors to @forge/api package
- df3811d: Handle NeedsAuthError returned from the proxy for Runtime v2
## 2.10.1-next.1
### Patch Changes
- Updated dependencies [aa193085]
- @forge/egress@1.1.2-next.0
## 2.10.1-next.0
### Patch Changes
- dfab69c: Add NodeJS runtime support for Events API
## 2.10.0
### Minor Changes
- e0e3587: Add NodeJS runtime support for Storage API
### Patch Changes
- 37f48c5: Fix contextAri for nodejs runtime
- ca8551d: Fix proxy fetch not respecting requestInit options
## 2.10.0-next.2
### Patch Changes
- 37f48c5: Fix contextAri for nodejs runtime
## 2.10.0-next.1
### Minor Changes
- e0e3587a: Add NodeJS runtime support for Storage API
## 2.9.2-next.0
### Patch Changes
- ca8551dd: Fix proxy fetch not respecting requestInit options
## 2.9.1
### Patch Changes
- 73b929a: Export routeFromAbsolute
- 8d0dc10: Use a single global to pass information from the runtime
- 7a4fa35: Support internet egress calls in the new runtime
## 2.9.1-next.2
### Patch Changes
- 8d0dc104: Use a single global to pass information from the runtime
## 2.9.1-next.1
### Patch Changes
- 73b929a: Export routeFromAbsolute
## 2.9.1-next.0
### Patch Changes
- 7a4fa35: Support internet egress calls in the new runtime
## 2.9.0
### Minor Changes
- e5dd325: support for requestBitbucket
## 2.9.0-next.0
### Minor Changes
- e5dd325d: support for requestBitbucket
## 2.8.1
### Patch Changes
- 8e2a5a6: Update node-fetch version
- Updated dependencies [8e2a5a6]
- @forge/storage@1.3.1
## 2.8.1-next.0
### Patch Changes
- 8e2a5a6: Update node-fetch version
- Updated dependencies [8e2a5a6]
- @forge/storage@1.3.1-next.0
## 2.8.0
### Minor Changes
- 95913f6: Call product APIs via proxy on Node runtime
## 2.8.0-next.0
### Minor Changes
- 95913f6: Call product APIs via proxy on Node runtime
## 2.7.0
### Minor Changes
- b3ee297: Unblock valid property API keys and handled error propagation
### Patch Changes
- Updated dependencies [3c3c42b]
- @forge/storage@1.3.0
## 2.7.0-next.0
### Minor Changes
- b3ee2973: Unblock valid property API keys and handled error propagation
### Patch Changes
- Updated dependencies [3c3c42b9]
- @forge/storage@1.3.0-next.0
## 2.6.1
### Patch Changes
- Updated dependencies [21e392d]
- @forge/storage@1.2.0
## 2.6.1-next.0
### Patch Changes
- Updated dependencies [21e392d]
- @forge/storage@1.2.0-next.0
## 2.6.0
### Minor Changes
- 8571c05: Add support for multiple accounts in external authentication
## 2.6.0-next.0
### Minor Changes
- 8571c05: Add support for multiple accounts in external authentication
## 2.5.0
### Minor Changes
- 70e9c8c: Enable auth providers api
### Patch Changes
- 32d11d1: Fix types on external auth APIs
## 2.5.0-next.1
### Patch Changes
- 32d11d1: Fix types on external auth APIs
## 2.5.0-next.0
### Minor Changes
- df2cd2f: Enable auth providers api
## 2.4.0
## 2.4.0-next.0
### Minor Changes
- de02d45: Enable auth providers api
## 2.3.0
### Minor Changes
- 0d7fe27: Support secret storage API
### Patch Changes
- df58629: Allow custom headers in requestGraph
- Updated dependencies [0d7fe27]
- @forge/storage@1.1.0
## 2.3.0-next.1
### Patch Changes
- df58629: Allow custom headers in requestGraph
## 2.3.0-next.0
### Minor Changes
- 0d7fe27: Support secret storage API
### Patch Changes
- Updated dependencies [0d7fe27]
- @forge/storage@1.1.0-next.0
## 2.2.1
### Patch Changes
- Updated dependencies [0700578]
- @forge/storage@1.0.5
## 2.2.1-next.0
### Patch Changes
- Updated dependencies [0700578]
- @forge/storage@1.0.5-next.0
## 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
### Patch Changes
- b0ae6aa: Fix properties onConfluenceSpace for personal spaces
- Updated dependencies [9b496aa]
- @forge/storage@1.0.3
## 1.2.0-next.2
### Patch Changes
- Updated dependencies [9b496aa]
- @forge/storage@1.0.3-next.0
## 1.2.0-next.1
### Minor Changes
- 2ede277: Add new getWebTriggerUrl runtime API method
## 1.1.1-next.0
### Patch Changes
- b0ae6aa: Fix properties onConfluenceSpace for personal spaces
## 1.1.0
### Minor Changes
- 2136fd7: Adds reportPersonalData method to forge help apps comply with GDPR
- ba442a3: Add requestGraph method to fetch api.
### Patch Changes
- Updated dependencies [c7c6de2]
- @forge/storage@1.0.2
## 1.1.0-next.2
### Patch Changes
- Updated dependencies [c7c6de2]
- @forge/storage@1.0.2-next.0
## 1.1.0-next.1
### Minor Changes
- ba442a3: Add requestGraph method to fetch api.
## 1.1.0-next.0

@@ -10,0 +395,0 @@

8

out/api/index.d.ts
import { RequestInfo, RequestInit } from 'node-fetch';
import { FetchAPI } from '..';
export { transformResponse } from './polyfill-response';
export declare type FetchWrapper = (fetchApi: Function) => (url: RequestInfo, init?: RequestInit) => any;
import { FetchAPI, FetchMethod, RequestProductMethod, FetchMethodAllowingRoute, APIResponse } from '..';
export declare type FetchWrapper = (fetchApi: Function) => (url: RequestInfo, init?: RequestInit) => Promise<APIResponse>;
export declare const wrapRequestGraph: (requestGraphApi: FetchMethod) => (query: string, variables?: any, headers?: {}) => Promise<APIResponse>;
export declare const wrapRequestProduct: (x: FetchMethod) => RequestProductMethod;
export declare const wrapWithRouteUnwrapper: (x: FetchMethod) => FetchMethodAllowingRoute;
export declare const wrapFetchApiMethods: (api: any, wrapFetch: FetchWrapper) => FetchAPI;
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapFetchApiMethods = void 0;
var polyfill_response_1 = require("./polyfill-response");
Object.defineProperty(exports, "transformResponse", { enumerable: true, get: function () { return polyfill_response_1.transformResponse; } });
exports.wrapFetchApiMethods = (api, wrapFetch) => {
exports.wrapFetchApiMethods = exports.wrapWithRouteUnwrapper = exports.wrapRequestProduct = exports.wrapRequestGraph = void 0;
const safeUrl_1 = require("../safeUrl");
const wrapRequestGraph = (requestGraphApi) => (query, variables, headers = {}) => requestGraphApi('/graphql', {
method: 'POST',
headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
body: JSON.stringify(Object.assign({ query }, (variables ? { variables } : {})))
});
exports.wrapRequestGraph = wrapRequestGraph;
const wrapRequestProduct = (requestProduct) => (path, init) => {
const safeUrl = (0, safeUrl_1.requireSafeUrl)(path);
return requestProduct(safeUrl.value, init);
};
exports.wrapRequestProduct = wrapRequestProduct;
const wrapWithRouteUnwrapper = (fetch) => (path, init) => {
const stringPath = (0, safeUrl_1.isRoute)(path) ? path.value : path;
return fetch(stringPath, init);
};
exports.wrapWithRouteUnwrapper = wrapWithRouteUnwrapper;
const wrapFetchApiMethods = (api, wrapFetch) => {
return {
fetch: wrapFetch(api.fetch),
requestJira: wrapFetch(api.requestJira),
requestConfluence: wrapFetch(api.requestConfluence),
fetch: (0, exports.wrapWithRouteUnwrapper)(wrapFetch(api.fetch)),
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.requestJira)),
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.requestConfluence)),
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.requestBitbucket)),
asUser: () => ({
requestJira: wrapFetch(api.asUser().requestJira),
requestConfluence: wrapFetch(api.asUser().requestConfluence)
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestJira)),
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestConfluence)),
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.asUser().requestBitbucket)),
requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asUser().requestGraph)),
withProvider: (provider, remoteName, tokenId) => {
const { hasCredentials, requestCredentials, listCredentials, fetch: withProviderFetch } = api.asUser().withProvider(provider, remoteName, tokenId);
const wrappedRequestRemote = (0, exports.wrapWithRouteUnwrapper)(wrapFetch(withProviderFetch));
return {
hasCredentials,
requestCredentials,
listCredentials,
fetch: wrappedRequestRemote
};
}
}),
asApp: () => ({
requestJira: wrapFetch(api.asApp().requestJira),
requestConfluence: wrapFetch(api.asApp().requestConfluence)
requestJira: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestJira)),
requestConfluence: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestConfluence)),
requestGraph: (0, exports.wrapRequestGraph)(wrapFetch(api.asApp().requestGraph)),
requestBitbucket: (0, exports.wrapRequestProduct)(wrapFetch(api.asApp().requestBitbucket))
})
};
};
exports.wrapFetchApiMethods = wrapFetchApiMethods;

@@ -5,5 +5,6 @@ "use strict";

const node_fetch_1 = require("node-fetch");
exports.transformResponse = (fetchApi) => async (url, init) => {
const transformResponse = (fetchApi) => async (url, init) => {
const response = await fetchApi(url, init);
return Object.assign(Object.assign({}, response), { headers: new node_fetch_1.Headers(response.headers) });
};
exports.transformResponse = transformResponse;
import { RequestInit, Response } from 'node-fetch';
import { QueryApi } from '@forge/storage';
import { authorize } from './authorization';
import { Route } from './safeUrl';
import { webTrigger } from './webTrigger';
import { createRequestStargateAsApp } from './runtime/fetch-and-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;
requestBitbucket: RequestProductMethod;
}
export interface GraphQLFetchMethods {
requestGraph: (query: string, variables?: any, headers?: Record<string, any>) => Promise<APIResponse>;
}
export interface ExternalAuthFetchMethods {
hasCredentials: () => Promise<boolean>;
requestCredentials: () => Promise<boolean>;
listCredentials: () => Promise<string[]>;
fetch: FetchMethodAllowingRoute;
}
export interface ExternalAuthFetchMethodsProvider {
withProvider: (provider: string, remoteName?: string, tokenId?: string) => ExternalAuthFetchMethods;
}
export interface StorageMethods {

@@ -21,4 +40,9 @@ get: (key: string) => Promise<any>;

}
interface StorageAPI extends StorageMethods, QueryApi {
export interface StorageAPI extends StorageMethods, QueryApi {
}
export interface ForgeStorageAPI extends StorageAPI {
getSecret: (key: string) => Promise<any>;
setSecret: (key: string, value: any) => Promise<void>;
deleteSecret: (key: string) => Promise<void>;
}
export interface StoreAPI extends PropertiesAPI {

@@ -30,6 +54,6 @@ onJiraProject: (context: string) => StorageMethods;

}
export interface FetchAPI extends FetchMethods {
asUser(): FetchMethods;
asApp(): FetchMethods;
fetch: FetchMethod;
export interface FetchAPI extends RequestProductMethods {
asUser(): RequestProductMethods & GraphQLFetchMethods & ExternalAuthFetchMethodsProvider;
asApp(): RequestProductMethods & GraphQLFetchMethods;
fetch: FetchMethodAllowingRoute;
}

@@ -39,9 +63,18 @@ export interface ForgeAPI extends FetchAPI {

}
declare const asUser: () => FetchMethods;
declare const asApp: () => FetchMethods;
declare const fetch: FetchMethod;
declare const requestJira: FetchMethod;
declare const requestConfluence: FetchMethod;
declare const asUser: () => RequestProductMethods & GraphQLFetchMethods & ExternalAuthFetchMethodsProvider;
declare const asApp: () => RequestProductMethods & GraphQLFetchMethods;
declare const fetch: FetchMethodAllowingRoute;
declare const requestJira: RequestProductMethod;
declare const requestConfluence: RequestProductMethod;
declare const requestBitbucket: RequestProductMethod;
declare const store: PropertiesAPI;
declare const storage: StorageAPI;
declare const storage: {
get: (key: string) => Promise<any>;
set: (key: string, value: any) => Promise<void>;
delete: (key: string) => Promise<void>;
getSecret: (key: string) => Promise<any>;
setSecret: (key: string, value: any) => Promise<void>;
deleteSecret: (key: string) => Promise<void>;
query: () => import("packages/forge-storage/out/query-api").DefaultQueryBuilder;
};
declare const properties: PropertiesAPI;

@@ -53,5 +86,8 @@ declare const API: ForgeAPI;

export default API;
export { asUser, asApp, fetch, requestJira, requestConfluence, store, storage, properties };
export { asUser, asApp, authorize, fetch, requestJira, requestConfluence, requestBitbucket, store, storage, properties, webTrigger, createRequestStargateAsApp };
export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, Value } from '@forge/storage';
export { startsWith } from '@forge/storage';
export { route, assumeTrustedRoute, routeFromAbsolute, Route } from './safeUrl';
export { ForgeRuntime, getRuntime } from './api/runtime';
export { NeedsAuthenticationError, ProxyRequestError, FetchError, ExternalEndpointNotAllowedError, ProductEndpointNotAllowedError, RequestProductNotAllowedError, NotAllowedError, InvalidWorkspaceRequestedError, HttpError, FUNCTION_ERR, isForgePlatformError, isHostedCodeError } from './api/errors';
//# sourceMappingURL=index.d.ts.map
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.properties = exports.storage = exports.store = exports.requestConfluence = exports.requestJira = exports.fetch = exports.asApp = exports.asUser = exports.privacy = void 0;
const api_1 = require("./api");
exports.isHostedCodeError = exports.isForgePlatformError = exports.FUNCTION_ERR = exports.HttpError = exports.InvalidWorkspaceRequestedError = exports.NotAllowedError = exports.RequestProductNotAllowedError = exports.ProductEndpointNotAllowedError = exports.ExternalEndpointNotAllowedError = exports.FetchError = exports.ProxyRequestError = exports.NeedsAuthenticationError = exports.getRuntime = exports.routeFromAbsolute = exports.assumeTrustedRoute = exports.route = exports.startsWith = exports.createRequestStargateAsApp = exports.webTrigger = exports.properties = exports.storage = exports.store = exports.requestBitbucket = exports.requestConfluence = exports.requestJira = exports.fetch = exports.authorize = exports.asApp = exports.asUser = exports.privacy = void 0;
const storage_1 = require("@forge/storage");
const authorization_1 = require("./authorization");
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorization_1.authorize; } });
const properties_1 = require("./properties");
const privacy_1 = require("./privacy");
const storage_1 = require("@forge/storage");
const webTrigger_1 = require("./webTrigger");
Object.defineProperty(exports, "webTrigger", { enumerable: true, get: function () { return webTrigger_1.webTrigger; } });
const fetch_and_storage_1 = require("./runtime/fetch-and-storage");
Object.defineProperty(exports, "createRequestStargateAsApp", { enumerable: true, get: function () { return fetch_and_storage_1.createRequestStargateAsApp; } });
function withDeprecatedMessage(method, message) {

@@ -15,13 +21,15 @@ const wrappedMethod = (...args) => {

}
const FetchAPI = api_1.wrapFetchApiMethods(global.api, api_1.transformResponse);
const asUser = FetchAPI.asUser;
const fetchAPI = (0, fetch_and_storage_1.getFetchAPI)();
const asUser = fetchAPI.asUser;
exports.asUser = asUser;
const asApp = FetchAPI.asApp;
const asApp = fetchAPI.asApp;
exports.asApp = asApp;
const fetch = FetchAPI.fetch;
const fetch = fetchAPI.fetch;
exports.fetch = fetch;
const requestJira = FetchAPI.requestJira;
const requestJira = fetchAPI.requestJira;
exports.requestJira = requestJira;
const requestConfluence = FetchAPI.requestConfluence;
const requestConfluence = fetchAPI.requestConfluence;
exports.requestConfluence = requestConfluence;
const requestBitbucket = fetchAPI.requestBitbucket;
exports.requestBitbucket = requestBitbucket;
const deprecatedPropertiesApi = Object.entries(properties_1.propertiesApi)

@@ -37,9 +45,9 @@ .map(([name, method]) => {

exports.store = store;
const storage = storage_1.getStorageInstanceWithQuery(new storage_1.GlobalStorage(global.api.__getAppAri, global.api.asApp().__requestAtlassian));
const storage = (0, storage_1.getStorageInstanceWithQuery)(new storage_1.GlobalStorage(fetch_and_storage_1.getContextAri, (0, fetch_and_storage_1.createRequestStargateAsApp)()));
exports.storage = storage;
const properties = properties_1.propertiesApi;
exports.properties = properties;
const API = Object.assign(Object.assign({}, FetchAPI), { store: Object.assign({}, store) });
const API = Object.assign(Object.assign({}, fetchAPI), { store: Object.assign({}, store) });
exports.privacy = {
reportPersonalData: privacy_1.createReportPersonalData(global.api.asApp().__requestAtlassian)
reportPersonalData: (0, privacy_1.createReportPersonalData)((_a = global.api) === null || _a === void 0 ? void 0 : _a.asApp().__requestAtlassian)
};

@@ -49,1 +57,20 @@ exports.default = API;

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; } });
Object.defineProperty(exports, "routeFromAbsolute", { enumerable: true, get: function () { return safeUrl_1.routeFromAbsolute; } });
var runtime_1 = require("./api/runtime");
Object.defineProperty(exports, "getRuntime", { enumerable: true, get: function () { return runtime_1.getRuntime; } });
var errors_1 = require("./api/errors");
Object.defineProperty(exports, "NeedsAuthenticationError", { enumerable: true, get: function () { return errors_1.NeedsAuthenticationError; } });
Object.defineProperty(exports, "ProxyRequestError", { enumerable: true, get: function () { return errors_1.ProxyRequestError; } });
Object.defineProperty(exports, "FetchError", { enumerable: true, get: function () { return errors_1.FetchError; } });
Object.defineProperty(exports, "ExternalEndpointNotAllowedError", { enumerable: true, get: function () { return errors_1.ExternalEndpointNotAllowedError; } });
Object.defineProperty(exports, "ProductEndpointNotAllowedError", { enumerable: true, get: function () { return errors_1.ProductEndpointNotAllowedError; } });
Object.defineProperty(exports, "RequestProductNotAllowedError", { enumerable: true, get: function () { return errors_1.RequestProductNotAllowedError; } });
Object.defineProperty(exports, "NotAllowedError", { enumerable: true, get: function () { return errors_1.NotAllowedError; } });
Object.defineProperty(exports, "InvalidWorkspaceRequestedError", { enumerable: true, get: function () { return errors_1.InvalidWorkspaceRequestedError; } });
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
Object.defineProperty(exports, "FUNCTION_ERR", { enumerable: true, get: function () { return errors_1.FUNCTION_ERR; } });
Object.defineProperty(exports, "isForgePlatformError", { enumerable: true, get: function () { return errors_1.isForgePlatformError; } });
Object.defineProperty(exports, "isHostedCodeError", { enumerable: true, get: function () { return errors_1.isHostedCodeError; } });

@@ -6,3 +6,3 @@ "use strict";

exports.LIMIT = 90;
exports.createReportPersonalData = (requestAtlassian) => {
const createReportPersonalData = (requestAtlassian) => {
return function fetchUpdates(accounts) {

@@ -28,1 +28,2 @@ if (accounts.length === 0) {

};
exports.createReportPersonalData = createReportPersonalData;

@@ -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) => (0, 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) => (0, 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) {

@@ -9,14 +9,8 @@ "use strict";

const confluence_space_1 = require("./confluence-space");
const sanitizedKey = (input) => {
const regex = /^[A-Za-z0-9_\-]+$/;
if (!regex.test(input)) {
throw new Error('Invalid context/property key');
}
return input;
};
const sanitized_key_1 = require("./sanitized-key");
const getPropertiesInstance = (adapter) => {
const storage = {
get: (key) => adapter.get(sanitizedKey(key)),
set: (key, value) => adapter.set(sanitizedKey(key), value),
delete: (key) => adapter.delete(sanitizedKey(key))
get: (key) => adapter.get((0, sanitized_key_1.sanitizedKey)(key)),
set: (key, value) => adapter.set((0, sanitized_key_1.sanitizedKey)(key), value),
delete: (key) => adapter.delete((0, sanitized_key_1.sanitizedKey)(key))
};

@@ -26,6 +20,6 @@ return storage;

exports.propertiesApi = {
onJiraIssue: (issueKey) => getPropertiesInstance(new jira_issue_1.JiraIssueStorage(sanitizedKey(issueKey), index_1.asApp().requestJira)),
onJiraProject: (projectKey) => getPropertiesInstance(new jira_project_1.JiraProjectStorage(sanitizedKey(projectKey), index_1.asApp().requestJira)),
onConfluencePage: (pageId) => getPropertiesInstance(new confluence_page_1.ConfluencePageStorage(sanitizedKey(pageId), index_1.asApp().requestConfluence)),
onConfluenceSpace: (spaceId) => getPropertiesInstance(new confluence_space_1.ConfluenceSpaceStorage(sanitizedKey(spaceId), index_1.asApp().requestConfluence))
onJiraIssue: (issueKey) => getPropertiesInstance(new jira_issue_1.JiraIssueStorage((0, sanitized_key_1.sanitizedKey)(issueKey), (0, index_1.asApp)().requestJira)),
onJiraProject: (projectKey) => getPropertiesInstance(new jira_project_1.JiraProjectStorage(projectKey, (0, index_1.asApp)().requestJira)),
onConfluencePage: (pageId) => getPropertiesInstance(new confluence_page_1.ConfluencePageStorage((0, sanitized_key_1.sanitizedKey)(pageId), (0, index_1.asApp)().requestConfluence)),
onConfluenceSpace: (spaceId) => getPropertiesInstance(new confluence_space_1.ConfluenceSpaceStorage((0, sanitized_key_1.sanitizedKey)(spaceId), (0, index_1.asApp)().requestConfluence))
};
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) => (0, 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) => (0, 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,5 +11,5 @@ "use strict";

async get(key) {
const response = await this.apiClient(`${this.storageApiPath}/${key}`);
const response = await this.apiClient(this.storageApiPath(key));
if (!response.ok) {
if (/400|401|403|404/.test(response.status.toString())) {
if (/403|404/.test(response.status.toString())) {
return undefined;

@@ -23,3 +23,3 @@ }

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);

{
"name": "@forge/api",
"version": "0.0.0-experimental-3ab06ec",
"version": "0.0.0-experimental-4515339",
"description": "Forge API methods",

@@ -14,5 +14,2 @@ "author": "Atlassian",

},
"engines": {
"node": "^12"
},
"devDependencies": {

@@ -22,6 +19,8 @@ "@types/node": "^12.12.63"

"dependencies": {
"@forge/storage": "^1.0.1",
"@forge/auth": "^0.0.1",
"@forge/egress": "^0.0.0-experimental-4515339",
"@forge/storage": "^1.3.1",
"@types/node-fetch": "^2.5.7",
"node-fetch": "^2.6.1"
"node-fetch": "2.6.7"
}
}

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc