@bottlebooks/valid-values 1.1.0 → 1.2.0

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/translate.d.ts +3 -0
  3. package/dist/core/translate.d.ts.map +1 -0
  4. package/dist/core/translate.js +24 -0
  5. package/dist/index.d.ts +1 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +9 -10
  8. package/dist/main.js +11 -5
  9. package/dist/validValues/award.d.ts +6 -2
  10. package/dist/validValues/award.d.ts.map +1 -1
  11. package/dist/validValues/award.js +29 -236
  12. package/dist/validValues/awardMedal.d.ts +1 -1
  13. package/dist/validValues/beerStyle.d.ts +1 -1
  14. package/dist/validValues/certification.d.ts +1 -1
  15. package/dist/validValues/country.d.ts +1 -1
  16. package/dist/validValues/ingredient.d.ts +1 -1
  17. package/dist/validValues/ingredient.d.ts.map +1 -1
  18. package/dist/validValues/ingredient.js +37 -33
  19. package/dist/validValues/packagingCertification.d.ts +1 -1
  20. package/dist/validValues/productType.d.ts +6 -2
  21. package/dist/validValues/productType.d.ts.map +1 -1
  22. package/dist/validValues/productType.js +39 -78
  23. package/dist/validValues/productionMethod.d.ts +1 -1
  24. package/dist/validValues/region.d.ts +14 -17
  25. package/dist/validValues/region.d.ts.map +1 -1
  26. package/dist/validValues/region.js +4804 -5250
  27. package/dist/validValues/responsibleConsumptionLogo.d.ts +1 -1
  28. package/dist/validValues/subregion.d.ts +12 -17
  29. package/dist/validValues/subregion.d.ts.map +1 -1
  30. package/dist/validValues/subregion.js +12501 -13853
  31. package/dist/validValues/types/ProductType.d.ts.map +1 -1
  32. package/dist/validValues/types/award_p85_100.d.ts +3 -0
  33. package/dist/validValues/types/award_p85_100.d.ts.map +1 -0
  34. package/dist/validValues/types/award_p85_100.js +9 -0
  35. package/dist/validValues/types/productTypesSpirit.d.ts +4 -0
  36. package/dist/validValues/types/productTypesSpirit.d.ts.map +1 -0
  37. package/dist/validValues/types/productTypesSpirit.js +9 -0
  38. package/dist/validValues/types/productTypesWine.d.ts +4 -0
  39. package/dist/validValues/types/productTypesWine.d.ts.map +1 -0
  40. package/dist/validValues/types/productTypesWine.js +9 -0
  41. package/dist/validValues/utils/createValidValues.d.ts +1 -1
  42. package/dist/validValues/utils/createValidValues.d.ts.map +1 -1
  43. package/dist/validValues/utils/createValidValues.js +50 -53
  44. package/dist/validValues/varietyName.d.ts +1 -1
  45. package/dist/validValues/wineColor.d.ts +1 -1
  46. package/dist/validValues/wineType.d.ts +1 -1
  47. package/package.json +2 -2
  48. package/region.ts +0 -0
  49. package/src/core/translate.ts +16 -0
  50. package/src/index.ts +1 -6
  51. package/src/locales/po/bg.po +1954 -1954
  52. package/src/locales/po/de.po +1954 -1954
  53. package/src/locales/po/ee.po +1954 -1954
  54. package/src/locales/po/en.po +1954 -1954
  55. package/src/locales/po/es.po +1954 -1954
  56. package/src/locales/po/fi.po +1954 -1954
  57. package/src/locales/po/fr.po +1954 -1954
  58. package/src/locales/po/hr.po +1954 -1954
  59. package/src/locales/po/hu.po +1954 -1954
  60. package/src/locales/po/it.po +1954 -1954
  61. package/src/locales/po/lt.po +1954 -1954
  62. package/src/locales/po/lv.po +1954 -1954
  63. package/src/locales/po/mt.po +1954 -1954
  64. package/src/locales/po/nl.po +1954 -1954
  65. package/src/locales/po/pl.po +1954 -1954
  66. package/src/locales/po/pt.po +1954 -1954
  67. package/src/locales/po/ro.po +1954 -1954
  68. package/src/locales/po/se.po +1954 -1954
  69. package/src/locales/po/si.po +1954 -1954
  70. package/src/locales/po/sk.po +1954 -1954
  71. package/src/main.ts +28 -21
  72. package/src/validValues/award.ts +242 -709
  73. package/src/validValues/ingredient.ts +35 -343
  74. package/src/validValues/productType.ts +7 -40
  75. package/src/validValues/region.ts +514 -479
  76. package/src/validValues/subregion.ts +1428 -1388
  77. package/src/validValues/types/ProductType.ts +0 -1
  78. package/src/validValues/types/award_p85_100.ts +19 -0
  79. package/src/validValues/types/productTypesSpirit.ts +38 -0
  80. package/src/validValues/types/productTypesWine.ts +10 -0
  81. package/src/validValues/utils/createValidValues.ts +52 -50
  82. package/src/validValues/types/Award.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"file":"ProductType.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/ProductType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACvD,KAAK,EAAE,iBAAiB,CAAC;CAC1B"}
