@vendure/cli 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +42 -42
- package/dist/cli.js +9 -9
- package/dist/commands/add/api-extension/templates/api-extensions.template.ts +3 -3
- package/dist/commands/add/api-extension/templates/crud-resolver.template.ts +109 -109
- package/dist/commands/add/api-extension/templates/simple-resolver.template.ts +31 -31
- package/dist/commands/add/codegen/add-codegen.js +6 -6
- package/dist/commands/add/codegen/templates/codegen.template.ts +17 -17
- package/dist/commands/add/entity/templates/entity-translation.template.ts +29 -29
- package/dist/commands/add/entity/templates/entity.template.ts +31 -31
- package/dist/commands/add/job-queue/add-job-queue.js +36 -36
- package/dist/commands/add/plugin/templates/constants.template.ts +2 -2
- package/dist/commands/add/plugin/templates/plugin.template.ts +25 -25
- package/dist/commands/add/plugin/templates/types.template.ts +7 -7
- package/dist/commands/add/service/add-service.js +21 -21
- package/dist/commands/add/service/templates/basic-service.template.ts +13 -13
- package/dist/commands/add/service/templates/entity-service.template.ts +146 -146
- package/dist/commands/add/ui-extensions/codemods/add-ui-extension-static-prop/add-ui-extension-static-prop.js +5 -5
- package/dist/commands/add/ui-extensions/codemods/update-admin-ui-plugin-init/update-admin-ui-plugin-init.js +6 -6
- package/dist/commands/add/ui-extensions/templates/providers.template.ts +3 -3
- package/dist/commands/add/ui-extensions/templates/routes.template.ts +3 -3
- package/dist/shared/vendure-plugin-ref.js +3 -3
- package/package.json +5 -5
package/LICENSE.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# License
|
|
2
|
-
Copyright (C) Vendure GmbH
|
|
3
|
-
|
|
4
|
-
This software is available under two different licenses:
|
|
5
|
-
* GNU General Public License version 3 (GPLv3) as Vendure Community Edition
|
|
6
|
-
* Vendure Commercial License (VCL)
|
|
7
|
-
|
|
8
|
-
The default Vendure license, without a valid Vendure Commercial License agreement, is the Open-Source GPLv3 license.
|
|
9
|
-
|
|
10
|
-
## GNU General Public License version 3 (GPLv3)
|
|
11
|
-
|
|
12
|
-
If you decide to choose the GPLv3 license, you must comply with the following terms:
|
|
13
|
-
|
|
14
|
-
This program is free software: you can redistribute it and/or modify
|
|
15
|
-
it under the terms of the GNU General Public License as published by
|
|
16
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
17
|
-
(at your option) any later version.
|
|
18
|
-
|
|
19
|
-
This program is distributed in the hope that it will be useful,
|
|
20
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
-
GNU General Public License for more details.
|
|
23
|
-
|
|
24
|
-
You should have received a copy of the GNU General Public License
|
|
25
|
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
26
|
-
|
|
27
|
-
Additional permission under GNU GPL version 3 section 7:
|
|
28
|
-
|
|
29
|
-
An additional exception under section 7 of the GPL is included in the plugin-exception.txt file,
|
|
30
|
-
which allows you to distribute Vendure plugins (i.e. extensions) under a different license.
|
|
31
|
-
|
|
32
|
-
## Vendure Commercial License (VCL)
|
|
33
|
-
|
|
34
|
-
Alternatively, commercial and supported versions of the program - also known as
|
|
35
|
-
Commercial Distributions - must be used in accordance with the terms and conditions
|
|
36
|
-
contained in a separate written agreement between you and Vendure GmbH.
|
|
37
|
-
For more information about the Vendure Commercial License (VCL) please contact contact@vendure.io.
|
|
38
|
-
|
|
39
|
-
Please see also:
|
|
40
|
-
|
|
41
|
-
- [Licensing FAQ - license-faq.md](license/license-faq.md)
|
|
42
|
-
- [GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - gpl-3.0.txt](license/gpl-3.0.txt)
|
|
1
|
+
# License
|
|
2
|
+
Copyright (C) Vendure GmbH
|
|
3
|
+
|
|
4
|
+
This software is available under two different licenses:
|
|
5
|
+
* GNU General Public License version 3 (GPLv3) as Vendure Community Edition
|
|
6
|
+
* Vendure Commercial License (VCL)
|
|
7
|
+
|
|
8
|
+
The default Vendure license, without a valid Vendure Commercial License agreement, is the Open-Source GPLv3 license.
|
|
9
|
+
|
|
10
|
+
## GNU General Public License version 3 (GPLv3)
|
|
11
|
+
|
|
12
|
+
If you decide to choose the GPLv3 license, you must comply with the following terms:
|
|
13
|
+
|
|
14
|
+
This program is free software: you can redistribute it and/or modify
|
|
15
|
+
it under the terms of the GNU General Public License as published by
|
|
16
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
17
|
+
(at your option) any later version.
|
|
18
|
+
|
|
19
|
+
This program is distributed in the hope that it will be useful,
|
|
20
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
+
GNU General Public License for more details.
|
|
23
|
+
|
|
24
|
+
You should have received a copy of the GNU General Public License
|
|
25
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
26
|
+
|
|
27
|
+
Additional permission under GNU GPL version 3 section 7:
|
|
28
|
+
|
|
29
|
+
An additional exception under section 7 of the GPL is included in the plugin-exception.txt file,
|
|
30
|
+
which allows you to distribute Vendure plugins (i.e. extensions) under a different license.
|
|
31
|
+
|
|
32
|
+
## Vendure Commercial License (VCL)
|
|
33
|
+
|
|
34
|
+
Alternatively, commercial and supported versions of the program - also known as
|
|
35
|
+
Commercial Distributions - must be used in accordance with the terms and conditions
|
|
36
|
+
contained in a separate written agreement between you and Vendure GmbH.
|
|
37
|
+
For more information about the Vendure Commercial License (VCL) please contact contact@vendure.io.
|
|
38
|
+
|
|
39
|
+
Please see also:
|
|
40
|
+
|
|
41
|
+
- [Licensing FAQ - license-faq.md](license/license-faq.md)
|
|
42
|
+
- [GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - gpl-3.0.txt](license/gpl-3.0.txt)
|
package/dist/cli.js
CHANGED
|
@@ -44,15 +44,15 @@ const version = require('../package.json').version;
|
|
|
44
44
|
program
|
|
45
45
|
.version(version)
|
|
46
46
|
.usage(`vendure <command>`)
|
|
47
|
-
.description(picocolors_1.default.blue(`
|
|
48
|
-
888
|
|
49
|
-
888
|
|
50
|
-
888
|
|
51
|
-
888 888 .d88b. 88888b. .d88888 888 888 888d888 .d88b.
|
|
52
|
-
888 888 d8P Y8b 888 "88b d88" 888 888 888 888P" d8P Y8b
|
|
53
|
-
Y88 88P 88888888 888 888 888 888 888 888 888 88888888
|
|
54
|
-
Y8bd8P Y8b. 888 888 Y88b 888 Y88b 888 888 Y8b.
|
|
55
|
-
Y88P "Y8888 888 888 "Y88888 "Y88888 888 "Y8888
|
|
47
|
+
.description(picocolors_1.default.blue(`
|
|
48
|
+
888
|
|
49
|
+
888
|
|
50
|
+
888
|
|
51
|
+
888 888 .d88b. 88888b. .d88888 888 888 888d888 .d88b.
|
|
52
|
+
888 888 d8P Y8b 888 "88b d88" 888 888 888 888P" d8P Y8b
|
|
53
|
+
Y88 88P 88888888 888 888 888 888 888 888 888 88888888
|
|
54
|
+
Y8bd8P Y8b. 888 888 Y88b 888 Y88b 888 888 Y8b.
|
|
55
|
+
Y88P "Y8888 888 888 "Y88888 "Y88888 888 "Y8888
|
|
56
56
|
`));
|
|
57
57
|
program
|
|
58
58
|
.command('add')
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import gql from 'graphql-tag';
|
|
2
|
-
|
|
3
|
-
export const adminApiExtensions = gql``;
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
|
|
3
|
+
export const adminApiExtensions = gql``;
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
|
-
import { DeletionResponse, Permission } from '@vendure/common/lib/generated-types';
|
|
3
|
-
import { CustomFieldsObject } from '@vendure/common/lib/shared-types';
|
|
4
|
-
import {
|
|
5
|
-
Allow,
|
|
6
|
-
Ctx,
|
|
7
|
-
PaginatedList,
|
|
8
|
-
RequestContext,
|
|
9
|
-
Transaction,
|
|
10
|
-
Relations,
|
|
11
|
-
VendureEntity,
|
|
12
|
-
ID,
|
|
13
|
-
TranslationInput,
|
|
14
|
-
ListQueryOptions,
|
|
15
|
-
RelationPaths,
|
|
16
|
-
} from '@vendure/core';
|
|
17
|
-
|
|
18
|
-
class TemplateEntity extends VendureEntity {
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class TemplateService {
|
|
25
|
-
findAll(ctx: RequestContext, options?: any, relations?: any): Promise<PaginatedList<TemplateEntity>> {
|
|
26
|
-
throw new Error('Method not implemented.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
findOne(ctx: RequestContext, id: ID, relations?: any): Promise<TemplateEntity | null> {
|
|
30
|
-
throw new Error('Method not implemented.');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
create(ctx: RequestContext, input: any): Promise<TemplateEntity> {
|
|
34
|
-
throw new Error('Method not implemented.');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
update(ctx: RequestContext, input: any): Promise<TemplateEntity> {
|
|
38
|
-
throw new Error('Method not implemented.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
delete(ctx: RequestContext, id: ID): Promise<DeletionResponse> {
|
|
42
|
-
throw new Error('Method not implemented.');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// These can be replaced by generated types if you set up code generation
|
|
47
|
-
interface CreateEntityInput {
|
|
48
|
-
// Define the input fields here
|
|
49
|
-
customFields?: CustomFieldsObject;
|
|
50
|
-
translations: Array<TranslationInput<TemplateEntity>>;
|
|
51
|
-
}
|
|
52
|
-
interface UpdateEntityInput {
|
|
53
|
-
id: ID;
|
|
54
|
-
// Define the input fields here
|
|
55
|
-
customFields?: CustomFieldsObject;
|
|
56
|
-
translations: Array<TranslationInput<TemplateEntity>>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Resolver()
|
|
60
|
-
export class EntityAdminResolver {
|
|
61
|
-
constructor(private templateService: TemplateService) {}
|
|
62
|
-
|
|
63
|
-
@Query()
|
|
64
|
-
@Allow(Permission.SuperAdmin)
|
|
65
|
-
async entity(
|
|
66
|
-
@Ctx() ctx: RequestContext,
|
|
67
|
-
@Args() args: { id: ID },
|
|
68
|
-
@Relations(TemplateEntity) relations: RelationPaths<TemplateEntity>,
|
|
69
|
-
): Promise<TemplateEntity | null> {
|
|
70
|
-
return this.templateService.findOne(ctx, args.id, relations);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@Query()
|
|
74
|
-
@Allow(Permission.SuperAdmin)
|
|
75
|
-
async entities(
|
|
76
|
-
@Ctx() ctx: RequestContext,
|
|
77
|
-
@Args() args: { options: ListQueryOptions<TemplateEntity> },
|
|
78
|
-
@Relations(TemplateEntity) relations: RelationPaths<TemplateEntity>,
|
|
79
|
-
): Promise<PaginatedList<TemplateEntity>> {
|
|
80
|
-
return this.templateService.findAll(ctx, args.options || undefined, relations);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@Mutation()
|
|
84
|
-
@Transaction()
|
|
85
|
-
@Allow(Permission.SuperAdmin)
|
|
86
|
-
async createEntity(
|
|
87
|
-
@Ctx() ctx: RequestContext,
|
|
88
|
-
@Args() args: { input: CreateEntityInput },
|
|
89
|
-
): Promise<TemplateEntity> {
|
|
90
|
-
return this.templateService.create(ctx, args.input);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Mutation()
|
|
94
|
-
@Transaction()
|
|
95
|
-
@Allow(Permission.SuperAdmin)
|
|
96
|
-
async updateEntity(
|
|
97
|
-
@Ctx() ctx: RequestContext,
|
|
98
|
-
@Args() args: { input: UpdateEntityInput },
|
|
99
|
-
): Promise<TemplateEntity> {
|
|
100
|
-
return this.templateService.update(ctx, args.input);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
@Mutation()
|
|
104
|
-
@Transaction()
|
|
105
|
-
@Allow(Permission.SuperAdmin)
|
|
106
|
-
async deleteEntity(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<DeletionResponse> {
|
|
107
|
-
return this.templateService.delete(ctx, args.id);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
|
+
import { DeletionResponse, Permission } from '@vendure/common/lib/generated-types';
|
|
3
|
+
import { CustomFieldsObject } from '@vendure/common/lib/shared-types';
|
|
4
|
+
import {
|
|
5
|
+
Allow,
|
|
6
|
+
Ctx,
|
|
7
|
+
PaginatedList,
|
|
8
|
+
RequestContext,
|
|
9
|
+
Transaction,
|
|
10
|
+
Relations,
|
|
11
|
+
VendureEntity,
|
|
12
|
+
ID,
|
|
13
|
+
TranslationInput,
|
|
14
|
+
ListQueryOptions,
|
|
15
|
+
RelationPaths,
|
|
16
|
+
} from '@vendure/core';
|
|
17
|
+
|
|
18
|
+
class TemplateEntity extends VendureEntity {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class TemplateService {
|
|
25
|
+
findAll(ctx: RequestContext, options?: any, relations?: any): Promise<PaginatedList<TemplateEntity>> {
|
|
26
|
+
throw new Error('Method not implemented.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
findOne(ctx: RequestContext, id: ID, relations?: any): Promise<TemplateEntity | null> {
|
|
30
|
+
throw new Error('Method not implemented.');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
create(ctx: RequestContext, input: any): Promise<TemplateEntity> {
|
|
34
|
+
throw new Error('Method not implemented.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
update(ctx: RequestContext, input: any): Promise<TemplateEntity> {
|
|
38
|
+
throw new Error('Method not implemented.');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
delete(ctx: RequestContext, id: ID): Promise<DeletionResponse> {
|
|
42
|
+
throw new Error('Method not implemented.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// These can be replaced by generated types if you set up code generation
|
|
47
|
+
interface CreateEntityInput {
|
|
48
|
+
// Define the input fields here
|
|
49
|
+
customFields?: CustomFieldsObject;
|
|
50
|
+
translations: Array<TranslationInput<TemplateEntity>>;
|
|
51
|
+
}
|
|
52
|
+
interface UpdateEntityInput {
|
|
53
|
+
id: ID;
|
|
54
|
+
// Define the input fields here
|
|
55
|
+
customFields?: CustomFieldsObject;
|
|
56
|
+
translations: Array<TranslationInput<TemplateEntity>>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Resolver()
|
|
60
|
+
export class EntityAdminResolver {
|
|
61
|
+
constructor(private templateService: TemplateService) {}
|
|
62
|
+
|
|
63
|
+
@Query()
|
|
64
|
+
@Allow(Permission.SuperAdmin)
|
|
65
|
+
async entity(
|
|
66
|
+
@Ctx() ctx: RequestContext,
|
|
67
|
+
@Args() args: { id: ID },
|
|
68
|
+
@Relations(TemplateEntity) relations: RelationPaths<TemplateEntity>,
|
|
69
|
+
): Promise<TemplateEntity | null> {
|
|
70
|
+
return this.templateService.findOne(ctx, args.id, relations);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Query()
|
|
74
|
+
@Allow(Permission.SuperAdmin)
|
|
75
|
+
async entities(
|
|
76
|
+
@Ctx() ctx: RequestContext,
|
|
77
|
+
@Args() args: { options: ListQueryOptions<TemplateEntity> },
|
|
78
|
+
@Relations(TemplateEntity) relations: RelationPaths<TemplateEntity>,
|
|
79
|
+
): Promise<PaginatedList<TemplateEntity>> {
|
|
80
|
+
return this.templateService.findAll(ctx, args.options || undefined, relations);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Mutation()
|
|
84
|
+
@Transaction()
|
|
85
|
+
@Allow(Permission.SuperAdmin)
|
|
86
|
+
async createEntity(
|
|
87
|
+
@Ctx() ctx: RequestContext,
|
|
88
|
+
@Args() args: { input: CreateEntityInput },
|
|
89
|
+
): Promise<TemplateEntity> {
|
|
90
|
+
return this.templateService.create(ctx, args.input);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Mutation()
|
|
94
|
+
@Transaction()
|
|
95
|
+
@Allow(Permission.SuperAdmin)
|
|
96
|
+
async updateEntity(
|
|
97
|
+
@Ctx() ctx: RequestContext,
|
|
98
|
+
@Args() args: { input: UpdateEntityInput },
|
|
99
|
+
): Promise<TemplateEntity> {
|
|
100
|
+
return this.templateService.update(ctx, args.input);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Mutation()
|
|
104
|
+
@Transaction()
|
|
105
|
+
@Allow(Permission.SuperAdmin)
|
|
106
|
+
async deleteEntity(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<DeletionResponse> {
|
|
107
|
+
return this.templateService.delete(ctx, args.id);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
|
-
import { Permission } from '@vendure/common/lib/generated-types';
|
|
3
|
-
import { ID } from '@vendure/common/lib/shared-types';
|
|
4
|
-
import { Allow, Ctx, RequestContext, Transaction } from '@vendure/core';
|
|
5
|
-
|
|
6
|
-
class TemplateService {
|
|
7
|
-
async exampleQueryHandler(ctx: RequestContext, id: ID) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
async exampleMutationHandler(ctx: RequestContext, id: ID) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@Resolver()
|
|
16
|
-
export class SimpleAdminResolver {
|
|
17
|
-
constructor(private templateService: TemplateService) {}
|
|
18
|
-
|
|
19
|
-
@Query()
|
|
20
|
-
@Allow(Permission.SuperAdmin)
|
|
21
|
-
async exampleQuery(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> {
|
|
22
|
-
return this.templateService.exampleQueryHandler(ctx, args.id);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Mutation()
|
|
26
|
-
@Transaction()
|
|
27
|
-
@Allow(Permission.SuperAdmin)
|
|
28
|
-
async exampleMutation(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> {
|
|
29
|
-
return this.templateService.exampleMutationHandler(ctx, args.id);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
2
|
+
import { Permission } from '@vendure/common/lib/generated-types';
|
|
3
|
+
import { ID } from '@vendure/common/lib/shared-types';
|
|
4
|
+
import { Allow, Ctx, RequestContext, Transaction } from '@vendure/core';
|
|
5
|
+
|
|
6
|
+
class TemplateService {
|
|
7
|
+
async exampleQueryHandler(ctx: RequestContext, id: ID) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
async exampleMutationHandler(ctx: RequestContext, id: ID) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Resolver()
|
|
16
|
+
export class SimpleAdminResolver {
|
|
17
|
+
constructor(private templateService: TemplateService) {}
|
|
18
|
+
|
|
19
|
+
@Query()
|
|
20
|
+
@Allow(Permission.SuperAdmin)
|
|
21
|
+
async exampleQuery(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> {
|
|
22
|
+
return this.templateService.exampleQueryHandler(ctx, args.id);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Mutation()
|
|
26
|
+
@Transaction()
|
|
27
|
+
@Allow(Permission.SuperAdmin)
|
|
28
|
+
async exampleMutation(@Ctx() ctx: RequestContext, @Args() args: { id: ID }): Promise<boolean> {
|
|
29
|
+
return this.templateService.exampleMutationHandler(ctx, args.id);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -86,12 +86,12 @@ async function addCodegen(options) {
|
|
|
86
86
|
codegenFile.addEntryToGeneratesObject({
|
|
87
87
|
name: `'${uiExtensionsPath}/gql/'`,
|
|
88
88
|
kind: ts_morph_1.StructureKind.PropertyAssignment,
|
|
89
|
-
initializer: `{
|
|
90
|
-
preset: 'client',
|
|
91
|
-
documents: '${uiExtensionsPath}/**/*.ts',
|
|
92
|
-
presetConfig: {
|
|
93
|
-
fragmentMasking: false,
|
|
94
|
-
},
|
|
89
|
+
initializer: `{
|
|
90
|
+
preset: 'client',
|
|
91
|
+
documents: '${uiExtensionsPath}/**/*.ts',
|
|
92
|
+
presetConfig: {
|
|
93
|
+
fragmentMasking: false,
|
|
94
|
+
},
|
|
95
95
|
}`,
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
-
|
|
3
|
-
const config: CodegenConfig = {
|
|
4
|
-
overwrite: true,
|
|
5
|
-
// This assumes your server is running on the standard port
|
|
6
|
-
// and with the default admin API path. Adjust accordingly.
|
|
7
|
-
schema: 'http://localhost:3000/admin-api',
|
|
8
|
-
config: {
|
|
9
|
-
// This tells codegen that the `Money` scalar is a number
|
|
10
|
-
scalars: { Money: 'number' },
|
|
11
|
-
// This ensures generated enums do not conflict with the built-in types.
|
|
12
|
-
namingConvention: { enumValues: 'keep' },
|
|
13
|
-
},
|
|
14
|
-
generates: {},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default config;
|
|
1
|
+
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
+
|
|
3
|
+
const config: CodegenConfig = {
|
|
4
|
+
overwrite: true,
|
|
5
|
+
// This assumes your server is running on the standard port
|
|
6
|
+
// and with the default admin API path. Adjust accordingly.
|
|
7
|
+
schema: 'http://localhost:3000/admin-api',
|
|
8
|
+
config: {
|
|
9
|
+
// This tells codegen that the `Money` scalar is a number
|
|
10
|
+
scalars: { Money: 'number' },
|
|
11
|
+
// This ensures generated enums do not conflict with the built-in types.
|
|
12
|
+
namingConvention: { enumValues: 'keep' },
|
|
13
|
+
},
|
|
14
|
+
generates: {},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default config;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
2
|
-
import { DeepPartial } from '@vendure/common/lib/shared-types';
|
|
3
|
-
import { HasCustomFields, Translation, VendureEntity } from '@vendure/core';
|
|
4
|
-
import { Column, Entity, Index, ManyToOne } from 'typeorm';
|
|
5
|
-
|
|
6
|
-
import { ScaffoldEntity } from './entity.template';
|
|
7
|
-
|
|
8
|
-
export class ScaffoldEntityCustomFieldsTranslation {}
|
|
9
|
-
|
|
10
|
-
@Entity()
|
|
11
|
-
export class ScaffoldTranslation
|
|
12
|
-
extends VendureEntity
|
|
13
|
-
implements Translation<ScaffoldEntity>, HasCustomFields
|
|
14
|
-
{
|
|
15
|
-
constructor(input?: DeepPartial<Translation<ScaffoldTranslation>>) {
|
|
16
|
-
super(input);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Column('varchar') languageCode: LanguageCode;
|
|
20
|
-
|
|
21
|
-
@Column() localizedName: string;
|
|
22
|
-
|
|
23
|
-
@Index()
|
|
24
|
-
@ManyToOne(type => ScaffoldEntity, base => base.translations, { onDelete: 'CASCADE' })
|
|
25
|
-
base: ScaffoldEntity;
|
|
26
|
-
|
|
27
|
-
@Column(type => ScaffoldEntityCustomFieldsTranslation)
|
|
28
|
-
customFields: ScaffoldEntityCustomFieldsTranslation;
|
|
29
|
-
}
|
|
1
|
+
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
2
|
+
import { DeepPartial } from '@vendure/common/lib/shared-types';
|
|
3
|
+
import { HasCustomFields, Translation, VendureEntity } from '@vendure/core';
|
|
4
|
+
import { Column, Entity, Index, ManyToOne } from 'typeorm';
|
|
5
|
+
|
|
6
|
+
import { ScaffoldEntity } from './entity.template';
|
|
7
|
+
|
|
8
|
+
export class ScaffoldEntityCustomFieldsTranslation {}
|
|
9
|
+
|
|
10
|
+
@Entity()
|
|
11
|
+
export class ScaffoldTranslation
|
|
12
|
+
extends VendureEntity
|
|
13
|
+
implements Translation<ScaffoldEntity>, HasCustomFields
|
|
14
|
+
{
|
|
15
|
+
constructor(input?: DeepPartial<Translation<ScaffoldTranslation>>) {
|
|
16
|
+
super(input);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Column('varchar') languageCode: LanguageCode;
|
|
20
|
+
|
|
21
|
+
@Column() localizedName: string;
|
|
22
|
+
|
|
23
|
+
@Index()
|
|
24
|
+
@ManyToOne(type => ScaffoldEntity, base => base.translations, { onDelete: 'CASCADE' })
|
|
25
|
+
base: ScaffoldEntity;
|
|
26
|
+
|
|
27
|
+
@Column(type => ScaffoldEntityCustomFieldsTranslation)
|
|
28
|
+
customFields: ScaffoldEntityCustomFieldsTranslation;
|
|
29
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DeepPartial,
|
|
3
|
-
HasCustomFields,
|
|
4
|
-
LocaleString,
|
|
5
|
-
Translatable,
|
|
6
|
-
Translation,
|
|
7
|
-
VendureEntity,
|
|
8
|
-
} from '@vendure/core';
|
|
9
|
-
import { Column, Entity, OneToMany } from 'typeorm';
|
|
10
|
-
|
|
11
|
-
import { ScaffoldTranslation } from './entity-translation.template';
|
|
12
|
-
|
|
13
|
-
export class ScaffoldEntityCustomFields {}
|
|
14
|
-
|
|
15
|
-
@Entity()
|
|
16
|
-
export class ScaffoldEntity extends VendureEntity implements Translatable, HasCustomFields {
|
|
17
|
-
constructor(input?: DeepPartial<ScaffoldEntity>) {
|
|
18
|
-
super(input);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Column()
|
|
22
|
-
code: string;
|
|
23
|
-
|
|
24
|
-
@Column(type => ScaffoldEntityCustomFields)
|
|
25
|
-
customFields: ScaffoldEntityCustomFields;
|
|
26
|
-
|
|
27
|
-
localizedName: LocaleString;
|
|
28
|
-
|
|
29
|
-
@OneToMany(type => ScaffoldTranslation, translation => translation.base, { eager: true })
|
|
30
|
-
translations: Array<Translation<ScaffoldEntity>>;
|
|
31
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DeepPartial,
|
|
3
|
+
HasCustomFields,
|
|
4
|
+
LocaleString,
|
|
5
|
+
Translatable,
|
|
6
|
+
Translation,
|
|
7
|
+
VendureEntity,
|
|
8
|
+
} from '@vendure/core';
|
|
9
|
+
import { Column, Entity, OneToMany } from 'typeorm';
|
|
10
|
+
|
|
11
|
+
import { ScaffoldTranslation } from './entity-translation.template';
|
|
12
|
+
|
|
13
|
+
export class ScaffoldEntityCustomFields {}
|
|
14
|
+
|
|
15
|
+
@Entity()
|
|
16
|
+
export class ScaffoldEntity extends VendureEntity implements Translatable, HasCustomFields {
|
|
17
|
+
constructor(input?: DeepPartial<ScaffoldEntity>) {
|
|
18
|
+
super(input);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Column()
|
|
22
|
+
code: string;
|
|
23
|
+
|
|
24
|
+
@Column(type => ScaffoldEntityCustomFields)
|
|
25
|
+
customFields: ScaffoldEntityCustomFields;
|
|
26
|
+
|
|
27
|
+
localizedName: LocaleString;
|
|
28
|
+
|
|
29
|
+
@OneToMany(type => ScaffoldTranslation, translation => translation.base, { eager: true })
|
|
30
|
+
translations: Array<Translation<ScaffoldEntity>>;
|
|
31
|
+
}
|
|
@@ -73,39 +73,39 @@ async function addJobQueue(options) {
|
|
|
73
73
|
if (ts_morph_1.Node.isBlock(body)) {
|
|
74
74
|
body.addStatements(writer => {
|
|
75
75
|
writer
|
|
76
|
-
.write(`this.${jobQueuePropertyName} = await this.jobQueueService.createQueue({
|
|
77
|
-
name: '${jobQueueName}',
|
|
78
|
-
process: async job => {
|
|
79
|
-
// Deserialize the RequestContext from the job data
|
|
80
|
-
const ctx = RequestContext.deserialize(job.data.ctx);
|
|
81
|
-
// The "someArg" property is passed in when the job is triggered
|
|
82
|
-
const someArg = job.data.someArg;
|
|
83
|
-
|
|
84
|
-
// Inside the \`process\` function we define how each job
|
|
85
|
-
// in the queue will be processed.
|
|
86
|
-
// Let's simulate some long-running task
|
|
87
|
-
const totalItems = 10;
|
|
88
|
-
for (let i = 0; i < totalItems; i++) {
|
|
89
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
90
|
-
|
|
91
|
-
// You can optionally respond to the job being cancelled
|
|
92
|
-
// during processing. This can be useful for very long-running
|
|
93
|
-
// tasks which can be cancelled by the user.
|
|
94
|
-
if (job.state === JobState.CANCELLED) {
|
|
95
|
-
throw new Error('Job was cancelled');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Progress can be reported as a percentage like this
|
|
99
|
-
job.setProgress(Math.floor(i / totalItems * 100));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// The value returned from the \`process\` function is stored
|
|
103
|
-
// as the "result" field of the job
|
|
104
|
-
return {
|
|
105
|
-
processedCount: totalItems,
|
|
106
|
-
message: \`Successfully processed \${totalItems} items\`,
|
|
107
|
-
};
|
|
108
|
-
},
|
|
76
|
+
.write(`this.${jobQueuePropertyName} = await this.jobQueueService.createQueue({
|
|
77
|
+
name: '${jobQueueName}',
|
|
78
|
+
process: async job => {
|
|
79
|
+
// Deserialize the RequestContext from the job data
|
|
80
|
+
const ctx = RequestContext.deserialize(job.data.ctx);
|
|
81
|
+
// The "someArg" property is passed in when the job is triggered
|
|
82
|
+
const someArg = job.data.someArg;
|
|
83
|
+
|
|
84
|
+
// Inside the \`process\` function we define how each job
|
|
85
|
+
// in the queue will be processed.
|
|
86
|
+
// Let's simulate some long-running task
|
|
87
|
+
const totalItems = 10;
|
|
88
|
+
for (let i = 0; i < totalItems; i++) {
|
|
89
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
90
|
+
|
|
91
|
+
// You can optionally respond to the job being cancelled
|
|
92
|
+
// during processing. This can be useful for very long-running
|
|
93
|
+
// tasks which can be cancelled by the user.
|
|
94
|
+
if (job.state === JobState.CANCELLED) {
|
|
95
|
+
throw new Error('Job was cancelled');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Progress can be reported as a percentage like this
|
|
99
|
+
job.setProgress(Math.floor(i / totalItems * 100));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// The value returned from the \`process\` function is stored
|
|
103
|
+
// as the "result" field of the job
|
|
104
|
+
return {
|
|
105
|
+
processedCount: totalItems,
|
|
106
|
+
message: \`Successfully processed \${totalItems} items\`,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
109
|
})`)
|
|
110
110
|
.newLine();
|
|
111
111
|
}).forEach(s => s.formatText());
|
|
@@ -116,9 +116,9 @@ async function addJobQueue(options) {
|
|
|
116
116
|
scope: ts_morph_1.Scope.Public,
|
|
117
117
|
parameters: [{ name: 'ctx', type: 'RequestContext' }],
|
|
118
118
|
statements: writer => {
|
|
119
|
-
writer.write(`return this.${jobQueuePropertyName}.add({
|
|
120
|
-
ctx: ctx.serialize(),
|
|
121
|
-
someArg: 'foo',
|
|
119
|
+
writer.write(`return this.${jobQueuePropertyName}.add({
|
|
120
|
+
ctx: ctx.serialize(),
|
|
121
|
+
someArg: 'foo',
|
|
122
122
|
})`);
|
|
123
123
|
},
|
|
124
124
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const TEMPLATE_PLUGIN_OPTIONS = Symbol('TEMPLATE_PLUGIN_OPTIONS');
|
|
2
|
-
export const loggerCtx = 'TemplatePlugin';
|
|
1
|
+
export const TEMPLATE_PLUGIN_OPTIONS = Symbol('TEMPLATE_PLUGIN_OPTIONS');
|
|
2
|
+
export const loggerCtx = 'TemplatePlugin';
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { PluginCommonModule, Type, VendurePlugin } from '@vendure/core';
|
|
2
|
-
|
|
3
|
-
import { TEMPLATE_PLUGIN_OPTIONS } from './constants.template';
|
|
4
|
-
import { PluginInitOptions } from './types.template';
|
|
5
|
-
|
|
6
|
-
@VendurePlugin({
|
|
7
|
-
imports: [PluginCommonModule],
|
|
8
|
-
providers: [{ provide: TEMPLATE_PLUGIN_OPTIONS, useFactory: () => TemplatePlugin.options }],
|
|
9
|
-
configuration: config => {
|
|
10
|
-
// Plugin-specific configuration
|
|
11
|
-
// such as custom fields, custom permissions,
|
|
12
|
-
// strategies etc. can be configured here by
|
|
13
|
-
// modifying the `config` object.
|
|
14
|
-
return config;
|
|
15
|
-
},
|
|
16
|
-
compatibility: '^3.0.0',
|
|
17
|
-
})
|
|
18
|
-
export class TemplatePlugin {
|
|
19
|
-
static options: PluginInitOptions;
|
|
20
|
-
|
|
21
|
-
static init(options: PluginInitOptions): Type<TemplatePlugin> {
|
|
22
|
-
this.options = options;
|
|
23
|
-
return TemplatePlugin;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
import { PluginCommonModule, Type, VendurePlugin } from '@vendure/core';
|
|
2
|
+
|
|
3
|
+
import { TEMPLATE_PLUGIN_OPTIONS } from './constants.template';
|
|
4
|
+
import { PluginInitOptions } from './types.template';
|
|
5
|
+
|
|
6
|
+
@VendurePlugin({
|
|
7
|
+
imports: [PluginCommonModule],
|
|
8
|
+
providers: [{ provide: TEMPLATE_PLUGIN_OPTIONS, useFactory: () => TemplatePlugin.options }],
|
|
9
|
+
configuration: config => {
|
|
10
|
+
// Plugin-specific configuration
|
|
11
|
+
// such as custom fields, custom permissions,
|
|
12
|
+
// strategies etc. can be configured here by
|
|
13
|
+
// modifying the `config` object.
|
|
14
|
+
return config;
|
|
15
|
+
},
|
|
16
|
+
compatibility: '^3.0.0',
|
|
17
|
+
})
|
|
18
|
+
export class TemplatePlugin {
|
|
19
|
+
static options: PluginInitOptions;
|
|
20
|
+
|
|
21
|
+
static init(options: PluginInitOptions): Type<TemplatePlugin> {
|
|
22
|
+
this.options = options;
|
|
23
|
+
return TemplatePlugin;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description
|
|
3
|
-
* The plugin can be configured using the following options:
|
|
4
|
-
*/
|
|
5
|
-
export interface PluginInitOptions {
|
|
6
|
-
exampleOption?: string;
|
|
7
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
* The plugin can be configured using the following options:
|
|
4
|
+
*/
|
|
5
|
+
export interface PluginInitOptions {
|
|
6
|
+
exampleOption?: string;
|
|
7
|
+
}
|
|
@@ -180,11 +180,11 @@ function customizeFindOneMethod(serviceClassDeclaration, entityRef) {
|
|
|
180
180
|
const findOneMethod = serviceClassDeclaration.getMethod('findOne');
|
|
181
181
|
findOneMethod
|
|
182
182
|
.setBodyText(writer => {
|
|
183
|
-
writer.write(` return this.connection
|
|
184
|
-
.getRepository(ctx, ${entityRef.name})
|
|
185
|
-
.findOne({
|
|
186
|
-
where: { id },
|
|
187
|
-
relations,
|
|
183
|
+
writer.write(` return this.connection
|
|
184
|
+
.getRepository(ctx, ${entityRef.name})
|
|
185
|
+
.findOne({
|
|
186
|
+
where: { id },
|
|
187
|
+
relations,
|
|
188
188
|
})`);
|
|
189
189
|
if (entityRef.isTranslatable()) {
|
|
190
190
|
writer.write(`.then(entity => entity && this.translator.translate(entity, ctx));`);
|
|
@@ -233,14 +233,14 @@ function customizeCreateMethod(serviceClassDeclaration, entityRef) {
|
|
|
233
233
|
.setBodyText(writer => {
|
|
234
234
|
var _a;
|
|
235
235
|
if (entityRef.isTranslatable()) {
|
|
236
|
-
writer.write(`const newEntity = await this.translatableSaver.create({
|
|
237
|
-
ctx,
|
|
238
|
-
input,
|
|
239
|
-
entityType: ${entityRef.name},
|
|
240
|
-
translationType: ${(_a = entityRef.getTranslationClass()) === null || _a === void 0 ? void 0 : _a.getName()},
|
|
241
|
-
beforeSave: async f => {
|
|
242
|
-
// Any pre-save logic can go here
|
|
243
|
-
},
|
|
236
|
+
writer.write(`const newEntity = await this.translatableSaver.create({
|
|
237
|
+
ctx,
|
|
238
|
+
input,
|
|
239
|
+
entityType: ${entityRef.name},
|
|
240
|
+
translationType: ${(_a = entityRef.getTranslationClass()) === null || _a === void 0 ? void 0 : _a.getName()},
|
|
241
|
+
beforeSave: async f => {
|
|
242
|
+
// Any pre-save logic can go here
|
|
243
|
+
},
|
|
244
244
|
});`);
|
|
245
245
|
}
|
|
246
246
|
else {
|
|
@@ -262,14 +262,14 @@ function customizeUpdateMethod(serviceClassDeclaration, entityRef) {
|
|
|
262
262
|
.setBodyText(writer => {
|
|
263
263
|
var _a;
|
|
264
264
|
if (entityRef.isTranslatable()) {
|
|
265
|
-
writer.write(`const updatedEntity = await this.translatableSaver.update({
|
|
266
|
-
ctx,
|
|
267
|
-
input,
|
|
268
|
-
entityType: ${entityRef.name},
|
|
269
|
-
translationType: ${(_a = entityRef.getTranslationClass()) === null || _a === void 0 ? void 0 : _a.getName()},
|
|
270
|
-
beforeSave: async f => {
|
|
271
|
-
// Any pre-save logic can go here
|
|
272
|
-
},
|
|
265
|
+
writer.write(`const updatedEntity = await this.translatableSaver.update({
|
|
266
|
+
ctx,
|
|
267
|
+
input,
|
|
268
|
+
entityType: ${entityRef.name},
|
|
269
|
+
translationType: ${(_a = entityRef.getTranslationClass()) === null || _a === void 0 ? void 0 : _a.getName()},
|
|
270
|
+
beforeSave: async f => {
|
|
271
|
+
// Any pre-save logic can go here
|
|
272
|
+
},
|
|
273
273
|
});`);
|
|
274
274
|
}
|
|
275
275
|
else {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ID, Product, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
3
|
-
|
|
4
|
-
@Injectable()
|
|
5
|
-
export class BasicServiceTemplate {
|
|
6
|
-
constructor(private connection: TransactionalConnection) {}
|
|
7
|
-
|
|
8
|
-
async exampleMethod(ctx: RequestContext, id: ID) {
|
|
9
|
-
// Add your method logic here
|
|
10
|
-
const result = await this.connection.getRepository(ctx, Product).findOne({ where: { id } });
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ID, Product, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class BasicServiceTemplate {
|
|
6
|
+
constructor(private connection: TransactionalConnection) {}
|
|
7
|
+
|
|
8
|
+
async exampleMethod(ctx: RequestContext, id: ID) {
|
|
9
|
+
// Add your method logic here
|
|
10
|
+
const result = await this.connection.getRepository(ctx, Product).findOne({ where: { id } });
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { DeletionResponse, DeletionResult, LanguageCode } from '@vendure/common/lib/generated-types';
|
|
3
|
-
import { CustomFieldsObject, ID, PaginatedList } from '@vendure/common/lib/shared-types';
|
|
4
|
-
import {
|
|
5
|
-
assertFound,
|
|
6
|
-
CustomFieldRelationService,
|
|
7
|
-
HasCustomFields,
|
|
8
|
-
ListQueryBuilder,
|
|
9
|
-
ListQueryOptions,
|
|
10
|
-
RelationPaths,
|
|
11
|
-
RequestContext,
|
|
12
|
-
TransactionalConnection,
|
|
13
|
-
Translatable,
|
|
14
|
-
TranslatableSaver,
|
|
15
|
-
Translated,
|
|
16
|
-
Translation,
|
|
17
|
-
TranslationInput,
|
|
18
|
-
TranslatorService,
|
|
19
|
-
VendureEntity,
|
|
20
|
-
patchEntity,
|
|
21
|
-
} from '@vendure/core';
|
|
22
|
-
|
|
23
|
-
// These can be replaced by generated types if you set up code generation
|
|
24
|
-
interface CreateEntityInput {
|
|
25
|
-
// Define the input fields here
|
|
26
|
-
customFields?: CustomFieldsObject;
|
|
27
|
-
translations: Array<TranslationInput<TemplateEntity>>;
|
|
28
|
-
}
|
|
29
|
-
interface UpdateEntityInput {
|
|
30
|
-
id: ID;
|
|
31
|
-
// Define the input fields here
|
|
32
|
-
customFields?: CustomFieldsObject;
|
|
33
|
-
translations: Array<TranslationInput<TemplateEntity>>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
class TemplateEntity extends VendureEntity implements Translatable, HasCustomFields {
|
|
37
|
-
constructor() {
|
|
38
|
-
super();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
customFields: CustomFieldsObject;
|
|
42
|
-
|
|
43
|
-
translations: Array<Translation<TemplateEntity>>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
class TemplateEntityTranslation extends VendureEntity implements Translation<TemplateEntity> {
|
|
47
|
-
constructor() {
|
|
48
|
-
super();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
id: ID;
|
|
52
|
-
languageCode: LanguageCode;
|
|
53
|
-
base: TemplateEntity;
|
|
54
|
-
customFields: CustomFieldsObject;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Injectable()
|
|
58
|
-
export class EntityServiceTemplate {
|
|
59
|
-
constructor(
|
|
60
|
-
private connection: TransactionalConnection,
|
|
61
|
-
private translatableSaver: TranslatableSaver,
|
|
62
|
-
private listQueryBuilder: ListQueryBuilder,
|
|
63
|
-
private customFieldRelationService: CustomFieldRelationService,
|
|
64
|
-
private translator: TranslatorService,
|
|
65
|
-
) {}
|
|
66
|
-
|
|
67
|
-
findAll(
|
|
68
|
-
ctx: RequestContext,
|
|
69
|
-
options?: ListQueryOptions<TemplateEntity>,
|
|
70
|
-
relations?: RelationPaths<TemplateEntity>,
|
|
71
|
-
): Promise<PaginatedList<Translated<TemplateEntity>>> {
|
|
72
|
-
return this.listQueryBuilder
|
|
73
|
-
.build(TemplateEntity, options, {
|
|
74
|
-
relations,
|
|
75
|
-
ctx,
|
|
76
|
-
})
|
|
77
|
-
.getManyAndCount()
|
|
78
|
-
.then(([_items, totalItems]) => {
|
|
79
|
-
const items = _items.map(item => this.translator.translate(item, ctx));
|
|
80
|
-
return {
|
|
81
|
-
items,
|
|
82
|
-
totalItems,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
findOne(
|
|
88
|
-
ctx: RequestContext,
|
|
89
|
-
id: ID,
|
|
90
|
-
relations?: RelationPaths<TemplateEntity>,
|
|
91
|
-
): Promise<Translated<TemplateEntity> | null> {
|
|
92
|
-
return this.connection
|
|
93
|
-
.getRepository(ctx, TemplateEntity)
|
|
94
|
-
.findOne({
|
|
95
|
-
where: { id },
|
|
96
|
-
relations,
|
|
97
|
-
})
|
|
98
|
-
.then(entity => entity && this.translator.translate(entity, ctx));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async create(ctx: RequestContext, input: CreateEntityInput): Promise<Translated<TemplateEntity>> {
|
|
102
|
-
const newEntity = await this.translatableSaver.create({
|
|
103
|
-
ctx,
|
|
104
|
-
input,
|
|
105
|
-
entityType: TemplateEntity,
|
|
106
|
-
translationType: TemplateEntityTranslation,
|
|
107
|
-
beforeSave: async f => {
|
|
108
|
-
// Any pre-save logic can go here
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
// Ensure any custom field relations get saved
|
|
112
|
-
await this.customFieldRelationService.updateRelations(ctx, TemplateEntity, input, newEntity);
|
|
113
|
-
return assertFound(this.findOne(ctx, newEntity.id));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async update(ctx: RequestContext, input: UpdateEntityInput): Promise<Translated<TemplateEntity>> {
|
|
117
|
-
const updatedEntity = await this.translatableSaver.update({
|
|
118
|
-
ctx,
|
|
119
|
-
input,
|
|
120
|
-
entityType: TemplateEntity,
|
|
121
|
-
translationType: TemplateEntityTranslation,
|
|
122
|
-
beforeSave: async f => {
|
|
123
|
-
// Any pre-save logic can go here
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
// This is just here to stop the import being removed by the IDE
|
|
127
|
-
patchEntity(updatedEntity, {});
|
|
128
|
-
await this.customFieldRelationService.updateRelations(ctx, TemplateEntity, input, updatedEntity);
|
|
129
|
-
return assertFound(this.findOne(ctx, updatedEntity.id));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async delete(ctx: RequestContext, id: ID): Promise<DeletionResponse> {
|
|
133
|
-
const entity = await this.connection.getEntityOrThrow(ctx, TemplateEntity, id);
|
|
134
|
-
try {
|
|
135
|
-
await this.connection.getRepository(ctx, TemplateEntity).remove(entity);
|
|
136
|
-
return {
|
|
137
|
-
result: DeletionResult.DELETED,
|
|
138
|
-
};
|
|
139
|
-
} catch (e: any) {
|
|
140
|
-
return {
|
|
141
|
-
result: DeletionResult.NOT_DELETED,
|
|
142
|
-
message: e.toString(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { DeletionResponse, DeletionResult, LanguageCode } from '@vendure/common/lib/generated-types';
|
|
3
|
+
import { CustomFieldsObject, ID, PaginatedList } from '@vendure/common/lib/shared-types';
|
|
4
|
+
import {
|
|
5
|
+
assertFound,
|
|
6
|
+
CustomFieldRelationService,
|
|
7
|
+
HasCustomFields,
|
|
8
|
+
ListQueryBuilder,
|
|
9
|
+
ListQueryOptions,
|
|
10
|
+
RelationPaths,
|
|
11
|
+
RequestContext,
|
|
12
|
+
TransactionalConnection,
|
|
13
|
+
Translatable,
|
|
14
|
+
TranslatableSaver,
|
|
15
|
+
Translated,
|
|
16
|
+
Translation,
|
|
17
|
+
TranslationInput,
|
|
18
|
+
TranslatorService,
|
|
19
|
+
VendureEntity,
|
|
20
|
+
patchEntity,
|
|
21
|
+
} from '@vendure/core';
|
|
22
|
+
|
|
23
|
+
// These can be replaced by generated types if you set up code generation
|
|
24
|
+
interface CreateEntityInput {
|
|
25
|
+
// Define the input fields here
|
|
26
|
+
customFields?: CustomFieldsObject;
|
|
27
|
+
translations: Array<TranslationInput<TemplateEntity>>;
|
|
28
|
+
}
|
|
29
|
+
interface UpdateEntityInput {
|
|
30
|
+
id: ID;
|
|
31
|
+
// Define the input fields here
|
|
32
|
+
customFields?: CustomFieldsObject;
|
|
33
|
+
translations: Array<TranslationInput<TemplateEntity>>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class TemplateEntity extends VendureEntity implements Translatable, HasCustomFields {
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
customFields: CustomFieldsObject;
|
|
42
|
+
|
|
43
|
+
translations: Array<Translation<TemplateEntity>>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class TemplateEntityTranslation extends VendureEntity implements Translation<TemplateEntity> {
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
id: ID;
|
|
52
|
+
languageCode: LanguageCode;
|
|
53
|
+
base: TemplateEntity;
|
|
54
|
+
customFields: CustomFieldsObject;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Injectable()
|
|
58
|
+
export class EntityServiceTemplate {
|
|
59
|
+
constructor(
|
|
60
|
+
private connection: TransactionalConnection,
|
|
61
|
+
private translatableSaver: TranslatableSaver,
|
|
62
|
+
private listQueryBuilder: ListQueryBuilder,
|
|
63
|
+
private customFieldRelationService: CustomFieldRelationService,
|
|
64
|
+
private translator: TranslatorService,
|
|
65
|
+
) {}
|
|
66
|
+
|
|
67
|
+
findAll(
|
|
68
|
+
ctx: RequestContext,
|
|
69
|
+
options?: ListQueryOptions<TemplateEntity>,
|
|
70
|
+
relations?: RelationPaths<TemplateEntity>,
|
|
71
|
+
): Promise<PaginatedList<Translated<TemplateEntity>>> {
|
|
72
|
+
return this.listQueryBuilder
|
|
73
|
+
.build(TemplateEntity, options, {
|
|
74
|
+
relations,
|
|
75
|
+
ctx,
|
|
76
|
+
})
|
|
77
|
+
.getManyAndCount()
|
|
78
|
+
.then(([_items, totalItems]) => {
|
|
79
|
+
const items = _items.map(item => this.translator.translate(item, ctx));
|
|
80
|
+
return {
|
|
81
|
+
items,
|
|
82
|
+
totalItems,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
findOne(
|
|
88
|
+
ctx: RequestContext,
|
|
89
|
+
id: ID,
|
|
90
|
+
relations?: RelationPaths<TemplateEntity>,
|
|
91
|
+
): Promise<Translated<TemplateEntity> | null> {
|
|
92
|
+
return this.connection
|
|
93
|
+
.getRepository(ctx, TemplateEntity)
|
|
94
|
+
.findOne({
|
|
95
|
+
where: { id },
|
|
96
|
+
relations,
|
|
97
|
+
})
|
|
98
|
+
.then(entity => entity && this.translator.translate(entity, ctx));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async create(ctx: RequestContext, input: CreateEntityInput): Promise<Translated<TemplateEntity>> {
|
|
102
|
+
const newEntity = await this.translatableSaver.create({
|
|
103
|
+
ctx,
|
|
104
|
+
input,
|
|
105
|
+
entityType: TemplateEntity,
|
|
106
|
+
translationType: TemplateEntityTranslation,
|
|
107
|
+
beforeSave: async f => {
|
|
108
|
+
// Any pre-save logic can go here
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// Ensure any custom field relations get saved
|
|
112
|
+
await this.customFieldRelationService.updateRelations(ctx, TemplateEntity, input, newEntity);
|
|
113
|
+
return assertFound(this.findOne(ctx, newEntity.id));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async update(ctx: RequestContext, input: UpdateEntityInput): Promise<Translated<TemplateEntity>> {
|
|
117
|
+
const updatedEntity = await this.translatableSaver.update({
|
|
118
|
+
ctx,
|
|
119
|
+
input,
|
|
120
|
+
entityType: TemplateEntity,
|
|
121
|
+
translationType: TemplateEntityTranslation,
|
|
122
|
+
beforeSave: async f => {
|
|
123
|
+
// Any pre-save logic can go here
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
// This is just here to stop the import being removed by the IDE
|
|
127
|
+
patchEntity(updatedEntity, {});
|
|
128
|
+
await this.customFieldRelationService.updateRelations(ctx, TemplateEntity, input, updatedEntity);
|
|
129
|
+
return assertFound(this.findOne(ctx, updatedEntity.id));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async delete(ctx: RequestContext, id: ID): Promise<DeletionResponse> {
|
|
133
|
+
const entity = await this.connection.getEntityOrThrow(ctx, TemplateEntity, id);
|
|
134
|
+
try {
|
|
135
|
+
await this.connection.getRepository(ctx, TemplateEntity).remove(entity);
|
|
136
|
+
return {
|
|
137
|
+
result: DeletionResult.DELETED,
|
|
138
|
+
};
|
|
139
|
+
} catch (e: any) {
|
|
140
|
+
return {
|
|
141
|
+
result: DeletionResult.NOT_DELETED,
|
|
142
|
+
message: e.toString(),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -13,11 +13,11 @@ function addUiExtensionStaticProp(plugin) {
|
|
|
13
13
|
name: 'ui',
|
|
14
14
|
isStatic: true,
|
|
15
15
|
type: adminUiExtensionType,
|
|
16
|
-
initializer: `{
|
|
17
|
-
id: '${extensionId}-ui',
|
|
18
|
-
extensionPath: path.join(__dirname, 'ui'),
|
|
19
|
-
routes: [{ route: '${extensionId}', filePath: 'routes.ts' }],
|
|
20
|
-
providers: ['providers.ts'],
|
|
16
|
+
initializer: `{
|
|
17
|
+
id: '${extensionId}-ui',
|
|
18
|
+
extensionPath: path.join(__dirname, 'ui'),
|
|
19
|
+
routes: [{ route: '${extensionId}', filePath: 'routes.ts' }],
|
|
20
|
+
providers: ['providers.ts'],
|
|
21
21
|
}`,
|
|
22
22
|
})
|
|
23
23
|
.formatText();
|
|
@@ -19,12 +19,12 @@ function updateAdminUiPluginInit(vendureConfig, options) {
|
|
|
19
19
|
initObject === null || initObject === void 0 ? void 0 : initObject.addProperty({
|
|
20
20
|
name: 'app',
|
|
21
21
|
kind: ts_morph_1.StructureKind.PropertyAssignment,
|
|
22
|
-
initializer: `compileUiExtensions({
|
|
23
|
-
outputPath: path.join(__dirname, '../admin-ui'),
|
|
24
|
-
extensions: [
|
|
25
|
-
${options.pluginClassName}.ui,
|
|
26
|
-
],
|
|
27
|
-
devMode: true,
|
|
22
|
+
initializer: `compileUiExtensions({
|
|
23
|
+
outputPath: path.join(__dirname, '../admin-ui'),
|
|
24
|
+
extensions: [
|
|
25
|
+
${options.pluginClassName}.ui,
|
|
26
|
+
],
|
|
27
|
+
devMode: true,
|
|
28
28
|
}),`,
|
|
29
29
|
}).formatText();
|
|
30
30
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
// Add your providers here
|
|
3
|
-
];
|
|
1
|
+
export default [
|
|
2
|
+
// Add your providers here
|
|
3
|
+
];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default [
|
|
2
|
-
// Add your custom routes here
|
|
3
|
-
];
|
|
1
|
+
export default [
|
|
2
|
+
// Add your custom routes here
|
|
3
|
+
];
|
|
@@ -129,9 +129,9 @@ class VendurePluginRef {
|
|
|
129
129
|
pluginOptions
|
|
130
130
|
.addPropertyAssignment({
|
|
131
131
|
name: 'adminApiExtensions',
|
|
132
|
-
initializer: `{
|
|
133
|
-
schema: ${extension.schema.getName()},
|
|
134
|
-
resolvers: [${extension.resolvers.map(r => r.getName()).join(', ')}]
|
|
132
|
+
initializer: `{
|
|
133
|
+
schema: ${extension.schema.getName()},
|
|
134
|
+
resolvers: [${extension.resolvers.map(r => r.getName()).join(', ')}]
|
|
135
135
|
}`,
|
|
136
136
|
})
|
|
137
137
|
.formatText();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "A modern, headless ecommerce framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"graphql",
|
|
14
14
|
"typescript"
|
|
15
15
|
],
|
|
16
|
-
"homepage": "https://www.vendure.io
|
|
16
|
+
"homepage": "https://www.vendure.io",
|
|
17
17
|
"funding": "https://github.com/sponsors/michaelbromley",
|
|
18
18
|
"private": false,
|
|
19
19
|
"license": "GPL-3.0-or-later",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@clack/prompts": "^0.7.0",
|
|
38
|
-
"@vendure/common": "^3.2.
|
|
38
|
+
"@vendure/common": "^3.2.1",
|
|
39
39
|
"change-case": "^4.1.2",
|
|
40
40
|
"commander": "^11.0.0",
|
|
41
41
|
"dotenv": "^16.4.5",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"tsconfig-paths": "^4.2.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@vendure/core": "^3.2.
|
|
49
|
+
"@vendure/core": "^3.2.1",
|
|
50
50
|
"typescript": "5.8.2"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d86ca35d52e64990f5cb17dad476c6315a2e548c"
|
|
53
53
|
}
|