@povio/openapi-codegen-cli 2.0.8-rc.8 → 3.0.0-rc.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.
Files changed (49) hide show
  1. package/README.md +29 -4
  2. package/dist/acl.d.mts +12 -1
  3. package/dist/acl.mjs +14 -3
  4. package/dist/{config-Cu_GYfai.d.mts → config-CKmoJbQB.d.mts} +1 -1
  5. package/dist/error-handling-CvW_FecB.d.mts +38 -0
  6. package/dist/error-handling-DkPY7Asf.mjs +187 -0
  7. package/dist/generate.runner-B0iop_CE.mjs +90 -0
  8. package/dist/{generateCodeFromOpenAPIDoc-B5lnFNGB.mjs → generateCodeFromOpenAPIDoc-BKIXvJIW.mjs} +2383 -2070
  9. package/dist/generator.d.mts +1 -1
  10. package/dist/generator.mjs +1 -1
  11. package/dist/index.d.mts +45 -60
  12. package/dist/index.mjs +76 -189
  13. package/dist/{options-DBz5YE3s.d.mts → options-C6CNQ6tq.d.mts} +8 -2
  14. package/dist/sh.mjs +22 -6
  15. package/dist/vite.d.mts +7 -4
  16. package/dist/vite.mjs +9 -6
  17. package/dist/zod.d.mts +20 -0
  18. package/dist/zod.mjs +33 -0
  19. package/package.json +12 -8
  20. package/dist/generate.runner-DNldmk0f.mjs +0 -98
  21. package/src/assets/useCrossTabQueryInvalidation.ts +0 -40
  22. package/src/assets/useMutationEffects.ts +0 -94
  23. package/src/generators/templates/acl-check.hbs +0 -29
  24. package/src/generators/templates/acl.hbs +0 -19
  25. package/src/generators/templates/app-acl.hbs +0 -17
  26. package/src/generators/templates/app-rest-client.hbs +0 -7
  27. package/src/generators/templates/configs.hbs +0 -80
  28. package/src/generators/templates/endpoints.hbs +0 -43
  29. package/src/generators/templates/models.hbs +0 -23
  30. package/src/generators/templates/partials/acl-check-call.hbs +0 -1
  31. package/src/generators/templates/partials/casl-ability-function.hbs +0 -12
  32. package/src/generators/templates/partials/casl-ability-query.hbs +0 -1
  33. package/src/generators/templates/partials/casl-ability-type.hbs +0 -1
  34. package/src/generators/templates/partials/columns-config.hbs +0 -11
  35. package/src/generators/templates/partials/endpoint-config.hbs +0 -31
  36. package/src/generators/templates/partials/endpoint-param-parse.hbs +0 -1
  37. package/src/generators/templates/partials/endpoint-params.hbs +0 -1
  38. package/src/generators/templates/partials/import.hbs +0 -1
  39. package/src/generators/templates/partials/inputs-config.hbs +0 -10
  40. package/src/generators/templates/partials/model-js-docs.hbs +0 -6
  41. package/src/generators/templates/partials/query-js-docs.hbs +0 -31
  42. package/src/generators/templates/partials/query-keys.hbs +0 -11
  43. package/src/generators/templates/partials/query-use-infinite-query.hbs +0 -21
  44. package/src/generators/templates/partials/query-use-mutation.hbs +0 -54
  45. package/src/generators/templates/partials/query-use-query.hbs +0 -16
  46. package/src/generators/templates/queries.hbs +0 -54
  47. package/src/generators/templates/query-modules.hbs +0 -5
  48. package/src/generators/templates/zod-extended.hbs +0 -49
  49. /package/dist/{auth.context-DKjzWiaA.mjs → auth.context-Bu5KW2sI.mjs} +0 -0
