This commit is contained in:
Cam 2023-11-16 10:25:52 -06:00
parent 8efdd06780
commit ae8e7acf5e
No known key found for this signature in database
GPG Key ID: 367B7C7EBD84A8BD
522 changed files with 106240 additions and 1 deletions

2
.gitignore vendored
View File

@ -7,7 +7,7 @@ etc/dev.yml
etc/dev-frontend.yml
# Dependencies
/node_modules/
node_modules/
# Artifacts
/dist/

View File

@ -0,0 +1,27 @@
"use strict";
const { Command } = require("commander"); // add this line
const zrok = require("zrok");
//const environ = require("zrok/environment")
const program = new Command();
program
.command('copyto')
.version("1.0.0")
.description("command to host content to be pastedfrom'd")
.action(() => {
console.log('copyto command called');
//console.log(environ)
let root = zrok.Load();
let shr = zrok.CreateShare(root, new zrok.ShareRequest(zrok.TCP_TUNNEL_BACKEND_MODE, zrok.PUBLIC_SHARE_MODE, "pastebin"));
console.log(shr);
zrok.DeleteShare(root, shr);
});
program
.command('pastefrom <shrToken>')
.version("1.0.0")
.description("command to paste content from coptyo")
.action((shrToken) => {
console.log('pastefrom command called', shrToken);
});
program.parse(process.argv);
const options = program.opts();
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,gBAAgB;AAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,6CAA6C;AAE7C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,4CAA4C,CAAC;KACzD,MAAM,CAAC,GAAG,EAAE;IACX,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,sBAAsB;IACtB,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IACtB,IAAI,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,uBAAuB,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC1H,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAChB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,sBAAsB,CAAC;KAC/B,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,CAAC,QAAgB,EAAE,EAAE;IAC3B,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC"}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
{
"dependencies": {
"commander": "^11.1.0",
"path": "^0.12.7",
"zrok": "../../sdk_ts/dist"
},
"devDependencies": {
"@types/node": "^20.9.0",
"nodemon": "^3.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"scripts": {
"build": "npx tsc"
}
}

View File

@ -0,0 +1,29 @@
const { Command } = require("commander"); // add this line
const zrok = require("zrok")
//const environ = require("zrok/environment")
const program = new Command();
program
.command('copyto')
.version("1.0.0")
.description("command to host content to be pastedfrom'd")
.action(() => {
console.log('copyto command called');
//console.log(environ)
let root = zrok.Load()
let shr = zrok.CreateShare(root, new zrok.ShareRequest(zrok.TCP_TUNNEL_BACKEND_MODE, zrok.PUBLIC_SHARE_MODE, "pastebin"));
console.log(shr)
zrok.DeleteShare(root, shr);
});
program
.command('pastefrom <shrToken>')
.version("1.0.0")
.description("command to paste content from coptyo")
.action((shrToken: string) => {
console.log('pastefrom command called', shrToken);
});
program.parse(process.argv)
const options = program.opts();

View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"strict": true,
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"esModuleInterop": true,
"moduleResolution": "node"
}
}

View File

@ -0,0 +1,31 @@
import os from "os";
import path from "node:path"
function rootDir() {
home = os.homedir()
return path.join(home, ".zrok")
}
function metadataFile() {
zrd = rootDir()
return path.join(zrd, "metadata.json")
}
function configFile() {
zrd = rootDir()
return path.join(zrd, "config.json")
}
function environmentFile() {
zrd = rootDir()
return path.join(zrd, "environment.json")
}
function identitiesDir() {
zrd = rootDir()
return path.join(zrd, "identities")
}
function identityFile(name) {
idd = identitiesDir()
return path.join(idd, name + ".json")
}

View File

@ -0,0 +1,154 @@
import {environmntFile, configFile, metadataFile, identityFile} from "./dirs"
import fs from "node:fs"
import JSON from "JSON"
import * as gateway from "../zrok/api/gateway"
const V = "v0.4"
class Metadata {
constructor(V, RootPath) {
this.V = V
this.RootPath = RootPath
}
}
class Config {
constructor(ApiEndpoint) {
this.ApiEndpoint = ApiEndpoint
}
}
class Environment {
constructor(Token, ZitiIdentity, ApiEndpoint) {
this.Token = Token
this.ZitiIdentity = ZitiIdentity
this.ApiEndpoint = ApiEndpoint
}
}
class ApiEndpoint {
constructor(endpoint, frm) {
this.endpoint = endpoint
this.frm = frm
}
}
class Root {
constructor(meta, cfg=Config(), env=Environment()){
this.meta = meta
this.cfg = cfg
this.env = env
if (meta === undefined) {
let root = rootDir()
this.meta = Metadata(V, root)
}
}
HasConfig() {
return this.cfg !== undefined && Object.keys(this.cfg).length === 0
}
Client() {
let apiEndpoint = this.ApiEndpoint()
function getAuthorization(security) {
switch(security.id) {
case 'key': return "why"
//case 'key': return getApiKey();
default: console.log('default');
}
}
gateway.init({
url: apiEndpoint + '/api/v1',
getAuthorization
})
}
ApiEndpoint() {
let apiEndpoint = "https://api.zrok.io"
let frm = "binary"
if (this.cfg.ApiEndpoint != "") {
apiEndpoint = this.cfg.ApiEndpoint
frm = "config"
}
env = process.env.ZROK_API_ENDPOINT
if (env != "") {
apiEndpoint = env
frm = "ZROK_API_ENDPOINT"
}
if (this.IsEnabled()) {
apiEndpoint = this.env.ApiEndpoint
frm = "env"
}
return ApiEndpoint(apiEndpoint.replace(/\/+$/, ""), frm)
}
IsEnabled() {
return this.env !== undefined && Object.keys(this.env).length === 0
}
PublicIdentityName() {
return "public"
}
EnvironmentIdentityName() {
return "environment"
}
ZitiIdentityName(name) {
return identityFile(name)
}
}
function Assert() {
if (rootExists()){
meta = loadMetadata()
return meta.V == V
}
return false
}
function Load() {
if (rootExists()) {
return Root(loadMetadata(), loadConfig(), loadEnvironment())
}
return Root()
}
function rootExists() {
mf = metadataFile()
return fs.existsSync(mf)
}
function loadMetadata() {
mf = metadataFile()
data = fs.readFileSync(mf)
serialized = JSON.parse(data)
return Metadata(serialized.v)
}
function loadConfig() {
cf = configFile()
data = fs.readFileSync(cf)
serialized = JSON.parse(data)
return Config(serialized.api_endpoint)
}
function isEnabled() {
ef = environmntFile()
return fs.existsSync(ef)
}
function loadEnvironment() {
ef = environmntFile()
data = fs.readFileSync(ef)
serialized = JSON.parse(data)
return Environment(serialized.zrok_token, serialized.ziti_identity, serialized.api_endpoint)
}

1
sdk/node/sdk/index.js Normal file
View File

@ -0,0 +1 @@
module.exports = require("./zrok/model")

1739
sdk/node/sdk/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

40
sdk/node/sdk/package.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "zrok",
"version": "1.0.0",
"description": "SDK to enable programmatic usee of the zrok sharing methods",
"main": "index.js",
"scripts": {
"test": "echo \\\"Error: no test specified\\\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/openziti/zrok.git"
},
"keywords": [
"security",
"network",
"peer-to-peer",
"reverse-proxy",
"zero-trust"
],
"author": "NetFoundry",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/openziti/zrok/issues"
},
"homepage": "https://github.com/openziti/zrok#readme",
"dependencies": {
"@openziti/ziti-sdk-nodejs": "^0.14.0"
},
"exports": {
".": "./index.js",
"./zrok": "./zrok",
"./zrok/share": "./zrok/share",
"./environment": "./environment",
"./environment/root": "./environment/root.js",
"./environment/dirs": "./environment/dirs"
},
"imports": {
"./environment/dirs": "./environment/dirs.js"
}
}

View File

@ -0,0 +1,29 @@
import {Root} from "../environment/root"
import {accessRequest, unaccessRequest, authUser} from "./api/types"
import {access, unaccess} from "./api/share"
import * as model from "./model"
export function CreateAccess(root, request) {
if (!root.IsEnabled()){
throw new Error("environment is not enabled; enable with 'zrok enable' first!")
}
out = accessRequest(request.ShareToken, root.env.ZitiIdentity)
root.Client()
access({body:out})
.catch(resp => {
throw new Error("unable to create access", resp)
})
}
export function DeleteAccess(root, acc) {
if (!root.IsEnabled()){
throw new Error("environment is not enabled; enable with 'zrok enable' first!")
}
req = unaccessRequest(acc.Token,acc.ShareToken, root.env.ZitiIdentity)
unaccess({body:req})
.catch(resp => {
throw new Error("error deleting access", resp)
})
}

View File

