@vendure/dashboard 3.7.0 → 3.7.1-master-202607040306

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 (33) hide show
  1. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/dev-config.js +251 -0
  2. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/package.json +4 -0
  3. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +23 -0
  4. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/api/api-extensions.js +99 -0
  5. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/api/product-entity.resolver.js +73 -0
  6. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/api/product-review-admin.resolver.js +146 -0
  7. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/api/product-review-entity.resolver.js +79 -0
  8. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/api/product-review-shop.resolver.js +79 -0
  9. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/entities/product-review-translation.entity.js +47 -0
  10. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/entities/product-review.entity.js +90 -0
  11. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/generated-admin-types.js +1021 -0
  12. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/generated-shop-types.js +974 -0
  13. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/reviews-plugin.js +46 -0
  14. package/dist/vite/.vendure-dashboard-temp/compiler/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/test-plugins/reviews/types.js +2 -0
  15. package/dist/vite/.vendure-dashboard-temp/gql-tada/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/schema.graphql +6844 -0
  16. package/dist/vite/.vendure-dashboard-temp/gql-tada/4348-1b2d6052-1f4d-42a1-ac2f-8bc87407758e/tsconfig.json +10 -0
  17. package/package.json +3 -3
  18. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/dev-config.js +0 -0
  19. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/package.json +0 -0
  20. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/nav-modifier-plugin/nav-modifier-plugin.js +0 -0
  21. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/api/api-extensions.js +0 -0
  22. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/api/product-entity.resolver.js +0 -0
  23. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/api/product-review-admin.resolver.js +0 -0
  24. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/api/product-review-entity.resolver.js +0 -0
  25. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/api/product-review-shop.resolver.js +0 -0
  26. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/entities/product-review-translation.entity.js +0 -0
  27. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/entities/product-review.entity.js +0 -0
  28. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/generated-admin-types.js +0 -0
  29. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/generated-shop-types.js +0 -0
  30. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/reviews-plugin.js +0 -0
  31. /package/dist/vite/.vendure-dashboard-temp/compiler/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/test-plugins/reviews/types.js +0 -0
  32. /package/dist/vite/.vendure-dashboard-temp/gql-tada/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/schema.graphql +0 -0
  33. /package/dist/vite/.vendure-dashboard-temp/gql-tada/{3390-1f9204be-301a-46ef-909f-bcf03820d62c → 3325-9731251f-fa22-4b57-a810-45305881da74}/tsconfig.json +0 -0
