primitive typescript appeasement vol 2

Signed-off-by: Traxus <shyidx@gmail.com>
This commit is contained in:
Traxus 2023-04-21 19:22:30 -04:00
parent 3eaa4db0c8
commit b2dc5d14c4
2 changed files with 29 additions and 29 deletions

View File

@ -24,7 +24,7 @@ function datocmsDateToIng(date : string) : number {
//-----graphql query interception
export async function datocmsQueryIntercept(query) {
export async function datocmsQueryIntercept(query : any) {
let parent = pluckFirstParentFromQuery(query);
let pageQueryWhitelist = getPageQueryBypassWhitelist();
let listingDirectory = getListingDirectoryByQueryParent(parent);
@ -87,7 +87,7 @@ function getListingQueryDirectories() {
}
function getListingDirectoryByQueryParent(parent) {
function getListingDirectoryByQueryParent(parent : string) {
//-----this acts as a whitelist and a mapping to the folder name...
let directories = getListingQueryDirectories() ;
@ -102,7 +102,7 @@ function getListingDirectoryByQueryParent(parent) {
return directory;
}
function pluckFirstParentFromQuery(query) {
function pluckFirstParentFromQuery(query : any) {
//-----only plucks the FIRST parent, if there are multiple parents in the query they will be ignored.
let parent = ((query.replace(/[\W_]+/g," ")).trim()).split(" ")[0];
@ -110,7 +110,7 @@ function pluckFirstParentFromQuery(query) {
}
async function datocmsPageQueryIntercept(query) {
async function datocmsPageQueryIntercept(query : any) {
let parent = pluckFirstParentFromQuery(query);
let jsonDirectory = path.join(process.cwd(), 'json/site_content');
@ -135,7 +135,7 @@ async function datocmsPageQueryIntercept(query) {
}
async function datocmsListingQueryIntercept(query) {
async function datocmsListingQueryIntercept(query : any) {
let parent = pluckFirstParentFromQuery(query);
let jsonData = {};
@ -181,7 +181,7 @@ async function datocmsListingQueryIntercept(query) {
//-----json traversal
function jsonFilePathIsValid(filePath) {
function jsonFilePathIsValid(filePath : string) {
if (filePath.startsWith("_")) {
return false;
@ -194,7 +194,7 @@ function jsonFilePathIsValid(filePath) {
return true;
}
function jsonNodeExists(jsonData, node) {
function jsonNodeExists(jsonData : object, node : string) {
if (typeof node === 'string' || node instanceof String) {
if (node in jsonData === true) {
@ -205,7 +205,7 @@ function jsonNodeExists(jsonData, node) {
return false;
}
function jsonNodesExist(jsonData, nodes) {
function jsonNodesExist(jsonData : object, nodes : array) {
//-----permit basic validation of the json we are trying to spit out by checking for existence of first order nodes
let node = '';
@ -244,7 +244,7 @@ function jsonNodesExist(jsonData, nodes) {
}
export async function getJsonItemsFromDirectory(jsonDirectory, pluckerFunction, validationNodes) {
export async function getJsonItemsFromDirectory(jsonDirectory : string, pluckerFunction : object, validationNodes : array) {
let jsonFiles = await fs.readdir(jsonDirectory);
let returnJson = [];
@ -286,7 +286,7 @@ function getBlogJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/blogPost');
}
function pluckBlogPostData(json) {
function pluckBlogPostData(json : object) {
let plucked = {};
@ -319,7 +319,7 @@ function getRequiedBlogPostNodes() {
}
function forceBlogPostsJsonSlugIntegrity(json) {
function forceBlogPostsJsonSlugIntegrity(json : object) {
//-----this is used to force the blog post slug to match that of its parent file name.
let returnJson = [];
@ -336,14 +336,14 @@ function forceBlogPostsJsonSlugIntegrity(json) {
}
function sortBlogPostsJsonByDate(json) {
function sortBlogPostsJsonByDate(json : object) {
let sortedJson = json.slice().sort((a, b) => datocmsDateToIng(b.date) - datocmsDateToIng(a.date));
return sortedJson;
}
function getFakePaginationData(json) {
function getFakePaginationData(json : object) {
let pagination = {};
let totalPosts = json.length;
@ -388,7 +388,7 @@ export async function getAllBlogPostsSlugsFromSource() {
}
export async function getAllBlogPostsFromSource(datocmsFilters) {
export async function getAllBlogPostsFromSource(datocmsFilters : object) {
let allBlogPostsFromSource = {};
if (process.env.NEXT_PUBLIC_DATOCMS_BYPASS_TYPE === "local_json") {
@ -425,7 +425,7 @@ async function getSingleBlogPostJsonBySlug(slug) {
}
export async function getSingleBlogPostBySlugFromSource(slug) {
export async function getSingleBlogPostBySlugFromSource(slug : string) {
let blogPostJson = {};
if (process.env.NEXT_PUBLIC_DATOCMS_BYPASS_TYPE === "local_json") {
@ -456,7 +456,7 @@ export async function getSingleBlogPostBySlugFromSource(slug) {
}
function getBlogPostCategorySlugs(blogPostJson) {
function getBlogPostCategorySlugs(blogPostJson : object) {
let categories = [];
@ -477,7 +477,7 @@ function getBlogPostCategorySlugs(blogPostJson) {
}
export async function getRelatedBlogPosts(blogPostJson, matchCount) {
export async function getRelatedBlogPosts(blogPostJson : object, matchCount : number) {
let relatedBlogPosts = [];
let reservedSlugs = []
@ -539,7 +539,7 @@ function getBlogCategoriesJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/category');
}
function pluckBlogCategoriesData(json) {
function pluckBlogCategoriesData(json : object) {
let plucked = {};
@ -593,7 +593,7 @@ function getEventsJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/event');
}
function pluckEventData(json) {
function pluckEventData(json : object) {
let plucked = {};
@ -620,7 +620,7 @@ function getRequiedEventNodes() {
}
function sortEventsJsonByStartDate(json) {
function sortEventsJsonByStartDate(json : object) {
let sortedJson = json.slice().sort((a, b) => datocmsDateToIng(b.eventStartdate) - datocmsDateToIng(a.eventStartdate));
@ -643,7 +643,7 @@ function getPositionsJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/position');
}
function pluckPositionData(json) {
function pluckPositionData(json : object) {
let plucked = {};
@ -669,7 +669,7 @@ function getRequiedPositionNodes() {
}
function sortPositionsJsonById(json) {
function sortPositionsJsonById(json : object) {
let sortedJson = json.slice().sort((a, b) => parseInt(a.id) - parseInt(b.id));
@ -692,7 +692,7 @@ function getPressReleasesJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/pressRelease');
}
function pluckPressReleaseData(json) {
function pluckPressReleaseData(json : object) {
let plucked = {};
@ -719,7 +719,7 @@ function getRequiedPressReleaseNodes() {
}
function sortPressReleasesJsonByDate(json) {
function sortPressReleasesJsonByDate(json : object) {
let sortedJson = json.slice().sort((a, b) => datocmsDateToIng(b.date) - datocmsDateToIng(a.date));
@ -742,7 +742,7 @@ function getTeamsJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/team');
}
function pluckTeamData(json) {
function pluckTeamData(json : object) {
let plucked = {};
@ -767,7 +767,7 @@ function getRequiedTeamNodes() {
}
function sortTeamsJsonById(json) {
function sortTeamsJsonById(json : object) {
let sortedJson = json.slice().sort((a, b) => parseInt(a.id) - parseInt(b.id));
@ -790,7 +790,7 @@ function getTestimonialsJsonDirectoryPath() {
return path.join(process.cwd(), 'json/site_content/testimonial');
}
function pluckTestimonialData(json) {
function pluckTestimonialData(json : object) {
let plucked = {};
@ -817,7 +817,7 @@ function getRequiedTestimonialNodes() {
}
function sortTestimonialsJsonById(json) {
function sortTestimonialsJsonById(json : object) {
let sortedJson = json.slice().sort((a, b) => parseInt(a.id) - parseInt(b.id));

View File

@ -219,7 +219,7 @@ export const getStaticProps = async () => {
//===== \/ START NEXT_PUBLIC_DATOCMS_BYPASS \/ ====================================================
function getInitialBlogPostsDataProp(allBlogPosts) {
function getInitialBlogPostsDataProp(allBlogPosts : object) {
let initialBlogPostsDataProp = {};