Updates
This commit is contained in:
+2
-1
@@ -10,12 +10,13 @@ type Params<T extends {
|
||||
deleteKeyValues?: SQLDeleteData<T>[];
|
||||
};
|
||||
targetID?: string | number;
|
||||
apiKey?: string;
|
||||
};
|
||||
export default function apiCrudDELETE<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, deleteSpec, targetID }: Params<T>): Promise<import("../../types").APIResponseObject<{
|
||||
}>({ dbName, tableName, deleteSpec, targetID, apiKey }: Params<T>): Promise<import("../../types").APIResponseObject<{
|
||||
[k: string]: any;
|
||||
}>>;
|
||||
export {};
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiCrudDELETE({ dbName, tableName, deleteSpec, targetID }) {
|
||||
export default async function apiCrudDELETE({ dbName, tableName, deleteSpec, targetID, apiKey }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const finalID = typeof targetID === "number" ? String(targetID) : targetID;
|
||||
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
||||
@@ -9,6 +9,7 @@ export default async function apiCrudDELETE({ dbName, tableName, deleteSpec, tar
|
||||
method: "DELETE",
|
||||
path: finalPath,
|
||||
body: deleteSpec,
|
||||
apiKey,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,10 +8,11 @@ type Params<T extends {
|
||||
tableName: string;
|
||||
query?: DsqlCrudQueryObject<T>;
|
||||
targetId?: string | number;
|
||||
apiKey?: string;
|
||||
};
|
||||
export default function apiCrudGET<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, query, targetId, }: Params<T>): Promise<APIResponseObject>;
|
||||
}>({ dbName, tableName, query, targetId, apiKey, }: Params<T>): Promise<APIResponseObject>;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-1
@@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiCrudGET({ dbName, tableName, query, targetId, }) {
|
||||
export default async function apiCrudGET({ dbName, tableName, query, targetId, apiKey, }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const finalID = typeof targetId === "number" ? String(targetId) : targetId;
|
||||
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
||||
@@ -9,6 +9,7 @@ export default async function apiCrudGET({ dbName, tableName, query, targetId, }
|
||||
method: "GET",
|
||||
path: finalPath,
|
||||
query,
|
||||
apiKey,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,9 +8,10 @@ export type APICrudPostParams<T extends {
|
||||
tableName: string;
|
||||
body: T;
|
||||
update?: boolean;
|
||||
apiKey?: string;
|
||||
};
|
||||
export default function apiCrudPOST<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, body, update, }: APICrudPostParams<T>): Promise<APIResponseObject>;
|
||||
}>({ dbName, tableName, body, update, apiKey, }: APICrudPostParams<T>): Promise<APIResponseObject>;
|
||||
|
||||
Vendored
+2
-1
@@ -1,7 +1,7 @@
|
||||
import path from "path";
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiCrudPOST({ dbName, tableName, body, update, }) {
|
||||
export default async function apiCrudPOST({ dbName, tableName, body, update, apiKey, }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const passedID = body.id;
|
||||
const finalID = update
|
||||
@@ -14,6 +14,7 @@ export default async function apiCrudPOST({ dbName, tableName, body, update, })
|
||||
method: update ? "PUT" : "POST",
|
||||
path: finalPath,
|
||||
body,
|
||||
apiKey,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,10 +5,11 @@ type Params<T extends {
|
||||
[key: string]: any;
|
||||
}> = Omit<APICrudPostParams<T>, "update"> & {
|
||||
targetID: string | number;
|
||||
apiKey?: string;
|
||||
};
|
||||
export default function apiCrudPUT<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, body, targetID }: Params<T>): Promise<import("../../types").APIResponseObject>;
|
||||
}>({ dbName, tableName, body, targetID, apiKey }: Params<T>): Promise<import("../../types").APIResponseObject>;
|
||||
export {};
|
||||
|
||||
Vendored
+2
-1
@@ -1,5 +1,5 @@
|
||||
import apiCrudPOST from "./post";
|
||||
export default async function apiCrudPUT({ dbName, tableName, body, targetID }) {
|
||||
export default async function apiCrudPUT({ dbName, tableName, body, targetID, apiKey }) {
|
||||
const updatedBody = Object.assign({}, body);
|
||||
if (targetID) {
|
||||
updatedBody["id"] = targetID;
|
||||
@@ -9,5 +9,6 @@ export default async function apiCrudPUT({ dbName, tableName, body, targetID })
|
||||
tableName,
|
||||
body: updatedBody,
|
||||
update: true,
|
||||
apiKey,
|
||||
});
|
||||
}
|
||||
|
||||
+5
-2
@@ -1,5 +1,8 @@
|
||||
import { APIResponseObject } from "../../types";
|
||||
import { DSQL_DATASQUIREL_USER_MEDIA } from "../../types/dsql";
|
||||
export default function apiMediaDELETE(params: {
|
||||
type Params = {
|
||||
mediaID?: string | number;
|
||||
}): Promise<APIResponseObject<DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]>>;
|
||||
apiKey?: string;
|
||||
};
|
||||
export default function apiMediaDELETE(params: Params): Promise<APIResponseObject<DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]>>;
|
||||
export {};
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ export default async function apiMediaDELETE(params) {
|
||||
const DELETE_MEDIA_RES = await queryDSQLAPI({
|
||||
method: "DELETE",
|
||||
path: finalPath,
|
||||
apiKey: params.apiKey,
|
||||
});
|
||||
return DELETE_MEDIA_RES;
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -13,6 +13,7 @@ export default async function apiMediaGET(params) {
|
||||
method: "GET",
|
||||
path: finalPath,
|
||||
query: params,
|
||||
apiKey: params.apiKey,
|
||||
});
|
||||
return GET_MEDIA_RES;
|
||||
}
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ export default async function apiMediaPOST(params) {
|
||||
method: "POST",
|
||||
path: basePath,
|
||||
body: params,
|
||||
apiKey: params.apiKey,
|
||||
});
|
||||
return POST_MEDIA_RES;
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,12 +2,12 @@ import { APIResponseObject, DataCrudRequestMethods, DataCrudRequestMethodsLowerC
|
||||
type Param<T = {
|
||||
[k: string]: any;
|
||||
}> = {
|
||||
key?: string;
|
||||
body?: T;
|
||||
query?: T;
|
||||
useDefault?: boolean;
|
||||
path: string;
|
||||
method?: (typeof DataCrudRequestMethods)[number] | (typeof DataCrudRequestMethodsLowerCase)[number];
|
||||
apiKey?: string;
|
||||
};
|
||||
/**
|
||||
* # Query DSQL API
|
||||
@@ -16,5 +16,5 @@ export default function queryDSQLAPI<T = {
|
||||
[k: string]: any;
|
||||
}, P = {
|
||||
[k: string]: any;
|
||||
}>({ key, body, query, useDefault, path: passedPath, method, }: Param<T>): Promise<APIResponseObject<P>>;
|
||||
}>({ body, query, useDefault, path: passedPath, method, apiKey, }: Param<T>): Promise<APIResponseObject<P>>;
|
||||
export {};
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import serializeQuery from "../../utils/serialize-query";
|
||||
/**
|
||||
* # Query DSQL API
|
||||
*/
|
||||
export default async function queryDSQLAPI({ key, body, query, useDefault, path: passedPath, method, }) {
|
||||
export default async function queryDSQLAPI({ body, query, useDefault, path: passedPath, method, apiKey, }) {
|
||||
const grabedHostNames = grabHostNames({ useDefault });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
try {
|
||||
@@ -17,7 +17,7 @@ export default async function queryDSQLAPI({ key, body, query, useDefault, path:
|
||||
const reqPayload = body ? JSON.stringify(body) : undefined;
|
||||
let headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: key ||
|
||||
Authorization: apiKey ||
|
||||
(!method || method == "GET" || method == "get"
|
||||
? process.env.DSQL_READ_ONLY_API_KEY
|
||||
: undefined) ||
|
||||
|
||||
Vendored
+2
@@ -1757,10 +1757,12 @@ export type APIGetMediaParams = {
|
||||
skipBase64?: "true" | "false";
|
||||
stream?: "stream";
|
||||
thumbnail?: "true" | "false";
|
||||
apiKey?: string;
|
||||
};
|
||||
export type AddMediaAPIBody = {
|
||||
media: MediaUploadDataType[];
|
||||
folder?: string | null;
|
||||
type: (typeof MediaTypes)[number];
|
||||
apiKey?: string;
|
||||
};
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user