@xylabs/api
Advanced tools
Comparing version 2.11.22 to 2.11.23
@@ -1,10 +0,10 @@ | ||
// src/ApiClient.ts | ||
var ApiClient = class { | ||
import { ApiStage } from "./ApiStage"; | ||
class ApiClient { | ||
constructor(token, stage) { | ||
this.token = token; | ||
this.stage = stage; | ||
this.stage = stage ?? "prod" /* Prod */; | ||
this.stage = stage ?? ApiStage.Prod; | ||
this.token = token; | ||
} | ||
}; | ||
} | ||
export { | ||
@@ -11,0 +11,0 @@ ApiClient |
@@ -1,4 +0,3 @@ | ||
// src/ApiEndpoint.ts | ||
import axios from "axios"; | ||
var ApiEndpoint = class { | ||
class ApiEndpoint { | ||
_value; | ||
@@ -41,3 +40,3 @@ config; | ||
} | ||
}; | ||
} | ||
export { | ||
@@ -44,0 +43,0 @@ ApiEndpoint |
@@ -1,2 +0,1 @@ | ||
// src/ApiStage.ts | ||
var ApiStage = /* @__PURE__ */ ((ApiStage2) => { | ||
@@ -3,0 +2,0 @@ ApiStage2["Beta"] = "beta"; |
@@ -1,9 +0,9 @@ | ||
// src/getApiStage.ts | ||
var getApiStage = (hostname) => { | ||
import { ApiStage } from "./ApiStage"; | ||
const getApiStage = (hostname) => { | ||
if (hostname.startsWith("localhost")) { | ||
return "local" /* Local */; | ||
return ApiStage.Local; | ||
} else if (hostname.startsWith("beta.")) { | ||
return "beta" /* Beta */; | ||
return ApiStage.Beta; | ||
} else { | ||
return "prod" /* Prod */; | ||
return ApiStage.Prod; | ||
} | ||
@@ -10,0 +10,0 @@ }; |
@@ -1,77 +0,6 @@ | ||
// src/ApiStage.ts | ||
var ApiStage = /* @__PURE__ */ ((ApiStage2) => { | ||
ApiStage2["Beta"] = "beta"; | ||
ApiStage2["Local"] = "local"; | ||
ApiStage2["Prod"] = "prod"; | ||
return ApiStage2; | ||
})(ApiStage || {}); | ||
// src/ApiClient.ts | ||
var ApiClient = class { | ||
constructor(token, stage) { | ||
this.token = token; | ||
this.stage = stage; | ||
this.stage = stage ?? "prod" /* Prod */; | ||
this.token = token; | ||
} | ||
}; | ||
// src/ApiEndpoint.ts | ||
import axios from "axios"; | ||
var ApiEndpoint = class { | ||
_value; | ||
config; | ||
path; | ||
constructor(config, path) { | ||
this.config = config; | ||
this.path = path; | ||
} | ||
get value() { | ||
return this._value; | ||
} | ||
get headers() { | ||
return this.config.jwtToken ? { Authorization: this.config.jwtToken } : void 0; | ||
} | ||
get url() { | ||
return `${this.config.apiDomain}/${this.path}`; | ||
} | ||
async fetch() { | ||
const response = await axios.get(this.url, { headers: this.headers }); | ||
if (response.status === 200) { | ||
this._value = response.data; | ||
} else { | ||
throw Error("Unexpected Status Code"); | ||
} | ||
return this._value; | ||
} | ||
async get() { | ||
return this._value ?? await this.fetch(); | ||
} | ||
async insert(value) { | ||
const response = await axios.post(this.url, value, { headers: this.headers }); | ||
if (response.status === 200) { | ||
this._value = response.data; | ||
} else { | ||
throw Error("Unexpected Status Code"); | ||
} | ||
return this._value; | ||
} | ||
}; | ||
// src/getApiStage.ts | ||
var getApiStage = (hostname) => { | ||
if (hostname.startsWith("localhost")) { | ||
return "local" /* Local */; | ||
} else if (hostname.startsWith("beta.")) { | ||
return "beta" /* Beta */; | ||
} else { | ||
return "prod" /* Prod */; | ||
} | ||
}; | ||
export { | ||
ApiClient, | ||
ApiEndpoint, | ||
ApiStage, | ||
getApiStage | ||
}; | ||
export * from "./ApiClient"; | ||
export * from "./ApiConfig"; | ||
export * from "./ApiEndpoint"; | ||
export * from "./ApiStage"; | ||
export * from "./getApiStage"; | ||
//# sourceMappingURL=index.js.map |
@@ -19,2 +19,4 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/ApiClient.ts | ||
var ApiClient_exports = {}; | ||
@@ -25,11 +27,10 @@ __export(ApiClient_exports, { | ||
module.exports = __toCommonJS(ApiClient_exports); | ||
var import_ApiStage = require("./ApiStage"); | ||
class ApiClient { | ||
var ApiClient = class { | ||
constructor(token, stage) { | ||
this.token = token; | ||
this.stage = stage; | ||
this.stage = stage ?? import_ApiStage.ApiStage.Prod; | ||
this.stage = stage ?? "prod" /* Prod */; | ||
this.token = token; | ||
} | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -36,0 +37,0 @@ 0 && (module.exports = { |
@@ -15,4 +15,6 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/ApiConfig.ts | ||
var ApiConfig_exports = {}; | ||
module.exports = __toCommonJS(ApiConfig_exports); | ||
//# sourceMappingURL=ApiConfig.js.map |
@@ -29,2 +29,4 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/ApiEndpoint.ts | ||
var ApiEndpoint_exports = {}; | ||
@@ -36,3 +38,3 @@ __export(ApiEndpoint_exports, { | ||
var import_axios = __toESM(require("axios")); | ||
class ApiEndpoint { | ||
var ApiEndpoint = class { | ||
_value; | ||
@@ -75,3 +77,3 @@ config; | ||
} | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -78,0 +80,0 @@ 0 && (module.exports = { |
@@ -19,2 +19,4 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/ApiStage.ts | ||
var ApiStage_exports = {}; | ||
@@ -21,0 +23,0 @@ __export(ApiStage_exports, { |
@@ -19,2 +19,4 @@ "use strict"; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/getApiStage.ts | ||
var getApiStage_exports = {}; | ||
@@ -25,10 +27,9 @@ __export(getApiStage_exports, { | ||
module.exports = __toCommonJS(getApiStage_exports); | ||
var import_ApiStage = require("./ApiStage"); | ||
const getApiStage = (hostname) => { | ||
var getApiStage = (hostname) => { | ||
if (hostname.startsWith("localhost")) { | ||
return import_ApiStage.ApiStage.Local; | ||
return "local" /* Local */; | ||
} else if (hostname.startsWith("beta.")) { | ||
return import_ApiStage.ApiStage.Beta; | ||
return "beta" /* Beta */; | ||
} else { | ||
return import_ApiStage.ApiStage.Prod; | ||
return "prod" /* Prod */; | ||
} | ||
@@ -35,0 +36,0 @@ }; |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
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) => { | ||
@@ -14,19 +20,99 @@ if (from && typeof from === "object" || typeof from === "function") { | ||
}; | ||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
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); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
ApiClient: () => ApiClient, | ||
ApiEndpoint: () => ApiEndpoint, | ||
ApiStage: () => ApiStage, | ||
getApiStage: () => getApiStage | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
__reExport(src_exports, require("./ApiClient"), module.exports); | ||
__reExport(src_exports, require("./ApiConfig"), module.exports); | ||
__reExport(src_exports, require("./ApiEndpoint"), module.exports); | ||
__reExport(src_exports, require("./ApiStage"), module.exports); | ||
__reExport(src_exports, require("./getApiStage"), module.exports); | ||
// src/ApiStage.ts | ||
var ApiStage = /* @__PURE__ */ ((ApiStage2) => { | ||
ApiStage2["Beta"] = "beta"; | ||
ApiStage2["Local"] = "local"; | ||
ApiStage2["Prod"] = "prod"; | ||
return ApiStage2; | ||
})(ApiStage || {}); | ||
// src/ApiClient.ts | ||
var ApiClient = class { | ||
constructor(token, stage) { | ||
this.token = token; | ||
this.stage = stage; | ||
this.stage = stage ?? "prod" /* Prod */; | ||
this.token = token; | ||
} | ||
}; | ||
// src/ApiEndpoint.ts | ||
var import_axios = __toESM(require("axios")); | ||
var ApiEndpoint = class { | ||
_value; | ||
config; | ||
path; | ||
constructor(config, path) { | ||
this.config = config; | ||
this.path = path; | ||
} | ||
get value() { | ||
return this._value; | ||
} | ||
get headers() { | ||
return this.config.jwtToken ? { Authorization: this.config.jwtToken } : void 0; | ||
} | ||
get url() { | ||
return `${this.config.apiDomain}/${this.path}`; | ||
} | ||
async fetch() { | ||
const response = await import_axios.default.get(this.url, { headers: this.headers }); | ||
if (response.status === 200) { | ||
this._value = response.data; | ||
} else { | ||
throw Error("Unexpected Status Code"); | ||
} | ||
return this._value; | ||
} | ||
async get() { | ||
return this._value ?? await this.fetch(); | ||
} | ||
async insert(value) { | ||
const response = await import_axios.default.post(this.url, value, { headers: this.headers }); | ||
if (response.status === 200) { | ||
this._value = response.data; | ||
} else { | ||
throw Error("Unexpected Status Code"); | ||
} | ||
return this._value; | ||
} | ||
}; | ||
// src/getApiStage.ts | ||
var getApiStage = (hostname) => { | ||
if (hostname.startsWith("localhost")) { | ||
return "local" /* Local */; | ||
} else if (hostname.startsWith("beta.")) { | ||
return "beta" /* Beta */; | ||
} else { | ||
return "prod" /* Prod */; | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
...require("./ApiClient"), | ||
...require("./ApiConfig"), | ||
...require("./ApiEndpoint"), | ||
...require("./ApiStage"), | ||
...require("./getApiStage") | ||
ApiClient, | ||
ApiEndpoint, | ||
ApiStage, | ||
getApiStage | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -48,4 +48,4 @@ { | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^3.0.70", | ||
"@xylabs/tsconfig": "^3.0.70", | ||
"@xylabs/ts-scripts-yarn3": "^3.0.72", | ||
"@xylabs/tsconfig": "^3.0.72", | ||
"typescript": "^5.2.2" | ||
@@ -61,4 +61,4 @@ }, | ||
"sideEffects": false, | ||
"version": "2.11.22", | ||
"version": "2.11.23", | ||
"packageManager": "yarn@3.3.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73571
921