@vendure/cli 2.2.0-next.6 → 2.2.0-next.7

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.
@@ -2,78 +2,78 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderServiceWithEntity = exports.renderService = void 0;
4
4
  function renderService(context) {
5
- return `
6
- import { Inject, Injectable } from '@nestjs/common';
7
- import { RequestContext, TransactionalConnection } from '@vendure/core';
8
-
9
- import { ${context.pluginInitOptionsName} } from '../constants';
10
- import { PluginInitOptions } from '../types';
11
-
12
- @Injectable()
13
- export class ${context.service.className} {
14
- constructor(
15
- private connection: TransactionalConnection,
16
- @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
17
- ) {}
18
-
19
- async exampleMethod(
20
- ctx: RequestContext,
21
- options?: { input?: string },
22
- ): Promise<string> {
23
- return options?.input ? 'Hello \${options.input}' : 'Hello World';
24
- }
25
- }
5
+ return `
6
+ import { Inject, Injectable } from '@nestjs/common';
7
+ import { RequestContext, TransactionalConnection, patchEntity } from '@vendure/core';
8
+
9
+ import { ${context.pluginInitOptionsName} } from '../constants';
10
+ import { PluginInitOptions } from '../types';
11
+
12
+ @Injectable()
13
+ export class ${context.service.className} {
14
+ constructor(
15
+ private connection: TransactionalConnection,
16
+ @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
17
+ ) {}
18
+
19
+ async exampleMethod(
20
+ ctx: RequestContext,
21
+ options?: { input?: string },
22
+ ): Promise<string> {
23
+ return options?.input ? 'Hello \${options.input}' : 'Hello World';
24
+ }
25
+ }
26
26
  `;
27
27
  }
28
28
  exports.renderService = renderService;
29
29
  function renderServiceWithEntity(context) {
30
- return `
31
- import { Inject, Injectable } from '@nestjs/common';
32
- import { ListQueryBuilder, ListQueryOptions, PaginatedList, RequestContext, TransactionalConnection } from '@vendure/core';
33
-
34
- import { ${context.customEntityName} } from '../entities/${context.entity.fileName}';
35
- import { ${context.pluginInitOptionsName} } from '../constants';
36
- import { PluginInitOptions } from '../types';
37
-
38
- // TODO: Set up graphql-code-generator to generate the types for the following inputs
39
- type Create${context.customEntityName}Input = any;
40
- type Update${context.customEntityName}Input = any;
41
-
42
- @Injectable()
43
- export class ${context.service.className} {
44
- constructor(
45
- private connection: TransactionalConnection,
46
- @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
47
- private listQueryBuilder: ListQueryBuilder,
48
- ) {}
49
-
50
- async findAll(
51
- ctx: RequestContext,
52
- options?: ListQueryOptions<${context.customEntityName}>,
53
- ): Promise<PaginatedList<${context.customEntityName}>> {
54
- return this.listQueryBuilder
55
- .build(${context.customEntityName}, options, { ctx })
56
- .getManyAndCount()
57
- .then(([items, totalItems]) => ({
58
- items,
59
- totalItems,
60
- }));
61
- }
62
-
63
- async findOne(ctx: RequestContext, id: string): Promise<${context.customEntityName} | null> {
64
- return this.connection.getRepository(ctx, ${context.customEntityName}).findOne({ where: { id } });
65
- }
66
-
67
- async create(ctx: RequestContext, input: Create${context.customEntityName}Input): Promise<${context.customEntityName}> {
68
- return this.connection.getRepository(ctx, ${context.customEntityName}).save(new ${context.customEntityName}(input));
69
- }
70
-
71
- async update(ctx: RequestContext, input: Update${context.customEntityName}Input): Promise<${context.customEntityName}> {
72
- const example = await this.connection.getEntityOrThrow(ctx, ${context.customEntityName}, input.id);
73
- const updated = { ...example, ...input };
74
- return this.connection.getRepository(ctx, ${context.customEntityName}).save(updated);
75
- }
76
- }
30
+ return `
31
+ import { Inject, Injectable } from '@nestjs/common';
32
+ import { ListQueryBuilder, ListQueryOptions, PaginatedList, RequestContext, TransactionalConnection } from '@vendure/core';
33
+
34
+ import { ${context.customEntityName} } from '../entities/${context.entity.fileName}';
35
+ import { ${context.pluginInitOptionsName} } from '../constants';
36
+ import { PluginInitOptions } from '../types';
37
+
38
+ // TODO: Set up graphql-code-generator to generate the types for the following inputs
39
+ type Create${context.customEntityName}Input = any;
40
+ type Update${context.customEntityName}Input = any;
41
+
42
+ @Injectable()
43
+ export class ${context.service.className} {
44
+ constructor(
45
+ private connection: TransactionalConnection,
46
+ @Inject(${context.pluginInitOptionsName}) private options: PluginInitOptions,
47
+ private listQueryBuilder: ListQueryBuilder,
48
+ ) {}
49
+
50
+ async findAll(
51
+ ctx: RequestContext,
52
+ options?: ListQueryOptions<${context.customEntityName}>,
53
+ ): Promise<PaginatedList<${context.customEntityName}>> {
54
+ return this.listQueryBuilder
55
+ .build(${context.customEntityName}, options, { ctx })
56
+ .getManyAndCount()
57
+ .then(([items, totalItems]) => ({
58
+ items,
59
+ totalItems,
60
+ }));
61
+ }
62
+
63
+ async findOne(ctx: RequestContext, id: string): Promise<${context.customEntityName} | null> {
64
+ return this.connection.getRepository(ctx, ${context.customEntityName}).findOne({ where: { id } });
65
+ }
66
+
67
+ async create(ctx: RequestContext, input: Create${context.customEntityName}Input): Promise<${context.customEntityName}> {
68
+ return this.connection.getRepository(ctx, ${context.customEntityName}).save(new ${context.customEntityName}(input));
69
+ }
70
+
71
+ async update(ctx: RequestContext, input: Update${context.customEntityName}Input): Promise<${context.customEntityName}> {
72
+ const example = await this.connection.getEntityOrThrow(ctx, ${context.customEntityName}, input.id);
73
+ const updated = patchEntity(example, input);
74
+ return this.connection.getRepository(ctx, ${context.customEntityName}).save(updated);
75
+ }
76
+ }
77
77
  `;
78
78
  }
79
79
  exports.renderServiceWithEntity = renderServiceWithEntity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure/cli",
3
- "version": "2.2.0-next.6",
3
+ "version": "2.2.0-next.7",
4
4
  "description": "A modern, headless ecommerce framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@clack/prompts": "^0.7.0",
38
- "@vendure/common": "2.2.0-next.6",
38
+ "@vendure/common": "2.2.0-next.7",
39
39
  "change-case": "^4.1.2",
40
40
  "commander": "^11.0.0",
41
41
  "fs-extra": "^11.2.0",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "typescript": "5.3.3"
47
47
  },
48
- "gitHead": "2357477d705829080cfa912db0cf04eedadeaa6e"
48
+ "gitHead": "76da4f48ebb5f8dc7236a30d037549da5197cc54"
49
49
  }