@mintlify/http-client
Advanced tools
Comparing version 0.0.113 to 0.0.114
@@ -27,8 +27,2 @@ import { BaseClient } from './baseClient.js'; | ||
export declare function handleJson<T>(this: BaseClient, req: RequestInit, res: Response, uri: string): Promise<T>; | ||
/** | ||
* Checks if a client has access to a resource. | ||
* @param accessCondition - The condition to check to get access. | ||
* @throws ClientError - If the condition is true. | ||
*/ | ||
export declare function handleAccess<TClient extends BaseClient>(this: TClient, accessCondition: boolean): void; | ||
//# sourceMappingURL=clientError.d.ts.map |
@@ -10,3 +10,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { ACCESS_DENIED, UNAUTHORIZED } from '../leaves-client/index.js'; | ||
/** | ||
@@ -43,3 +42,2 @@ * Represents a client-side error. | ||
'host' in object.client && | ||
'isPasswordProtected' in object.client && | ||
'subdomain' in object.client && | ||
@@ -87,12 +85,2 @@ 'response' in object && | ||
} | ||
/** | ||
* Checks if a client has access to a resource. | ||
* @param accessCondition - The condition to check to get access. | ||
* @throws ClientError - If the condition is true. | ||
*/ | ||
export function handleAccess(accessCondition) { | ||
if (!accessCondition) { | ||
throw new ClientError(ACCESS_DENIED, this, UNAUTHORIZED); | ||
} | ||
} | ||
//# sourceMappingURL=clientError.js.map |
@@ -1,4 +0,2 @@ | ||
import { ErrorResponseType } from '../client/types.js'; | ||
export declare const ADMIN_TOKEN: string | undefined; | ||
export declare const SUBDOMAIN: string | undefined; | ||
export declare const AUTH_HEADER: { | ||
@@ -13,5 +11,2 @@ Authorization: string; | ||
export declare const PATHS_ROUTE = "paths"; | ||
export declare const UNAUTHORIZED: ErrorResponseType; | ||
export declare const ACCESS_DENIED = "Access denied. Not authorized to access protected content."; | ||
export declare const IS_PASSWORD_PROTECTED: boolean; | ||
//# sourceMappingURL=constants.d.ts.map |
export const ADMIN_TOKEN = process.env.ADMIN_TOKEN; | ||
export const SUBDOMAIN = process.env.SUBDOMAIN; | ||
export const AUTH_HEADER = ADMIN_TOKEN ? { Authorization: `Bearer ${ADMIN_TOKEN}` } : undefined; | ||
@@ -8,5 +7,2 @@ export const API_ENDPOINT = process.env.API_ENDPOINT || 'http://localhost:5000'; | ||
export const PATHS_ROUTE = 'paths'; | ||
export const UNAUTHORIZED = { status: 401 }; | ||
export const ACCESS_DENIED = 'Access denied. Not authorized to access protected content.'; | ||
export const IS_PASSWORD_PROTECTED = process.env.IS_PASSWORD_PROTECTED === 'true'; | ||
//# sourceMappingURL=constants.js.map |
@@ -5,4 +5,3 @@ import type { ServerStaticProps } from '@mintlify/models'; | ||
readonly subdomain: string; | ||
readonly isPasswordProtected: boolean; | ||
constructor(subdomain: string, isPasswordProtected: boolean, host: string, reqInit?: RequestInit | undefined); | ||
constructor(subdomain: string, host: string, reqInit?: RequestInit | undefined); | ||
getStaticProps(pagePath: string): Promise<ServerStaticProps>; | ||
@@ -12,3 +11,3 @@ getHostingLocation(): Promise<string>; | ||
} | ||
export declare const getLeavesClient: (subdomain: string, isPasswordProtected?: boolean, host?: string, reqInit?: { | ||
export declare const getLeavesClient: (subdomain: string, host?: string, reqInit?: { | ||
headers: { | ||
@@ -15,0 +14,0 @@ Authorization: string; |
@@ -1,11 +0,7 @@ | ||
import { handleAccess } from '../client/clientError.js'; | ||
import { BaseClient } from '../client/index.js'; | ||
import { ENDPOINT, HEADERS, IS_PASSWORD_PROTECTED, SUBDOMAIN } from './constants.js'; | ||
import { ENDPOINT, HEADERS } from './constants.js'; | ||
export class LeavesClient extends BaseClient { | ||
constructor(subdomain, isPasswordProtected, host, reqInit = undefined) { | ||
constructor(subdomain, host, reqInit = undefined) { | ||
super(host, reqInit); | ||
this.isPasswordProtected = isPasswordProtected; | ||
this.subdomain = SUBDOMAIN !== null && SUBDOMAIN !== void 0 ? SUBDOMAIN : subdomain; | ||
const isAccessDenied = SUBDOMAIN !== subdomain && this.isPasswordProtected; | ||
handleAccess.bind(this)(!isAccessDenied); | ||
this.subdomain = subdomain; | ||
} | ||
@@ -25,4 +21,4 @@ getStaticProps(pagePath) { | ||
} | ||
export const getLeavesClient = (subdomain, isPasswordProtected = IS_PASSWORD_PROTECTED, host = ENDPOINT, reqInit = { headers: HEADERS }) => new LeavesClient(subdomain, isPasswordProtected, host, reqInit); | ||
export const getLeavesClient = (subdomain, host = ENDPOINT, reqInit = { headers: HEADERS }) => new LeavesClient(subdomain, host, reqInit); | ||
export default getLeavesClient; | ||
//# sourceMappingURL=leavesClient.js.map |
{ | ||
"name": "@mintlify/http-client", | ||
"version": "0.0.113", | ||
"version": "0.0.114", | ||
"type": "module", | ||
@@ -43,4 +43,4 @@ "description": "The Mintlify http client package", | ||
"dependencies": { | ||
"@mintlify/models": "0.0.91", | ||
"@mintlify/validation": "0.1.153" | ||
"@mintlify/models": "0.0.92", | ||
"@mintlify/validation": "0.1.154" | ||
}, | ||
@@ -68,3 +68,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "c88dc295661cc12d7984b0aad187e2cf9601c89e" | ||
"gitHead": "ce77d5d48c5f3d504bdda66bb10c32efe61d4d20" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79927
461
+ Added@mintlify/models@0.0.92(transitive)
+ Added@mintlify/validation@0.1.154(transitive)
- Removed@mintlify/models@0.0.91(transitive)
- Removed@mintlify/validation@0.1.153(transitive)
Updated@mintlify/models@0.0.92
Updated@mintlify/validation@0.1.154