@povio/openapi-codegen-cli 2.0.8-rc.37 → 2.0.8-rc.39
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/README.md +0 -87
- package/dist/acl.d.ts +4 -0
- package/dist/acl.mjs +7 -73
- package/dist/commands/check.command.d.ts +2 -0
- package/dist/commands/check.d.ts +7 -0
- package/dist/commands/generate.command.d.ts +2 -0
- package/dist/commands/generate.d.ts +8 -0
- package/dist/generator.d.ts +3 -0
- package/dist/generator.js +78 -0
- package/dist/generators/checkOpenAPIDoc.d.ts +3 -0
- package/dist/generators/const/acl.const.d.ts +13 -0
- package/dist/generators/const/buildConfigs.const.d.ts +1 -0
- package/dist/generators/const/deps.const.d.ts +38 -0
- package/dist/generators/const/endpoints.const.d.ts +11 -0
- package/dist/generators/const/js.const.d.ts +1 -0
- package/dist/generators/const/openapi.const.d.ts +7 -0
- package/dist/generators/const/options.const.d.ts +2 -0
- package/dist/generators/const/package.const.d.ts +2 -0
- package/dist/generators/const/queries.const.d.ts +8 -0
- package/dist/generators/const/validation.const.d.ts +53 -0
- package/dist/generators/const/zod.const.d.ts +19 -0
- package/dist/generators/core/SchemaResolver.class.d.ts +71 -0
- package/dist/generators/core/endpoints/getEndpointAcl.d.ts +8 -0
- package/dist/generators/core/endpoints/getEndpointBody.d.ts +13 -0
- package/dist/generators/core/endpoints/getEndpointParameter.d.ts +11 -0
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.d.ts +3 -0
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.test.d.ts +1 -0
- package/dist/generators/core/getDataFromOpenAPIDoc.d.ts +8 -0
- package/dist/generators/core/getMetadataFromOpenAPIDoc.d.ts +4 -0
- package/dist/generators/core/getMetadataFromOpenAPIDoc.test.d.ts +1 -0
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.d.ts +2 -0
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.test.d.ts +1 -0
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.d.ts +6 -0
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.test.d.ts +1 -0
- package/dist/generators/core/openapi/getSchemaRefObjs.d.ts +4 -0
- package/dist/generators/core/openapi/iterateSchema.d.ts +22 -0
- package/dist/generators/core/resolveConfig.d.ts +7 -0
- package/dist/generators/core/zod/ZodSchema.class.d.ts +26 -0
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaNames.d.ts +2 -0
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaTags.d.ts +2 -0
- package/dist/generators/core/zod/enumExtraction/updateExtractedEnumZodSchemaData.d.ts +17 -0
- package/dist/generators/core/zod/getZodChain.d.ts +8 -0
- package/dist/generators/core/zod/getZodSchema.d.ts +17 -0
- package/dist/generators/core/zod/getZodSchema.test.d.ts +1 -0
- package/dist/generators/core/zod/getZodSchemaRefs.d.ts +6 -0
- package/dist/generators/core/zod/getZodSchemasFromOpenAPIDoc.d.ts +6 -0
- package/dist/generators/core/zod/resolveZodSchemaName.d.ts +10 -0
- package/dist/generators/core/zod/sortZodSchemasByTopology.d.ts +4 -0
- package/dist/generators/generate/generateAcl.d.ts +3 -0
- package/dist/generators/generate/generateAclCheck.d.ts +2 -0
- package/dist/generators/generate/generateAppRestClient.d.ts +2 -0
- package/dist/generators/generate/generateConfigs.d.ts +2 -0
- package/dist/generators/generate/generateEndpoints.d.ts +2 -0
- package/dist/generators/generate/generateModels.d.ts +2 -0
- package/dist/generators/generate/generateQueries.d.ts +2 -0
- package/dist/generators/generate/generateQueryModules.d.ts +2 -0
- package/dist/generators/generate/generateZodExtended.d.ts +2 -0
- package/dist/generators/generateCodeFromOpenAPIDoc.d.ts +4 -0
- package/dist/generators/types/builder-config.d.ts +48 -0
- package/dist/generators/types/common.d.ts +27 -0
- package/dist/generators/types/config.d.ts +2 -0
- package/dist/generators/types/endpoint.d.ts +50 -0
- package/dist/generators/types/generate.d.ts +39 -0
- package/dist/generators/types/metadata.d.ts +51 -0
- package/dist/generators/types/openapi.d.ts +22 -0
- package/dist/generators/types/options.d.ts +66 -0
- package/dist/generators/types/validation.d.ts +5 -0
- package/dist/generators/utils/array.utils.d.ts +1 -0
- package/dist/generators/utils/endpoint.utils.d.ts +12 -0
- package/dist/generators/utils/endpoint.utils.test.d.ts +1 -0
- package/dist/generators/utils/file.utils.d.ts +8 -0
- package/dist/generators/utils/generate/generate.acl.utils.d.ts +23 -0
- package/dist/generators/utils/generate/generate.configs.utils.d.ts +15 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +41 -0
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +39 -0
- package/dist/generators/utils/generate/generate.imports.utils.test.d.ts +1 -0
- package/dist/generators/utils/generate/generate.openapi.utils.d.ts +2 -0
- package/dist/generators/utils/generate/generate.query.utils.d.ts +6 -0
- package/dist/generators/utils/generate/generate.utils.d.ts +18 -0
- package/dist/generators/utils/generate/generate.zod.utils.d.ts +13 -0
- package/dist/generators/utils/generate-files.utils.d.ts +6 -0
- package/dist/generators/utils/hbs/hbs-template.utils.d.ts +3 -0
- package/dist/generators/utils/hbs/hbs.acl.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.common.utils.d.ts +1 -0
- package/dist/generators/utils/hbs/hbs.endpoints.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.imports.utils.d.ts +1 -0
- package/dist/generators/utils/hbs/hbs.partials.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.query.utils.d.ts +2 -0
- package/dist/generators/utils/hbs/hbs.zod.utils.d.ts +2 -0
- package/dist/generators/utils/js.utils.d.ts +2 -0
- package/dist/generators/utils/js.utils.test.d.ts +1 -0
- package/dist/generators/utils/math.utils.d.ts +1 -0
- package/dist/generators/utils/namespace.utils.d.ts +7 -0
- package/dist/generators/utils/object.utils.d.ts +13 -0
- package/dist/generators/utils/object.utils.test.d.ts +1 -0
- package/dist/generators/utils/openapi-schema.utils.d.ts +15 -0
- package/dist/generators/utils/openapi.utils.d.ts +23 -0
- package/dist/generators/utils/openapi.utils.test.d.ts +1 -0
- package/dist/generators/utils/operation.utils.d.ts +22 -0
- package/dist/generators/utils/operation.utils.test.d.ts +1 -0
- package/dist/generators/utils/query.utils.d.ts +7 -0
- package/dist/generators/utils/sort.utils.d.ts +7 -0
- package/dist/generators/utils/string.utils.d.ts +14 -0
- package/dist/generators/utils/string.utils.test.d.ts +1 -0
- package/dist/generators/utils/tag.utils.d.ts +7 -0
- package/dist/generators/utils/ts.utils.d.ts +16 -0
- package/dist/generators/utils/validation.utils.d.ts +17 -0
- package/dist/generators/utils/zod-schema.utils.d.ts +15 -0
- package/dist/helpers/cli.helper.d.ts +22 -0
- package/dist/helpers/config.helper.d.ts +3 -0
- package/dist/helpers/version.helper.d.ts +4 -0
- package/dist/helpers/yargs.helper.d.ts +10 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.mjs +22 -252
- package/dist/lib/acl/AclGuard.d.ts +8 -0
- package/dist/lib/acl/AclGuard.mjs +14 -0
- package/dist/lib/acl/Can.d.ts +9 -0
- package/dist/lib/acl/Can.mjs +11 -0
- package/dist/lib/acl/ability.context.d.ts +15 -0
- package/dist/lib/acl/ability.context.mjs +37 -0
- package/dist/lib/acl/appAbility.types.d.ts +3 -0
- package/dist/lib/assets/locales/en/translation.json.mjs +8 -0
- package/dist/lib/assets/locales/sl/translation.json.mjs +8 -0
- package/dist/lib/auth/AuthGuard.d.ts +6 -0
- package/dist/lib/auth/AuthGuard.mjs +26 -0
- package/dist/lib/auth/auth.context.d.ts +22 -0
- package/dist/lib/auth/auth.context.mjs +41 -0
- package/dist/lib/config/i18n.d.ts +32 -0
- package/dist/lib/config/i18n.mjs +31 -0
- package/dist/lib/config/queryConfig.context.d.ts +17 -0
- package/dist/lib/config/queryConfig.context.mjs +26 -0
- package/dist/lib/config/router.context.d.ts +9 -0
- package/dist/lib/config/router.context.mjs +20 -0
- package/dist/lib/react-query.types.d.ts +10 -0
- package/dist/lib/rest/error-handling.d.ts +30 -0
- package/dist/lib/rest/error-handling.mjs +132 -0
- package/dist/lib/rest/rest-client.d.ts +22 -0
- package/dist/lib/rest/rest-client.mjs +62 -0
- package/dist/lib/rest/rest-client.types.d.ts +23 -0
- package/dist/lib/rest/rest-interceptor.d.ts +8 -0
- package/dist/lib/rest/rest-interceptor.mjs +21 -0
- package/dist/lib/rest/rest.utils.d.ts +7 -0
- package/dist/lib/rest/rest.utils.mjs +51 -0
- package/dist/sh.d.ts +2 -0
- package/dist/sh.js +649 -0
- package/package.json +43 -51
- package/src/assets/useCrossTabQueryInvalidation.ts +40 -0
- package/src/assets/useMutationEffects.ts +94 -0
- package/src/generators/templates/acl-check.hbs +29 -0
- package/src/generators/templates/acl.hbs +19 -0
- package/src/generators/templates/app-acl.hbs +17 -0
- package/src/generators/templates/app-rest-client.hbs +7 -0
- package/src/generators/templates/configs.hbs +80 -0
- package/src/generators/templates/endpoints.hbs +44 -0
- package/src/generators/templates/models.hbs +23 -0
- package/src/generators/templates/partials/acl-check-call.hbs +1 -0
- package/src/generators/templates/partials/casl-ability-function.hbs +12 -0
- package/src/generators/templates/partials/casl-ability-query.hbs +1 -0
- package/src/generators/templates/partials/casl-ability-type.hbs +1 -0
- package/src/generators/templates/partials/columns-config.hbs +11 -0
- package/src/generators/templates/partials/endpoint-config.hbs +31 -0
- package/src/generators/templates/partials/endpoint-param-parse.hbs +1 -0
- package/src/generators/templates/partials/endpoint-params.hbs +1 -0
- package/src/generators/templates/partials/import.hbs +1 -0
- package/src/generators/templates/partials/inputs-config.hbs +10 -0
- package/src/generators/templates/partials/model-js-docs.hbs +6 -0
- package/src/generators/templates/partials/query-js-docs.hbs +31 -0
- package/src/generators/templates/partials/query-keys.hbs +11 -0
- package/src/generators/templates/partials/query-use-infinite-query.hbs +22 -0
- package/src/generators/templates/partials/query-use-mutation.hbs +54 -0
- package/src/generators/templates/partials/query-use-query.hbs +17 -0
- package/src/generators/templates/queries.hbs +54 -0
- package/src/generators/templates/query-modules.hbs +5 -0
- package/src/generators/templates/zod-extended.hbs +49 -0
- package/dist/acl.d.mts +0 -59
- package/dist/auth.context-Bu5KW2sI.mjs +0 -59
- package/dist/config-DTx4Ck6g.d.mts +0 -6
- package/dist/error-handling-CXeVTk1T.d.mts +0 -38
- package/dist/error-handling-DkPY7Asf.mjs +0 -187
- package/dist/generate.runner-DLLGYMVB.mjs +0 -90
- package/dist/generateCodeFromOpenAPIDoc-CFbiHxB7.mjs +0 -4729
- package/dist/generator.d.mts +0 -65
- package/dist/generator.mjs +0 -144
- package/dist/index.d.mts +0 -231
- package/dist/options-fyt0BYYE.d.mts +0 -95
- package/dist/sh.d.mts +0 -1
- package/dist/sh.mjs +0 -450
- package/dist/vite.d.mts +0 -11
- package/dist/vite.mjs +0 -53
- package/dist/zod.d.mts +0 -20
- package/dist/zod.mjs +0 -33
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import { SchemaResolver } from '../core/SchemaResolver.class';
|
|
3
|
+
import { TsMetaType, TsTypeBase } from '../types/metadata';
|
|
4
|
+
import { PrimitiveType } from '../types/openapi';
|
|
5
|
+
export declare function primitiveTypeToTsType(type: PrimitiveType): string;
|
|
6
|
+
export declare function getTsTypeBase({ zodSchemaName, schema, resolver, }: {
|
|
7
|
+
zodSchemaName?: string;
|
|
8
|
+
schema?: OpenAPIV3.SchemaObject;
|
|
9
|
+
resolver: SchemaResolver;
|
|
10
|
+
}): TsTypeBase;
|
|
11
|
+
export declare function getSchemaTsMetaType({ schema, isCircular, parentTypes, resolver, }: {
|
|
12
|
+
schema?: OpenAPIV3.SchemaObject;
|
|
13
|
+
isCircular?: boolean;
|
|
14
|
+
parentTypes: TsTypeBase[];
|
|
15
|
+
resolver: SchemaResolver;
|
|
16
|
+
}): TsMetaType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpStatusCode } from '../const/validation.const';
|
|
2
|
+
import { Endpoint, EndpointParameter } from '../types/endpoint';
|
|
3
|
+
import { OperationObject } from '../types/openapi';
|
|
4
|
+
import { ValidationError, ValidationErrorType } from '../types/validation';
|
|
5
|
+
export declare function getInvalidSchemaError(message: string): ValidationError;
|
|
6
|
+
export declare function getInvalidOperationIdError(operationId: string): ValidationError;
|
|
7
|
+
export declare function getMissingPathParameterError(params: EndpointParameter[], path: string): ValidationError;
|
|
8
|
+
export declare function getNotAllowedInlineEnumError(enumProperty: string): ValidationError;
|
|
9
|
+
export declare function getNotAllowedCircularSchemaError(message: string): ValidationError;
|
|
10
|
+
export declare function getMissingAclConditionPropertyError(propertyName: string, operation: OperationObject, endpoint: Endpoint): ValidationError;
|
|
11
|
+
export declare function getMissingStatusCodeError(statusCode: HttpStatusCode, operation: OperationObject, endpoint: Endpoint): ValidationError;
|
|
12
|
+
export declare function getInvalidStatusCodeError(statusCode: {
|
|
13
|
+
expected: HttpStatusCode;
|
|
14
|
+
received: HttpStatusCode;
|
|
15
|
+
}, operation: OperationObject, endpoint: Endpoint): ValidationError;
|
|
16
|
+
export declare function getMultipleSuccessStatusCodesError(statusCodes: HttpStatusCode[], operation: OperationObject, endpoint: Endpoint): ValidationError;
|
|
17
|
+
export declare function groupByType(validationErrors: ValidationError[]): Record<ValidationErrorType, string[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const getZodSchemaName: (name: string, schemaSuffix: string) => string;
|
|
2
|
+
export declare const getEnumZodSchemaName: (name: string, enumSuffix: string, schemaSuffix: string) => string;
|
|
3
|
+
export declare const isNamedZodSchema: (schema: string) => boolean;
|
|
4
|
+
export declare const isEnumZodSchema: (schema: string) => boolean;
|
|
5
|
+
export declare const getZodSchemaOperationName: (operationName: string, isUniqueOperationName: boolean, tag: string) => string;
|
|
6
|
+
export declare const getBodyZodSchemaName: (operationName: string) => string;
|
|
7
|
+
export declare const getParamZodSchemaName: (operationName: string, paramName: string) => string;
|
|
8
|
+
export declare const getMainResponseZodSchemaName: (operationName: string) => string;
|
|
9
|
+
export declare const getErrorResponseZodSchemaName: (operationName: string, statusCode: string) => string;
|
|
10
|
+
export declare function getResponseZodSchemaName({ statusCode, operationName, isUniqueOperationName, tag, }: {
|
|
11
|
+
statusCode: string;
|
|
12
|
+
operationName: string;
|
|
13
|
+
isUniqueOperationName: boolean;
|
|
14
|
+
tag: string;
|
|
15
|
+
}): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print a variable, color it magenta if it's different from the default
|
|
3
|
+
* @param name
|
|
4
|
+
* @param value
|
|
5
|
+
* @param defaultValue
|
|
6
|
+
*/
|
|
7
|
+
export declare function logVariable(name: string, value: any, defaultValue?: string | number): void;
|
|
8
|
+
export declare function log(message: string): void;
|
|
9
|
+
export declare function logInfo(message: string): void;
|
|
10
|
+
export declare function logNotice(message: string): void;
|
|
11
|
+
export declare function logSuccess(message: string): void;
|
|
12
|
+
export declare function logWarning(message: string): void;
|
|
13
|
+
export declare function logError(error: Error | string, message?: string): void;
|
|
14
|
+
export declare function logBanner(message: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Request a ENV variable from the user if not set
|
|
17
|
+
* @param name
|
|
18
|
+
* @param value
|
|
19
|
+
* @param suggested - the value the scripts expects and suggest
|
|
20
|
+
*/
|
|
21
|
+
export declare function promptVar(name: string, value: string, suggested?: string): Promise<string>;
|
|
22
|
+
export declare function confirm(message: string): Promise<boolean>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Options } from 'yargs';
|
|
2
|
+
interface IOptionProperties extends Options {
|
|
3
|
+
envAlias?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function YargOption(properties: IOptionProperties): (target: object, propertyKey: string) => void;
|
|
6
|
+
export declare function getYargsOption<T>(target: any): Record<keyof T, IOptionProperties>;
|
|
7
|
+
export declare function getBuilder(options: any): (y: any) => Promise<any>;
|
|
8
|
+
export declare function getYargsOptions<T>(target: any): Record<keyof T, Options>;
|
|
9
|
+
export declare function loadYargsConfig<T>(cls: new () => T, _argv: Record<string, unknown>): Promise<T>;
|
|
10
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './generators/types/config';
|
|
2
|
+
export { RestClient } from './lib/rest/rest-client';
|
|
3
|
+
export type { RequestInfo, RequestConfig, Response, RestClient as IRestClient } from './lib/rest/rest-client.types';
|
|
4
|
+
export { RestInterceptor } from './lib/rest/rest-interceptor';
|
|
5
|
+
export { RestUtils } from './lib/rest/rest.utils';
|
|
6
|
+
export { ApplicationException, ErrorHandler, SharedErrorHandler } from './lib/rest/error-handling';
|
|
7
|
+
export type { GeneralErrorCodes, ErrorHandlerOptions, ErrorEntry } from './lib/rest/error-handling';
|
|
8
|
+
export type { AppQueryOptions, AppMutationOptions, AppInfiniteQueryOptions } from './lib/react-query.types';
|
|
9
|
+
export { OpenApiRouter } from './lib/config/router.context';
|
|
10
|
+
export { OpenApiQueryConfig } from './lib/config/queryConfig.context';
|
|
11
|
+
export type { InvalidationMap } from './lib/config/queryConfig.context';
|
|
12
|
+
export { ns, resources } from './lib/config/i18n';
|
|
13
|
+
export { AuthContext } from './lib/auth/auth.context';
|
|
14
|
+
export { AuthGuard } from './lib/auth/AuthGuard';
|
|
15
|
+
export type { AuthGuardProps } from './lib/auth/AuthGuard';
|
package/dist/index.mjs
CHANGED
|
@@ -1,253 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
ejectInterceptor(interceptor) {
|
|
25
|
-
interceptor.removeInterceptor(this.client);
|
|
26
|
-
}
|
|
27
|
-
async get(requestInfo, url, requestConfig) {
|
|
28
|
-
return this.makeRequest(requestInfo, {
|
|
29
|
-
...requestConfig,
|
|
30
|
-
method: "get",
|
|
31
|
-
url
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async post(requestInfo, url, data, requestConfig) {
|
|
35
|
-
return this.makeRequest(requestInfo, {
|
|
36
|
-
...requestConfig,
|
|
37
|
-
method: "post",
|
|
38
|
-
url,
|
|
39
|
-
data
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async patch(requestInfo, url, data, requestConfig) {
|
|
43
|
-
return this.makeRequest(requestInfo, {
|
|
44
|
-
...requestConfig,
|
|
45
|
-
method: "patch",
|
|
46
|
-
url,
|
|
47
|
-
data
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
async put(requestInfo, url, data, requestConfig) {
|
|
51
|
-
return this.makeRequest(requestInfo, {
|
|
52
|
-
...requestConfig,
|
|
53
|
-
method: "put",
|
|
54
|
-
url,
|
|
55
|
-
data
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
async delete(requestInfo, url, data, requestConfig) {
|
|
59
|
-
return this.makeRequest(requestInfo, {
|
|
60
|
-
...requestConfig,
|
|
61
|
-
method: "delete",
|
|
62
|
-
url,
|
|
63
|
-
data
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
async makeRequest(requestInfo, requestConfig) {
|
|
67
|
-
const errorStack = (/* @__PURE__ */ new Error()).stack;
|
|
68
|
-
try {
|
|
69
|
-
const { rawResponse, ...config } = requestConfig;
|
|
70
|
-
const res = await this.client(config);
|
|
71
|
-
const resData = requestInfo.resSchema.parse(res.data);
|
|
72
|
-
return rawResponse ? {
|
|
73
|
-
...res,
|
|
74
|
-
data: resData
|
|
75
|
-
} : resData;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
if (error instanceof z.ZodError) {
|
|
78
|
-
error.name = "BE Response schema mismatch - ZodError";
|
|
79
|
-
error.stack = [error.stack, ...errorStack?.split("\n").slice(2) ?? []].join("\n");
|
|
80
|
-
}
|
|
81
|
-
(requestInfo.errorHandler ?? this.errorHandler).rethrowError(error);
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
import { RestClient } from "./lib/rest/rest-client.mjs";
|
|
2
|
+
import { RestInterceptor } from "./lib/rest/rest-interceptor.mjs";
|
|
3
|
+
import { RestUtils } from "./lib/rest/rest.utils.mjs";
|
|
4
|
+
import { ApplicationException, ErrorHandler, SharedErrorHandler } from "./lib/rest/error-handling.mjs";
|
|
5
|
+
import { OpenApiRouter } from "./lib/config/router.context.mjs";
|
|
6
|
+
import { OpenApiQueryConfig } from "./lib/config/queryConfig.context.mjs";
|
|
7
|
+
import { ns, resources } from "./lib/config/i18n.mjs";
|
|
8
|
+
import { AuthContext } from "./lib/auth/auth.context.mjs";
|
|
9
|
+
import { AuthGuard } from "./lib/auth/AuthGuard.mjs";
|
|
10
|
+
export {
|
|
11
|
+
ApplicationException,
|
|
12
|
+
AuthContext,
|
|
13
|
+
AuthGuard,
|
|
14
|
+
ErrorHandler,
|
|
15
|
+
OpenApiQueryConfig,
|
|
16
|
+
OpenApiRouter,
|
|
17
|
+
RestClient,
|
|
18
|
+
RestInterceptor,
|
|
19
|
+
RestUtils,
|
|
20
|
+
SharedErrorHandler,
|
|
21
|
+
ns,
|
|
22
|
+
resources
|
|
85
23
|
};
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/lib/rest/rest-interceptor.ts
|
|
89
|
-
var RestInterceptor = class {
|
|
90
|
-
interceptorIdMap = [];
|
|
91
|
-
constructor(applyInterceptor) {
|
|
92
|
-
this.applyInterceptor = applyInterceptor;
|
|
93
|
-
}
|
|
94
|
-
addInterceptor(client, ...args) {
|
|
95
|
-
this.removeInterceptor(client);
|
|
96
|
-
const interceptorId = this.applyInterceptor(client, ...args);
|
|
97
|
-
this.interceptorIdMap.push({
|
|
98
|
-
client,
|
|
99
|
-
interceptorId
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
removeInterceptor(client) {
|
|
103
|
-
const interceptorId = this.interceptorIdMap.find((i) => i.client === client)?.interceptorId;
|
|
104
|
-
if (interceptorId != null) {
|
|
105
|
-
client.interceptors.request.eject(interceptorId);
|
|
106
|
-
this.interceptorIdMap = this.interceptorIdMap.filter((i) => i.client !== client);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/lib/config/queryConfig.context.tsx
|
|
113
|
-
let OpenApiQueryConfig;
|
|
114
|
-
(function(_OpenApiQueryConfig) {
|
|
115
|
-
const Context = createContext({});
|
|
116
|
-
function Provider({ preferUpdate, invalidateCurrentModule, invalidationMap, crossTabInvalidation, onError, children }) {
|
|
117
|
-
const value = useMemo(() => ({
|
|
118
|
-
preferUpdate,
|
|
119
|
-
invalidateCurrentModule,
|
|
120
|
-
invalidationMap,
|
|
121
|
-
crossTabInvalidation,
|
|
122
|
-
onError
|
|
123
|
-
}), [
|
|
124
|
-
preferUpdate,
|
|
125
|
-
invalidateCurrentModule,
|
|
126
|
-
invalidationMap,
|
|
127
|
-
crossTabInvalidation,
|
|
128
|
-
onError
|
|
129
|
-
]);
|
|
130
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
131
|
-
value,
|
|
132
|
-
children
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
_OpenApiQueryConfig.Provider = Provider;
|
|
136
|
-
_OpenApiQueryConfig.useConfig = () => {
|
|
137
|
-
return use(Context) ?? {};
|
|
138
|
-
};
|
|
139
|
-
})(OpenApiQueryConfig || (OpenApiQueryConfig = {}));
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/lib/react-query/cross-tab-invalidation.ts
|
|
143
|
-
const CROSS_TAB_INVALIDATE_KEY = "__rq_invalidate__";
|
|
144
|
-
const broadcastQueryInvalidation = (queryKeys) => {
|
|
145
|
-
localStorage.setItem(CROSS_TAB_INVALIDATE_KEY, JSON.stringify({
|
|
146
|
-
keys: queryKeys,
|
|
147
|
-
timestamp: Date.now()
|
|
148
|
-
}));
|
|
149
|
-
};
|
|
150
|
-
let isListenerSetUp = false;
|
|
151
|
-
const setupCrossTabListener = (queryClient) => {
|
|
152
|
-
if (isListenerSetUp) return;
|
|
153
|
-
isListenerSetUp = true;
|
|
154
|
-
window.addEventListener("storage", (e) => {
|
|
155
|
-
if (e.key !== CROSS_TAB_INVALIDATE_KEY || !e.newValue) return;
|
|
156
|
-
try {
|
|
157
|
-
const { keys } = JSON.parse(e.newValue);
|
|
158
|
-
for (const queryKey of keys) queryClient.invalidateQueries({ queryKey });
|
|
159
|
-
} catch {}
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/lib/react-query/useMutationEffects.ts
|
|
165
|
-
function useMutationEffects({ currentModule }) {
|
|
166
|
-
const queryClient = useQueryClient();
|
|
167
|
-
const config = OpenApiQueryConfig.useConfig();
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
if (!config.crossTabInvalidation) return;
|
|
170
|
-
setupCrossTabListener(queryClient);
|
|
171
|
-
}, [queryClient, config.crossTabInvalidation]);
|
|
172
|
-
return { runMutationEffects: useCallback(async (data, variables, options = {}, updateKeys) => {
|
|
173
|
-
const { invalidateCurrentModule, invalidationMap, invalidateModules, invalidateKeys, preferUpdate } = options;
|
|
174
|
-
const shouldUpdate = preferUpdate ?? config.preferUpdate ?? false;
|
|
175
|
-
const shouldInvalidateCurrentModule = invalidateCurrentModule ?? config.invalidateCurrentModule ?? true;
|
|
176
|
-
const isQueryKeyEqual = (keyA, keyB) => keyA.length === keyB.length && keyA.every((item, index) => item === keyB[index]);
|
|
177
|
-
const isQueryKeyPrefix = (queryKey, prefixKey) => prefixKey.length <= queryKey.length && prefixKey.every((item, index) => item === queryKey[index]);
|
|
178
|
-
const mappedInvalidationKeys = invalidationMap?.[currentModule]?.(data, variables) ?? config.invalidationMap?.[currentModule]?.(data, variables);
|
|
179
|
-
const shouldInvalidateQuery = (queryKey) => {
|
|
180
|
-
const isUpdateKey = updateKeys?.some((key) => isQueryKeyEqual(queryKey, key));
|
|
181
|
-
if (shouldUpdate && isUpdateKey) return false;
|
|
182
|
-
const isCurrentModule = shouldInvalidateCurrentModule && queryKey[0] === currentModule;
|
|
183
|
-
const isInvalidateModule = !!invalidateModules && invalidateModules.some((module) => queryKey[0] === module);
|
|
184
|
-
const isInvalidateKey = !!invalidateKeys && invalidateKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
185
|
-
const isMappedKey = !!mappedInvalidationKeys && mappedInvalidationKeys.some((key) => isQueryKeyPrefix(queryKey, key));
|
|
186
|
-
return isCurrentModule || isInvalidateModule || isInvalidateKey || isMappedKey;
|
|
187
|
-
};
|
|
188
|
-
const invalidatedQueryKeys = [];
|
|
189
|
-
const shouldBroadcast = options.crossTabInvalidation ?? config.crossTabInvalidation;
|
|
190
|
-
queryClient.invalidateQueries({ predicate: ({ queryKey }) => {
|
|
191
|
-
const shouldInvalidate = shouldInvalidateQuery(queryKey);
|
|
192
|
-
if (shouldInvalidate && shouldBroadcast) invalidatedQueryKeys.push([...queryKey]);
|
|
193
|
-
return shouldInvalidate;
|
|
194
|
-
} });
|
|
195
|
-
if (shouldBroadcast && invalidatedQueryKeys.length > 0) broadcastQueryInvalidation(invalidatedQueryKeys);
|
|
196
|
-
if (shouldUpdate && updateKeys) updateKeys.map((queryKey) => queryClient.setQueryData(queryKey, data));
|
|
197
|
-
}, [
|
|
198
|
-
queryClient,
|
|
199
|
-
currentModule,
|
|
200
|
-
config.preferUpdate,
|
|
201
|
-
config.invalidateCurrentModule,
|
|
202
|
-
config.invalidationMap,
|
|
203
|
-
config.crossTabInvalidation
|
|
204
|
-
]) };
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/lib/config/workspace.context.tsx
|
|
209
|
-
let OpenApiWorkspaceContext;
|
|
210
|
-
(function(_OpenApiWorkspaceContext) {
|
|
211
|
-
const Context = createContext({});
|
|
212
|
-
_OpenApiWorkspaceContext.Provider = ({ values, children }) => {
|
|
213
|
-
const contextValues = useMemo(() => values ?? {}, [values]);
|
|
214
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
215
|
-
value: contextValues,
|
|
216
|
-
children
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
_OpenApiWorkspaceContext.useContext = () => {
|
|
220
|
-
return use(Context);
|
|
221
|
-
};
|
|
222
|
-
_OpenApiWorkspaceContext.resolveParam = (context, name, value) => {
|
|
223
|
-
if (value != null) return value;
|
|
224
|
-
const workspaceValue = context[name];
|
|
225
|
-
if (workspaceValue == null) throw new Error(`Missing workspace context param "${name}"`);
|
|
226
|
-
return workspaceValue;
|
|
227
|
-
};
|
|
228
|
-
})(OpenApiWorkspaceContext || (OpenApiWorkspaceContext = {}));
|
|
229
|
-
const useWorkspaceContext = () => OpenApiWorkspaceContext.useContext();
|
|
230
|
-
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/lib/auth/AuthGuard.tsx
|
|
233
|
-
const AuthGuard = ({ type, redirectTo, children }) => {
|
|
234
|
-
const { isAuthenticated, routes, loadingState } = AuthContext.useAuth();
|
|
235
|
-
const { replace } = OpenApiRouter.useRouter();
|
|
236
|
-
const [hasMounted, setHasMounted] = useState(false);
|
|
237
|
-
useEffect(() => {
|
|
238
|
-
setHasMounted(true);
|
|
239
|
-
}, []);
|
|
240
|
-
if (!hasMounted) return loadingState;
|
|
241
|
-
if (type === "private" && !isAuthenticated) {
|
|
242
|
-
replace(redirectTo || routes?.unauthenticated || "/");
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
if (type === "public-only" && isAuthenticated) {
|
|
246
|
-
replace(redirectTo || routes?.authenticated || "/");
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
return children;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
//#endregion
|
|
253
|
-
export { ApplicationException, AuthContext, AuthGuard, ErrorHandler, OpenApiQueryConfig, OpenApiRouter, OpenApiWorkspaceContext, RestClient, RestInterceptor, RestUtils, SharedErrorHandler, ns, resources, useMutationEffects, useWorkspaceContext };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { AppAbilities } from './appAbility.types';
|
|
3
|
+
interface AclGuardProps<TAppAbilities extends AppAbilities = AppAbilities> {
|
|
4
|
+
canUse: TAppAbilities;
|
|
5
|
+
redirectTo?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createAclGuard: <TAppAbilities extends AppAbilities = AppAbilities>() => ({ canUse, redirectTo, children }: PropsWithChildren<AclGuardProps<TAppAbilities>>) => import('react').ReactNode;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OpenApiRouter } from "../config/router.context.mjs";
|
|
2
|
+
import { AbilityContext } from "./ability.context.mjs";
|
|
3
|
+
const createAclGuard = () => ({ canUse, redirectTo = "/", children }) => {
|
|
4
|
+
const ability = AbilityContext.useAbility();
|
|
5
|
+
const { replace } = OpenApiRouter.useRouter();
|
|
6
|
+
if (!ability.can(canUse[0], canUse[1])) {
|
|
7
|
+
replace(redirectTo);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return children;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
createAclGuard
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AbilityTuple, PureAbility } from '@casl/ability';
|
|
2
|
+
import { BoundCanProps } from '@casl/react';
|
|
3
|
+
import { AppAbilities } from './appAbility.types';
|
|
4
|
+
type CanAbility = PureAbility<AbilityTuple<AppAbilities[0], AppAbilities[1]>>;
|
|
5
|
+
type CanProps<TAppAbilities extends AppAbilities = AppAbilities> = {
|
|
6
|
+
use: TAppAbilities;
|
|
7
|
+
} & Omit<BoundCanProps<CanAbility>, "do" | "I" | "on" | "a" | "an" | "this">;
|
|
8
|
+
export declare const Can: <TAppAbilities extends AppAbilities = AppAbilities>({ use, ...props }: CanProps<TAppAbilities>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContextualCan } from "@casl/react";
|
|
3
|
+
import { AbilityContext } from "./ability.context.mjs";
|
|
4
|
+
const ContextualCan = createContextualCan(AbilityContext.Consumer);
|
|
5
|
+
const Can = ({ use, ...props }) => {
|
|
6
|
+
const [action, subject] = use;
|
|
7
|
+
return /* @__PURE__ */ jsx(ContextualCan, { ...props, do: action, on: subject });
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
Can
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { PureAbility, RawRuleOf } from '@casl/ability';
|
|
3
|
+
import { PackRule } from '@casl/ability/extra';
|
|
4
|
+
import { AppAbilities, AppAbility } from './appAbility.types';
|
|
5
|
+
export declare namespace AbilityContext {
|
|
6
|
+
export const Consumer: import("react").Consumer<AppAbility>;
|
|
7
|
+
interface ProviderProps {
|
|
8
|
+
user?: {
|
|
9
|
+
aclRules?: PackRule<RawRuleOf<AppAbility>>[];
|
|
10
|
+
} | null;
|
|
11
|
+
}
|
|
12
|
+
export const Provider: ({ children }: PropsWithChildren<ProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export const useAbility: <TAppAbilities extends AppAbilities = AppAbilities>() => PureAbility<TAppAbilities>;
|
|
14
|
+
export {};
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useState, useEffect } from "react";
|
|
3
|
+
import { AbilityBuilder, createMongoAbility } from "@casl/ability";
|
|
4
|
+
import { unpackRules } from "@casl/ability/extra";
|
|
5
|
+
import { useAbility } from "@casl/react";
|
|
6
|
+
import { AuthContext } from "../auth/auth.context.mjs";
|
|
7
|
+
var AbilityContext;
|
|
8
|
+
((AbilityContext2) => {
|
|
9
|
+
const createAppAbilityBuilder = () => new AbilityBuilder(createMongoAbility);
|
|
10
|
+
const initialAppAbility = createAppAbilityBuilder().build();
|
|
11
|
+
const Context = createContext({});
|
|
12
|
+
({ Consumer: AbilityContext2.Consumer } = Context);
|
|
13
|
+
AbilityContext2.Provider = ({ children }) => {
|
|
14
|
+
const [ability, setAbility] = useState(initialAppAbility);
|
|
15
|
+
const { user } = AuthContext.useAuth();
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!user || !("aclRules" in user)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { can, build } = createAppAbilityBuilder();
|
|
21
|
+
const packedRules = user.aclRules;
|
|
22
|
+
const rules = unpackRules(packedRules);
|
|
23
|
+
rules.forEach(({ action, subject, conditions }) => {
|
|
24
|
+
can(action, subject, conditions);
|
|
25
|
+
});
|
|
26
|
+
setAbility(build());
|
|
27
|
+
}, [user]);
|
|
28
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: ability, children });
|
|
29
|
+
};
|
|
30
|
+
AbilityContext2.useAbility = () => {
|
|
31
|
+
const ability = useAbility(Context);
|
|
32
|
+
return ability;
|
|
33
|
+
};
|
|
34
|
+
})(AbilityContext || (AbilityContext = {}));
|
|
35
|
+
export {
|
|
36
|
+
AbilityContext
|
|
37
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const openapi = { "sharedErrors": { "dataValidation": "An error occurred while validating the data", "internalError": "An internal error occurred. This is most likely a bug on our end. Please try again later.", "networkError": "A network error occurred. Are you connected to the internet?", "canceledError": "The request was canceled.", "unknownError": "An unknown error occurred. Please try again later.", "unknownErrorWithCode": 'An unknown error occurred. Error code: "{{code}}"' } };
|
|
2
|
+
const translationEN = {
|
|
3
|
+
openapi
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
translationEN as default,
|
|
7
|
+
openapi
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const openapi = { "sharedErrors": { "dataValidation": "Pri preverjanju podatkov je prišlo do napake", "internalError": "Prišlo je do notranje napake.", "networkError": "Prišlo je do napake v omrežju.", "canceledError": "Zahteva je bila preklicana.", "unknownError": "Prišlo je do neznane napake.", "unknownErrorWithCode": 'Prišlo je do neznane napake. Koda napake: "{{code}}"' } };
|
|
2
|
+
const translationSL = {
|
|
3
|
+
openapi
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
translationSL as default,
|
|
7
|
+
openapi
|
|
8
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export interface AuthGuardProps {
|
|
3
|
+
type: "public-only" | "private";
|
|
4
|
+
redirectTo?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const AuthGuard: ({ type, redirectTo, children }: PropsWithChildren<AuthGuardProps>) => import('react').ReactNode;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { OpenApiRouter } from "../config/router.context.mjs";
|
|
3
|
+
import { AuthContext } from "./auth.context.mjs";
|
|
4
|
+
const AuthGuard = ({ type, redirectTo, children }) => {
|
|
5
|
+
const { isAuthenticated, routes, loadingState } = AuthContext.useAuth();
|
|
6
|
+
const { replace } = OpenApiRouter.useRouter();
|
|
7
|
+
const [hasMounted, setHasMounted] = useState(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setHasMounted(true);
|
|
10
|
+
}, []);
|
|
11
|
+
if (!hasMounted) {
|
|
12
|
+
return loadingState;
|
|
13
|
+
}
|
|
14
|
+
if (type === "private" && !isAuthenticated) {
|
|
15
|
+
replace(redirectTo || routes?.unauthenticated || "/");
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (type === "public-only" && isAuthenticated) {
|
|
19
|
+
replace(redirectTo || routes?.authenticated || "/");
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return children;
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
AuthGuard
|
|
26
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
export declare namespace AuthContext {
|
|
3
|
+
export interface Routes {
|
|
4
|
+
authenticated?: string;
|
|
5
|
+
unauthenticated?: string;
|
|
6
|
+
}
|
|
7
|
+
interface Type<TUser = unknown> {
|
|
8
|
+
isAuthenticated: boolean;
|
|
9
|
+
isInitializing: boolean;
|
|
10
|
+
logout: () => void;
|
|
11
|
+
updateTokens?: (accessToken: string | null, refreshToken?: string | null) => void;
|
|
12
|
+
accessToken?: string | null;
|
|
13
|
+
user?: TUser | null;
|
|
14
|
+
userPromise?: () => Promise<TUser | null>;
|
|
15
|
+
routes?: Routes;
|
|
16
|
+
loadingState?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
type ProviderProps<TUser = unknown> = Type<TUser>;
|
|
19
|
+
export const Provider: <TUser>({ isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState, children, }: PropsWithChildren<ProviderProps<TUser>>) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export const useAuth: <TUser>() => Type<TUser>;
|
|
21
|
+
export {};
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useMemo, use } from "react";
|
|
3
|
+
var AuthContext;
|
|
4
|
+
((AuthContext2) => {
|
|
5
|
+
const Context = createContext({});
|
|
6
|
+
AuthContext2.Provider = ({
|
|
7
|
+
isAuthenticated,
|
|
8
|
+
isInitializing,
|
|
9
|
+
logout,
|
|
10
|
+
updateTokens,
|
|
11
|
+
accessToken,
|
|
12
|
+
user,
|
|
13
|
+
userPromise,
|
|
14
|
+
routes,
|
|
15
|
+
loadingState,
|
|
16
|
+
children
|
|
17
|
+
}) => {
|
|
18
|
+
const value = useMemo(
|
|
19
|
+
() => ({
|
|
20
|
+
isAuthenticated,
|
|
21
|
+
isInitializing,
|
|
22
|
+
logout,
|
|
23
|
+
updateTokens,
|
|
24
|
+
accessToken,
|
|
25
|
+
user,
|
|
26
|
+
userPromise,
|
|
27
|
+
routes,
|
|
28
|
+
loadingState
|
|
29
|
+
}),
|
|
30
|
+
[isAuthenticated, isInitializing, logout, updateTokens, accessToken, user, userPromise, routes, loadingState]
|
|
31
|
+
);
|
|
32
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
33
|
+
};
|
|
34
|
+
AuthContext2.useAuth = () => {
|
|
35
|
+
const auth = use(Context);
|
|
36
|
+
return auth;
|
|
37
|
+
};
|
|
38
|
+
})(AuthContext || (AuthContext = {}));
|
|
39
|
+
export {
|
|
40
|
+
AuthContext
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const ns = "openapi";
|
|
2
|
+
export declare const resources: {
|
|
3
|
+
readonly en: {
|
|
4
|
+
readonly openapi: {
|
|
5
|
+
openapi: {
|
|
6
|
+
sharedErrors: {
|
|
7
|
+
dataValidation: string;
|
|
8
|
+
internalError: string;
|
|
9
|
+
networkError: string;
|
|
10
|
+
canceledError: string;
|
|
11
|
+
unknownError: string;
|
|
12
|
+
unknownErrorWithCode: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly sl: {
|
|
18
|
+
readonly openapi: {
|
|
19
|
+
openapi: {
|
|
20
|
+
sharedErrors: {
|
|
21
|
+
dataValidation: string;
|
|
22
|
+
internalError: string;
|
|
23
|
+
networkError: string;
|
|
24
|
+
canceledError: string;
|
|
25
|
+
unknownError: string;
|
|
26
|
+
unknownErrorWithCode: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const defaultT: import('i18next').TFunction<["translation", ...string[]], undefined>;
|