@globus/sdk
Advanced tools
Comparing version 0.0.4-alpha.0 to 0.1.1-alpha.0
@@ -27,3 +27,2 @@ "use strict"; | ||
const auth_1 = require("../services/auth"); | ||
const global_1 = require("./global"); | ||
const consent_1 = require("./consent"); | ||
@@ -39,3 +38,6 @@ const storage_1 = require("./storage"); | ||
storage = (0, storage_1.createStorage)("localStorage"); | ||
__classPrivateFieldSet(this, _PKCEAuthorization_configuration, Object.assign({ client_id: (0, global_1.getConfigurationValue)("CLIENT_ID"), authorization_endpoint: (0, auth_1.getAuthorizationEndpoint)(), token_endpoint: (0, auth_1.getTokenEndpoint)() }, configuration), "f"); | ||
if (!configuration.client_id) { | ||
throw new Error("You must provide a `client_id`."); | ||
} | ||
__classPrivateFieldSet(this, _PKCEAuthorization_configuration, Object.assign({ client_id: configuration.client_id, authorization_endpoint: (0, auth_1.getAuthorizationEndpoint)(), token_endpoint: (0, auth_1.getTokenEndpoint)() }, configuration), "f"); | ||
__classPrivateFieldSet(this, _PKCEAuthorization_pkce, __classPrivateFieldGet(this, _PKCEAuthorization_instances, "m", _PKCEAuthorization_createPKCEInstance).call(this), "f"); | ||
@@ -42,0 +44,0 @@ } |
@@ -1,4 +0,1 @@ | ||
import * as AUTH from "../services/auth/config"; | ||
import * as TRANSFER from "../services/transfer/config"; | ||
export declare function env(key: string, fallback?: any): any; | ||
/** | ||
@@ -15,7 +12,11 @@ * Handlers for: GLOBUS_SDK_ENVIRONMENT | ||
}; | ||
export type Environment = typeof ENVIRONMENTS[keyof typeof ENVIRONMENTS]; | ||
export type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS]; | ||
export declare function getEnvironment(): Environment; | ||
export declare const SERVICES: Record<string, string>; | ||
export declare const SERVICES: { | ||
AUTH: string; | ||
TRANSFER: string; | ||
FLOWS: string; | ||
}; | ||
export type Service = keyof typeof SERVICES; | ||
export declare const SERVICE_HOSTS: Record<Service, Partial<Record<Environment, string>>>; | ||
export type Service = typeof AUTH.ID | typeof TRANSFER.ID; | ||
/** | ||
@@ -35,3 +36,3 @@ * Handlers for: GLOBUS_SDK_VERIFY_SSL | ||
export declare function getHttpTimeout(): number | null; | ||
export declare function getConfigurationValue(key: string): any; | ||
export declare function getServiceBaseUrl(service: Service, environment?: Environment): `https://${string}` | undefined; | ||
//# sourceMappingURL=global.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getConfigurationValue = exports.getHttpTimeout = exports.getVerifySSL = exports.SERVICE_HOSTS = exports.SERVICES = exports.getEnvironment = exports.ENVIRONMENTS = exports.env = void 0; | ||
exports.getServiceBaseUrl = exports.getHttpTimeout = exports.getVerifySSL = exports.SERVICE_HOSTS = exports.SERVICES = exports.getEnvironment = exports.ENVIRONMENTS = void 0; | ||
const AUTH = require("../services/auth/config"); | ||
const TRANSFER = require("../services/transfer/config"); | ||
const FLOWS = require("../services/flows/config"); | ||
const errors_1 = require("./errors"); | ||
@@ -22,4 +23,3 @@ function getRuntime() { | ||
} | ||
if (Object.prototype.hasOwnProperty.call(envConfiguration, key)) { | ||
// @ts-ignore | ||
if (key in envConfiguration) { | ||
return envConfiguration[key]; | ||
@@ -29,3 +29,2 @@ } | ||
} | ||
exports.env = env; | ||
/** | ||
@@ -43,5 +42,5 @@ * Handlers for: GLOBUS_SDK_ENVIRONMENT | ||
function getEnvironment() { | ||
const environment = env('GLOBUS_SDK_ENVIRONMENT', exports.ENVIRONMENTS.PRODUCTION); | ||
if (!Object.values(exports.ENVIRONMENTS).includes(environment)) { | ||
throw new errors_1.EnvironmentConfigurationError('GLOBUS_SDK_ENVIRONMENT', environment); | ||
const environment = env("GLOBUS_SDK_ENVIRONMENT", exports.ENVIRONMENTS.PRODUCTION); | ||
if (!environment || !Object.values(exports.ENVIRONMENTS).includes(environment)) { | ||
throw new errors_1.EnvironmentConfigurationError("GLOBUS_SDK_ENVIRONMENT", environment); | ||
} | ||
@@ -54,2 +53,3 @@ return environment; | ||
[TRANSFER.ID]: TRANSFER.ID, | ||
[FLOWS.ID]: FLOWS.ID, | ||
}; | ||
@@ -59,2 +59,3 @@ exports.SERVICE_HOSTS = { | ||
[TRANSFER.ID]: TRANSFER.HOSTS, | ||
[FLOWS.ID]: FLOWS.HOSTS, | ||
}; | ||
@@ -71,5 +72,5 @@ /** | ||
function getVerifySSL() { | ||
const verifySSLTemp = env('GLOBUS_SDK_VERIFY_SSL', 'true').toLowerCase(); | ||
const verifySSLTemp = env("GLOBUS_SDK_VERIFY_SSL", "true").toLowerCase(); | ||
if (["n", "no", "f", "false", "off", "0"].includes(verifySSLTemp)) { | ||
console.warn('Setting GLOBUS_SDK_VERIFY_SSL to false is disallowed in the Globus Javascript SDK. It will always true in this context'); | ||
console.warn("Setting GLOBUS_SDK_VERIFY_SSL to false is disallowed in the Globus Javascript SDK. It will always true in this context"); | ||
} | ||
@@ -83,3 +84,3 @@ return true; | ||
function getHttpTimeout() { | ||
const timeout = Number(env('GLOBUS_SDK_HTTP_TIMEOUT', 60)); | ||
const timeout = Number(env("GLOBUS_SDK_HTTP_TIMEOUT", "60")); | ||
if (timeout === -1) { | ||
@@ -91,9 +92,10 @@ return null; | ||
exports.getHttpTimeout = getHttpTimeout; | ||
function getConfiguration() { | ||
return env('GLOBUS') || {}; | ||
function getServiceHost(service, environment) { | ||
return exports.SERVICE_HOSTS[service][environment]; | ||
} | ||
function getConfigurationValue(key) { | ||
return getConfiguration()[key]; | ||
function getServiceBaseUrl(service, environment = getEnvironment()) { | ||
const host = getServiceHost(service, environment); | ||
return env(`GLOBUS_SDK_SERVICE_URL_${service}`, host ? `https://${host}` : undefined); | ||
} | ||
exports.getConfigurationValue = getConfigurationValue; | ||
exports.getServiceBaseUrl = getServiceBaseUrl; | ||
//# sourceMappingURL=global.js.map |
@@ -1,6 +0,7 @@ | ||
import type { Service, Environment } from "./global"; | ||
import { Environment } from "./global"; | ||
import type { Service } from "./global"; | ||
export declare function getServiceURL(service: Service, path?: string, environment?: Environment): URL; | ||
export declare function build(service: Service, path: string, options?: { | ||
search?: Record<string, any>; | ||
search?: ConstructorParameters<typeof URLSearchParams>[0]; | ||
}): string; | ||
//# sourceMappingURL=url.d.ts.map |
@@ -5,7 +5,4 @@ "use strict"; | ||
const global_1 = require("./global"); | ||
function getServiceHost(service, environment) { | ||
return global_1.SERVICE_HOSTS[service][environment]; | ||
} | ||
function getServiceURL(service, path = "", environment = "production") { | ||
const base = (0, global_1.env)(`GLOBUS_SDK_SERVICE_URL_${service}`, `https://` + getServiceHost(service, environment)); | ||
function getServiceURL(service, path = "", environment = (0, global_1.getEnvironment)()) { | ||
const base = (0, global_1.getServiceBaseUrl)(service, environment); | ||
return new URL(path, base); | ||
@@ -15,9 +12,5 @@ } | ||
function build(service, path, options) { | ||
const url = getServiceURL(service, path, (0, global_1.getEnvironment)()); | ||
const url = getServiceURL(service, path); | ||
if (options && options.search) { | ||
const search = new URLSearchParams(); | ||
Object.keys(options.search).forEach((key) => { | ||
var _a; | ||
search.append(key, (_a = options.search) === null || _a === void 0 ? void 0 : _a[key].toString()); | ||
}); | ||
const search = new URLSearchParams(options.search); | ||
url.search = search.toString(); | ||
@@ -24,0 +17,0 @@ } |
@@ -16,3 +16,3 @@ "use strict"; | ||
return (0, fetch_1.fetchWithScope)("urn:globus:auth:scope:transfer.api.globus.org:all", (0, url_1.build)(config_1.ID, `/v0.10/endpoint_search`, { | ||
search: parameters, | ||
search: parameters !== null && parameters !== void 0 ? parameters : {}, | ||
}), (_a = options === null || options === void 0 ? void 0 : options.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
@@ -19,0 +19,0 @@ } |
@@ -1,5 +0,5 @@ | ||
import type { ServiceMethodDynamicSegments } from "../../types"; | ||
export declare const get: ServiceMethodDynamicSegments<{ | ||
payload: void; | ||
}>; | ||
/** | ||
* Fetch an endpoint by its UUID. | ||
*/ | ||
export declare const get: (endpoint_xid: string, _options?: undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
//# sourceMappingURL=endpoint.d.ts.map |
@@ -7,7 +7,9 @@ "use strict"; | ||
const config_1 = require("../config"); | ||
const get = function (endpoint_xid, options, sdkOptions) { | ||
/** | ||
* Fetch an endpoint by its UUID. | ||
*/ | ||
exports.get = function (endpoint_xid, _options, sdkOptions) { | ||
var _a; | ||
return (0, fetch_1.fetchWithScope)("urn:globus:auth:scope:transfer.api.globus.org:all", (0, url_1.build)(config_1.ID, `/v0.10/endpoint/${endpoint_xid}`), Object.assign({}, (_a = sdkOptions === null || sdkOptions === void 0 ? void 0 : sdkOptions.fetch) === null || _a === void 0 ? void 0 : _a.options)); | ||
}; | ||
exports.get = get; | ||
//# sourceMappingURL=endpoint.js.map |
@@ -1,2 +0,1 @@ | ||
import type { ServiceMethodDynamicSegments, SDKOptions } from "../../types"; | ||
import type { Globus } from "../types"; | ||
@@ -9,3 +8,3 @@ /** | ||
*/ | ||
export declare function ls(endpoint_xid: string, parameters?: Globus.Transfer.DirectoryListingQuery, options?: SDKOptions): Promise<Response>; | ||
export declare const ls: (endpoint_xid: string, parameters?: Globus.Transfer.DirectoryListingQuery | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -17,5 +16,5 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
export declare const mkdir: ServiceMethodDynamicSegments<{ | ||
export declare const mkdir: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Mkdir, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -29,5 +28,5 @@ * Rename or move a file, directory, or symlink on an endpoint filesystem. | ||
*/ | ||
export declare const rename: ServiceMethodDynamicSegments<{ | ||
export declare const rename: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Rename, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -39,5 +38,5 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
export declare const symlink: ServiceMethodDynamicSegments<{ | ||
export declare const symlink: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Symlink, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
//# sourceMappingURL=file-operations.d.ts.map |
@@ -15,9 +15,8 @@ "use strict"; | ||
*/ | ||
function ls(endpoint_xid, parameters, options) { | ||
exports.ls = function (endpoint_xid, parameters, sdkOptions) { | ||
var _a; | ||
return (0, fetch_1.fetchWithScope)("urn:globus:auth:scope:transfer.api.globus.org:all", (0, url_1.build)(config_1.ID, `/v0.10/operation/endpoint/${endpoint_xid}/ls`, { | ||
search: parameters, | ||
}), (_a = options === null || options === void 0 ? void 0 : options.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
} | ||
exports.ls = ls; | ||
}), (_a = sdkOptions === null || sdkOptions === void 0 ? void 0 : sdkOptions.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
}; | ||
/** | ||
@@ -29,3 +28,3 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
const mkdir = function (endpoint_xid, options, sdkOptions) { | ||
exports.mkdir = function (endpoint_xid, options, sdkOptions) { | ||
var _a; | ||
@@ -35,3 +34,2 @@ const reqBody = Object.assign({ DATA_TYPE: "mkdir" }, options === null || options === void 0 ? void 0 : options.payload); | ||
}; | ||
exports.mkdir = mkdir; | ||
/** | ||
@@ -45,3 +43,3 @@ * Rename or move a file, directory, or symlink on an endpoint filesystem. | ||
*/ | ||
const rename = function (endpoint_xid, options, sdkOptions) { | ||
exports.rename = function (endpoint_xid, options, sdkOptions) { | ||
var _a; | ||
@@ -51,3 +49,2 @@ const reqBody = Object.assign({ DATA_TYPE: "rename" }, options === null || options === void 0 ? void 0 : options.payload); | ||
}; | ||
exports.rename = rename; | ||
/** | ||
@@ -59,3 +56,3 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
const symlink = function (endpoint_xid, options, sdkOptions) { | ||
exports.symlink = function (endpoint_xid, options, sdkOptions) { | ||
var _a; | ||
@@ -65,3 +62,2 @@ const reqBody = Object.assign({ DATA_TYPE: "symlink" }, options === null || options === void 0 ? void 0 : options.payload); | ||
}; | ||
exports.symlink = symlink; | ||
//# sourceMappingURL=file-operations.js.map |
import type { FetchOverrides } from "../core/fetch"; | ||
export interface JSONFetchResponse<Res> extends Response { | ||
json(): Promise<Res>; | ||
} | ||
export type SDKOptions = { | ||
@@ -19,9 +22,11 @@ fetch?: { | ||
}; | ||
export type ServiceMethodOptions<Q, P> = { | ||
export type ServiceMethodOptions<Q extends Record<string, string>, P extends Record<string, string>> = { | ||
query?: Record<string, any> & Q; | ||
payload?: Record<string, any> & P; | ||
}; | ||
export type ServiceMethod<Options, R = Response> = (methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type ServiceMethodDynamicSegments<Options, R = Response> = (segments: string | Record<string, string>, methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type RPCServiceMethod<O, R> = ServiceMethod<O, R> | ServiceMethodDynamicSegments<O, R>; | ||
type Segment = string | Record<string, string>; | ||
type Options = Record<string, never> | Record<string, any> | ServiceMethodOptions<any, any>; | ||
export type ServiceMethod<Options, R extends Response = Response> = (methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type ServiceMethodDynamicSegments<S extends Segment, O extends Options, R extends Response = Response> = (segments: S, methodOptions?: O, sdkOptions?: SDKOptions) => Promise<R>; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -5,3 +5,2 @@ var _PKCEAuthorization_instances, _PKCEAuthorization_pkce, _PKCEAuthorization_configuration, _PKCEAuthorization_response, _PKCEAuthorization_createPKCEInstance, _PKCEAuthorization_resetPKCE; | ||
import { getAuthorizationEndpoint, getTokenEndpoint } from "../services/auth"; | ||
import { getConfigurationValue } from "./global"; | ||
import { addTokenResponse, getTokenForScope, reset as resetTokens, } from "./consent"; | ||
@@ -17,3 +16,6 @@ import { createStorage } from "./storage"; | ||
storage = createStorage("localStorage"); | ||
__classPrivateFieldSet(this, _PKCEAuthorization_configuration, Object.assign({ client_id: getConfigurationValue("CLIENT_ID"), authorization_endpoint: getAuthorizationEndpoint(), token_endpoint: getTokenEndpoint() }, configuration), "f"); | ||
if (!configuration.client_id) { | ||
throw new Error("You must provide a `client_id`."); | ||
} | ||
__classPrivateFieldSet(this, _PKCEAuthorization_configuration, Object.assign({ client_id: configuration.client_id, authorization_endpoint: getAuthorizationEndpoint(), token_endpoint: getTokenEndpoint() }, configuration), "f"); | ||
__classPrivateFieldSet(this, _PKCEAuthorization_pkce, __classPrivateFieldGet(this, _PKCEAuthorization_instances, "m", _PKCEAuthorization_createPKCEInstance).call(this), "f"); | ||
@@ -20,0 +22,0 @@ } |
@@ -1,4 +0,1 @@ | ||
import * as AUTH from "../services/auth/config"; | ||
import * as TRANSFER from "../services/transfer/config"; | ||
export declare function env(key: string, fallback?: any): any; | ||
/** | ||
@@ -15,7 +12,11 @@ * Handlers for: GLOBUS_SDK_ENVIRONMENT | ||
}; | ||
export type Environment = typeof ENVIRONMENTS[keyof typeof ENVIRONMENTS]; | ||
export type Environment = (typeof ENVIRONMENTS)[keyof typeof ENVIRONMENTS]; | ||
export declare function getEnvironment(): Environment; | ||
export declare const SERVICES: Record<string, string>; | ||
export declare const SERVICES: { | ||
AUTH: string; | ||
TRANSFER: string; | ||
FLOWS: string; | ||
}; | ||
export type Service = keyof typeof SERVICES; | ||
export declare const SERVICE_HOSTS: Record<Service, Partial<Record<Environment, string>>>; | ||
export type Service = typeof AUTH.ID | typeof TRANSFER.ID; | ||
/** | ||
@@ -35,3 +36,3 @@ * Handlers for: GLOBUS_SDK_VERIFY_SSL | ||
export declare function getHttpTimeout(): number | null; | ||
export declare function getConfigurationValue(key: string): any; | ||
export declare function getServiceBaseUrl(service: Service, environment?: Environment): `https://${string}` | undefined; | ||
//# sourceMappingURL=global.d.ts.map |
import * as AUTH from "../services/auth/config"; | ||
import * as TRANSFER from "../services/transfer/config"; | ||
import { EnvironmentConfigurationError } from './errors'; | ||
import * as FLOWS from "../services/flows/config"; | ||
import { EnvironmentConfigurationError } from "./errors"; | ||
function getRuntime() { | ||
@@ -10,3 +11,3 @@ return typeof window !== "undefined" ? window : process; | ||
} | ||
export function env(key, fallback = undefined) { | ||
function env(key, fallback = undefined) { | ||
const runtime = getRuntime(); | ||
@@ -20,4 +21,3 @@ let envConfiguration; | ||
} | ||
if (Object.prototype.hasOwnProperty.call(envConfiguration, key)) { | ||
// @ts-ignore | ||
if (key in envConfiguration) { | ||
return envConfiguration[key]; | ||
@@ -39,5 +39,5 @@ } | ||
export function getEnvironment() { | ||
const environment = env('GLOBUS_SDK_ENVIRONMENT', ENVIRONMENTS.PRODUCTION); | ||
if (!Object.values(ENVIRONMENTS).includes(environment)) { | ||
throw new EnvironmentConfigurationError('GLOBUS_SDK_ENVIRONMENT', environment); | ||
const environment = env("GLOBUS_SDK_ENVIRONMENT", ENVIRONMENTS.PRODUCTION); | ||
if (!environment || !Object.values(ENVIRONMENTS).includes(environment)) { | ||
throw new EnvironmentConfigurationError("GLOBUS_SDK_ENVIRONMENT", environment); | ||
} | ||
@@ -49,2 +49,3 @@ return environment; | ||
[TRANSFER.ID]: TRANSFER.ID, | ||
[FLOWS.ID]: FLOWS.ID, | ||
}; | ||
@@ -54,2 +55,3 @@ export const SERVICE_HOSTS = { | ||
[TRANSFER.ID]: TRANSFER.HOSTS, | ||
[FLOWS.ID]: FLOWS.HOSTS, | ||
}; | ||
@@ -66,5 +68,5 @@ /** | ||
export function getVerifySSL() { | ||
const verifySSLTemp = env('GLOBUS_SDK_VERIFY_SSL', 'true').toLowerCase(); | ||
const verifySSLTemp = env("GLOBUS_SDK_VERIFY_SSL", "true").toLowerCase(); | ||
if (["n", "no", "f", "false", "off", "0"].includes(verifySSLTemp)) { | ||
console.warn('Setting GLOBUS_SDK_VERIFY_SSL to false is disallowed in the Globus Javascript SDK. It will always true in this context'); | ||
console.warn("Setting GLOBUS_SDK_VERIFY_SSL to false is disallowed in the Globus Javascript SDK. It will always true in this context"); | ||
} | ||
@@ -77,3 +79,3 @@ return true; | ||
export function getHttpTimeout() { | ||
const timeout = Number(env('GLOBUS_SDK_HTTP_TIMEOUT', 60)); | ||
const timeout = Number(env("GLOBUS_SDK_HTTP_TIMEOUT", "60")); | ||
if (timeout === -1) { | ||
@@ -84,8 +86,9 @@ return null; | ||
} | ||
function getConfiguration() { | ||
return env('GLOBUS') || {}; | ||
function getServiceHost(service, environment) { | ||
return SERVICE_HOSTS[service][environment]; | ||
} | ||
export function getConfigurationValue(key) { | ||
return getConfiguration()[key]; | ||
export function getServiceBaseUrl(service, environment = getEnvironment()) { | ||
const host = getServiceHost(service, environment); | ||
return env(`GLOBUS_SDK_SERVICE_URL_${service}`, host ? `https://${host}` : undefined); | ||
} | ||
//# sourceMappingURL=global.js.map |
@@ -1,6 +0,7 @@ | ||
import type { Service, Environment } from "./global"; | ||
import { Environment } from "./global"; | ||
import type { Service } from "./global"; | ||
export declare function getServiceURL(service: Service, path?: string, environment?: Environment): URL; | ||
export declare function build(service: Service, path: string, options?: { | ||
search?: Record<string, any>; | ||
search?: ConstructorParameters<typeof URLSearchParams>[0]; | ||
}): string; | ||
//# sourceMappingURL=url.d.ts.map |
@@ -1,17 +0,10 @@ | ||
import { SERVICE_HOSTS, getEnvironment, env } from "./global"; | ||
function getServiceHost(service, environment) { | ||
return SERVICE_HOSTS[service][environment]; | ||
} | ||
export function getServiceURL(service, path = "", environment = "production") { | ||
const base = env(`GLOBUS_SDK_SERVICE_URL_${service}`, `https://` + getServiceHost(service, environment)); | ||
import { getServiceBaseUrl, getEnvironment } from "./global"; | ||
export function getServiceURL(service, path = "", environment = getEnvironment()) { | ||
const base = getServiceBaseUrl(service, environment); | ||
return new URL(path, base); | ||
} | ||
export function build(service, path, options) { | ||
const url = getServiceURL(service, path, getEnvironment()); | ||
const url = getServiceURL(service, path); | ||
if (options && options.search) { | ||
const search = new URLSearchParams(); | ||
Object.keys(options.search).forEach((key) => { | ||
var _a; | ||
search.append(key, (_a = options.search) === null || _a === void 0 ? void 0 : _a[key].toString()); | ||
}); | ||
const search = new URLSearchParams(options.search); | ||
url.search = search.toString(); | ||
@@ -18,0 +11,0 @@ } |
@@ -14,5 +14,5 @@ import { build } from "../../../core/url"; | ||
return fetchWithScope("urn:globus:auth:scope:transfer.api.globus.org:all", build(ID, `/v0.10/endpoint_search`, { | ||
search: parameters, | ||
search: parameters !== null && parameters !== void 0 ? parameters : {}, | ||
}), (_a = options === null || options === void 0 ? void 0 : options.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
} | ||
//# sourceMappingURL=endpoint-search.js.map |
@@ -1,5 +0,5 @@ | ||
import type { ServiceMethodDynamicSegments } from "../../types"; | ||
export declare const get: ServiceMethodDynamicSegments<{ | ||
payload: void; | ||
}>; | ||
/** | ||
* Fetch an endpoint by its UUID. | ||
*/ | ||
export declare const get: (endpoint_xid: string, _options?: undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
//# sourceMappingURL=endpoint.d.ts.map |
import { build } from "../../../core/url"; | ||
import { fetchWithScope } from "../../../core/fetch"; | ||
import { ID } from "../config"; | ||
export const get = function (endpoint_xid, options, sdkOptions) { | ||
/** | ||
* Fetch an endpoint by its UUID. | ||
*/ | ||
export const get = function (endpoint_xid, _options, sdkOptions) { | ||
var _a; | ||
@@ -6,0 +9,0 @@ return fetchWithScope("urn:globus:auth:scope:transfer.api.globus.org:all", build(ID, `/v0.10/endpoint/${endpoint_xid}`), Object.assign({}, (_a = sdkOptions === null || sdkOptions === void 0 ? void 0 : sdkOptions.fetch) === null || _a === void 0 ? void 0 : _a.options)); |
@@ -1,2 +0,1 @@ | ||
import type { ServiceMethodDynamicSegments, SDKOptions } from "../../types"; | ||
import type { Globus } from "../types"; | ||
@@ -9,3 +8,3 @@ /** | ||
*/ | ||
export declare function ls(endpoint_xid: string, parameters?: Globus.Transfer.DirectoryListingQuery, options?: SDKOptions): Promise<Response>; | ||
export declare const ls: (endpoint_xid: string, parameters?: Globus.Transfer.DirectoryListingQuery | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -17,5 +16,5 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
export declare const mkdir: ServiceMethodDynamicSegments<{ | ||
export declare const mkdir: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Mkdir, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -29,5 +28,5 @@ * Rename or move a file, directory, or symlink on an endpoint filesystem. | ||
*/ | ||
export declare const rename: ServiceMethodDynamicSegments<{ | ||
export declare const rename: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Rename, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
/** | ||
@@ -39,5 +38,5 @@ * Create a directory at the specified path on an endpoint filesystem. | ||
*/ | ||
export declare const symlink: ServiceMethodDynamicSegments<{ | ||
export declare const symlink: (endpoint_xid: string, options: { | ||
payload: Omit<Globus.Transfer.Request.Symlink, "DATA_TYPE">; | ||
}>; | ||
} | undefined, sdkOptions?: import("../../types").SDKOptions | undefined) => Promise<Response>; | ||
//# sourceMappingURL=file-operations.d.ts.map |
@@ -12,8 +12,8 @@ import { build } from "../../../core/url"; | ||
*/ | ||
export function ls(endpoint_xid, parameters, options) { | ||
export const ls = function (endpoint_xid, parameters, sdkOptions) { | ||
var _a; | ||
return fetchWithScope("urn:globus:auth:scope:transfer.api.globus.org:all", build(ID, `/v0.10/operation/endpoint/${endpoint_xid}/ls`, { | ||
search: parameters, | ||
}), (_a = options === null || options === void 0 ? void 0 : options.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
} | ||
}), (_a = sdkOptions === null || sdkOptions === void 0 ? void 0 : sdkOptions.fetch) === null || _a === void 0 ? void 0 : _a.options); | ||
}; | ||
/** | ||
@@ -20,0 +20,0 @@ * Create a directory at the specified path on an endpoint filesystem. |
import type { FetchOverrides } from "../core/fetch"; | ||
export interface JSONFetchResponse<Res> extends Response { | ||
json(): Promise<Res>; | ||
} | ||
export type SDKOptions = { | ||
@@ -19,9 +22,11 @@ fetch?: { | ||
}; | ||
export type ServiceMethodOptions<Q, P> = { | ||
export type ServiceMethodOptions<Q extends Record<string, string>, P extends Record<string, string>> = { | ||
query?: Record<string, any> & Q; | ||
payload?: Record<string, any> & P; | ||
}; | ||
export type ServiceMethod<Options, R = Response> = (methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type ServiceMethodDynamicSegments<Options, R = Response> = (segments: string | Record<string, string>, methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type RPCServiceMethod<O, R> = ServiceMethod<O, R> | ServiceMethodDynamicSegments<O, R>; | ||
type Segment = string | Record<string, string>; | ||
type Options = Record<string, never> | Record<string, any> | ServiceMethodOptions<any, any>; | ||
export type ServiceMethod<Options, R extends Response = Response> = (methodOptions?: Options, sdkOptions?: SDKOptions) => Promise<R>; | ||
export type ServiceMethodDynamicSegments<S extends Segment, O extends Options, R extends Response = Response> = (segments: S, methodOptions?: O, sdkOptions?: SDKOptions) => Promise<R>; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@globus/sdk", | ||
"version": "0.0.4-alpha.0", | ||
"version": "0.1.1-alpha.0", | ||
"private": false, | ||
@@ -12,3 +12,5 @@ "description": "The Globus SDK for Javascript", | ||
}, | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
@@ -24,7 +26,8 @@ "test": "jest", | ||
"devDependencies": { | ||
"@types/jest": "29.4.0", | ||
"jest": "29.4.3", | ||
"ts-jest": "29.0.5", | ||
"typedoc": "^0.23.25", | ||
"typescript": "4.9.5" | ||
"@types/jest": "29.5.1", | ||
"jest": "29.5.0", | ||
"msw": "^1.2.1", | ||
"ts-jest": "29.1.0", | ||
"typedoc": "^0.24.6", | ||
"typescript": "5.0.4" | ||
}, | ||
@@ -37,3 +40,4 @@ "engines": { | ||
"js-pkce": "^1.2.1" | ||
} | ||
}, | ||
"gitHead": "aa3888a282462c9583956e02e3a764a2f88e0d1d" | ||
} |
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
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
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
285627
298
2543
6
6
4