Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
271be33
Done: Remove index value not_analyzed for some fields as it is deprec…
adityasharma7 Aug 26, 2019
cea9c5e
Updated: changelog with index property value change #334
adityasharma7 Aug 30, 2019
233d41a
Update README.md – Node 10.x is now required
haelbichalex Sep 3, 2019
272ef36
Merge pull request #339 from haelbichalex/patch-1
pkarw Sep 12, 2019
6038563
Merge pull request #335 from hotwax/vue-storefront-api#334
pkarw Sep 15, 2019
62fd54b
1.11.0-rc1 release
lukeromanowicz Oct 3, 2019
b938c59
Fixed graphql resolvers where the _source_include or _source_include …
ResuBaka Oct 15, 2019
ed48f30
Fixed/added some smaller stuff in graphql schemas
ResuBaka Oct 15, 2019
55f689d
Fixed problem around accessing the scope of the filter in graphql
ResuBaka Oct 15, 2019
534b89b
Updated CHANGELOG.md
ResuBaka Oct 15, 2019
5362c4a
Add the websiteId to the storeViews and use it when calling reset-pas…
Oct 20, 2019
7d5ae07
Typo in README.md
knospe- Oct 24, 2019
b419892
Merge pull request #355 from knospe-/master
lukeromanowicz Oct 25, 2019
f64b58d
Remove default user and password from default.json
KevinGimbel Nov 6, 2019
c584a85
refactor taxcalc
Oct 31, 2019
be99ce4
lint fix
Oct 31, 2019
9ad142f
add lodash fn
Oct 31, 2019
f10e525
update changelog
Oct 31, 2019
34d2be5
Changed var === undefined to !var
ResuBaka Nov 11, 2019
bd4ee8b
Changed var === undefined to !var
ResuBaka Nov 11, 2019
abc618c
Merge pull request #360 from synoa/fix/remove-user-from-default-json
andrzejewsky Nov 11, 2019
0b82cbe
Merge pull request #356 from gibkigonzo/feature/refactor-taxcalc
andrzejewsky Nov 11, 2019
664b6fe
Merge pull request #350 from ResuBaka/fix/graphql-resolvers-and-schemas
andrzejewsky Nov 11, 2019
ba67269
Merge branch 'release/v1.11-rc1' into add-website-id-to-password-reset
andrzejewsky Nov 12, 2019
895cbb3
Merge pull request #352 from haelbichalex/add-website-id-to-password-…
andrzejewsky Nov 12, 2019
deb8304
taxcalc.js - fix issue with deprecatedPriceFieldsSupport config.
Nov 5, 2019
2d68607
Merge pull request #359 from afirlejczyk/bugfix/taxcalc
andrzejewsky Nov 13, 2019
afd38f9
resolve conflicts
andrzejewsky Nov 26, 2019
33f7623
import, types
andrzejewsky Nov 27, 2019
bdc1f78
fixes
andrzejewsky Nov 27, 2019
71301e1
update catalog.json
andrzejewsky Nov 27, 2019
5fe72af
Merge pull request #369 from andrzejewsky/resolveConflicts
andrzejewsky Nov 27, 2019
a7b5e13
Merge branch 'develop' into release/v1.11-rc1
andrzejewsky Nov 27, 2019
74e4ce0
catalog.json
andrzejewsky Nov 27, 2019
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
Expand Up @@ -11,7 +11,6 @@ src/config.json
config/local.json
config/certs/*.pem
var/magento2-sample-data/
var/*
.migrate
*.iml
/docker/elasticsearch/data/
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.11.0-rc.1] - UNRELEASED
## [1.11.0-rc.2] - unreleased

### Fixed

- Fixed some smaller issues with graphql so that it is now working again with the fronted - #350


## [1.11.0-rc.1] - 2019.10.03

### Added
- Experimental Elastic 7 support - @pkarw (#342)
Expand Down Expand Up @@ -32,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Error responses for mailchimp - @andrzejewsky (#3337)
- Replaced function arguments to object destructuring in `calculateProductTax` - @andrzejewsky (#3337)
- Refactor `taxcalc.js` similar to frontend - @gibkigonzo (#356)

## [1.10.0] - 2019.08.12

Expand All @@ -49,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Sharp dependency has been updated. *It might require reinstalling yarn dependencies* - @lukeromanowicz
- Replaced index property value `not_analyzed` with `true` for `options` field in attribute schema - @adityasharma7 (#334)

### Fixed
- Missing `res` and `req` parameters are now passed to ProductProcessor - @jahvi (#218)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Besides a big improvement for the shopping experience, we also want to create a
- Docker and Docker Compose

Already included in `vue-storefront-api` Docker image (required locally, if you do not use containerization):
- Node.js 8.x or higher
- Node.js 10.x or higher
- Yarn

## Installation
Expand Down Expand Up @@ -144,7 +144,7 @@ This backend is using ElasticSearch data formats popularized by [ElasticSuite fo
Please use data migration mechanism provided to manipulate Redis, ElasticSearch or kue. Details: https://github.com/DivanteLtd/vue-storefront-api/tree/master/doc

## Adding custom modules with own dependencies (Yarn only)
When adding custom [Extensions to the API](https://github.com/DivanteLtd/vue-storefront/blob/master/doc/Extending%20vue-storefront-api.md) you might want to define some dependencies inside them. Thanks to [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) dependecies defined inside your custom module will be intaled when you execute `yarn` at project root level, so it's way esier and faster than installing all modules dependcies separetly.
When adding custom [Extensions to the API](https://github.com/DivanteLtd/vue-storefront/blob/master/doc/Extending%20vue-storefront-api.md) you might want to define some dependencies inside them. Thanks to [Yarn workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) dependencies defined inside your custom module will be installed when you execute `yarn` at project root level, so it's way easier and faster than installing all modules dependencies separately.

To do this, define the `package.json` with your dependencies in your custom module:
- `src/api/extensions/{your-custom-extension}/package.json`
Expand Down
2 changes: 2 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"storeCode": "de",
"disabled": false,
"storeId": 3,
"websiteId": 1,
"name": "German Store",
"url": "/de",
"elasticsearch": {
Expand Down Expand Up @@ -97,6 +98,7 @@
"storeCode": "it",
"disabled": false,
"storeId": 4,
"websiteId": 1,
"name": "Italian Store",
"url": "/it",
"elasticsearch": {
Expand Down
2 changes: 1 addition & 1 deletion config/elastic.schema.attribute.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
}
}
}
}
}
10 changes: 5 additions & 5 deletions config/elastic.schema.category.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"is_active": {"type": "boolean"},
"product_count": {"type": "integer"},
"parent_id": {"type": "integer"},
"position": {"type": "long"},
"created_at": {
"type": "date",
"position": {"type": "integer"},
"created_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"updated_at": {
"type": "date",
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
Expand Down
4 changes: 4 additions & 0 deletions scripts/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ program

console.log(`** Putting the mappings on top of ${tempIndex}`)
es.putMappings(common.db, tempIndex, (err) => {
if (err) {
console.error(err.meta ? err.meta : err)
}

console.log(`** We will reindex ${originalIndex} with the current schema`)
es.reIndex(common.db, originalIndex, tempIndex, (err) => {
if (err) {
Expand Down
12 changes: 7 additions & 5 deletions src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ export default ({config, db}) => {
*/
userApi.post('/reset-password', (req, res) => {
const userProxy = _getProxy(req)
const storeCode = req.query.storeCode
const websiteId = config.storeViews[storeCode].websiteId

if (!req.body.email) {
return apiStatus(res, 'Invalid e-mail provided!', 500)
}

userProxy.resetPassword({ email: req.body.email, template: 'email_reset', websiteId: 1 }).then((result) => {
userProxy.resetPassword({ email: req.body.email, template: 'email_reset', websiteId }).then((result) => {
apiStatus(res, result, 200);
}).catch(err => {
apiError(res, err);
Expand All @@ -150,10 +152,10 @@ export default ({config, db}) => {
userApi.get('/order-history', (req, res) => {
const userProxy = _getProxy(req)
userProxy.orderHistory(
req.query.token,
req.query.pageSize || 20,
req.query.currentPage || 1
).then((result) => {
req.query.token,
req.query.pageSize || 20,
req.query.currentPage || 1
).then((result) => {
apiStatus(res, result, 200);
}).catch(err => {
apiError(res, err);
Expand Down
4 changes: 2 additions & 2 deletions src/db.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from 'config'
import * as redis from '../src/lib/redis'
import * as elastic from '../src/lib/elastic'
import * as redis from './lib/redis'
import * as elastic from './lib/elastic'

export default callback => {
// connect to a database if needed, then pass it to `callback`:
Expand Down
3 changes: 0 additions & 3 deletions src/graphql/elasticsearch/attribute/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ async function listAttributes (attributes, context, rootValue, _sourceIncludes)
body: query,
_sourceIncludes
};
if (parseInt(config.elasticsearch.apiVersion) < 6) {
esQuery.type = config.elasticsearch.indexTypes[3]
}

const response = await client.search(adjustQuery(esQuery, 'attribute', config));

Expand Down
5 changes: 3 additions & 2 deletions src/graphql/elasticsearch/catalog/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ input FilterTypeInput @doc(description: "FilterTypeInput specifies which action
gte: String @doc(description: "Greater than or equal to")
gteq: String @doc(description: "Greater than or equal to")
in: [JSON] @doc(description: "In. The value can contain a set of comma-separated values")
like: String @doc(description: "Like. The specified value can contain % (percent signs) to allow matching of 0 or more characters")
like: [String] @doc(description: "Like. The specified value can contain % (percent signs) to allow matching of 0 or more characters")
lt: String @doc(description: "Less than")
lte: String @doc(description: "Less than or equal to")
lteq: String @doc(description: "Less than or equal to")
Expand Down Expand Up @@ -151,6 +151,7 @@ input ProductFilterInput @doc(description: "ProductFilterInput defines the filte
stock: ProductFilterInput @doc(description: "The product stock. Customers use this stock to identify the product.")
is_in_stock: FilterTypeInput @doc(description: "Is product in stock")
keyword: FilterTypeInput @doc(description: "keyword filter input")
url_path: FilterTypeInput @doc(description: "The url path assigned to the product")
}

type LayerFilter {
Expand Down Expand Up @@ -182,4 +183,4 @@ type SortFields @doc(description: "SortFields contains a default value for sort
enum SortEnum {
ASC
DESC
}
}
3 changes: 2 additions & 1 deletion src/graphql/elasticsearch/category/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ input CategorySortInput {
display_mode: SortEnum @doc(description: "Category display mode")
is_anchor: SortEnum @doc(description: "Is filter avalaible in category")
page_layout: SortEnum @doc(description: "Category page layout")
}
_score: SortEnum @doc(description: "Category page layout")
}
5 changes: 4 additions & 1 deletion src/graphql/elasticsearch/cms/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ input CmsInput @doc(description: "ProductFilterInput defines the filters to be u
id: FilterTypeInput @doc(description: "Id of the CMS entity")
identifier: FilterTypeInput @doc(description: "Identifiers of the CMS entity")
store_id: FilterTypeInput @doc(description: "Store Id of the CMS entity")
url_path: FilterTypeInput @doc(description: "The url path assigned to the cms_page")
}

type CmsPage @doc(description: "CMS pages information") {
Expand All @@ -32,6 +33,7 @@ type CmsPages @doc(description: "CMS page defines all CMS page information") {
meta_description: String @doc(description: "CMS page meta description")
meta_keywords: String @doc(description: "CMS page meta keywords")
store_id: Int @doc(description: "Store Id of CMS page")
url_path: String @doc(description: "CMS page meta keywords")
}

type CmsBlocks @doc(description: "CMS blocks information") {
Expand All @@ -40,6 +42,7 @@ type CmsBlocks @doc(description: "CMS blocks information") {

type CmsBlock @doc(description: "CMS block defines all CMS block information") {
identifier: String @doc(description: "CMS block identifier")
id: Int @doc(description: "CMS block identifier")
title: String @doc(description: "CMS block title")
content: String @doc(description: "CMS block content")
creation_time: String @doc(description: "Timestamp indicating when the CMS block was created")
Expand All @@ -60,4 +63,4 @@ type CmsHierarchy {
request_url: String @doc(description: "Request URL of CMS hierarchy node")
xpath: String @doc(description: "XPATH of CMS hierarchy node")
store_id: Int @doc(description: "Store Id of CMS hierarchy node")
}
}
14 changes: 12 additions & 2 deletions src/graphql/elasticsearch/queryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ function processNestedFieldFilter (attribute, value) {
return processedFilter;
}

/**
*
* @param {Object} object
* @param {String} scope
* @returns {boolean}
*/
function checkIfObjectHasScope ({ object, scope }) {
return object.scope === scope || (Array.isArray(object.scope) && object.scope.find(scrope => scrope === scope));
}

function applyFilters (filter, query, type) {
if (filter.length === 0) {
return query
Expand Down Expand Up @@ -46,7 +56,7 @@ function applyFilters (filter, query, type) {

// apply default filters
appliedFilters.forEach((filter) => {
if (filter.scope === 'default' && Object.keys(filter.value).length) {
if (checkIfObjectHasScope({ object: filter, scope: 'default' }) && Object.keys(filter.value).length) {
if (rangeOperators.every(rangeOperator => Object.prototype.hasOwnProperty.call(filter.value, rangeOperator))) {
// process range filters
query = query.filter('range', filter.attribute, filter.value);
Expand All @@ -67,7 +77,7 @@ function applyFilters (filter, query, type) {
let attrFilterBuilder = (filterQr, attrPostfix = '') => {
appliedFilters.forEach((catalogfilter) => {
const valueKeys = Object.keys(catalogfilter.value);
if (catalogfilter.scope === 'catalog' && valueKeys.length) {
if (checkIfObjectHasScope({ object: catalogfilter, scope: 'catalog' }) && valueKeys.length) {
const isRange = valueKeys.filter(value => rangeOperators.indexOf(value) !== -1)
if (isRange.length) {
let rangeAttribute = catalogfilter.attribute
Expand Down
77 changes: 29 additions & 48 deletions src/lib/elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ function reIndex (db, fromIndexName, toIndexName, next) {
}).then(res => {
next()
}).catch(err => {
console.error(err)
next(err)
})
}
Expand Down Expand Up @@ -215,58 +214,40 @@ function putMappings (db, indexName, next) {
let pageSchema = loadSchema('cms_page', '5.6');
let blockSchema = loadSchema('cms_block', '5.6');

db.indices.putMapping({
index: indexName,
type: 'product',
body: productSchema
}).then(res1 => {
console.dir(res1, { depth: null, colors: true })

Promise.all([
db.indices.putMapping({
index: indexName,
type: 'product',
body: productSchema
}),
db.indices.putMapping({
index: indexName,
type: 'taxrule',
body: taxruleSchema
}).then(res2 => {
console.dir(res2, { depth: null, colors: true })

db.indices.putMapping({
index: indexName,
type: 'attribute',
body: attributeSchema
}).then(res3 => {
console.dir(res3, { depth: null, colors: true })
db.indices.putMapping({
index: indexName,
type: 'cms_page',
body: pageSchema
}).then(res4 => {
console.dir(res4, { depth: null, colors: true })
db.indices.putMapping({
index: indexName,
type: 'cms_block',
body: blockSchema
}).then(res5 => {
console.dir(res5, { depth: null, colors: true })
db.indices.putMapping({
index: indexName,
type: 'category',
body: categorySchema
}).then(res6 => {
console.dir(res6, { depth: null, colors: true })
next()
})
})
})
}).catch(err3 => {
throw new Error(err3)
})
}).catch(err2 => {
throw new Error(err2)
}),
db.indices.putMapping({
index: indexName,
type: 'attribute',
body: attributeSchema
}),
db.indices.putMapping({
index: indexName,
type: 'cms_page',
body: pageSchema
}),
db.indices.putMapping({
index: indexName,
type: 'cms_block',
body: blockSchema
}),
db.indices.putMapping({
index: indexName,
type: 'category',
body: categorySchema
})
}).catch(err1 => {
console.error(err1)
next(err1)
})
]).then(values => values.forEach(res => console.dir(res.body, { depth: null, colors: true })))
.then(next)
.catch(next)
}

module.exports = {
Expand Down
Loading