1.5.15 • Published 29 days ago

@forge/storage v1.5.15

Weekly downloads
329
License
UNLICENSED
Repository
-
Last release
29 days ago

Common library for both Forge environment and Harmonised Connect app environment.

Usage example:

// https://hello.atlassian.net/wiki/spaces/ECO/pages/955640295/Explore+-+Making+a+Hosted+storage+call+from+a+Harmonised+app

import fetch, { RequestInit } from 'node-fetch';

import { GlobalStorage } from './global-storage';
import { APIResponse, getStorageInstanceWithQuery } from './index';

const API_BASE = 'https://api.atlassian.com';

// For user agent header
const version = '0.0.1';
const appAri = 'ari:cloud:ecosystem::app/7746820b-fbb0-48d1-a251-7b802ba1aab8';

// For Storage service auth
const appContextAri = 'ari:cloud:jira::site/dd7fa939-ad77-48c9-894f-bd7da936d769';
const token =
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik16bERNemsxTVRoRlFVRTJRa0ZGT0VGRk9URkJOREJDTVRRek5EZzJSRVpDT1VKRFJrVXdNZyJ9.eyJodHRwczovL2F0bGFzc2lhbi5jb20vc3lzdGVtQWNjb3VudElkIjoiNWZkMDAyZjFmZWU3OTMwMDc1MTRiODFjIiwiaHR0cHM6Ly9hdGxhc3NpYW4uY29tL3N5c3RlbUFjY291bnRFbWFpbCI6IjQ1ZWM2ODE4LWNjNmQtNGI5OC1iOWU4LWZlODI1NDIwZmQ0MUBjb25uZWN0LmF0bGFzc2lhbi5jb20iLCJodHRwczovL2F0bGFzc2lhbi5jb20vZmlyc3RQYXJ0eSI6ZmFsc2UsImh0dHBzOi8vYXRsYXNzaWFuLmNvbS8zbG8iOmZhbHNlLCJpc3MiOiJodHRwczovL2F0bGFzc2lhbi1hY2NvdW50LXByb2QucHVzMi5hdXRoMC5jb20vIiwic3ViIjoiV0dyaDJSZWMwdnBkS25KNEhNM0hMNjk4ckNLS1NFazBAY2xpZW50cyIsImF1ZCI6ImFwaS5hdGxhc3NpYW4uY29tIiwiaWF0IjoxNjA3NDY5OTkzLCJleHAiOjE2MDc0NzM1OTMsImF6cCI6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p0kNDBrwwkijVQWewr3G64LP9nD85TdEFaVxMdEo-eRlaMhNOmvVkkn_9LtzTJD85n_a3MWwAjtLbbBPwNfghzOi_7T6yH7FAa3oOog1IipdmApbFWPPuWIQ';

async function apiClient(path: string, init: RequestInit): Promise<APIResponse> {
  const url = API_BASE + path;

  const extraHeaders = {
    // See add-forge-user-agent.ts
    'User-Agent': `H11n/${version} ${appAri}`,
    'X-Forge-Context': appContextAri,

    Authorization: `Bearer ${token}`

    // Only required when accessing Storage service via the GraphQL gateway
    // https://api.atlassian.com/graphql
    // 'X-ExperimentalApi': 'AppEntityStorage'
  };

  init.headers = Object.assign(init.headers!, extraHeaders);
  return fetch(url, init);
}

const adapter = new GlobalStorage(() => appContextAri, apiClient);
const storage = getStorageInstanceWithQuery(adapter);

async function demo() {
  await storage.set('key', 'vvv');
  console.log(await storage.get('key'));
  await storage.delete('key');
}

demo();
1.5.15

3 months ago

1.5.15-next.0

3 months ago

1.5.14

4 months ago

1.5.14-next.0

4 months ago

1.5.12-next.0

6 months ago

1.5.10-next.1

8 months ago

1.5.10-next.0

8 months ago

1.5.12-next.1

6 months ago

1.5.8-next.0

8 months ago

1.5.6-next.0

9 months ago

1.5.8-next.1

8 months ago

1.5.6-next.1

9 months ago

1.5.8-next.2

8 months ago

1.5.8-next.3

8 months ago

1.5.9-next.0

8 months ago

1.5.9

8 months ago

1.5.8

8 months ago

1.5.7

8 months ago

1.5.6

9 months ago

1.5.13-next.0

6 months ago

1.5.11-next.0

7 months ago

1.5.13-next.1

6 months ago

1.5.11-next.1

7 months ago

1.5.5

10 months ago

1.5.9-next.1

8 months ago

1.5.9-next.2

8 months ago

1.5.7-next.0

9 months ago

1.5.5-next.0

10 months ago

1.5.10

7 months ago

1.5.12

6 months ago

1.5.5-next.2

10 months ago

1.5.11

7 months ago

1.5.5-next.1

10 months ago

1.5.13

6 months ago

1.5.4

11 months ago

1.5.4-next.0

11 months ago

1.5.3

11 months ago

1.5.3-next.0

11 months ago

1.5.3-next.1

11 months ago

1.5.2-next.0

12 months ago

1.5.2

12 months ago

1.5.1

1 year ago

1.5.1-next.1

1 year ago

1.5.1-next.0

1 year ago

1.4.0-next.0

1 year ago

1.4.0

1 year ago

1.5.0-next.0

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.3.2-next.8

1 year ago

1.3.2-next.1

1 year ago

1.3.2-next.0

1 year ago

1.3.2-next.3

1 year ago

1.3.2-next.2

1 year ago

1.3.2-next.5

1 year ago

1.3.2-next.4

1 year ago

1.3.2-next.7

1 year ago

1.3.2-next.6

1 year ago

1.3.1

2 years ago

1.3.1-next.0

2 years ago

1.3.0

2 years ago

1.3.0-next.0

2 years ago

1.2.0

2 years ago

1.2.0-next.0

2 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.1.0-next.0

3 years ago

1.0.5-next.0

3 years ago

1.0.4

3 years ago

1.0.4-next.0

3 years ago

1.0.3

3 years ago

1.0.3-next.0

3 years ago

1.0.2

3 years ago

1.0.2-next.0

3 years ago

1.0.1

3 years ago

1.0.1-next.0

3 years ago

1.0.0

3 years ago

1.0.0-next.0

3 years ago

0.0.2

3 years ago

0.0.2-next.0

3 years ago