@ -0,0 +1,129 @@
/** @module account */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {module:types.inviteRequest} [options.body]
* @return {Promise<object>} invitation created
*/
export function invite(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(inviteOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.loginRequest} [options.body]
* @return {Promise<module:types.loginResponse>} login successful
*/
export function login(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(loginOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.registerRequest} [options.body]
* @return {Promise<module:types.registerResponse>} account created
*/
export function register(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(registerOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.resetPasswordRequest} [options.body]
* @return {Promise<object>} password reset
*/
export function resetPassword(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(resetPasswordOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {object} [options.body]
* @return {Promise<object>} forgot password request created
*/
export function resetPasswordRequest(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(resetPasswordRequestOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.verifyRequest} [options.body]
* @return {Promise<module:types.verifyResponse>} token ready
*/
export function verify(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(verifyOperation, parameters)
}
const inviteOperation = {
path: '/invite',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}
const loginOperation = {
path: '/login',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}
const registerOperation = {
path: '/register',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}
const resetPasswordOperation = {
path: '/resetPassword',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}
const resetPasswordRequestOperation = {
path: '/resetPasswordRequest',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}
const verifyOperation = {
path: '/verify',
contentTypes: ['application/zrok.v1+json'],
method: 'post'
}

View File

@ -0,0 +1,149 @@
/** @module admin */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {module:types.createFrontendRequest} [options.body]
* @return {Promise<module:types.createFrontendResponse>} frontend created
*/
export function createFrontend(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(createFrontendOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.updateFrontendRequest} [options.body]
* @return {Promise<object>} frontend updated
*/
export function updateFrontend(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(updateFrontendOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.deleteFrontendRequest} [options.body]
* @return {Promise<object>} frontend deleted
*/
export function deleteFrontend(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(deleteFrontendOperation, parameters)
}
/**
*/
export function listFrontends() {
return gateway.request(listFrontendsOperation)
}
/**
* @param {object} options Optional options
* @param {object} [options.body]
* @return {Promise<object>} created
*/
export function createIdentity(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(createIdentityOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.inviteTokenGenerateRequest} [options.body]
* @return {Promise<object>} invitation tokens created
*/
export function inviteTokenGenerate(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(inviteTokenGenerateOperation, parameters)
}
const createFrontendOperation = {
path: '/frontend',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const updateFrontendOperation = {
path: '/frontend',
contentTypes: ['application/zrok.v1+json'],
method: 'patch',
security: [
{
id: 'key'
}
]
}
const deleteFrontendOperation = {
path: '/frontend',
contentTypes: ['application/zrok.v1+json'],
method: 'delete',
security: [
{
id: 'key'
}
]
}
const listFrontendsOperation = {
path: '/frontends',
method: 'get',
security: [
{
id: 'key'
}
]
}
const createIdentityOperation = {
path: '/identity',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const inviteTokenGenerateOperation = {
path: '/invite/token/generate',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}

View File

@ -0,0 +1,55 @@
/** @module environment */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {module:types.enableRequest} [options.body]
* @return {Promise<module:types.enableResponse>} environment enabled
*/
export function enable(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(enableOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.disableRequest} [options.body]
* @return {Promise<object>} environment disabled
*/
export function disable(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(disableOperation, parameters)
}
const enableOperation = {
path: '/enable',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const disableOperation = {
path: '/disable',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}

View File

@ -0,0 +1,281 @@
// Auto-generated, edits will be overwritten
import spec from './spec'
export class ServiceError extends Error {}
let options = {}
export function init(serviceOptions) {
options = serviceOptions
}
export function request(op, parameters, attempt) {
if (!attempt) attempt = 1;
return acquireRights(op, spec, options)
.then(rights => {
parameters = parameters || {}
const baseUrl = getBaseUrl(spec)
let reqInfo = { parameters, baseUrl }
if (options.processRequest) {
reqInfo = options.processRequest(op, reqInfo)
}
const req = buildRequest(op, reqInfo.baseUrl, reqInfo.parameters, rights)
return makeFetchRequest(req)
.then(res => processResponse(req, res, attempt, options), e => processError(req, e))
.then(outcome => outcome.retry ? request(op, parameters, attempt + 1) : outcome.res)
})
}
function acquireRights(op, spec, options) {
if (op.security && options.getAuthorization) {
return op.security.reduce((promise, security) => {
return promise.then(rights => {
const securityDefinition = spec.securityDefinitions[security.id]
return options.getAuthorization(security, securityDefinition, op)
.then(auth => {
rights[security.id] = auth
return rights
})
})
}, Promise.resolve({}))
}
return Promise.resolve({})
}
function makeFetchRequest(req) {
let fetchOptions = {
compress: true,
method: (req.method || 'get').toUpperCase(),
headers: req.headers,
body: req.body ? JSON.stringify(req.body) : undefined
}
if (options.fetchOptions) {
const opts = options.fetchOptions
const headers = opts.headers
? Object.assign(fetchOptions.headers, opts.headers)
: fetchOptions.headers
fetchOptions = Object.assign({}, fetchOptions, opts)
fetchOptions.headers = headers
}
let promise = fetch(req.url, fetchOptions)
return promise
}
function buildRequest(op, baseUrl, parameters, rights) {
let paramGroups = groupParams(op, parameters)
paramGroups = applyAuthorization(paramGroups, rights, spec)
const url = buildUrl(op, baseUrl, paramGroups, spec)
const headers = buildHeaders(op, paramGroups)
const body = buildBody(parameters.body)
return {
method: op.method,
url,
headers,
body
}
}
function groupParams(op, parameters) {
const groups = ['header', 'path', 'query', 'formData'].reduce((groups, name) => {
groups[name] = formatParamsGroup(groups[name])
return groups
}, parameters)
if (!groups.header) groups.header = {}
return groups
}
function formatParamsGroup(groups) {
return Object.keys(groups || {}).reduce((g, name) => {
const param = groups[name]
if (param !== undefined) {
g[name] = formatParam(param)
}
return g
}, {})
}
function formatParam(param) {
if (param === undefined || param === null) return ''
else if (param instanceof Date) return param.toJSON()
else if (Array.isArray(param)) return param
else return param.toString()
}
function buildUrl(op, baseUrl, parameters, spec) {
let url = `${baseUrl}${op.path}`
if (parameters.path) {
url = Object.keys(parameters.path)
.reduce((url, name) => url.replace(`{${name}}`, parameters.path[name]), url)
}
const query = createQueryString(parameters.query)
return url + query
}
function getBaseUrl(spec) {
return options.url || `${spec.schemes[0] || 'https'}://${spec.host}${spec.basePath}`
}
function createQueryParam(name, value) {
const v = formatParam(value)
if (v && typeof v === 'string') return `${name}=${encodeURIComponent(v)}`
return name;
}
function createQueryString(query) {
const names = Object.keys(query || {})
if (!names.length) return ''
const params = names.map(name => ({name, value: query[name]}))
.reduce((acc, value) => {
if (Array.isArray(value.value)) {
return acc.concat(value.value)
} else {
acc.push(createQueryParam(value.name, value.value))
return acc
}
}, [])
return '?' + params.sort().join('&')
}
function buildHeaders(op, parameters) {
const headers = {}
let accepts
if (op.accepts && op.accepts.length) accepts = op.accepts
else if (spec.accepts && spec.accepts.length) accepts = spec.accepts
else accepts = [ 'application/json' ]
headers.Accept = accepts.join(', ')
let contentType
if (op.contentTypes && op.contentTypes[0]) contentType = op.contentTypes[0]
else if (spec.contentTypes && spec.contentTypes[0]) contentType = spec.contentTypes[0]
if (contentType) headers['Content-Type'] = contentType
return Object.assign(headers, parameters.header)
}
function buildBody(bodyParams) {
if (bodyParams) {
if (bodyParams.body) return bodyParams.body
const key = Object.keys(bodyParams)[0]
if (key) return bodyParams[key]
}
return undefined
}
function resolveAuthHeaderName(headerName){
if (options.authorizationHeader && headerName.toLowerCase() === 'authorization') {
return options.authorizationHeader
} else {
return headerName
}
}
function applyAuthorization(req, rights, spec) {
Object.keys(rights).forEach(name => {
const rightsInfo = rights[name]
const definition = spec.securityDefinitions[name]
switch (definition.type) {
case 'basic':
const creds = `${rightsInfo.username}:${rightsInfo.password}`
const token = (typeof window !== 'undefined' && window.btoa)
? window.btoa(creds)
: new Buffer(creds).toString('base64')
req.header[resolveAuthHeaderName('Authorization')] = `Basic ${token}`
break
case 'oauth2':
req.header[resolveAuthHeaderName('Authorization')] = `Bearer ${rightsInfo.token}`
break
case 'apiKey':
if (definition.in === 'header') {
req.header[resolveAuthHeaderName(definition.name)] = rightsInfo.apiKey
} else if (definition.in === 'query') {
req.query[definition.name] = rightsInfo.apiKey
} else {
throw new Error(`Api key must be in header or query not '${definition.in}'`)
}
break
default:
throw new Error(`Security definition type '${definition.type}' not supported`)
}
})
return req
}
function processResponse(req, response, attempt, options) {
const format = response.ok ? formatResponse : formatServiceError
const contentType = response.headers.get('content-type') || ''
let parse
if (response.status === 204) {
parse = Promise.resolve()
} else if (~contentType.indexOf('json')) {
parse = response.json()
} else if (~contentType.indexOf('octet-stream')) {
parse = response.blob()
} else if (~contentType.indexOf('text')) {
parse = response.text()
} else {
parse = Promise.resolve()
}
return parse
.then(data => format(response, data, options))
.then(res => {
if (options.processResponse) return options.processResponse(req, res, attempt)
else return Promise.resolve({ res })
})
}
function formatResponse(response, data, options) {
return { raw: response, data }
}
function formatServiceError(response, data, options) {
if (options.formatServiceError) {
data = options.formatServiceError(response, data)
} else {
const serviceError = new ServiceError()
if (data) {
if (typeof data === 'string') serviceError.message = data
else {
if (data.message) serviceError.message = data.message
if (data.body) serviceError.body = data.body
else serviceError.body = data
}
if (data.code) serviceError.code = data.code
} else {
serviceError.message = response.statusText
}
serviceError.status = response.status
data = serviceError
}
return { raw: response, data, error: true }
}
function processError(req, error) {
const { processError } = options
const res = { res: { raw: {}, data: error, error: true } }
return Promise.resolve(processError ? processError(req, res) : res)
}
const COLLECTION_DELIM = { csv: ',', multi: '&', pipes: '|', ssv: ' ', tsv: '\t' }
export function formatArrayParam(array, format, name) {
if (!array) return
if (format === 'multi') return array.map(value => createQueryParam(name, value))
const delim = COLLECTION_DELIM[format]
if (!delim) throw new Error(`Invalid collection format '${format}'`)
return array.map(formatParam).join(delim)
}
export function formatDate(date, format) {
if (!date) return
const str = date.toISOString()
return (format === 'date') ? str.split('T')[0] : str
}

View File

@ -0,0 +1,23 @@
// Auto-generated, edits will be overwritten
const spec = {
'host': 'localhost',
'schemes': [
'http'
],
'basePath': '/api/v1',
'contentTypes': [
'application/zrok.v1+json'
],
'accepts': [
'application/zrok.v1+json'
],
'securityDefinitions': {
'key': {
'type': 'apiKey',
'in': 'header',
'name': 'x-token'
}
}
}
export default spec

View File

@ -0,0 +1,209 @@
/** @module metadata */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
*/
export function configuration() {
return gateway.request(configurationOperation)
}
/**
*/
export function getAccountDetail() {
return gateway.request(getAccountDetailOperation)
}
/**
* @param {string} envZId
* @return {Promise<module:types.environmentAndResources>} ok
*/
export function getEnvironmentDetail(envZId) {
const parameters = {
path: {
envZId
}
}
return gateway.request(getEnvironmentDetailOperation, parameters)
}
/**
* @param {number} feId
* @return {Promise<module:types.frontend>} ok
*/
export function getFrontendDetail(feId) {
const parameters = {
path: {
feId
}
}
return gateway.request(getFrontendDetailOperation, parameters)
}
/**
* @param {string} shrToken
* @return {Promise<module:types.share>} ok
*/
export function getShareDetail(shrToken) {
const parameters = {
path: {
shrToken
}
}
return gateway.request(getShareDetailOperation, parameters)
}
/**
*/
export function overview() {
return gateway.request(overviewOperation)
}
/**
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} account metrics
*/
export function getAccountMetrics(options) {
if (!options) options = {}
const parameters = {
query: {
duration: options.duration
}
}
return gateway.request(getAccountMetricsOperation, parameters)
}
/**
* @param {string} envId
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} environment metrics
*/
export function getEnvironmentMetrics(envId, options) {
if (!options) options = {}
const parameters = {
path: {
envId
},
query: {
duration: options.duration
}
}
return gateway.request(getEnvironmentMetricsOperation, parameters)
}
/**
* @param {string} shrToken
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} share metrics
*/
export function getShareMetrics(shrToken, options) {
if (!options) options = {}
const parameters = {
path: {
shrToken
},
query: {
duration: options.duration
}
}
return gateway.request(getShareMetricsOperation, parameters)
}
/**
*/
export function version() {
return gateway.request(versionOperation)
}
const configurationOperation = {
path: '/configuration',
method: 'get'
}
const getAccountDetailOperation = {
path: '/detail/account',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getEnvironmentDetailOperation = {
path: '/detail/environment/{envZId}',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getFrontendDetailOperation = {
path: '/detail/frontend/{feId}',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getShareDetailOperation = {
path: '/detail/share/{shrToken}',
method: 'get',
security: [
{
id: 'key'
}
]
}
const overviewOperation = {
path: '/overview',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getAccountMetricsOperation = {
path: '/metrics/account',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getEnvironmentMetricsOperation = {
path: '/metrics/environment/{envId}',
method: 'get',
security: [
{
id: 'key'
}
]
}
const getShareMetricsOperation = {
path: '/metrics/share/{shrToken}',
method: 'get',
security: [
{
id: 'key'
}
]
}
const versionOperation = {
path: '/version',
method: 'get'
}

View File

@ -0,0 +1,133 @@
/** @module share */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {module:types.accessRequest} [options.body]
* @return {Promise<module:types.accessResponse>} access created
*/
export function access(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(accessOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.shareRequest} [options.body]
* @return {Promise<module:types.shareResponse>} share created
*/
export function share(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(shareOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.updateShareRequest} [options.body]
* @return {Promise<object>} share updated
*/
export function updateShare(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(updateShareOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.unaccessRequest} [options.body]
* @return {Promise<object>} access removed
*/
export function unaccess(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(unaccessOperation, parameters)
}
/**
* @param {object} options Optional options
* @param {module:types.unshareRequest} [options.body]
* @return {Promise<object>} share removed
*/
export function unshare(options) {
if (!options) options = {}
const parameters = {
body: {
body: options.body
}
}
return gateway.request(unshareOperation, parameters)
}
const accessOperation = {
path: '/access',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const shareOperation = {
path: '/share',
contentTypes: ['application/zrok.v1+json'],
method: 'post',
security: [
{
id: 'key'
}
]
}
const updateShareOperation = {
path: '/share',
contentTypes: ['application/zrok.v1+json'],
method: 'patch',
security: [
{
id: 'key'
}
]
}
const unaccessOperation = {
path: '/unaccess',
contentTypes: ['application/zrok.v1+json'],
method: 'delete',
security: [
{
id: 'key'
}
]
}
const unshareOperation = {
path: '/unshare',
contentTypes: ['application/zrok.v1+json'],
method: 'delete',
security: [
{
id: 'key'
}
]
}

View File

@ -0,0 +1,325 @@
/** @module types */
// Auto-generated, edits will be overwritten
/**
* @typedef accessRequest
* @memberof module:types
*
* @property {string} envZId
* @property {string} shrToken
*/
/**
* @typedef accessResponse
* @memberof module:types
*
* @property {string} frontendToken
* @property {string} backendMode
*/
/**
* @typedef authUser
* @memberof module:types
*
* @property {string} username
* @property {string} password
*/
/**
* @typedef configuration
* @memberof module:types
*
* @property {string} version
* @property {string} touLink
* @property {boolean} invitesOpen
* @property {boolean} requiresInviteToken
* @property {string} inviteTokenContact
* @property {module:types.passwordRequirements} passwordRequirements
*/
/**
* @typedef createFrontendRequest
* @memberof module:types
*
* @property {string} zId
* @property {string} url_template
* @property {string} public_name
*/
/**
* @typedef createFrontendResponse
* @memberof module:types
*
* @property {string} token
*/
/**
* @typedef deleteFrontendRequest
* @memberof module:types
*
* @property {string} frontendToken
*/
/**
* @typedef disableRequest
* @memberof module:types
*
* @property {string} identity
*/
/**
* @typedef enableRequest
* @memberof module:types
*
* @property {string} description
* @property {string} host
*/
/**
* @typedef enableResponse
* @memberof module:types
*
* @property {string} identity
* @property {string} cfg
*/
/**
* @typedef environment
* @memberof module:types
*
* @property {string} description
* @property {string} host
* @property {string} address
* @property {string} zId
* @property {module:types.sparkData} activity
* @property {boolean} limited
* @property {number} createdAt
* @property {number} updatedAt
*/
/**
* @typedef environmentAndResources
* @memberof module:types
*
* @property {module:types.environment} environment
* @property {module:types.frontends} frontends
* @property {module:types.shares} shares
*/
/**
* @typedef frontend
* @memberof module:types
*
* @property {number} id
* @property {string} shrToken
* @property {string} zId
* @property {number} createdAt
* @property {number} updatedAt
*/
/**
* @typedef inviteTokenGenerateRequest
* @memberof module:types
*
* @property {string[]} tokens
*/
/**
* @typedef inviteRequest
* @memberof module:types
*
* @property {string} email
* @property {string} token
*/
/**
* @typedef loginRequest
* @memberof module:types
*
* @property {string} email
* @property {string} password
*/
/**
* @typedef metrics
* @memberof module:types
*
* @property {string} scope
* @property {string} id
* @property {number} period
* @property {module:types.metricsSample[]} samples
*/
/**
* @typedef metricsSample
* @memberof module:types
*
* @property {number} rx
* @property {number} tx
* @property {number} timestamp
*/
/**
* @typedef overview
* @memberof module:types
*
* @property {boolean} accountLimited
* @property {module:types.environmentAndResources[]} environments
*/
/**
* @typedef passwordRequirements
* @memberof module:types
*
* @property {number} length
* @property {boolean} requireCapital
* @property {boolean} requireNumeric
* @property {boolean} requireSpecial
* @property {string} validSpecialCharacters
*/
/**
* @typedef principal
* @memberof module:types
*
* @property {number} id
* @property {string} email
* @property {string} token
* @property {boolean} limitless
* @property {boolean} admin
*/
/**
* @typedef publicFrontend
* @memberof module:types
*
* @property {string} token
* @property {string} zId
* @property {string} urlTemplate
* @property {string} publicName
* @property {number} createdAt
* @property {number} updatedAt
*/
/**
* @typedef registerRequest
* @memberof module:types
*
* @property {string} token
* @property {string} password
*/
/**
* @typedef registerResponse
* @memberof module:types
*
* @property {string} token
*/
/**
* @typedef resetPasswordRequest
* @memberof module:types
*
* @property {string} token
* @property {string} password
*/
/**
* @typedef share
* @memberof module:types
*
* @property {string} token
* @property {string} zId
* @property {string} shareMode
* @property {string} backendMode
* @property {string} frontendSelection
* @property {string} frontendEndpoint
* @property {string} backendProxyEndpoint
* @property {boolean} reserved
* @property {module:types.sparkData} activity
* @property {boolean} limited
* @property {number} createdAt
* @property {number} updatedAt
*/
/**
* @typedef shareRequest
* @memberof module:types
*
* @property {string} envZId
* @property {string} shareMode
* @property {string[]} frontendSelection
* @property {string} backendMode
* @property {string} backendProxyEndpoint
* @property {string} authScheme
* @property {module:types.authUser[]} authUsers
* @property {string} oauthProvider
* @property {string[]} oauthEmailDomains
* @property {string} oauthAuthorizationCheckInterval
* @property {boolean} reserved
*/
/**
* @typedef shareResponse
* @memberof module:types
*
* @property {string[]} frontendProxyEndpoints
* @property {string} shrToken
*/
/**
* @typedef sparkDataSample
* @memberof module:types
*
* @property {number} rx
* @property {number} tx
*/
/**
* @typedef unaccessRequest
* @memberof module:types
*
* @property {string} frontendToken
* @property {string} envZId
* @property {string} shrToken
*/
/**
* @typedef unshareRequest
* @memberof module:types
*
* @property {string} envZId
* @property {string} shrToken
* @property {boolean} reserved
*/
/**
* @typedef updateFrontendRequest
* @memberof module:types
*
* @property {string} frontendToken
* @property {string} publicName
* @property {string} urlTemplate
*/
/**
* @typedef updateShareRequest
* @memberof module:types
*
* @property {string} shrToken
* @property {string} backendProxyEndpoint
*/
/**
* @typedef verifyRequest
* @memberof module:types
*
* @property {string} token
*/
/**
* @typedef verifyResponse
* @memberof module:types
*
* @property {string} email
*/

View File

@ -0,0 +1,61 @@
PROXY_BACKEND_MODE = "proxy"
WEB_BACKEND_MODE = "web"
TCP_TUNNEL_BACKEND_MODE = "tcpTunnel"
UDP_TUNNEL_BACKEND_MODE = "udpTunnel"
CADDY_BACKEND_MODE = "caddy"
PRIVATE_SHARE_MODE = "private"
PUBLIC_SHARE_MODE = "public"
export class ShareRequest {
constructor(backendMode, shareMode, target, frontends, basicAuth, oauthProvider, oauthEmailDomains, oauthAuthorizationCheckInterval) {
this.backendMode = backendMode
this.shareMode = shareMode
this.target = target
this.frontends = frontends
this.basicAuth = basicAuth
this.oauthProvider = oauthProvider
this.oauthEmailDomains = oauthEmailDomains
this.oauthAuthorizationCheckInterval = oauthAuthorizationCheckInterval
}
}
export class Share {
constructor(token, frontendEndpoints) {
this.token = token
this.frontendEndpoints = frontendEndpoints
}
}
export class AccessRequest {
constructor(shareToken) {
this.shareToken = shareToken
}
}
export class Access {
constructor(token, shareToken, backendMode) {
this.token = token
this.shareToken = shareToken
this.backendMode = backendMode
}
}
export class SessionMetrics {
constructor(bytesRead, bytesWritten, lastUpdate) {
this.bytesRead = bytesRead
this.bytesWritten = bytesWritten
this.lastUpdate = lastUpdate
}
}
export class Metrics {
constructor(namespace, sessions) {
this.namespace = namespace
this.sessions = sessions
}
}
AUTH_SCHEME_NONE = "none"
AUTH_SCHEME_BASIC = "basic"
AUTH_SCHEME_OAUTH = "oauth"

View File

@ -0,0 +1,7 @@
import {Root} from "../environment/root"
function Overview(root) {
if (!root.IsEnabled()){
throw new Error("environment is not enabled; enable with 'zrok enable' first!")
}
}

View File

@ -0,0 +1,71 @@
import {Root} from "../environment/root"
import {shareRequest, unshareRequest, authUser} from "./api/types"
import {share, unshare} from "./api/share"
import * as model from "./model"
function CreateShare(root, request) {
if (!root.IsEnabled()){
throw new Error("environment is not enabled; enable with 'zrok enable' first!")
}
switch(request.shareMode) {
case model.PRIVATE_SHARE_MODE:
out = newPrivateShare(root, request)
break
case model.PUBLIC_SHARE_MODE:
out = newPublicShare(root, request)
break
default:
throw new Error("unknown share mode " + request.shareMode)
}
if (request.basicAuth.length > 0) {
out.auth_scheme = model.AUTH_SCHEME_BASIC
for(pair in request.basicAuth) {
tokens = pair.split(":")
if (tokens.length === 2) {
out.auth_users.push(authUser(tokens[0].strip(), tokens[1].strip()))
}
else {
throw new Error("invalid username:password pair: " + pair)
}
}
}
if (request.oauthProvider !== "") {
out.auth_scheme = model.AUTH_SCHEME_OAUTH
}
console.log(out)
root.Client()
share({body: out})
.catch(resp => {
throw new Error("unable tp create share", resp)
})
}
function newPrivateShare(root, request) {
return shareRequest(root.env.ZitiIdentity,
request.shareMode,
request.backendMode,
request.target,
model.AUTH_SCHEME_NONE)
}
function newPublicShare(root, request) {
return shareRequest(root.env.ZitiIdentity,
request.shareMode,
request.backendMode,
request.target,
model.AUTH_SCHEME_NONE,
request.oauthEmailDomains,
request.oauthProvider,
request.oauthAuthroizationCheckInterval)
}
function DeleteShare(root, shr) {
req = unshareRequest(root.env.ZitiIdentity, shr.Token)
root.Client()
unshare({body:req})
.catch(resp => {
throw new Error("error deleting share", resp)
})
}

View File

@ -0,0 +1,60 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/environment/dirs.ts
var dirs_exports = {};
__export(dirs_exports, {
configFile: () => configFile,
environmentFile: () => environmentFile,
identitiesDir: () => identitiesDir,
identityFile: () => identityFile,
metadataFile: () => metadataFile,
rootDir: () => rootDir
});
module.exports = __toCommonJS(dirs_exports);
var import_os = require("os");
var import_node_path = require("path");
function rootDir() {
return (0, import_node_path.join)((0, import_os.homedir)(), ".zrok");
}
function metadataFile() {
return (0, import_node_path.join)(rootDir(), "metadata.json");
}
function configFile() {
return (0, import_node_path.join)(rootDir(), "config.json");
}
function environmentFile() {
return (0, import_node_path.join)(rootDir(), "environment.json");
}
function identitiesDir() {
return (0, import_node_path.join)(rootDir(), "identities");
}
function identityFile(name) {
return (0, import_node_path.join)(identitiesDir(), name + ".json");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
configFile,
environmentFile,
identitiesDir,
identityFile,
metadataFile,
rootDir
});
//# sourceMappingURL=dirs.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/environment/dirs.ts"],"sourcesContent":["import { homedir } from \"os\"\nimport { join } from \"node:path\"\n\nexport function rootDir(): string {\n return join(homedir(), \".zrok\")\n}\n\nexport function metadataFile(): string {\n return join(rootDir(), \"metadata.json\")\n}\n\nexport function configFile(): string {\n return join(rootDir(), \"config.json\")\n}\n\nexport function environmentFile(): string {\n return join(rootDir(), \"environment.json\")\n}\n\nexport function identitiesDir(): string {\n return join(rootDir(), \"identities\")\n}\n\nexport function identityFile(name: string): string {\n return join(identitiesDir(), name + \".json\")\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAwB;AACxB,uBAAqB;AAEd,SAAS,UAAkB;AAC9B,aAAO,2BAAK,mBAAQ,GAAG,OAAO;AAClC;AAEO,SAAS,eAAuB;AACnC,aAAO,uBAAK,QAAQ,GAAG,eAAe;AAC1C;AAEO,SAAS,aAAqB;AACjC,aAAO,uBAAK,QAAQ,GAAG,aAAa;AACxC;AAEO,SAAS,kBAA0B;AACtC,aAAO,uBAAK,QAAQ,GAAG,kBAAkB;AAC7C;AAEO,SAAS,gBAAwB;AACpC,aAAO,uBAAK,QAAQ,GAAG,YAAY;AACvC;AAEO,SAAS,aAAa,MAAsB;AAC/C,aAAO,uBAAK,cAAc,GAAG,OAAO,OAAO;AAC/C;","names":[]}

View File

@ -0,0 +1,30 @@
// src/environment/dirs.ts
import { homedir } from "os";
import { join } from "path";
function rootDir() {
return join(homedir(), ".zrok");
}
function metadataFile() {
return join(rootDir(), "metadata.json");
}
function configFile() {
return join(rootDir(), "config.json");
}
function environmentFile() {
return join(rootDir(), "environment.json");
}
function identitiesDir() {
return join(rootDir(), "identities");
}
function identityFile(name) {
return join(identitiesDir(), name + ".json");
}
export {
configFile,
environmentFile,
identitiesDir,
identityFile,
metadataFile,
rootDir
};
//# sourceMappingURL=dirs.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/environment/dirs.ts"],"sourcesContent":["import { homedir } from \"os\"\nimport { join } from \"node:path\"\n\nexport function rootDir(): string {\n return join(homedir(), \".zrok\")\n}\n\nexport function metadataFile(): string {\n return join(rootDir(), \"metadata.json\")\n}\n\nexport function configFile(): string {\n return join(rootDir(), \"config.json\")\n}\n\nexport function environmentFile(): string {\n return join(rootDir(), \"environment.json\")\n}\n\nexport function identitiesDir(): string {\n return join(rootDir(), \"identities\")\n}\n\nexport function identityFile(name: string): string {\n return join(identitiesDir(), name + \".json\")\n}"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,YAAY;AAEd,SAAS,UAAkB;AAC9B,SAAO,KAAK,QAAQ,GAAG,OAAO;AAClC;AAEO,SAAS,eAAuB;AACnC,SAAO,KAAK,QAAQ,GAAG,eAAe;AAC1C;AAEO,SAAS,aAAqB;AACjC,SAAO,KAAK,QAAQ,GAAG,aAAa;AACxC;AAEO,SAAS,kBAA0B;AACtC,SAAO,KAAK,QAAQ,GAAG,kBAAkB;AAC7C;AAEO,SAAS,gBAAwB;AACpC,SAAO,KAAK,QAAQ,GAAG,YAAY;AACvC;AAEO,SAAS,aAAa,MAAsB;AAC/C,SAAO,KAAK,cAAc,GAAG,OAAO,OAAO;AAC/C;","names":[]}

949
sdk/node/sdk_ts/dist/environment/root.js vendored Normal file
View File

@ -0,0 +1,949 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/environment/root.ts
var root_exports = {};
__export(root_exports, {
ApiEndpoint: () => ApiEndpoint,
Assert: () => Assert,
Config: () => Config,
Environment: () => Environment,
Load: () => Load,
Metadata: () => Metadata,
Root: () => Root
});
module.exports = __toCommonJS(root_exports);
// src/environment/dirs.ts
var import_os = require("os");
var import_node_path = require("path");
function rootDir() {
return (0, import_node_path.join)((0, import_os.homedir)(), ".zrok");
}
function metadataFile() {
return (0, import_node_path.join)(rootDir(), "metadata.json");
}
function configFile() {
return (0, import_node_path.join)(rootDir(), "config.json");
}
function environmentFile() {
return (0, import_node_path.join)(rootDir(), "environment.json");
}
function identitiesDir() {
return (0, import_node_path.join)(rootDir(), "identities");
}
function identityFile(name) {
return (0, import_node_path.join)(identitiesDir(), name + ".json");
}
// src/environment/root.ts
var import_node_fs = __toESM(require("fs"));
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = "RequiredError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/SparkDataSample.ts
function SparkDataSampleFromJSON(json) {
return SparkDataSampleFromJSONTyped(json, false);
}
function SparkDataSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"]
};
}
// src/zrok/api/models/Environment.ts
function EnvironmentFromJSON(json) {
return EnvironmentFromJSONTyped(json, false);
}
function EnvironmentFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"description": !exists(json, "description") ? void 0 : json["description"],
"host": !exists(json, "host") ? void 0 : json["host"],
"address": !exists(json, "address") ? void 0 : json["address"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Frontend.ts
function FrontendFromJSON(json) {
return FrontendFromJSONTyped(json, false);
}
function FrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"id": !exists(json, "id") ? void 0 : json["id"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Share.ts
function ShareFromJSON(json) {
return ShareFromJSONTyped(json, false);
}
function ShareFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"shareMode": !exists(json, "shareMode") ? void 0 : json["shareMode"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"],
"frontendSelection": !exists(json, "frontendSelection") ? void 0 : json["frontendSelection"],
"frontendEndpoint": !exists(json, "frontendEndpoint") ? void 0 : json["frontendEndpoint"],
"backendProxyEndpoint": !exists(json, "backendProxyEndpoint") ? void 0 : json["backendProxyEndpoint"],
"reserved": !exists(json, "reserved") ? void 0 : json["reserved"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/EnvironmentAndResources.ts
function EnvironmentAndResourcesFromJSON(json) {
return EnvironmentAndResourcesFromJSONTyped(json, false);
}
function EnvironmentAndResourcesFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"environment": !exists(json, "environment") ? void 0 : EnvironmentFromJSON(json["environment"]),
"frontends": !exists(json, "frontends") ? void 0 : json["frontends"].map(FrontendFromJSON),
"shares": !exists(json, "shares") ? void 0 : json["shares"].map(ShareFromJSON)
};
}
// src/zrok/api/models/MetricsSample.ts
function MetricsSampleFromJSON(json) {
return MetricsSampleFromJSONTyped(json, false);
}
function MetricsSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"],
"timestamp": !exists(json, "timestamp") ? void 0 : json["timestamp"]
};
}
// src/zrok/api/models/Metrics.ts
function MetricsFromJSON(json) {
return MetricsFromJSONTyped(json, false);
}
function MetricsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"scope": !exists(json, "scope") ? void 0 : json["scope"],
"id": !exists(json, "id") ? void 0 : json["id"],
"period": !exists(json, "period") ? void 0 : json["period"],
"samples": !exists(json, "samples") ? void 0 : json["samples"].map(MetricsSampleFromJSON)
};
}
// src/zrok/api/models/PasswordRequirements.ts
function PasswordRequirementsFromJSON(json) {
return PasswordRequirementsFromJSONTyped(json, false);
}
function PasswordRequirementsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"length": !exists(json, "length") ? void 0 : json["length"],
"requireCapital": !exists(json, "requireCapital") ? void 0 : json["requireCapital"],
"requireNumeric": !exists(json, "requireNumeric") ? void 0 : json["requireNumeric"],
"requireSpecial": !exists(json, "requireSpecial") ? void 0 : json["requireSpecial"],
"validSpecialCharacters": !exists(json, "validSpecialCharacters") ? void 0 : json["validSpecialCharacters"]
};
}
// src/zrok/api/models/ModelConfiguration.ts
function ModelConfigurationFromJSON(json) {
return ModelConfigurationFromJSONTyped(json, false);
}
function ModelConfigurationFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"version": !exists(json, "version") ? void 0 : json["version"],
"touLink": !exists(json, "touLink") ? void 0 : json["touLink"],
"invitesOpen": !exists(json, "invitesOpen") ? void 0 : json["invitesOpen"],
"requiresInviteToken": !exists(json, "requiresInviteToken") ? void 0 : json["requiresInviteToken"],
"inviteTokenContact": !exists(json, "inviteTokenContact") ? void 0 : json["inviteTokenContact"],
"passwordRequirements": !exists(json, "passwordRequirements") ? void 0 : PasswordRequirementsFromJSON(json["passwordRequirements"])
};
}
// src/zrok/api/models/Overview.ts
function OverviewFromJSON(json) {
return OverviewFromJSONTyped(json, false);
}
function OverviewFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"accountLimited": !exists(json, "accountLimited") ? void 0 : json["accountLimited"],
"environments": !exists(json, "environments") ? void 0 : json["environments"].map(EnvironmentAndResourcesFromJSON)
};
}
// src/zrok/api/apis/MetadataApi.ts
var MetadataApi = class extends BaseAPI {
/**
*/
_configurationRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/configuration`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ModelConfigurationFromJSON(jsonValue));
});
}
/**
*/
_configuration(initOverrides) {
return __async(this, null, function* () {
const response = yield this._configurationRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountDetailRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EnvironmentFromJSON));
});
}
/**
*/
getAccountDetail(initOverrides) {
return __async(this, null, function* () {
const response = yield this.getAccountDetailRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getAccountMetrics() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.getAccountMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envZId === null || requestParameters.envZId === void 0) {
throw new RequiredError("envZId", "Required parameter requestParameters.envZId was null or undefined when calling getEnvironmentDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/environment/{envZId}`.replace(`{${"envZId"}}`, encodeURIComponent(String(requestParameters.envZId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnvironmentAndResourcesFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envId === null || requestParameters.envId === void 0) {
throw new RequiredError("envId", "Required parameter requestParameters.envId was null or undefined when calling getEnvironmentMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/environment/{envId}`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getFrontendDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.feId === null || requestParameters.feId === void 0) {
throw new RequiredError("feId", "Required parameter requestParameters.feId was null or undefined when calling getFrontendDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/frontend/{feId}`.replace(`{${"feId"}}`, encodeURIComponent(String(requestParameters.feId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => FrontendFromJSON(jsonValue));
});
}
/**
*/
getFrontendDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getFrontendDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareFromJSON(jsonValue));
});
}
/**
*/
getShareDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getShareMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
overviewRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/overview`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => OverviewFromJSON(jsonValue));
});
}
/**
*/
overview(initOverrides) {
return __async(this, null, function* () {
const response = yield this.overviewRaw(initOverrides);
return yield response.value();
});
}
/**
*/
versionRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/version`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
version(initOverrides) {
return __async(this, null, function* () {
const response = yield this.versionRaw(initOverrides);
return yield response.value();
});
}
};
// src/environment/root.ts
var V = "v0.4";
var Metadata = class {
constructor(V2, RootPath = "") {
this.V = V2;
this.RootPath = RootPath;
}
};
var ApiEndpoint = class {
constructor(endpoint, frm) {
this.endpoint = endpoint;
this.frm = frm;
}
};
var Config = class {
constructor(ApiEndpoint2) {
this.ApiEndpoint = ApiEndpoint2;
}
};
var Environment = class {
constructor(Token, ZitiIdentity, ApiEndpoint2) {
this.Token = Token;
this.ZitiIdentity = ZitiIdentity;
this.ApiEndpoint = ApiEndpoint2;
}
};
var Root = class {
constructor(meta = new Metadata(V, rootDir()), cfg, env) {
this.meta = meta;
this.cfg = cfg;
this.env = env;
}
HasConfig() {
return this.cfg !== void 0 && Object.keys(this.cfg).length === 0;
}
Client() {
let apiEndpoint = this.ApiEndpoint();
let conf = new Configuration({
basePath: apiEndpoint.endpoint + "/api/v1",
accessToken: this.env.Token
});
let mapi = new MetadataApi(conf);
let ver = mapi.version();
const regex = new RegExp("^(refs/(heads|tags)/)?" + V);
ver.then((v) => {
console.log("got version " + v);
if (!regex.test(v)) {
throw new Error("Expected a '" + V + "' version, received: '" + v + "'");
}
});
return conf;
}
ApiEndpoint() {
let apiEndpoint = "https://api.zrok.io";
let frm = "binary";
if (this.cfg.ApiEndpoint != "") {
apiEndpoint = this.cfg.ApiEndpoint;
frm = "config";
}
let env = process.env.ZROK_API_ENDPOINT;
if (env != null) {
apiEndpoint = env;
frm = "ZROK_API_ENDPOINT";
}
if (this.IsEnabled()) {
apiEndpoint = this.env.ApiEndpoint;
frm = "env";
}
return new ApiEndpoint(apiEndpoint.replace(/\/+$/, ""), frm);
}
IsEnabled() {
return this.env !== void 0 && Object.keys(this.env).length > 0;
}
PublicIdentityName() {
return "public";
}
EnvironmentIdentityName() {
return "environment";
}
ZitiIdentityName(name) {
return identityFile(name);
}
};
function Assert() {
if (rootExists()) {
let meta = loadMetadata();
return meta.V == V;
}
return false;
}
function Load() {
if (rootExists()) {
return new Root(loadMetadata(), loadConfig(), loadEnvironment());
}
throw new Error("unable to load root. Does not exist");
}
function rootExists() {
return import_node_fs.default.existsSync(metadataFile());
}
function loadMetadata() {
let mf = metadataFile();
let data = import_node_fs.default.readFileSync(mf);
let serial = JSON.parse(data.toString());
return new Metadata(serial.v);
}
function loadConfig() {
let cf = configFile();
let data = import_node_fs.default.readFileSync(cf);
let serial = JSON.parse(data.toString());
return new Config(serial.api_endpoint);
}
function loadEnvironment() {
let ef = environmentFile();
let data = import_node_fs.default.readFileSync(ef);
let serial = JSON.parse(data.toString());
return new Environment(serial.zrok_token, serial.ziti_identity, serial.api_endpoint);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ApiEndpoint,
Assert,
Config,
Environment,
Load,
Metadata,
Root
});
//# sourceMappingURL=root.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,909 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/environment/dirs.ts
import { homedir } from "os";
import { join } from "path";
function rootDir() {
return join(homedir(), ".zrok");
}
function metadataFile() {
return join(rootDir(), "metadata.json");
}
function configFile() {
return join(rootDir(), "config.json");
}
function environmentFile() {
return join(rootDir(), "environment.json");
}
function identitiesDir() {
return join(rootDir(), "identities");
}
function identityFile(name) {
return join(identitiesDir(), name + ".json");
}
// src/environment/root.ts
import fs from "fs";
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = "RequiredError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/SparkDataSample.ts
function SparkDataSampleFromJSON(json) {
return SparkDataSampleFromJSONTyped(json, false);
}
function SparkDataSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"]
};
}
// src/zrok/api/models/Environment.ts
function EnvironmentFromJSON(json) {
return EnvironmentFromJSONTyped(json, false);
}
function EnvironmentFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"description": !exists(json, "description") ? void 0 : json["description"],
"host": !exists(json, "host") ? void 0 : json["host"],
"address": !exists(json, "address") ? void 0 : json["address"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Frontend.ts
function FrontendFromJSON(json) {
return FrontendFromJSONTyped(json, false);
}
function FrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"id": !exists(json, "id") ? void 0 : json["id"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Share.ts
function ShareFromJSON(json) {
return ShareFromJSONTyped(json, false);
}
function ShareFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"shareMode": !exists(json, "shareMode") ? void 0 : json["shareMode"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"],
"frontendSelection": !exists(json, "frontendSelection") ? void 0 : json["frontendSelection"],
"frontendEndpoint": !exists(json, "frontendEndpoint") ? void 0 : json["frontendEndpoint"],
"backendProxyEndpoint": !exists(json, "backendProxyEndpoint") ? void 0 : json["backendProxyEndpoint"],
"reserved": !exists(json, "reserved") ? void 0 : json["reserved"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/EnvironmentAndResources.ts
function EnvironmentAndResourcesFromJSON(json) {
return EnvironmentAndResourcesFromJSONTyped(json, false);
}
function EnvironmentAndResourcesFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"environment": !exists(json, "environment") ? void 0 : EnvironmentFromJSON(json["environment"]),
"frontends": !exists(json, "frontends") ? void 0 : json["frontends"].map(FrontendFromJSON),
"shares": !exists(json, "shares") ? void 0 : json["shares"].map(ShareFromJSON)
};
}
// src/zrok/api/models/MetricsSample.ts
function MetricsSampleFromJSON(json) {
return MetricsSampleFromJSONTyped(json, false);
}
function MetricsSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"],
"timestamp": !exists(json, "timestamp") ? void 0 : json["timestamp"]
};
}
// src/zrok/api/models/Metrics.ts
function MetricsFromJSON(json) {
return MetricsFromJSONTyped(json, false);
}
function MetricsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"scope": !exists(json, "scope") ? void 0 : json["scope"],
"id": !exists(json, "id") ? void 0 : json["id"],
"period": !exists(json, "period") ? void 0 : json["period"],
"samples": !exists(json, "samples") ? void 0 : json["samples"].map(MetricsSampleFromJSON)
};
}
// src/zrok/api/models/PasswordRequirements.ts
function PasswordRequirementsFromJSON(json) {
return PasswordRequirementsFromJSONTyped(json, false);
}
function PasswordRequirementsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"length": !exists(json, "length") ? void 0 : json["length"],
"requireCapital": !exists(json, "requireCapital") ? void 0 : json["requireCapital"],
"requireNumeric": !exists(json, "requireNumeric") ? void 0 : json["requireNumeric"],
"requireSpecial": !exists(json, "requireSpecial") ? void 0 : json["requireSpecial"],
"validSpecialCharacters": !exists(json, "validSpecialCharacters") ? void 0 : json["validSpecialCharacters"]
};
}
// src/zrok/api/models/ModelConfiguration.ts
function ModelConfigurationFromJSON(json) {
return ModelConfigurationFromJSONTyped(json, false);
}
function ModelConfigurationFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"version": !exists(json, "version") ? void 0 : json["version"],
"touLink": !exists(json, "touLink") ? void 0 : json["touLink"],
"invitesOpen": !exists(json, "invitesOpen") ? void 0 : json["invitesOpen"],
"requiresInviteToken": !exists(json, "requiresInviteToken") ? void 0 : json["requiresInviteToken"],
"inviteTokenContact": !exists(json, "inviteTokenContact") ? void 0 : json["inviteTokenContact"],
"passwordRequirements": !exists(json, "passwordRequirements") ? void 0 : PasswordRequirementsFromJSON(json["passwordRequirements"])
};
}
// src/zrok/api/models/Overview.ts
function OverviewFromJSON(json) {
return OverviewFromJSONTyped(json, false);
}
function OverviewFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"accountLimited": !exists(json, "accountLimited") ? void 0 : json["accountLimited"],
"environments": !exists(json, "environments") ? void 0 : json["environments"].map(EnvironmentAndResourcesFromJSON)
};
}
// src/zrok/api/apis/MetadataApi.ts
var MetadataApi = class extends BaseAPI {
/**
*/
_configurationRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/configuration`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ModelConfigurationFromJSON(jsonValue));
});
}
/**
*/
_configuration(initOverrides) {
return __async(this, null, function* () {
const response = yield this._configurationRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountDetailRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EnvironmentFromJSON));
});
}
/**
*/
getAccountDetail(initOverrides) {
return __async(this, null, function* () {
const response = yield this.getAccountDetailRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getAccountMetrics() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.getAccountMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envZId === null || requestParameters.envZId === void 0) {
throw new RequiredError("envZId", "Required parameter requestParameters.envZId was null or undefined when calling getEnvironmentDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/environment/{envZId}`.replace(`{${"envZId"}}`, encodeURIComponent(String(requestParameters.envZId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnvironmentAndResourcesFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envId === null || requestParameters.envId === void 0) {
throw new RequiredError("envId", "Required parameter requestParameters.envId was null or undefined when calling getEnvironmentMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/environment/{envId}`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getFrontendDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.feId === null || requestParameters.feId === void 0) {
throw new RequiredError("feId", "Required parameter requestParameters.feId was null or undefined when calling getFrontendDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/frontend/{feId}`.replace(`{${"feId"}}`, encodeURIComponent(String(requestParameters.feId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => FrontendFromJSON(jsonValue));
});
}
/**
*/
getFrontendDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getFrontendDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareFromJSON(jsonValue));
});
}
/**
*/
getShareDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getShareMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
overviewRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/overview`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => OverviewFromJSON(jsonValue));
});
}
/**
*/
overview(initOverrides) {
return __async(this, null, function* () {
const response = yield this.overviewRaw(initOverrides);
return yield response.value();
});
}
/**
*/
versionRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/version`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
version(initOverrides) {
return __async(this, null, function* () {
const response = yield this.versionRaw(initOverrides);
return yield response.value();
});
}
};
// src/environment/root.ts
var V = "v0.4";
var Metadata = class {
constructor(V2, RootPath = "") {
this.V = V2;
this.RootPath = RootPath;
}
};
var ApiEndpoint = class {
constructor(endpoint, frm) {
this.endpoint = endpoint;
this.frm = frm;
}
};
var Config = class {
constructor(ApiEndpoint2) {
this.ApiEndpoint = ApiEndpoint2;
}
};
var Environment = class {
constructor(Token, ZitiIdentity, ApiEndpoint2) {
this.Token = Token;
this.ZitiIdentity = ZitiIdentity;
this.ApiEndpoint = ApiEndpoint2;
}
};
var Root = class {
constructor(meta = new Metadata(V, rootDir()), cfg, env) {
this.meta = meta;
this.cfg = cfg;
this.env = env;
}
HasConfig() {
return this.cfg !== void 0 && Object.keys(this.cfg).length === 0;
}
Client() {
let apiEndpoint = this.ApiEndpoint();
let conf = new Configuration({
basePath: apiEndpoint.endpoint + "/api/v1",
accessToken: this.env.Token
});
let mapi = new MetadataApi(conf);
let ver = mapi.version();
const regex = new RegExp("^(refs/(heads|tags)/)?" + V);
ver.then((v) => {
console.log("got version " + v);
if (!regex.test(v)) {
throw new Error("Expected a '" + V + "' version, received: '" + v + "'");
}
});
return conf;
}
ApiEndpoint() {
let apiEndpoint = "https://api.zrok.io";
let frm = "binary";
if (this.cfg.ApiEndpoint != "") {
apiEndpoint = this.cfg.ApiEndpoint;
frm = "config";
}
let env = process.env.ZROK_API_ENDPOINT;
if (env != null) {
apiEndpoint = env;
frm = "ZROK_API_ENDPOINT";
}
if (this.IsEnabled()) {
apiEndpoint = this.env.ApiEndpoint;
frm = "env";
}
return new ApiEndpoint(apiEndpoint.replace(/\/+$/, ""), frm);
}
IsEnabled() {
return this.env !== void 0 && Object.keys(this.env).length > 0;
}
PublicIdentityName() {
return "public";
}
EnvironmentIdentityName() {
return "environment";
}
ZitiIdentityName(name) {
return identityFile(name);
}
};
function Assert() {
if (rootExists()) {
let meta = loadMetadata();
return meta.V == V;
}
return false;
}
function Load() {
if (rootExists()) {
return new Root(loadMetadata(), loadConfig(), loadEnvironment());
}
throw new Error("unable to load root. Does not exist");
}
function rootExists() {
return fs.existsSync(metadataFile());
}
function loadMetadata() {
let mf = metadataFile();
let data = fs.readFileSync(mf);
let serial = JSON.parse(data.toString());
return new Metadata(serial.v);
}
function loadConfig() {
let cf = configFile();
let data = fs.readFileSync(cf);
let serial = JSON.parse(data.toString());
return new Config(serial.api_endpoint);
}
function loadEnvironment() {
let ef = environmentFile();
let data = fs.readFileSync(ef);
let serial = JSON.parse(data.toString());
return new Environment(serial.zrok_token, serial.ziti_identity, serial.api_endpoint);
}
export {
ApiEndpoint,
Assert,
Config,
Environment,
Load,
Metadata,
Root
};
//# sourceMappingURL=root.mjs.map

