@unchainedshop/core-assortments 1.1.3

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.
@@ -0,0 +1,7 @@
1
+ This directory and the files immediately inside it are automatically generated
2
+ when you change this package's NPM dependencies. Commit the files in this
3
+ directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
4
+ so that others run the same versions of sub-dependencies.
5
+
6
+ You should NOT check in the node_modules directory that Meteor automatically
7
+ creates; if you are using git, the .gitignore file tells git to ignore it.
@@ -0,0 +1,200 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "dependencies": {
4
+ "@colors/colors": {
5
+ "version": "1.5.0",
6
+ "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
7
+ "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ=="
8
+ },
9
+ "@dabh/diagnostics": {
10
+ "version": "2.0.3",
11
+ "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz",
12
+ "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA=="
13
+ },
14
+ "@unchainedshop/logger": {
15
+ "version": "1.1.0",
16
+ "resolved": "https://registry.npmjs.org/@unchainedshop/logger/-/logger-1.1.0.tgz",
17
+ "integrity": "sha512-PwS2wtlwzRo1RlfRbKQN6cLCz7XEp2dGmVbXCQ1E49O9VvAYNh5mdTg2BNoWYZ1Sl7KWpLkANNYispb+X/Y4jw=="
18
+ },
19
+ "async": {
20
+ "version": "3.2.4",
21
+ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
22
+ "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
23
+ },
24
+ "clone": {
25
+ "version": "2.1.2",
26
+ "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
27
+ "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="
28
+ },
29
+ "color": {
30
+ "version": "3.2.1",
31
+ "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz",
32
+ "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA=="
33
+ },
34
+ "color-convert": {
35
+ "version": "1.9.3",
36
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
37
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg=="
38
+ },
39
+ "color-name": {
40
+ "version": "1.1.3",
41
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
42
+ "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
43
+ },
44
+ "color-string": {
45
+ "version": "1.9.1",
46
+ "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
47
+ "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg=="
48
+ },
49
+ "colorspace": {
50
+ "version": "1.1.4",
51
+ "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz",
52
+ "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w=="
53
+ },
54
+ "enabled": {
55
+ "version": "2.0.0",
56
+ "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz",
57
+ "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ=="
58
+ },
59
+ "fecha": {
60
+ "version": "4.2.3",
61
+ "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
62
+ "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw=="
63
+ },
64
+ "fn.name": {
65
+ "version": "1.1.0",
66
+ "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
67
+ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="
68
+ },
69
+ "inherits": {
70
+ "version": "2.0.4",
71
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
72
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
73
+ },
74
+ "is-arrayish": {
75
+ "version": "0.3.2",
76
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
77
+ "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
78
+ },
79
+ "is-stream": {
80
+ "version": "2.0.1",
81
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
82
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
83
+ },
84
+ "kuler": {
85
+ "version": "2.0.0",
86
+ "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
87
+ "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A=="
88
+ },
89
+ "locale": {
90
+ "version": "0.1.0",
91
+ "resolved": "https://registry.npmjs.org/locale/-/locale-0.1.0.tgz",
92
+ "integrity": "sha512-rY3ZMnUkMfaZEix1fp/pjdwsHJkDQcE0UEcXHuYI77J03K8gddL3iD+UuJCLAmT2Z2oz5A70/0QS4J9OLCCvXw=="
93
+ },
94
+ "lodash._reinterpolate": {
95
+ "version": "3.0.0",
96
+ "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz",
97
+ "integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA=="
98
+ },
99
+ "lodash.template": {
100
+ "version": "4.5.0",
101
+ "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.5.0.tgz",
102
+ "integrity": "sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A=="
103
+ },
104
+ "lodash.templatesettings": {
105
+ "version": "4.2.0",
106
+ "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz",
107
+ "integrity": "sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ=="
108
+ },
109
+ "logform": {
110
+ "version": "2.4.0",
111
+ "resolved": "https://registry.npmjs.org/logform/-/logform-2.4.0.tgz",
112
+ "integrity": "sha512-CPSJw4ftjf517EhXZGGvTHHkYobo7ZCc0kvwUoOYcjfR2UVrI66RHj8MCrfAdEitdmFqbu2BYdYs8FHHZSb6iw=="
113
+ },
114
+ "message-box": {
115
+ "version": "0.2.7",
116
+ "resolved": "https://registry.npmjs.org/message-box/-/message-box-0.2.7.tgz",
117
+ "integrity": "sha512-C4ccA5nHb58kTS+pLrgF/JWtr7fAIkHxRDceH7tdy5fMA783nUfbYwZ7H2XLvSeYfcnWIYCig5dWW+icK9X/Ag=="
118
+ },
119
+ "mongo-object": {
120
+ "version": "0.1.4",
121
+ "resolved": "https://registry.npmjs.org/mongo-object/-/mongo-object-0.1.4.tgz",
122
+ "integrity": "sha512-QtYk0gupWEn2+iB+DDRt1L+WbcNYvJRaHdih/dcqthOa1DbnREUGSs2WGcW478GNYpElflo/yybZXu0sTiRXHg=="
123
+ },
124
+ "ms": {
125
+ "version": "2.1.3",
126
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
127
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
128
+ },
129
+ "one-time": {
130
+ "version": "1.0.0",
131
+ "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz",
132
+ "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g=="
133
+ },
134
+ "ramda": {
135
+ "version": "0.27.1",
136
+ "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
137
+ "integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
138
+ },
139
+ "readable-stream": {
140
+ "version": "3.6.0",
141
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
142
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA=="
143
+ },
144
+ "safe-buffer": {
145
+ "version": "5.2.1",
146
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
147
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
148
+ },
149
+ "safe-stable-stringify": {
150
+ "version": "2.3.1",
151
+ "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz",
152
+ "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg=="
153
+ },
154
+ "simpl-schema": {
155
+ "version": "1.12.0",
156
+ "resolved": "https://registry.npmjs.org/simpl-schema/-/simpl-schema-1.12.0.tgz",
157
+ "integrity": "sha512-lzXC3L8jJbPhNXGR3cjlyIauqqrC5WUJS4O34Ym/wLIvb8K3ZieK+1OfTzs4mBpDc3Y8u53gQFAr1X37DmTcEg=="
158
+ },
159
+ "simple-swizzle": {
160
+ "version": "0.2.2",
161
+ "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
162
+ "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg=="
163
+ },
164
+ "stack-trace": {
165
+ "version": "0.0.10",
166
+ "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
167
+ "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="
168
+ },
169
+ "string_decoder": {
170
+ "version": "1.3.0",
171
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
172
+ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="
173
+ },
174
+ "text-hex": {
175
+ "version": "1.0.0",
176
+ "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
177
+ "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
178
+ },
179
+ "triple-beam": {
180
+ "version": "1.3.0",
181
+ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
182
+ "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
183
+ },
184
+ "util-deprecate": {
185
+ "version": "1.0.2",
186
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
187
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
188
+ },
189
+ "winston": {
190
+ "version": "3.7.2",
191
+ "resolved": "https://registry.npmjs.org/winston/-/winston-3.7.2.tgz",
192
+ "integrity": "sha512-QziIqtojHBoyzUOdQvQiar1DH0Xp9nF1A1y7NVy2DGEsz82SBDtOalS0ulTRGVT14xPX3WRWkCsdcJKqNflKng=="
193
+ },
194
+ "winston-transport": {
195
+ "version": "4.5.0",
196
+ "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.5.0.tgz",
197
+ "integrity": "sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q=="
198
+ }
199
+ }
200
+ }
package/.versions ADDED
@@ -0,0 +1,53 @@
1
+ allow-deny@1.1.1
2
+ babel-compiler@7.9.0
3
+ babel-runtime@1.5.1
4
+ base64@1.0.12
5
+ binary-heap@1.0.11
6
+ boilerplate-generator@1.7.1
7
+ callback-hook@1.4.0
8
+ check@1.3.1
9
+ ddp@1.4.0
10
+ ddp-client@2.5.0
11
+ ddp-common@1.4.0
12
+ ddp-server@2.5.0
13
+ diff-sequence@1.1.1
14
+ dynamic-import@0.7.2
15
+ ecmascript@0.16.2
16
+ ecmascript-runtime@0.8.0
17
+ ecmascript-runtime-client@0.12.1
18
+ ecmascript-runtime-server@0.11.0
19
+ ejson@1.1.2
20
+ fetch@0.1.1
21
+ geojson-utils@1.0.10
22
+ id-map@1.1.1
23
+ inter-process-messaging@0.1.1
24
+ local-test:unchained:core-assortments@1.1.1
25
+ logging@1.3.1
26
+ meteor@1.10.0
27
+ meteortesting:browser-tests@0.1.2
28
+ meteortesting:mocha@0.4.4
29
+ minimongo@1.8.0
30
+ modern-browsers@0.1.8
31
+ modules@0.18.0
32
+ modules-runtime@0.13.0
33
+ mongo@1.15.0
34
+ mongo-decimal@0.1.3
35
+ mongo-dev-server@1.1.0
36
+ mongo-id@1.0.8
37
+ npm-mongo@4.3.1
38
+ ordered-dict@1.1.0
39
+ practicalmeteor:mocha-core@1.0.1
40
+ promise@0.12.0
41
+ random@1.2.0
42
+ react-fast-refresh@0.2.3
43
+ reload@1.3.1
44
+ retry@1.1.0
45
+ routepolicy@1.1.1
46
+ socket-stream-client@0.5.0
47
+ tracker@1.2.0
48
+ typescript@4.5.4
49
+ unchained:core-assortments@1.1.1
50
+ unchained:mongodb@1.0.0
51
+ underscore@1.0.10
52
+ webapp@1.13.1
53
+ webapp-hashing@1.1.0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Assortments (Unchained Engine)
2
+
3
+ This package contains business logic and database abstraction for assortments in Unchained.
package/package.js ADDED
@@ -0,0 +1,36 @@
1
+ Package.describe({
2
+ name: 'unchained:core-assortments',
3
+ version: '1.1.3',
4
+ summary: 'Unchained Engine Core: Assortments',
5
+ git: 'https://github.com/unchainedshop/unchained',
6
+ documentation: 'README.md',
7
+ });
8
+
9
+ Npm.depends({
10
+ locale: '0.1.0',
11
+ ramda: '0.27.1',
12
+ 'simpl-schema': '1.12.0',
13
+ '@unchainedshop/logger': '1.1.3',
14
+ '@unchainedshop/utils': '1.1.3',
15
+ // '@unchainedshop/events': '1.1.4', // PEER!
16
+ // '@unchainedshop/file-upload': '1.1.4', // PEER!
17
+ });
18
+
19
+ Package.onUse((api) => {
20
+ api.versionsFrom('2.7.3');
21
+ api.use('ecmascript');
22
+ api.use('typescript');
23
+
24
+ api.mainModule('src/assortments-index.ts', 'server');
25
+ });
26
+
27
+ Package.onTest((api) => {
28
+ api.use('meteortesting:mocha');
29
+ api.use('ecmascript');
30
+ api.use('typescript');
31
+
32
+ api.use('unchained:mongodb');
33
+ api.use('unchained:core-assortments');
34
+
35
+ api.mainModule('tests/assortments-index.test.ts');
36
+ });
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@unchainedshop/core-assortments",
3
+ "version": "1.1.3",
4
+ "main": "lib/assortments-index.js",
5
+ "types": "lib/assortments-index.d.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc --watch",
10
+ "link:core": "npm link @unchainedshop/types",
11
+ "test": "cross-env METEOR_PACKAGE_DIRS=../ TEST_CLIENT=0 TEST_WATCH=1 meteor test-packages ./ --driver-package meteortesting:mocha --port 4200"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/unchainedshop/unchained.git"
16
+ },
17
+ "keywords": [
18
+ "unchained",
19
+ "ecommerce",
20
+ "core"
21
+ ],
22
+ "author": "Joël Meiller",
23
+ "license": "EUPL-1.2",
24
+ "bugs": {
25
+ "url": "https://github.com/unchainedshop/unchained/issues"
26
+ },
27
+ "homepage": "https://github.com/unchainedshop/unchained#readme",
28
+ "dependencies": {
29
+ "@unchainedshop/events": "latest",
30
+ "@unchainedshop/file-upload": "latest",
31
+ "@unchainedshop/logger": "latest",
32
+ "@unchainedshop/utils": "latest",
33
+ "locale": "^0.1.0",
34
+ "ramda": "^0.28.0",
35
+ "simpl-schema": "^1.12.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/chai": "^4.3.1",
39
+ "@types/locale": "^0.1.1",
40
+ "@types/mocha": "^9.1.1",
41
+ "@unchainedshop/types": "latest",
42
+ "chai": "^4.3.6",
43
+ "cross-env": "^7.0.3",
44
+ "typescript": "^4.7.4"
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ export { configureAssortmentsModule } from './module/configureAssortmentsModule';
2
+
3
+ export { assortmentsSettings } from './assortments-settings';
@@ -0,0 +1,27 @@
1
+ import { AssortmentsSettingsOptions } from '@unchainedshop/types/assortments';
2
+ import { Db } from '@unchainedshop/types/common';
3
+ import { slugify as defaultSlugify } from '@unchainedshop/utils';
4
+ import zipTreeByDeepness from './utils/tree-zipper/zipTreeByDeepness';
5
+ import makeMongoDBCache from './product-cache/mongodb';
6
+
7
+ export const assortmentsSettings = {
8
+ zipTree: null,
9
+ slugify: null,
10
+ setCachedProductIds: null,
11
+ getCachedProductIds: null,
12
+ configureSettings: async (
13
+ {
14
+ setCachedProductIds,
15
+ getCachedProductIds,
16
+ zipTree = zipTreeByDeepness,
17
+ slugify = defaultSlugify,
18
+ }: AssortmentsSettingsOptions,
19
+ db: Db,
20
+ ) => {
21
+ const defaultCache = await makeMongoDBCache(db);
22
+ assortmentsSettings.zipTree = zipTree;
23
+ assortmentsSettings.slugify = slugify;
24
+ assortmentsSettings.setCachedProductIds = setCachedProductIds || defaultCache.setCachedProductIds;
25
+ assortmentsSettings.getCachedProductIds = getCachedProductIds || defaultCache.getCachedProductIds;
26
+ },
27
+ };
@@ -0,0 +1,26 @@
1
+ import { AssortmentMedia, AssortmentMediaText } from '@unchainedshop/types/assortments.media';
2
+ import { Db } from '@unchainedshop/types/common';
3
+ import { buildDbIndexes } from '@unchainedshop/utils';
4
+
5
+ export const AssortmentMediaCollection = async (db: Db) => {
6
+ const AssortmentMedias = db.collection<AssortmentMedia>('assortment_media');
7
+ const AssortmentMediaTexts = db.collection<AssortmentMediaText>('assortment_media_texts');
8
+
9
+ // Assortment Indexes
10
+ await buildDbIndexes(AssortmentMedias, [
11
+ { index: { mediaId: 1 } },
12
+ { index: { assortmentId: 1 } },
13
+ { index: { tags: 1 } },
14
+ ]);
15
+
16
+ // AssortmentTexts indexes
17
+ await buildDbIndexes(AssortmentMediaTexts, [
18
+ { index: { assortmentMediaId: 1 } },
19
+ { index: { locale: 1 } },
20
+ ]);
21
+
22
+ return {
23
+ AssortmentMedias,
24
+ AssortmentMediaTexts,
25
+ };
26
+ };
@@ -0,0 +1,31 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+
4
+ export const AssortmentMediasSchema = new SimpleSchema(
5
+ {
6
+ mediaId: { type: String, required: true },
7
+ assortmentId: { type: String, required: true },
8
+ sortKey: { type: Number, required: true },
9
+ tags: Array,
10
+ 'tags.$': String,
11
+ meta: { type: Object, blackbox: true },
12
+ authorId: { type: String, required: true },
13
+ ...Schemas.timestampFields,
14
+ },
15
+ { requiredByDefault: false },
16
+ );
17
+
18
+ export const AssortmentMediaTextsSchema = new SimpleSchema(
19
+ {
20
+ assortmentMediaId: {
21
+ type: String,
22
+ required: true,
23
+ },
24
+ locale: String,
25
+ authorId: { type: String, required: true },
26
+ title: String,
27
+ subtitle: String,
28
+ ...Schemas.timestampFields,
29
+ },
30
+ { requiredByDefault: false },
31
+ );
@@ -0,0 +1,84 @@
1
+ import { Db } from '@unchainedshop/types/common';
2
+ import { buildDbIndexes } from '@unchainedshop/utils';
3
+ import {
4
+ Assortment,
5
+ AssortmentText,
6
+ AssortmentProduct,
7
+ AssortmentLink,
8
+ AssortmentFilter,
9
+ AssortmentProductIdCacheRecord,
10
+ } from '@unchainedshop/types/assortments';
11
+
12
+ export const AssortmentsCollection = async (db: Db) => {
13
+ const Assortments = db.collection<Assortment>('assortments');
14
+ const AssortmentTexts = db.collection<AssortmentText>('assortment_texts');
15
+ const AssortmentProducts = db.collection<AssortmentProduct>('assortment_products');
16
+ const AssortmentLinks = db.collection<AssortmentLink>('assortment_links');
17
+ const AssortmentFilters = db.collection<AssortmentFilter>('assortment_filters');
18
+ const AssortmentProductIdCache = db.collection<AssortmentProductIdCacheRecord>(
19
+ 'assortment_productId_cache',
20
+ );
21
+
22
+ // Assortment Indexes
23
+ await buildDbIndexes(Assortments, [
24
+ { index: { isActive: 1 } },
25
+ { index: { isRoot: 1 } },
26
+ { index: { sequence: 1 } },
27
+ { index: { slugs: 1 } },
28
+ { index: { tags: 1 } },
29
+ {
30
+ index: { slugs: 'text' },
31
+ options: {
32
+ name: 'assortments_fulltext_search',
33
+ },
34
+ },
35
+ ]);
36
+
37
+ // AssortmentTexts indexes
38
+ await buildDbIndexes(AssortmentTexts, [
39
+ { index: { assortmentId: 1 } },
40
+ { index: { locale: 1 } },
41
+ { index: { slug: 1 } },
42
+ { index: { locale: 1, assortmentId: 1 } },
43
+ {
44
+ index: { title: 'text', subtitle: 'text' },
45
+ options: {
46
+ weights: {
47
+ title: 8,
48
+ subtitle: 6,
49
+ },
50
+ name: 'assortments_texts_fulltext_search',
51
+ },
52
+ },
53
+ ]);
54
+
55
+ // AssortmentProducts indexes
56
+ await buildDbIndexes(AssortmentProducts, [
57
+ { index: { assortmentId: 1 } },
58
+ { index: { productId: 1 } },
59
+ { index: { tags: 1 } },
60
+ ]);
61
+
62
+ // AssortmentLinks indices
63
+ await buildDbIndexes(AssortmentLinks, [
64
+ { index: { parentAssortmentId: 1 } },
65
+ { index: { childAssortmentId: 1 } },
66
+ { index: { tags: 1 } },
67
+ ]);
68
+
69
+ // AssortmentFilter indices
70
+ await buildDbIndexes(AssortmentFilters, [
71
+ { index: { assortmentId: 1 } },
72
+ { index: { filterId: 1 } },
73
+ { index: { tags: 1 } },
74
+ ]);
75
+
76
+ return {
77
+ Assortments,
78
+ AssortmentTexts,
79
+ AssortmentProducts,
80
+ AssortmentLinks,
81
+ AssortmentFilters,
82
+ AssortmentProductIdCache,
83
+ };
84
+ };
@@ -0,0 +1,75 @@
1
+ import { Schemas } from '@unchainedshop/utils';
2
+ import SimpleSchema from 'simpl-schema';
3
+
4
+ export const AssortmentsSchema = new SimpleSchema(
5
+ {
6
+ authorId: { type: String, required: true },
7
+ isActive: Boolean,
8
+ isBase: Boolean,
9
+ isRoot: Boolean,
10
+ meta: { type: Object, blackbox: true },
11
+ sequence: { type: Number, required: true },
12
+ slugs: Array,
13
+ 'slugs.$': String,
14
+ tags: Array,
15
+ 'tags.$': String,
16
+ ...Schemas.timestampFields,
17
+ },
18
+ { requiredByDefault: false },
19
+ );
20
+
21
+ export const AssortmentTextsSchema = new SimpleSchema(
22
+ {
23
+ assortmentId: { type: String, required: true },
24
+ authorId: { type: String, required: true },
25
+ description: String,
26
+ locale: { type: String, required: true },
27
+ slug: String,
28
+ subtitle: String,
29
+ title: String,
30
+ ...Schemas.timestampFields,
31
+ },
32
+ { requiredByDefault: false },
33
+ );
34
+
35
+ export const AssortmentProductsSchema = new SimpleSchema(
36
+ {
37
+ assortmentId: { type: String, required: true },
38
+ authorId: { type: String, required: true },
39
+ meta: { type: Object, blackbox: true },
40
+ productId: { type: String, required: true },
41
+ sortKey: { type: Number, required: true },
42
+ tags: Array,
43
+ 'tags.$': String,
44
+ ...Schemas.timestampFields,
45
+ },
46
+ { requiredByDefault: false },
47
+ );
48
+
49
+ export const AssortmentLinksSchema = new SimpleSchema(
50
+ {
51
+ authorId: { type: String, required: true },
52
+ childAssortmentId: { type: String, required: true },
53
+ meta: { type: Object, blackbox: true },
54
+ parentAssortmentId: { type: String, required: true },
55
+ sortKey: { type: Number, required: true },
56
+ tags: Array,
57
+ 'tags.$': String,
58
+ ...Schemas.timestampFields,
59
+ },
60
+ { requiredByDefault: false },
61
+ );
62
+
63
+ export const AssortmentFiltersSchema = new SimpleSchema(
64
+ {
65
+ assortmentId: { type: String, required: true },
66
+ authorId: { type: String, required: true },
67
+ filterId: { type: String, required: true },
68
+ meta: { type: Object, blackbox: true },
69
+ sortKey: { type: Number, required: true },
70
+ tags: Array,
71
+ 'tags.$': String,
72
+ ...Schemas.timestampFields,
73
+ },
74
+ { requiredByDefault: false },
75
+ );
@@ -0,0 +1,41 @@
1
+ // @ts-nocheck
2
+ import { Migration } from '@unchainedshop/types/api';
3
+ import { MigrationRepository } from '@unchainedshop/types/common';
4
+ import { AssortmentsCollection } from '../db/AssortmentsCollection';
5
+
6
+ export default function addMigrations(repository: MigrationRepository<Migration>) {
7
+ repository?.register({
8
+ id: 20220216000000,
9
+ name: 'Move _cachedProductIds cache to own collection in order to save a lot of bandwidth',
10
+ up: async () => {
11
+ const { Assortments, AssortmentProductIdCache } = await AssortmentsCollection(repository.db);
12
+ const assortments = await Assortments.find(
13
+ {},
14
+ { projection: { _id: true, _cachedProductIds: true } },
15
+ ).toArray();
16
+
17
+ await Promise.all(
18
+ assortments.map(async (assortment) => {
19
+ await AssortmentProductIdCache.updateOne(
20
+ {
21
+ _id: assortment._id as any,
22
+ },
23
+ {
24
+ $set: { productIds: assortment._cachedProductIds }, // eslint-disable-line
25
+ },
26
+ {
27
+ upsert: true,
28
+ },
29
+ );
30
+ }),
31
+ );
32
+
33
+ await Assortments.updateMany(
34
+ {},
35
+ {
36
+ $unset: { _cachedProductIds: 1 },
37
+ },
38
+ );
39
+ },
40
+ });
41
+ }