Skip to content

Commit

Permalink
added missing snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Oct 30, 2024
1 parent e980c49 commit 1b86631
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
36 changes: 1 addition & 35 deletions src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2017,9 +2017,6 @@ export class Stack {

private async bindLeftoverAssets(queries: IQuery, locale: string, pointerList: IShelf[]) {
// const contents = await readFile(getAssetsPath(locale) + '.json')
if (!this.sanitizeIQuery(queries)) {
throw new Error('Invalid queries provided');
}
const filteredAssets = await this.db.collection(getCollectionName({
content_type_uid: this.types.assets,
locale,
Expand Down Expand Up @@ -2099,9 +2096,6 @@ export class Stack {
}

private async getReferencePath(query, locale, currentInclude) {
if (!this.sanityQueryAny(query)) {
throw new Error('Invalid query provided');
}
const schemas = await this.db.collection(getCollectionName({
content_type_uid: this.types.content_types,
locale,
Expand Down Expand Up @@ -2190,9 +2184,6 @@ export class Stack {

private async fetchEntries(query: IQuery, locale: string, paths: string[], include: string[], includeAll:
boolean = false) {
if (!this.sanitizeIQuery(query)) {
throw new Error('Invalid queries provided');
}
const result = await this.db.collection(getCollectionName({
content_type_uid: 'entries',
locale,
Expand Down Expand Up @@ -2385,30 +2376,5 @@ export class Stack {
paths,
}
}

private sanitizeIQuery(query: IQuery): boolean {
if (!query || typeof query !== 'object' || Array.isArray(query)) {
return false;
}
if (!query || !Array.isArray(query.$or)) {
return false;
}
for (const item of query.$or) {
if (
typeof item._content_type_uid !== 'string' ||
typeof item.uid !== 'string' ||
(item._version && typeof item._version.$exists !== 'boolean') ||
(item.locale && typeof item.locale !== 'string')
) {
return false;
}
}
return true;
}
private sanityQueryAny(query: any): boolean {
if (!query || typeof query !== 'object' || Array.isArray(query)) {
return false;
}
return true;
}
// tslint:disable-next-line: max-file-line-count
}
2 changes: 0 additions & 2 deletions typings/stack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,4 @@ export declare class Stack {
private bindReferences;
private includeAllReferencesIteration;
private getAllReferencePaths;
private sanitizeIQuery;
private sanityQueryAny;
}

0 comments on commit 1b86631

Please sign in to comment.