@povio/openapi-codegen-cli 2.0.8-rc.18 → 2.0.8-rc.19

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/dist/acl.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as ErrorHandler } from "./error-handling-p69GkKGP.mjs";
1
+ import { r as ErrorHandler } from "./error-handling-CXeVTk1T.mjs";
2
2
  import * as react from "react";
3
3
  import { PropsWithChildren } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/acl.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { a as SharedErrorHandler, n as OpenApiRouter, t as AuthContext } from "./auth.context-HV1I5QMx.mjs";
1
+ import { r as SharedErrorHandler } from "./error-handling-DkPY7Asf.mjs";
2
+ import { n as OpenApiRouter, t as AuthContext } from "./auth.context-Bu5KW2sI.mjs";
2
3
  import { createContext, useCallback, useEffect, useState } from "react";
3
4
  import { jsx } from "react/jsx-runtime";
4
5
  import { AbilityBuilder, createMongoAbility } from "@casl/ability";
@@ -0,0 +1,59 @@
1
+ import { createContext, use, useMemo } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/lib/config/router.context.tsx
5
+ let OpenApiRouter;
6
+ (function(_OpenApiRouter) {
7
+ const Context = createContext(null);
8
+ _OpenApiRouter.Provider = ({ children, replace }) => {
9
+ return /* @__PURE__ */ jsx(Context, {
10
+ value: useMemo(() => ({ replace }), [replace]),
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
+
21
+ //#endregion
22
+ //#region src/lib/auth/auth.context.tsx
23
+ let AuthContext;
24
+ (function(_AuthContext) {
25
+ const Context = createContext({});
26
+ _AuthContext.Provider = ({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children }) => {
27
+ const value = useMemo(() => ({
28
+ isAuthenticated,
29
+ isInitializing,
30
+ logout,
31
+ updateTokens,
32
+ accessToken,
33
+ user,
34
+ userPromise,
35
+ routes,
36
+ loadingState
37
+ }), [
38
+ isAuthenticated,
39
+ isInitializing,
40
+ logout,
41
+ updateTokens,
42
+ accessToken,
43
+ user,
44
+ userPromise,
45
+ routes,
46
+ loadingState
47
+ ]);
48
+ return /* @__PURE__ */ jsx(Context.Provider, {
49
+ value,
50
+ children
51
+ });
52
+ };
53
+ _AuthContext.useAuth = () => {
54
+ return use(Context);
55
+ };
56
+ })(AuthContext || (AuthContext = {}));
57
+
58
+ //#endregion
59
+ export { OpenApiRouter as n, AuthContext as t };
@@ -1,4 +1,4 @@
1
- import { t as GenerateOptions } from "./options-Bvmh6rai.mjs";
1
+ import { t as GenerateOptions } from "./options-DmUw8IYE.mjs";
2
2
 
3
3
  //#region src/generators/types/config.d.ts
4
4
  type OpenAPICodegenConfig = Partial<GenerateOptions>;
@@ -1,8 +1,6 @@
1
1
  import { isAxiosError, isCancel } from "axios";
2
2
  import { z } from "zod";
3
3
  import i18next from "i18next";
4
- import { createContext, use, useMemo } from "react";
5
- import { jsx } from "react/jsx-runtime";
6
4
 
7
5
  //#region src/lib/assets/locales/en/translation.json
8
6
  var translation_default$1 = { openapi: { "sharedErrors": {
@@ -186,59 +184,4 @@ var ErrorHandler = class {
186
184
  const SharedErrorHandler = new ErrorHandler({ entries: [] });
187
185
 
188
186
  //#endregion
189
- //#region src/lib/config/router.context.tsx
190
- let OpenApiRouter;
191
- (function(_OpenApiRouter) {
192
- const Context = createContext(null);
193
- _OpenApiRouter.Provider = ({ children, replace }) => {
194
- return /* @__PURE__ */ jsx(Context, {
195
- value: useMemo(() => ({ replace }), [replace]),
196
- children
197
- });
198
- };
199
- _OpenApiRouter.useRouter = () => {
200
- const context = use(Context);
201
- if (!context) throw new Error("useRouter must be used within an OpenApiRouter.Provider");
202
- return context;
203
- };
204
- })(OpenApiRouter || (OpenApiRouter = {}));
205
-
206
- //#endregion
207
- //#region src/lib/auth/auth.context.tsx
208
- let AuthContext;
209
- (function(_AuthContext) {
210
- const Context = createContext({});
211
- _AuthContext.Provider = ({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children }) => {
212
- const value = useMemo(() => ({
213
- isAuthenticated,
214
- isInitializing,
215
- logout,
216
- updateTokens,
217
- accessToken,
218
- user,
219
- userPromise,
220
- routes,
221
- loadingState
222
- }), [
223
- isAuthenticated,
224
- isInitializing,
225
- logout,
226
- updateTokens,
227
- accessToken,
228
- user,
229
- userPromise,
230
- routes,
231
- loadingState
232
- ]);
233
- return /* @__PURE__ */ jsx(Context.Provider, {
234
- value,
235
- children
236
- });
237
- };
238
- _AuthContext.useAuth = () => {
239
- return use(Context);
240
- };
241
- })(AuthContext || (AuthContext = {}));
242
-
243
- //#endregion
244
- export { SharedErrorHandler as a, resources as c, ErrorHandler as i, OpenApiRouter as n, RestUtils as o, ApplicationException as r, ns as s, AuthContext as t };
187
+ export { ns as a, RestUtils as i, ErrorHandler as n, resources as o, SharedErrorHandler as r, ApplicationException as t };
@@ -1,4 +1,4 @@
1
- import { n as GenerateFileData, t as GenerateOptions } from "./options-Bvmh6rai.mjs";
1
+ import { n as GenerateFileData, t as GenerateOptions } from "./options-DmUw8IYE.mjs";
2
2
  import { OpenAPIV3 } from "openapi-types";
3
3
 
4
4
  //#region src/generators/types/metadata.d.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-p69GkKGP.mjs";
2
- import "./options-Bvmh6rai.mjs";
3
- import { t as OpenAPICodegenConfig } from "./config-B4HK4BLi.mjs";
1
+ import { a as GeneralErrorCodes, i as ErrorHandlerOptions, n as ErrorEntry, o as SharedErrorHandler, r as ErrorHandler, t as ApplicationException } from "./error-handling-CXeVTk1T.mjs";
2
+ import "./options-DmUw8IYE.mjs";
3
+ import { t as OpenAPICodegenConfig } from "./config-CDt7S_BM.mjs";
4
4
  import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
5
5
  import { z } from "zod";
6
6
  import "i18next";
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { a as SharedErrorHandler, c as resources, i as ErrorHandler, n as OpenApiRouter, o as RestUtils, r as ApplicationException, s as ns, t as AuthContext } from "./auth.context-HV1I5QMx.mjs";
1
+ import { a as ns, i as RestUtils, n as ErrorHandler, o as resources, r as SharedErrorHandler, t as ApplicationException } from "./error-handling-DkPY7Asf.mjs";
2
+ import { n as OpenApiRouter, t as AuthContext } from "./auth.context-Bu5KW2sI.mjs";
2
3
  import axios from "axios";
3
4
  import { z } from "zod";
4
5
  import { createContext, use, useCallback, useEffect, useMemo, useState } from "react";
package/dist/sh.mjs CHANGED
@@ -39,7 +39,7 @@ function logBanner(message) {
39
39
  * Fetch the version from package.json
40
40
  */
41
41
  function getVersion() {
42
- return "2.0.8-rc.18";
42
+ return "2.0.8-rc.19";
43
43
  }
44
44
 
45
45
  //#endregion
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import "./options-Bvmh6rai.mjs";
2
- import { t as OpenAPICodegenConfig } from "./config-B4HK4BLi.mjs";
1
+ import "./options-DmUw8IYE.mjs";
2
+ import { t as OpenAPICodegenConfig } from "./config-CDt7S_BM.mjs";
3
3
  import { Plugin } from "vite";
4
4
 
5
5
  //#region src/vite/openapi-codegen.plugin.d.ts
package/dist/zod.d.mts ADDED
@@ -0,0 +1,20 @@
1
+ import { r as ErrorHandler } from "./error-handling-CXeVTk1T.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.18",
3
+ "version": "2.0.8-rc.19",
4
4
  "keywords": [
5
5
  "codegen",
6
6
  "openapi",