@@ -0,0 +1,251 @@
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 admin_ui_plugin_1 = require("@vendure/admin-ui-plugin");
18
+ const asset_server_plugin_1 = require("@vendure/asset-server-plugin");
19
+ const shared_constants_1 = require("@vendure/common/lib/shared-constants");
20
+ const core_1 = require("@vendure/core");
21
+ const plugin_1 = require("@vendure/dashboard/plugin");
22
+ const email_plugin_1 = require("@vendure/email-plugin");
23
+ const graphiql_plugin_1 = require("@vendure/graphiql-plugin");
24
+ const telemetry_plugin_1 = require("@vendure/telemetry-plugin");
25
+ require("dotenv/config");
26
+ const path_1 = __importDefault(require("path"));
27
+ const nav_modifier_plugin_1 = require("./test-plugins/nav-modifier-plugin/nav-modifier-plugin");
28
+ // import { FieldTestPlugin } from './test-plugins/field-test/field-test-plugin';
29
+ const reviews_plugin_1 = require("./test-plugins/reviews/reviews-plugin");
30
+ const IS_INSTRUMENTED = process.env.IS_INSTRUMENTED === 'true';
31
+ const dashboardAppDir = path_1.default.basename(__dirname) === 'dist'
32
+ ? path_1.default.join(__dirname, './dashboard')
33
+ : path_1.default.join(__dirname, './dist/dashboard');
34
+ let ReadonlySettingsTestPlugin = class ReadonlySettingsTestPlugin {
35
+ constructor(settingsStoreService, requestContextService) {
36
+ this.settingsStoreService = settingsStoreService;
37
+ this.requestContextService = requestContextService;
38
+ }
39
+ async onApplicationBootstrap() {
40
+ const ctx = await this.requestContextService.create({ apiType: 'admin' });
41
+ await this.settingsStoreService.set(ctx, 'ReadonlyTest.buildVersion', 'v3.5.2');
42
+ await this.settingsStoreService.set(ctx, 'ReadonlyTest.buildMeta', {
43
+ buildDate: '2026-03-06',
44
+ commit: 'd0384f3ed',
45
+ features: ['settings-store-ui', 'option-groups'],
46
+ });
47
+ }
48
+ };
49
+ ReadonlySettingsTestPlugin = __decorate([
50
+ (0, core_1.VendurePlugin)({
51
+ imports: [core_1.PluginCommonModule],
52
+ configuration: config => {
53
+ config.settingsStoreFields = {
54
+ ...config.settingsStoreFields,
55
+ ReadonlyTest: [
56
+ { name: 'buildVersion', readonly: true },
57
+ { name: 'buildMeta', readonly: true },
58
+ ],
59
+ };
60
+ return config;
61
+ },
62
+ }),
63
+ __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])
64
+ ], ReadonlySettingsTestPlugin);
65
+ /**
66
+ * Config settings used during development
67
+ */
68
+ exports.devConfig = {
69
+ apiOptions: {
70
+ port: Number(process.env.API_PORT) || shared_constants_1.API_PORT,
71
+ adminApiPath: shared_constants_1.ADMIN_API_PATH,
72
+ adminApiPlayground: {
73
+ settings: {
74
+ 'request.credentials': 'include',
75
+ },
76
+ },
77
+ adminApiDebug: true,
78
+ shopApiPath: shared_constants_1.SHOP_API_PATH,
79
+ shopApiPlayground: {
80
+ settings: {
81
+ 'request.credentials': 'include',
82
+ },
83
+ },
84
+ shopApiDebug: true,
85
+ },
86
+ authOptions: {
87
+ disableAuth: false,
88
+ tokenMethod: ['bearer', 'cookie', 'api-key'],
89
+ requireVerification: true,
90
+ customPermissions: [],
91
+ cookieOptions: {
92
+ secret: 'abc',
93
+ },
94
+ },
95
+ dbConnectionOptions: {
96
+ synchronize: false,
97
+ logging: false,
98
+ migrations: [path_1.default.join(__dirname, 'migrations/*.ts')],
99
+ ...getDbConfig(),
100
+ },
101
+ paymentOptions: {
102
+ paymentMethodHandlers: [core_1.dummyPaymentHandler],
103
+ },
104
+ settingsStoreFields: {
105
+ MyPlugin: [
106
+ {
107
+ name: 'globalVal',
108
+ },
109
+ {
110
+ name: 'userVal',
111
+ scope: core_1.SettingsStoreScopes.user,
112
+ },
113
+ ],
114
+ },
115
+ customFields: {},
116
+ logger: new core_1.DefaultLogger({ level: core_1.LogLevel.Verbose }),
117
+ importExportOptions: {
118
+ importAssetsDir: path_1.default.join(__dirname, 'import-assets'),
119
+ },
120
+ plugins: [
121
+ // MultivendorPlugin.init({
122
+ // platformFeePercent: 10,
123
+ // platformFeeSKU: 'FEE',
124
+ // }),
125
+ ReadonlySettingsTestPlugin,
126
+ reviews_plugin_1.ReviewsPlugin,
127
+ // FieldTestPlugin,
128
+ nav_modifier_plugin_1.NavModifierPlugin,
129
+ graphiql_plugin_1.GraphiqlPlugin.init(),
130
+ asset_server_plugin_1.AssetServerPlugin.init({
131
+ route: 'assets',
132
+ assetUploadDir: path_1.default.join(__dirname, 'assets'),
133
+ }),
134
+ core_1.DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: false }),
135
+ // Enable if you need to debug the job queue
136
+ // BullMQJobQueuePlugin.init({}),
137
+ core_1.DefaultJobQueuePlugin.init({}),
138
+ // JobQueueTestPlugin.init({ queueCount: 10 }),
139
+ core_1.DefaultSchedulerPlugin.init({}),
140
+ email_plugin_1.EmailPlugin.init({
141
+ devMode: true,
142
+ route: 'mailbox',
143
+ handlers: email_plugin_1.defaultEmailHandlers,
144
+ templateLoader: new email_plugin_1.FileBasedTemplateLoader(path_1.default.join(__dirname, '../email-plugin/templates')),
145
+ outputPath: path_1.default.join(__dirname, 'test-emails'),
146
+ globalTemplateVars: {
147
+ verifyEmailAddressUrl: 'http://localhost:4201/verify',
148
+ passwordResetUrl: 'http://localhost:4201/reset-password',
149
+ changeEmailAddressUrl: 'http://localhost:4201/change-email-address',
150
+ },
151
+ }),
152
+ ...(IS_INSTRUMENTED ? [telemetry_plugin_1.TelemetryPlugin.init({})] : []),
153
+ // AdminUiPlugin.init({
154
+ // route: 'admin',
155
+ // port: 5001,
156
+ // adminUiConfig: {},
157
+ // // Un-comment to compile a custom admin ui
158
+ // // app: compileUiExtensions({
159
+ // // outputPath: path.join(__dirname, './custom-admin-ui'),
160
+ // // extensions: [
161
+ // // {
162
+ // // id: 'ui-extensions-library',
163
+ // // extensionPath: path.join(__dirname, 'example-plugins/ui-extensions-library/ui'),
164
+ // // routes: [{ route: 'ui-library', filePath: 'routes.ts' }],
165
+ // // providers: ['providers.ts'],
166
+ // // },
167
+ // // {
168
+ // // globalStyles: path.join(
169
+ // // __dirname,
170
+ // // 'test-plugins/with-ui-extension/ui/custom-theme.scss',
171
+ // // ),
172
+ // // },
173
+ // // ],
174
+ // // devMode: true,
175
+ // // }),
176
+ // }),
177
+ admin_ui_plugin_1.AdminUiPlugin.init({
178
+ route: 'admin',
179
+ port: 5001,
180
+ adminUiConfig: {},
181
+ // Un-comment to compile a custom admin ui
182
+ // app: compileUiExtensions({
183
+ // outputPath: path.join(__dirname, './custom-admin-ui'),
184
+ // extensions: [
185
+ // {
186
+ // id: 'ui-extensions-library',
187
+ // extensionPath: path.join(__dirname, 'example-plugins/ui-extensions-library/ui'),
188
+ // routes: [{ route: 'ui-library', filePath: 'routes.ts' }],
189
+ // providers: ['providers.ts'],
190
+ // },
191
+ // {
192
+ // globalStyles: path.join(
193
+ // __dirname,
194
+ // 'test-plugins/with-ui-extension/ui/custom-theme.scss',
195
+ // ),
196
+ // },
197
+ // ],
198
+ // devMode: true,
199
+ // }),
200
+ }),
201
+ plugin_1.DashboardPlugin.init({
202
+ route: 'dashboard',
203
+ appDir: dashboardAppDir,
204
+ }),
205
+ ],
206
+ };
207
+ function getDbConfig() {
208
+ const dbType = process.env.DB || 'mysql';
209
+ switch (dbType) {
210
+ case 'postgres':
211
+ console.log('Using postgres connection');
212
+ return {
213
+ synchronize: true,
214
+ type: 'postgres',
215
+ host: process.env.DB_HOST || 'localhost',
216
+ port: Number(process.env.DB_PORT) || 5432,
217
+ username: process.env.DB_USERNAME || 'vendure',
218
+ password: process.env.DB_PASSWORD || 'password',
219
+ database: process.env.DB_NAME || 'vendure-dev',
220
+ schema: process.env.DB_SCHEMA || 'public',
221
+ };
222
+ case 'sqlite':
223
+ console.log('Using sqlite connection');
224
+ return {
225
+ synchronize: true,
226
+ type: 'better-sqlite3',
227
+ database: path_1.default.join(__dirname, 'vendure.sqlite'),
228
+ };
229
+ case 'sqljs':
230
+ console.log('Using sql.js connection');
231
+ return {
232
+ type: 'sqljs',
233
+ autoSave: true,
234
+ database: new Uint8Array([]),
235
+ location: path_1.default.join(__dirname, 'vendure.sqlite'),
236
+ };
237
+ case 'mysql':
238
+ case 'mariadb':
239
+ default:
240
+ console.log('Using mysql connection');
241
+ return {
242
+ synchronize: true,
243
+ type: 'mariadb',
244
+ host: '127.0.0.1',
245
+ port: 3306,
246
+ username: 'vendure',
247
+ password: 'password',
248
+ database: 'vendure-dev',
249
+ };
250
+ }
251
+ }
@@ -0,0 +1,23 @@
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);
@@ -0,0 +1,99 @@
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
+ `;
@@ -0,0 +1,73 @@
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);
@@ -0,0 +1,146 @@
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, _g, _h, _j, _k, _l, _m, _o;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ProductReviewAdminResolver = void 0;
17
+ const graphql_1 = require("@nestjs/graphql");
18
+ const core_1 = require("@vendure/core");
19
+ const product_review_translation_entity_1 = require("../entities/product-review-translation.entity");
20
+ const product_review_entity_1 = require("../entities/product-review.entity");
21
+ const generated_admin_types_1 = require("../generated-admin-types");
22
+ let ProductReviewAdminResolver = class ProductReviewAdminResolver {
23
+ constructor(connection, listQueryBuilder, translatableSaver) {
24
+ this.connection = connection;
25
+ this.listQueryBuilder = listQueryBuilder;
26
+ this.translatableSaver = translatableSaver;
27
+ }
28
+ async productReviews(ctx, args) {
29
+ return this.listQueryBuilder
30
+ .build(product_review_entity_1.ProductReview, args.options || undefined, {
31
+ relations: ['product'],
32
+ ctx,
33
+ })
34
+ .getManyAndCount()
35
+ .then(([items, totalItems]) => ({
36
+ items,
37
+ totalItems,
38
+ }));
39
+ }
40
+ async productReview(ctx, args) {
41
+ const review = await this.connection.getRepository(ctx, product_review_entity_1.ProductReview).findOne({
42
+ where: { id: args.id },
43
+ relations: {
44
+ author: true,
45
+ product: true,
46
+ productVariant: true,
47
+ },
48
+ });
49
+ if (!review) {
50
+ throw new core_1.EntityNotFoundError(product_review_entity_1.ProductReview.name, args.id);
51
+ }
52
+ return (0, core_1.translateDeep)(review, ctx.languageCode);
53
+ }
54
+ async updateProductReview(ctx, { input }) {
55
+ const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, input.id);
56
+ const originalResponse = review.response;
57
+ return this.translatableSaver.update({
58
+ ctx,
59
+ input,
60
+ entityType: product_review_entity_1.ProductReview,
61
+ translationType: product_review_translation_entity_1.ProductReviewTranslation,
62
+ });
63
+ }
64
+ async approveProductReview(ctx, { id }) {
65
+ const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, id, {
66
+ relations: ['product'],
67
+ });
68
+ if (review.state !== 'new') {
69
+ return review;
70
+ }
71
+ const { product } = review;
72
+ const newRating = this.calculateNewReviewAverage(review.rating, product);
73
+ product.customFields.reviewCount++;
74
+ product.customFields.reviewRating = newRating;
75
+ await this.connection.getRepository(ctx, core_1.Product).save(product);
76
+ review.state = 'approved';
77
+ return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
78
+ }
79
+ async rejectProductReview(ctx, { id }) {
80
+ const review = await this.connection.getEntityOrThrow(ctx, product_review_entity_1.ProductReview, id);
81
+ if (review.state !== 'new') {
82
+ return review;
83
+ }
84
+ review.state = 'rejected';
85
+ return this.connection.getRepository(ctx, product_review_entity_1.ProductReview).save(review);
86
+ }
87
+ calculateNewReviewAverage(rating, product) {
88
+ const count = product.customFields.reviewCount;
89
+ const currentRating = product.customFields.reviewRating || 0;
90
+ const newRating = (currentRating * count + rating) / (count + 1);
91
+ return newRating;
92
+ }
93
+ };
94
+ exports.ProductReviewAdminResolver = ProductReviewAdminResolver;
95
+ __decorate([
96
+ (0, graphql_1.Query)(),
97
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog),
98
+ __param(0, (0, core_1.Ctx)()),
99
+ __param(1, (0, graphql_1.Args)()),
100
+ __metadata("design:type", Function),
101
+ __metadata("design:paramtypes", [typeof (_d = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _d : Object, typeof (_e = typeof generated_admin_types_1.QueryProductReviewsArgs !== "undefined" && generated_admin_types_1.QueryProductReviewsArgs) === "function" ? _e : Object]),
102
+ __metadata("design:returntype", Promise)
103
+ ], ProductReviewAdminResolver.prototype, "productReviews", null);
104
+ __decorate([
105
+ (0, graphql_1.Query)(),
106
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog),
107
+ __param(0, (0, core_1.Ctx)()),
108
+ __param(1, (0, graphql_1.Args)()),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [typeof (_f = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _f : Object, typeof (_g = typeof generated_admin_types_1.QueryProductReviewArgs !== "undefined" && generated_admin_types_1.QueryProductReviewArgs) === "function" ? _g : Object]),
111
+ __metadata("design:returntype", Promise)
112
+ ], ProductReviewAdminResolver.prototype, "productReview", null);
113
+ __decorate([
114
+ (0, core_1.Transaction)(),
115
+ (0, graphql_1.Mutation)(),
116
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog),
117
+ __param(0, (0, core_1.Ctx)()),
118
+ __param(1, (0, graphql_1.Args)()),
119
+ __metadata("design:type", Function),
120
+ __metadata("design:paramtypes", [typeof (_h = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _h : Object, typeof (_j = typeof generated_admin_types_1.MutationUpdateProductReviewArgs !== "undefined" && generated_admin_types_1.MutationUpdateProductReviewArgs) === "function" ? _j : Object]),
121
+ __metadata("design:returntype", Promise)
122
+ ], ProductReviewAdminResolver.prototype, "updateProductReview", null);
123
+ __decorate([
124
+ (0, core_1.Transaction)(),
125
+ (0, graphql_1.Mutation)(),
126
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog),
127
+ __param(0, (0, core_1.Ctx)()),
128
+ __param(1, (0, graphql_1.Args)()),
129
+ __metadata("design:type", Function),
130
+ __metadata("design:paramtypes", [typeof (_k = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _k : Object, typeof (_l = typeof generated_admin_types_1.MutationApproveProductReviewArgs !== "undefined" && generated_admin_types_1.MutationApproveProductReviewArgs) === "function" ? _l : Object]),
131
+ __metadata("design:returntype", Promise)
132
+ ], ProductReviewAdminResolver.prototype, "approveProductReview", null);
133
+ __decorate([
134
+ (0, core_1.Transaction)(),
135
+ (0, graphql_1.Mutation)(),
136
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog),
137
+ __param(0, (0, core_1.Ctx)()),
138
+ __param(1, (0, graphql_1.Args)()),
139
+ __metadata("design:type", Function),
140
+ __metadata("design:paramtypes", [typeof (_m = typeof core_1.RequestContext !== "undefined" && core_1.RequestContext) === "function" ? _m : Object, typeof (_o = typeof generated_admin_types_1.MutationRejectProductReviewArgs !== "undefined" && generated_admin_types_1.MutationRejectProductReviewArgs) === "function" ? _o : Object]),
141
+ __metadata("design:returntype", Promise)
142
+ ], ProductReviewAdminResolver.prototype, "rejectProductReview", null);
143
+ exports.ProductReviewAdminResolver = ProductReviewAdminResolver = __decorate([
144
+ (0, graphql_1.Resolver)(),
145
+ __metadata("design:paramtypes", [typeof (_a = typeof core_1.TransactionalConnection !== "undefined" && core_1.TransactionalConnection) === "function" ? _a : Object, typeof (_b = typeof core_1.ListQueryBuilder !== "undefined" && core_1.ListQueryBuilder) === "function" ? _b : Object, typeof (_c = typeof core_1.TranslatableSaver !== "undefined" && core_1.TranslatableSaver) === "function" ? _c : Object])
146
+ ], ProductReviewAdminResolver);