1
+ {"version":3,"file":"ProductType.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/ProductType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACvD,KAAK,EAAE,iBAAiB,CAAC;CAC1B"}
@@ -0,0 +1,3 @@
1
+ declare const range: Array<string>;
2
+ export default range;
3
+ //# sourceMappingURL=award_p85_100.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"award_p85_100.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/award_p85_100.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,MAAM,CAiBxB,CAAC;AACF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var range = ['p_85', 'p_86', 'p_87', 'p_88', 'p_89', 'p_90', 'p_91', 'p_92', 'p_93', 'p_94', 'p_95', 'p_96', 'p_97', 'p_98', 'p_99', 'p_100'];
8
+ var _default = range;
9
+ exports["default"] = _default;
@@ -0,0 +1,4 @@
1
+ import { ProductType } from './ProductTypeKey';
2
+ declare const PRODUCT_TYPE_SPIRITS: Array<ProductType>;
3
+ export default PRODUCT_TYPE_SPIRITS;
4
+ //# sourceMappingURL=productTypesSpirit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productTypesSpirit.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/productTypesSpirit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,QAAA,MAAM,oBAAoB,EAAE,KAAK,CAAC,WAAW,CAkC5C,CAAC;AACF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var PRODUCT_TYPE_SPIRITS = ['spirit_absinthe', 'spirit_anise', 'spirit_aquavit', 'spirit_arak', 'spirit_armagnac', 'spirit_asianspirit', 'spirit_bitter', 'spirit_cachaca', 'spirit_calvados', 'spirit_cocktail', 'spirit_cognac', 'spirit_fruitspirit', 'spirit_genever', 'spirit_gin', 'spirit_grainspirit', 'spirit_grapebrandy', 'spirit_grappa', 'spirit_liqueur', 'spirit_marc', 'spirit_mezcal', 'spirit_miscspririt', 'spirit_ouzo', 'spirit_pastis', 'spirit_pisco', 'spirit_raki', 'spirit_rum', 'spirit_sambuca', 'spirit_shochu', 'spirit_schnaps', 'spirit_tequila', 'spirit_vermouth', 'spirit_vodka', 'spirit_whisky'];
8
+ var _default = PRODUCT_TYPE_SPIRITS;
9
+ exports["default"] = _default;
@@ -0,0 +1,4 @@
1
+ import { ProductType } from './ProductTypeKey';
2
+ declare const PRODUCT_TYPE_WINES: Array<ProductType>;
3
+ export default PRODUCT_TYPE_WINES;
4
+ //# sourceMappingURL=productTypesWine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productTypesWine.d.ts","sourceRoot":"","sources":["../../../src/validValues/types/productTypesWine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,WAAW,CAM1C,CAAC;AACF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var PRODUCT_TYPE_WINES = ['wine_stillwine', 'wine_fortified', 'wine_pearlwine', 'wine_sparkling', 'wine_aromatized'];
8
+ var _default = PRODUCT_TYPE_WINES;
9
+ exports["default"] = _default;
@@ -2,7 +2,7 @@ import { allMessages } from '../../locales/locales.js';
2
2
  import { ValidValueDefinition } from '../types/ValidValueDefinition';
3
3
  declare type Locale = keyof typeof allMessages;
