7.1.6 • Published 6 months ago

@apiida/obsidian-api-helper v7.1.6

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

apiida obsidian api helper

https://apiida.com/product/obsidian/

https://pinia.vuejs.org/

https://axios-http.com/docs/intro

https://www.npmjs.com/package/webstomp-client

Merge conflicts / version conflicts

The branches "master" and "fallback" are published on npm. Npm always takes the highest version number, the branch doesn't matter. The "master" should always contain the highest version (see examples below). If there are problems with the versions during parallel development: 1) In case of a merge conflict you have to check if there are breaking changes in the other frontends. If so, the merge must be aborted and the fallback must be used. 2) There a new version number is set. 3) With this new version number you can continue to work in the other frontends. 4) Set the version number in the frontend:

npm install @apiida/obsidian-api-helper@2.1.0

5) Discuss with the team and merge the version number.

// local version of obsidian-api-helper
npm list @apiida/obsidian-api-helper

// Highest verion in npm (online)
npm view @apiida/obsidian-api-helper

Usage

Examples

Create the following two classes. How to implement the classes

ApiClient.ts

import axios, { AxiosInstance } from 'axios';
import { ApiClient } from '@apiida/obsidian-api-helper';
import { notify } from 'notiwind';
import config from '../config';
import { insertTenantId } from '../helper/TenantHelper';

function getBackendUrl(): string {
  return `${config.backendUrl}/`;
}

const apiClient: AxiosInstance = axios.create({
  baseURL: getBackendUrl(),
  headers: {
    'Content-Type': 'application/json',
  },
  timeout: 30000,
  validateStatus(status: number) {
    return status < 500; // Resolve only if the status code is less than 500
  },
});

// Set the AUTH token for any request
apiClient.interceptors.request.use((axiosConfig) => {
  const token = localStorage.getItem('accessToken');

  if (axiosConfig != null && axiosConfig.headers !== undefined && token != null) {
    axiosConfig.headers.Authorization = token;
  }

  return axiosConfig;
});

export default new ApiClient(apiClient, notify);

BasicService.ts

import { BasicType, BasicService as TheBasicService } from '@apiida/obsidian-api-helper';
import apiClient from './ApiClient';

export default abstract class BasicService<T extends BasicType> extends TheBasicService<T> {
  protected constructor(url: string, entityName: string) {
    super(url, entityName, apiClient);
  }
}

Now you can create a Pinia Store and a service for your entity.

SubscriptionStore.ts

import { defineStore } from 'pinia';
import Subscription from '../types/applications/Subscription';

const subscription = defineStore({
  id: 'subscription',
  state: () => ({
    subscriptions: [] as Subscription[],
  }),
});

export default subscription;

SubscriptionService.ts

import Subscription from '../../types/applications/Subscription';
import subscriptionStore from '../../stores/SubscriptionStore';
import BasicService from '../BasicService';

class SubscriptionService extends BasicService<Subscription> {
  constructor() {
    super('/subscriptions', 'Subscription');
  }

  storeFill(entitys: Subscription[]): void {
    this.getStore().subscriptions = entitys;
  }

  storeGetAllEntitys(): Subscription[] {
    return this.getStore().subscriptions;
  }

  getStore(): any {
    return subscriptionStore();
  }
}

export default new SubscriptionService();

You can send CRUD calls to the API with the SubscriptionService and the BasicService takes care of the caching.

Contribute

Version

The version is made up as follows.

BreakingChange.CreateOrUpdateComponent.BugFix (1.2.598)
7.1.6

6 months ago

7.1.5

6 months ago

7.1.4

6 months ago

6.0.0

9 months ago

6.1.0

9 months ago

6.1.1

9 months ago

6.2.1

9 months ago

6.2.0

9 months ago

6.2.2

9 months ago

7.0.0

9 months ago

7.0.2

9 months ago

7.0.1

9 months ago

6.3.0

9 months ago

7.1.3

7 months ago

7.1.2

7 months ago

7.1.1

8 months ago

7.1.0

8 months ago

5.0.5

11 months ago

5.0.4

11 months ago

5.0.3

11 months ago

5.0.2

11 months ago

4.0.1

1 year ago

4.0.0

1 year ago

5.0.1

12 months ago

5.0.0

12 months ago

3.14.6

1 year ago

3.13.2

1 year ago

3.13.1

1 year ago

3.13.4

1 year ago

3.13.3

1 year ago

3.13.6

1 year ago

3.13.5

1 year ago

3.13.7

1 year ago

3.12.1

1 year ago

3.12.0

1 year ago

3.14.1

1 year ago

3.14.0

1 year ago

3.14.3

1 year ago

3.14.2

1 year ago

3.14.5

1 year ago

3.14.4

1 year ago

3.13.0

1 year ago

3.11.4

1 year ago

3.11.3

1 year ago

3.11.5

1 year ago

3.9.0

1 year ago

3.10.1

1 year ago

3.10.0

1 year ago

3.8.4

1 year ago

3.8.3

1 year ago

3.11.0

1 year ago

3.11.2

1 year ago

3.11.1

1 year ago

3.3.7

2 years ago

3.3.6

2 years ago

3.6.2

1 year ago

3.6.1

2 years ago

3.6.0

2 years ago

3.6.6

1 year ago

3.6.5

1 year ago

3.6.4

1 year ago

3.2.8

2 years ago

3.6.3

1 year ago

3.6.7

1 year ago

3.5.0

2 years ago

3.4.0

2 years ago

3.8.0

1 year ago

3.4.3

2 years ago

3.4.2

2 years ago

3.4.1

2 years ago

3.8.2

1 year ago

3.8.1

1 year ago

3.3.1

2 years ago

3.3.0

2 years ago

3.3.5

2 years ago

3.7.0

1 year ago

3.3.4

2 years ago

3.3.3

2 years ago

3.3.2

2 years ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.2.6

2 years ago

3.2.5

2 years ago

3.2.4

2 years ago

3.2.3

2 years ago

3.2.7

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.1.9

2 years ago

3.1.8

2 years ago

3.0.0

2 years ago

2.1.2

2 years ago

1.10.5

2 years ago

1.10.4

2 years ago

1.10.3

2 years ago

1.10.2

2 years ago

1.10.6

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

1.11.10

2 years ago

2.0.8

2 years ago

1.11.11

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.11.4

2 years ago

1.11.3

2 years ago

1.11.2

2 years ago

1.11.1

2 years ago

1.11.8

2 years ago

1.11.7

2 years ago

1.11.6

2 years ago

1.11.5

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.11.9

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.9.5

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.11.0

2 years ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

2.1.1

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.1.0

2 years ago

1.8.9

2 years ago

1.8.10

2 years ago

1.8.8

2 years ago

1.8.7

2 years ago

1.8.6

2 years ago

1.8.5

2 years ago

1.8.3

2 years ago

1.2.0

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.4.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.12

2 years ago

1.2.13

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.16

2 years ago

1.2.14

2 years ago

1.2.15

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.1.2

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.2.9

2 years ago

1.0.11

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago