refactor: move to new sdks

This commit is contained in:
Derrick Hammer 2023-07-05 05:33:18 -04:00
parent f1bbbf540d
commit c9c7bfe498
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
12 changed files with 18428 additions and 145 deletions

5
.presetterrc.json Normal file
View File

@ -0,0 +1,5 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

17
dist/index.d.ts vendored
View File

@ -1,17 +0,0 @@
import { Client } from "@lumeweb/libkernel-universal";
import { DNSResult, ResolverOptions } from "@lumeweb/libresolver";
import { ResolverModule } from "./module.js";
export declare class DnsClient extends Client {
get resolvers(): Promise<Set<ResolverModule>>;
register(): Promise<void>;
registerResolver(module: string): Promise<void>;
clear(): Promise<void>;
resolve(
domain: string,
options?: ResolverOptions,
bypassCache?: boolean
): Promise<DNSResult>;
}
export declare const createClient: (...args: any) => DnsClient;
export * from "./module.js";
//# sourceMappingURL=index.d.ts.map

1
dist/index.d.ts.map vendored
View File

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAEL,SAAS,EACT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAI3D,qBAAa,SAAU,SAAQ,MAAM;IACnC,IAAI,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAQ5C;IAEY,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAmD,EAC5D,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,SAAS,CAAC;CAGtB;AAED,eAAO,MAAM,YAAY,6BAAwC,CAAC;AAClE,cAAc,aAAa,CAAC"}

29
dist/index.js vendored
View File

@ -1,29 +0,0 @@
import { Client, factory } from "@lumeweb/libkernel-universal";
import { DNS_RECORD_TYPE, } from "@lumeweb/libresolver";
import { createModule } from "./module.js";
const MODULE = "vAA-phmM1ztqu8zGBKF2nM3b8N_IQGWlB6J_doi2FhqS-A";
export class DnsClient extends Client {
get resolvers() {
return this.callModuleReturn("getResolvers").then((resolvers) => {
return new Set(resolvers.map((resolver) => {
return createModule(resolver, this);
}));
});
}
async register() {
return this.callModuleReturn("register");
}
async registerResolver(module) {
const bag = await this.loadBound(module);
const ret = await bag.callModule("register");
return ret[0];
}
async clear() {
return this.callModuleReturn("clear");
}
async resolve(domain, options = { type: DNS_RECORD_TYPE.CONTENT }, bypassCache = false) {
return this.callModuleReturn("resolve", { domain, options, bypassCache });
}
}
export const createClient = factory(DnsClient, MODULE);
export * from "./module.js";

21
dist/module.d.ts vendored
View File

@ -1,21 +0,0 @@
import { Client } from "@lumeweb/libkernel-universal";
import { DnsClient } from "./index.js";
import { DNSResult, ResolverOptions } from "@lumeweb/libresolver";
export declare class ResolverModule extends Client {
private domain;
constructor(domain: string, resolver?: DnsClient);
private _resolver?;
get resolver(): DnsClient;
set resolver(value: DnsClient);
resolve(
domain: string,
options: ResolverOptions,
bypassCache: boolean
): Promise<DNSResult>;
getSupportedTlds(): Promise<string[]>;
}
export declare const createModule: (
module: string,
client: DnsClient
) => ResolverModule;
//# sourceMappingURL=module.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,SAAS,EAET,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,cAAe,SAAQ,MAAM;IACxC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS;IAMhD,OAAO,CAAC,SAAS,CAAC,CAAY;IAE9B,IAAI,QAAQ,IAAI,SAAS,CAExB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,SAAS,EAE5B;IAEK,OAAO,CACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC;IAWf,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAG5C;AAED,eAAO,MAAM,YAAY,WACf,MAAM,UACN,SAAS,KAChB,cAC8D,CAAC"}

33
dist/module.js vendored
View File

@ -1,33 +0,0 @@
import { Client, factory } from "@lumeweb/libkernel-universal";
import { resolverError, } from "@lumeweb/libresolver";
export class ResolverModule extends Client {
domain;
constructor(domain, resolver) {
super();
this._resolver = resolver;
this.domain = domain;
}
_resolver;
get resolver() {
return this._resolver;
}
set resolver(value) {
this._resolver = value;
}
async resolve(domain, options, bypassCache) {
try {
return this.callModuleReturn("resolve", {
domain,
options,
bypassCache,
});
}
catch (e) {
return resolverError(e);
}
}
async getSupportedTlds() {
return this.callModuleReturn("getSupportedTlds");
}
}
export const createModule = (module, client) => factory(ResolverModule, module)(module, client);

