Merge branch 'master' into P5-7626-fix-dev
This commit is contained in:
@@ -214,6 +214,12 @@ describe('GraphQL Apollo tests', () => {
|
|||||||
);
|
);
|
||||||
const marketControlData = market_response.rows[0];
|
const marketControlData = market_response.rows[0];
|
||||||
|
|
||||||
|
// Locale
|
||||||
|
const locale_response = await allContainers.db.raw(
|
||||||
|
`SELECT * FROM locales WHERE value='${orderControlData.locale}';`,
|
||||||
|
);
|
||||||
|
const localeControlData = locale_response.rows[0];
|
||||||
|
|
||||||
// Order row
|
// Order row
|
||||||
const orderrow_response = await allContainers.db.raw(
|
const orderrow_response = await allContainers.db.raw(
|
||||||
`SELECT * FROM "order-rows" WHERE orderid = 1;`,
|
`SELECT * FROM "order-rows" WHERE orderid = 1;`,
|
||||||
@@ -230,8 +236,10 @@ describe('GraphQL Apollo tests', () => {
|
|||||||
{
|
{
|
||||||
order(id: 1) {
|
order(id: 1) {
|
||||||
id
|
id
|
||||||
localeName
|
locale {
|
||||||
marketName
|
id
|
||||||
|
value
|
||||||
|
}
|
||||||
market {
|
market {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@@ -254,8 +262,6 @@ describe('GraphQL Apollo tests', () => {
|
|||||||
|
|
||||||
// Order
|
// Order
|
||||||
expect(order.id).toBe(`${orderControlData.id}`);
|
expect(order.id).toBe(`${orderControlData.id}`);
|
||||||
expect(order.marketName).toBe(orderControlData.country_code);
|
|
||||||
expect(order.localeName).toBe(orderControlData.locale);
|
|
||||||
|
|
||||||
// Market
|
// Market
|
||||||
expect(order.market.id).toBe(`${marketControlData.id}`);
|
expect(order.market.id).toBe(`${marketControlData.id}`);
|
||||||
@@ -266,6 +272,10 @@ describe('GraphQL Apollo tests', () => {
|
|||||||
parseFloat(marketControlData.price_adjustment),
|
parseFloat(marketControlData.price_adjustment),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Locale
|
||||||
|
expect(order.locale.id).toBe(`${localeControlData.id}`);
|
||||||
|
expect(order.locale.value).toBe(localeControlData.value);
|
||||||
|
|
||||||
// Order Rows
|
// Order Rows
|
||||||
expect(order.rows.length).toBe(orderRowsControlData.length);
|
expect(order.rows.length).toBe(orderRowsControlData.length);
|
||||||
expect(order.rows[0].id).toBe('' + orderRowsControlData[0].rowid);
|
expect(order.rows[0].id).toBe('' + orderRowsControlData[0].rowid);
|
||||||
|
|||||||
@@ -135,9 +135,10 @@ const verifyToken = async (
|
|||||||
if (claim.token_use === 'access') {
|
if (claim.token_use === 'access') {
|
||||||
// Access token, check for scopes
|
// Access token, check for scopes
|
||||||
const accessClaim = claim as AccessTokenClaim;
|
const accessClaim = claim as AccessTokenClaim;
|
||||||
console.debug(`accessClaim confirmed for ${accessClaim.username}`);
|
const who = accessClaim.username ?? accessClaim.client_id;
|
||||||
|
console.debug(`accessClaim confirmed for ${who}`);
|
||||||
return {
|
return {
|
||||||
userName: accessClaim.username,
|
userName: who,
|
||||||
isValid: true,
|
isValid: true,
|
||||||
idToken: null,
|
idToken: null,
|
||||||
accessToken: accessClaim,
|
accessToken: accessClaim,
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ WHERE product_category.product_id = ?
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: should we have these?
|
* TODO: should we have these?
|
||||||
* category keywords and texts
|
* category keywords
|
||||||
*
|
*
|
||||||
SELECT category_keyword.category_id, keywords.value
|
SELECT category_keyword.category_id, keywords.value
|
||||||
FROM category_keyword
|
FROM category_keyword
|
||||||
@@ -52,12 +52,11 @@ WHERE product_category.product_id = ?
|
|||||||
JOIN categorydatakeys cdk ON cd.datakey_id = cdk.id
|
JOIN categorydatakeys cdk ON cd.datakey_id = cdk.id
|
||||||
*
|
*
|
||||||
* category texts
|
* category texts
|
||||||
SELECT name,
|
SELECT name, text
|
||||||
text
|
FROM categorydata cd
|
||||||
FROM categorydata cd
|
JOIN categorydatakeys cdk ON cd.datakey_id = cdk.id
|
||||||
JOIN categorydatakeys cdk ON cd.datakey_id = cdk.id
|
WHERE category_id = ?
|
||||||
WHERE category_id = ?
|
AND locale_id = ?;
|
||||||
AND locale_id = ?;
|
|
||||||
|
|
||||||
|
|
||||||
* category teaser images???
|
* category teaser images???
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import { SQLDataSource } from 'datasource-sql';
|
|
||||||
import { Market } from '../types/market-types';
|
|
||||||
|
|
||||||
const MINUTE = 60;
|
|
||||||
|
|
||||||
export class MarketAPI extends SQLDataSource {
|
|
||||||
constructor(config) {
|
|
||||||
super(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMarketById(id: number): Promise<Market> {
|
|
||||||
return this.knex
|
|
||||||
.select('*')
|
|
||||||
.from('markets')
|
|
||||||
.where('id', id)
|
|
||||||
.first()
|
|
||||||
.cache(MINUTE * 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMarketByName(name: string): Promise<Market> {
|
|
||||||
return this.knex
|
|
||||||
.select('*')
|
|
||||||
.from('markets')
|
|
||||||
.where('name', name)
|
|
||||||
.first()
|
|
||||||
.cache(MINUTE * 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMarkets(): Promise<Array<Market>> {
|
|
||||||
return this.knex
|
|
||||||
.select('*')
|
|
||||||
.from('markets')
|
|
||||||
.cache(MINUTE * 5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { SQLDataSource } from 'datasource-sql';
|
||||||
|
import { Market, Locale } from '../types/market-locale-types';
|
||||||
|
|
||||||
|
const MINUTE = 60;
|
||||||
|
|
||||||
|
// TODO: perhaps rename to MarketLocale API and add market_locales and locales here.
|
||||||
|
export class MarketLocaleAPI extends SQLDataSource {
|
||||||
|
constructor(config) {
|
||||||
|
super(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMarketById(id: number): Promise<Market> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('markets')
|
||||||
|
.where('id', id)
|
||||||
|
.first()
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMarketByName(name: string): Promise<Market> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('markets')
|
||||||
|
.where('name', name)
|
||||||
|
.first()
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMarkets(): Promise<Array<Market>> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('markets')
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getLocaleById(id: number): Promise<Locale> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('locales')
|
||||||
|
.where('id', id)
|
||||||
|
.first()
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getLocaleByValue(value: string): Promise<Locale> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('locales')
|
||||||
|
.where('value', value)
|
||||||
|
.first()
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getLocales(): Promise<Array<Locale>> {
|
||||||
|
return this.knex
|
||||||
|
.select('*')
|
||||||
|
.from('locales')
|
||||||
|
.cache(MINUTE * 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -11,7 +11,7 @@ import { ProductAPI } from './datasources/product-api';
|
|||||||
import { DesignerAPI } from './datasources/designer-api';
|
import { DesignerAPI } from './datasources/designer-api';
|
||||||
import { CategoryAPI } from './datasources/category-api';
|
import { CategoryAPI } from './datasources/category-api';
|
||||||
import { KeywordAPI } from './datasources/keyword-api';
|
import { KeywordAPI } from './datasources/keyword-api';
|
||||||
import { MarketAPI } from './datasources/market-api';
|
import { MarketLocaleAPI } from './datasources/market-locale-api';
|
||||||
import { ImageServerApi } from './datasources/imageserver-api';
|
import { ImageServerApi } from './datasources/imageserver-api';
|
||||||
import { InteriorAPI } from './datasources/interior-api';
|
import { InteriorAPI } from './datasources/interior-api';
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ const designerApi = new DesignerAPI(knexConfig);
|
|||||||
const imageServerApi = new ImageServerApi();
|
const imageServerApi = new ImageServerApi();
|
||||||
const interiorApi = new InteriorAPI(knexConfig, imageServerApi);
|
const interiorApi = new InteriorAPI(knexConfig, imageServerApi);
|
||||||
const keywordApi = new KeywordAPI(knexConfig);
|
const keywordApi = new KeywordAPI(knexConfig);
|
||||||
const marketApi = new MarketAPI(knexConfig);
|
const marketLocaleApi = new MarketLocaleAPI(knexConfig);
|
||||||
const orderApi = new OrderAPI(knexConfig);
|
const orderApi = new OrderAPI(knexConfig);
|
||||||
const productApi = new ProductAPI(knexConfig);
|
const productApi = new ProductAPI(knexConfig);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ const dataSources = () => ({
|
|||||||
interiorApi,
|
interiorApi,
|
||||||
imageServerApi,
|
imageServerApi,
|
||||||
keywordApi,
|
keywordApi,
|
||||||
marketApi,
|
marketLocaleApi,
|
||||||
orderApi,
|
orderApi,
|
||||||
productApi,
|
productApi,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import {
|
|||||||
import { designerQueryTypeDefs, designerTypeDefs } from './designers-resolver';
|
import { designerQueryTypeDefs, designerTypeDefs } from './designers-resolver';
|
||||||
import { categoryQueryTypeDefs, categoryTypeDefs } from './categories-resolver';
|
import { categoryQueryTypeDefs, categoryTypeDefs } from './categories-resolver';
|
||||||
import { keywordsQueryTypeDefs, keywordTypeDefs } from './keywords-resolver';
|
import { keywordsQueryTypeDefs, keywordTypeDefs } from './keywords-resolver';
|
||||||
import { marketsQueryTypeDefs, marketTypeDefs } from './markets-resolver';
|
import {
|
||||||
|
marketsQueryTypeDefs,
|
||||||
|
marketTypeDefs,
|
||||||
|
} from './markets-locale-resolver';
|
||||||
|
|
||||||
import { DateTimeResolver, DateResolver, JSONResolver } from 'graphql-scalars';
|
import { DateTimeResolver, DateResolver, JSONResolver } from 'graphql-scalars';
|
||||||
import { interiorsQueryTypeDefs, interiorTypeDefs } from './interiors-resolver';
|
import { interiorsQueryTypeDefs, interiorTypeDefs } from './interiors-resolver';
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { IResolverObject } from 'graphql-tools';
|
||||||
|
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||||
|
|
||||||
|
const Market: IResolverObject = {};
|
||||||
|
|
||||||
|
async function getMarkets(_, _args, { dataSources }) {
|
||||||
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarkets();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getMarket(_, { name }, { dataSources }) {
|
||||||
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Locale: IResolverObject = {};
|
||||||
|
|
||||||
|
async function getLocales(_, _args, { dataSources }) {
|
||||||
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocales();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getLocale(_, { value }, { dataSources }) {
|
||||||
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocaleByValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const marketTypeDefs = { Market, Locale };
|
||||||
|
|
||||||
|
export const marketsQueryTypeDefs = {
|
||||||
|
markets: getMarkets,
|
||||||
|
market: getMarket,
|
||||||
|
locales: getLocales,
|
||||||
|
locale: getLocale,
|
||||||
|
};
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { IResolverObject } from 'graphql-tools';
|
|
||||||
import { MarketAPI } from '../datasources/market-api';
|
|
||||||
|
|
||||||
const Market: IResolverObject = {};
|
|
||||||
|
|
||||||
async function getMarkets(_, _args, { dataSources }) {
|
|
||||||
return (<MarketAPI>dataSources.marketApi).getMarkets();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getMarket(_, { name }, { dataSources }) {
|
|
||||||
return (<MarketAPI>dataSources.marketApi).getMarketByName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const marketTypeDefs = { Market };
|
|
||||||
|
|
||||||
export const marketsQueryTypeDefs = {
|
|
||||||
markets: getMarkets,
|
|
||||||
market: getMarket,
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { IResolverObject } from 'graphql-tools';
|
import { IResolverObject } from 'graphql-tools';
|
||||||
import { MarketAPI } from '../datasources/market-api';
|
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||||
import { OrderAPI } from '../datasources/order-api';
|
import { OrderAPI } from '../datasources/order-api';
|
||||||
import { FilterInput } from '../types/types';
|
import { FilterInput } from '../types/types';
|
||||||
|
|
||||||
@@ -15,7 +15,14 @@ const Order: IResolverObject = {
|
|||||||
return (<OrderAPI>dataSources.orderApi).getOrderRowsByOrderId(id);
|
return (<OrderAPI>dataSources.orderApi).getOrderRowsByOrderId(id);
|
||||||
},
|
},
|
||||||
async market({ market }, _args, { dataSources }) {
|
async market({ market }, _args, { dataSources }) {
|
||||||
return (<MarketAPI>dataSources.marketApi).getMarketByName(market);
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketByName(
|
||||||
|
market,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
async locale({ locale }, _args, { dataSources }) {
|
||||||
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocaleByValue(
|
||||||
|
locale,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import { CategoryAPI } from '../datasources/category-api';
|
|||||||
import { Category } from '../types/category-types';
|
import { Category } from '../types/category-types';
|
||||||
import { KeywordAPI } from '../datasources/keyword-api';
|
import { KeywordAPI } from '../datasources/keyword-api';
|
||||||
import { Keyword } from '../types/keyword-types';
|
import { Keyword } from '../types/keyword-types';
|
||||||
import { MarketAPI } from '../datasources/market-api';
|
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||||
import { InteriorAPI } from '../datasources/interior-api';
|
import { InteriorAPI } from '../datasources/interior-api';
|
||||||
|
|
||||||
const ProductBlacklist: IResolverObject = {
|
const ProductBlacklist: IResolverObject = {
|
||||||
async market(parent, _args, { dataSources }) {
|
async market(parent, _args, { dataSources }) {
|
||||||
return (<MarketAPI>dataSources.marketApi).getMarketById(parent.marketId);
|
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketById(
|
||||||
|
parent.marketId,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+19
-9
@@ -21,6 +21,8 @@ const typeDefs = gql`
|
|||||||
designer(id: Int!): Designer
|
designer(id: Int!): Designer
|
||||||
markets: [Market]
|
markets: [Market]
|
||||||
market(name: String!): Market
|
market(name: String!): Market
|
||||||
|
locales: [Locale]
|
||||||
|
locale(value: String!): Locale
|
||||||
interiors(filter: InteriorsFilterInput): [Interior]
|
interiors(filter: InteriorsFilterInput): [Interior]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ const typeDefs = gql`
|
|||||||
offset: Int!
|
offset: Int!
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Later replace with implements ListResult
|
Later replace with implements ListResult when products support it
|
||||||
"""
|
"""
|
||||||
type OrderResult {
|
type OrderResult {
|
||||||
total: Int!
|
total: Int!
|
||||||
@@ -63,10 +65,17 @@ const typeDefs = gql`
|
|||||||
|
|
||||||
type Market {
|
type Market {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String
|
name: String!
|
||||||
vat: Float
|
vat: Float!
|
||||||
currency: String
|
currency: String!
|
||||||
priceAdjustment: Float
|
priceAdjustment: Float!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Locale {
|
||||||
|
id: ID!
|
||||||
|
value: String!
|
||||||
|
name: String!
|
||||||
|
fallbackId: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address {
|
type Address {
|
||||||
@@ -132,14 +141,16 @@ const typeDefs = gql`
|
|||||||
customerEmail: String
|
customerEmail: String
|
||||||
customerCellphone: String
|
customerCellphone: String
|
||||||
flyerIds: String
|
flyerIds: String
|
||||||
marketName: String
|
|
||||||
localeName: String
|
|
||||||
billingInformation: ContactInformation
|
billingInformation: ContactInformation
|
||||||
deliveryInformation: ContactInformation
|
deliveryInformation: ContactInformation
|
||||||
billingAddressId: Int
|
billingAddressId: Int
|
||||||
deliveryAddressId: Int
|
deliveryAddressId: Int
|
||||||
rows: [OrderRow]
|
"""
|
||||||
|
pwinty needs to be updated with market being a subtype
|
||||||
|
"""
|
||||||
market: Market
|
market: Market
|
||||||
|
locale: Locale
|
||||||
|
rows: [OrderRow]
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderRow {
|
type OrderRow {
|
||||||
@@ -292,7 +303,6 @@ const typeDefs = gql`
|
|||||||
id: ID!
|
id: ID!
|
||||||
groupId: Int!
|
groupId: Int!
|
||||||
group: ProductGroup!
|
group: ProductGroup!
|
||||||
marketId: Int!
|
|
||||||
market: Market!
|
market: Market!
|
||||||
inserted: DateTime!
|
inserted: DateTime!
|
||||||
updated: DateTime!
|
updated: DateTime!
|
||||||
|
|||||||
@@ -5,3 +5,10 @@ export interface Market {
|
|||||||
currency: string;
|
currency: string;
|
||||||
priceAdjustment: number;
|
priceAdjustment: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Locale {
|
||||||
|
id: number;
|
||||||
|
value: string;
|
||||||
|
fallbackId: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
@@ -85,6 +85,11 @@ export interface ProductFields {
|
|||||||
printFileWidth?: number;
|
printFileWidth?: number;
|
||||||
printFileHeight?: number;
|
printFileHeight?: number;
|
||||||
printFileDpi?: number;
|
printFileDpi?: number;
|
||||||
|
// Below exists for Canvas frame in DB but in shop limits.php is used
|
||||||
|
// minHeight: number;
|
||||||
|
// minWidth: number;
|
||||||
|
// maxHeight: number;
|
||||||
|
// maxWidth: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProductGroupStringFromString(group: string): string {
|
export function getProductGroupStringFromString(group: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user