@typegraph/sdk
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -76,4 +76,7 @@ export namespace aws { | ||
export namespace utils { | ||
export { addAuth }; | ||
export { addGraphqlEndpoint }; | ||
export { addRawAuth }; | ||
export { genApplyb }; | ||
export { oauth2 }; | ||
} | ||
@@ -418,8 +421,17 @@ declare function registerS3Runtime(arg0: any): number | { | ||
}; | ||
declare function addAuth(arg0: any): number | { | ||
stack: string[]; | ||
}; | ||
declare function addGraphqlEndpoint(arg0: any): number | { | ||
stack: string[]; | ||
}; | ||
declare function addRawAuth(arg0: any): number | { | ||
stack: string[]; | ||
}; | ||
declare function genApplyb(arg0: any, arg1: any): number | { | ||
stack: string[]; | ||
}; | ||
declare function oauth2(arg0: any, arg1: any): string | { | ||
stack: string[]; | ||
}; | ||
export {}; |
import "./_dnt.polyfills.js"; | ||
import { RawAuth } from "./typegraph.js"; | ||
import { Auth as Auth_ } from "./wit.js"; | ||
@@ -7,2 +8,16 @@ export declare class Auth { | ||
static basic(users: string[]): Auth_; | ||
static oauth2Digitalocean(scopes: string): RawAuth; | ||
static oauth2Discord(scopes: string): RawAuth; | ||
static oauth2Dropbox(scopes: string): RawAuth; | ||
static oauth2Facebook(scopes: string): RawAuth; | ||
static oauth2Github(scopes: string): RawAuth; | ||
static oauth2Gitlab(scopes: string): RawAuth; | ||
static oauth2Google(scopes: string): RawAuth; | ||
static oauth2Instagram(scopes: string): RawAuth; | ||
static oauth2Linkedin(scopes: string): RawAuth; | ||
static oauth2Microsoft(scopes: string): RawAuth; | ||
static oauth2Reddit(scopes: string): RawAuth; | ||
static oauth2Slack(scopes: string): RawAuth; | ||
static oauth2Stackexchange(scopes: string): RawAuth; | ||
static oauth2Twitter(scopes: string): RawAuth; | ||
} |
// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
import "./_dnt.polyfills.js"; | ||
import { RawAuth } from "./typegraph.js"; | ||
import { wit_utils } from "./wit.js"; | ||
export class Auth { | ||
@@ -35,2 +37,44 @@ static jwt(name, format, algorithm) { | ||
} | ||
static oauth2Digitalocean(scopes) { | ||
return new RawAuth(wit_utils.oauth2("digitalocean", scopes)); | ||
} | ||
static oauth2Discord(scopes) { | ||
return new RawAuth(wit_utils.oauth2("discord", scopes)); | ||
} | ||
static oauth2Dropbox(scopes) { | ||
return new RawAuth(wit_utils.oauth2("dropbox", scopes)); | ||
} | ||
static oauth2Facebook(scopes) { | ||
return new RawAuth(wit_utils.oauth2("facebook", scopes)); | ||
} | ||
static oauth2Github(scopes) { | ||
return new RawAuth(wit_utils.oauth2("github", scopes)); | ||
} | ||
static oauth2Gitlab(scopes) { | ||
return new RawAuth(wit_utils.oauth2("gitlab", scopes)); | ||
} | ||
static oauth2Google(scopes) { | ||
return new RawAuth(wit_utils.oauth2("google", scopes)); | ||
} | ||
static oauth2Instagram(scopes) { | ||
return new RawAuth(wit_utils.oauth2("instagram", scopes)); | ||
} | ||
static oauth2Linkedin(scopes) { | ||
return new RawAuth(wit_utils.oauth2("linkedin", scopes)); | ||
} | ||
static oauth2Microsoft(scopes) { | ||
return new RawAuth(wit_utils.oauth2("microsoft", scopes)); | ||
} | ||
static oauth2Reddit(scopes) { | ||
return new RawAuth(wit_utils.oauth2("reddit", scopes)); | ||
} | ||
static oauth2Slack(scopes) { | ||
return new RawAuth(wit_utils.oauth2("slack", scopes)); | ||
} | ||
static oauth2Stackexchange(scopes) { | ||
return new RawAuth(wit_utils.oauth2("stackexchange", scopes)); | ||
} | ||
static oauth2Twitter(scopes) { | ||
return new RawAuth(wit_utils.oauth2("twitter", scopes)); | ||
} | ||
} |
@@ -14,3 +14,2 @@ import "./_dnt.polyfills.js"; | ||
cors?: Cors; | ||
auths?: Array<Auth>; | ||
rate?: Rate; | ||
@@ -22,2 +21,3 @@ } | ||
rest: (graphql: string) => number; | ||
auth: (value: Auth | RawAuth) => number; | ||
} | ||
@@ -33,2 +33,6 @@ export declare class InheritDef { | ||
type TypegraphBuilder = (g: TypegraphBuilderArgs) => void; | ||
export declare class RawAuth { | ||
readonly jsonStr: string; | ||
constructor(jsonStr: string); | ||
} | ||
export declare function typegraph(name: string, builder: TypegraphBuilder): void; | ||
@@ -35,0 +39,0 @@ export declare function typegraph(args: TypegraphArgs): void; |
@@ -39,2 +39,12 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. | ||
} | ||
export class RawAuth { | ||
constructor(jsonStr) { | ||
Object.defineProperty(this, "jsonStr", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: jsonStr | ||
}); | ||
} | ||
} | ||
export function typegraph(nameOrArgs, maybeBuilder) { | ||
@@ -44,3 +54,3 @@ const args = typeof nameOrArgs === "string" | ||
: nameOrArgs; | ||
const { name, dynamic, auths, cors, prefix, rate, secrets, } = args; | ||
const { name, dynamic, cors, prefix, rate, secrets, } = args; | ||
const builder = "builder" in args | ||
@@ -67,3 +77,2 @@ ? args.builder | ||
}, | ||
auths: auths ?? [], | ||
rate, | ||
@@ -82,2 +91,8 @@ }; | ||
}, | ||
auth: (value) => { | ||
if (value instanceof RawAuth) { | ||
return wit_utils.addRawAuth(value.jsonStr); | ||
} | ||
return wit_utils.addAuth(value); | ||
}, | ||
}; | ||
@@ -84,0 +99,0 @@ builder(g); |
@@ -10,2 +10,3 @@ import "./_dnt.polyfills.js"; | ||
export declare const wit_utils: typeof MetatypeTypegraphUtils; | ||
export type { Auth, AuthProtocol, AuthProtocolBasic, AuthProtocolJwt, AuthProtocolOauth2, Cors, Rate, } from "./gen/interfaces/metatype-typegraph-core"; | ||
export type { Cors, Rate } from "./gen/interfaces/metatype-typegraph-core"; | ||
export type { Auth, AuthProtocol, AuthProtocolBasic, AuthProtocolJwt, AuthProtocolOauth2, } from "./gen/interfaces/metatype-typegraph-utils"; |
{ | ||
"module": "./esm/mod.js", | ||
"name": "@typegraph/sdk", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Declarative API development platform. Build serverless backends with zero-trust and less code, no matter where and how your (legacy) systems are.", | ||
@@ -6,0 +6,0 @@ "license": "MPL-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
4159705
12868