File diff suppressed because one or more lines are too long

1461
sdk/node/sdk_ts/dist/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
sdk/node/sdk_ts/dist/index.js.map vendored Normal file

File diff suppressed because one or more lines are too long

1394
sdk/node/sdk_ts/dist/index.mjs vendored Normal file

File diff suppressed because it is too large Load Diff

1
sdk/node/sdk_ts/dist/index.mjs.map vendored Normal file

File diff suppressed because one or more lines are too long

3392
sdk/node/sdk_ts/dist/zrok/api/api.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

3301
sdk/node/sdk_ts/dist/zrok/api/api.mjs vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

3271
sdk/node/sdk_ts/dist/zrok/api/api/apis.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

3224
sdk/node/sdk_ts/dist/zrok/api/api/apis.mjs vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,594 @@
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/apis/AccountApi.ts
var AccountApi_exports = {};
__export(AccountApi_exports, {
AccountApi: () => AccountApi
});
module.exports = __toCommonJS(AccountApi_exports);
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/InviteRequest.ts
function InviteRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"email": value.email,
"token": value.token
};
}
// src/zrok/api/models/LoginRequest.ts
function LoginRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"email": value.email,
"password": value.password
};
}
// src/zrok/api/models/RegisterRequest.ts
function RegisterRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token,
"password": value.password
};
}
// src/zrok/api/models/RegisterResponse.ts
function RegisterResponseFromJSON(json) {
return RegisterResponseFromJSONTyped(json, false);
}
function RegisterResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"]
};
}
// src/zrok/api/models/ResetPasswordRequest.ts
function ResetPasswordRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token,
"password": value.password
};
}
// src/zrok/api/models/ResetPasswordRequestRequest.ts
function ResetPasswordRequestRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"emailAddress": value.emailAddress
};
}
// src/zrok/api/models/VerifyRequest.ts
function VerifyRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token
};
}
// src/zrok/api/models/VerifyResponse.ts
function VerifyResponseFromJSON(json) {
return VerifyResponseFromJSONTyped(json, false);
}
function VerifyResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"email": !exists(json, "email") ? void 0 : json["email"]
};
}
// src/zrok/api/apis/AccountApi.ts
var AccountApi = class extends BaseAPI {
/**
*/
inviteRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/invite`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: InviteRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
invite() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.inviteRaw(requestParameters, initOverrides);
});
}
/**
*/
loginRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/login`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: LoginRequestToJSON(requestParameters.body)
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
login() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.loginRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
registerRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/register`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: RegisterRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => RegisterResponseFromJSON(jsonValue));
});
}
/**
*/
register() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.registerRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
resetPasswordRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/resetPassword`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ResetPasswordRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
resetPassword() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.resetPasswordRaw(requestParameters, initOverrides);
});
}
/**
*/
resetPasswordRequestRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/resetPasswordRequest`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ResetPasswordRequestRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
resetPasswordRequest() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.resetPasswordRequestRaw(requestParameters, initOverrides);
});
}
/**
*/
verifyRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/verify`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: VerifyRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => VerifyResponseFromJSON(jsonValue));
});
}
/**
*/
verify() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.verifyRaw(requestParameters, initOverrides);
return yield response.value();
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AccountApi
});
//# sourceMappingURL=AccountApi.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,570 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/InviteRequest.ts
function InviteRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"email": value.email,
"token": value.token
};
}
// src/zrok/api/models/LoginRequest.ts
function LoginRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"email": value.email,
"password": value.password
};
}
// src/zrok/api/models/RegisterRequest.ts
function RegisterRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token,
"password": value.password
};
}
// src/zrok/api/models/RegisterResponse.ts
function RegisterResponseFromJSON(json) {
return RegisterResponseFromJSONTyped(json, false);
}
function RegisterResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"]
};
}
// src/zrok/api/models/ResetPasswordRequest.ts
function ResetPasswordRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token,
"password": value.password
};
}
// src/zrok/api/models/ResetPasswordRequestRequest.ts
function ResetPasswordRequestRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"emailAddress": value.emailAddress
};
}
// src/zrok/api/models/VerifyRequest.ts
function VerifyRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"token": value.token
};
}
// src/zrok/api/models/VerifyResponse.ts
function VerifyResponseFromJSON(json) {
return VerifyResponseFromJSONTyped(json, false);
}
function VerifyResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"email": !exists(json, "email") ? void 0 : json["email"]
};
}
// src/zrok/api/apis/AccountApi.ts
var AccountApi = class extends BaseAPI {
/**
*/
inviteRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/invite`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: InviteRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
invite() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.inviteRaw(requestParameters, initOverrides);
});
}
/**
*/
loginRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/login`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: LoginRequestToJSON(requestParameters.body)
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
login() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.loginRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
registerRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/register`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: RegisterRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => RegisterResponseFromJSON(jsonValue));
});
}
/**
*/
register() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.registerRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
resetPasswordRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/resetPassword`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ResetPasswordRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
resetPassword() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.resetPasswordRaw(requestParameters, initOverrides);
});
}
/**
*/
resetPasswordRequestRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/resetPasswordRequest`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ResetPasswordRequestRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
resetPasswordRequest() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.resetPasswordRequestRaw(requestParameters, initOverrides);
});
}
/**
*/
verifyRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
const response = yield this.request({
path: `/verify`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: VerifyRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => VerifyResponseFromJSON(jsonValue));
});
}
/**
*/
verify() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.verifyRaw(requestParameters, initOverrides);
return yield response.value();
});
}
};
export {
AccountApi
};
//# sourceMappingURL=AccountApi.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,602 @@
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/apis/AdminApi.ts
var AdminApi_exports = {};
__export(AdminApi_exports, {
AdminApi: () => AdminApi
});
module.exports = __toCommonJS(AdminApi_exports);
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/CreateFrontendRequest.ts
function CreateFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"zId": value.zId,
"url_template": value.urlTemplate,
"public_name": value.publicName
};
}
// src/zrok/api/models/CreateFrontendResponse.ts
function CreateFrontendResponseFromJSON(json) {
return CreateFrontendResponseFromJSONTyped(json, false);
}
function CreateFrontendResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"]
};
}
// src/zrok/api/models/CreateIdentity201Response.ts
function CreateIdentity201ResponseFromJSON(json) {
return CreateIdentity201ResponseFromJSONTyped(json, false);
}
function CreateIdentity201ResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"identity": !exists(json, "identity") ? void 0 : json["identity"],
"cfg": !exists(json, "cfg") ? void 0 : json["cfg"]
};
}
// src/zrok/api/models/CreateIdentityRequest.ts
function CreateIdentityRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"name": value.name
};
}
// src/zrok/api/models/DeleteFrontendRequest.ts
function DeleteFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken
};
}
// src/zrok/api/models/InviteTokenGenerateRequest.ts
function InviteTokenGenerateRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"tokens": value.tokens
};
}
// src/zrok/api/models/PublicFrontend.ts
function PublicFrontendFromJSON(json) {
return PublicFrontendFromJSONTyped(json, false);
}
function PublicFrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"urlTemplate": !exists(json, "urlTemplate") ? void 0 : json["urlTemplate"],
"publicName": !exists(json, "publicName") ? void 0 : json["publicName"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/UpdateFrontendRequest.ts
function UpdateFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken,
"publicName": value.publicName,
"urlTemplate": value.urlTemplate
};
}
// src/zrok/api/apis/AdminApi.ts
var AdminApi = class extends BaseAPI {
/**
*/
createFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: CreateFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => CreateFrontendResponseFromJSON(jsonValue));
});
}
/**
*/
createFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.createFrontendRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
createIdentityRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/identity`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: CreateIdentityRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => CreateIdentity201ResponseFromJSON(jsonValue));
});
}
/**
*/
createIdentity() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.createIdentityRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
deleteFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: DeleteFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
deleteFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.deleteFrontendRaw(requestParameters, initOverrides);
});
}
/**
*/
inviteTokenGenerateRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/invite/token/generate`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: InviteTokenGenerateRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
inviteTokenGenerate() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.inviteTokenGenerateRaw(requestParameters, initOverrides);
});
}
/**
*/
listFrontendsRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontends`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(PublicFrontendFromJSON));
});
}
/**
*/
listFrontends(initOverrides) {
return __async(this, null, function* () {
const response = yield this.listFrontendsRaw(initOverrides);
return yield response.value();
});
}
/**
*/
updateFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "PATCH",
headers: headerParameters,
query: queryParameters,
body: UpdateFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
updateFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.updateFrontendRaw(requestParameters, initOverrides);
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AdminApi
});
//# sourceMappingURL=AdminApi.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,578 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/CreateFrontendRequest.ts
function CreateFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"zId": value.zId,
"url_template": value.urlTemplate,
"public_name": value.publicName
};
}
// src/zrok/api/models/CreateFrontendResponse.ts
function CreateFrontendResponseFromJSON(json) {
return CreateFrontendResponseFromJSONTyped(json, false);
}
function CreateFrontendResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"]
};
}
// src/zrok/api/models/CreateIdentity201Response.ts
function CreateIdentity201ResponseFromJSON(json) {
return CreateIdentity201ResponseFromJSONTyped(json, false);
}
function CreateIdentity201ResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"identity": !exists(json, "identity") ? void 0 : json["identity"],
"cfg": !exists(json, "cfg") ? void 0 : json["cfg"]
};
}
// src/zrok/api/models/CreateIdentityRequest.ts
function CreateIdentityRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"name": value.name
};
}
// src/zrok/api/models/DeleteFrontendRequest.ts
function DeleteFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken
};
}
// src/zrok/api/models/InviteTokenGenerateRequest.ts
function InviteTokenGenerateRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"tokens": value.tokens
};
}
// src/zrok/api/models/PublicFrontend.ts
function PublicFrontendFromJSON(json) {
return PublicFrontendFromJSONTyped(json, false);
}
function PublicFrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"urlTemplate": !exists(json, "urlTemplate") ? void 0 : json["urlTemplate"],
"publicName": !exists(json, "publicName") ? void 0 : json["publicName"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/UpdateFrontendRequest.ts
function UpdateFrontendRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken,
"publicName": value.publicName,
"urlTemplate": value.urlTemplate
};
}
// src/zrok/api/apis/AdminApi.ts
var AdminApi = class extends BaseAPI {
/**
*/
createFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: CreateFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => CreateFrontendResponseFromJSON(jsonValue));
});
}
/**
*/
createFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.createFrontendRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
createIdentityRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/identity`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: CreateIdentityRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => CreateIdentity201ResponseFromJSON(jsonValue));
});
}
/**
*/
createIdentity() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.createIdentityRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
deleteFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: DeleteFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
deleteFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.deleteFrontendRaw(requestParameters, initOverrides);
});
}
/**
*/
inviteTokenGenerateRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/invite/token/generate`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: InviteTokenGenerateRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
inviteTokenGenerate() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.inviteTokenGenerateRaw(requestParameters, initOverrides);
});
}
/**
*/
listFrontendsRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontends`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(PublicFrontendFromJSON));
});
}
/**
*/
listFrontends(initOverrides) {
return __async(this, null, function* () {
const response = yield this.listFrontendsRaw(initOverrides);
return yield response.value();
});
}
/**
*/
updateFrontendRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/frontend`,
method: "PATCH",
headers: headerParameters,
query: queryParameters,
body: UpdateFrontendRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
updateFrontend() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.updateFrontendRaw(requestParameters, initOverrides);
});
}
};
export {
AdminApi
};
//# sourceMappingURL=AdminApi.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,421 @@
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/apis/EnvironmentApi.ts
var EnvironmentApi_exports = {};
__export(EnvironmentApi_exports, {
EnvironmentApi: () => EnvironmentApi
});
module.exports = __toCommonJS(EnvironmentApi_exports);
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/DisableRequest.ts
function DisableRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"identity": value.identity
};
}
// src/zrok/api/models/EnableRequest.ts
function EnableRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"description": value.description,
"host": value.host
};
}
// src/zrok/api/models/EnableResponse.ts
function EnableResponseFromJSON(json) {
return EnableResponseFromJSONTyped(json, false);
}
function EnableResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"identity": !exists(json, "identity") ? void 0 : json["identity"],
"cfg": !exists(json, "cfg") ? void 0 : json["cfg"]
};
}
// src/zrok/api/apis/EnvironmentApi.ts
var EnvironmentApi = class extends BaseAPI {
/**
*/
disableRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/disable`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: DisableRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
disable() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.disableRaw(requestParameters, initOverrides);
});
}
/**
*/
enableRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/enable`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: EnableRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnableResponseFromJSON(jsonValue));
});
}
/**
*/
enable() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.enableRaw(requestParameters, initOverrides);
return yield response.value();
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
EnvironmentApi
});
//# sourceMappingURL=EnvironmentApi.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,397 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/DisableRequest.ts
function DisableRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"identity": value.identity
};
}
// src/zrok/api/models/EnableRequest.ts
function EnableRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"description": value.description,
"host": value.host
};
}
// src/zrok/api/models/EnableResponse.ts
function EnableResponseFromJSON(json) {
return EnableResponseFromJSONTyped(json, false);
}
function EnableResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"identity": !exists(json, "identity") ? void 0 : json["identity"],
"cfg": !exists(json, "cfg") ? void 0 : json["cfg"]
};
}
// src/zrok/api/apis/EnvironmentApi.ts
var EnvironmentApi = class extends BaseAPI {
/**
*/
disableRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/disable`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: DisableRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
disable() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.disableRaw(requestParameters, initOverrides);
});
}
/**
*/
enableRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/enable`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: EnableRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnableResponseFromJSON(jsonValue));
});
}
/**
*/
enable() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.enableRaw(requestParameters, initOverrides);
return yield response.value();
});
}
};
export {
EnvironmentApi
};
//# sourceMappingURL=EnvironmentApi.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,784 @@
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/apis/MetadataApi.ts
var MetadataApi_exports = {};
__export(MetadataApi_exports, {
MetadataApi: () => MetadataApi
});
module.exports = __toCommonJS(MetadataApi_exports);
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = "RequiredError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/SparkDataSample.ts
function SparkDataSampleFromJSON(json) {
return SparkDataSampleFromJSONTyped(json, false);
}
function SparkDataSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"]
};
}
// src/zrok/api/models/Environment.ts
function EnvironmentFromJSON(json) {
return EnvironmentFromJSONTyped(json, false);
}
function EnvironmentFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"description": !exists(json, "description") ? void 0 : json["description"],
"host": !exists(json, "host") ? void 0 : json["host"],
"address": !exists(json, "address") ? void 0 : json["address"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Frontend.ts
function FrontendFromJSON(json) {
return FrontendFromJSONTyped(json, false);
}
function FrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"id": !exists(json, "id") ? void 0 : json["id"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Share.ts
function ShareFromJSON(json) {
return ShareFromJSONTyped(json, false);
}
function ShareFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"shareMode": !exists(json, "shareMode") ? void 0 : json["shareMode"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"],
"frontendSelection": !exists(json, "frontendSelection") ? void 0 : json["frontendSelection"],
"frontendEndpoint": !exists(json, "frontendEndpoint") ? void 0 : json["frontendEndpoint"],
"backendProxyEndpoint": !exists(json, "backendProxyEndpoint") ? void 0 : json["backendProxyEndpoint"],
"reserved": !exists(json, "reserved") ? void 0 : json["reserved"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/EnvironmentAndResources.ts
function EnvironmentAndResourcesFromJSON(json) {
return EnvironmentAndResourcesFromJSONTyped(json, false);
}
function EnvironmentAndResourcesFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"environment": !exists(json, "environment") ? void 0 : EnvironmentFromJSON(json["environment"]),
"frontends": !exists(json, "frontends") ? void 0 : json["frontends"].map(FrontendFromJSON),
"shares": !exists(json, "shares") ? void 0 : json["shares"].map(ShareFromJSON)
};
}
// src/zrok/api/models/MetricsSample.ts
function MetricsSampleFromJSON(json) {
return MetricsSampleFromJSONTyped(json, false);
}
function MetricsSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"],
"timestamp": !exists(json, "timestamp") ? void 0 : json["timestamp"]
};
}
// src/zrok/api/models/Metrics.ts
function MetricsFromJSON(json) {
return MetricsFromJSONTyped(json, false);
}
function MetricsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"scope": !exists(json, "scope") ? void 0 : json["scope"],
"id": !exists(json, "id") ? void 0 : json["id"],
"period": !exists(json, "period") ? void 0 : json["period"],
"samples": !exists(json, "samples") ? void 0 : json["samples"].map(MetricsSampleFromJSON)
};
}
// src/zrok/api/models/PasswordRequirements.ts
function PasswordRequirementsFromJSON(json) {
return PasswordRequirementsFromJSONTyped(json, false);
}
function PasswordRequirementsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"length": !exists(json, "length") ? void 0 : json["length"],
"requireCapital": !exists(json, "requireCapital") ? void 0 : json["requireCapital"],
"requireNumeric": !exists(json, "requireNumeric") ? void 0 : json["requireNumeric"],
"requireSpecial": !exists(json, "requireSpecial") ? void 0 : json["requireSpecial"],
"validSpecialCharacters": !exists(json, "validSpecialCharacters") ? void 0 : json["validSpecialCharacters"]
};
}
// src/zrok/api/models/ModelConfiguration.ts
function ModelConfigurationFromJSON(json) {
return ModelConfigurationFromJSONTyped(json, false);
}
function ModelConfigurationFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"version": !exists(json, "version") ? void 0 : json["version"],
"touLink": !exists(json, "touLink") ? void 0 : json["touLink"],
"invitesOpen": !exists(json, "invitesOpen") ? void 0 : json["invitesOpen"],
"requiresInviteToken": !exists(json, "requiresInviteToken") ? void 0 : json["requiresInviteToken"],
"inviteTokenContact": !exists(json, "inviteTokenContact") ? void 0 : json["inviteTokenContact"],
"passwordRequirements": !exists(json, "passwordRequirements") ? void 0 : PasswordRequirementsFromJSON(json["passwordRequirements"])
};
}
// src/zrok/api/models/Overview.ts
function OverviewFromJSON(json) {
return OverviewFromJSONTyped(json, false);
}
function OverviewFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"accountLimited": !exists(json, "accountLimited") ? void 0 : json["accountLimited"],
"environments": !exists(json, "environments") ? void 0 : json["environments"].map(EnvironmentAndResourcesFromJSON)
};
}
// src/zrok/api/apis/MetadataApi.ts
var MetadataApi = class extends BaseAPI {
/**
*/
_configurationRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/configuration`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ModelConfigurationFromJSON(jsonValue));
});
}
/**
*/
_configuration(initOverrides) {
return __async(this, null, function* () {
const response = yield this._configurationRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountDetailRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EnvironmentFromJSON));
});
}
/**
*/
getAccountDetail(initOverrides) {
return __async(this, null, function* () {
const response = yield this.getAccountDetailRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getAccountMetrics() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.getAccountMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envZId === null || requestParameters.envZId === void 0) {
throw new RequiredError("envZId", "Required parameter requestParameters.envZId was null or undefined when calling getEnvironmentDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/environment/{envZId}`.replace(`{${"envZId"}}`, encodeURIComponent(String(requestParameters.envZId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnvironmentAndResourcesFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envId === null || requestParameters.envId === void 0) {
throw new RequiredError("envId", "Required parameter requestParameters.envId was null or undefined when calling getEnvironmentMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/environment/{envId}`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getFrontendDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.feId === null || requestParameters.feId === void 0) {
throw new RequiredError("feId", "Required parameter requestParameters.feId was null or undefined when calling getFrontendDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/frontend/{feId}`.replace(`{${"feId"}}`, encodeURIComponent(String(requestParameters.feId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => FrontendFromJSON(jsonValue));
});
}
/**
*/
getFrontendDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getFrontendDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareFromJSON(jsonValue));
});
}
/**
*/
getShareDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getShareMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
overviewRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/overview`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => OverviewFromJSON(jsonValue));
});
}
/**
*/
overview(initOverrides) {
return __async(this, null, function* () {
const response = yield this.overviewRaw(initOverrides);
return yield response.value();
});
}
/**
*/
versionRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/version`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
version(initOverrides) {
return __async(this, null, function* () {
const response = yield this.versionRaw(initOverrides);
return yield response.value();
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MetadataApi
});
//# sourceMappingURL=MetadataApi.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,760 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = "RequiredError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/zrok/api/models/SparkDataSample.ts
function SparkDataSampleFromJSON(json) {
return SparkDataSampleFromJSONTyped(json, false);
}
function SparkDataSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"]
};
}
// src/zrok/api/models/Environment.ts
function EnvironmentFromJSON(json) {
return EnvironmentFromJSONTyped(json, false);
}
function EnvironmentFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"description": !exists(json, "description") ? void 0 : json["description"],
"host": !exists(json, "host") ? void 0 : json["host"],
"address": !exists(json, "address") ? void 0 : json["address"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Frontend.ts
function FrontendFromJSON(json) {
return FrontendFromJSONTyped(json, false);
}
function FrontendFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"id": !exists(json, "id") ? void 0 : json["id"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/Share.ts
function ShareFromJSON(json) {
return ShareFromJSONTyped(json, false);
}
function ShareFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"token": !exists(json, "token") ? void 0 : json["token"],
"zId": !exists(json, "zId") ? void 0 : json["zId"],
"shareMode": !exists(json, "shareMode") ? void 0 : json["shareMode"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"],
"frontendSelection": !exists(json, "frontendSelection") ? void 0 : json["frontendSelection"],
"frontendEndpoint": !exists(json, "frontendEndpoint") ? void 0 : json["frontendEndpoint"],
"backendProxyEndpoint": !exists(json, "backendProxyEndpoint") ? void 0 : json["backendProxyEndpoint"],
"reserved": !exists(json, "reserved") ? void 0 : json["reserved"],
"activity": !exists(json, "activity") ? void 0 : json["activity"].map(SparkDataSampleFromJSON),
"limited": !exists(json, "limited") ? void 0 : json["limited"],
"createdAt": !exists(json, "createdAt") ? void 0 : json["createdAt"],
"updatedAt": !exists(json, "updatedAt") ? void 0 : json["updatedAt"]
};
}
// src/zrok/api/models/EnvironmentAndResources.ts
function EnvironmentAndResourcesFromJSON(json) {
return EnvironmentAndResourcesFromJSONTyped(json, false);
}
function EnvironmentAndResourcesFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"environment": !exists(json, "environment") ? void 0 : EnvironmentFromJSON(json["environment"]),
"frontends": !exists(json, "frontends") ? void 0 : json["frontends"].map(FrontendFromJSON),
"shares": !exists(json, "shares") ? void 0 : json["shares"].map(ShareFromJSON)
};
}
// src/zrok/api/models/MetricsSample.ts
function MetricsSampleFromJSON(json) {
return MetricsSampleFromJSONTyped(json, false);
}
function MetricsSampleFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"rx": !exists(json, "rx") ? void 0 : json["rx"],
"tx": !exists(json, "tx") ? void 0 : json["tx"],
"timestamp": !exists(json, "timestamp") ? void 0 : json["timestamp"]
};
}
// src/zrok/api/models/Metrics.ts
function MetricsFromJSON(json) {
return MetricsFromJSONTyped(json, false);
}
function MetricsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"scope": !exists(json, "scope") ? void 0 : json["scope"],
"id": !exists(json, "id") ? void 0 : json["id"],
"period": !exists(json, "period") ? void 0 : json["period"],
"samples": !exists(json, "samples") ? void 0 : json["samples"].map(MetricsSampleFromJSON)
};
}
// src/zrok/api/models/PasswordRequirements.ts
function PasswordRequirementsFromJSON(json) {
return PasswordRequirementsFromJSONTyped(json, false);
}
function PasswordRequirementsFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"length": !exists(json, "length") ? void 0 : json["length"],
"requireCapital": !exists(json, "requireCapital") ? void 0 : json["requireCapital"],
"requireNumeric": !exists(json, "requireNumeric") ? void 0 : json["requireNumeric"],
"requireSpecial": !exists(json, "requireSpecial") ? void 0 : json["requireSpecial"],
"validSpecialCharacters": !exists(json, "validSpecialCharacters") ? void 0 : json["validSpecialCharacters"]
};
}
// src/zrok/api/models/ModelConfiguration.ts
function ModelConfigurationFromJSON(json) {
return ModelConfigurationFromJSONTyped(json, false);
}
function ModelConfigurationFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"version": !exists(json, "version") ? void 0 : json["version"],
"touLink": !exists(json, "touLink") ? void 0 : json["touLink"],
"invitesOpen": !exists(json, "invitesOpen") ? void 0 : json["invitesOpen"],
"requiresInviteToken": !exists(json, "requiresInviteToken") ? void 0 : json["requiresInviteToken"],
"inviteTokenContact": !exists(json, "inviteTokenContact") ? void 0 : json["inviteTokenContact"],
"passwordRequirements": !exists(json, "passwordRequirements") ? void 0 : PasswordRequirementsFromJSON(json["passwordRequirements"])
};
}
// src/zrok/api/models/Overview.ts
function OverviewFromJSON(json) {
return OverviewFromJSONTyped(json, false);
}
function OverviewFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"accountLimited": !exists(json, "accountLimited") ? void 0 : json["accountLimited"],
"environments": !exists(json, "environments") ? void 0 : json["environments"].map(EnvironmentAndResourcesFromJSON)
};
}
// src/zrok/api/apis/MetadataApi.ts
var MetadataApi = class extends BaseAPI {
/**
*/
_configurationRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/configuration`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ModelConfigurationFromJSON(jsonValue));
});
}
/**
*/
_configuration(initOverrides) {
return __async(this, null, function* () {
const response = yield this._configurationRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountDetailRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(EnvironmentFromJSON));
});
}
/**
*/
getAccountDetail(initOverrides) {
return __async(this, null, function* () {
const response = yield this.getAccountDetailRaw(initOverrides);
return yield response.value();
});
}
/**
*/
getAccountMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/account`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getAccountMetrics() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.getAccountMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envZId === null || requestParameters.envZId === void 0) {
throw new RequiredError("envZId", "Required parameter requestParameters.envZId was null or undefined when calling getEnvironmentDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/environment/{envZId}`.replace(`{${"envZId"}}`, encodeURIComponent(String(requestParameters.envZId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => EnvironmentAndResourcesFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getEnvironmentMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.envId === null || requestParameters.envId === void 0) {
throw new RequiredError("envId", "Required parameter requestParameters.envId was null or undefined when calling getEnvironmentMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/environment/{envId}`.replace(`{${"envId"}}`, encodeURIComponent(String(requestParameters.envId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getEnvironmentMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getEnvironmentMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getFrontendDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.feId === null || requestParameters.feId === void 0) {
throw new RequiredError("feId", "Required parameter requestParameters.feId was null or undefined when calling getFrontendDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/frontend/{feId}`.replace(`{${"feId"}}`, encodeURIComponent(String(requestParameters.feId))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => FrontendFromJSON(jsonValue));
});
}
/**
*/
getFrontendDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getFrontendDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareDetailRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareDetail.");
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/detail/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareFromJSON(jsonValue));
});
}
/**
*/
getShareDetail(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareDetailRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
getShareMetricsRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
if (requestParameters.shrToken === null || requestParameters.shrToken === void 0) {
throw new RequiredError("shrToken", "Required parameter requestParameters.shrToken was null or undefined when calling getShareMetrics.");
}
const queryParameters = {};
if (requestParameters.duration !== void 0) {
queryParameters["duration"] = requestParameters.duration;
}
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/metrics/share/{shrToken}`.replace(`{${"shrToken"}}`, encodeURIComponent(String(requestParameters.shrToken))),
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => MetricsFromJSON(jsonValue));
});
}
/**
*/
getShareMetrics(requestParameters, initOverrides) {
return __async(this, null, function* () {
const response = yield this.getShareMetricsRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
overviewRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/overview`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => OverviewFromJSON(jsonValue));
});
}
/**
*/
overview(initOverrides) {
return __async(this, null, function* () {
const response = yield this.overviewRaw(initOverrides);
return yield response.value();
});
}
/**
*/
versionRaw(initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
const response = yield this.request({
path: `/version`,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new JSONApiResponse(response);
} else {
return new TextApiResponse(response);
}
});
}
/**
*/
version(initOverrides) {
return __async(this, null, function* () {
const response = yield this.versionRaw(initOverrides);
return yield response.value();
});
}
};
export {
MetadataApi
};
//# sourceMappingURL=MetadataApi.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,585 @@
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/apis/ShareApi.ts
var ShareApi_exports = {};
__export(ShareApi_exports, {
ShareApi: () => ShareApi
});
module.exports = __toCommonJS(ShareApi_exports);
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/AccessRequest.ts
function AccessRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shrToken": value.shrToken
};
}
// src/zrok/api/models/AccessResponse.ts
function AccessResponseFromJSON(json) {
return AccessResponseFromJSONTyped(json, false);
}
function AccessResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"frontendToken": !exists(json, "frontendToken") ? void 0 : json["frontendToken"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"]
};
}
// src/zrok/api/models/AuthUser.ts
function AuthUserToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"username": value.username,
"password": value.password
};
}
// src/zrok/api/models/ShareRequest.ts
function ShareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shareMode": value.shareMode,
"frontendSelection": value.frontendSelection,
"backendMode": value.backendMode,
"backendProxyEndpoint": value.backendProxyEndpoint,
"authScheme": value.authScheme,
"authUsers": value.authUsers === void 0 ? void 0 : value.authUsers.map(AuthUserToJSON),
"oauthProvider": value.oauthProvider,
"oauthEmailDomains": value.oauthEmailDomains,
"oauthAuthorizationCheckInterval": value.oauthAuthorizationCheckInterval,
"reserved": value.reserved
};
}
// src/zrok/api/models/ShareResponse.ts
function ShareResponseFromJSON(json) {
return ShareResponseFromJSONTyped(json, false);
}
function ShareResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"frontendProxyEndpoints": !exists(json, "frontendProxyEndpoints") ? void 0 : json["frontendProxyEndpoints"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"]
};
}
// src/zrok/api/models/UnaccessRequest.ts
function UnaccessRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken,
"envZId": value.envZId,
"shrToken": value.shrToken
};
}
// src/zrok/api/models/UnshareRequest.ts
function UnshareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shrToken": value.shrToken,
"reserved": value.reserved
};
}
// src/zrok/api/models/UpdateShareRequest.ts
function UpdateShareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"shrToken": value.shrToken,
"backendProxyEndpoint": value.backendProxyEndpoint
};
}
// src/zrok/api/apis/ShareApi.ts
var ShareApi = class extends BaseAPI {
/**
*/
accessRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/access`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: AccessRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => AccessResponseFromJSON(jsonValue));
});
}
/**
*/
access() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.accessRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
shareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/share`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ShareRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareResponseFromJSON(jsonValue));
});
}
/**
*/
share() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.shareRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
unaccessRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/unaccess`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: UnaccessRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
unaccess() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.unaccessRaw(requestParameters, initOverrides);
});
}
/**
*/
unshareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/unshare`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: UnshareRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
unshare() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.unshareRaw(requestParameters, initOverrides);
});
}
/**
*/
updateShareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/share`,
method: "PATCH",
headers: headerParameters,
query: queryParameters,
body: UpdateShareRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
updateShare() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.updateShareRaw(requestParameters, initOverrides);
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ShareApi
});
//# sourceMappingURL=ShareApi.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,561 @@
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/zrok/api/runtime.ts
var BASE_PATH = "/api/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
// src/zrok/api/models/AccessRequest.ts
function AccessRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shrToken": value.shrToken
};
}
// src/zrok/api/models/AccessResponse.ts
function AccessResponseFromJSON(json) {
return AccessResponseFromJSONTyped(json, false);
}
function AccessResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"frontendToken": !exists(json, "frontendToken") ? void 0 : json["frontendToken"],
"backendMode": !exists(json, "backendMode") ? void 0 : json["backendMode"]
};
}
// src/zrok/api/models/AuthUser.ts
function AuthUserToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"username": value.username,
"password": value.password
};
}
// src/zrok/api/models/ShareRequest.ts
function ShareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shareMode": value.shareMode,
"frontendSelection": value.frontendSelection,
"backendMode": value.backendMode,
"backendProxyEndpoint": value.backendProxyEndpoint,
"authScheme": value.authScheme,
"authUsers": value.authUsers === void 0 ? void 0 : value.authUsers.map(AuthUserToJSON),
"oauthProvider": value.oauthProvider,
"oauthEmailDomains": value.oauthEmailDomains,
"oauthAuthorizationCheckInterval": value.oauthAuthorizationCheckInterval,
"reserved": value.reserved
};
}
// src/zrok/api/models/ShareResponse.ts
function ShareResponseFromJSON(json) {
return ShareResponseFromJSONTyped(json, false);
}
function ShareResponseFromJSONTyped(json, ignoreDiscriminator) {
if (json === void 0 || json === null) {
return json;
}
return {
"frontendProxyEndpoints": !exists(json, "frontendProxyEndpoints") ? void 0 : json["frontendProxyEndpoints"],
"shrToken": !exists(json, "shrToken") ? void 0 : json["shrToken"]
};
}
// src/zrok/api/models/UnaccessRequest.ts
function UnaccessRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"frontendToken": value.frontendToken,
"envZId": value.envZId,
"shrToken": value.shrToken
};
}
// src/zrok/api/models/UnshareRequest.ts
function UnshareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"envZId": value.envZId,
"shrToken": value.shrToken,
"reserved": value.reserved
};
}
// src/zrok/api/models/UpdateShareRequest.ts
function UpdateShareRequestToJSON(value) {
if (value === void 0) {
return void 0;
}
if (value === null) {
return null;
}
return {
"shrToken": value.shrToken,
"backendProxyEndpoint": value.backendProxyEndpoint
};
}
// src/zrok/api/apis/ShareApi.ts
var ShareApi = class extends BaseAPI {
/**
*/
accessRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/access`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: AccessRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => AccessResponseFromJSON(jsonValue));
});
}
/**
*/
access() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.accessRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
shareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/share`,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: ShareRequestToJSON(requestParameters.body)
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ShareResponseFromJSON(jsonValue));
});
}
/**
*/
share() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
const response = yield this.shareRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
*/
unaccessRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/unaccess`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: UnaccessRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
unaccess() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.unaccessRaw(requestParameters, initOverrides);
});
}
/**
*/
unshareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/unshare`,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
body: UnshareRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
unshare() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.unshareRaw(requestParameters, initOverrides);
});
}
/**
*/
updateShareRaw(requestParameters, initOverrides) {
return __async(this, null, function* () {
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/zrok.v1+json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-token"] = this.configuration.apiKey("x-token");
}
const response = yield this.request({
path: `/share`,
method: "PATCH",
headers: headerParameters,
query: queryParameters,
body: UpdateShareRequestToJSON(requestParameters.body)
}, initOverrides);
return new VoidApiResponse(response);
});
}
/**
*/
updateShare() {
return __async(this, arguments, function* (requestParameters = {}, initOverrides) {
yield this.updateShareRaw(requestParameters, initOverrides);
});
}
};
export {
ShareApi
};
//# sourceMappingURL=ShareApi.mjs.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2763
sdk/node/sdk_ts/dist/zrok/api/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2564
sdk/node/sdk_ts/dist/zrok/api/index.mjs vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,49 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/zrok/api/model/accessRequest.ts
var accessRequest_exports = {};
__export(accessRequest_exports, {
AccessRequest: () => AccessRequest
});
module.exports = __toCommonJS(accessRequest_exports);
var _AccessRequest = class _AccessRequest {
static getAttributeTypeMap() {
return _AccessRequest.attributeTypeMap;
}
};
_AccessRequest.discriminator = void 0;
_AccessRequest.attributeTypeMap = [
{
"name": "envZId",
"baseName": "envZId",
"type": "string"
},
{
"name": "shrToken",
"baseName": "shrToken",
"type": "string"
}
];
var AccessRequest = _AccessRequest;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AccessRequest
});
//# sourceMappingURL=accessRequest.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/zrok/api/model/accessRequest.ts"],"sourcesContent":["/**\n * zrok\n * zrok client access\n *\n * The version of the OpenAPI document: 0.3.0\n * \n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport { RequestFile } from './models';\n\nexport class AccessRequest {\n 'envZId'?: string;\n 'shrToken'?: string;\n\n static discriminator: string | undefined = undefined;\n\n static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [\n {\n \"name\": \"envZId\",\n \"baseName\": \"envZId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"shrToken\",\n \"baseName\": \"shrToken\",\n \"type\": \"string\"\n } ];\n\n static getAttributeTypeMap() {\n return AccessRequest.attributeTypeMap;\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,IAAM,iBAAN,MAAM,eAAc;AAAA,EAkBvB,OAAO,sBAAsB;AACzB,WAAO,eAAc;AAAA,EACzB;AACJ;AArBa,eAIF,gBAAoC;AAJlC,eAMF,mBAA0E;AAAA,EAC7E;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAK;AAhBN,IAAM,gBAAN;","names":[]}

View File

@ -0,0 +1,24 @@
// src/zrok/api/model/accessRequest.ts
var _AccessRequest = class _AccessRequest {
static getAttributeTypeMap() {
return _AccessRequest.attributeTypeMap;
}
};
_AccessRequest.discriminator = void 0;
_AccessRequest.attributeTypeMap = [
{
"name": "envZId",
"baseName": "envZId",
"type": "string"
},
{
"name": "shrToken",
"baseName": "shrToken",
"type": "string"
}
];
var AccessRequest = _AccessRequest;
export {
AccessRequest
};
//# sourceMappingURL=accessRequest.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/zrok/api/model/accessRequest.ts"],"sourcesContent":["/**\n * zrok\n * zrok client access\n *\n * The version of the OpenAPI document: 0.3.0\n * \n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport { RequestFile } from './models';\n\nexport class AccessRequest {\n 'envZId'?: string;\n 'shrToken'?: string;\n\n static discriminator: string | undefined = undefined;\n\n static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [\n {\n \"name\": \"envZId\",\n \"baseName\": \"envZId\",\n \"type\": \"string\"\n },\n {\n \"name\": \"shrToken\",\n \"baseName\": \"shrToken\",\n \"type\": \"string\"\n } ];\n\n static getAttributeTypeMap() {\n return AccessRequest.attributeTypeMap;\n }\n}\n\n"],"mappings":";AAcO,IAAM,iBAAN,MAAM,eAAc;AAAA,EAkBvB,OAAO,sBAAsB;AACzB,WAAO,eAAc;AAAA,EACzB;AACJ;AArBa,eAIF,gBAAoC;AAJlC,eAMF,mBAA0E;AAAA,EAC7E;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAK;AAhBN,IAAM,gBAAN;","names":[]}

View File

@ -0,0 +1,49 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/zrok/api/model/accessResponse.ts
var accessResponse_exports = {};
__export(accessResponse_exports, {
AccessResponse: () => AccessResponse
});
module.exports = __toCommonJS(accessResponse_exports);
var _AccessResponse = class _AccessResponse {
static getAttributeTypeMap() {
return _AccessResponse.attributeTypeMap;
}
};
_AccessResponse.discriminator = void 0;
_AccessResponse.attributeTypeMap = [
{
"name": "frontendToken",
"baseName": "frontendToken",
"type": "string"
},
{
"name": "backendMode",
"baseName": "backendMode",
"type": "string"
}
];
var AccessResponse = _AccessResponse;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AccessResponse
});
//# sourceMappingURL=accessResponse.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/zrok/api/model/accessResponse.ts"],"sourcesContent":["/**\n * zrok\n * zrok client access\n *\n * The version of the OpenAPI document: 0.3.0\n * \n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport { RequestFile } from './models';\n\nexport class AccessResponse {\n 'frontendToken'?: string;\n 'backendMode'?: string;\n\n static discriminator: string | undefined = undefined;\n\n static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [\n {\n \"name\": \"frontendToken\",\n \"baseName\": \"frontendToken\",\n \"type\": \"string\"\n },\n {\n \"name\": \"backendMode\",\n \"baseName\": \"backendMode\",\n \"type\": \"string\"\n } ];\n\n static getAttributeTypeMap() {\n return AccessResponse.attributeTypeMap;\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,IAAM,kBAAN,MAAM,gBAAe;AAAA,EAkBxB,OAAO,sBAAsB;AACzB,WAAO,gBAAe;AAAA,EAC1B;AACJ;AArBa,gBAIF,gBAAoC;AAJlC,gBAMF,mBAA0E;AAAA,EAC7E;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAK;AAhBN,IAAM,iBAAN;","names":[]}

View File

@ -0,0 +1,24 @@
// src/zrok/api/model/accessResponse.ts
var _AccessResponse = class _AccessResponse {
static getAttributeTypeMap() {
return _AccessResponse.attributeTypeMap;
}
};
_AccessResponse.discriminator = void 0;
_AccessResponse.attributeTypeMap = [
{
"name": "frontendToken",
"baseName": "frontendToken",
"type": "string"
},
{
"name": "backendMode",
"baseName": "backendMode",
"type": "string"
}
];
var AccessResponse = _AccessResponse;
export {
AccessResponse
};
//# sourceMappingURL=accessResponse.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/zrok/api/model/accessResponse.ts"],"sourcesContent":["/**\n * zrok\n * zrok client access\n *\n * The version of the OpenAPI document: 0.3.0\n * \n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\nimport { RequestFile } from './models';\n\nexport class AccessResponse {\n 'frontendToken'?: string;\n 'backendMode'?: string;\n\n static discriminator: string | undefined = undefined;\n\n static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [\n {\n \"name\": \"frontendToken\",\n \"baseName\": \"frontendToken\",\n \"type\": \"string\"\n },\n {\n \"name\": \"backendMode\",\n \"baseName\": \"backendMode\",\n \"type\": \"string\"\n } ];\n\n static getAttributeTypeMap() {\n return AccessResponse.attributeTypeMap;\n }\n}\n\n"],"mappings":";AAcO,IAAM,kBAAN,MAAM,gBAAe;AAAA,EAkBxB,OAAO,sBAAsB;AACzB,WAAO,gBAAe;AAAA,EAC1B;AACJ;AArBa,gBAIF,gBAAoC;AAJlC,gBAMF,mBAA0E;AAAA,EAC7E;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,IACI,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAQ;AAAA,EACZ;AAAK;AAhBN,IAAM,iBAAN;","names":[]}

Some files were not shown because too many files have changed in this diff Show More