18390
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,17 +2,30 @@
"name": "@lumeweb/kernel-dns-client", "name": "@lumeweb/kernel-dns-client",
"version": "0.1.0", "version": "0.1.0",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "lib/index.js",
"dependencies": { "repository": {
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git", "type": "git",
"@lumeweb/libresolver": "git+https://git.lumeweb.com/LumeWeb/libresolver.git", "url": "gitea@git.lumeweb.com:LumeWeb/kernel-dns-client.git"
"libkernel": "^0.1.43",
"libkmodule": "^0.2.44",
"libskynet": "^0.0.62"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.0.6", "@lumeweb/node-library-preset": "^0.2.7",
"prettier": "^2.7.1", "presetter": "*"
"typescript": "^4.9.5" },
"readme": "ERROR: No README data found!",
"_id": "@lumeweb/kernel-dns-client@0.1.0",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/libkernel": "^0.1.0-develop.14",
"@lumeweb/libresolver": "^0.0.2-develop.1"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
} }
} }

View File

@ -1,4 +1,4 @@
import { Client, factory } from "@lumeweb/libkernel-universal"; import { Client, factory } from "@lumeweb/libkernel/module";
import { import {
DNS_RECORD_TYPE, DNS_RECORD_TYPE,
DNSResult, DNSResult,
@ -6,7 +6,7 @@ import {
} from "@lumeweb/libresolver"; } from "@lumeweb/libresolver";
import { createModule, ResolverModule } from "./module.js"; import { createModule, ResolverModule } from "./module.js";
const MODULE = "vAA-phmM1ztqu8zGBKF2nM3b8N_IQGWlB6J_doi2FhqS-A"; const MODULE = "zduJC2T9pCyTnrYvEacy64LAufhjfpQdpz5sweUgDdGqy4u18LK6yvKLqM";
export class DnsClient extends Client { export class DnsClient extends Client {
get resolvers(): Promise<Set<ResolverModule>> { get resolvers(): Promise<Set<ResolverModule>> {
@ -14,7 +14,7 @@ export class DnsClient extends Client {
return new Set( return new Set(
resolvers.map((resolver: string): ResolverModule => { resolvers.map((resolver: string): ResolverModule => {
return createModule(resolver, this); return createModule(resolver, this);
}) }),
); );
}); });
} }
@ -24,7 +24,7 @@ export class DnsClient extends Client {
} }
public async registerResolver(module: string): Promise<void> { public async registerResolver(module: string): Promise<void> {
const bag = await this.loadBound(module); const bag = await this.getBound(module);
const ret = await bag.callModule("register"); const ret = await bag.callModule("register");
return ret[0]; return ret[0];
} }
@ -36,7 +36,7 @@ export class DnsClient extends Client {
public async resolve( public async resolve(
domain: string, domain: string,
options: ResolverOptions = { type: DNS_RECORD_TYPE.CONTENT }, options: ResolverOptions = { type: DNS_RECORD_TYPE.CONTENT },
bypassCache: boolean = false bypassCache: boolean = false,
): Promise<DNSResult> { ): Promise<DNSResult> {
return this.callModuleReturn("resolve", { domain, options, bypassCache }); return this.callModuleReturn("resolve", { domain, options, bypassCache });
} }

View File

@ -1,4 +1,4 @@
import { Client, factory } from "@lumeweb/libkernel-universal"; import { Client, factory } from "@lumeweb/libkernel/module";
import { DnsClient } from "./index.js"; import { DnsClient } from "./index.js";
import { import {
DNSResult, DNSResult,
@ -9,8 +9,8 @@ import {
export class ResolverModule extends Client { export class ResolverModule extends Client {
private domain: string; private domain: string;
constructor(domain: string, resolver?: DnsClient) { constructor(module: string, domain: string, resolver?: DnsClient) {
super(); super(module);
this._resolver = resolver; this._resolver = resolver;
this.domain = domain; this.domain = domain;
} }
@ -28,7 +28,7 @@ export class ResolverModule extends Client {
async resolve( async resolve(
domain: string, domain: string,
options: ResolverOptions, options: ResolverOptions,
bypassCache: boolean bypassCache: boolean,
): Promise<DNSResult> { ): Promise<DNSResult> {
try { try {
return this.callModuleReturn("resolve", { return this.callModuleReturn("resolve", {
@ -47,6 +47,6 @@ export class ResolverModule extends Client {
export const createModule = ( export const createModule = (
module: string, module: string,
client: DnsClient client: DnsClient,
): ResolverModule => ): ResolverModule =>
factory<ResolverModule>(ResolverModule, module)(module, client); factory<ResolverModule>(ResolverModule, module)(module, client);

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"declaration": true,
"strict": true,
"module": "esnext",
"target": "esnext",
"esModuleInterop": true,
"sourceMap": false,
"rootDir": "src",
"outDir": "dist",
"typeRoots": [
"node_modules/@types",
],
"moduleResolution": "node",
"declarationMap": true,
"declarationDir": "dist",
"emitDeclarationOnly": false,
"allowJs": true
},
"include": [
"src"
]
}