package/dist/zod.d.mts ADDED
@@ -0,0 +1,20 @@
1
+ import { r as ErrorHandler } from "./error-handling-CvW_FecB.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/zod.d.ts
5
+ declare namespace ZodExtended {
6
+ interface ParseOptions {
7
+ type: "body" | "query";
8
+ name?: string;
9
+ errorHandler?: ErrorHandler<never>;
10
+ }
11
+ export function parse<ZOutput, ZInput>(schema: z.ZodType<ZOutput, ZInput>, data: unknown, {
12
+ type,
13
+ name,
14
+ errorHandler
15
+ }?: ParseOptions): ZOutput;
16
+ export const sortExp: (enumSchema: z.ZodEnum) => z.ZodString;
17
+ export {};
18
+ }
19
+ //#endregion
20
+ export { ZodExtended };
package/dist/zod.mjs ADDED
@@ -0,0 +1,33 @@
1
+ import { r as SharedErrorHandler } from "./error-handling-DkPY7Asf.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/zod.ts
5
+ let ZodExtended;
6
+ (function(_ZodExtended) {
7
+ function parse(schema, data, { type, name, errorHandler } = { type: "body" }) {
8
+ try {
9
+ return schema.parse(data);
10
+ } catch (e) {
11
+ if (e instanceof z.ZodError) e.name = `FE Request ${type === "body" ? "body" : "query param"}${name ? ` ("${name}")` : ""} schema mismatch - ZodError`;
12
+ (errorHandler ?? SharedErrorHandler).rethrowError(e);
13
+ throw e;
14
+ }
15
+ }
16
+ _ZodExtended.parse = parse;
17
+ function isSortExpValid(enumSchema, data) {
18
+ if (data === void 0 || data === "" || enumSchema.options.length === 0) return true;
19
+ const prefixedEnumOptions = `([+-]?(${enumSchema.options.join("|")}))`;
20
+ const commaSeparatedOptions = `(${prefixedEnumOptions})(\\s*,\\s*${prefixedEnumOptions})*`;
21
+ return new RegExp(`^${commaSeparatedOptions}$`).test(data);
22
+ }
23
+ _ZodExtended.sortExp = (enumSchema) => z.string().superRefine((arg, ctx) => {
24
+ if (!isSortExpValid(enumSchema, arg)) ctx.addIssue({
25
+ code: "invalid_value",
26
+ message: "Invalid sorting string.",
27
+ values: []
28
+ });
29
+ });
30
+ })(ZodExtended || (ZodExtended = {}));
31
+
32
+ //#endregion
33
+ export { ZodExtended };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/openapi-codegen-cli",
3
- "version": "2.0.8-rc.8",
3
+ "version": "3.0.0-rc.1",
4
4
  "keywords": [
5
5
  "codegen",
6
6
  "openapi",
@@ -21,8 +21,7 @@
21
21
  "files": [
22
22
  "README.md",
23
23
  "dist/*",
24
- "src/assets/**",
25
- "src/generators/templates/**"
24
+ "src/assets/**"
26
25
  ],
27
26
  "type": "module",
28
27
  "main": "./dist/index.mjs",
@@ -43,6 +42,10 @@
43
42
  "./acl": {
44
43
  "types": "./dist/acl.d.mts",
45
44
  "import": "./dist/acl.mjs"
45
+ },
46
+ "./zod": {
47
+ "types": "./dist/zod.d.mts",
48
+ "import": "./dist/zod.mjs"
46
49
  }
47
50
  },
48
51
  "scripts": {
@@ -69,15 +72,14 @@
69
72
  },
70
73
  "dependencies": {
71
74
  "@apidevtools/swagger-parser": "^10.1.0",
72
- "handlebars": "^4.7.8",
73
75
  "i18next": "^25.8.13",
74
76
  "import-fresh": "^3.3.1",
77
+ "openapi-types": "^12.1.3",
75
78
  "prompt-sync": "^4.2.0",
76
79
  "reflect-metadata": "^0.2.2",
77
80
  "ts-pattern": "^5.9.0",
78
81
  "typescript": "^5.9.3",
79
- "yargs": "^18.0.0",
80
- "openapi-types": "^12.1.3"
82
+ "yargs": "^18.0.0"
81
83
  },
82
84
  "devDependencies": {
83
85
  "@casl/ability": "^6.8.0",
@@ -97,7 +99,9 @@
97
99
  "type-fest": "^5.4.4",
98
100
  "vite": "npm:rolldown-vite@^7.3.1",
99
101
  "vite-plugin-dts": "^4.5.4",
100
- "vitest": "4.0.18"
102
+ "vitest": "4.0.18",
103
+ "yargs": "^17.7.2",
104
+ "zod": "^4.3.6"
101
105
  },
102
106
  "peerDependencies": {
103
107
  "@casl/ability": "^6.7.3",
@@ -105,7 +109,7 @@
105
109
  "@tanstack/react-query": "^5.90.21",
106
110
  "axios": "^1.13.1",
107
111
  "react": "^19.1.0",
108
- "vite": "^6.0.0 || ^7.0.0",
112
+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
109
113
  "zod": "^4.1.12"
110
114
  },
