@povio/openapi-codegen-cli 1.0.2 → 1.1.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "main": "./dist/index.js",
5
5
  "bin": {
6
6
  "openapi-codegen": "./dist/sh.js"
@@ -8,14 +8,6 @@
8
8
  {{#if includeNamespace}}
9
9
  export namespace {{namespace}} {
10
10
  {{/if}}
11
- {{! Ability types }}
12
- {{#each endpoints as | endpoint |}}
13
- {{{genCaslAbilityType endpoint}}}
14
-
15
- {{/each}}
16
- {{! All abilities type }}
17
- export type AllAbilities =
18
- {{#each endpoints as | endpoint |}} | {{abilityTypeName endpoint}} {{/each}};
19
11
 
20
12
  {{! Ability functions }}
21
13
  {{#each endpoints as | endpoint |}}
@@ -24,4 +16,4 @@ export type AllAbilities =
24
16
  {{/each}}
25
17
  {{#if includeNamespace}}
26
18
  }
27
- {{/if}}
19
+ {{/if}}
@@ -1,17 +1,17 @@
1
1
  {{! Casl AbilityTuple import}}
2
2
  {{{genImport caslAbilityTupleImport}}}
3
- {{! Acl imports }}
4
- {{#each imports as | import |}}
5
- {{{genImport import}}}
3
+ {{! Models import }}
4
+ {{#each modelsImports as | modelsImport |}}
5
+ {{{genImport modelsImport}}}
6
6
  {{/each}}
7
7
 
8
8
  {{! AppAbilities union type }}
9
- export type {{appAbilities}} =
10
- {{#if tags}}
11
- {{#if includeNamespace}}{{#each namespaces as | namespace |}} | {{namespace}}.{{../allAbilities}}{{/each}}
12
- {{else}}{{#each tags as | tag |}} | {{tagAllAbilitiesName tag}}{{/each}}{{/if}}
9
+ export type {{appAbilities}} = {{#if appAbilitiesType}}
10
+ {{#each appAbilitiesType as | appAbilityType |}}
11
+ | {{../abilityTuple}}<"{{@key}}", {{{union appAbilityType}}}>
12
+ {{/each}}
13
13
  {{else}}
14
14
  {{abilityTuple}}<string, {{subjectType}}>;
15
15
  {{/if}}
16
16
 
17
- export type AppAbility = PureAbility<{{appAbilities}}>;
17
+ export type AppAbility = PureAbility<{{appAbilities}}>;
@@ -12,8 +12,7 @@ export namespace {{namespace}} {
12
12
  {{! Js docs }}
13
13
  {{{genModelJsDocs @key zodSchema ../tag}}}
14
14
  {{! Zod schema export }}
15
- export const {{@key}}{{#if zodSchema.isCircular}}: z.ZodType<unknown> // TODO: Fix type inference {{/if}}
16
- = {{{zodSchema.code}}};
15
+ export const {{@key}} = {{{zodSchema.code}}};
17
16
  {{! Zod schema infered type export }}
18
17
  export type {{zodInferedType @key}} = z.infer<typeof {{@key}}>;
19
18
  {{#if zodSchema.isEnum}}export const {{zodInferedType @key}} = {{@key}}.enum;{{/if}}
@@ -2,11 +2,11 @@
2
2
  * Use for {{{genCaslAbilityQuery endpoint}}} ability. {{#if (hasAbilityConditions endpoint)}}For global ability, omit the object parameter.{{/if}}{{#if (abilityDescription endpoint)}}
3
3
  * @description {{abilityDescription endpoint}}{{/if}}
4
4
  {{#if (hasAbilityConditions endpoint)}}{{#each (abilityConditionsTypes endpoint) as | propertyType |}} * @param { {{propertyType.type}}{{propertyType.zodSchemaName}} } object.{{propertyType.name}} {{propertyType.name}} from {{propertyType.info}}
5
- {{/each}}{{/if}} * @returns { {{abilityTypeName endpoint}} } An ability tuple indicating the user's ability to use {{{genCaslAbilityQuery endpoint}}}
5
+ {{/each}}{{/if}} * @returns { AbilityTuple } An ability tuple indicating the user's ability to use {{{genCaslAbilityQuery endpoint}}}
6
6
  */
7
7
  export const {{abilityFunctionName endpoint}} = (
8
8
  {{#if (hasAbilityConditions endpoint)}}object?: { {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}{{#unless propertyType.required}}?{{/unless}}: {{propertyType.type}}{{propertyType.zodSchemaName}}, {{/each}} } {{/if}}
9
9
  ) => [
10
10
  "{{ablityAction endpoint}}",
11
11
  {{#if (hasAbilityConditions endpoint)}}object ? subject("{{ablitySubject endpoint}}", object) : "{{ablitySubject endpoint}}"{{else}}"{{ablitySubject endpoint}}"{{/if}}
12
- ] as {{abilityTypeName endpoint}};
12
+ ] as {{{genCaslAbilityType endpoint}}};
@@ -1,5 +1 @@
1
- type {{abilityTypeName endpoint}} = {{abilityTupleType}}<
2
- "{{ablityAction endpoint}}",
3
- "{{ablitySubject endpoint}}"
4
- {{#if (hasAbilityConditions endpoint)}}| (ForcedSubject<"{{ablitySubject endpoint}}"> & { {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}{{#unless propertyType.required}}?{{/unless}}: {{propertyType.type}}{{propertyType.zodSchemaName}}, {{/each}} }){{/if}}
5
- >;
1
+ {{abilityTuple}}<"{{ablityAction endpoint}}", {{{union (abilitySubjectTypes endpoint)}}}>
@@ -1,2 +0,0 @@
1
- import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
2
- export declare function wrapCircularZodSchemas(resolver: SchemaResolver, zodSchemas: Record<string, string>): Record<string, string>;