Skip to content

fix: fixed npm audit issues and other compilation issues #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Module dependencies
node_modules
package-lock.json

# Test coverages
coverage
Expand Down
4 changes: 4 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fileignoreconfig:
- filename: package-lock.json
checksum: 218e63a11ff5af63d734e6facf8d71a2965870700eadf98c423ac74839036a46
version: ""
2 changes: 1 addition & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2019 Contentstack LLC <https://www.contentstack.com/>
Copyright (c) 2022 Contentstack LLC <https://www.contentstack.com/>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Security

Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.

If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Send email to [[email protected]](mailto:[email protected]).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)
1 change: 1 addition & 0 deletions dist/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* MIT Licensed
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
exports.config = {
contentStore: {
collection: {
Expand Down
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* MIT Licensed
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contentstack = void 0;
const stack_1 = require("./stack");
/**
* @class Stack
Expand Down
74 changes: 41 additions & 33 deletions dist/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
* MIT Licensed
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stack = void 0;
const lodash_1 = require("lodash");
const mongodb_1 = require("mongodb");
const sift_1 = __importDefault(require("sift"));
Expand All @@ -30,9 +32,9 @@ const util_1 = require("./util");
*/
class Stack {
constructor(stackConfig, existingDB) {
this.config = lodash_1.merge(config_1.config, stackConfig);
this.config = (0, lodash_1.merge)(config_1.config, stackConfig);
// validates config.locales property
util_1.validateConfig(this.config);
(0, util_1.validateConfig)(this.config);
this.contentStore = this.config.contentStore;
this.collectionNames = this.contentStore.collection;
this.types = this.contentStore.internal.types;
Expand Down Expand Up @@ -137,8 +139,8 @@ class Stack {
*/
connect(overrides = {}) {
return __awaiter(this, void 0, void 0, function* () {
const dbConfig = lodash_1.merge({}, this.config, overrides).contentStore;
const url = util_1.validateURI(dbConfig.url);
const dbConfig = (0, lodash_1.merge)({}, this.config, overrides).contentStore;
const url = (0, util_1.validateURI)(dbConfig.url);
const options = dbConfig.options;
const dbName = dbConfig.dbName;
const client = new mongodb_1.MongoClient(url, options);
Expand Down Expand Up @@ -218,7 +220,7 @@ class Stack {
throw new Error('Kindly provide valid parameters for .and()!');
}
else if (this.q.query && typeof this.q.query === 'object') {
this.q.query = lodash_1.merge(this.q.query, {
this.q.query = (0, lodash_1.merge)(this.q.query, {
$and: queries,
});
}
Expand Down Expand Up @@ -262,7 +264,7 @@ class Stack {
throw new Error('Kindly provide valid parameters for .or()!');
}
else if (this.q.query && typeof this.q.query === 'object') {
this.q.query = lodash_1.merge(this.q.query, {
this.q.query = (0, lodash_1.merge)(this.q.query, {
$or: queries,
});
}
Expand Down Expand Up @@ -1011,7 +1013,7 @@ class Stack {
*/
query(queryObject = {}) {
if (this.q.query && typeof this.q.query === 'object') {
this.q.query = lodash_1.merge(this.q.query, queryObject);
this.q.query = (0, lodash_1.merge)(this.q.query, queryObject);
}
else {
this.q.query = queryObject;
Expand Down Expand Up @@ -1086,7 +1088,7 @@ class Stack {
this.internal.except[field] = 0;
}
});
this.internal.except = lodash_1.merge(this.contentStore.projections, this.internal.except);
this.internal.except = (0, lodash_1.merge)(this.contentStore.projections, this.internal.except);
return this;
}
/**
Expand Down Expand Up @@ -1118,7 +1120,7 @@ class Stack {
throw new Error('Kindly provide a valid field and pattern value for \'.regex()\'');
}
else if (this.q.query && typeof this.q.query === 'object') {
this.q.query = lodash_1.merge(this.q.query, {
this.q.query = (0, lodash_1.merge)(this.q.query, {
[field]: {
$options: options,
$regex: pattern,
Expand Down Expand Up @@ -1161,7 +1163,7 @@ class Stack {
throw new Error('Kindly provide valid \'field\' values for \'tags()\'');
}
// filter non-string keys
lodash_1.remove(values, (value) => {
(0, lodash_1.remove)(values, (value) => {
return typeof value !== 'string';
});
this.q.query = this.q.query || {};
Expand Down Expand Up @@ -1217,7 +1219,7 @@ class Stack {
if (typeof expr === 'function') {
expr = expr.toString();
}
this.q.query = lodash_1.merge(this.q.query, {
this.q.query = (0, lodash_1.merge)(this.q.query, {
$where: expr,
});
}
Expand Down Expand Up @@ -1489,7 +1491,7 @@ class Stack {
yield this.includeAssetsOnly(result, this.q.content_type_uid, this.q.locale);
}
if (this.internal.queryReferences) {
result = result.filter(sift_1.default(this.internal.queryReferences));
result = result.filter((0, sift_1.default)(this.internal.queryReferences));
if (this.internal.skip) {
result = result.splice(this.internal.skip, this.internal.limit);
}
Expand Down Expand Up @@ -1583,7 +1585,7 @@ class Stack {
preProcess(query) {
let queryFilters;
if (this.q.query && typeof this.q.query === 'object') {
this.q.query = lodash_1.merge(this.q.query, query);
this.q.query = (0, lodash_1.merge)(this.q.query, query);
}
else {
this.q.query = {};
Expand All @@ -1594,7 +1596,7 @@ class Stack {
this.internal.projections = this.internal.only;
}
else {
this.internal.projections = lodash_1.merge(this.contentStore.projections, this.internal.except);
this.internal.projections = (0, lodash_1.merge)(this.contentStore.projections, this.internal.except);
}
// set default limit, if .limit() hasn't been called
if (!(this.internal.limit)) {
Expand Down Expand Up @@ -1631,7 +1633,7 @@ class Stack {
else {
queryFilters = filters;
}
this.collection = this.db.collection(util_1.getCollectionName({
this.collection = this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.q.content_type_uid,
locale: this.q.locale,
}, this.collectionNames));
Expand Down Expand Up @@ -1696,7 +1698,7 @@ class Stack {
break;
}
if (this.internal.includeCount) {
output.count = yield this.db.collection(util_1.getCollectionName({
output.count = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.q.content_type_uid,
locale: this.q.locale,
}, this.collectionNames))
Expand All @@ -1705,17 +1707,19 @@ class Stack {
});
}
if (this.internal.includeSchema) {
output.content_type = yield this.db.collection(util_1.getCollectionName({
output.content_type = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.content_types,
locale: this.q.locale,
}, this.collectionNames))
.findOne({
uid: this.q.content_type_uid,
}, {
_assets: 0,
_content_type_uid: 0,
_id: 0,
_references: 0,
projection: {
_assets: 0,
_content_type_uid: 0,
_id: 0,
_references: 0,
}
});
}
this.cleanup();
Expand All @@ -1725,16 +1729,18 @@ class Stack {
includeAssetsOnly(entries, contentTypeUid, locale) {
return __awaiter(this, void 0, void 0, function* () {
const schema = yield this.db
.collection(util_1.getCollectionName({
.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.content_types,
locale,
}, this.collectionNames))
.findOne({
_content_type_uid: this.types.content_types,
uid: contentTypeUid,
}, {
_assets: 1,
_id: 0,
projection: {
_assets: 1,
_id: 0,
}
});
if (schema === null || schema[this.types.assets] !== 'object') {
return;
Expand All @@ -1750,7 +1756,7 @@ class Stack {
if (shelf.length === 0) {
return;
}
const assets = yield this.db.collection(util_1.getCollectionName({
const assets = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.assets,
locale,
}, this.collectionNames))
Expand Down Expand Up @@ -1788,7 +1794,8 @@ class Stack {
};
const { paths, // ref. fields in the current content types
pendingPath, // left over of *paths*
schemaList, } = yield this.getReferencePath(ctQuery, locale, include);
schemaList, // list of content type uids, the current content types refer to
} = yield this.getReferencePath(ctQuery, locale, include);
const queries = {
$or: [],
}; // reference field paths
Expand Down Expand Up @@ -1892,7 +1899,7 @@ class Stack {
bindLeftoverAssets(queries, locale, pointerList) {
return __awaiter(this, void 0, void 0, function* () {
// const contents = await readFile(getAssetsPath(locale) + '.json')
const filteredAssets = yield this.db.collection(util_1.getCollectionName({
const filteredAssets = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.assets,
locale,
}, this.collectionNames))
Expand Down Expand Up @@ -1955,7 +1962,7 @@ class Stack {
}
getReferencePath(query, locale, currentInclude) {
return __awaiter(this, void 0, void 0, function* () {
const schemas = yield this.db.collection(util_1.getCollectionName({
const schemas = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.content_types,
locale,
}, this.collectionNames))
Expand All @@ -1982,7 +1989,7 @@ class Stack {
let entryReferences = {};
schemas.forEach((schema) => {
// Entry references
entryReferences = lodash_1.merge(entryReferences, schema[this.types.references]);
entryReferences = (0, lodash_1.merge)(entryReferences, schema[this.types.references]);
// tslint:disable-next-line: forin
for (const path in schema[this.types.assets]) {
paths.push(path);
Expand Down Expand Up @@ -2035,7 +2042,7 @@ class Stack {
}
fetchEntries(query, locale, paths, include, includeAll = false) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.db.collection(util_1.getCollectionName({
const result = yield this.db.collection((0, util_1.getCollectionName)({
content_type_uid: 'entries',
locale,
}, this.collectionNames))
Expand Down Expand Up @@ -2085,7 +2092,8 @@ class Stack {
}],
};
const { paths, // ref. fields in the current content types
ctQueries, } = yield this.getAllReferencePaths(ctQuery, locale);
ctQueries, // list of content type uids, the current content types refer to
} = yield this.getAllReferencePaths(ctQuery, locale);
const queries = {
$or: [],
}; // reference field paths
Expand Down Expand Up @@ -2151,7 +2159,7 @@ class Stack {
getAllReferencePaths(contentTypeQueries, locale) {
return __awaiter(this, void 0, void 0, function* () {
const contents = yield this.db
.collection(util_1.getCollectionName({
.collection((0, util_1.getCollectionName)({
content_type_uid: this.types.content_types,
locale,
}, this.collectionNames))
Expand Down
Loading