chore: introduce @automatisch/types
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
bbb6f0b0ff
commit
3391578655
@@ -1,6 +1,6 @@
|
||||
import type { IField } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Authentication {
|
||||
appData: any;
|
||||
@@ -18,7 +18,7 @@ export default class Authentication {
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
).value;
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import { google as GoogleApi } from 'googleapis';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import Field from '../../types/field';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: OAuth2Client;
|
||||
|
||||
scopes: string[] = [
|
||||
@@ -17,7 +19,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
'profile',
|
||||
];
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.appData = appData;
|
||||
this.connectionData = connectionData;
|
||||
|
||||
@@ -32,7 +34,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
).value;
|
||||
}
|
||||
|
||||
|
@@ -1,16 +1,18 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import FlickrApi from 'flickr-sdk';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import Field from '../../types/field';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: typeof FlickrApi;
|
||||
oauthClient: typeof FlickrApi;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.oauthClient = new FlickrApi.OAuth(
|
||||
connectionData.consumerKey,
|
||||
connectionData.consumerSecret
|
||||
@@ -33,7 +35,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
|
||||
async createAuthData() {
|
||||
const appFields = this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
|
@@ -1,16 +1,18 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import {
|
||||
getWebFlowAuthorizationUrl,
|
||||
exchangeWebFlowCode,
|
||||
checkToken,
|
||||
} from '@octokit/oauth-methods';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import Field from '../../types/field';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
scopes: string[] = ['repo'];
|
||||
client: {
|
||||
getWebFlowAuthorizationUrl: typeof getWebFlowAuthorizationUrl;
|
||||
@@ -18,7 +20,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
checkToken: typeof checkToken;
|
||||
};
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = appData;
|
||||
|
||||
@@ -31,7 +33,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
|
||||
get oauthRedirectUrl(): string {
|
||||
return this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
).value;
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,17 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import { Client } from 'pg';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: Client;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.client = new Client({
|
||||
host: connectionData.host as string,
|
||||
port: connectionData.port as number,
|
||||
|
@@ -1,13 +1,16 @@
|
||||
import nodemailer, { Transporter, TransportOptions } from 'nodemailer';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
|
||||
export default class Authentication {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: Transporter;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.client = nodemailer.createTransport({
|
||||
host: connectionData.host,
|
||||
port: connectionData.port,
|
||||
|
@@ -1,14 +1,16 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import TwilioApi from 'twilio';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: TwilioApi.Twilio;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.client = TwilioApi(
|
||||
connectionData.accountSid as string,
|
||||
connectionData.authToken as string
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import TwitchApi, { TwitchJsOptions } from 'twitch-js';
|
||||
import fetchUtil from 'twitch-js/lib/utils/fetch';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import Field from '../../types/field';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
type TwitchTokenResponse = {
|
||||
accessToken: string;
|
||||
@@ -12,12 +14,12 @@ type TwitchTokenResponse = {
|
||||
tokenType: string;
|
||||
};
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: TwitchApi;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = appData;
|
||||
|
||||
@@ -36,7 +38,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
).value;
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,17 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import TwitterApi, { TwitterApiTokens } from 'twitter-api-v2';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import Field from '../../types/field';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: TwitterApi;
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.appData = appData;
|
||||
this.connectionData = connectionData;
|
||||
|
||||
@@ -25,7 +27,7 @@ export default class Authentication implements AuthenticationInterface {
|
||||
|
||||
async createAuthData() {
|
||||
const appFields = this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import AuthenticationInterface from '../../types/interfaces/authentication-interface';
|
||||
import type {
|
||||
IAuthentication,
|
||||
IApp,
|
||||
IField,
|
||||
IJSONObject,
|
||||
} from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import AppInfo from '../../types/app-info';
|
||||
import Field from '../../types/field';
|
||||
import JSONObject from '../../types/interfaces/json-object';
|
||||
|
||||
export default class Authentication implements AuthenticationInterface {
|
||||
appData: AppInfo;
|
||||
connectionData: JSONObject;
|
||||
export default class Authentication implements IAuthentication {
|
||||
appData: IApp;
|
||||
connectionData: IJSONObject;
|
||||
client: AxiosInstance = axios.create({
|
||||
baseURL: 'https://api.typeform.com',
|
||||
});
|
||||
@@ -22,14 +24,14 @@ export default class Authentication implements AuthenticationInterface {
|
||||
'workspaces:read',
|
||||
];
|
||||
|
||||
constructor(appData: AppInfo, connectionData: JSONObject) {
|
||||
constructor(appData: IApp, connectionData: IJSONObject) {
|
||||
this.connectionData = connectionData;
|
||||
this.appData = appData;
|
||||
}
|
||||
|
||||
get oauthRedirectUrl() {
|
||||
return this.appData.fields.find(
|
||||
(field: Field) => field.key == 'oAuthRedirectUrl'
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
).value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user