@povio/openapi-codegen-cli 3.3.0-rc.2 → 3.3.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.
Files changed (68) hide show
  1. package/README.md +125 -9
  2. package/dist/AuthGuard-GbtTDXs0.d.mts +32 -0
  3. package/dist/AuthGuard-qpAtHaBz.mjs +24 -0
  4. package/dist/acl.d.mts +6 -19
  5. package/dist/acl.mjs +7 -7
  6. package/dist/{auth.context-BAz8frX9.mjs → auth.context-COWO6ssl.mjs} +1 -18
  7. package/dist/auth.d.mts +2 -0
  8. package/dist/auth.mjs +3 -0
  9. package/dist/axios.d.mts +2 -0
  10. package/dist/axios.mjs +2 -0
  11. package/dist/{config-BQqze8rU.d.mts → config-FD2Y872S.d.mts} +1 -2
  12. package/dist/config.d.mts +4 -0
  13. package/dist/config.mjs +5 -0
  14. package/dist/{error-handling-D6ZYITQ3.d.mts → error-handling-LPEPQV1V.d.mts} +3 -42
  15. package/dist/{error-handling-CsnufAil.mjs → error-handling-uS0DgYUR.mjs} +23 -47
  16. package/dist/errors.d.mts +3 -0
  17. package/dist/errors.mjs +2 -0
  18. package/dist/generate.runner-CLK1FoLT.mjs +1669 -0
  19. package/dist/generate.utils-BSDYGp-0.cjs +2270 -0
  20. package/dist/{generateCodeFromOpenAPIDoc-SYuVswEJ.mjs → generateCodeFromOpenAPIDoc-BypeVKIE.cjs} +1496 -2258
  21. package/dist/generateCodeFromOpenAPIDoc-CDyGSv2w.mjs +2242 -0
  22. package/dist/generator.d.mts +3 -10
  23. package/dist/generator.mjs +6 -4
  24. package/dist/getDataFromOpenAPIDoc-DYiCTWno.mjs +2016 -0
  25. package/dist/i18n-B_brQh4X.d.mts +38 -0
  26. package/dist/i18n-D-FesqFb.mjs +36 -0
  27. package/dist/index.d.mts +12 -198
  28. package/dist/index.mjs +12 -256
  29. package/dist/metro.cjs +118 -4862
  30. package/dist/metro.d.mts +3 -4
  31. package/dist/metro.mjs +3 -3
  32. package/dist/native-rest-interceptor-Np4Ov54n.mjs +215 -0
  33. package/dist/native-rest-interceptor-PgziZt1f.d.mts +49 -0
  34. package/dist/native.d.mts +3 -0
  35. package/dist/native.mjs +3 -0
  36. package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
  37. package/dist/openapi-codegen-native-linux-x64.node +0 -0
  38. package/dist/openapi-codegen-native-win32-x64.node +0 -0
  39. package/dist/{openapi-codegen.runner-CCXQsUum.mjs → openapi-codegen.runner-DUqQD2B5.mjs} +2 -2
  40. package/dist/{openapi-source.runner-B6KKrXw7.d.mts → openapi-source.runner-Bje-tMOV.d.mts} +2 -8
  41. package/dist/{openapi-source.runner-8kCe-g9S.mjs → openapi-source.runner-DPUNTduQ.mjs} +25 -11
  42. package/dist/{options-DdQJ9BSc.d.mts → options-rz2bcsaN.d.mts} +10 -1
  43. package/dist/query.d.mts +3 -0
  44. package/dist/query.mjs +3 -0
  45. package/dist/queryConfig.context-CRJOgf19.d.mts +22 -0
  46. package/dist/queryConfig.context-CldQ5YL9.mjs +34 -0
  47. package/dist/rest-client-CQyFvqYC.d.mts +55 -0
  48. package/dist/rest-interceptor-Dm9DFErh.mjs +115 -0
  49. package/dist/rest-transport.types-DM5-qyOJ.d.mts +66 -0
  50. package/dist/rest-transport.types-DxitRtsB.mjs +11 -0
  51. package/dist/rest.d.mts +2 -0
  52. package/dist/rest.mjs +2 -0
  53. package/dist/rest.utils-DpiFIdhF.d.mts +9 -0
  54. package/dist/router.context-EPlMBk3G.mjs +21 -0
  55. package/dist/sh.d.mts +1 -1
  56. package/dist/sh.mjs +50 -55
  57. package/dist/tiny.d.mts +1 -1
  58. package/dist/tiny.mjs +1 -1
  59. package/dist/useMutationEffects-DIdL8tlx.d.mts +29 -0
  60. package/dist/useMutationEffects-PB1fvKWM.mjs +68 -0
  61. package/dist/vite.d.mts +3 -4
  62. package/dist/vite.mjs +5 -4
  63. package/dist/workspace.context-XWvQ_7Hg.mjs +26 -0
  64. package/dist/workspace.context-isVY9ves.d.mts +23 -0
  65. package/dist/zod.d.mts +2 -7
  66. package/dist/zod.mjs +1 -1
  67. package/package.json +67 -19
  68. package/dist/generate.runner-B0Zm3pIl.mjs +0 -87
