@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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
-
import { Context } from '@unchainedshop/types/api';
|
|
3
|
-
import { systemLocale } from '@unchainedshop/utils';
|
|
4
|
-
import { IncomingMessage } from 'http';
|
|
5
|
-
import localePkg from 'locale';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { useMiddlewareWithCurrentContext } from './context';
|
|
8
|
-
|
|
9
|
-
const { Locale } = localePkg;
|
|
10
|
-
|
|
11
|
-
const logger = createLogger('unchained:erc-metadata');
|
|
12
|
-
|
|
13
|
-
const { ERC_METADATA_API_PATH = '/erc-metadata' } = process.env;
|
|
14
|
-
|
|
15
|
-
const errorHandler = (res) => (e) => {
|
|
16
|
-
logger.error(e.message);
|
|
17
|
-
res.writeHead(503);
|
|
18
|
-
res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const methodWrongHandler = (res) => () => {
|
|
22
|
-
logger.error('Method not supported, return 404');
|
|
23
|
-
res.writeHead(404);
|
|
24
|
-
res.end();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ercMetadataMiddleware = async (req: IncomingMessage & { unchainedContext?: Context }, res) => {
|
|
28
|
-
try {
|
|
29
|
-
if (req.method !== 'GET') {
|
|
30
|
-
methodWrongHandler(res)();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const resolvedContext = req.unchainedContext;
|
|
35
|
-
|
|
36
|
-
const url = new URL(req.url, process.env.ROOT_URL);
|
|
37
|
-
const parsedPath = path.parse(url.pathname);
|
|
38
|
-
|
|
39
|
-
if (parsedPath.ext !== '.json') throw new Error('Invalid ERC Metadata URI');
|
|
40
|
-
|
|
41
|
-
const [, productId, localeOrTokenFilename, tokenFileName] = url.pathname.split('/');
|
|
42
|
-
|
|
43
|
-
const locale = tokenFileName ? localeOrTokenFilename : systemLocale.language;
|
|
44
|
-
const chainTokenId = parsedPath.name;
|
|
45
|
-
|
|
46
|
-
const product = await resolvedContext.modules.products.findProduct({
|
|
47
|
-
productId,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const [token] = await resolvedContext.modules.warehousing.findTokens({
|
|
51
|
-
chainTokenId,
|
|
52
|
-
contractAddress: product?.tokenization?.contractAddress,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const ercMetadata = await resolvedContext.modules.warehousing.tokenMetadata(
|
|
56
|
-
chainTokenId,
|
|
57
|
-
{
|
|
58
|
-
token,
|
|
59
|
-
product,
|
|
60
|
-
referenceDate: new Date(),
|
|
61
|
-
},
|
|
62
|
-
{ ...resolvedContext, localeContext: new Locale(locale) },
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const body = JSON.stringify(ercMetadata);
|
|
66
|
-
res.writeHead(200, {
|
|
67
|
-
'Content-Length': Buffer.byteLength(body),
|
|
68
|
-
'Content-Type': 'text/plain',
|
|
69
|
-
});
|
|
70
|
-
res.end(body);
|
|
71
|
-
} catch (e) {
|
|
72
|
-
errorHandler(res)(e);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default (expressApp) => {
|
|
77
|
-
useMiddlewareWithCurrentContext(expressApp, ERC_METADATA_API_PATH, ercMetadataMiddleware);
|
|
78
|
-
};
|
package/src/schema/types/log.js
DELETED