now using tsclass

This commit is contained in:
Philipp Kunz 2017-06-11 21:07:41 +02:00
parent d3d5f72193
commit 9c036925fd
10 changed files with 53 additions and 27 deletions

View File

@ -1,5 +1,6 @@
import 'typings-global'; import 'typings-global';
import * as interfaces from './cflare.interfaces'; import * as interfaces from './cflare.interfaces';
import { TDnsRecord } from 'tsclass';
export declare class CflareAccount { export declare class CflareAccount {
private authEmail; private authEmail;
private authKey; private authKey;
@ -9,9 +10,9 @@ export declare class CflareAccount {
key: string; key: string;
}): void; }): void;
getZoneId(domainName: string): Promise<string>; getZoneId(domainName: string): Promise<string>;
getRecord(domainNameArg: string, typeArg: interfaces.TRecord): Promise<interfaces.ICflareRecord>; getRecord(domainNameArg: string, typeArg: TDnsRecord): Promise<interfaces.ICflareRecord>;
createRecord(domainNameArg: string, typeArg: interfaces.TRecord, contentArg: string): Promise<{}>; createRecord(domainNameArg: string, typeArg: TDnsRecord, contentArg: string): Promise<{}>;
removeRecord(domainNameArg: string, typeArg: interfaces.TRecord): Promise<{}>; removeRecord(domainNameArg: string, typeArg: TDnsRecord): Promise<{}>;
updateRecord(domainNameArg: string, typeArg: string, valueArg: any): Promise<{}>; updateRecord(domainNameArg: string, typeArg: string, valueArg: any): Promise<{}>;
/** /**
* list all records of a specified domain name * list all records of a specified domain name

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
export declare type TRecord = 'A' | 'AAAA' | 'CNAME' | 'TXT' | 'SRV' | 'LOC' | 'MX' | 'NS' | 'SPF';
export interface ICflareZone { export interface ICflareZone {
'id': string; 'id': string;
'name': string; 'name': string;

View File

@ -1,6 +1,8 @@
import 'typings-global'; import 'typings-global';
export declare let beautylog: any; import * as beautylog from 'beautylog';
export import q = require('smartq'); import * as q from 'smartq';
export import smartrequest = require('smartrequest'); import * as smartdelay from 'smartdelay';
export import smartstring = require('smartstring'); import * as smartrequest from 'smartrequest';
export import smartdelay = require('smartdelay'); import * as smartstring from 'smartstring';
import * as tsclass from 'tsclass';
export { beautylog, q, smartdelay, smartrequest, smartstring, tsclass };

View File

@ -1,9 +1,16 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global"); require("typings-global");
exports.beautylog = require('beautylog'); const beautylog = require("beautylog");
exports.q = require("smartq"); exports.beautylog = beautylog;
exports.smartrequest = require("smartrequest"); const q = require("smartq");
exports.smartstring = require("smartstring"); exports.q = q;
exports.smartdelay = require("smartdelay"); const smartdelay = require("smartdelay");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jZmxhcmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUNaLFFBQUEsU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtBQUMzQyw4QkFBbUM7QUFDbkMsK0NBQW9EO0FBQ3BELDZDQUFrRDtBQUNsRCwyQ0FBZ0QifQ== exports.smartdelay = smartdelay;
const smartrequest = require("smartrequest");
exports.smartrequest = smartrequest;
const smartstring = require("smartstring");
exports.smartstring = smartstring;
const tsclass = require("tsclass");
exports.tsclass = tsclass;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jZmxhcmUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBc0M7QUFRcEMsOEJBQVM7QUFQWCw0QkFBMkI7QUFRekIsY0FBQztBQVBILHlDQUF3QztBQVF0QyxnQ0FBVTtBQVBaLDZDQUE0QztBQVExQyxvQ0FBWTtBQVBkLDJDQUEwQztBQVF4QyxrQ0FBVztBQVBiLG1DQUFrQztBQVFoQywwQkFBTyJ9

View File

@ -27,6 +27,7 @@
"smartq": "^1.1.1", "smartq": "^1.1.1",
"smartrequest": "^1.0.6", "smartrequest": "^1.0.6",
"smartstring": "^2.0.24", "smartstring": "^2.0.24",
"tsclass": "^1.0.12",
"typings-global": "^1.0.17" "typings-global": "^1.0.17"
}, },
"devDependencies": { "devDependencies": {

View File

@ -2,11 +2,14 @@ import 'typings-global'
import plugins = require('./cflare.plugins') import plugins = require('./cflare.plugins')
import * as interfaces from './cflare.interfaces' import * as interfaces from './cflare.interfaces'
// interfaces
import { TDnsRecord } from 'tsclass'
export class CflareAccount { export class CflareAccount {
private authEmail: string private authEmail: string
private authKey: string private authKey: string
constructor() { constructor() {
// Nothing here
} }
auth (optionsArg: { email: string, key: string }) { auth (optionsArg: { email: string, key: string }) {
@ -28,7 +31,7 @@ export class CflareAccount {
} }
} }
getRecord (domainNameArg: string, typeArg: interfaces.TRecord): Promise<interfaces.ICflareRecord> { getRecord (domainNameArg: string, typeArg: TDnsRecord): Promise<interfaces.ICflareRecord> {
let done = plugins.q.defer() let done = plugins.q.defer()
let result: interfaces.ICflareRecord let result: interfaces.ICflareRecord
@ -43,7 +46,7 @@ export class CflareAccount {
return done.promise return done.promise
} }
async createRecord (domainNameArg: string, typeArg: interfaces.TRecord, contentArg: string) { async createRecord (domainNameArg: string, typeArg: TDnsRecord, contentArg: string) {
let done = plugins.q.defer() let done = plugins.q.defer()
let domain = new plugins.smartstring.Domain(domainNameArg) let domain = new plugins.smartstring.Domain(domainNameArg)
let domainIdArg = await this.getZoneId(domain.zoneName) let domainIdArg = await this.getZoneId(domain.zoneName)
@ -59,7 +62,7 @@ export class CflareAccount {
return done.promise return done.promise
} }
removeRecord (domainNameArg: string, typeArg: interfaces.TRecord) { removeRecord (domainNameArg: string, typeArg: TDnsRecord) {
let done = plugins.q.defer() let done = plugins.q.defer()
let domain = new plugins.smartstring.Domain(domainNameArg) let domain = new plugins.smartstring.Domain(domainNameArg)
this.getRecord(domain.fullName, typeArg) this.getRecord(domain.fullName, typeArg)

View File

@ -1,7 +1,5 @@
import * as plugins from './cflare.plugins' import * as plugins from './cflare.plugins'
export type TRecord = 'A' | 'AAAA' | 'CNAME' | 'TXT' | 'SRV' | 'LOC' | 'MX' | 'NS' | 'SPF'
export interface ICflareZone { export interface ICflareZone {
'id': string 'id': string
'name': string 'name': string

View File

@ -1,6 +1,16 @@
import 'typings-global' import 'typings-global'
export let beautylog = require('beautylog') import * as beautylog from 'beautylog'
export import q = require('smartq') import * as q from 'smartq'
export import smartrequest = require('smartrequest') import * as smartdelay from 'smartdelay'
export import smartstring = require('smartstring') import * as smartrequest from 'smartrequest'
export import smartdelay = require('smartdelay') import * as smartstring from 'smartstring'
import * as tsclass from 'tsclass'
export {
beautylog,
q,
smartdelay,
smartrequest,
smartstring,
tsclass
}

View File

@ -606,6 +606,10 @@ through2@^2.0.1:
readable-stream "^2.1.5" readable-stream "^2.1.5"
xtend "~4.0.1" xtend "~4.0.1"
tsclass@^1.0.12:
version "1.0.12"
resolved "https://registry.yarnpkg.com/tsclass/-/tsclass-1.0.12.tgz#350c4e567ca7ae7fa426b95bbb77ec478ec0edef"
type-detect@0.1.1: type-detect@0.1.1:
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"