@vendure/dashboard 3.7.2-master-202607290305 → 3.7.2-master-202607300304

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 (37) hide show
  1. package/dist/vite/utils/temp-compilation-dir.d.ts +27 -0
  2. package/dist/vite/utils/temp-compilation-dir.js +30 -0
  3. package/dist/vite/vite-plugin-vendure-dashboard.d.ts +11 -0
  4. package/dist/vite/vite-plugin-vendure-dashboard.js +2 -1
  5. package/package.json +3 -3
  6. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/dev-config.js +0 -208
  7. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/package.json +0 -4
  8. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +0 -23
  9. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/api/api-extensions.js +0 -99
  10. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/api/product-entity.resolver.js +0 -73
  11. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/api/product-review-admin.resolver.js +0 -146
  12. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/api/product-review-entity.resolver.js +0 -79
  13. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/api/product-review-shop.resolver.js +0 -79
  14. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/entities/product-review-translation.entity.js +0 -47
  15. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/entities/product-review.entity.js +0 -90
  16. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/generated-admin-types.js +0 -1021
  17. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/generated-shop-types.js +0 -974
  18. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/reviews-plugin.js +0 -46
  19. package/dist/vite/.vendure-dashboard-temp/compiler/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/test-plugins/reviews/types.js +0 -2
  20. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/dev-config.js +0 -208
  21. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/package.json +0 -4
  22. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +0 -23
  23. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/api/api-extensions.js +0 -99
  24. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/api/product-entity.resolver.js +0 -73
  25. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/api/product-review-admin.resolver.js +0 -146
  26. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/api/product-review-entity.resolver.js +0 -79
  27. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/api/product-review-shop.resolver.js +0 -79
  28. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/entities/product-review-translation.entity.js +0 -47
  29. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/entities/product-review.entity.js +0 -90
  30. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/generated-admin-types.js +0 -1021
  31. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/generated-shop-types.js +0 -974
  32. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/reviews-plugin.js +0 -46
  33. package/dist/vite/.vendure-dashboard-temp/compiler/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/test-plugins/reviews/types.js +0 -2
  34. package/dist/vite/.vendure-dashboard-temp/gql-tada/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/schema.graphql +0 -6813
  35. package/dist/vite/.vendure-dashboard-temp/gql-tada/3457-c441dc41-079f-40f2-8c7a-20f03bf94186/tsconfig.json +0 -10
  36. package/dist/vite/.vendure-dashboard-temp/gql-tada/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/schema.graphql +0 -6813
  37. package/dist/vite/.vendure-dashboard-temp/gql-tada/4417-08b9f5a0-ae27-4f76-b09f-53852e4d41f2/tsconfig.json +0 -10
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Name of the directory (under the consuming project's `node_modules/.cache`)
3
+ * into which the VendureConfig is compiled for introspection during the
4
+ * dashboard build.
5
+ */
6
+ export declare const TEMP_COMPILATION_DIR_NAME = "vendure-dashboard-temp";
7
+ /**
8
+ * Resolves the default directory into which the VendureConfig is transpiled (to
9
+ * CommonJS) and dynamically imported during the dashboard build.
10
+ *
11
+ * This deliberately does NOT live inside the `@vendure/dashboard` package.
12
+ * When the config contains a local import from above its own directory (e.g.
13
+ * `import { x } from '../shared/util.js'`), the compiler emits the resolved
14
+ * file one level above `outputPath`, escaping the compiler-written
15
+ * `{"type":"commonjs"}` guard. Node then resolves the emitted `.js` against
16
+ * the nearest `package.json` — which, inside `@vendure/dashboard`, declares
17
+ * `"type": "module"` — and loading throws
18
+ * `ReferenceError: exports is not defined in ES module scope`. See
19
+ * https://github.com/vendurehq/vendure/issues/4979.
20
+ *
21
+ * Placing the output under the consuming project's `node_modules/.cache` keeps
22
+ * module resolution intact (the compiled config can still resolve
23
+ * `@vendure/core` and friends) while ensuring it is not inside a `type: module`
24
+ * package. The location can still be overridden via the `tempCompilationDir`
25
+ * plugin option.
26
+ */
27
+ export declare function getDefaultTempCompilationDir(cwd?: string): string;
@@ -0,0 +1,30 @@
1
+ import path from 'node:path';
2
+ /**
3
+ * Name of the directory (under the consuming project's `node_modules/.cache`)
4
+ * into which the VendureConfig is compiled for introspection during the
5
+ * dashboard build.
6
+ */
7
+ export const TEMP_COMPILATION_DIR_NAME = 'vendure-dashboard-temp';
8
+ /**
9
+ * Resolves the default directory into which the VendureConfig is transpiled (to
10
+ * CommonJS) and dynamically imported during the dashboard build.
11
+ *
12
+ * This deliberately does NOT live inside the `@vendure/dashboard` package.
13
+ * When the config contains a local import from above its own directory (e.g.
14
+ * `import { x } from '../shared/util.js'`), the compiler emits the resolved
15
+ * file one level above `outputPath`, escaping the compiler-written
16
+ * `{"type":"commonjs"}` guard. Node then resolves the emitted `.js` against
17
+ * the nearest `package.json` — which, inside `@vendure/dashboard`, declares
18
+ * `"type": "module"` — and loading throws
19
+ * `ReferenceError: exports is not defined in ES module scope`. See
20
+ * https://github.com/vendurehq/vendure/issues/4979.
21
+ *
22
+ * Placing the output under the consuming project's `node_modules/.cache` keeps
23
+ * module resolution intact (the compiled config can still resolve
24
+ * `@vendure/core` and friends) while ensuring it is not inside a `type: module`
25
+ * package. The location can still be overridden via the `tempCompilationDir`
26
+ * plugin option.
27
+ */
28
+ export function getDefaultTempCompilationDir(cwd = process.cwd()) {
29
+ return path.join(cwd, 'node_modules', '.cache', TEMP_COMPILATION_DIR_NAME);
30
+ }
@@ -70,6 +70,17 @@ export type VitePluginVendureDashboardOptions = {
70
70
  * The path to the directory where the generated GraphQL Tada files will be output.
71
71
  */
72
72
  gqlOutputPath?: string;
73
+ /**
74
+ * @description
75
+ * The directory into which the VendureConfig is transpiled and loaded in order
76
+ * to introspect the configuration during the dashboard build.
77
+ *
78
+ * Defaults to `<project>/node_modules/.cache/vendure-dashboard-temp`. It must
79
+ * not be located inside a `"type": "module"` package (such as
80
+ * `@vendure/dashboard` itself), because the config is compiled to CommonJS and
81
+ * Node would then load it as ESM, failing with
82
+ * `exports is not defined in ES module scope`.
83
+ */
73
84
  tempCompilationDir?: string;
74
85
  /**
75
86
  * @description
@@ -6,6 +6,7 @@ import { randomUUID } from 'node:crypto';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import path from 'path';
8
8
  import { buildTanstackRouterPluginConfig, } from './utils/tanstack-router-config.js';
9
+ import { getDefaultTempCompilationDir } from './utils/temp-compilation-dir.js';
9
10
  import { adminApiSchemaPlugin } from './vite-plugin-admin-api-schema.js';
10
11
  import { bundleEntryPlugin } from './vite-plugin-bundle-entry.js';
11
12
  import { configLoaderPlugin } from './vite-plugin-config-loader.js';
@@ -34,7 +35,7 @@ import { uiConfigPlugin } from './vite-plugin-ui-config.js';
34
35
  */
35
36
  export function vendureDashboardPlugin(options) {
36
37
  var _a, _b;
37
- const tempDir = (_a = options.tempCompilationDir) !== null && _a !== void 0 ? _a : path.join(import.meta.dirname, './.vendure-dashboard-temp');
38
+ const tempDir = (_a = options.tempCompilationDir) !== null && _a !== void 0 ? _a : getDefaultTempCompilationDir();
38
39
  const tempInstanceId = `${process.pid}-${randomUUID()}`;
39
40
  const compilationTempDir = path.join(tempDir, 'compiler', tempInstanceId);
40
41
  const gqlTadaTempDir = path.join(tempDir, 'gql-tada', tempInstanceId);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vendure/dashboard",
3
3
  "private": false,
4
- "version": "3.7.2-master-202607290305",
4
+ "version": "3.7.2-master-202607300304",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -139,8 +139,8 @@
139
139
  "@storybook/addon-vitest": "^10.3.1",
140
140
  "@storybook/react-vite": "^10.3.1",
141
141
  "@types/node": "^22.19.0",
142
- "@vendure/common": "^3.7.2-master-202607290305",
143
- "@vendure/core": "^3.7.2-master-202607290305",
142
+ "@vendure/common": "^3.7.2-master-202607300304",
143
+ "@vendure/core": "^3.7.2-master-202607300304",
144
144
  "@vitest/browser": "^3.2.4",
145
145
  "@vitest/coverage-v8": "^3.2.4",
146
146
  "eslint": "^9.39.0",
@@ -1,208 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- var _a, _b;
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.devConfig = void 0;
17
- const asset_server_plugin_1 = require("@vendure/asset-server-plugin");
18
- const shared_constants_1 = require("@vendure/common/lib/shared-constants");
19
- const core_1 = require("@vendure/core");
20
- const plugin_1 = require("@vendure/dashboard/plugin");
21
- const email_plugin_1 = require("@vendure/email-plugin");
22
- require("dotenv/config");
23
- const node_module_1 = require("node:module");
24
- const path_1 = __importDefault(require("path"));
25
- const nav_modifier_plugin_1 = require("./test-plugins/nav-modifier-plugin/nav-modifier-plugin");
26
- // import { FieldTestPlugin } from './test-plugins/field-test/field-test-plugin';
27
- const reviews_plugin_1 = require("./test-plugins/reviews/reviews-plugin");
28
- const IS_INSTRUMENTED = process.env.IS_INSTRUMENTED === 'true';
29
- const SERVE_GRAPHIQL = process.env.VENDURE_SERVE_GRAPHIQL !== 'false';
30
- const SERVE_STATIC_DASHBOARD = process.env.VENDURE_SERVE_STATIC_DASHBOARD !== 'false';
31
- const loadPackage = (0, node_module_1.createRequire)(__filename);
32
- const dashboardUrl = process.env.VENDURE_DASHBOARD_URL || 'http://localhost:3000/dashboard';
33
- const dashboardAppDir = path_1.default.basename(__dirname) === 'dist'
34
- ? path_1.default.join(__dirname, './dashboard')
35
- : path_1.default.join(__dirname, './dist/dashboard');
36
- let ReadonlySettingsTestPlugin = class ReadonlySettingsTestPlugin {
37
- constructor(settingsStoreService, requestContextService) {
38
- this.settingsStoreService = settingsStoreService;
39
- this.requestContextService = requestContextService;
40
- }
41
- async onApplicationBootstrap() {
42
- const ctx = await this.requestContextService.create({ apiType: 'admin' });
43
- await this.settingsStoreService.set(ctx, 'ReadonlyTest.buildVersion', 'v3.5.2');
44
- await this.settingsStoreService.set(ctx, 'ReadonlyTest.buildMeta', {
45
- buildDate: '2026-03-06',
46
- commit: 'd0384f3ed',
47
- features: ['settings-store-ui', 'option-groups'],
48
- });
49
- }
50
- };
51
- ReadonlySettingsTestPlugin = __decorate([
52
- (0, core_1.VendurePlugin)({
53
- imports: [core_1.PluginCommonModule],
54
- configuration: config => {
55
- config.settingsStoreFields = {
56
- ...config.settingsStoreFields,
57
- ReadonlyTest: [
58
- { name: 'buildVersion', readonly: true },
59
- { name: 'buildMeta', readonly: true },
60
- ],
61
- };
62
- return config;
63
- },
64
- }),
65
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.SettingsStoreService !== "undefined" && core_1.SettingsStoreService) === "function" ? _a : Object, typeof (_b = typeof core_1.RequestContextService !== "undefined" && core_1.RequestContextService) === "function" ? _b : Object])
66
- ], ReadonlySettingsTestPlugin);
67
- /**
68
- * Config settings used during development
69
- */
70
- exports.devConfig = {
71
- apiOptions: {
72
- port: Number(process.env.PORT) || Number(process.env.API_PORT) || shared_constants_1.API_PORT,
73
- trustProxy: process.env.VENDURE_TRUST_PROXY === 'true',
74
- adminApiPath: shared_constants_1.ADMIN_API_PATH,
75
- adminApiPlayground: {
76
- settings: {
77
- 'request.credentials': 'include',
78
- },
79
- },
80
- adminApiDebug: true,
81
- shopApiPath: shared_constants_1.SHOP_API_PATH,
82
- shopApiPlayground: {
83
- settings: {
84
- 'request.credentials': 'include',
85
- },
86
- },
87
- shopApiDebug: true,
88
- },
89
- authOptions: {
90
- disableAuth: false,
91
- tokenMethod: ['bearer', 'cookie', 'api-key'],
92
- requireVerification: true,
93
- customPermissions: [],
94
- cookieOptions: {
95
- secret: 'abc',
96
- },
97
- },
98
- dbConnectionOptions: {
99
- synchronize: false,
100
- logging: false,
101
- migrations: [path_1.default.join(__dirname, 'migrations/*.ts')],
102
- ...getDbConfig(),
103
- },
104
- paymentOptions: {
105
- paymentMethodHandlers: [core_1.dummyPaymentHandler],
106
- },
107
- settingsStoreFields: {
108
- MyPlugin: [
109
- {
110
- name: 'globalVal',
111
- },
112
- {
113
- name: 'userVal',
114
- scope: core_1.SettingsStoreScopes.user,
115
- },
116
- ],
117
- },
118
- customFields: {},
119
- logger: new core_1.DefaultLogger({ level: core_1.LogLevel.Verbose }),
120
- importExportOptions: {
121
- importAssetsDir: path_1.default.join(__dirname, 'import-assets'),
122
- },
123
- plugins: [
124
- // MultivendorPlugin.init({
125
- // platformFeePercent: 10,
126
- // platformFeeSKU: 'FEE',
127
- // }),
128
- ReadonlySettingsTestPlugin,
129
- reviews_plugin_1.ReviewsPlugin,
130
- // FieldTestPlugin,
131
- nav_modifier_plugin_1.NavModifierPlugin,
132
- ...(SERVE_GRAPHIQL ? [loadPackage('@vendure/graphiql-plugin').GraphiqlPlugin.init()] : []),
133
- asset_server_plugin_1.AssetServerPlugin.init({
134
- route: 'assets',
135
- assetUploadDir: path_1.default.join(__dirname, 'assets'),
136
- }),
137
- core_1.DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: false }),
138
- // Enable if you need to debug the job queue
139
- // BullMQJobQueuePlugin.init({}),
140
- core_1.DefaultJobQueuePlugin.init({}),
141
- // JobQueueTestPlugin.init({ queueCount: 10 }),
142
- core_1.DefaultSchedulerPlugin.init({}),
143
- email_plugin_1.EmailPlugin.init({
144
- devMode: true,
145
- route: 'mailbox',
146
- handlers: email_plugin_1.defaultEmailHandlers,
147
- templateLoader: new email_plugin_1.FileBasedTemplateLoader(path_1.default.join(__dirname, '../email-plugin/templates')),
148
- outputPath: path_1.default.join(__dirname, 'test-emails'),
149
- globalTemplateVars: {
150
- verifyEmailAddressUrl: `${dashboardUrl}/verify`,
151
- passwordResetUrl: `${dashboardUrl}/reset-password`,
152
- changeEmailAddressUrl: `${dashboardUrl}/change-email-address`,
153
- },
154
- }),
155
- ...(IS_INSTRUMENTED ? [loadPackage('@vendure/telemetry-plugin').TelemetryPlugin.init({})] : []),
156
- SERVE_STATIC_DASHBOARD
157
- ? plugin_1.DashboardPlugin.init({
158
- route: 'dashboard',
159
- appDir: dashboardAppDir,
160
- })
161
- : plugin_1.DashboardPlugin,
162
- ],
163
- };
164
- function getDbConfig() {
165
- const dbType = process.env.DB || 'mysql';
166
- switch (dbType) {
167
- case 'postgres':
168
- console.log('Using postgres connection');
169
- return {
170
- synchronize: true,
171
- type: 'postgres',
172
- host: process.env.DB_HOST || 'localhost',
173
- port: Number(process.env.DB_PORT) || 5432,
174
- username: process.env.DB_USERNAME || 'vendure',
175
- password: process.env.DB_PASSWORD || 'password',
176
- database: process.env.DB_NAME || 'vendure-dev',
177
- schema: process.env.DB_SCHEMA || 'public',
178
- };
179
- case 'sqlite':
180
- console.log('Using sqlite connection');
181
- return {
182
- synchronize: true,
183
- type: 'better-sqlite3',
184
- database: path_1.default.join(__dirname, 'vendure.sqlite'),
185
- };
186
- case 'sqljs':
187
- console.log('Using sql.js connection');
188
- return {
189
- type: 'sqljs',
190
- autoSave: true,
191
- database: new Uint8Array([]),
192
- location: path_1.default.join(__dirname, 'vendure.sqlite'),
193
- };
194
- case 'mysql':
195
- case 'mariadb':
196
- default:
197
- console.log('Using mysql connection');
198
- return {
199
- synchronize: true,
200
- type: 'mariadb',
201
- host: '127.0.0.1',
202
- port: 3306,
203
- username: 'vendure',
204
- password: 'password',
205
- database: 'vendure-dev',
206
- };
207
- }
208
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.NavModifierPlugin = void 0;
10
- const core_1 = require("@vendure/core");
11
- /**
12
- * A minimal test plugin that demonstrates the function form of `navSections`
13
- * in `defineDashboardExtension`. It moves the "Administrators" and "Roles"
14
- * items out of the "Settings" section into a new "Access & Identity" section.
15
- */
16
- let NavModifierPlugin = class NavModifierPlugin {
17
- };
18
- exports.NavModifierPlugin = NavModifierPlugin;
19
- exports.NavModifierPlugin = NavModifierPlugin = __decorate([
20
- (0, core_1.VendurePlugin)({
21
- dashboard: './dashboard/index.tsx',
22
- })
23
- ], NavModifierPlugin);
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shopApiExtensions = exports.adminApiExtensions = exports.commonApiExtensions = void 0;
4
- const graphql_tag_1 = require("graphql-tag");
5
- exports.commonApiExtensions = (0, graphql_tag_1.gql) `
6
- type ProductReviewTranslation {
7
- id: ID!
8
- languageCode: LanguageCode!
9
- text: String!
10
- }
11
-
12
- type ProductReview implements Node {
13
- id: ID!
14
- createdAt: DateTime!
15
- updatedAt: DateTime!
16
- product: Product!
17
- productVariant: ProductVariant
18
- summary: String!
19
- body: String
20
- rating: Float!
21
- authorName: String!
22
- authorLocation: String
23
- upvotes: Int!
24
- downvotes: Int!
25
- state: String!
26
- response: String
27
- responseCreatedAt: DateTime
28
- translations: [ProductReviewTranslation!]!
29
- }
30
-
31
- type ProductReviewList implements PaginatedList {
32
- items: [ProductReview!]!
33
- totalItems: Int!
34
- }
35
-
36
- type ProductReviewHistogramItem {
37
- bin: Int!
38
- frequency: Int!
39
- }
40
-
41
- extend type Product {
42
- reviews(options: ProductReviewListOptions): ProductReviewList!
43
- reviewsHistogram: [ProductReviewHistogramItem!]!
44
- }
45
-
46
- # Auto-generated at runtime
47
- input ProductReviewListOptions
48
- `;
49
- exports.adminApiExtensions = (0, graphql_tag_1.gql) `
50
- ${exports.commonApiExtensions}
51
-
52
- input ProductReviewTranslationInput {
53
- languageCode: LanguageCode!
54
- text: String!
55
- }
56
-
57
- input UpdateProductReviewInput {
58
- id: ID!
59
- summary: String
60
- body: String
61
- response: String
62
- state: String
63
- translations: [ProductReviewTranslationInput!]!
64
- }
65
-
66
- extend type ProductReview {
67
- author: Customer
68
- }
69
-
70
- extend type Query {
71
- productReviews(options: ProductReviewListOptions): ProductReviewList!
72
- productReview(id: ID!): ProductReview
73
- }
74
-
75
- extend type Mutation {
76
- updateProductReview(input: UpdateProductReviewInput!): ProductReview!
77
- approveProductReview(id: ID!): ProductReview
78
- rejectProductReview(id: ID!): ProductReview
79
- }
80
- `;
81
- exports.shopApiExtensions = (0, graphql_tag_1.gql) `
82
- ${exports.commonApiExtensions}
83
-
84
- input SubmitProductReviewInput {
85
- productId: ID!
86
- variantId: ID
87
- customerId: ID
88
- summary: String!
89
- body: String!
90
- rating: Float!
91
- authorName: String!
92
- authorLocation: String
93
- }
94
-
95
- extend type Mutation {
96
- submitProductReview(input: SubmitProductReviewInput!): ProductReview!
97
- voteOnReview(id: ID!, vote: Boolean!): ProductReview!
98
- }
99
- `;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var _a, _b, _c, _d, _e, _f;
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ProductEntityResolver = void 0;
17
- const graphql_1 = require("@nestjs/graphql");
18
- const core_1 = require("@vendure/core");
19
- const product_review_entity_1 = require("../entities/product-review.entity");
20
- const generated_shop_types_1 = require("../generated-shop-types");
21
- let ProductEntityResolver = class ProductEntityResolver {
22
- constructor(listQueryBuilder, connection) {
23
- this.listQueryBuilder = listQueryBuilder;
24
- this.connection = connection;
25
- }
26
- reviews(apiType, product, args) {
27
- return this.listQueryBuilder
28
- .build(product_review_entity_1.ProductReview, args.options || undefined, {
29
- where: {
30
- product: { id: product.id },
31
- ...(apiType === 'shop' ? { state: 'approved' } : {}),
32
- },
33
- relations: ['product', 'product.featuredAsset'],
34
- })
35
- .getManyAndCount()
36
- .then(([items, totalItems]) => ({
37
- items,
38
- totalItems,
39
- }));
40
- }
41
- reviewsHistogram(product) {
42
- return this.connection.rawConnection
43
- .createQueryBuilder()
44
- .select('ROUND(`rating`)', 'bin')
45
- .addSelect('COUNT(*)', 'frequency')
46
- .from(product_review_entity_1.ProductReview, 'review')
47
- .where('review.product = :productId', { productId: product.id })
48
- .andWhere('review.state = :state', { state: 'approved' })
49
- .groupBy('ROUND(`rating`)')
50
- .getRawMany();
51
- }
52
- };
53
- exports.ProductEntityResolver = ProductEntityResolver;
54
- __decorate([
55
- (0, graphql_1.ResolveField)(),
56
- __param(0, (0, core_1.Api)()),
57
- __param(1, (0, graphql_1.Parent)()),
58
- __param(2, (0, graphql_1.Args)()),
59
- __metadata("design:type", Function),
60
- __metadata("design:paramtypes", [typeof (_c = typeof core_1.ApiType !== "undefined" && core_1.ApiType) === "function" ? _c : Object, typeof (_d = typeof core_1.Product !== "undefined" && core_1.Product) === "function" ? _d : Object, typeof (_e = typeof generated_shop_types_1.ProductReviewsArgs !== "undefined" && generated_shop_types_1.ProductReviewsArgs) === "function" ? _e : Object]),
61
- __metadata("design:returntype", void 0)
62
- ], ProductEntityResolver.prototype, "reviews", null);
63
- __decorate([
64
- (0, graphql_1.ResolveField)(),
65
- __param(0, (0, graphql_1.Parent)()),
66
- __metadata("design:type", Function),
67
- __metadata("design:paramtypes", [typeof (_f = typeof core_1.Product !== "undefined" && core_1.Product) === "function" ? _f : Object]),
68
- __metadata("design:returntype", void 0)
69
- ], ProductEntityResolver.prototype, "reviewsHistogram", null);
70
- exports.ProductEntityResolver = ProductEntityResolver = __decorate([
71
- (0, graphql_1.Resolver)('Product'),
72
- __metadata("design:paramtypes", [typeof (_a = typeof core_1.ListQueryBuilder !== "undefined" && core_1.ListQueryBuilder) === "function" ? _a : Object, typeof (_b = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _b : Object])
73
- ], ProductEntityResolver);