4
4
  export default function createValidValues<ValidValue extends ValidValueDefinition = ValidValueDefinition>(values: Record<string, ValidValue>): {
5
- list: () => ({
5
+ list: ({
6
6
  /** The value identifier. */
7
7
  id: string;
8
8
  } & ValidValue & {
@@ -1 +1 @@
1
- {"version":3,"file":"createValidValues.d.ts","sourceRoot":"","sources":["../../../src/validValues/utils/createValidValues.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAKrE,aAAK,MAAM,GAAG,MAAM,OAAO,WAAW,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,UAAU,SAAS,oBAAoB,GAAG,oBAAoB,EAC9D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;QA0B5B,4BAA4B;;;QAG5B,qDAAqD;4BArB5B,MAAM;QAuB/B,0DAA0D;4BACvC,MAAM,EAAE;;;;;YAN3B,4BAA4B;;;YAG5B,qDAAqD;gCArB5B,MAAM;YAuB/B,0DAA0D;gCACvC,MAAM,EAAE;;;;EA4BlC"}
1
+ {"version":3,"file":"createValidValues.d.ts","sourceRoot":"","sources":["../../../src/validValues/utils/createValidValues.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAKrE,aAAK,MAAM,GAAG,MAAM,OAAO,WAAW,CAAC;AAEvC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,UAAU,SAAS,oBAAoB,GAAG,oBAAoB,EAC9D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;QA4B9B,4BAA4B;;;QAG5B,qDAAqD;4BAxB5B,MAAM;QA0B/B,0DAA0D;4BACvC,MAAM,EAAE;;;;;YAN3B,4BAA4B;;;YAG5B,qDAAqD;gCAxB5B,MAAM;YA0B/B,0DAA0D;gCACvC,MAAM,EAAE;;;;EA4BhC"}
@@ -34,66 +34,63 @@ _core.i18n.loadLocaleData(_locales.allLocaleData);
34
34
  _core.i18n.load(_locales.allMessages);
35
35
 
36
36
  function createValidValues(values) {
37
- function list() {
38
- // TODO if we provide locale argument here we can avoid getTitle without locale argument which can help in .map functions
39
- // const initialLocale = locale;
40
- return Object.entries(values).map(function (_ref) {
41
- var _ref2 = _slicedToArray(_ref, 2),
42
- id = _ref2[0],
43
- value = _ref2[1];
44
-
45
- var key = value.key,
46
- title = value.title,
47
- form = value.form,
48
- frontend = value.frontend;
49
- if (!title) throw new Error('missing_required:title');
50
-
51
- function getTitle(locale) {
52
- if (typeof title === 'string') {
53
- return title;
54
- } else if (title) {
55
- _core.i18n.activate(locale || 'en');
56
-
57
- var translation = _core.i18n._(title) || '';
58
-
59
- if (translation === title.id) {
60
- console.log('%c' + "WARNING: translation_missing:".concat(title.id, ":").concat(locale), 'color: #d0011b;');
61
-
62
- _core.i18n.activate('en');
63
-
64
- return _core.i18n._(title) || '';
65
- }
66
-
67
- return translation;
68
- } else {
69
- return key;
37
+ // TODO if we provide locale argument here we can avoid getTitle without locale argument which can help in .map functions
38
+ // const initialLocale = locale;
39
+ var list = Object.entries(values).map(function (_ref) {
40
+ var _ref2 = _slicedToArray(_ref, 2),
41
+ id = _ref2[0],
42
+ value = _ref2[1];
43
+
44
+ var key = value.key,
45
+ title = value.title,
46
+ form = value.form,
47
+ frontend = value.frontend;
48
+ if (!title) throw new Error('missing_required:title');
49
+
50
+ function getTitle(locale) {
51
+ if (typeof title === 'string') {
52
+ return title;
53
+ } else if (title) {
54
+ _core.i18n.activate(locale || 'en');
55
+
56
+ var translation = _core.i18n._(title) || '';
57
+
58
+ if (translation === title.id) {
59
+ console.log('%c' + "WARNING: translation_missing:".concat(title.id, ":").concat(locale), 'color: #d0011b;');
60
+
61
+ _core.i18n.activate('en');
62
+
63
+ return _core.i18n._(title) || '';
70
64
  }
65
+
66
+ return translation;
67
+ } else {
68
+ return key;
71
69
  }
70
+ }
72
71
 
73
- return _objectSpread(_objectSpread({
74
- /** The value identifier. */
75
- id: id
76
- }, value), {}, {
77
- /** Returns the localized title of a lookup value. */
78
- getTitle: getTitle,
79
-
80
- /** Returns the translatet titles for multiple locales. */
81
- getTitles: function getTitles() {
82
- var locales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : allSupportedLocales;
83
- var translations = Object.fromEntries(locales.map(function (locale) {
84
- return [locale, getTitle(locale)];
85
- }));
86
- return translations;
87
- },
88
- form: value.form ? _objectSpread({}, value.form) : undefined
89
- });
72
+ return _objectSpread(_objectSpread({
73
+ /** The value identifier. */
74
+ id: id
75
+ }, value), {}, {
76
+ /** Returns the localized title of a lookup value. */
77
+ getTitle: getTitle,
78
+
79
+ /** Returns the translatet titles for multiple locales. */
80
+ getTitles: function getTitles() {
81
+ var locales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : allSupportedLocales;
82
+ var translations = Object.fromEntries(locales.map(function (locale) {
83
+ return [locale, getTitle(locale)];
84
+ }));
85
+ return translations;
86
+ },
87
+ form: value.form ? _objectSpread({}, value.form) : undefined
90
88
  });
91
- }
92
-
89
+ });
93
90
  return {
94
91
  list: list,
95
92
  byId: function byId() {
96
- return Object.fromEntries(list().map(function (value) {
93
+ return Object.fromEntries(list.map(function (value) {
97
94
  return [value.id, value];
98
95
  }));
99
96
  }
@@ -2,7 +2,7 @@ import { ValidValueDefinition } from './types/ValidValueDefinition';
2
2
  export interface VarietyName extends ValidValueDefinition {
3
3
  }
4
4
  declare const _default: {
5
- list: () => ({
5
+ list: ({
6
6
  id: string;
7
7
  } & VarietyName & {
8
8
  getTitle: (locale?: "de" | "en" | "es" | "fr" | "it" | "pt" | "sk" | "bg" | "hr" | "nl" | "ee" | "fi" | "hu" | "lv" | "lt" | "mt" | "pl" | "ro" | "si" | "se" | undefined) => string;
@@ -2,7 +2,7 @@ import { ValidValueDefinition } from './types/ValidValueDefinition';
2
2
  export interface WineColor extends ValidValueDefinition {
3
3
  }
4
4
  declare const _default: {
5
- list: () => ({
5
+ list: ({
6
6
  id: string;
7
7
  } & WineColor & {
8
8
  getTitle: (locale?: "de" | "en" | "es" | "fr" | "it" | "pt" | "sk" | "bg" | "hr" | "nl" | "ee" | "fi" | "hu" | "lv" | "lt" | "mt" | "pl" | "ro" | "si" | "se" | undefined) => string;
@@ -2,7 +2,7 @@ import { ValidValueDefinition } from './types/ValidValueDefinition';
2
2
  export interface WineType extends ValidValueDefinition {
3
3
  }
4
4
  declare const _default: {
5
- list: () => ({
5
+ list: ({
6
6
  id: string;
7
7
  } & WineType & {
8
8
  getTitle: (locale?: "de" | "en" | "es" | "fr" | "it" | "pt" | "sk" | "bg" | "hr" | "nl" | "ee" | "fi" | "hu" | "lv" | "lt" | "mt" | "pl" | "ro" | "si" | "se" | undefined) => string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@bottlebooks/valid-values",
3
3
  "description": "The Bottlebooks lookup values, defined globally.",
4
4
  "private": false,
5
- "version": "1.1.0",
5
+ "version": "1.2.0",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
8
8
  "scripts": {
@@ -32,5 +32,5 @@
32
32
  "@babel/core": "^7.15.5",
33
33
  "@lingui/core": "^3.14.0"
34
34
  },
35
- "gitHead": "9ab06a18f85e53955536c3e65ff53381ec1df03f"
35
+ "gitHead": "c633baa84173c2e200b85f3833ef54bfb3809a22"
36
36
  }
package/region.ts ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ import { i18n, MessageDescriptor } from '@lingui/core';
2
+
3
+ export function translate(message: MessageDescriptor, locale: string) {
4
+ i18n.activate(locale);
5
+ const translation = i18n._(message);
6
+ if (translation === message.id) {
7
+ console.log(
8
+ '%c' + `WARNING: translation_missing:${message.id}:${locale}`,
9
+ 'color: #d0011b;'
10
+ );
11
+ i18n.activate('en');
12
+ return i18n._(message) || '';
13
+ }
14
+ return translation;
15
+ }
16
+
package/src/index.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import { i18n, MessageDescriptor } from '@lingui/core';
2
2
  import { allLocaleData } from './locales/locales.js';
3
-
3
+ export { translate } from './core/translate';
4
4
  export * from './validValues';
5
5
  export const allSupportedLocales = Object.keys(allLocaleData);
6
-
7
- export function translate(message: MessageDescriptor, locale: string) {
8
- i18n.activate(locale);
9
- return i18n._(message);
10
- }