@povio/openapi-codegen-cli 3.2.0-rc.8 → 3.2.0-rc.9

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/dist/AuthGuard-GbtTDXs0.d.mts +32 -0
  2. package/dist/AuthGuard-qpAtHaBz.mjs +24 -0
  3. package/dist/acl.d.mts +1 -1
  4. package/dist/acl.mjs +3 -2
  5. package/dist/{auth.context-YFWzkwoN.mjs → auth.context-COWO6ssl.mjs} +1 -19
  6. package/dist/auth.d.mts +2 -0
  7. package/dist/auth.mjs +3 -0
  8. package/dist/axios.d.mts +2 -0
  9. package/dist/axios.mjs +2 -0
  10. package/dist/config.d.mts +4 -0
  11. package/dist/config.mjs +5 -0
  12. package/dist/{error-handling-BMXC5P08.mjs → error-handling-BeydPL7s.mjs} +2 -36
  13. package/dist/{error-handling-CNOHs4Fc.d.mts → error-handling-LPEPQV1V.d.mts} +2 -38
  14. package/dist/errors.d.mts +3 -0
  15. package/dist/errors.mjs +2 -0
  16. package/dist/generate.runner-D8AYuEFm.mjs +184 -0
  17. package/dist/{generate.utils-CH2U2Dpr.cjs → generate.utils-CT-LA-gX.cjs} +6 -53
  18. package/dist/{generateCodeFromOpenAPIDoc-glAKBEGP.mjs → generateCodeFromOpenAPIDoc--ufinTug.mjs} +29 -4
  19. package/dist/{generateCodeFromOpenAPIDoc-CZT3sThI.cjs → generateCodeFromOpenAPIDoc-iEa8YAUQ.cjs} +48 -23
  20. package/dist/generator.mjs +4 -3
  21. package/dist/{getDataFromOpenAPIDoc-7RxjULpB.mjs → getDataFromOpenAPIDoc-D8w0QElH.mjs} +1 -1
  22. package/dist/i18n-B_brQh4X.d.mts +38 -0
  23. package/dist/i18n-D-FesqFb.mjs +36 -0
  24. package/dist/index.d.mts +8 -159
  25. package/dist/index.mjs +9 -256
  26. package/dist/metro.cjs +2 -2
  27. package/dist/metro.mjs +1 -1
  28. package/dist/{generate.runner-BvSprH6D.mjs → native-bindings-BTQGSGhU.mjs} +5 -208
  29. package/dist/openapi-codegen-native-darwin-arm64.node +0 -0
  30. package/dist/openapi-codegen-native-linux-x64.node +0 -0
  31. package/dist/openapi-codegen-native-win32-x64.node +0 -0
  32. package/dist/{openapi-codegen.runner-C93V7SGj.mjs → openapi-codegen.runner-6Yth6QZC.mjs} +2 -1
  33. package/dist/query.d.mts +3 -0
  34. package/dist/query.mjs +3 -0
  35. package/dist/queryConfig.context-CRJOgf19.d.mts +22 -0
  36. package/dist/queryConfig.context-CldQ5YL9.mjs +34 -0
  37. package/dist/rest-client-CQyFvqYC.d.mts +55 -0
  38. package/dist/rest-interceptor-D5NCNTm1.mjs +115 -0
  39. package/dist/rest.utils-rezWAIYL.d.mts +10 -0
  40. package/dist/router.context-EPlMBk3G.mjs +21 -0
  41. package/dist/sh.mjs +4 -3
  42. package/dist/useMutationEffects-DIdL8tlx.d.mts +29 -0
  43. package/dist/useMutationEffects-PB1fvKWM.mjs +68 -0
  44. package/dist/vite.mjs +1 -1
  45. package/dist/workspace.context-XWvQ_7Hg.mjs +26 -0
  46. package/dist/workspace.context-isVY9ves.d.mts +23 -0
  47. package/dist/zod.d.mts +1 -1
  48. package/dist/zod.mjs +1 -1
  49. package/package.json +39 -2
@@ -1,4 +1,29 @@
1
- const require_generate_utils = require("./generate.utils-CH2U2Dpr.cjs");
1
+ const require_generate_utils = require("./generate.utils-CT-LA-gX.cjs");
2
+ //#region src/generators/const/acl.const.ts
3
+ const ACL_APP_ABILITY_FILE = {
4
+ fileName: "acl/app.ability",
5
+ extension: "ts"
6
+ };
7
+ const ACL_APP_ABILITIES = "AppAbilities";
8
+ const ACL_CHECK_HOOK = "useAclCheck";
9
+ const CASL_ABILITY_BINDING = {
10
+ abilityTuple: "AbilityTuple",
11
+ pureAbility: "PureAbility",
12
+ forcedSubject: "ForcedSubject",
13
+ subjectType: "Subject",
14
+ subject: "subject"
15
+ };
16
+ const CASL_ABILITY_IMPORT = {
17
+ bindings: [
18
+ CASL_ABILITY_BINDING.abilityTuple,
19
+ CASL_ABILITY_BINDING.pureAbility,
20
+ CASL_ABILITY_BINDING.forcedSubject,
21
+ CASL_ABILITY_BINDING.subjectType,
22
+ CASL_ABILITY_BINDING.subject
23
+ ],
24
+ from: "@casl/ability"
25
+ };
26
+ //#endregion
2
27
  //#region src/generators/core/zod/getZodChain.ts
