@unchainedshop/api 2.0.0-beta7 → 2.0.0-beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api-index.d.ts +3 -6
- package/lib/api-index.js +4 -12
- package/lib/api-index.js.map +1 -1
- package/lib/context.d.ts +0 -1
- package/lib/context.js +0 -12
- package/lib/context.js.map +1 -1
- package/lib/createGraphQLServer.d.ts +1 -1
- package/lib/createGraphQLServer.js +2 -33
- package/lib/createGraphQLServer.js.map +1 -1
- package/lib/express/createApolloMiddleware.d.ts +4 -0
- package/lib/express/createApolloMiddleware.js +34 -0
- package/lib/express/createApolloMiddleware.js.map +1 -0
- package/lib/express/createBulkImportMiddleware.d.ts +2 -0
- package/lib/express/createBulkImportMiddleware.js +79 -0
- package/lib/express/createBulkImportMiddleware.js.map +1 -0
- package/lib/express/createERCMetadataMiddleware.d.ts +3 -0
- package/lib/express/createERCMetadataMiddleware.js +56 -0
- package/lib/express/createERCMetadataMiddleware.js.map +1 -0
- package/lib/express/createSingleSignOnMiddleware.d.ts +6 -0
- package/lib/express/createSingleSignOnMiddleware.js +71 -0
- package/lib/express/createSingleSignOnMiddleware.js.map +1 -0
- package/lib/express/index.d.ts +6 -0
- package/lib/express/index.js +27 -0
- package/lib/express/index.js.map +1 -0
- package/lib/resolvers/mutations/accounts/changePassword.d.ts +0 -2
- package/lib/resolvers/mutations/accounts/changePassword.js +2 -2
- package/lib/resolvers/mutations/accounts/changePassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createUser.js +2 -2
- package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/enrollUser.js +1 -1
- package/lib/resolvers/mutations/accounts/enrollUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/loginWithPassword.js +3 -3
- package/lib/resolvers/mutations/accounts/loginWithPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.d.ts +0 -1
- package/lib/resolvers/mutations/accounts/setPassword.js +1 -1
- package/lib/resolvers/mutations/accounts/setPassword.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortment.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentFilter.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentLink.js.map +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js +1 -1
- package/lib/resolvers/mutations/assortments/removeAssortmentProduct.js.map +1 -1
- package/lib/resolvers/mutations/enrollments/updateEnrollment.d.ts +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.js +1 -1
- package/lib/resolvers/mutations/filters/removeFilter.js.map +1 -1
- package/lib/resolvers/mutations/index.d.ts +1 -1
- package/lib/resolvers/mutations/pageView.d.ts +1 -1
- package/lib/resolvers/mutations/pageView.js +2 -2
- package/lib/resolvers/mutations/pageView.js.map +1 -1
- package/lib/resolvers/mutations/products/removeProduct.d.ts +1 -1
- package/lib/resolvers/mutations/products/removeProduct.js +5 -8
- package/lib/resolvers/mutations/products/removeProduct.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-media-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-path-link-types.d.ts +1 -4
- package/lib/resolvers/type/assortment/assortment-path-link-types.js +0 -7
- package/lib/resolvers/type/assortment/assortment-path-link-types.js.map +1 -1
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts +2 -2
- package/lib/resolvers/type/assortment/assortment-types.d.ts +1 -1
- package/lib/resolvers/type/bookmark-types.d.ts +1 -1
- package/lib/resolvers/type/country-types.d.ts +1 -1
- package/lib/resolvers/type/delivery-provider-types.d.ts +1 -1
- package/lib/resolvers/type/enrollment/enrollment-delivery-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-payment-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-period-types.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-plan-tyes.d.ts +2 -2
- package/lib/resolvers/type/enrollment/enrollment-types.d.ts +2 -2
- package/lib/resolvers/type/event-types.d.ts +1 -1
- package/lib/resolvers/type/filter/filter-option-types.d.ts +2 -2
- package/lib/resolvers/type/filter/filter-types.d.ts +2 -2
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-pickup-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +1 -1
- package/lib/resolvers/type/price-types.d.ts +1 -1
- package/lib/resolvers/type/product/product-discount.d.ts +1 -1
- package/lib/resolvers/type/product/product-review-types.d.ts +1 -1
- package/lib/resolvers/type/quotation-types.d.ts +2 -2
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/token-types.d.ts +1 -1
- package/lib/resolvers/type/user-types.d.ts +1 -3
- package/lib/resolvers/type/user-types.js +0 -12
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +1 -1
- package/lib/resolvers/type/work-types.d.ts +1 -1
- package/lib/schema/{types/log.d.ts → directives.d.ts} +0 -0
- package/lib/schema/directives.js +15 -0
- package/lib/schema/directives.js.map +1 -0
- package/lib/schema/index.js +2 -1
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/inputTypes.js +0 -15
- package/lib/schema/inputTypes.js.map +1 -1
- package/lib/schema/mutation.js +4 -23
- package/lib/schema/mutation.js.map +1 -1
- package/lib/schema/query.js +28 -10
- package/lib/schema/query.js.map +1 -1
- package/lib/schema/types/assortment.js +9 -10
- package/lib/schema/types/assortment.js.map +1 -1
- package/lib/schema/types/color.js +1 -1
- package/lib/schema/types/country.js +1 -1
- package/lib/schema/types/currency.js +1 -1
- package/lib/schema/types/delivery.js +3 -2
- package/lib/schema/types/delivery.js.map +1 -1
- package/lib/schema/types/dimensions.js +1 -1
- package/lib/schema/types/discount.js +1 -1
- package/lib/schema/types/dispatch.js +1 -0
- package/lib/schema/types/dispatch.js.map +1 -1
- package/lib/schema/types/filter.js +5 -8
- package/lib/schema/types/filter.js.map +1 -1
- package/lib/schema/types/geo-position.js +1 -1
- package/lib/schema/types/language.js +1 -1
- package/lib/schema/types/media.js +1 -1
- package/lib/schema/types/payment.js +3 -3
- package/lib/schema/types/price.js +2 -2
- package/lib/schema/types/product/bundle-product.js +2 -3
- package/lib/schema/types/product/bundle-product.js.map +1 -1
- package/lib/schema/types/product/configurable-product.js +7 -7
- package/lib/schema/types/product/plan-product.js +4 -3
- package/lib/schema/types/product/plan-product.js.map +1 -1
- package/lib/schema/types/product/product.js +11 -11
- package/lib/schema/types/product/simple-product.js +5 -4
- package/lib/schema/types/product/simple-product.js.map +1 -1
- package/lib/schema/types/product/tokenized-product.js +4 -3
- package/lib/schema/types/product/tokenized-product.js.map +1 -1
- package/lib/schema/types/search.js +3 -8
- package/lib/schema/types/search.js.map +1 -1
- package/lib/schema/types/shop.js +2 -2
- package/lib/schema/types/stock.js +1 -0
- package/lib/schema/types/stock.js.map +1 -1
- package/lib/schema/types/types.js +1 -1
- package/lib/schema/types/user.js +1 -3
- package/lib/schema/types/user.js.map +1 -1
- package/lib/schema/types/warehousing.js +3 -3
- package/package.json +23 -10
- package/src/api-index.ts +5 -26
- package/src/context.ts +0 -18
- package/src/createGraphQLServer.ts +1 -44
- package/src/express/createApolloMiddleware.ts +40 -0
- package/src/express/createBulkImportMiddleware.ts +90 -0
- package/src/express/createERCMetadataMiddleware.ts +72 -0
- package/src/express/createSingleSignOnMiddleware.ts +83 -0
- package/src/express/index.ts +48 -0
- package/src/resolvers/mutations/accounts/changePassword.ts +2 -4
- package/src/resolvers/mutations/accounts/createUser.ts +2 -2
- package/src/resolvers/mutations/accounts/enrollUser.ts +1 -1
- package/src/resolvers/mutations/accounts/loginWithPassword.ts +3 -4
- package/src/resolvers/mutations/accounts/resetPassword.ts +2 -2
- package/src/resolvers/mutations/accounts/setPassword.ts +2 -2
- package/src/resolvers/mutations/assortments/removeAssortment.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentFilter.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentLink.ts +1 -1
- package/src/resolvers/mutations/assortments/removeAssortmentProduct.ts +1 -1
- package/src/resolvers/mutations/filters/removeFilter.ts +1 -1
- package/src/resolvers/mutations/pageView.ts +2 -2
- package/src/resolvers/mutations/products/removeProduct.ts +6 -8
- package/src/resolvers/type/assortment/assortment-path-link-types.ts +0 -11
- package/src/resolvers/type/user-types.ts +0 -15
- package/src/schema/directives.js +14 -0
- package/src/schema/index.js +2 -1
- package/src/schema/inputTypes.js +0 -15
- package/src/schema/mutation.js +4 -23
- package/src/schema/query.js +28 -10
- package/src/schema/types/assortment.js +9 -10
- package/src/schema/types/color.js +1 -1
- package/src/schema/types/country.js +1 -1
- package/src/schema/types/currency.js +1 -1
- package/src/schema/types/delivery.js +3 -2
- package/src/schema/types/dimensions.js +1 -1
- package/src/schema/types/discount.js +1 -1
- package/src/schema/types/dispatch.js +1 -0
- package/src/schema/types/filter.js +5 -8
- package/src/schema/types/geo-position.js +1 -1
- package/src/schema/types/language.js +1 -1
- package/src/schema/types/media.js +1 -1
- package/src/schema/types/payment.js +3 -3
- package/src/schema/types/price.js +2 -2
- package/src/schema/types/product/bundle-product.js +2 -3
- package/src/schema/types/product/configurable-product.js +7 -7
- package/src/schema/types/product/plan-product.js +4 -3
- package/src/schema/types/product/product.js +11 -11
- package/src/schema/types/product/simple-product.js +5 -4
- package/src/schema/types/product/tokenized-product.js +4 -3
- package/src/schema/types/search.js +3 -8
- package/src/schema/types/shop.js +2 -2
- package/src/schema/types/stock.js +1 -0
- package/src/schema/types/types.js +1 -1
- package/src/schema/types/user.js +1 -3
- package/src/schema/types/warehousing.js +3 -3
- package/lib/createBulkImportServer.d.ts +0 -2
- package/lib/createBulkImportServer.js +0 -81
- package/lib/createBulkImportServer.js.map +0 -1
- package/lib/createERCMetadataServer.d.ts +0 -2
- package/lib/createERCMetadataServer.js +0 -59
- package/lib/createERCMetadataServer.js.map +0 -1
- package/lib/schema/types/log.js +0 -16
- package/lib/schema/types/log.js.map +0 -1
- package/src/createBulkImportServer.ts +0 -95
- package/src/createERCMetadataServer.ts +0 -78
- package/src/schema/types/log.js +0 -15
|
@@ -12,20 +12,20 @@ export default [
|
|
|
12
12
|
TEXT
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
type ProductVariationTexts {
|
|
15
|
+
type ProductVariationTexts @cacheControl(maxAge: 180) {
|
|
16
16
|
_id: ID!
|
|
17
17
|
locale: String
|
|
18
18
|
title: String
|
|
19
19
|
subtitle: String
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
type ProductVariationOption {
|
|
22
|
+
type ProductVariationOption @cacheControl(maxAge: 180) {
|
|
23
23
|
_id: ID!
|
|
24
24
|
texts(forceLocale: String): ProductVariationTexts
|
|
25
25
|
value: String
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
type ProductVariation {
|
|
28
|
+
type ProductVariation @cacheControl(maxAge: 180) {
|
|
29
29
|
_id: ID!
|
|
30
30
|
texts(forceLocale: String): ProductVariationTexts
|
|
31
31
|
type: ProductVariationType
|
|
@@ -36,7 +36,7 @@ export default [
|
|
|
36
36
|
"""
|
|
37
37
|
Key Value Combination
|
|
38
38
|
"""
|
|
39
|
-
type ProductVariationAssignmentVector {
|
|
39
|
+
type ProductVariationAssignmentVector @cacheControl(maxAge: 180) {
|
|
40
40
|
_id: ID!
|
|
41
41
|
variation: ProductVariation
|
|
42
42
|
option: ProductVariationOption
|
|
@@ -45,7 +45,7 @@ export default [
|
|
|
45
45
|
"""
|
|
46
46
|
Key Value Combination to Product Assignment
|
|
47
47
|
"""
|
|
48
|
-
type ProductVariationAssignment {
|
|
48
|
+
type ProductVariationAssignment @cacheControl(maxAge: 180) {
|
|
49
49
|
_id: ID!
|
|
50
50
|
|
|
51
51
|
"""
|
|
@@ -62,7 +62,7 @@ export default [
|
|
|
62
62
|
"""
|
|
63
63
|
Configurable Product (Proxy)
|
|
64
64
|
"""
|
|
65
|
-
type ConfigurableProduct implements Product {
|
|
65
|
+
type ConfigurableProduct implements Product @cacheControl(maxAge: 180) {
|
|
66
66
|
_id: ID!
|
|
67
67
|
sequence: Int!
|
|
68
68
|
status: ProductStatus!
|
|
@@ -97,7 +97,7 @@ export default [
|
|
|
97
97
|
includeInactive: Boolean = false
|
|
98
98
|
currency: String
|
|
99
99
|
useNetPrice: Boolean = false
|
|
100
|
-
): PriceRange
|
|
100
|
+
): PriceRange @cacheControl(scope: PRIVATE)
|
|
101
101
|
|
|
102
102
|
"""
|
|
103
103
|
Reduced list of possible products by key/value combinations
|
|
@@ -13,7 +13,7 @@ export default [
|
|
|
13
13
|
METERED
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
type ProductPlanConfiguration {
|
|
16
|
+
type ProductPlanConfiguration @cacheControl(maxAge: 180) {
|
|
17
17
|
usageCalculationType: ProductPlanUsageCalculationType!
|
|
18
18
|
billingInterval: ProductPlanConfigurationInterval!
|
|
19
19
|
billingIntervalCount: Int
|
|
@@ -32,7 +32,7 @@ export default [
|
|
|
32
32
|
"""
|
|
33
33
|
Plan (Virtual Product that somebody can enroll to)
|
|
34
34
|
"""
|
|
35
|
-
type PlanProduct implements Product {
|
|
35
|
+
type PlanProduct implements Product @cacheControl(maxAge: 180) {
|
|
36
36
|
_id: ID!
|
|
37
37
|
sequence: Int!
|
|
38
38
|
status: ProductStatus!
|
|
@@ -45,7 +45,8 @@ export default [
|
|
|
45
45
|
catalogPrice(quantity: Int = 1, currency: String): Price
|
|
46
46
|
leveledCatalogPrices(currency: String): [PriceLevel!]!
|
|
47
47
|
simulatedPrice(currency: String, useNetPrice: Boolean = false, quantity: Int = 1): Price
|
|
48
|
-
|
|
48
|
+
@cacheControl(scope: PRIVATE)
|
|
49
|
+
simulatedDiscounts(quantity: Int = 1): [ProductDiscount!] @cacheControl(scope: PRIVATE)
|
|
49
50
|
assortmentPaths(forceLocale: String): [ProductAssortmentPath!]!
|
|
50
51
|
siblings(
|
|
51
52
|
assortmentId: ID
|
|
@@ -17,20 +17,20 @@ export default [
|
|
|
17
17
|
DELETED
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
type ProductDiscount {
|
|
20
|
+
type ProductDiscount @cacheControl(maxAge: 0) {
|
|
21
21
|
_id: ID!
|
|
22
22
|
interface: DiscountInterface
|
|
23
23
|
total: Price!
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
type ProductMediaTexts {
|
|
26
|
+
type ProductMediaTexts @cacheControl(maxAge: 180) {
|
|
27
27
|
_id: ID!
|
|
28
28
|
locale: String
|
|
29
29
|
title: String
|
|
30
30
|
subtitle: String
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
type ProductMedia {
|
|
33
|
+
type ProductMedia @cacheControl(maxAge: 180) {
|
|
34
34
|
_id: ID!
|
|
35
35
|
tags: [LowerCaseString!]
|
|
36
36
|
file: Media!
|
|
@@ -38,7 +38,7 @@ export default [
|
|
|
38
38
|
texts(forceLocale: String): ProductMediaTexts
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
type ProductTexts {
|
|
41
|
+
type ProductTexts @cacheControl(maxAge: 180) {
|
|
42
42
|
_id: ID!
|
|
43
43
|
locale: String
|
|
44
44
|
slug: String
|
|
@@ -53,7 +53,7 @@ export default [
|
|
|
53
53
|
"""
|
|
54
54
|
Abstract Product
|
|
55
55
|
"""
|
|
56
|
-
interface Product {
|
|
56
|
+
interface Product @cacheControl(maxAge: 180) {
|
|
57
57
|
_id: ID!
|
|
58
58
|
sequence: Int!
|
|
59
59
|
status: ProductStatus!
|
|
@@ -81,12 +81,12 @@ export default [
|
|
|
81
81
|
"""
|
|
82
82
|
Directed assortment to product paths (breadcrumbs)
|
|
83
83
|
"""
|
|
84
|
-
type ProductAssortmentPath {
|
|
84
|
+
type ProductAssortmentPath @cacheControl(maxAge: 180) {
|
|
85
85
|
assortmentProduct: AssortmentProduct!
|
|
86
86
|
links: [AssortmentPathLink!]!
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
type ProductReview {
|
|
89
|
+
type ProductReview @cacheControl(maxAge: 60) {
|
|
90
90
|
_id: ID!
|
|
91
91
|
created: DateTime
|
|
92
92
|
updated: DateTime
|
|
@@ -97,10 +97,10 @@ export default [
|
|
|
97
97
|
title: String
|
|
98
98
|
review: String
|
|
99
99
|
voteCount(type: ProductReviewVoteType): Int
|
|
100
|
-
ownVotes: [ProductReviewVote!]!
|
|
100
|
+
ownVotes: [ProductReviewVote!]! @cacheControl(scope: PRIVATE, maxAge: 60)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
type ProductReviewVote {
|
|
103
|
+
type ProductReviewVote @cacheControl(maxAge: 60) {
|
|
104
104
|
_id: ID!
|
|
105
105
|
timestamp: Timestamp!
|
|
106
106
|
type: ProductReviewVoteType!
|
|
@@ -117,13 +117,13 @@ export default [
|
|
|
117
117
|
value: String!
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
type PriceLevel {
|
|
120
|
+
type PriceLevel @cacheControl(maxAge: 60) {
|
|
121
121
|
minQuantity: Int!
|
|
122
122
|
maxQuantity: Int
|
|
123
123
|
price: Price!
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
type ProductCatalogPrice {
|
|
126
|
+
type ProductCatalogPrice @cacheControl(maxAge: 60) {
|
|
127
127
|
_id: ID!
|
|
128
128
|
isTaxable: Boolean!
|
|
129
129
|
isNetPrice: Boolean!
|
|
@@ -3,7 +3,7 @@ export default [
|
|
|
3
3
|
"""
|
|
4
4
|
Simple Product
|
|
5
5
|
"""
|
|
6
|
-
type SimpleProduct implements Product {
|
|
6
|
+
type SimpleProduct implements Product @cacheControl(maxAge: 180) {
|
|
7
7
|
_id: ID!
|
|
8
8
|
sequence: Int!
|
|
9
9
|
status: ProductStatus!
|
|
@@ -16,16 +16,17 @@ export default [
|
|
|
16
16
|
catalogPrice(quantity: Int = 1, currency: String): Price
|
|
17
17
|
leveledCatalogPrices(currency: String): [PriceLevel!]!
|
|
18
18
|
simulatedPrice(currency: String, useNetPrice: Boolean = false, quantity: Int = 1): Price
|
|
19
|
-
|
|
19
|
+
@cacheControl(scope: PRIVATE, maxAge: 10)
|
|
20
|
+
simulatedDiscounts(quantity: Int = 1): [ProductDiscount!] @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
20
21
|
simulatedDispatches(
|
|
21
22
|
deliveryProviderType: DeliveryProviderType = SHIPPING
|
|
22
23
|
referenceDate: Timestamp
|
|
23
24
|
quantity: Int = 1
|
|
24
|
-
): [Dispatch!]
|
|
25
|
+
): [Dispatch!] @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
25
26
|
simulatedStocks(
|
|
26
27
|
deliveryProviderType: DeliveryProviderType = SHIPPING
|
|
27
28
|
referenceDate: Timestamp
|
|
28
|
-
): [Stock!]
|
|
29
|
+
): [Stock!] @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
29
30
|
assortmentPaths: [ProductAssortmentPath!]!
|
|
30
31
|
siblings(
|
|
31
32
|
assortmentId: ID
|
|
@@ -13,7 +13,7 @@ export default [
|
|
|
13
13
|
ERC721
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
type ContractConfiguration {
|
|
16
|
+
type ContractConfiguration @cacheControl(maxAge: 180) {
|
|
17
17
|
tokenId: String
|
|
18
18
|
supply: Int
|
|
19
19
|
ercMetadataProperties: JSON
|
|
@@ -35,8 +35,9 @@ export default [
|
|
|
35
35
|
catalogPrice(quantity: Int = 1, currency: String): Price
|
|
36
36
|
leveledCatalogPrices(currency: String): [PriceLevel!]!
|
|
37
37
|
simulatedPrice(currency: String, useNetPrice: Boolean = false, quantity: Int = 1): Price
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
@cacheControl(scope: PRIVATE, maxAge: 10)
|
|
39
|
+
simulatedDiscounts(quantity: Int = 1): [ProductDiscount!] @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
40
|
+
simulatedStocks(referenceDate: Timestamp): [Stock!] @cacheControl(scope: PRIVATE, maxAge: 10)
|
|
40
41
|
assortmentPaths(forceLocale: String): [ProductAssortmentPath!]!
|
|
41
42
|
siblings(
|
|
42
43
|
assortmentId: ID
|
|
@@ -7,10 +7,8 @@ export default [
|
|
|
7
7
|
"""
|
|
8
8
|
Search result
|
|
9
9
|
"""
|
|
10
|
-
type SearchResult {
|
|
11
|
-
totalProducts: Int! @deprecated(reason: "Renamed, use the productsCount field")
|
|
10
|
+
type SearchResult @cacheControl(maxAge: 180) {
|
|
12
11
|
productsCount: Int!
|
|
13
|
-
filteredProducts: Int! @deprecated(reason: "Renamed, use the filteredProductsCount field")
|
|
14
12
|
filteredProductsCount: Int!
|
|
15
13
|
filters: [LoadedFilter!]!
|
|
16
14
|
products(limit: Int = 10, offset: Int = 0): [Product!]!
|
|
@@ -19,17 +17,14 @@ export default [
|
|
|
19
17
|
"""
|
|
20
18
|
Search result
|
|
21
19
|
"""
|
|
22
|
-
type ProductSearchResult {
|
|
23
|
-
totalProducts: Int! @deprecated(reason: "Renamed, use the productsCount field")
|
|
20
|
+
type ProductSearchResult @cacheControl(maxAge: 180) {
|
|
24
21
|
productsCount: Int!
|
|
25
|
-
filteredProducts: Int! @deprecated(reason: "Renamed, use the filteredProductsCount field")
|
|
26
22
|
filteredProductsCount: Int!
|
|
27
23
|
filters: [LoadedFilter!]!
|
|
28
24
|
products(limit: Int = 10, offset: Int = 0): [Product!]!
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
type AssortmentSearchResult {
|
|
32
|
-
totalAssortments: Int! @deprecated(reason: "Renamed, use the assortmentsCount field")
|
|
27
|
+
type AssortmentSearchResult @cacheControl(maxAge: 180) {
|
|
33
28
|
assortmentsCount: Int!
|
|
34
29
|
assortments(limit: Int = 10, offset: Int = 0): [Assortment!]!
|
|
35
30
|
}
|
package/src/schema/types/shop.js
CHANGED
package/src/schema/types/user.js
CHANGED
|
@@ -5,7 +5,7 @@ export default [
|
|
|
5
5
|
"""
|
|
6
6
|
Type returned when the user logs in
|
|
7
7
|
"""
|
|
8
|
-
type LoginMethodResponse {
|
|
8
|
+
type LoginMethodResponse @cacheControl(maxAge: 0, scope: PRIVATE) {
|
|
9
9
|
"""
|
|
10
10
|
Id of the user logged in user
|
|
11
11
|
"""
|
|
@@ -86,9 +86,7 @@ export default [
|
|
|
86
86
|
|
|
87
87
|
type User {
|
|
88
88
|
_id: ID!
|
|
89
|
-
email: String @deprecated(reason: "Please use primaryEmail.address instead")
|
|
90
89
|
username: String
|
|
91
|
-
isEmailVerified: Boolean! @deprecated(reason: "Please use primaryEmail.verified instead")
|
|
92
90
|
isGuest: Boolean!
|
|
93
91
|
isTwoFactorEnabled: Boolean!
|
|
94
92
|
isInitialPassword: Boolean!
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default [
|
|
2
2
|
/* GraphQL */ `
|
|
3
|
-
type WarehousingInterface {
|
|
3
|
+
type WarehousingInterface @cacheControl(maxAge: 180) {
|
|
4
4
|
_id: ID!
|
|
5
5
|
label: String
|
|
6
6
|
version: String
|
|
@@ -24,7 +24,7 @@ export default [
|
|
|
24
24
|
WRONG_CREDENTIALS
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
type WarehousingProvider {
|
|
27
|
+
type WarehousingProvider @cacheControl(maxAge: 60) {
|
|
28
28
|
_id: ID!
|
|
29
29
|
created: DateTime
|
|
30
30
|
updated: DateTime
|
|
@@ -42,7 +42,7 @@ export default [
|
|
|
42
42
|
DECENTRALIZED
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
type Token {
|
|
45
|
+
type Token @cacheControl(maxAge: 0, scope: PRIVATE) {
|
|
46
46
|
_id: ID!
|
|
47
47
|
user: User
|
|
48
48
|
walletAddress: String
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { checkAction } from './acl';
|
|
4
|
-
import { actions } from './roles';
|
|
5
|
-
import { useMiddlewareWithCurrentContext } from './context';
|
|
6
|
-
const logger = createLogger('unchained:bulk-import');
|
|
7
|
-
const { BULK_IMPORT_API_PATH = '/bulk-import', BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY } = process.env;
|
|
8
|
-
const errorHandler = (res) => (e) => {
|
|
9
|
-
logger.error(e.message);
|
|
10
|
-
res.writeHead(503);
|
|
11
|
-
res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
12
|
-
};
|
|
13
|
-
const methodWrongHandler = (res) => () => {
|
|
14
|
-
logger.error('Method not supported, return 404');
|
|
15
|
-
res.writeHead(404);
|
|
16
|
-
res.end();
|
|
17
|
-
};
|
|
18
|
-
const createWriteStreamToFilesystem = (cacheDirectory) => {
|
|
19
|
-
const date = new Date().toISOString();
|
|
20
|
-
const payloadFilePath = `${cacheDirectory}/${date}.json`;
|
|
21
|
-
const stream = fs.createWriteStream(payloadFilePath, { flags: 'a' });
|
|
22
|
-
return stream;
|
|
23
|
-
};
|
|
24
|
-
const createWriteStreamToMongoDB = (BulkImportPayloads) => {
|
|
25
|
-
const date = new Date().toISOString();
|
|
26
|
-
const stream = BulkImportPayloads.openUploadStreamWithId(date, `${date}.json`, {
|
|
27
|
-
contentType: 'application/json',
|
|
28
|
-
});
|
|
29
|
-
return stream;
|
|
30
|
-
};
|
|
31
|
-
const bulkImportMiddleware = async (req, res) => {
|
|
32
|
-
try {
|
|
33
|
-
if (req.method !== 'POST') {
|
|
34
|
-
methodWrongHandler(res)();
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const resolvedContext = req.unchainedContext;
|
|
38
|
-
await checkAction(resolvedContext, actions.bulkImport);
|
|
39
|
-
const input = {
|
|
40
|
-
createShouldUpsertIfIDExists: !!req.query?.createShouldUpsertIfIDExists,
|
|
41
|
-
skipCacheInvalidation: !!req.query?.skipCacheInvalidation,
|
|
42
|
-
fsPayloadCacheDirectory: BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY,
|
|
43
|
-
remoteAddress: resolvedContext.remoteAddress,
|
|
44
|
-
};
|
|
45
|
-
const stream = input.fsPayloadCacheDirectory
|
|
46
|
-
? createWriteStreamToFilesystem(input.fsPayloadCacheDirectory)
|
|
47
|
-
: createWriteStreamToMongoDB(resolvedContext.bulkImporter.BulkImportPayloads);
|
|
48
|
-
req
|
|
49
|
-
.pipe(stream)
|
|
50
|
-
.on('error', errorHandler(res))
|
|
51
|
-
.on('finish', async (file) => {
|
|
52
|
-
try {
|
|
53
|
-
if (input.fsPayloadCacheDirectory) {
|
|
54
|
-
input.payloadFilePath = stream.path;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
input.payloadId = file._id;
|
|
58
|
-
input.payloadSize = file.length;
|
|
59
|
-
}
|
|
60
|
-
const work = await resolvedContext.modules.worker.addWork({
|
|
61
|
-
type: 'BULK_IMPORT',
|
|
62
|
-
input: Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value))),
|
|
63
|
-
retries: 0,
|
|
64
|
-
priority: 10,
|
|
65
|
-
}, resolvedContext.userId);
|
|
66
|
-
res.writeHead(200);
|
|
67
|
-
res.end(JSON.stringify(work));
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
errorHandler(res)(e);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
errorHandler(res)(e);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
export default (expressApp) => {
|
|
79
|
-
useMiddlewareWithCurrentContext(expressApp, BULK_IMPORT_API_PATH, bulkImportMiddleware);
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=createBulkImportServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createBulkImportServer.js","sourceRoot":"","sources":["../src/createBulkImportServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,EAAE,oBAAoB,GAAG,cAAc,EAAE,mCAAmC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEnG,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IAClC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACxB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,GAAG,CAAC,I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,EAAE,EAAE;iBACb,EACD,eAAe,CAAC,MAAM,CACvB,CAAC;gBACF,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;aAC/B;YAAC,OAAO,CAAC,EAAE;gBACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;KACN;IAAC,OAAO,CAAC,EAAE;QACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACtB;AACH,CAAC,CAAC;AAEF,eAAe,CAAC,UAAU,EAAE,EAAE;IAC5B,+BAA+B,CAAC,UAAU,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AAC1F,CAAC,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import { systemLocale } from '@unchainedshop/utils';
|
|
3
|
-
import localePkg from 'locale';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { useMiddlewareWithCurrentContext } from './context';
|
|
6
|
-
const { Locale } = localePkg;
|
|
7
|
-
const logger = createLogger('unchained:erc-metadata');
|
|
8
|
-
const { ERC_METADATA_API_PATH = '/erc-metadata' } = process.env;
|
|
9
|
-
const errorHandler = (res) => (e) => {
|
|
10
|
-
logger.error(e.message);
|
|
11
|
-
res.writeHead(503);
|
|
12
|
-
res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
13
|
-
};
|
|
14
|
-
const methodWrongHandler = (res) => () => {
|
|
15
|
-
logger.error('Method not supported, return 404');
|
|
16
|
-
res.writeHead(404);
|
|
17
|
-
res.end();
|
|
18
|
-
};
|
|
19
|
-
const ercMetadataMiddleware = async (req, res) => {
|
|
20
|
-
try {
|
|
21
|
-
if (req.method !== 'GET') {
|
|
22
|
-
methodWrongHandler(res)();
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const resolvedContext = req.unchainedContext;
|
|
26
|
-
const url = new URL(req.url, process.env.ROOT_URL);
|
|
27
|
-
const parsedPath = path.parse(url.pathname);
|
|
28
|
-
if (parsedPath.ext !== '.json')
|
|
29
|
-
throw new Error('Invalid ERC Metadata URI');
|
|
30
|
-
const [, productId, localeOrTokenFilename, tokenFileName] = url.pathname.split('/');
|
|
31
|
-
const locale = tokenFileName ? localeOrTokenFilename : systemLocale.language;
|
|
32
|
-
const chainTokenId = parsedPath.name;
|
|
33
|
-
const product = await resolvedContext.modules.products.findProduct({
|
|
34
|
-
productId,
|
|
35
|
-
});
|
|
36
|
-
const [token] = await resolvedContext.modules.warehousing.findTokens({
|
|
37
|
-
chainTokenId,
|
|
38
|
-
contractAddress: product?.tokenization?.contractAddress,
|
|
39
|
-
});
|
|
40
|
-
const ercMetadata = await resolvedContext.modules.warehousing.tokenMetadata(chainTokenId, {
|
|
41
|
-
token,
|
|
42
|
-
product,
|
|
43
|
-
referenceDate: new Date(),
|
|
44
|
-
}, { ...resolvedContext, localeContext: new Locale(locale) });
|
|
45
|
-
const body = JSON.stringify(ercMetadata);
|
|
46
|
-
res.writeHead(200, {
|
|
47
|
-
'Content-Length': Buffer.byteLength(body),
|
|
48
|
-
'Content-Type': 'text/plain',
|
|
49
|
-
});
|
|
50
|
-
res.end(body);
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
errorHandler(res)(e);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
export default (expressApp) => {
|
|
57
|
-
useMiddlewareWithCurrentContext(expressApp, ERC_METADATA_API_PATH, ercMetadataMiddleware);
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=createERCMetadataServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createERCMetadataServer.js","sourceRoot":"","sources":["../src/createERCMetadataServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAA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,IAAI,CAAC;YACzC,cAAc,EAAE,YAAY;SAC7B,CAAC,CAAC;QACH,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACf;IAAC,OAAO,CAAC,EAAE;QACV,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACtB;AACH,CAAC,CAAC;AAEF,eAAe,CAAC,UAAU,EAAE,EAAE;IAC5B,+BAA+B,CAAC,UAAU,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;AAC5F,CAAC,CAAC"}
|
package/lib/schema/types/log.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
/* GraphQL */ `
|
|
3
|
-
"""
|
|
4
|
-
Server side log entry, that is contextually augmented with user & order
|
|
5
|
-
"""
|
|
6
|
-
type Log {
|
|
7
|
-
_id: ID!
|
|
8
|
-
created: DateTime!
|
|
9
|
-
level: String!
|
|
10
|
-
message: String!
|
|
11
|
-
user: User
|
|
12
|
-
order: Order
|
|
13
|
-
}
|
|
14
|
-
`,
|
|
15
|
-
];
|
|
16
|
-
//# sourceMappingURL=log.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/schema/types/log.js"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;GAYb;CACF,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import { Context } from '@unchainedshop/types/api';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
|
|
5
|
-
import { checkAction } from './acl';
|
|
6
|
-
import { actions } from './roles';
|
|
7
|
-
|
|
8
|
-
import { useMiddlewareWithCurrentContext } from './context';
|
|
9
|
-
|
|
10
|
-
const logger = createLogger('unchained:bulk-import');
|
|
11
|
-
|
|
12
|
-
const { BULK_IMPORT_API_PATH = '/bulk-import', BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY } = process.env;
|
|
13
|
-
|
|
14
|
-
const errorHandler = (res) => (e) => {
|
|
15
|
-
logger.error(e.message);
|
|
16
|
-
res.writeHead(503);
|
|
17
|
-
res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const methodWrongHandler = (res) => () => {
|
|
21
|
-
logger.error('Method not supported, return 404');
|
|
22
|
-
res.writeHead(404);
|
|
23
|
-
res.end();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const createWriteStreamToFilesystem = (cacheDirectory) => {
|
|
27
|
-
const date = new Date().toISOString();
|
|
28
|
-
const payloadFilePath = `${cacheDirectory}/${date}.json`;
|
|
29
|
-
const stream = fs.createWriteStream(payloadFilePath, { flags: 'a' });
|
|
30
|
-
return stream;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const createWriteStreamToMongoDB = (BulkImportPayloads) => {
|
|
34
|
-
const date = new Date().toISOString();
|
|
35
|
-
const stream = BulkImportPayloads.openUploadStreamWithId(date, `${date}.json`, {
|
|
36
|
-
contentType: 'application/json',
|
|
37
|
-
});
|
|
38
|
-
return stream;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const bulkImportMiddleware = async (req, res) => {
|
|
42
|
-
try {
|
|
43
|
-
if (req.method !== 'POST') {
|
|
44
|
-
methodWrongHandler(res)();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const resolvedContext = req.unchainedContext as Context;
|
|
49
|
-
await checkAction(resolvedContext, (actions as any).bulkImport);
|
|
50
|
-
|
|
51
|
-
const input: any = {
|
|
52
|
-
createShouldUpsertIfIDExists: !!req.query?.createShouldUpsertIfIDExists,
|
|
53
|
-
skipCacheInvalidation: !!req.query?.skipCacheInvalidation,
|
|
54
|
-
fsPayloadCacheDirectory: BULK_IMPORT_PAYLOAD_CACHE_DIRECTORY,
|
|
55
|
-
remoteAddress: resolvedContext.remoteAddress,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const stream = input.fsPayloadCacheDirectory
|
|
59
|
-
? createWriteStreamToFilesystem(input.fsPayloadCacheDirectory)
|
|
60
|
-
: createWriteStreamToMongoDB(resolvedContext.bulkImporter.BulkImportPayloads);
|
|
61
|
-
|
|
62
|
-
req
|
|
63
|
-
.pipe(stream)
|
|
64
|
-
.on('error', errorHandler(res))
|
|
65
|
-
.on('finish', async (file) => {
|
|
66
|
-
try {
|
|
67
|
-
if (input.fsPayloadCacheDirectory) {
|
|
68
|
-
input.payloadFilePath = stream.path;
|
|
69
|
-
} else {
|
|
70
|
-
input.payloadId = file._id;
|
|
71
|
-
input.payloadSize = file.length;
|
|
72
|
-
}
|
|
73
|
-
const work = await resolvedContext.modules.worker.addWork(
|
|
74
|
-
{
|
|
75
|
-
type: 'BULK_IMPORT',
|
|
76
|
-
input: Object.fromEntries(Object.entries(input).filter(([, value]) => Boolean(value))),
|
|
77
|
-
retries: 0,
|
|
78
|
-
priority: 10,
|
|
79
|
-
},
|
|
80
|
-
resolvedContext.userId,
|
|
81
|
-
);
|
|
82
|
-
res.writeHead(200);
|
|
83
|
-
res.end(JSON.stringify(work));
|
|
84
|
-
} catch (e) {
|
|
85
|
-
errorHandler(res)(e);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
} catch (e) {
|
|
89
|
-
errorHandler(res)(e);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default (expressApp) => {
|
|
94
|
-
useMiddlewareWithCurrentContext(expressApp, BULK_IMPORT_API_PATH, bulkImportMiddleware);
|
|
95
|
-
};
|