1.6.0 • Published 8 months ago

@forge/storage v1.6.0

Weekly downloads
329
License
UNLICENSED
Repository
-
Last release
8 months ago

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

Usage example:

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

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

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

// For user agent header
const version = '0.0.1';
const appAri = 'ari:cloud:ecosystem::app/...';

// For Storage service auth
const appContextAri = 'ari:cloud:jira::site/...';
const token = '...';

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, getMetrics);
const storage = getStorageInstanceWithQuery(adapter);

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

demo();
1.6.0

8 months ago

1.6.0-next.1

9 months ago

1.6.0-next.0

9 months ago

1.5.15

1 year ago

1.5.15-next.0

1 year ago

1.5.14

1 year ago

1.5.14-next.0

1 year ago

1.5.12-next.0

2 years ago

1.5.10-next.1

2 years ago

1.5.10-next.0

2 years ago

1.5.12-next.1

2 years ago

1.5.8-next.0

2 years ago

1.5.6-next.0

2 years ago

1.5.8-next.1

2 years ago

1.5.6-next.1

2 years ago

1.5.8-next.2

2 years ago

1.5.8-next.3

2 years ago

1.5.9-next.0

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.13-next.0

2 years ago

1.5.11-next.0

2 years ago

1.5.13-next.1

2 years ago

1.5.11-next.1

2 years ago

1.5.5

2 years ago

1.5.9-next.1

2 years ago

1.5.9-next.2

2 years ago

1.5.7-next.0

2 years ago

1.5.5-next.0

2 years ago

1.5.10

2 years ago

1.5.12

2 years ago

1.5.5-next.2

2 years ago

1.5.11

2 years ago

1.5.5-next.1

2 years ago

1.5.13

2 years ago

1.5.4

2 years ago

1.5.4-next.0

2 years ago

1.5.3

2 years ago

1.5.3-next.0

2 years ago

1.5.3-next.1

2 years ago

1.5.2-next.0

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.1-next.1

2 years ago

1.5.1-next.0

2 years ago

1.4.0-next.0

2 years ago

1.4.0

2 years ago

1.5.0-next.0

2 years ago

1.5.0

2 years ago

1.3.2

2 years ago

1.3.2-next.8

2 years ago

1.3.2-next.1

2 years ago

1.3.2-next.0

2 years ago

1.3.2-next.3

2 years ago

1.3.2-next.2

2 years ago

1.3.2-next.5

2 years ago

1.3.2-next.4

2 years ago

1.3.2-next.7

2 years ago

1.3.2-next.6

2 years ago

1.3.1

3 years ago

1.3.1-next.0

3 years ago

1.3.0

3 years ago

1.3.0-next.0

3 years ago

1.2.0

3 years ago

1.2.0-next.0

3 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.1.0-next.0

4 years ago

1.0.5-next.0

4 years ago

1.0.4

4 years ago

1.0.4-next.0

4 years ago

1.0.3

4 years ago

1.0.3-next.0

4 years ago

1.0.2

4 years ago

1.0.2-next.0

4 years ago

1.0.1

4 years ago

1.0.1-next.0

4 years ago

1.0.0

4 years ago

1.0.0-next.0

4 years ago

0.0.2

4 years ago

0.0.2-next.0

4 years ago