@azure-net/cli 1.3.10 → 1.3.12

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@azure-net/cli",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "azure-net": "bin/azure-net.js"
7
7
  },
8
8
  "dependencies": {
9
- "@azure-net/kit": "^0.1.3",
9
+ "@azure-net/kit": "^0.3.3",
10
10
  "commander": "^11",
11
11
  "ejs": "^3",
12
12
  "prompts": "^2"
@@ -96,7 +96,7 @@ export default async function generateCrud() {
96
96
 
97
97
  // === 1) Abstracts
98
98
  const abstractsDir = path.join(domainPath, 'Abstracts');
99
- for (const file of ['Class', 'ClassCreateRequest', 'ClassUpdateRequest']) {
99
+ for (const file of ['Class', 'ClassCreateRequest', 'ClassUpdateRequest', 'ClassCollectionQuery']) {
100
100
  const tpl = await fs.readFile(path.join(__dirname, `../templates/domain/abstracts/${file}.ejs`), 'utf-8');
101
101
  const result = ejs.render(tpl, templateData);
102
102
  await writeIfNotExists(path.join(abstractsDir, `${capital}${file.replace('Class', '')}.ts`), result);
@@ -123,7 +123,7 @@ export default async function generateCrud() {
123
123
  path.join(domainPath, 'index.ts'),
124
124
  [`export * from './Abstracts';`, `export * from './Request';`].join('\n')
125
125
  );
126
- await updateIndexTs(domainPath);
126
+ //await updateIndexTs(domainPath);
127
127
 
128
128
  // === 5) Repo
129
129
  const repoTpl = await fs.readFile(path.join(__dirname, '../templates/data/repo/ClassRepo.ejs'), 'utf-8');
@@ -1,17 +1,18 @@
1
- import { <%= datasource %> } from '<%= aliasShared %>/datasources';
1
+ import { <%= datasource %> } from '$core/datasources';
2
2
  import type {
3
3
  I<%= pascalCaseName %>Collection,
4
4
  I<%= pascalCaseName %>Resource,
5
5
  I<%= pascalCaseName %>CreateRequest,
6
- I<%= pascalCaseName %>UpdateRequest
6
+ I<%= pascalCaseName %>UpdateRequest,
7
+ I<%= pascalCaseName %>CollectionQuery,
7
8
  } from '<%= aliasDomain %>/<%= pascalCaseName %>';
8
9
 
9
10
  export class <%= pascalCaseName %>Repo {
10
11
  private endpoint = '<%= endpoint %>';
11
12
  constructor(private source = new <%= datasource %>()) {}
12
13
 
13
- public async collection() {
14
- return await this.source.createRequest<I<%= pascalCaseName %>Collection>(({ http }) => http.get(this.endpoint));
14
+ public async collection(queryParams?: I<%= pascalCaseName %>CollectionQuery) {
15
+ return await this.source.createRequest<I<%= pascalCaseName %>Collection>(({ http, query }) => http.get(`${this.endpoint}${query.build(queryParams)}`));
15
16
  }
16
17
 
17
18
  public async resource(id: number) {
@@ -0,0 +1,3 @@
1
+ export interface I<%= pascalCaseName %>CollectionQuery {
2
+ [key: string]: unknown;
3
+ }
@@ -1,14 +1,14 @@
1
1
  import { BaseService } from '@azure-net/kit';
2
2
  import { <%= pascalCaseName %>Repo } from '<%= aliasRepo %>';
3
- import type { <%= pascalCaseName %>CreateRequest, <%= pascalCaseName %>UpdateRequest } from '<%= aliasDomain %>/<%= pascalCaseName %>';
3
+ import type { <%= pascalCaseName %>CreateRequest, <%= pascalCaseName %>UpdateRequest, I<%= pascalCaseName %>CollectionQuery } from '<%= aliasDomain %>/<%= pascalCaseName %>';
4
4
 
5
5
  export class <%= pascalCaseName %>Service extends BaseService {
6
6
  constructor(private <%= camelCaseName %>Repo = new <%= pascalCaseName %>Repo()) {
7
7
  super();
8
8
  }
9
9
 
10
- async collection() {
11
- return await this.transformResponse(this.<%= camelCaseName %>Repo.collection());
10
+ async collection(queryParams?: I<%= pascalCaseName %>CollectionQuery) {
11
+ return await this.transformResponse(this.<%= camelCaseName %>Repo.collection(queryParams));
12
12
  }
13
13
 
14
14
  async resource(id: number) {