111
115
  "peerDependenciesMeta": {
@@ -1,98 +0,0 @@
1
- import { a as deepMerge, p as DEFAULT_GENERATE_OPTIONS, r as writeGenerateFileData, t as generateCodeFromOpenAPIDoc, x as Profiler } from "./generateCodeFromOpenAPIDoc-B5lnFNGB.mjs";
2
- import fs from "fs";
3
- import path from "path";
4
- import SwaggerParser from "@apidevtools/swagger-parser";
5
-
6
- //#region src/generators/core/resolveConfig.ts
7
- function resolveConfig({ fileConfig = {}, params: { excludeTags, inlineEndpointsExcludeModules, ...options } }) {
8
- const resolvedConfig = deepMerge(DEFAULT_GENERATE_OPTIONS, fileConfig ?? {}, {
9
- ...options,
10
- excludeTags: excludeTags?.split(","),
11
- inlineEndpointsExcludeModules: inlineEndpointsExcludeModules?.split(",")
12
- });
13
- resolvedConfig.checkAcl = resolvedConfig.acl && resolvedConfig.checkAcl;
14
- return resolvedConfig;
15
- }
16
-
17
- //#endregion
18
- //#region src/generators/run/generate.runner.ts
19
- const CACHE_FILE_NAME = ".openapi-codegen-cache.json";
20
- async function runGenerate({ fileConfig, params, profiler = new Profiler(process.env.OPENAPI_CODEGEN_PROFILE === "1") }) {
21
- const config = profiler.runSync("config.resolve", () => resolveConfig({
22
- fileConfig,
23
- params: params ?? {}
24
- }));
25
- const openApiDoc = await getOpenApiDoc(config.input, profiler);
26
- const openApiHash = hashString(stableStringify(openApiDoc));
27
- const optionsHash = hashString(stableStringify(getCacheableConfig(config)));
28
- const cacheFilePath = path.resolve(config.output, CACHE_FILE_NAME);
29
- if (config.incremental) {
30
- const cached = readCache(cacheFilePath);
31
- if (cached && cached.openApiHash === openApiHash && cached.optionsHash === optionsHash) return {
32
- skipped: true,
33
- config
34
- };
35
- }
36
- const filesData = profiler.runSync("generate.total", () => generateCodeFromOpenAPIDoc(openApiDoc, config, profiler));
37
- profiler.runSync("files.write", () => writeGenerateFileData(filesData));
38
- if (config.incremental) writeCache(cacheFilePath, {
39
- openApiHash,
40
- optionsHash
41
- });
42
- return {
43
- skipped: false,
44
- config
45
- };
46
- }
47
- async function getOpenApiDoc(input, profiler) {
48
- const parsedDoc = await profiler.runAsync("openapi.parse", async () => await SwaggerParser.parse(input));
49
- if (!profiler.runSync("openapi.detectExternalRefs", () => hasExternalRef(parsedDoc))) return parsedDoc;
50
- return await profiler.runAsync("openapi.bundle", async () => await SwaggerParser.bundle(input));
51
- }
52
- function hasExternalRef(value) {
53
- const stack = [value];
54
- const visited = /* @__PURE__ */ new Set();
55
- while (stack.length > 0) {
56
- const current = stack.pop();
57
- if (!current || typeof current !== "object") continue;
58
- if (visited.has(current)) continue;
59
- visited.add(current);
60
- if ("$ref" in current && typeof current.$ref === "string" && !current.$ref.startsWith("#/")) return true;
61
- for (const nested of Object.values(current)) if (nested && typeof nested === "object") stack.push(nested);
62
- }
63
- return false;
64
- }
65
- function getCacheableConfig(config) {
66
- const { output, incremental, ...cacheableConfig } = config;
67
- return cacheableConfig;
68
- }
69
- function readCache(filePath) {
70
- if (!fs.existsSync(filePath)) return null;
71
- try {
72
- return JSON.parse(fs.readFileSync(filePath, "utf-8"));
73
- } catch {
74
- return null;
75
- }
76
- }
77
- function writeCache(filePath, data) {
78
- const dir = path.dirname(filePath);
79
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
80
- fs.writeFileSync(filePath, JSON.stringify(data), "utf-8");
81
- }
82
- function hashString(input) {
83
- let hash = 2166136261;
84
- for (let i = 0; i < input.length; i += 1) {
85
- hash ^= input.charCodeAt(i);
86
- hash = Math.imul(hash, 16777619);
87
- }
88
- return (hash >>> 0).toString(16);
89
- }
90
- function stableStringify(input) {
91
- if (input === null || typeof input !== "object") return JSON.stringify(input);
92
- if (Array.isArray(input)) return `[${input.map((item) => stableStringify(item)).join(",")}]`;
93
- const obj = input;
94
- return `{${Object.keys(obj).sort((a, b) => a.localeCompare(b)).map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`).join(",")}}`;
95
- }
96
-
97
- //#endregion
98
- export { resolveConfig as n, runGenerate as t };
@@ -1,40 +0,0 @@
1
- import type { QueryClient, QueryKey } from "@tanstack/react-query";
2
-
3
- const CROSS_TAB_INVALIDATE_KEY = "__rq_invalidate__";
4
-
5
- /**
6
- * Broadcasts a query invalidation event to all other open tabs via localStorage.
7
- *
8
- * @param queryKeys - An array of query keys to invalidate (array of arrays).
9
- *
10
- * NOTE: The `storage` event only fires in *other* tabs — the calling tab
11
- * must invalidate its own queryClient separately if needed.
12
- */
13
- export const broadcastQueryInvalidation = (queryKeys: QueryKey[]) => {
14
- localStorage.setItem(CROSS_TAB_INVALIDATE_KEY, JSON.stringify({ keys: queryKeys, timestamp: Date.now() }));
15
- };
16
-
17
- /**
18
- * Registers a one-time global `storage` event listener that reacts to
19
- * cross-tab invalidation broadcasts. Safe to call from multiple hooks —
20
- * only the first call sets up the listener.
21
- */
22
- let isListenerSetUp = false;
23
-
24
- export const setupCrossTabListener = (queryClient: QueryClient) => {
25
- if (isListenerSetUp) return;
26
- isListenerSetUp = true;
27
-
28
- window.addEventListener("storage", (e: StorageEvent) => {
29
- if (e.key !== CROSS_TAB_INVALIDATE_KEY || !e.newValue) return;
30
-
31
- try {
32
- const { keys } = JSON.parse(e.newValue) as { keys: QueryKey[] };
33
- for (const queryKey of keys) {
34
- queryClient.invalidateQueries({ queryKey });
35
- }
36
- } catch {
37
- // Ignore malformed payloads
38
- }
39
- });
40
- };
@@ -1,94 +0,0 @@
1
- import { useCallback, useEffect } from "react";
2
-
3
- import { QueryKey, useQueryClient } from "@tanstack/react-query";
4
- import { OpenApiQueryConfig, QueryModule, InvalidationMap } from "../lib/config/queryConfig.context";
5
- import { broadcastQueryInvalidation, setupCrossTabListener } from "./useCrossTabQueryInvalidation";
6
-
7
- export interface MutationEffectsOptions {
8
- invalidateCurrentModule?: boolean;
9
- crossTabInvalidation?: boolean;
10
- invalidationMap?: InvalidationMap;
11
- invalidateModules?: QueryModule[];
12
- invalidateKeys?: QueryKey[];
13
- preferUpdate?: boolean;
14
- }
15
-
16
- export interface UseMutationEffectsProps {
17
- currentModule: QueryModule;
18
- }
19
-
20
- export function useMutationEffects({ currentModule }: UseMutationEffectsProps) {
21
- const queryClient = useQueryClient();
22
- const config = OpenApiQueryConfig.useConfig();
23
-
24
- useEffect(() => {
25
- if (!config.crossTabInvalidation) return;
26
- setupCrossTabListener(queryClient);
27
- }, [queryClient, config.crossTabInvalidation]);
28
-
29
- const runMutationEffects = useCallback(
30
- async <TData, TVariables>(
31
- data: TData,
32
- variables: TVariables,
33
- options: MutationEffectsOptions = {},
34
- updateKeys?: QueryKey[],
35
- ) => {
36
- const { invalidateCurrentModule, invalidateModules, invalidateKeys, preferUpdate } = options;
37
- const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
38
- const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
39
-
40
- const isQueryKeyEqual = (keyA: QueryKey, keyB: QueryKey) =>
41
- keyA.length === keyB.length && keyA.every((item, index) => item === keyB[index]);
42
- const isQueryKeyPrefix = (queryKey: QueryKey, prefixKey: QueryKey) =>
43
- prefixKey.length <= queryKey.length && prefixKey.every((item, index) => item === queryKey[index]);
44
- const mappedInvalidationKeys = config.invalidationMap?.[currentModule]?.(data, variables);
45
-
46
- const shouldInvalidateQuery = (queryKey: QueryKey) => {
47
- const isUpdateKey = updateKeys?.some((key) => isQueryKeyEqual(queryKey, key));
48
- if (shouldUpdate && isUpdateKey) {
49
- return false;
50
- }
51
-
52
- const isCurrentModule = shouldInvalidateCurrentModule && queryKey[0] === currentModule;
53
- const isInvalidateModule = !!invalidateModules && invalidateModules.some((module) => queryKey[0] === module);
54
- const isInvalidateKey = !!invalidateKeys && invalidateKeys.some((key) => isQueryKeyPrefix(queryKey, key));
55
- const isMappedKey =
56
- !!mappedInvalidationKeys && mappedInvalidationKeys.some((key) => isQueryKeyPrefix(queryKey, key));
57
-
58
- return isCurrentModule || isInvalidateModule || isInvalidateKey || isMappedKey;
59
- };
60
-
61
- const invalidatedQueryKeys: QueryKey[] = [];
62
-
63
- queryClient.invalidateQueries({
64
- predicate: ({ queryKey }) => {
65
- const shouldInvalidate = shouldInvalidateQuery(queryKey);
66
-
67
- if (shouldInvalidate && config.crossTabInvalidation) {
68
- invalidatedQueryKeys.push([...queryKey]);
69
- }
70
-
71
- return shouldInvalidate;
72
- },
73
- });
74
-
75
- if (config.crossTabInvalidation && invalidatedQueryKeys.length > 0) {
76
- broadcastQueryInvalidation(invalidatedQueryKeys);
77
- }
78
-
79
- if (shouldUpdate && updateKeys) {
80
- updateKeys.map((queryKey) => queryClient.setQueryData(queryKey, data));
81
- }
82
- },
83
- [
84
- queryClient,
85
- currentModule,
86
- config.preferUpdate,
87
- config.invalidateCurrentModule,
88
- config.invalidationMap,
89
- config.crossTabInvalidation,
90
- ],
91
- );
92
-
93
- return { runMutationEffects };
94
- }
@@ -1,29 +0,0 @@
1
- {{! CASL ability import }}
2
- {{{genImport abilityTupleImport}}}
3
- {{! Error handling import }}
4
- {{{genImport errorHandlingImport}}}
5
- {{! Ability context import }}
6
- {{{genImport abilityContextImport}}}
7
- import { useCallback } from "react";
8
-
9
- {{! App abilities import }}
10
- {{{genImport appAbilitiesImport}}}
11
-
12
- interface UseAclCheckProps {
13
- errorHandler?: {{errorHandler}}<never>;
14
- }
15
-
16
- export function {{aclCheckHook}}({ errorHandler }: UseAclCheckProps = {}) {
17
- const ability = {{abilityContext}}.useAbility{{#if hasGenericAppAbilities}}<{{appAbilities}}>{{/if}}();
18
-
19
- const checkAcl = useCallback(
20
- (appAbility: {{appAbilities}}) => {
21
- if (!ability.can(...(appAbility as {{abilityTuple}}))) {
22
- (errorHandler ?? {{sharedErrorHandler}}).rethrowError(new Error("ACL check failed"));
23
- }
24
- },
25
- [ability, errorHandler],
26
- );
27
-
28
- return { checkAcl };
29
- }
@@ -1,19 +0,0 @@
1
- {{! Casl AbilityTuple import}}
2
- {{{genImport caslAbilityTupleImport}}}
3
- {{! Models import }}
4
- {{#each modelsImports as | modelsImport |}}
5
- {{{genImport modelsImport}}}
6
- {{/each}}
7
-
8
- {{#if includeNamespace}}
9
- export namespace {{namespace}} {
10
- {{/if}}
11
-
12
- {{! Ability functions }}
13
- {{#each endpoints as | endpoint |}}
14
- {{{genCaslAbilityFunction endpoint}}}
15
-
16
- {{/each}}
17
- {{#if includeNamespace}}
18
- }
19
- {{/if}}
@@ -1,17 +0,0 @@
1
- {{! Casl AbilityTuple import}}
2
- {{{genImport caslAbilityTupleImport}}}
3
- {{! Models import }}
4
- {{#each modelsImports as | modelsImport |}}
5
- {{{genImport modelsImport}}}
6
- {{/each}}
7
-
8
- {{! AppAbilities union type }}
9
- export type {{appAbilities}} = {{#if appAbilitiesType}}
10
- {{#each appAbilitiesType as | appAbilityType |}}
11
- | {{../abilityTuple}}<"{{@key}}", {{{union appAbilityType}}}>
12
- {{/each}}
13
- {{else}}
14
- {{abilityTuple}}<string, {{subjectType}}>;
15
- {{/if}}
16
-
17
- export type AppAbility = PureAbility<{{appAbilities}}>;
@@ -1,7 +0,0 @@
1
- import { RestClient } from "{{restClientImportPath}}";
2
-
3
- export const {{appRestClientName}} = new RestClient({
4
- config: {
5
- baseURL: "{{baseUrl}}"
6
- },
7
- });
@@ -1,80 +0,0 @@
1
- {{! Zod import }}
2
- {{#if hasZodImport}}
3
- {{{genImport zodImport}}}
4
- {{/if}}
5
- {{! Dynamic inputs import }}
6
- {{#if hasDynamicInputsImport}}
7
- {{{genImport dynamicInputsImport}}}
8
- {{/if}}
9
- {{! Dynamic columns import }}
10
- {{#if hasDynamicColumnsImport}}
11
- {{{genImport dynamicColumnsImport}}}
12
- {{/if}}
13
- {{! Models import }}
14
- {{#each modelsImports as | modelsImport |}}
15
- {{{genImport modelsImport}}}
16
- {{/each}}
17
- {{! Queries import }}
18
- {{#each queriesImports as | queriesImport |}}
19
- {{{genImport queriesImport}}}
20
- {{/each}}
21
- {{! Acl import }}
22
- {{#each aclImports as | aclImport |}}
23
- {{{genImport aclImport}}}
24
- {{/each}}
25
-
26
- {{#if includeNamespace}}
27
- export namespace {{namespace}} {
28
- {{/if}}
29
- {{! Configs export }}
30
- {{#each configs as |config|}}
31
- export const {{config.name}} = {
32
- meta: {
33
- title: "{{{config.title}}}",
34
- },
35
- readAll: {
36
- {{#if config.readAll.acl}} acl: {{{config.readAll.acl}}},
37
- {{/if}} schema: {{{config.readAll.columns.schema}}},
38
- paginated: {{{config.readAll.paginated}}}, {{#if config.readAll.infinite}}
39
- infinite: {{{config.readAll.infinite}}},
40
- {{/if}} {{#if config.readAll.filters}} filters: {
41
- schema: {{{config.readAll.filters.schema}}},
42
- filterDefs: {{../dynamicInputs}}({{{genInputsConfig config.readAll.filters}}})
43
- },
44
- {{/if}} columns: {{../dynamicColumns}}({{{genColumnsConfig config.readAll.columns}}}),
45
- }, {{#if config.read}}
46
- read: {
47
- {{#if config.read.acl}} acl: {{{config.read.acl}}},
48
- {{/if}} schema: {{{config.read.schema}}},
49
- query: {{{config.read.query}}},
50
- },{{/if}} {{#if config.create}}
51
- create: {
52
- {{#if config.create.acl}} acl: {{{config.create.acl}}},
53
- {{/if}} {{#if config.create.inputDefs}} schema: {{{config.create.inputDefs.schema}}},
54
- {{/if}} mutation: {{{config.create.mutation}}},
55
- {{#if config.create.inputDefs}} inputDefs: {{../dynamicInputs}}({{{genInputsConfig config.create.inputDefs}}})
56
- {{/if}}
57
- },{{/if}} {{#if config.update}}
58
- update: {
59
- {{#if config.update.acl}} acl: {{{config.update.acl}}},
60
- {{/if}} {{#if config.update.inputDefs}} schema: {{{config.update.inputDefs.schema}}},
61
- {{/if}} mutation: {{{config.update.mutation}}},
62
- {{#if config.update.inputDefs}} inputDefs: {{../dynamicInputs}}({{{genInputsConfig config.update.inputDefs}}})
63
- {{/if}}
64
- },{{/if}} {{#if config.delete}}
65
- delete: {
66
- {{#if config.delete.acl}} acl: {{{config.delete.acl}}},
67
- {{/if}} mutation: {{{config.delete.mutation}}},
68
- },{{/if}} {{!-- {{#if config.bulkDelete}}
69
- bulkDelete: {
70
- {{#if config.bulkDelete.acl}} acl: {{{config.bulkDelete.acl}}},
71
- {{/if}} mutation: {{{config.bulkDelete.mutation}}},
72
- {{#if config.bulkDelete.inputDefs}} inputDefs: {{../dynamicInputs}}({{{genInputsConfig config.bulkDelete.inputDefs}}})
73
- {{/if}}
74
- },{{/if}} --}}
75
- };
76
-
77
- {{/each}}
78
- {{#if includeNamespace}}
79
- }
80
- {{/if}}
@@ -1,43 +0,0 @@
1
- {{! App rest client import}}
2
- {{{genImport appRestClientImport}}}
3
- {{! Axios import }}
4
- {{#if hasAxiosImport}}
5
- {{{genImport axiosImport}}}
6
- {{/if}}
7
- {{! Zod import }}
8
- {{#if hasZodImport}}
9
- {{{genImport zodImport}}}
10
- {{/if}}
11
- {{! Zod extended import }}
12
- {{#if hasZodExtendedImport}}
13
- {{{genImport zodExtendedImport}}}
14
- {{/if}}
15
- {{! Models import }}
16
- {{#each modelsImports as | modelsImport |}}
17
- {{{genImport modelsImport}}}
18
- {{/each}}
19
-
20
- {{#if includeNamespace}}
21
- export namespace {{namespace}} {
22
- {{/if}}
23
- {{! Endpoints export }}
24
- {{#each endpoints as | endpoint |}}
25
- export const {{endpointName endpoint}} = ({{{genEndpointParams endpoint}}}{{#if ../hasAxiosRequestConfig}}{{../axiosRequestConfigName}}?: {{../axiosRequestConfigType}}{{/if}}) => {
26
- return {{../restClientName}}.{{endpoint.method}}(
27
- {{! Response }}
28
- { resSchema: {{importedZodSchemaName endpoint.response}} },
29
- {{! Path }}
30
- `{{endpointPath endpoint}}`,
31
- {{! Body }}
32
- {{#with (endpointBody endpoint) as | endpointBody |}}
33
- {{#if endpointBody}}{{#if ../../generateParse}}{{{genEndpointParamParse endpointBody endpointBody.name}}}{{else}}{{endpointBody.name}}{{/if}}, {{/if}}
34
- {{/with}}
35
- {{#if (hasUndefinedEndpointBody endpoint)}} undefined,
36
- {{! Config }}
37
- {{/if}}{{{genEndpointConfig endpoint}}}
38
- )
39
- };
40
- {{/each}}
41
- {{#if includeNamespace}}
42
- }
43
- {{/if}}
@@ -1,23 +0,0 @@
1
- {{! Zod import}}
2
- {{{genImport zodImport}}}
3
- {{! Models import }}
4
- {{#each modelsImports as | modelsImport |}}
5
- {{{genImport modelsImport}}}
6
- {{/each}}
7
-
8
- {{#if includeNamespace}}
9
- export namespace {{namespace}} {
10
- {{/if}}
11
- {{#each zodSchemasData as | zodSchema |}}
12
- {{! Js docs }}
13
- {{{genModelJsDocs @key zodSchema ../tag}}}
14
- {{! Zod schema export }}
15
- export const {{@key}} = {{{zodSchema.code}}};
16
- {{! Zod schema infered type export }}
17
- export type {{zodInferedType @key}} = z.infer<typeof {{@key}}>;
18
- {{#if zodSchema.isEnum}}export const {{zodInferedType @key}} = {{@key}}.enum;{{/if}}
19
-
20
- {{/each}}
21
- {{#if includeNamespace}}
22
- }
23
- {{/if}}
@@ -1 +0,0 @@
1
- checkAcl({{importedAbilityFunctionName endpoint}}({{#if generateAclCheckParams}}{ {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}, {{/each}} } {{/if}}));
@@ -1,12 +0,0 @@
1
- /**
2
- * Use for {{{genCaslAbilityQuery endpoint}}} ability. {{#if (hasAbilityConditions endpoint)}}For global ability, omit the object parameter.{{/if}}{{#if (abilityDescription endpoint)}}
3
- * @description {{abilityDescription endpoint}}{{/if}}
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 { AbilityTuple } An ability tuple indicating the user's ability to use {{{genCaslAbilityQuery endpoint}}}
6
- */
7
- export const {{abilityFunctionName endpoint}} = (
8
- {{#if (hasAbilityConditions endpoint)}}object?: { {{#each (abilityConditionsTypes endpoint) as | propertyType |}}{{propertyType.name}}{{#unless propertyType.required}}?{{/unless}}: {{propertyType.type}}{{propertyType.zodSchemaName}}, {{/each}} } {{/if}}
9
- ) => [
10
- "{{ablityAction endpoint}}",
11
- {{#if (hasAbilityConditions endpoint)}}object ? subject("{{ablitySubject endpoint}}", object) : "{{ablitySubject endpoint}}"{{else}}"{{ablitySubject endpoint}}"{{/if}}
12
- ] as {{{genCaslAbilityType endpoint}}};
@@ -1 +0,0 @@
1
- {{#if (isQuery endpoint)}}{{#if (isMutation endpoint)}}`{{queryName endpoint}}` query or `{{queryName endpoint mutation=true}}` mutation{{else}}`{{queryName endpoint}}` query{{/if}}{{else}}`{{queryName endpoint}}` mutation{{/if}}
@@ -1 +0,0 @@
1
- {{abilityTuple}}<"{{ablityAction endpoint}}", {{{union (abilitySubjectTypes endpoint)}}}>
@@ -1,11 +0,0 @@
1
- {
2
- schema: {{columnsConfig.schema}},
3
- options: {
4
- columns: {
5
- {{#each columnsConfig.options.columns}}
6
- {{@key}}: true,
7
- {{/each}}
8
- }, {{#if columnsConfig.options.sortable}}
9
- sortable: {{columnsConfig.options.sortable}}, {{/if}}
10
- }
11
- }
@@ -1,31 +0,0 @@
1
- {
2
- {{! Query params}}
3
- {{#if hasAxiosRequestConfig}}
4
- ...{{axiosRequestConfigName}},
5
- {{/if}}
6
- {{#if endpointConfig.params}}
7
- params: {
8
- {{#each endpointConfig.params as | param |}}
9
- {{#if (isEqual param.name param.value) }}
10
- {{{param.name}}}{{#if ../generateParse}}: {{{genEndpointParamParse param param.name}}}{{/if}},
11
- {{else}}
12
- {{{param.name}}}: {{#if ../generateParse}}{{{genEndpointParamParse param param.value}}}{{else}}{{param.value}}{{/if}},
13
- {{/if}}
14
- {{/each}}
15
- },
16
- {{/if}}
17
- {{! Headers}}
18
- {{#if endpointConfig.headers}}
19
- headers: {
20
- {{#each endpointConfig.headers as | header |}}
21
- '{{@key}}': {{{header}}},
22
- {{/each}}
23
- },
24
- {{/if}}
25
- {{#if hasBlobResponse}}
26
- responseType: "blob",
27
- {{/if}}
28
- {{#if hasFileDownload}}
29
- rawResponse: true,
30
- {{/if}}
31
- }
@@ -1 +0,0 @@
1
- {{zodExtendedNamespace}}.{{parse}}({{#if param.parameterSortingEnumSchemaName}}{{zodExtendedNamespace}}.{{sortExp}}({{{importedZodSchemaName param.parameterSortingEnumSchemaName}}}){{#if addOptional}}.optional(){{/if}}{{else}}{{{importedZodSchemaName param.zodSchema}}}{{#if addOptional}}.optional(){{/if}}{{/if}}, {{paramName}}{{#if isQuery}}, { type: "query", name: "{{paramName}}" }{{/if}})
@@ -1 +0,0 @@
1
- {{#each (endpointParams endpoint options) as | endpointParam |}}{{endpointParam.name}}{{#unless endpointParam.required}}?{{/unless}}: {{endpointParam.type}}, {{/each}}
@@ -1 +0,0 @@
1
- import {{importNames import.bindings import.defaultImport}} from "{{import.from}}";
@@ -1,10 +0,0 @@
1
- {
2
- schema: {{inputsConfig.schema}},
3
- options: {
4
- inputs: {
5
- {{#each inputsConfig.options.inputs}}
6
- {{@key}}: true,
7
- {{/each}}
8
- }
9
- }
10
- }