@replit/database
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -21,11 +21,2 @@ /** | ||
/** | ||
* An object that represents an error with a request | ||
* @public | ||
*/ | ||
interface RequestError { | ||
message: string; | ||
statusCode?: number; | ||
} | ||
declare class Client { | ||
@@ -94,3 +85,7 @@ private _dbUrl; | ||
} | ||
interface RequestError { | ||
message: string; | ||
statusCode?: number; | ||
} | ||
export { Client as default }; | ||
export = Client; |
@@ -1,30 +0,4 @@ | ||
"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); | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts | ||
var _fs = require('fs'); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
default: () => Client | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/request.ts | ||
var import_fs = require("fs"); | ||
// src/result.ts | ||
@@ -38,39 +12,7 @@ function Err(error, errorExtras) { | ||
// src/request.ts | ||
async function doFetch({ | ||
urlPath, | ||
...rest | ||
}) { | ||
try { | ||
const response = await fetch(new URL(urlPath), rest); | ||
if (response.status !== 200 && response.status !== 204) { | ||
return Err({ | ||
message: await response.text(), | ||
statusCode: response.status | ||
}); | ||
} | ||
return Ok(response); | ||
} catch (e) { | ||
return Err({ message: e instanceof Error ? e.message : "unknown error" }); | ||
} | ||
} | ||
var replitDBFilename = "/tmp/replitdb"; | ||
function getDbUrl() { | ||
let dbUrl; | ||
try { | ||
dbUrl = (0, import_fs.readFileSync)(replitDBFilename, "utf8"); | ||
} catch (err) { | ||
dbUrl = process.env.REPLIT_DB_URL; | ||
} | ||
if (!dbUrl) { | ||
throw new Error("expected dbUrl, got undefined"); | ||
} | ||
return dbUrl; | ||
} | ||
// src/index.ts | ||
var Client = class { | ||
_dbUrl; | ||
// use this.dbUrl internally | ||
lastDbUrlRefreshTime; | ||
/** | ||
@@ -121,3 +63,3 @@ * Initiates Class. | ||
return Ok(parsed === null || parsed === void 0 ? null : parsed); | ||
} catch { | ||
} catch (e2) { | ||
return Err({ | ||
@@ -253,1 +195,36 @@ message: `Failed to parse value of ${key}, try passing a raw option to get the raw value` | ||
}; | ||
async function doFetch({ | ||
urlPath, | ||
...rest | ||
}) { | ||
try { | ||
const response = await fetch(new URL(urlPath), rest); | ||
if (response.status !== 200 && response.status !== 204) { | ||
return Err({ | ||
message: await response.text(), | ||
statusCode: response.status | ||
}); | ||
} | ||
return Ok(response); | ||
} catch (e) { | ||
return Err({ message: e instanceof Error ? e.message : "unknown error" }); | ||
} | ||
} | ||
var replitDBFilename = "/tmp/replitdb"; | ||
function getDbUrl() { | ||
let dbUrl; | ||
try { | ||
dbUrl = _fs.readFileSync.call(void 0, replitDBFilename, "utf8"); | ||
} catch (err) { | ||
dbUrl = process.env.REPLIT_DB_URL; | ||
} | ||
if (!dbUrl) { | ||
throw new Error("expected dbUrl, got undefined"); | ||
} | ||
return dbUrl; | ||
} | ||
exports.default = Client; | ||
module.exports = exports.default |
{ | ||
"name": "@replit/database", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"engines": { | ||
@@ -15,13 +15,11 @@ "node": ">=18" | ||
"scripts": { | ||
"build": "rm -rf dist && tsup src/index.ts --platform node --dts --format esm,cjs", | ||
"test": "vitest run src/*" | ||
"build": "rm -rf dist/ && tsup src/index.ts --platform node --format cjs,esm --dts --cjsInterop --splitting", | ||
"prepublishOnly": "npm run build", | ||
"test": "npm run build && cd test && npm install && cd ../ && vitest run test/*" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": { | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": "./dist/index.js", | ||
"default": "./dist/index.js" | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts" | ||
} | ||
@@ -35,3 +33,4 @@ }, | ||
"devDependencies": { | ||
"tsup": "^8.0.2", | ||
"@types/node": "^18.11.18", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.4.3", | ||
@@ -38,0 +37,0 @@ "vitest": "^1.4.0" |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2
23225
4
529