Updates
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import { SQLDeleteData } from "../../types";
|
||||
type Params<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
dbName: string;
|
||||
tableName: string;
|
||||
deleteSpec?: T & {
|
||||
deleteKeyValues?: SQLDeleteData<T>[];
|
||||
};
|
||||
targetID?: string | number;
|
||||
};
|
||||
export default function apiCrudDELETE<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, deleteSpec, targetID }: Params<T>): Promise<import("../../types").APIResponseObject<{
|
||||
[k: string]: any;
|
||||
}>>;
|
||||
export {};
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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 }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const finalID = typeof targetID === "number" ? String(targetID) : targetID;
|
||||
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
||||
const GET_RES = await queryDSQLAPI({
|
||||
method: "DELETE",
|
||||
path: finalPath,
|
||||
body: deleteSpec,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { APIResponseObject, DsqlCrudQueryObject } from "../../types";
|
||||
type Params<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
dbName: string;
|
||||
tableName: string;
|
||||
query?: DsqlCrudQueryObject<T>;
|
||||
targetId?: string | number;
|
||||
};
|
||||
export default function apiCrudGET<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, query, targetId, }: Params<T>): Promise<APIResponseObject>;
|
||||
export {};
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
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, }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const finalID = typeof targetId === "number" ? String(targetId) : targetId;
|
||||
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
||||
const GET_RES = await queryDSQLAPI({
|
||||
method: "GET",
|
||||
path: finalPath,
|
||||
query,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import apiCrudGET from "./get";
|
||||
import apiCrudPOST from "./post";
|
||||
import apiCrudPUT from "./put";
|
||||
import apiCrudDELETE from "./delete";
|
||||
declare const crud: {
|
||||
get: typeof apiCrudGET;
|
||||
insert: typeof apiCrudPOST;
|
||||
update: typeof apiCrudPUT;
|
||||
delete: typeof apiCrudDELETE;
|
||||
options: () => Promise<void>;
|
||||
};
|
||||
export default crud;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import apiCrudGET from "./get";
|
||||
import apiCrudPOST from "./post";
|
||||
import apiCrudPUT from "./put";
|
||||
import apiCrudDELETE from "./delete";
|
||||
const crud = {
|
||||
get: apiCrudGET,
|
||||
insert: apiCrudPOST,
|
||||
update: apiCrudPUT,
|
||||
delete: apiCrudDELETE,
|
||||
options: async () => { },
|
||||
};
|
||||
export default crud;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { APIResponseObject } from "../../types";
|
||||
export type APICrudPostParams<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = {
|
||||
dbName: string;
|
||||
tableName: string;
|
||||
body: T;
|
||||
update?: boolean;
|
||||
};
|
||||
export default function apiCrudPOST<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, body, update, }: APICrudPostParams<T>): Promise<APIResponseObject>;
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
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, }) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
||||
const passedID = body.id;
|
||||
const finalID = update
|
||||
? typeof passedID === "number"
|
||||
? String(passedID)
|
||||
: passedID
|
||||
: undefined;
|
||||
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
||||
const GET_RES = await queryDSQLAPI({
|
||||
method: update ? "PUT" : "POST",
|
||||
path: finalPath,
|
||||
body,
|
||||
});
|
||||
return GET_RES;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { APICrudPostParams } from "./post";
|
||||
type Params<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}> = Omit<APICrudPostParams<T>, "update"> & {
|
||||
targetID: string | number;
|
||||
};
|
||||
export default function apiCrudPUT<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
[key: string]: any;
|
||||
}>({ dbName, tableName, body, targetID }: Params<T>): Promise<import("../../types").APIResponseObject>;
|
||||
export {};
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import apiCrudPOST from "./post";
|
||||
export default async function apiCrudPUT({ dbName, tableName, body, targetID }) {
|
||||
const updatedBody = Object.assign({}, body);
|
||||
if (targetID) {
|
||||
updatedBody["id"] = targetID;
|
||||
}
|
||||
return await apiCrudPOST({
|
||||
dbName,
|
||||
tableName,
|
||||
body: updatedBody,
|
||||
update: true,
|
||||
});
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { APIResponseObject } from "../../types";
|
||||
import { DSQL_DATASQUIREL_USER_MEDIA } from "../../types/dsql";
|
||||
export default function apiMediaDELETE(params: {
|
||||
mediaID?: string | number;
|
||||
}): Promise<APIResponseObject<DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]>>;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import path from "path";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiMediaDELETE(params) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "media" });
|
||||
const mediaID = params.mediaID
|
||||
? typeof params.mediaID === "number"
|
||||
? String(params.mediaID)
|
||||
: params.mediaID
|
||||
: undefined;
|
||||
const finalPath = path.join(basePath, mediaID || "");
|
||||
const DELETE_MEDIA_RES = await queryDSQLAPI({
|
||||
method: "DELETE",
|
||||
path: finalPath,
|
||||
});
|
||||
return DELETE_MEDIA_RES;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { APIGetMediaParams, APIResponseObject } from "../../types";
|
||||
import { DSQL_DATASQUIREL_USER_MEDIA } from "../../types/dsql";
|
||||
export default function apiMediaGET(params: APIGetMediaParams): Promise<APIResponseObject<DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]>>;
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import path from "path";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiMediaGET(params) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "media" });
|
||||
const mediaID = params.mediaID
|
||||
? typeof params.mediaID === "number"
|
||||
? String(params.mediaID)
|
||||
: params.mediaID
|
||||
: undefined;
|
||||
const finalPath = path.join(basePath, mediaID || "");
|
||||
const GET_MEDIA_RES = await queryDSQLAPI({
|
||||
method: "GET",
|
||||
path: finalPath,
|
||||
query: params,
|
||||
});
|
||||
return GET_MEDIA_RES;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import apiMediaGET from "./get";
|
||||
import apiMediaPOST from "./post";
|
||||
import apiMediaDELETE from "./delete";
|
||||
declare const media: {
|
||||
get: typeof apiMediaGET;
|
||||
add: typeof apiMediaPOST;
|
||||
delete: typeof apiMediaDELETE;
|
||||
};
|
||||
export default media;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import apiMediaGET from "./get";
|
||||
import apiMediaPOST from "./post";
|
||||
import apiMediaDELETE from "./delete";
|
||||
const media = {
|
||||
get: apiMediaGET,
|
||||
add: apiMediaPOST,
|
||||
delete: apiMediaDELETE,
|
||||
};
|
||||
export default media;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { AddMediaAPIBody, APIResponseObject } from "../../types";
|
||||
import { DSQL_DATASQUIREL_USER_MEDIA } from "../../types/dsql";
|
||||
export default function apiMediaPOST(params: AddMediaAPIBody): Promise<APIResponseObject<DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]>>;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
||||
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
||||
export default async function apiMediaPOST(params) {
|
||||
const basePath = grabAPIBasePath({ paradigm: "media" });
|
||||
const POST_MEDIA_RES = await queryDSQLAPI({
|
||||
method: "POST",
|
||||
path: basePath,
|
||||
body: params,
|
||||
});
|
||||
return POST_MEDIA_RES;
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
declare const user: {};
|
||||
export default user;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
const user = {};
|
||||
export default user;
|
||||
Reference in New Issue
Block a user