Updates
This commit is contained in:
parent
cd6bfdfc67
commit
d78e44c98d
3
dist/package-shared/actions/upload-file.d.ts
vendored
3
dist/package-shared/actions/upload-file.d.ts
vendored
@ -15,9 +15,10 @@ type Param = {
|
|||||||
isPrivate?: boolean;
|
isPrivate?: boolean;
|
||||||
};
|
};
|
||||||
user_id?: string | number;
|
user_id?: string | number;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* # Upload File via API
|
* # Upload File via API
|
||||||
*/
|
*/
|
||||||
export default function uploadImage({ key, payload, user_id, }: Param): Promise<Return>;
|
export default function uploadImage({ key, payload, user_id, useDefault, }: Param): Promise<Return>;
|
||||||
export {};
|
export {};
|
||||||
|
4
dist/package-shared/actions/upload-file.js
vendored
4
dist/package-shared/actions/upload-file.js
vendored
@ -18,9 +18,9 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
|||||||
* # Upload File via API
|
* # Upload File via API
|
||||||
*/
|
*/
|
||||||
function uploadImage(_a) {
|
function uploadImage(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
|
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, useDefault, }) {
|
||||||
var _b;
|
var _b;
|
||||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
const grabedHostNames = (0, grab_host_names_1.default)({ useDefault });
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
|
@ -17,9 +17,10 @@ type Param = {
|
|||||||
isPrivate?: boolean;
|
isPrivate?: boolean;
|
||||||
};
|
};
|
||||||
user_id?: string | number;
|
user_id?: string | number;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* # Upload Image via API
|
* # Upload Image via API
|
||||||
*/
|
*/
|
||||||
export default function uploadImage({ key, payload, user_id, }: Param): Promise<FunctionReturn>;
|
export default function uploadImage({ key, payload, user_id, useDefault, }: Param): Promise<FunctionReturn>;
|
||||||
export {};
|
export {};
|
||||||
|
4
dist/package-shared/actions/upload-image.js
vendored
4
dist/package-shared/actions/upload-image.js
vendored
@ -19,9 +19,9 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
|||||||
* # Upload Image via API
|
* # Upload Image via API
|
||||||
*/
|
*/
|
||||||
function uploadImage(_a) {
|
function uploadImage(_a) {
|
||||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
|
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, useDefault, }) {
|
||||||
var _b;
|
var _b;
|
||||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
const grabedHostNames = (0, grab_host_names_1.default)({ useDefault });
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ const grabApiCred = ({ key, database, table, user_id, media, }) => {
|
|||||||
if (!allowedKeysPath)
|
if (!allowedKeysPath)
|
||||||
throw new Error("process.env.DSQL_API_KEYS_PATH variable not found");
|
throw new Error("process.env.DSQL_API_KEYS_PATH variable not found");
|
||||||
const ApiJSON = (0, decrypt_1.default)({ encryptedString: key });
|
const ApiJSON = (0, decrypt_1.default)({ encryptedString: key });
|
||||||
/** @type {import("../../types").ApiKeyObject} */
|
|
||||||
const ApiObject = JSON.parse(ApiJSON || "");
|
const ApiObject = JSON.parse(ApiJSON || "");
|
||||||
const isApiKeyValid = fs_1.default.existsSync(`${allowedKeysPath}/${ApiObject.sign}`);
|
const isApiKeyValid = fs_1.default.existsSync(`${allowedKeysPath}/${ApiObject.sign}`);
|
||||||
if (String(ApiObject.user_id) !== String(user_id))
|
if (String(ApiObject.user_id) !== String(user_id))
|
||||||
@ -42,7 +41,7 @@ const grabApiCred = ({ key, database, table, user_id, media, }) => {
|
|||||||
return ApiObject;
|
return ApiObject;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch ( /** @type {any} */error) {
|
catch (error) {
|
||||||
console.log(`api-cred ERROR: ${error.message}`);
|
console.log(`api-cred ERROR: ${error.message}`);
|
||||||
return { error: `api-cred ERROR: ${error.message}` };
|
return { error: `api-cred ERROR: ${error.message}` };
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ type Param = {
|
|||||||
env?: {
|
env?: {
|
||||||
[k: string]: string;
|
[k: string]: string;
|
||||||
};
|
};
|
||||||
|
remoteHost?: string;
|
||||||
|
remoteHostPort?: string;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* # Grab Names For Query
|
* # Grab Names For Query
|
||||||
|
8
dist/package-shared/utils/grab-host-names.js
vendored
8
dist/package-shared/utils/grab-host-names.js
vendored
@ -17,10 +17,14 @@ function grabHostNames(param) {
|
|||||||
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
|
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
|
||||||
const localHost = finalEnv["DSQL_LOCAL_HOST"];
|
const localHost = finalEnv["DSQL_LOCAL_HOST"];
|
||||||
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
|
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
|
||||||
const remoteHost = ((_a = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _a === void 0 ? void 0 : _a.match(/.*\..*/))
|
const remoteHost = (param === null || param === void 0 ? void 0 : param.useDefault)
|
||||||
|
? undefined
|
||||||
|
: ((_a = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _a === void 0 ? void 0 : _a.match(/.*\..*/))
|
||||||
? finalEnv["DSQL_API_REMOTE_HOST"]
|
? finalEnv["DSQL_API_REMOTE_HOST"]
|
||||||
: undefined;
|
: undefined;
|
||||||
const remoteHostPort = ((_b = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _b === void 0 ? void 0 : _b.match(/./))
|
const remoteHostPort = (param === null || param === void 0 ? void 0 : param.useDefault)
|
||||||
|
? undefined
|
||||||
|
: ((_b = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _b === void 0 ? void 0 : _b.match(/./))
|
||||||
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
||||||
: undefined;
|
: undefined;
|
||||||
return {
|
return {
|
||||||
|
@ -18,6 +18,7 @@ type Param = {
|
|||||||
isPrivate?: boolean;
|
isPrivate?: boolean;
|
||||||
};
|
};
|
||||||
user_id?: string | number;
|
user_id?: string | number;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,8 +28,9 @@ export default async function uploadImage({
|
|||||||
key,
|
key,
|
||||||
payload,
|
payload,
|
||||||
user_id,
|
user_id,
|
||||||
|
useDefault,
|
||||||
}: Param): Promise<Return> {
|
}: Param): Promise<Return> {
|
||||||
const grabedHostNames = grabHostNames();
|
const grabedHostNames = grabHostNames({ useDefault });
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -22,6 +22,7 @@ type Param = {
|
|||||||
isPrivate?: boolean;
|
isPrivate?: boolean;
|
||||||
};
|
};
|
||||||
user_id?: string | number;
|
user_id?: string | number;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,8 +32,9 @@ export default async function uploadImage({
|
|||||||
key,
|
key,
|
||||||
payload,
|
payload,
|
||||||
user_id,
|
user_id,
|
||||||
|
useDefault,
|
||||||
}: Param): Promise<FunctionReturn> {
|
}: Param): Promise<FunctionReturn> {
|
||||||
const grabedHostNames = grabHostNames();
|
const grabedHostNames = grabHostNames({ useDefault });
|
||||||
const { host, port, scheme } = grabedHostNames;
|
const { host, port, scheme } = grabedHostNames;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -24,10 +24,11 @@ const grabApiCred: CheckApiCredentialsFn = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const ApiJSON = decrypt({ encryptedString: key });
|
const ApiJSON = decrypt({ encryptedString: key });
|
||||||
/** @type {import("../../types").ApiKeyObject} */
|
|
||||||
const ApiObject: import("../../types").ApiKeyObject = JSON.parse(
|
const ApiObject: import("../../types").ApiKeyObject = JSON.parse(
|
||||||
ApiJSON || ""
|
ApiJSON || ""
|
||||||
);
|
);
|
||||||
|
|
||||||
const isApiKeyValid = fs.existsSync(
|
const isApiKeyValid = fs.existsSync(
|
||||||
`${allowedKeysPath}/${ApiObject.sign}`
|
`${allowedKeysPath}/${ApiObject.sign}`
|
||||||
);
|
);
|
||||||
@ -50,7 +51,7 @@ const grabApiCred: CheckApiCredentialsFn = ({
|
|||||||
.includes(String(table));
|
.includes(String(table));
|
||||||
if (isTableAllowed) return ApiObject;
|
if (isTableAllowed) return ApiObject;
|
||||||
return null;
|
return null;
|
||||||
} catch (/** @type {any} */ error: any) {
|
} catch (error: any) {
|
||||||
console.log(`api-cred ERROR: ${error.message}`);
|
console.log(`api-cred ERROR: ${error.message}`);
|
||||||
return { error: `api-cred ERROR: ${error.message}` };
|
return { error: `api-cred ERROR: ${error.message}` };
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ type GrabHostNamesReturn = {
|
|||||||
type Param = {
|
type Param = {
|
||||||
userId?: string | number;
|
userId?: string | number;
|
||||||
env?: { [k: string]: string };
|
env?: { [k: string]: string };
|
||||||
|
remoteHost?: string;
|
||||||
|
remoteHostPort?: string;
|
||||||
|
useDefault?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,10 +29,15 @@ export default function grabHostNames(param?: Param): GrabHostNamesReturn {
|
|||||||
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
|
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
|
||||||
const localHost = finalEnv["DSQL_LOCAL_HOST"];
|
const localHost = finalEnv["DSQL_LOCAL_HOST"];
|
||||||
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
|
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
|
||||||
const remoteHost = finalEnv["DSQL_API_REMOTE_HOST"]?.match(/.*\..*/)
|
|
||||||
|
const remoteHost = param?.useDefault
|
||||||
|
? undefined
|
||||||
|
: finalEnv["DSQL_API_REMOTE_HOST"]?.match(/.*\..*/)
|
||||||
? finalEnv["DSQL_API_REMOTE_HOST"]
|
? finalEnv["DSQL_API_REMOTE_HOST"]
|
||||||
: undefined;
|
: undefined;
|
||||||
const remoteHostPort = finalEnv["DSQL_API_REMOTE_HOST_PORT"]?.match(/./)
|
const remoteHostPort = param?.useDefault
|
||||||
|
? undefined
|
||||||
|
: finalEnv["DSQL_API_REMOTE_HOST_PORT"]?.match(/./)
|
||||||
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "4.4.2",
|
"version": "4.4.3",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user