@unchainedshop/core-products 2.0.0-beta4 → 2.0.0-beta5

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/jest.config.js CHANGED
@@ -2,4 +2,4 @@
2
2
  export default {
3
3
  preset: 'ts-jest/presets/default-esm',
4
4
  testEnvironment: 'node',
5
- }
5
+ };
@@ -1,7 +1,5 @@
1
1
  import { removeProductService } from './removeProductService';
2
- import { ercMetadataService } from './ercMetadataService';
3
2
  export const productServices = {
4
3
  removeProduct: removeProductService,
5
- ercMetadata: ercMetadataService,
6
4
  };
7
5
  //# sourceMappingURL=productServices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"productServices.js","sourceRoot":"","sources":["../../src/service/productServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,aAAa,EAAE,oBAAoB;IACnC,WAAW,EAAE,kBAAkB;CAChC,CAAC"}
1
+ {"version":3,"file":"productServices.js","sourceRoot":"","sources":["../../src/service/productServices.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,aAAa,EAAE,oBAAoB;CACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-products",
3
- "version": "2.0.0-beta4",
3
+ "version": "2.0.0-beta5",
4
4
  "main": "lib/products-index.js",
5
5
  "exports": {
6
6
  ".": "./lib/products-index.js",
@@ -30,18 +30,18 @@
30
30
  },
31
31
  "homepage": "https://github.com/unchainedshop/unchained#readme",
32
32
  "dependencies": {
33
- "@unchainedshop/events": "^2.0.0-beta4",
34
- "@unchainedshop/file-upload": "^2.0.0-beta4",
35
- "@unchainedshop/utils": "^2.0.0-beta4",
33
+ "@unchainedshop/events": "^2.0.0-beta5",
34
+ "@unchainedshop/file-upload": "^2.0.0-beta5",
35
+ "@unchainedshop/utils": "^2.0.0-beta5",
36
36
  "locale": "^0.1.0",
37
37
  "lru-cache": "^7.14.0",
38
38
  "simpl-schema": "^3.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/locale": "^0.1.1",
42
- "@types/node": "^16.11.68",
43
- "@unchainedshop/types": "^2.0.0-beta4",
44
- "jest": "^29.2.1",
42
+ "@types/node": "^16.18.2",
43
+ "@unchainedshop/types": "^2.0.0-beta5",
44
+ "jest": "^29.2.2",
45
45
  "ts-jest": "^29.0.3",
46
46
  "typescript": "^4.8.4"
47
47
  }
@@ -1,8 +1,6 @@
1
1
  import { ProductServices } from '@unchainedshop/types/products';
2
2
  import { removeProductService } from './removeProductService';
3
- import { ercMetadataService } from './ercMetadataService';
4
3
 
5
4
  export const productServices: ProductServices = {
6
5
  removeProduct: removeProductService,
7
- ercMetadata: ercMetadataService,
8
6
  };
@@ -1,2 +0,0 @@
1
- import { ERCMetadataService } from '@unchainedshop/types/products';
2
- export declare const ercMetadataService: ERCMetadataService;
@@ -1,47 +0,0 @@
1
- import { ProductContractStandard } from '@unchainedshop/types/products';
2
- import { systemLocale } from '@unchainedshop/utils';
3
- export const ercMetadataService = async ({ product, locale }, { modules }) => {
4
- // if ERC721 -> tokenUri
5
- // if ERC1155 -> uri
6
- // -> use the contract to get the correct metadata uri from tokenId
7
- // depending on the ERC, build the correct metadata json schema
8
- // https://eips.ethereum.org/EIPS/eip-1155
9
- // https://eips.ethereum.org/EIPS/eip-721
10
- const allLanguages = await modules.languages.findLanguages({
11
- includeInactive: false,
12
- });
13
- const [firstMedia] = await modules.products.media.findProductMedias({
14
- productId: product._id,
15
- limit: 1,
16
- });
17
- const file = firstMedia && (await modules.files.findFile({ fileId: firstMedia.mediaId }));
18
- const url = file && (await modules.files.getUrl(file, {}));
19
- const text = await modules.products.texts.findLocalizedText({
20
- productId: product._id,
21
- locale: locale.normalized,
22
- });
23
- if (product.tokenization.contractStandard === ProductContractStandard.ERC1155) {
24
- const isDefaultLanguageActive = locale.language === systemLocale.language;
25
- const localization = isDefaultLanguageActive
26
- ? {
27
- uri: `${process.env.ROOT_URL}/erc-metadata/${product.tokenization.tokenId}/{locale}.json`,
28
- default: systemLocale.language,
29
- locales: allLanguages.map((lang) => lang.isoCode),
30
- }
31
- : undefined;
32
- return {
33
- name: text.title,
34
- description: text.description,
35
- image: url,
36
- properties: product.meta,
37
- localization,
38
- // decimals:
39
- };
40
- }
41
- return {
42
- name: text.title,
43
- description: text.description,
44
- image: url,
45
- };
46
- };
47
- //# sourceMappingURL=ercMetadataService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ercMetadataService.js","sourceRoot":"","sources":["../../src/service/ercMetadataService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAuB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/F,wBAAwB;IACxB,oBAAoB;IACpB,mEAAmE;IAEnE,+DAA+D;IAC/D,0CAA0C;IAC1C,yCAAyC;IAEzC,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC;QACzD,eAAe,EAAE,KAAK;KACvB,CAAC,CAAC;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAClE,SAAS,EAAE,OAAO,CAAC,GAAG;QACtB,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,UAAU,IAAI,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,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2
- import { systemLocale } from '@unchainedshop/utils';
3
-
4
- export const ercMetadataService: ERCMetadataService = async ({ product, locale }, { modules }) => {
5
- // if ERC721 -> tokenUri
6
- // if ERC1155 -> uri
7
- // -> use the contract to get the correct metadata uri from tokenId
8
-
9
- // depending on the ERC, build the correct metadata json schema
10
- // https://eips.ethereum.org/EIPS/eip-1155
11
- // https://eips.ethereum.org/EIPS/eip-721
12
-
13
- const allLanguages = await modules.languages.findLanguages({
14
- includeInactive: false,
15
- });
16
-
17
- const [firstMedia] = await modules.products.media.findProductMedias({
18
- productId: product._id,
19
- limit: 1,
20
- });
21
- const file = firstMedia && (await modules.files.findFile({ fileId: firstMedia.mediaId }));
22
- const url = file && (await modules.files.getUrl(file, {}));
23
- const text = await modules.products.texts.findLocalizedText({
24
- productId: product._id,
25
- locale: locale.normalized,
26
- });
27
-
28
- if (product.tokenization.contractStandard === ProductContractStandard.ERC1155) {
29
- const isDefaultLanguageActive = locale.language === systemLocale.language;
30
- const localization = isDefaultLanguageActive
31
- ? {
32
- uri: `${process.env.ROOT_URL}/erc-metadata/${product.tokenization.tokenId}/{locale}.json`,
33
- default: systemLocale.language,
34
- locales: allLanguages.map((lang) => lang.isoCode),
35
- }
36
- : undefined;
37
-
38
- return {
39
- name: text.title,
40
- description: text.description,
41
- image: url,
42
- properties: product.meta,
43
- localization,
44
- // decimals:
45
- };
46
- }
47
- return {
48
- name: text.title,
49
- description: text.description,
50
- image: url,
51
- };
52
- };