@@ -0,0 +1,115 @@
1
+ import { i as SharedErrorHandler } from "./error-handling-uS0DgYUR.mjs";
2
+ import axios from "axios";
3
+ import { z } from "zod";
4
+ //#region src/lib/rest/rest-client.ts
5
+ var RestClient = class {
6
+ client;
7
+ errorHandler;
8
+ constructor({ config, interceptors, errorHandler } = {}) {
9
+ this.client = axios.create(config);
10
+ this.errorHandler = errorHandler ?? SharedErrorHandler;
11
+ this.attachInterceptors(interceptors);
12
+ }
13
+ attachInterceptors(interceptors, ...args) {
14
+ if (interceptors != null) interceptors.forEach((interceptor) => this.attachInterceptor(interceptor, ...args));
15
+ }
16
+ attachInterceptor(interceptor, ...args) {
17
+ interceptor.addInterceptor(this.client, ...args);
18
+ }
19
+ ejectInterceptor(interceptor) {
20
+ interceptor.removeInterceptor(this.client);
21
+ }
22
+ async get(requestInfo, url, requestConfig) {
23
+ return this.makeRequest(requestInfo, {
24
+ ...requestConfig,
25
+ method: "get",
26
+ url
27
+ });
28
+ }
29
+ async post(requestInfo, url, data, requestConfig) {
30
+ return this.makeRequest(requestInfo, {
31
+ ...requestConfig,
32
+ method: "post",
33
+ url,
34
+ data
35
+ });
36
+ }
37
+ async patch(requestInfo, url, data, requestConfig) {
38
+ return this.makeRequest(requestInfo, {
39
+ ...requestConfig,
40
+ method: "patch",
41
+ url,
42
+ data
43
+ });
44
+ }
45
+ async put(requestInfo, url, data, requestConfig) {
46
+ return this.makeRequest(requestInfo, {
47
+ ...requestConfig,
48
+ method: "put",
49
+ url,
50
+ data
51
+ });
52
+ }
53
+ async delete(requestInfo, url, data, requestConfig) {
54
+ return this.makeRequest(requestInfo, {
55
+ ...requestConfig,
56
+ method: "delete",
57
+ url,
58
+ data
59
+ });
60
+ }
61
+ async makeRequest(requestInfo, requestConfig) {
62
+ const errorStack = (/* @__PURE__ */ new Error()).stack;
63
+ try {
64
+ const { rawResponse, allowInvalidResponseData, ...config } = requestConfig;
65
+ const res = await this.client(config);
66
+ const responseData = res.status === 204 && res.data === "" ? void 0 : res.data;
67
+ const parseResult = requestInfo.resSchema.safeParse(responseData);
68
+ let resData;
69
+ if (parseResult.success) resData = parseResult.data;
70
+ else if (allowInvalidResponseData && config.method === "get") {
71
+ parseResult.error.name = "BE Response schema mismatch - ZodError";
72
+ parseResult.error.stack = [parseResult.error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
73
+ console.error(parseResult.error);
74
+ resData = res.data;
75
+ } else throw parseResult.error;
76
+ return rawResponse ? {
77
+ ...res,
78
+ data: resData
79
+ } : resData;
80
+ } catch (error) {
81
+ if (error instanceof z.ZodError) {
82
+ error.name = "BE Response schema mismatch - ZodError";
83
+ error.stack = [error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
84
+ }
85
+ (requestInfo.errorHandler ?? this.errorHandler).rethrowError(error);
86
+ throw error;
87
+ }
88
+ }
89
+ };
90
+ //#endregion
91
+ //#region src/lib/rest/rest-interceptor.ts
92
+ var RestInterceptor = class {
93
+ applyInterceptor;
94
+ interceptorIdMap = [];
95
+ constructor(applyInterceptor) {
96
+ this.applyInterceptor = applyInterceptor;
97
+ }
98
+ addInterceptor(client, ...args) {
99
+ this.removeInterceptor(client);
100
+ const interceptorId = this.applyInterceptor(client, ...args);
101
+ this.interceptorIdMap.push({
102
+ client,
103
+ interceptorId
104
+ });
105
+ }
106
+ removeInterceptor(client) {
107
+ const interceptorId = this.interceptorIdMap.find((i) => i.client === client)?.interceptorId;
108
+ if (interceptorId != null) {
109
+ client.interceptors.request.eject(interceptorId);
110
+ this.interceptorIdMap = this.interceptorIdMap.filter((i) => i.client !== client);
111
+ }
112
+ }
113
+ };
114
+ //#endregion
115
+ export { RestClient as n, RestInterceptor as t };
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ //#region src/lib/rest/rest-transport.types.d.ts
3
+ type GeneralTransportErrorCode = "DATA_VALIDATION_ERROR" | "NETWORK_ERROR" | "CANCELED_ERROR" | "INTERNAL_ERROR" | "UNKNOWN_ERROR";
4
+ type RestResponseType = "json" | "text" | "blob" | "arrayBuffer";
5
+ type TransportFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
6
+ interface UploadProgress {
7
+ loaded: number;
8
+ total: number;
9
+ }
10
+ interface TransportRequestConfig<IsRawRes extends boolean = false> {
11
+ headers?: HeadersInit;
12
+ params?: Record<string, unknown>;
13
+ signal?: AbortSignal;
14
+ timeout?: number;
15
+ credentials?: RequestCredentials;
16
+ responseType?: RestResponseType;
17
+ rawResponse?: IsRawRes;
18
+ allowInvalidResponseData?: boolean;
19
+ onUploadProgress?: (progress: UploadProgress) => void;
20
+ }
21
+ interface TransportResponse<T> {
22
+ data: T;
23
+ status: number;
24
+ statusText: string;
25
+ headers: Headers;
26
+ url: string;
27
+ }
28
+ interface RestRequestInfo<ZOutput, ECodes extends string> {
29
+ resSchema: z.ZodType<ZOutput>;
30
+ }
31
+ interface TransportRequest {
32
+ url: string;
33
+ method: string;
34
+ headers: Headers;
35
+ body?: BodyInit | null;
36
+ signal?: AbortSignal;
37
+ credentials?: RequestCredentials;
38
+ retryCount?: number;
39
+ }
40
+ interface TransportErrorContext {
41
+ request: TransportRequest;
42
+ response?: TransportResponse<unknown>;
43
+ retry(request?: TransportRequest): Promise<TransportResponse<unknown>>;
44
+ }
45
+ interface RestTransportInterceptor {
46
+ onRequest?(request: TransportRequest): TransportRequest | Promise<TransportRequest>;
47
+ onResponse?<T>(response: TransportResponse<T>): TransportResponse<T> | Promise<TransportResponse<T>>;
48
+ onError?(error: unknown, context: TransportErrorContext): unknown | Promise<unknown>;
49
+ }
50
+ type TransportResult<T, IsRawRes extends boolean> = IsRawRes extends true ? TransportResponse<T> : T;
51
+ interface RestTransport {
52
+ attachInterceptor(interceptor: RestTransportInterceptor): void;
53
+ ejectInterceptor(interceptor: RestTransportInterceptor): void;
54
+ get<T, E extends string, R extends boolean = false>(info: RestRequestInfo<T, E>, url: string, config?: TransportRequestConfig<R>): Promise<TransportResult<T, R>>;
55
+ post<T, E extends string, R extends boolean = false>(info: RestRequestInfo<T, E>, url: string, data?: unknown, config?: TransportRequestConfig<R>): Promise<TransportResult<T, R>>;
56
+ patch<T, E extends string, R extends boolean = false>(info: RestRequestInfo<T, E>, url: string, data?: unknown, config?: TransportRequestConfig<R>): Promise<TransportResult<T, R>>;
57
+ put<T, E extends string, R extends boolean = false>(info: RestRequestInfo<T, E>, url: string, data?: unknown, config?: TransportRequestConfig<R>): Promise<TransportResult<T, R>>;
58
+ delete<T, E extends string, R extends boolean = false>(info: RestRequestInfo<T, E>, url: string, data?: unknown, config?: TransportRequestConfig<R>): Promise<TransportResult<T, R>>;
59
+ upload(url: string, data: BodyInit, config?: TransportRequestConfig, method?: "put" | "post"): Promise<void>;
60
+ }
61
+ declare class HttpError<T = unknown> extends Error {
62
+ readonly response: TransportResponse<T>;
63
+ constructor(message: string, response: TransportResponse<T>);
64
+ }
65
+ //#endregion
66
+ export { RestTransport as a, TransportFetch as c, TransportResponse as d, TransportResult as f, RestResponseType as i, TransportRequest as l, HttpError as n, RestTransportInterceptor as o, UploadProgress as p, RestRequestInfo as r, TransportErrorContext as s, GeneralTransportErrorCode as t, TransportRequestConfig as u };
@@ -0,0 +1,11 @@
1
+ //#region src/lib/rest/rest-transport.types.ts
2
+ var HttpError = class extends Error {
3
+ response;
4
+ constructor(message, response) {
5
+ super(message);
6
+ this.response = response;
7
+ this.name = "HttpError";
8
+ }
9
+ };
10
+ //#endregion
11
+ export { HttpError as t };
@@ -0,0 +1,2 @@
1
+ import { a as RestTransport, d as TransportResponse, f as TransportResult, i as RestResponseType, l as TransportRequest, n as HttpError, o as RestTransportInterceptor, p as UploadProgress, r as RestRequestInfo, t as GeneralTransportErrorCode, u as TransportRequestConfig } from "./rest-transport.types-DM5-qyOJ.mjs";
2
+ export { type GeneralTransportErrorCode, HttpError, type RestRequestInfo, type RestResponseType, type RestTransport, type RestTransportInterceptor, type TransportRequest, type TransportRequestConfig, type TransportResponse, type TransportResult, type UploadProgress };
package/dist/rest.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { t as HttpError } from "./rest-transport.types-DxitRtsB.mjs";
2
+ export { HttpError };
@@ -0,0 +1,9 @@
1
+ //#region src/lib/rest/rest.utils.d.ts
2
+ declare namespace RestUtils {
3
+ const extractServerResponseCode: (e: unknown) => string | number | null;
4
+ const doesServerErrorMessageContain: (e: unknown, text: string) => boolean;
5
+ const extractServerErrorMessage: (e: unknown) => string | null;
6
+ const extractContentDispositionFilename: (headers: Headers | Record<string, unknown>) => string | undefined;
7
+ }
8
+ //#endregion
9
+ export { RestUtils as t };
@@ -0,0 +1,21 @@
1
+ import { createContext, use, useMemo } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/lib/config/router.context.tsx
4
+ let OpenApiRouter;
5
+ (function(_OpenApiRouter) {
6
+ const Context = createContext(null);
7
+ _OpenApiRouter.Provider = ({ children, replace }) => {
8
+ const value = useMemo(() => ({ replace }), [replace]);
9
+ return /* @__PURE__ */ jsx(Context, {
10
+ value,
11
+ children
12
+ });
13
+ };
14
+ _OpenApiRouter.useRouter = () => {
15
+ const context = use(Context);
16
+ if (!context) throw new Error("useRouter must be used within an OpenApiRouter.Provider");
17
+ return context;
18
+ };
19
+ })(OpenApiRouter || (OpenApiRouter = {}));
20
+ //#endregion
21
+ export { OpenApiRouter as t };
package/dist/sh.d.mts CHANGED
@@ -1 +1 @@
1
- export { };
1
+ export {}
package/dist/sh.mjs CHANGED
@@ -1,18 +1,13 @@
1
- #!/usr/bin/env node
2
- import { S as VALIDATION_ERROR_TYPE_TITLE, a as getDataFromOpenAPIDoc, m as groupByType, n as getOutputFileName, u as getTagFileName, x as Profiler } from "./generateCodeFromOpenAPIDoc-SYuVswEJ.mjs";
3
- import { n as resolveConfig, t as runGenerate } from "./generate.runner-B0Zm3pIl.mjs";
4
- import { createRequire } from "node:module";
1
+ #!/usr/bin/env bun
2
+ import { i as VALIDATION_ERROR_TYPE_TITLE, n as groupByType, t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-DYiCTWno.mjs";
3
+ import { D as getTagFileName, Wn as Profiler, a as resolveConfig, n as runGenerate, o as getOutputFileName, t as getOpenApiDoc } from "./generate.runner-CLK1FoLT.mjs";
5
4
  import yargs from "yargs";
6
5
  import { hideBin } from "yargs/helpers";
7
6
  import { styleText } from "node:util";
8
- import fs, { existsSync, rmSync, writeFileSync } from "fs";
7
+ import fs from "fs";
9
8
  import "reflect-metadata";
10
9
  import path from "path";
11
- import SwaggerParser from "@apidevtools/swagger-parser";
12
10
  import { exec } from "child_process";
13
- //#region \0rolldown/runtime.js
14
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
15
- //#endregion
16
11
  //#region src/helpers/cli.helper.ts
17
12
  function log(message) {
18
13
  console.log(message);
@@ -36,7 +31,7 @@ function logBanner(message) {
36
31
  * Fetch the version from package.json
37
32
  */
38
33
  function getVersion() {
39
- return "3.3.0-rc.2";
34
+ return "3.3.0";
40
35
  }
41
36
  //#endregion
42
37
  //#region src/helpers/yargs.helper.ts
@@ -130,50 +125,16 @@ async function loadConfigFromPath(filePath) {
130
125
  const ext = path.extname(absolutePath).toLowerCase();
131
126
  if (ext === ".mjs") return loadMjsConfig(absolutePath);
132
127
  if (ext !== ".ts") throw new Error(`Only ESM (.mjs) and TypeScript (.ts) configuration files are supported. Found: ${ext}`);
133
- return loadTsConfig(absolutePath);
128
+ return loadModuleConfig(absolutePath, "TypeScript");
134
129
  }
135
130
  async function loadMjsConfig(filePath) {
131
+ return loadModuleConfig(filePath, "ESM");
132
+ }
133
+ async function loadModuleConfig(filePath, format) {
136
134
  const imported = await import(`${pathToFileURL(filePath).href}?t=${Date.now()}`);
137
- if (!imported.default) throw new Error(`ESM config must have a default export: ${filePath}`);
135
+ if (!imported.default) throw new Error(`${format} config must have a default export: ${filePath}`);
138
136
  return imported.default;
139
137
  }
140
- let importFresh;
141
- const loadJsSync = function loadJsSync(filepath) {
142
- if (importFresh === void 0) importFresh = __require("import-fresh");
143
- return importFresh(filepath);
144
- };
145
- let typescript;
146
- async function loadTsConfig(filePath) {
147
- if (typescript === void 0) typescript = __require("typescript");
148
- const transpiledFilepath = `${filePath.slice(0, -2)}cjs`;
149
- try {
150
- const tsConfig = resolveTsConfig(path.dirname(filePath)) ?? {};
151
- tsConfig.compilerOptions = Object.assign({}, tsConfig.compilerOptions, {
152
- module: typescript.ModuleKind.NodeNext,
153
- moduleResolution: typescript.ModuleResolutionKind.NodeNext,
154
- target: typescript.ScriptTarget.ES2022,
155
- noEmit: false
156
- });
157
- const fileContent = fs.readFileSync(filePath, "utf-8");
158
- const transpiledFileContent = typescript.transpileModule(fileContent, tsConfig).outputText;
159
- writeFileSync(transpiledFilepath, transpiledFileContent);
160
- return loadJsSync(transpiledFilepath).default;
161
- } catch (error) {
162
- error.message = `TypeScript Error in ${filePath}:\n${error.message}`;
163
- throw error;
164
- } finally {
165
- if (existsSync(transpiledFilepath)) rmSync(transpiledFilepath);
166
- }
167
- }
168
- function resolveTsConfig(directory) {
169
- const filePath = typescript.findConfigFile(directory, (fileName) => {
170
- return typescript.sys.fileExists(fileName);
171
- });
172
- if (filePath === void 0) return;
173
- const { config, error } = typescript.readConfigFile(filePath, (path) => typescript.sys.readFile(path));
174
- if (error) throw new Error(`Error in ${filePath}: ${error.messageText.toString()}`);
175
- return config;
176
- }
177
138
  function pathToFileURL(filePath) {
178
139
  const normalizedPath = path.resolve(filePath).replace(/\\/g, "/");
179
140
  return { href: normalizedPath.startsWith("/") ? `file://${normalizedPath}` : `file:///${normalizedPath}` };
@@ -183,24 +144,25 @@ function pathToFileURL(filePath) {
183
144
  async function check({ verbose, config: configParam, includeTags: _includeTagsParam, excludeTags: _excludeTagsParam, ...params }) {
184
145
  const start = Date.now();
185
146
  if (verbose) logInfo("Resolving config...");
147
+ const fileConfig = await loadConfig(configParam);
186
148
  const config = resolveConfig({
187
- fileConfig: await loadConfig(configParam),
149
+ fileConfig,
188
150
  params
189
151
  });
190
152
  if (verbose) logInfo("Parsing OpenAPI spec...");
191
- const openApiDoc = await SwaggerParser.bundle(config.input);
153
+ const openApiDoc = await getOpenApiDoc(config.input);
192
154
  if (verbose) logInfo("Running check...");
193
155
  const errorMessages = checkOpenAPIDoc(openApiDoc, config);
194
156
  if (errorMessages.length === 0) logSuccess(`Time: ${Date.now() - start}ms`);
195
157
  else throw new Error(`Found ${errorMessages.length} issues. Time: ${Date.now() - start}ms`);
196
158
  }
197
159
  //#endregion
198
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorateMetadata.js
160
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorateMetadata.js
199
161
  function __decorateMetadata(k, v) {
200
162
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
201
163
  }
202
164
  //#endregion
203
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
165
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
204
166
  function __decorate(decorators, target, key, desc) {
205
167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
206
168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -278,8 +240,10 @@ async function generate({ prettier, verbose, config: configParam, ...params }) {
278
240
  function execPrettier({ output, verbose }) {
279
241
  if (verbose) logInfo("Running Prettier...");
280
242
  exec(`prettier --write ${output} `, (error) => {
281
- if (verbose) if (error) logError(error, "Prettier error");
282
- else logSuccess("Prettier finished.");
243
+ if (verbose) {
244
+ if (error) logError(error, "Prettier error");
245
+ else logSuccess("Prettier finished.");
246
+ }
283
247
  });
284
248
  }
285
249
  //#endregion
@@ -291,6 +255,7 @@ var GenerateOptions = class {
291
255
  clearOutput;
292
256
  incremental;
293
257
  tsNamespaces;
258
+ treeShakeableNamespaces;
294
259
  tsPath;
295
260
  splitByTags;
296
261
  defaultTag;
@@ -299,8 +264,15 @@ var GenerateOptions = class {
299
264
  excludePathRegex;
300
265
  excludeRedundantZodSchemas;
301
266
  importPath;
267
+ compileSchemas;
268
+ lazySchemas;
302
269
  extractEnums;
303
270
  modelsInCommon;
271
+ modelsInModules;
272
+ zodImportPath;
273
+ restClient;
274
+ mutationEffectsImportPath;
275
+ aclCheckImportPath;
304
276
  removeOperationPrefixEndingWith;
305
277
  acl;
306
278
  checkAcl;
@@ -335,6 +307,10 @@ __decorate([YargOption({
335
307
  envAlias: "tsNamespaces",
336
308
  type: "boolean"
337
309
  }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "tsNamespaces", void 0);
310
+ __decorate([YargOption({
311
+ envAlias: "treeShakeableNamespaces",
312
+ type: "boolean"
313
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "treeShakeableNamespaces", void 0);
338
314
  __decorate([YargOption({ envAlias: "tsPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "tsPath", void 0);
339
315
  __decorate([YargOption({
340
316
  envAlias: "splitByTags",
@@ -349,6 +325,14 @@ __decorate([YargOption({
349
325
  type: "boolean"
350
326
  }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "excludeRedundantZodSchemas", void 0);
351
327
  __decorate([YargOption({ envAlias: "importPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "importPath", void 0);
328
+ __decorate([YargOption({
329
+ envAlias: "compileSchemas",
330
+ type: "boolean"
331
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "compileSchemas", void 0);
332
+ __decorate([YargOption({
333
+ envAlias: "lazySchemas",
334
+ type: "boolean"
335
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "lazySchemas", void 0);
352
336
  __decorate([YargOption({
353
337
  envAlias: "extractEnums",
354
338
  type: "boolean"
@@ -357,6 +341,17 @@ __decorate([YargOption({
357
341
  envAlias: "modelsInCommon",
358
342
  type: "boolean"
359
343
  }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "modelsInCommon", void 0);
344
+ __decorate([YargOption({
345
+ envAlias: "modelsInModules",
346
+ type: "boolean"
347
+ }), __decorateMetadata("design:type", Boolean)], GenerateOptions.prototype, "modelsInModules", void 0);
348
+ __decorate([YargOption({ envAlias: "zodImportPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "zodImportPath", void 0);
349
+ __decorate([YargOption({
350
+ envAlias: "restClient",
351
+ choices: ["axios", "native"]
352
+ }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "restClient", void 0);
353
+ __decorate([YargOption({ envAlias: "mutationEffectsImportPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "mutationEffectsImportPath", void 0);
354
+ __decorate([YargOption({ envAlias: "aclCheckImportPath" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "aclCheckImportPath", void 0);
360
355
  __decorate([YargOption({ envAlias: "removeOperationPrefixEndingWith" }), __decorateMetadata("design:type", String)], GenerateOptions.prototype, "removeOperationPrefixEndingWith", void 0);
361
356
  __decorate([YargOption({
362
357
  envAlias: "acl",
package/dist/tiny.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as getModuleOpenApiTag, A as collectApiModelSchemaExports, At as toOpenAPI30Document, B as collectReachableModelSchemas, C as applyEnumExtensions, Ct as procedureSchemaName, D as applyRobodevModuleExtensions, Dt as schemaExportName, E as applyParameterExtensions, Et as schemaComponentRef, F as collectExtraSchemas, G as findComponentEnumNames, H as compactTagName, I as collectModelSchemaExports, J as generateOpenApiFile, K as findEnumNames, L as collectModuleModelSchemaExports, M as collectContractSchemas, Mt as toOpenAPIAclRule, N as collectDbTableModelSchemaExport, Nt as toPascalCase, O as applyRobodevUserRolesExtension, Ot as sharedSchemaExportName, P as collectDbTableModelSchemaExports, Pt as visitZodSchema, Q as getModuleOpenApiController, R as collectOperationMeta, S as addContractSchema, St as operationKey, T as applyPaginatedItemSchemas, Tt as routeHasPathParameters, U as createModelSchemaNameGetter, V as collectSchemaRegistryRoots, W as defineOpenApiSchemas, X as getContractProcedureData, Y as getComponentSchemas, Z as getDerivedOperationId, _ as OpenApiSchemaRegistry, _t as namedControllerActionSchema, a as isTinyOpenApiFakeMode, at as getProcedureInputSchemaRole, b as TinyOpenApiUserRole, bt as namedOpenApiResponseSchema, c as AnyContractRouter, ct as isContractProcedure, d as GenerateOpenApiFile, dt as isObject, et as getObjectPropertySchema, f as GenerateOpenApiFileOptions, ft as isProcedureMeta, g as JsonObject, gt as namedControllerActionInputDtoSchema, h as GenerateTinyOpenApiFileOptions, ht as modelSchemaNameEntries, i as getLocalInputPath, it as getPaginatedItemSchema, j as collectContractSchemaRoots, jt as toOpenAPI30Schema, k as asStringArray, kt as stripNoContentResponseBodies, l as AnySchema, lt as isNullSchema, m as GenerateOpenApiSpec, mt as modelSchemaExportName, nt as getOperationAction, o as normalizeWatchFolders, ot as getRobodevModuleRoles, p as GenerateOpenApiFileResult, pt as isZodSchema, q as generateORPCOpenAPISpec, r as createTinyOpenApiSourceRunner, rt as getOperationController, s as AclRule, st as getStringEnumValues, t as TinyOpenApiSourceRunnerConfig, tt as getOpenApiSchemaName, u as GenerateORPCOpenAPISpecOptions, ut as isNullableOnlySchema, v as ProcedureMeta, vt as namedOpenApiOutputSchema, w as applyOperationMeta, wt as resolveOpenApiOutputPath, x as ZodSchema, xt as namedOpenApiSchema, y as TinyOpenApiModule, yt as namedOpenApiRequestSchema, z as collectOperationTags } from "./openapi-source.runner-B6KKrXw7.mjs";
1
+ import { $ as getModuleOpenApiTag, A as collectApiModelSchemaExports, At as toOpenAPI30Document, B as collectReachableModelSchemas, C as applyEnumExtensions, Ct as procedureSchemaName, D as applyRobodevModuleExtensions, Dt as schemaExportName, E as applyParameterExtensions, Et as schemaComponentRef, F as collectExtraSchemas, G as findComponentEnumNames, H as compactTagName, I as collectModelSchemaExports, J as generateOpenApiFile, K as findEnumNames, L as collectModuleModelSchemaExports, M as collectContractSchemas, Mt as toOpenAPIAclRule, N as collectDbTableModelSchemaExport, Nt as toPascalCase, O as applyRobodevUserRolesExtension, Ot as sharedSchemaExportName, P as collectDbTableModelSchemaExports, Pt as visitZodSchema, Q as getModuleOpenApiController, R as collectOperationMeta, S as addContractSchema, St as operationKey, T as applyPaginatedItemSchemas, Tt as routeHasPathParameters, U as createModelSchemaNameGetter, V as collectSchemaRegistryRoots, W as defineOpenApiSchemas, X as getContractProcedureData, Y as getComponentSchemas, Z as getDerivedOperationId, _ as OpenApiSchemaRegistry, _t as namedControllerActionSchema, a as isTinyOpenApiFakeMode, at as getProcedureInputSchemaRole, b as TinyOpenApiUserRole, bt as namedOpenApiResponseSchema, c as AnyContractRouter, ct as isContractProcedure, d as GenerateOpenApiFile, dt as isObject, et as getObjectPropertySchema, f as GenerateOpenApiFileOptions, ft as isProcedureMeta, g as JsonObject, gt as namedControllerActionInputDtoSchema, h as GenerateTinyOpenApiFileOptions, ht as modelSchemaNameEntries, i as getLocalInputPath, it as getPaginatedItemSchema, j as collectContractSchemaRoots, jt as toOpenAPI30Schema, k as asStringArray, kt as stripNoContentResponseBodies, l as AnySchema, lt as isNullSchema, m as GenerateOpenApiSpec, mt as modelSchemaExportName, nt as getOperationAction, o as normalizeWatchFolders, ot as getRobodevModuleRoles, p as GenerateOpenApiFileResult, pt as isZodSchema, q as generateORPCOpenAPISpec, r as createTinyOpenApiSourceRunner, rt as getOperationController, s as AclRule, st as getStringEnumValues, t as TinyOpenApiSourceRunnerConfig, tt as getOpenApiSchemaName, u as GenerateORPCOpenAPISpecOptions, ut as isNullableOnlySchema, v as ProcedureMeta, vt as namedOpenApiOutputSchema, w as applyOperationMeta, wt as resolveOpenApiOutputPath, x as ZodSchema, xt as namedOpenApiSchema, y as TinyOpenApiModule, yt as namedOpenApiRequestSchema, z as collectOperationTags } from "./openapi-source.runner-Bje-tMOV.mjs";
2
2
  export { AclRule, AnyContractRouter, AnySchema, GenerateORPCOpenAPISpecOptions, GenerateOpenApiFile, GenerateOpenApiFileOptions, GenerateOpenApiFileResult, GenerateOpenApiSpec, GenerateTinyOpenApiFileOptions, JsonObject, OpenApiSchemaRegistry, ProcedureMeta, TinyOpenApiModule, type TinyOpenApiSourceRunnerConfig, TinyOpenApiUserRole, ZodSchema, addContractSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createModelSchemaNameGetter, createTinyOpenApiSourceRunner, defineOpenApiSchemas, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getProcedureInputSchemaRole, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, modelSchemaExportName, modelSchemaNameEntries, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, procedureSchemaName, resolveOpenApiOutputPath, routeHasPathParameters, schemaComponentRef, schemaExportName, sharedSchemaExportName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
package/dist/tiny.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as namedControllerActionInputDtoSchema, A as generateORPCOpenAPISpec, B as getOperationController, C as collectReachableModelSchemas, D as defineOpenApiSchemas, E as createModelSchemaNameGetter, F as getModuleOpenApiController, G as isContractProcedure, H as getProcedureInputSchemaRole, I as getModuleOpenApiTag, J as isObject, K as isNullSchema, L as getObjectPropertySchema, M as getComponentSchemas, N as getContractProcedureData, O as findComponentEnumNames, P as getDerivedOperationId, Q as modelSchemaNameEntries, R as getOpenApiSchemaName, S as collectOperationTags, T as compactTagName, U as getRobodevModuleRoles, V as getPaginatedItemSchema, W as getStringEnumValues, X as isZodSchema, Y as isProcedureMeta, Z as modelSchemaExportName, _ as collectDbTableModelSchemaExports, _t as visitZodSchema, a as addContractSchema, at as operationKey, b as collectModuleModelSchemaExports, c as applyPaginatedItemSchemas, ct as routeHasPathParameters, d as applyRobodevUserRolesExtension, dt as sharedSchemaExportName, et as namedControllerActionSchema, f as asStringArray, ft as stripNoContentResponseBodies, g as collectDbTableModelSchemaExport, gt as toPascalCase, h as collectContractSchemas, ht as toOpenAPIAclRule, i as normalizeWatchFolders, it as namedOpenApiSchema, j as generateOpenApiFile, k as findEnumNames, l as applyParameterExtensions, lt as schemaComponentRef, m as collectContractSchemaRoots, mt as toOpenAPI30Schema, n as getLocalInputPath, nt as namedOpenApiRequestSchema, o as applyEnumExtensions, ot as procedureSchemaName, p as collectApiModelSchemaExports, pt as toOpenAPI30Document, q as isNullableOnlySchema, r as isTinyOpenApiFakeMode, rt as namedOpenApiResponseSchema, s as applyOperationMeta, st as resolveOpenApiOutputPath, t as createTinyOpenApiSourceRunner, tt as namedOpenApiOutputSchema, u as applyRobodevModuleExtensions, ut as schemaExportName, v as collectExtraSchemas, w as collectSchemaRegistryRoots, x as collectOperationMeta, y as collectModelSchemaExports, z as getOperationAction } from "./openapi-source.runner-8kCe-g9S.mjs";
1
+ import { $ as namedControllerActionInputDtoSchema, A as generateORPCOpenAPISpec, B as getOperationController, C as collectReachableModelSchemas, D as defineOpenApiSchemas, E as createModelSchemaNameGetter, F as getModuleOpenApiController, G as isContractProcedure, H as getProcedureInputSchemaRole, I as getModuleOpenApiTag, J as isObject, K as isNullSchema, L as getObjectPropertySchema, M as getComponentSchemas, N as getContractProcedureData, O as findComponentEnumNames, P as getDerivedOperationId, Q as modelSchemaNameEntries, R as getOpenApiSchemaName, S as collectOperationTags, T as compactTagName, U as getRobodevModuleRoles, V as getPaginatedItemSchema, W as getStringEnumValues, X as isZodSchema, Y as isProcedureMeta, Z as modelSchemaExportName, _ as collectDbTableModelSchemaExports, _t as visitZodSchema, a as addContractSchema, at as operationKey, b as collectModuleModelSchemaExports, c as applyPaginatedItemSchemas, ct as routeHasPathParameters, d as applyRobodevUserRolesExtension, dt as sharedSchemaExportName, et as namedControllerActionSchema, f as asStringArray, ft as stripNoContentResponseBodies, g as collectDbTableModelSchemaExport, gt as toPascalCase, h as collectContractSchemas, ht as toOpenAPIAclRule, i as normalizeWatchFolders, it as namedOpenApiSchema, j as generateOpenApiFile, k as findEnumNames, l as applyParameterExtensions, lt as schemaComponentRef, m as collectContractSchemaRoots, mt as toOpenAPI30Schema, n as getLocalInputPath, nt as namedOpenApiRequestSchema, o as applyEnumExtensions, ot as procedureSchemaName, p as collectApiModelSchemaExports, pt as toOpenAPI30Document, q as isNullableOnlySchema, r as isTinyOpenApiFakeMode, rt as namedOpenApiResponseSchema, s as applyOperationMeta, st as resolveOpenApiOutputPath, t as createTinyOpenApiSourceRunner, tt as namedOpenApiOutputSchema, u as applyRobodevModuleExtensions, ut as schemaExportName, v as collectExtraSchemas, w as collectSchemaRegistryRoots, x as collectOperationMeta, y as collectModelSchemaExports, z as getOperationAction } from "./openapi-source.runner-DPUNTduQ.mjs";
2
2
  export { addContractSchema, applyEnumExtensions, applyOperationMeta, applyPaginatedItemSchemas, applyParameterExtensions, applyRobodevModuleExtensions, applyRobodevUserRolesExtension, asStringArray, collectApiModelSchemaExports, collectContractSchemaRoots, collectContractSchemas, collectDbTableModelSchemaExport, collectDbTableModelSchemaExports, collectExtraSchemas, collectModelSchemaExports, collectModuleModelSchemaExports, collectOperationMeta, collectOperationTags, collectReachableModelSchemas, collectSchemaRegistryRoots, compactTagName, createModelSchemaNameGetter, createTinyOpenApiSourceRunner, defineOpenApiSchemas, findComponentEnumNames, findEnumNames, generateORPCOpenAPISpec, generateOpenApiFile, getComponentSchemas, getContractProcedureData, getDerivedOperationId, getModuleOpenApiController, getModuleOpenApiTag, getObjectPropertySchema, getOpenApiSchemaName, getOperationAction, getOperationController, getPaginatedItemSchema, getProcedureInputSchemaRole, getRobodevModuleRoles, getStringEnumValues, getLocalInputPath as getTinyOpenApiLocalInputPath, isContractProcedure, isNullSchema, isNullableOnlySchema, isObject, isProcedureMeta, isTinyOpenApiFakeMode, isZodSchema, modelSchemaExportName, modelSchemaNameEntries, namedControllerActionInputDtoSchema, namedControllerActionSchema, namedOpenApiOutputSchema, namedOpenApiRequestSchema, namedOpenApiResponseSchema, namedOpenApiSchema, normalizeWatchFolders as normalizeTinyOpenApiWatchFolders, operationKey, procedureSchemaName, resolveOpenApiOutputPath, routeHasPathParameters, schemaComponentRef, schemaExportName, sharedSchemaExportName, stripNoContentResponseBodies, toOpenAPI30Document, toOpenAPI30Schema, toOpenAPIAclRule, toPascalCase, visitZodSchema };
@@ -0,0 +1,29 @@
1
+ import { s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-LPEPQV1V.mjs";
2
+ import { i as QueryModule, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
3
+ import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
4
+ //#region src/lib/react-query.types.d.ts
5
+ type Function = (...args: any) => any;
6
+ type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
7
+ type IsAny<T> = IfAny<T, true, never>;
8
+ type IsUnknown<T, Y, N = T> = IsAny<T> extends never ? (unknown extends T ? Y : N) : N;
9
+ type AppQueryOptions<TFunction extends Function, TData = Awaited<ReturnType<TFunction>>, TErrorCodes = GeneralErrorCodes> = Omit<UseQueryOptions<Awaited<ReturnType<TFunction>>, ApplicationException<TErrorCodes>, IsUnknown<TData, Awaited<ReturnType<TFunction>>>>, "queryKey" | "queryFn">;
10
+ type AppMutationOptions<TFunction extends Function, TVariables = void, TData = Awaited<ReturnType<TFunction>>, TErrorCodes = GeneralErrorCodes> = Omit<UseMutationOptions<TData, ApplicationException<TErrorCodes>, TVariables>, "mutationKey" | "mutationFn">;
11
+ type AppInfiniteQueryOptions<TFunction extends Function, TData = InfiniteData<Awaited<ReturnType<TFunction>>>, TErrorCodes = GeneralErrorCodes, TQueryKey extends QueryKey = QueryKey, TPageParam = number> = Omit<UseInfiniteQueryOptions<Awaited<ReturnType<TFunction>>, ApplicationException<TErrorCodes>, IsUnknown<TData, InfiniteData<Awaited<ReturnType<TFunction>>>>, TQueryKey, TPageParam>, "queryKey" | "queryFn" | "initialPageParam" | "getNextPageParam">;
12
+ //#endregion
13
+ //#region src/lib/react-query/useMutationEffects.d.ts
14
+ interface MutationEffectsOptions<TQueryModule extends QueryModule = QueryModule> {
15
+ invalidateCurrentModule?: boolean;
16
+ crossTabInvalidation?: boolean;
17
+ invalidationMap?: InvalidationMap<TQueryModule>;
18
+ invalidateModules?: QueryModule[];
19
+ invalidateKeys?: QueryKey[];
20
+ preferUpdate?: boolean;
21
+ }
22
+ interface UseMutationEffectsProps<TQueryModule extends QueryModule = QueryModule> {
23
+ currentModule: TQueryModule;
24
+ }
25
+ declare function useMutationEffects<TQueryModule extends QueryModule = QueryModule>({ currentModule }: UseMutationEffectsProps<TQueryModule>): {
26
+ runMutationEffects: <TData, TVariables>(data: TData, variables: TVariables, options?: MutationEffectsOptions<TQueryModule>, updateKeys?: QueryKey[]) => Promise<void>;
27
+ };
28
+ //#endregion
29
+ export { AppQueryOptions as a, AppMutationOptions as i, useMutationEffects as n, AppInfiniteQueryOptions as r, MutationEffectsOptions as t };
@@ -0,0 +1,68 @@
1
+ import { t as OpenApiQueryConfig } from "./queryConfig.context-CldQ5YL9.mjs";
2
+ import { useCallback, useEffect } from "react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ //#region src/lib/react-query/cross-tab-invalidation.ts
5
+ const CROSS_TAB_INVALIDATE_KEY = "__rq_invalidate__";
6
+ const broadcastQueryInvalidation = (queryKeys) => {
7
+ localStorage.setItem(CROSS_TAB_INVALIDATE_KEY, JSON.stringify({
8
+ keys: queryKeys,
9
+ timestamp: Date.now()
10
+ }));
11
+ };
12
+ let isListenerSetUp = false;
13
+ const setupCrossTabListener = (queryClient) => {
14
+ if (isListenerSetUp) return;
15
+ isListenerSetUp = true;
16
+ window.addEventListener("storage", (e) => {
17
+ if (e.key !== CROSS_TAB_INVALIDATE_KEY || !e.newValue) return;
18
+ try {
19
+ const { keys } = JSON.parse(e.newValue);
20
+ for (const queryKey of keys) queryClient.invalidateQueries({ queryKey });
21
+ } catch {}
22
+ });
23
+ };
24
+ //#endregion
25
+ //#region src/lib/react-query/useMutationEffects.ts
26
+ function useMutationEffects({ currentModule }) {
27
+ const queryClient = useQueryClient();
28
+ const config = OpenApiQueryConfig.useConfig();
29
+ useEffect(() => {
30
+ if (!config.crossTabInvalidation) return;
31
+ setupCrossTabListener(queryClient);
32
+ }, [queryClient, config.crossTabInvalidation]);
33
+ return { runMutationEffects: useCallback(async (data, variables, options = {}, updateKeys) => {
34
+ const { invalidateCurrentModule, invalidationMap, invalidateModules, invalidateKeys, preferUpdate } = options;
35
+ const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
36
+ const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
37
+ const isQueryKeyEqual = (keyA, keyB) => keyA.length === keyB.length && keyA.every((item, index) => item === keyB[index]);
38
+ const isQueryKeyPrefix = (queryKey, prefixKey) => prefixKey.length <= queryKey.length && prefixKey.every((item, index) => item === queryKey[index]);
39
+ const mappedInvalidationKeys = invalidationMap?.[currentModule]?.(data, variables) ?? config.invalidationMap?.[currentModule]?.(data, variables);
40
+ const shouldInvalidateQuery = (queryKey) => {
41
+ const isUpdateKey = updateKeys?.some((key) => isQueryKeyEqual(queryKey, key));
42
+ if (shouldUpdate && isUpdateKey) return false;
43
+ const isCurrentModule = shouldInvalidateCurrentModule && queryKey[0] === currentModule;
44
+ const isInvalidateModule = !!invalidateModules && invalidateModules.some((module) => queryKey[0] === module);
45
+ const isInvalidateKey = !!invalidateKeys && invalidateKeys.some((key) => isQueryKeyPrefix(queryKey, key));
46
+ const isMappedKey = !!mappedInvalidationKeys && mappedInvalidationKeys.some((key) => isQueryKeyPrefix(queryKey, key));
47
+ return isCurrentModule || isInvalidateModule || isInvalidateKey || isMappedKey;
48
+ };
49
+ const invalidatedQueryKeys = [];
50
+ const shouldBroadcast = options.crossTabInvalidation ?? config.crossTabInvalidation;
51
+ queryClient.invalidateQueries({ predicate: ({ queryKey }) => {
52
+ const shouldInvalidate = shouldInvalidateQuery(queryKey);
53
+ if (shouldInvalidate && shouldBroadcast) invalidatedQueryKeys.push([...queryKey]);
54
+ return shouldInvalidate;
55
+ } });
56
+ if (shouldBroadcast && invalidatedQueryKeys.length > 0) broadcastQueryInvalidation(invalidatedQueryKeys);
57
+ if (shouldUpdate && updateKeys) updateKeys.map((queryKey) => queryClient.setQueryData(queryKey, data));
58
+ }, [
59
+ queryClient,
60
+ currentModule,
61
+ config.preferUpdate,
62
+ config.invalidateCurrentModule,
63
+ config.invalidationMap,
64
+ config.crossTabInvalidation
65
+ ]) };
66
+ }
67
+ //#endregion
68
+ export { useMutationEffects as t };
package/dist/vite.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { r as GenerateFileFormatter } from "./options-DdQJ9BSc.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-BQqze8rU.mjs";
3
- import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-B6KKrXw7.mjs";
1
+ import { r as GenerateFileFormatter } from "./options-rz2bcsaN.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-FD2Y872S.mjs";
3
+ import { d as GenerateOpenApiFile, m as GenerateOpenApiSpec, n as TinyOpenApiSpecModuleConfig } from "./openapi-source.runner-Bje-tMOV.mjs";
4
4
  import { Plugin, PluginOption } from "vite";
5
-
6
5
  //#region src/plugins/openapi-codegen.runner.d.ts
7
6
  type OpenApiCodegenPluginConfig = OpenAPICodegenConfig & {
8
7
  formatGeneratedFile?: GenerateFileFormatter;
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-CCXQsUum.mjs";
2
- import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-8kCe-g9S.mjs";
1
+ import { t as createOpenApiCodegenRunner } from "./openapi-codegen.runner-DUqQD2B5.mjs";
2
+ import { i as normalizeWatchFolders, r as isTinyOpenApiFakeMode, t as createTinyOpenApiSourceRunner } from "./openapi-source.runner-DPUNTduQ.mjs";
3
3
  import path from "path";
4
4
  //#region src/vite/openapi-codegen.plugin.ts
5
5
  function openApiCodegen(config) {
@@ -36,7 +36,7 @@ function openApiCodegen(config) {
36
36
  }
37
37
  //#endregion
38
38
  //#region src/vite/tiny-openapi-codegen.plugin.ts
39
- const watchedEvents = new Set([
39
+ const watchedEvents = /* @__PURE__ */ new Set([
40
40
  "add",
41
41
  "change",
42
42
  "unlink"
@@ -75,7 +75,8 @@ function tinyOpenApiCodegenPlugin(codegenConfig, options) {
75
75
  }, debounceMs);
76
76
  };
77
77
  const setupWatcher = (server) => {
78
- const watchFolders = normalizeWatchFolders(resolvedConfig?.root ?? server.config.root, options.watchFolders);
78
+ const root = resolvedConfig?.root ?? server.config.root;
79
+ const watchFolders = normalizeWatchFolders(root, options.watchFolders);
79
80
  server.watcher.add(watchFolders);
80
81
  server.watcher.on("all", (event, changedPath) => {
81
82
  if (watchedEvents.has(event) && isPathInWatchFolders(changedPath, watchFolders)) scheduleGenerate(server);
@@ -0,0 +1,26 @@
1
+ import { createContext, use, useMemo } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/lib/config/workspace.context.tsx
4
+ let OpenApiWorkspaceContext;
5
+ (function(_OpenApiWorkspaceContext) {
6
+ const Context = createContext({});
7
+ _OpenApiWorkspaceContext.Provider = ({ values, children }) => {
8
+ const contextValues = useMemo(() => values ?? {}, [values]);
9
+ return /* @__PURE__ */ jsx(Context.Provider, {
10
+ value: contextValues,
11
+ children
12
+ });
13
+ };
14
+ _OpenApiWorkspaceContext.useContext = () => {
15
+ return use(Context);
16
+ };
17
+ _OpenApiWorkspaceContext.resolveParam = (context, name, value) => {
18
+ if (value != null) return value;
19
+ const workspaceValue = context[name];
20
+ if (workspaceValue == null) throw new Error(`Missing workspace context param "${name}"`);
21
+ return workspaceValue;
22
+ };
23
+ })(OpenApiWorkspaceContext || (OpenApiWorkspaceContext = {}));
24
+ const useWorkspaceContext = () => OpenApiWorkspaceContext.useContext();
25
+ //#endregion
26
+ export { useWorkspaceContext as n, OpenApiWorkspaceContext as t };