3
28
  const zodChainCache = /* @__PURE__ */ new WeakMap();
4
29
  function getZodChain({ schema, meta, options }) {
@@ -2004,13 +2029,13 @@ function generateAcl({ resolver, data, tag }) {
2004
2029
  const { hasAdditionalAbilityImports, modelsImports, endpoints } = aclData;
2005
2030
  const hasWorkspaceContext = endpoints.some((endpoint) => getWorkspaceConditionNames(resolver, endpoint).length > 0);
2006
2031
  const caslAbilityTupleImport = {
2007
- bindings: [...hasAdditionalAbilityImports ? [require_generate_utils.CASL_ABILITY_BINDING.forcedSubject, require_generate_utils.CASL_ABILITY_BINDING.subject] : []],
2008
- typeBindings: [require_generate_utils.CASL_ABILITY_BINDING.abilityTuple],
2009
- from: require_generate_utils.CASL_ABILITY_IMPORT.from
2032
+ bindings: [...hasAdditionalAbilityImports ? [CASL_ABILITY_BINDING.forcedSubject, CASL_ABILITY_BINDING.subject] : []],
2033
+ typeBindings: [CASL_ABILITY_BINDING.abilityTuple],
2034
+ from: CASL_ABILITY_IMPORT.from
2010
2035
  };
2011
2036
  const workspaceContextImport = {
2012
2037
  bindings: ["useWorkspaceContext"],
2013
- from: require_generate_utils.PACKAGE_IMPORT_PATH
2038
+ from: require_generate_utils.CONFIG_PACKAGE_IMPORT_PATH
2014
2039
  };
2015
2040
  const lines = [];
2016
2041
  lines.push(renderImport$4(caslAbilityTupleImport));
@@ -2042,12 +2067,12 @@ function generateAppAcl({ resolver, data }) {
2042
2067
  const caslAbilityTupleImport = {
2043
2068
  bindings: [],
2044
2069
  typeBindings: [
2045
- require_generate_utils.CASL_ABILITY_BINDING.pureAbility,
2046
- require_generate_utils.CASL_ABILITY_BINDING.abilityTuple,
2047
- ...!appAbilitiesType ? [require_generate_utils.CASL_ABILITY_BINDING.subjectType] : [],
2048
- ...hasAdditionalAbilityImports ? [require_generate_utils.CASL_ABILITY_BINDING.forcedSubject] : []
2070
+ CASL_ABILITY_BINDING.pureAbility,
2071
+ CASL_ABILITY_BINDING.abilityTuple,
2072
+ ...!appAbilitiesType ? [CASL_ABILITY_BINDING.subjectType] : [],
2073
+ ...hasAdditionalAbilityImports ? [CASL_ABILITY_BINDING.forcedSubject] : []
2049
2074
  ],
2050
- from: require_generate_utils.CASL_ABILITY_IMPORT.from,
2075
+ from: CASL_ABILITY_IMPORT.from,
2051
2076
  typeOnly: true
2052
2077
  };
2053
2078
  const lines = [];
@@ -2055,11 +2080,11 @@ function generateAppAcl({ resolver, data }) {
2055
2080
  for (const modelsImport of modelsImports) lines.push(renderImport$4(modelsImport));
2056
2081
  lines.push("");
2057
2082
  if (appAbilitiesType) {
2058
- lines.push(`export type ${require_generate_utils.ACL_APP_ABILITIES} = `);
2059
- for (const [action, subjects] of Object.entries(appAbilitiesType)) lines.push(`| ${require_generate_utils.CASL_ABILITY_BINDING.abilityTuple}<"${action}", ${subjects.join(" | ")}>`);
2060
- } else lines.push(`export type ${require_generate_utils.ACL_APP_ABILITIES} = ${require_generate_utils.CASL_ABILITY_BINDING.abilityTuple}<string, ${require_generate_utils.CASL_ABILITY_BINDING.subjectType}>;`);
2083
+ lines.push(`export type ${ACL_APP_ABILITIES} = `);
2084
+ for (const [action, subjects] of Object.entries(appAbilitiesType)) lines.push(`| ${CASL_ABILITY_BINDING.abilityTuple}<"${action}", ${subjects.join(" | ")}>`);
2085
+ } else lines.push(`export type ${ACL_APP_ABILITIES} = ${CASL_ABILITY_BINDING.abilityTuple}<string, ${CASL_ABILITY_BINDING.subjectType}>;`);
2061
2086
  lines.push("");
2062
- lines.push(`export type AppAbility = PureAbility<${require_generate_utils.ACL_APP_ABILITIES}>;`);
2087
+ lines.push(`export type AppAbility = PureAbility<${ACL_APP_ABILITIES}>;`);
2063
2088
  return lines.join("\n");
2064
2089
  }
2065
2090
  function renderImport$4(importData) {
@@ -2118,7 +2143,7 @@ function renderAbilityFunction({ resolver, endpoint }) {
2118
2143
  lines.push(") => [");
2119
2144
  lines.push(` "${require_generate_utils.getAbilityAction(endpoint)}",`);
2120
2145
  lines.push(` ${hasConditions ? `object ? subject("${require_generate_utils.getAbilitySubject(endpoint)}", object) : "${require_generate_utils.getAbilitySubject(endpoint)}"` : `"${require_generate_utils.getAbilitySubject(endpoint)}"`}`);
2121
- lines.push(`] as ${require_generate_utils.CASL_ABILITY_BINDING.abilityTuple}<"${require_generate_utils.getAbilityAction(endpoint)}", ${require_generate_utils.getAbilitySubjectTypes(endpoint, resolver, require_generate_utils.getEndpointTag(endpoint, resolver.options)).join(" | ")}>;`);
2146
+ lines.push(`] as ${CASL_ABILITY_BINDING.abilityTuple}<"${require_generate_utils.getAbilityAction(endpoint)}", ${require_generate_utils.getAbilitySubjectTypes(endpoint, resolver, require_generate_utils.getEndpointTag(endpoint, resolver.options)).join(" | ")}>;`);
2122
2147
  const workspaceAclHook = renderWorkspaceAclHook({
2123
2148
  resolver,
2124
2149
  endpoint
@@ -2439,7 +2464,7 @@ function generateConfigs(generateTypeParams) {
2439
2464
  from: require_generate_utils.getQueryModulesImportPath(resolver.options)
2440
2465
  };
2441
2466
  const aclCheckImport = {
2442
- bindings: [require_generate_utils.ACL_CHECK_HOOK],
2467
+ bindings: [ACL_CHECK_HOOK],
2443
2468
  from: resolver.options.aclCheckImportPath
2444
2469
  };
2445
2470
  const hasDynamicInputsImport = configs.some((config) => config.readAll.filters || config.create?.inputDefs || config.update?.inputDefs);
@@ -2534,7 +2559,7 @@ function renderMutationContent(resolver, endpoint, tag) {
2534
2559
  lines.push(`(options?: AppMutationOptions<typeof ${endpointFunction}, ${mutationVariablesType}>${hasMutationEffects ? ` & ${require_generate_utils.MUTATION_EFFECTS.optionsType}` : ""}${hasAxiosRequestConfig ? `, config?: ${require_generate_utils.getRequestConfigTypeName(resolver.options.restClient)}` : ""}) => {`);
2535
2560
  if (hasMutationDefaultOnError) lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
2536
2561
  if (hasMutationEffects) lines.push(` const { runMutationEffects } = useMutationEffects<${require_generate_utils.QUERY_MODULE_ENUM}.${endpointTag}>({ currentModule: ${require_generate_utils.QUERY_MODULE_ENUM}.${tag} });`);
2537
- if (hasAclCheck) lines.push(` const { checkAcl } = ${require_generate_utils.ACL_CHECK_HOOK}();`);
2562
+ if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
2538
2563
  lines.push("");
2539
2564
  lines.push(` return ${QUERY_HOOKS.mutation}({`);
2540
2565
  const mutationFnArg = destructuredMutationArgs ? `{ ${destructuredMutationArgs}${endpoint.mediaUpload ? `${destructuredMutationArgs ? ", " : ""}abortController, onUploadProgress` : ""} }` : "";
@@ -2952,7 +2977,7 @@ function generateQueries(params) {
2952
2977
  };
2953
2978
  const hasAclCheck = resolver.options.checkAcl && aclEndpoints.length > 0;
2954
2979
  const aclCheckImport = {
2955
- bindings: [require_generate_utils.ACL_CHECK_HOOK],
2980
+ bindings: [ACL_CHECK_HOOK],
2956
2981
  from: resolver.options.aclCheckImportPath
2957
2982
  };
2958
2983
  const queryTypesImport = {
@@ -2967,7 +2992,7 @@ function generateQueries(params) {
2967
2992
  const hasWorkspaceContext = resolver.options.workspaceContext && endpoints.some((endpoint) => getWorkspaceParamNames(resolver, endpoint).length > 0);
2968
2993
  const workspaceContextImport = {
2969
2994
  bindings: ["useWorkspaceContext"],
2970
- from: require_generate_utils.PACKAGE_IMPORT_PATH
2995
+ from: require_generate_utils.CONFIG_PACKAGE_IMPORT_PATH
2971
2996
  };
2972
2997
  const endpointParams = endpoints.flatMap((endpoint) => endpoint.parameters);
2973
2998
  const endpointParamsParseSchemas = endpointParams.filter((param) => !["Path", "Header"].includes(param.type)).map((param) => param.parameterSortingEnumSchemaName ?? param.zodSchema);
@@ -3422,7 +3447,7 @@ function renderQuery({ resolver, endpoint, inlineEndpoints }) {
3422
3447
  }));
3423
3448
  lines.push(`export const ${require_generate_utils.getQueryName(endpoint)} = <TData>(${endpointParams ? `{ ${endpointArgs} }: { ${endpointParams} }, ` : ""}options?: AppQueryOptions<typeof ${inlineEndpoints ? require_generate_utils.getEndpointName(endpoint) : require_generate_utils.getImportedEndpointName(endpoint, resolver.options)}, TData>${hasAxiosRequestConfig ? `, ${require_generate_utils.AXIOS_REQUEST_CONFIG_NAME}?: ${require_generate_utils.getRequestConfigTypeName(resolver.options.restClient)}` : ""}) => {`);
3424
3449
  lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
3425
- if (hasAclCheck) lines.push(` const { checkAcl } = ${require_generate_utils.ACL_CHECK_HOOK}();`);
3450
+ if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
3426
3451
  lines.push(...renderWorkspaceParamResolutions({
3427
3452
  replacements: workspaceParamReplacements,
3428
3453
  paramTypes: workspaceParamTypes,
@@ -3492,7 +3517,7 @@ function renderMutation({ resolver, endpoint, inlineEndpoints, precomputed }) {
3492
3517
  }));
3493
3518
  lines.push(`export const ${require_generate_utils.getQueryName(endpoint, true)} = (${pathParamFirstArg}options?: AppMutationOptions<typeof ${endpointFunction}${mutationOptionsTypeArg}>${hasMutationEffects ? ` & ${require_generate_utils.MUTATION_EFFECTS.optionsType}` : ""}${hasAxiosRequestConfig ? `, ${require_generate_utils.AXIOS_REQUEST_CONFIG_NAME}?: ${require_generate_utils.getRequestConfigTypeName(resolver.options.restClient)}` : ""}) => {`);
3494
3519
  if (hasMutationDefaultOnError) lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
3495
- if (hasAclCheck) lines.push(` const { checkAcl } = ${require_generate_utils.ACL_CHECK_HOOK}();`);
3520
+ if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
3496
3521
  lines.push(...renderWorkspaceContextDestructure({
3497
3522
  replacements: workspaceParamReplacements,
3498
3523
  paramTypes: workspaceParamTypes,
@@ -3611,7 +3636,7 @@ function renderInfiniteQuery({ resolver, endpoint, inlineEndpoints }) {
3611
3636
  }));
3612
3637
  lines.push(`export const ${require_generate_utils.getInfiniteQueryName(endpoint)} = <TData>(${endpointParams ? `{ ${endpointArgsWithoutPage} }: { ${endpointParams} }, ` : ""}options?: AppInfiniteQueryOptions<typeof ${inlineEndpoints ? require_generate_utils.getEndpointName(endpoint) : require_generate_utils.getImportedEndpointName(endpoint, resolver.options)}, TData>${hasAxiosRequestConfig ? `, ${require_generate_utils.AXIOS_REQUEST_CONFIG_NAME}?: ${require_generate_utils.getRequestConfigTypeName(resolver.options.restClient)}` : ""}) => {`);
3613
3638
  lines.push(" const queryConfig = OpenApiQueryConfig.useConfig();");
3614
- if (hasAclCheck) lines.push(` const { checkAcl } = ${require_generate_utils.ACL_CHECK_HOOK}();`);
3639
+ if (hasAclCheck) lines.push(` const { checkAcl } = ${ACL_CHECK_HOOK}();`);
3615
3640
  lines.push(...renderWorkspaceParamResolutions({
3616
3641
  replacements: workspaceParamReplacements,
3617
3642
  paramTypes: workspaceParamTypes,
@@ -3716,7 +3741,7 @@ function getAclFiles(data, resolver) {
3716
3741
  return [{
3717
3742
  fileName: require_generate_utils.getOutputFileName({
3718
3743
  output: resolver.options.output,
3719
- fileName: require_generate_utils.getFileNameWithExtension(require_generate_utils.ACL_APP_ABILITY_FILE)
3744
+ fileName: require_generate_utils.getFileNameWithExtension(ACL_APP_ABILITY_FILE)
3720
3745
  }),
3721
3746
  content: generateAppAcl({
3722
3747
  resolver,
@@ -1,6 +1,7 @@
1
- import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc-glAKBEGP.mjs";
2
- import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-7RxjULpB.mjs";
3
- import { H as getQueryName, In as formatTag, Kt as getNamespaceName, O as getTagImportPath, S as getTsTypeBase, Tt as invalidVariableNameCharactersToCamel, d as isQuery, dt as DEFAULT_GENERATE_OPTIONS, en as isMediaTypeAllowed, t as getOpenApiDoc, tn as isParamMediaTypeAllowed, u as isMutation, x as getSchemaTsMetaType } from "./generate.runner-BvSprH6D.mjs";
1
+ import { t as generateCodeFromOpenAPIDoc } from "./generateCodeFromOpenAPIDoc--ufinTug.mjs";
2
+ import { t as getDataFromOpenAPIDoc } from "./getDataFromOpenAPIDoc-D8w0QElH.mjs";
3
+ import { H as getQueryName, Ht as getNamespaceName, Mn as formatTag, O as getTagImportPath, S as getTsTypeBase, Xt as isMediaTypeAllowed, Zt as isParamMediaTypeAllowed, bt as invalidVariableNameCharactersToCamel, d as isQuery, dt as DEFAULT_GENERATE_OPTIONS, u as isMutation, x as getSchemaTsMetaType } from "./native-bindings-BTQGSGhU.mjs";
4
+ import { t as getOpenApiDoc } from "./generate.runner-D8AYuEFm.mjs";
4
5
  //#region src/generators/core/getMetadataFromOpenAPIDoc.ts
5
6
  async function getMetadataFromOpenAPIDoc(openApiDoc, options) {
6
7
  const { resolver, data } = await getDataFromOpenAPIDoc(openApiDoc, options);
@@ -1,4 +1,4 @@
1
- import { $t as isMainResponseStatus, At as getZodSchemaName, Cn as STRING_SCHEMA, Dt as getEnumZodSchemaName, En as VOID_SCHEMA, Et as getBodyZodSchemaName, Hn as capitalize, In as formatTag, Jn as Profiler, Jt as escapeControlCharacters, Kn as removeWord, Kt as getNamespaceName, Ln as getEndpointTag, Mn as BODY_PARAMETER_NAME, Nn as JSON_APPLICATION_FORMAT, Nt as isNamedZodSchema, Ot as getParamZodSchemaName, Qt as isErrorStatus, Rn as getOperationTag, Sn as NUMBER_SCHEMA, Tn as UUID_SCHEMA, Tt as invalidVariableNameCharactersToCamel, Un as decapitalize, Wn as getMostCommonAdjacentCombinationSplit, Xt as getSchemaNameByRef, Yt as getParameterEnumNames, Zt as getSchemaRef, _n as BLOB_SCHEMA, an as pathParamToVariableName, bn as ENUM_SCHEMA, cn as unwrapQuotesIfNeeded, d as isQuery, dn as isArraySchemaObject, en as isMediaTypeAllowed, fn as isReferenceObject, gn as ANY_SCHEMA, hn as ALLOWED_PATH_IN, in as isSortingParameterObject, jt as getZodSchemaOperationName, kt as getResponseZodSchemaName, ln as wrapWithQuotesIfNeeded, lt as iterateSchema, mn as ALLOWED_METHODS, nn as isPathExcluded, on as pathToVariableName, pn as isSchemaObject, qn as snakeToCamel, qt as autocorrectRef, rn as isPrimitiveType, s as pick, sn as replaceHyphenatedPath, tn as isParamMediaTypeAllowed, un as inferRequiredSchema, ut as getUniqueArray, vn as DATETIME_SCHEMA, wn as URL_SCHEMA, xn as INT_SCHEMA, yn as EMAIL_SCHEMA, zn as isTagIncluded } from "./generate.runner-BvSprH6D.mjs";
1
+ import { $t as isPrimitiveType, Bn as getMostCommonAdjacentCombinationSplit, Ct as getParamZodSchemaName, Et as getZodSchemaOperationName, Fn as isTagIncluded, Gt as getParameterEnumNames, Hn as removeWord, Ht as getNamespaceName, Jt as isErrorStatus, Kt as getSchemaNameByRef, Mn as formatTag, Nn as getEndpointTag, On as BODY_PARAMETER_NAME, Ot as isNamedZodSchema, Pn as getOperationTag, Qt as isPathExcluded, Rn as capitalize, Sn as VOID_SCHEMA, St as getEnumZodSchemaName, Tt as getZodSchemaName, Un as snakeToCamel, Ut as autocorrectRef, Wn as Profiler, Wt as escapeControlCharacters, Xt as isMediaTypeAllowed, Yt as isMainResponseStatus, Zt as isParamMediaTypeAllowed, _n as INT_SCHEMA, an as wrapWithQuotesIfNeeded, bn as URL_SCHEMA, bt as invalidVariableNameCharactersToCamel, cn as isReferenceObject, d as isQuery, dn as ALLOWED_PATH_IN, en as isSortingParameterObject, fn as ANY_SCHEMA, gn as ENUM_SCHEMA, hn as EMAIL_SCHEMA, in as unwrapQuotesIfNeeded, kn as JSON_APPLICATION_FORMAT, ln as isSchemaObject, lt as iterateSchema, mn as DATETIME_SCHEMA, nn as pathToVariableName, on as inferRequiredSchema, pn as BLOB_SCHEMA, qt as getSchemaRef, rn as replaceHyphenatedPath, s as pick, sn as isArraySchemaObject, tn as pathParamToVariableName, un as ALLOWED_METHODS, ut as getUniqueArray, vn as NUMBER_SCHEMA, wt as getResponseZodSchemaName, xn as UUID_SCHEMA, xt as getBodyZodSchemaName, yn as STRING_SCHEMA, zn as decapitalize } from "./native-bindings-BTQGSGhU.mjs";
2
2
  //#region src/generators/const/validation.const.ts
3
3
  const HTTP_STATUS_CODES = {
4
4
  "100": "Continue",
@@ -0,0 +1,38 @@
1
+ //#region src/lib/config/i18n.d.ts
2
+ declare const ns = "openapi";
3
+ declare const resources: {
4
+ readonly en: {
5
+ readonly openapi: {
6
+ openapi: {
7
+ sharedErrors: {
8
+ dataValidation: string;
9
+ internalError: string;
10
+ networkError: string;
11
+ canceledError: string;
12
+ unknownError: string;
13
+ unknownErrorWithCode: string;
14
+ };
15
+ };
16
+ };
17
+ };
18
+ readonly sl: {
19
+ readonly openapi: {
20
+ openapi: {
21
+ sharedErrors: {
22
+ dataValidation: string;
23
+ internalError: string;
24
+ networkError: string;
25
+ canceledError: string;
26
+ unknownError: string;
27
+ unknownErrorWithCode: string;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ };
33
+ type TranslateFunction = (key: string, options?: {
34
+ ns?: string;
35
+ }) => string;
36
+ declare function configureTranslations<T>(getter: () => T): void;
37
+ //#endregion
38
+ export { resources as i, configureTranslations as n, ns as r, TranslateFunction as t };
@@ -0,0 +1,36 @@
1
+ //#region src/lib/assets/locales/en/translation.json
2
+ var translation_default$1 = { openapi: { "sharedErrors": {
3
+ "dataValidation": "An error occurred while validating the data",
4
+ "internalError": "An internal error occurred. This is most likely a bug on our end. Please try again later.",
5
+ "networkError": "A network error occurred. Are you connected to the internet?",
6
+ "canceledError": "The request was canceled.",
7
+ "unknownError": "An unknown error occurred. Please try again later.",
8
+ "unknownErrorWithCode": "An unknown error occurred. Error code: \"{{code}}\""
9
+ } } };
10
+ //#endregion
11
+ //#region src/lib/assets/locales/sl/translation.json
12
+ var translation_default = { openapi: { "sharedErrors": {
13
+ "dataValidation": "Pri preverjanju podatkov je prišlo do napake",
14
+ "internalError": "Prišlo je do notranje napake.",
15
+ "networkError": "Prišlo je do napake v omrežju.",
16
+ "canceledError": "Zahteva je bila preklicana.",
17
+ "unknownError": "Prišlo je do neznane napake.",
18
+ "unknownErrorWithCode": "Prišlo je do neznane napake. Koda napake: \"{{code}}\""
19
+ } } };
20
+ //#endregion
21
+ //#region src/lib/config/i18n.ts
22
+ const ns = "openapi";
23
+ const resources = {
24
+ en: { [ns]: translation_default$1 },
25
+ sl: { [ns]: translation_default }
26
+ };
27
+ let getT = null;
28
+ function configureTranslations(getter) {
29
+ getT = () => getter();
30
+ }
31
+ function resolveT() {
32
+ if (!getT) throw new Error("Translations not configured. Call configureTranslations() at app startup.");
33
+ return getT();
34
+ }
35
+ //#endregion
36
+ export { resources as i, ns as n, resolveT as r, configureTranslations as t };
package/dist/index.d.mts CHANGED
@@ -1,163 +1,12 @@
1
- import { a as ErrorHandler, c as SharedErrorHandler, d as ns, f as resources, i as ErrorEntry, l as TranslateFunction, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException, u as configureTranslations } from "./error-handling-CNOHs4Fc.mjs";
1
+ import { i as resources, n as configureTranslations, r as ns, t as TranslateFunction } from "./i18n-B_brQh4X.mjs";
2
+ import { a as ErrorHandler, c as SharedErrorHandler, i as ErrorEntry, n as DomainErrorEntry, o as ErrorHandlerOptions, r as DomainErrorRegistry, s as GeneralErrorCodes, t as ApplicationException } from "./error-handling-LPEPQV1V.mjs";
3
+ import { n as AuthGuardProps, r as AuthContext, t as AuthGuard } from "./AuthGuard-GbtTDXs0.mjs";
4
+ import { a as RestClient, i as Response, n as RequestConfig, o as RestInterceptor, r as RequestInfo, t as RestClient$1 } from "./rest-client-CQyFvqYC.mjs";
5
+ import { n as useWorkspaceContext, r as OpenApiRouter, t as OpenApiWorkspaceContext } from "./workspace.context-isVY9ves.mjs";
6
+ import { i as QueryModule, n as InvalidationMapFunc, r as OpenApiQueryConfig, t as InvalidationMap } from "./queryConfig.context-CRJOgf19.mjs";
7
+ import { t as RestUtils } from "./rest.utils-rezWAIYL.mjs";
2
8
  import { t as OpenAPICodegenConfig } from "./config-DgrOddSC.mjs";
3
9
  import { d as TransportResponse, l as TransportRequest, n as HttpError, p as UploadProgress, u as TransportRequestConfig } from "./rest-transport.types-DM5-qyOJ.mjs";
4
10
  import { n as NativeRestInterceptor, r as NativeRestClient, t as NativeInterceptor } from "./native-rest-interceptor-Cz6saoq5.mjs";
5
- import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosResponseHeaders, CreateAxiosDefaults } from "axios";
6
- import { z } from "zod";
7
- import { PropsWithChildren, ReactNode } from "react";
8
- import { InfiniteData, QueryKey, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
9
- //#region src/lib/rest/rest-interceptor.d.ts
10
- declare class RestInterceptor<T extends any[]> {
11
- private applyInterceptor;
12
- private interceptorIdMap;
13
- constructor(applyInterceptor: (client: AxiosInstance, ...args: T) => number);
14
- addInterceptor(client: AxiosInstance, ...args: T): void;
15
- removeInterceptor(client: AxiosInstance): void;
16
- }
17
- //#endregion
18
- //#region src/lib/rest/rest-client.types.d.ts
19
- type GeneralErrorCodes$1 = string;
20
- interface RequestInfo<ZOutput, ECodes extends string> {
21
- resSchema: z.ZodType<ZOutput>;
22
- errorHandler?: ErrorHandler<ECodes>;
23
- }
24
- interface RequestConfig<IsRawRes extends boolean = false> {
25
- rawResponse?: IsRawRes;
26
- allowInvalidResponseData?: boolean;
27
- }
28
- type Response<ZOutput, IsRawRes extends boolean = false> = IsRawRes extends true ? AxiosResponse<ZOutput> : ZOutput;
29
- interface RestClient {
30
- attachInterceptors<T extends any[]>(interceptors?: RestInterceptor<T>[], ...args: T): void;
31
- attachInterceptor<T extends any[]>(interceptor: RestInterceptor<T>, ...args: T): void;
32
- ejectInterceptor<T extends any[]>(interceptor: RestInterceptor<T>): void;
33
- get<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
34
- post<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
35
- patch<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
36
- put<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
37
- delete<ZOutput, ECodes extends string = GeneralErrorCodes$1, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
38
- }
39
- //#endregion
40
- //#region src/lib/rest/rest-client.d.ts
41
- declare class RestClient$1 implements RestClient {
42
- private readonly client;
43
- private readonly errorHandler;
44
- constructor({ config, interceptors, errorHandler }?: {
45
- config?: CreateAxiosDefaults;
46
- interceptors?: RestInterceptor<any[]>[];
47
- errorHandler?: ErrorHandler<any>;
48
- });
49
- attachInterceptors<T extends any[]>(interceptors?: RestInterceptor<T>[], ...args: T): void;
50
- attachInterceptor<T extends any[]>(interceptor: RestInterceptor<T>, ...args: T): void;
51
- ejectInterceptor<T extends any[]>(interceptor: RestInterceptor<T>): void;
52
- get<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
53
- post<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
54
- patch<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
55
- put<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
56
- delete<ZOutput, ECodes extends string = GeneralErrorCodes, IsRawRes extends boolean = false>(requestInfo: RequestInfo<ZOutput, ECodes>, url: string, data?: any, requestConfig?: AxiosRequestConfig & RequestConfig<IsRawRes>): Promise<Response<ZOutput, IsRawRes>>;
57
- private makeRequest;
58
- }
59
- //#endregion
60
- //#region src/lib/rest/rest.utils.d.ts
61
- declare namespace RestUtils {
62
- const extractServerResponseCode: (e: unknown) => string | number | null;
63
- const doesServerErrorMessageContain: (e: AxiosError, text: string) => boolean;
64
- const extractServerErrorMessage: (e: unknown) => string | null;
65
- const extractContentDispositionFilename: (headers: AxiosResponseHeaders) => string | undefined;
66
- }
67
- //#endregion
68
- //#region src/lib/react-query.types.d.ts
69
- type Function = (...args: any) => any;
70
- type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
71
- type IsAny<T> = IfAny<T, true, never>;
72
- type IsUnknown<T, Y, N = T> = IsAny<T> extends never ? (unknown extends T ? Y : N) : N;
73
- 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">;
74
- type AppMutationOptions<TFunction extends Function, TVariables = void, TData = Awaited<ReturnType<TFunction>>, TErrorCodes = GeneralErrorCodes> = Omit<UseMutationOptions<TData, ApplicationException<TErrorCodes>, TVariables>, "mutationKey" | "mutationFn">;
75
- 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">;
76
- //#endregion
77
- //#region src/lib/config/queryConfig.context.d.ts
78
- type QueryModule = string | number | symbol;
79
- type InvalidationMapFunc<TData = any, TVariables = any> = (data: TData, variables: TVariables) => QueryKey[];
80
- type InvalidationMap<TQueryModule extends QueryModule = QueryModule, TData = any, TVariables = any> = Partial<Record<TQueryModule, InvalidationMapFunc<TData, TVariables>>>;
81
- declare namespace OpenApiQueryConfig {
82
- export interface Type<TQueryModule extends QueryModule = QueryModule> {
83
- preferUpdate?: boolean;
84
- invalidateCurrentModule?: boolean;
85
- invalidationMap?: InvalidationMap<TQueryModule>;
86
- crossTabInvalidation?: boolean;
87
- allowInvalidResponseData?: boolean;
88
- onError?: (error: unknown) => void;
89
- }
90
- type ProviderProps<TQueryModule extends QueryModule = QueryModule> = Type<TQueryModule>;
91
- export function Provider<TQueryModule extends QueryModule = QueryModule>({ preferUpdate, invalidateCurrentModule, invalidationMap, crossTabInvalidation, allowInvalidResponseData, onError, children }: PropsWithChildren<ProviderProps<TQueryModule>>): import("react").JSX.Element;
92
- export const useConfig: <TQueryModule extends QueryModule = QueryModule>() => Type<TQueryModule>;
93
- export {};
94
- }
95
- //#endregion
96
- //#region src/lib/react-query/useMutationEffects.d.ts
97
- interface MutationEffectsOptions<TQueryModule extends QueryModule = QueryModule> {
98
- invalidateCurrentModule?: boolean;
99
- crossTabInvalidation?: boolean;
100
- invalidationMap?: InvalidationMap<TQueryModule>;
101
- invalidateModules?: QueryModule[];
102
- invalidateKeys?: QueryKey[];
103
- preferUpdate?: boolean;
104
- }
105
- interface UseMutationEffectsProps<TQueryModule extends QueryModule = QueryModule> {
106
- currentModule: TQueryModule;
107
- }
108
- declare function useMutationEffects<TQueryModule extends QueryModule = QueryModule>({ currentModule }: UseMutationEffectsProps<TQueryModule>): {
109
- runMutationEffects: <TData, TVariables>(data: TData, variables: TVariables, options?: MutationEffectsOptions<TQueryModule>, updateKeys?: QueryKey[]) => Promise<void>;
110
- };
111
- //#endregion
112
- //#region src/lib/config/router.context.d.ts
113
- interface RouterProviderProps {
114
- replace: (url: string) => void;
115
- }
116
- declare namespace OpenApiRouter {
117
- const Provider: ({ children, replace }: PropsWithChildren<RouterProviderProps>) => import("react").JSX.Element;
118
- const useRouter: () => RouterProviderProps;
119
- }
120
- //#endregion
121
- //#region src/lib/config/workspace.context.d.ts
122
- type WorkspaceValues = Record<string, unknown>;
123
- interface WorkspaceProviderProps {
124
- values?: WorkspaceValues;
125
- }
126
- declare namespace OpenApiWorkspaceContext {
127
- const Provider: ({ values, children }: PropsWithChildren<WorkspaceProviderProps>) => import("react").JSX.Element;
128
- const useContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
129
- const resolveParam: <T>(context: WorkspaceValues, name: string, value: T | null | undefined) => T;
130
- }
131
- declare const useWorkspaceContext: <TValues extends WorkspaceValues = WorkspaceValues>() => TValues;
132
- //#endregion
133
- //#region src/lib/auth/auth.context.d.ts
134
- declare namespace AuthContext {
135
- export interface Routes {
136
- authenticated?: string;
137
- unauthenticated?: string;
138
- }
139
- interface Type<TUser = unknown> {
140
- isAuthenticated: boolean;
141
- isInitializing: boolean;
142
- logout: () => void;
143
- updateTokens?: (accessToken: string | null, refreshToken?: string | null) => void;
144
- accessToken?: string | null;
145
- user?: TUser | null;
146
- userPromise?: () => Promise<TUser | null>;
147
- routes?: Routes;
148
- loadingState?: ReactNode;
149
- }
150
- type ProviderProps<TUser = unknown> = Type<TUser>;
151
- export const Provider: <TUser>({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children }: PropsWithChildren<ProviderProps<TUser>>) => import("react").JSX.Element;
152
- export const useAuth: <TUser>() => Type<TUser>;
153
- export {};
154
- }
155
- //#endregion
156
- //#region src/lib/auth/AuthGuard.d.ts
157
- interface AuthGuardProps {
158
- type: "public-only" | "private";
159
- redirectTo?: string;
160
- }
161
- declare const AuthGuard: ({ type, redirectTo, children }: PropsWithChildren<AuthGuardProps>) => import("react").ReactNode;
162
- //#endregion
11
+ import { a as AppQueryOptions, i as AppMutationOptions, n as useMutationEffects, r as AppInfiniteQueryOptions, t as MutationEffectsOptions } from "./useMutationEffects-DIdL8tlx.mjs";
163
12
  export { type AppInfiniteQueryOptions, type AppMutationOptions, type AppQueryOptions, ApplicationException, AuthContext, AuthGuard, type AuthGuardProps, type DomainErrorEntry, DomainErrorRegistry, type ErrorEntry, ErrorHandler, type ErrorHandlerOptions, type GeneralErrorCodes, type RestClient as IRestClient, type InvalidationMap, type InvalidationMapFunc, type MutationEffectsOptions, HttpError as NativeHttpError, type NativeInterceptor, type TransportRequest as NativeRequest, type TransportRequestConfig as NativeRequestConfig, type TransportResponse as NativeResponse, NativeRestClient, NativeRestInterceptor, type UploadProgress as NativeUploadProgress, OpenAPICodegenConfig, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, type QueryModule, type RequestConfig, type RequestInfo, type Response, RestClient$1 as RestClient, RestInterceptor, RestUtils, SharedErrorHandler, type TranslateFunction, configureTranslations, ns, resources, useMutationEffects, useWorkspaceContext };