mobx-tanstack-query-api 0.24.0 → 0.26.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.
- package/builtin.cjs +27 -0
- package/builtin.cjs.map +1 -0
- package/builtin.d.ts +6 -0
- package/builtin.js +27 -0
- package/builtin.js.map +1 -0
- package/cli.cjs +1279 -0
- package/cli.cjs.map +1 -0
- package/{codegen/types/generate-query-api-params.d.cts → cli.d.ts} +55 -10
- package/cli.js +1278 -0
- package/cli.js.map +1 -0
- package/index.cjs +771 -16
- package/index.cjs.map +1 -0
- package/index.d.ts +322 -2
- package/index.js +768 -2
- package/index.js.map +1 -0
- package/package.json +21 -64
- package/builtin/index.cjs +0 -25
- package/builtin/index.d.cts +0 -4
- package/builtin/index.d.cts.map +0 -1
- package/builtin/index.d.ts +0 -4
- package/builtin/index.d.ts.map +0 -1
- package/builtin/index.js +0 -22
- package/cli/bin.cjs +0 -17
- package/cli/bin.d.cts +0 -2
- package/cli/bin.d.cts.map +0 -1
- package/cli/bin.d.ts +0 -2
- package/cli/bin.d.ts.map +0 -1
- package/cli/bin.js +0 -15
- package/cli/index.cjs +0 -18
- package/cli/index.d.cts +0 -3
- package/cli/index.d.cts.map +0 -1
- package/cli/index.d.ts +0 -3
- package/cli/index.d.ts.map +0 -1
- package/cli/index.js +0 -2
- package/cli/utils/define-config.cjs +0 -9
- package/cli/utils/define-config.d.cts +0 -4
- package/cli/utils/define-config.d.cts.map +0 -1
- package/cli/utils/define-config.d.ts +0 -4
- package/cli/utils/define-config.d.ts.map +0 -1
- package/cli/utils/define-config.js +0 -5
- package/cli/utils/exec-config-path.cjs +0 -16
- package/cli/utils/exec-config-path.d.cts +0 -2
- package/cli/utils/exec-config-path.d.cts.map +0 -1
- package/cli/utils/exec-config-path.d.ts +0 -2
- package/cli/utils/exec-config-path.d.ts.map +0 -1
- package/cli/utils/exec-config-path.js +0 -12
- package/cli/utils/resolve-config-path.cjs +0 -65
- package/cli/utils/resolve-config-path.d.cts +0 -3
- package/cli/utils/resolve-config-path.d.cts.map +0 -1
- package/cli/utils/resolve-config-path.d.ts +0 -3
- package/cli/utils/resolve-config-path.d.ts.map +0 -1
- package/cli/utils/resolve-config-path.js +0 -25
- package/codegen/index.cjs +0 -545
- package/codegen/index.d.cts +0 -4
- package/codegen/index.d.cts.map +0 -1
- package/codegen/index.d.ts +0 -4
- package/codegen/index.d.ts.map +0 -1
- package/codegen/index.js +0 -524
- package/codegen/templates/all-endpoints-per-file.tmpl.cjs +0 -94
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-endpoints-per-file.tmpl.js +0 -90
- package/codegen/templates/all-exports.tmpl.cjs +0 -14
- package/codegen/templates/all-exports.tmpl.d.cts +0 -9
- package/codegen/templates/all-exports.tmpl.d.cts.map +0 -1
- package/codegen/templates/all-exports.tmpl.d.ts +0 -9
- package/codegen/templates/all-exports.tmpl.d.ts.map +0 -1
- package/codegen/templates/all-exports.tmpl.js +0 -9
- package/codegen/templates/constants.cjs +0 -5
- package/codegen/templates/constants.d.cts +0 -2
- package/codegen/templates/constants.d.cts.map +0 -1
- package/codegen/templates/constants.d.ts +0 -2
- package/codegen/templates/constants.d.ts.map +0 -1
- package/codegen/templates/constants.js +0 -2
- package/codegen/templates/data-contract.tmpl.cjs +0 -49
- package/codegen/templates/data-contract.tmpl.d.cts +0 -8
- package/codegen/templates/data-contract.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contract.tmpl.d.ts +0 -8
- package/codegen/templates/data-contract.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contract.tmpl.js +0 -45
- package/codegen/templates/data-contracts-file.tmpl.cjs +0 -27
- package/codegen/templates/data-contracts-file.tmpl.d.cts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.d.ts +0 -6
- package/codegen/templates/data-contracts-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/data-contracts-file.tmpl.js +0 -23
- package/codegen/templates/endpoint-jsdoc.tmpl.cjs +0 -111
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts +0 -8
- package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-jsdoc.tmpl.js +0 -107
- package/codegen/templates/endpoint-per-file.tmpl.cjs +0 -87
- package/codegen/templates/endpoint-per-file.tmpl.d.cts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.d.ts +0 -14
- package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/endpoint-per-file.tmpl.js +0 -83
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.cjs +0 -10
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.cts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +0 -6
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +0 -1
- package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.js +0 -6
- package/codegen/templates/meta-info.tmpl.cjs +0 -48
- package/codegen/templates/meta-info.tmpl.d.cts +0 -9
- package/codegen/templates/meta-info.tmpl.d.cts.map +0 -1
- package/codegen/templates/meta-info.tmpl.d.ts +0 -9
- package/codegen/templates/meta-info.tmpl.d.ts.map +0 -1
- package/codegen/templates/meta-info.tmpl.js +0 -42
- package/codegen/templates/new-endpoint.tmpl.cjs +0 -188
- package/codegen/templates/new-endpoint.tmpl.d.cts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.cts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.d.ts +0 -15
- package/codegen/templates/new-endpoint.tmpl.d.ts.map +0 -1
- package/codegen/templates/new-endpoint.tmpl.js +0 -184
- package/codegen/types/all-import-file-params.cjs +0 -2
- package/codegen/types/all-import-file-params.d.cts +0 -5
- package/codegen/types/all-import-file-params.d.cts.map +0 -1
- package/codegen/types/all-import-file-params.d.ts +0 -5
- package/codegen/types/all-import-file-params.d.ts.map +0 -1
- package/codegen/types/all-import-file-params.js +0 -1
- package/codegen/types/base-tmpl-params.cjs +0 -2
- package/codegen/types/base-tmpl-params.d.cts +0 -16
- package/codegen/types/base-tmpl-params.d.cts.map +0 -1
- package/codegen/types/base-tmpl-params.d.ts +0 -16
- package/codegen/types/base-tmpl-params.d.ts.map +0 -1
- package/codegen/types/base-tmpl-params.js +0 -1
- package/codegen/types/codegen-data-utils.cjs +0 -2
- package/codegen/types/codegen-data-utils.d.cts +0 -8
- package/codegen/types/codegen-data-utils.d.cts.map +0 -1
- package/codegen/types/codegen-data-utils.d.ts +0 -8
- package/codegen/types/codegen-data-utils.d.ts.map +0 -1
- package/codegen/types/codegen-data-utils.js +0 -1
- package/codegen/types/endpoint-data.cjs +0 -2
- package/codegen/types/endpoint-data.d.cts +0 -3
- package/codegen/types/endpoint-data.d.cts.map +0 -1
- package/codegen/types/endpoint-data.d.ts +0 -3
- package/codegen/types/endpoint-data.d.ts.map +0 -1
- package/codegen/types/endpoint-data.js +0 -1
- package/codegen/types/generate-query-api-params.cjs +0 -2
- package/codegen/types/generate-query-api-params.d.cts.map +0 -1
- package/codegen/types/generate-query-api-params.d.ts +0 -162
- package/codegen/types/generate-query-api-params.d.ts.map +0 -1
- package/codegen/types/generate-query-api-params.js +0 -1
- package/codegen/types/import-file-params.cjs +0 -2
- package/codegen/types/import-file-params.d.cts +0 -5
- package/codegen/types/import-file-params.d.cts.map +0 -1
- package/codegen/types/import-file-params.d.ts +0 -5
- package/codegen/types/import-file-params.d.ts.map +0 -1
- package/codegen/types/import-file-params.js +0 -1
- package/codegen/types/index.cjs +0 -23
- package/codegen/types/index.d.cts +0 -8
- package/codegen/types/index.d.cts.map +0 -1
- package/codegen/types/index.d.ts +0 -8
- package/codegen/types/index.d.ts.map +0 -1
- package/codegen/types/index.js +0 -7
- package/codegen/types/meta-info.cjs +0 -2
- package/codegen/types/meta-info.d.cts +0 -6
- package/codegen/types/meta-info.d.cts.map +0 -1
- package/codegen/types/meta-info.d.ts +0 -6
- package/codegen/types/meta-info.d.ts.map +0 -1
- package/codegen/types/meta-info.js +0 -1
- package/codegen/types/type-info.cjs +0 -2
- package/codegen/types/type-info.d.cts +0 -4
- package/codegen/types/type-info.d.cts.map +0 -1
- package/codegen/types/type-info.d.ts +0 -4
- package/codegen/types/type-info.d.ts.map +0 -1
- package/codegen/types/type-info.js +0 -1
- package/codegen/utils/create-short-model-type.cjs +0 -12
- package/codegen/utils/create-short-model-type.d.cts +0 -5
- package/codegen/utils/create-short-model-type.d.cts.map +0 -1
- package/codegen/utils/create-short-model-type.d.ts +0 -5
- package/codegen/utils/create-short-model-type.d.ts.map +0 -1
- package/codegen/utils/create-short-model-type.js +0 -8
- package/codegen/utils/remove-unused-types.cjs +0 -117
- package/codegen/utils/remove-unused-types.d.cts +0 -7
- package/codegen/utils/remove-unused-types.d.cts.map +0 -1
- package/codegen/utils/remove-unused-types.d.ts +0 -7
- package/codegen/utils/remove-unused-types.d.ts.map +0 -1
- package/codegen/utils/remove-unused-types.js +0 -110
- package/codegen/utils/unpack-filter-option.cjs +0 -23
- package/codegen/utils/unpack-filter-option.d.cts +0 -7
- package/codegen/utils/unpack-filter-option.d.cts.map +0 -1
- package/codegen/utils/unpack-filter-option.d.ts +0 -7
- package/codegen/utils/unpack-filter-option.d.ts.map +0 -1
- package/codegen/utils/unpack-filter-option.js +0 -19
- package/index.d.cts +0 -3
- package/index.d.cts.map +0 -1
- package/index.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.cjs +0 -101
- package/runtime/endpoint-infinite-query.d.cts +0 -17
- package/runtime/endpoint-infinite-query.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.d.ts +0 -17
- package/runtime/endpoint-infinite-query.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.js +0 -97
- package/runtime/endpoint-infinite-query.types.cjs +0 -2
- package/runtime/endpoint-infinite-query.types.d.cts +0 -30
- package/runtime/endpoint-infinite-query.types.d.cts.map +0 -1
- package/runtime/endpoint-infinite-query.types.d.ts +0 -30
- package/runtime/endpoint-infinite-query.types.d.ts.map +0 -1
- package/runtime/endpoint-infinite-query.types.js +0 -1
- package/runtime/endpoint-mutation.cjs +0 -74
- package/runtime/endpoint-mutation.d.cts +0 -13
- package/runtime/endpoint-mutation.d.cts.map +0 -1
- package/runtime/endpoint-mutation.d.ts +0 -13
- package/runtime/endpoint-mutation.d.ts.map +0 -1
- package/runtime/endpoint-mutation.js +0 -70
- package/runtime/endpoint-mutation.types.cjs +0 -2
- package/runtime/endpoint-mutation.types.d.cts +0 -36
- package/runtime/endpoint-mutation.types.d.cts.map +0 -1
- package/runtime/endpoint-mutation.types.d.ts +0 -36
- package/runtime/endpoint-mutation.types.d.ts.map +0 -1
- package/runtime/endpoint-mutation.types.js +0 -1
- package/runtime/endpoint-query-client.cjs +0 -79
- package/runtime/endpoint-query-client.d.cts +0 -13
- package/runtime/endpoint-query-client.d.cts.map +0 -1
- package/runtime/endpoint-query-client.d.ts +0 -13
- package/runtime/endpoint-query-client.d.ts.map +0 -1
- package/runtime/endpoint-query-client.js +0 -75
- package/runtime/endpoint-query-client.types.cjs +0 -2
- package/runtime/endpoint-query-client.types.d.cts +0 -16
- package/runtime/endpoint-query-client.types.d.cts.map +0 -1
- package/runtime/endpoint-query-client.types.d.ts +0 -16
- package/runtime/endpoint-query-client.types.d.ts.map +0 -1
- package/runtime/endpoint-query-client.types.js +0 -1
- package/runtime/endpoint-query.cjs +0 -214
- package/runtime/endpoint-query.d.cts +0 -29
- package/runtime/endpoint-query.d.cts.map +0 -1
- package/runtime/endpoint-query.d.ts +0 -29
- package/runtime/endpoint-query.d.ts.map +0 -1
- package/runtime/endpoint-query.js +0 -208
- package/runtime/endpoint-query.types.cjs +0 -2
- package/runtime/endpoint-query.types.d.cts +0 -42
- package/runtime/endpoint-query.types.d.cts.map +0 -1
- package/runtime/endpoint-query.types.d.ts +0 -42
- package/runtime/endpoint-query.types.d.ts.map +0 -1
- package/runtime/endpoint-query.types.js +0 -1
- package/runtime/endpoint.cjs +0 -131
- package/runtime/endpoint.d.cts +0 -73
- package/runtime/endpoint.d.cts.map +0 -1
- package/runtime/endpoint.d.ts +0 -73
- package/runtime/endpoint.d.ts.map +0 -1
- package/runtime/endpoint.js +0 -127
- package/runtime/endpoint.types.cjs +0 -2
- package/runtime/endpoint.types.d.cts +0 -24
- package/runtime/endpoint.types.d.cts.map +0 -1
- package/runtime/endpoint.types.d.ts +0 -24
- package/runtime/endpoint.types.d.ts.map +0 -1
- package/runtime/endpoint.types.js +0 -1
- package/runtime/http-client.cjs +0 -190
- package/runtime/http-client.d.cts +0 -85
- package/runtime/http-client.d.cts.map +0 -1
- package/runtime/http-client.d.ts +0 -85
- package/runtime/http-client.d.ts.map +0 -1
- package/runtime/http-client.js +0 -184
- package/runtime/index.cjs +0 -25
- package/runtime/index.d.cts +0 -10
- package/runtime/index.d.cts.map +0 -1
- package/runtime/index.d.ts +0 -10
- package/runtime/index.d.ts.map +0 -1
- package/runtime/index.js +0 -9
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/runtime/endpoint-query.ts","../src/runtime/endpoint-infinite-query.ts","../src/runtime/endpoint-mutation.ts","../src/runtime/endpoint.ts","../src/runtime/endpoint-query-client.ts","../src/runtime/http-client.ts"],"sourcesContent":["/** biome-ignore-all lint/correctness/noUnusedVariables: <explanation> */\nimport type {\n DefaultError,\n QueryFunctionContext,\n QueryObserverResult,\n RefetchOptions,\n} from '@tanstack/query-core';\nimport {\n comparer,\n computed,\n makeObservable,\n observable,\n reaction,\n runInAction,\n} from 'mobx';\nimport { Query, type QueryUpdateOptionsAllVariants } from 'mobx-tanstack-query';\nimport { callFunction } from 'yummies/common';\nimport { getMobxAdministration, lazyObserve } from 'yummies/mobx';\nimport type { AnyObject, Maybe, MaybeFalsy, MaybeFn } from 'yummies/types';\nimport type { AnyEndpoint } from './endpoint.types.js';\nimport type {\n EndpointQueryFlattenOptions,\n EndpointQueryOptions,\n EndpointQueryUniqKey,\n ExcludedQueryKeys,\n} from './endpoint-query.types.js';\nimport type { EndpointQueryClient } from './endpoint-query-client.js';\nimport type { RequestParams } from './http-client.js';\n\ninterface InternalObservableData<TEndpoint extends AnyEndpoint> {\n params: MaybeFalsy<TEndpoint['__params']>;\n uniqKey?: EndpointQueryUniqKey;\n initialized?: boolean;\n dynamicOptions?: any;\n response: TEndpoint['__response'] | null;\n}\n\n/**\n * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-queries/)\n */\nexport class EndpointQuery<\n TEndpoint extends AnyEndpoint,\n TQueryFnData = TEndpoint['__response']['data'],\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n> extends Query<TQueryFnData, TError, TData, TQueryData> {\n private _observableData: InternalObservableData<TEndpoint>;\n\n constructor(\n private endpoint: AnyEndpoint,\n inputQueryClient: EndpointQueryClient,\n queryOptionsInput:\n | EndpointQueryOptions<TEndpoint, TQueryFnData, TError, TData, TQueryData>\n | (() => EndpointQueryFlattenOptions<\n TEndpoint,\n TQueryFnData,\n TError,\n TData,\n TQueryData\n >),\n ) {\n const isQueryOptionsInputFn = typeof queryOptionsInput === 'function';\n const unpackedQueryOptionsInput = isQueryOptionsInputFn\n ? queryOptionsInput()\n : queryOptionsInput;\n\n const {\n uniqKey,\n transform: transformResponse,\n params,\n queryClient: overridedQueryClient,\n ...queryOptions\n } = unpackedQueryOptionsInput;\n\n const queryClient = overridedQueryClient ?? inputQueryClient;\n\n const _observableData: InternalObservableData<TEndpoint> = {\n params: null,\n dynamicOptions: undefined,\n response: null,\n uniqKey: unpackedQueryOptionsInput.uniqKey,\n };\n\n if (!isQueryOptionsInputFn && typeof params !== 'function') {\n if ('params' in unpackedQueryOptionsInput) {\n _observableData.params = params;\n } else {\n _observableData.params = {};\n }\n _observableData.initialized = true;\n }\n\n makeObservable(_observableData, {\n params: observable.ref,\n response: observable.ref,\n dynamicOptions: observable,\n });\n\n super({\n ...queryOptions,\n queryClient,\n meta: endpoint.toQueryMeta(queryOptions.meta),\n options: (): any => {\n const builtOptions = buildOptionsFromParams(\n endpoint,\n _observableData.params,\n _observableData.uniqKey,\n );\n\n let isEnabled = !!_observableData.initialized && builtOptions.enabled;\n\n if (\n typeof queryOptionsInput !== 'function' &&\n queryOptionsInput.enabled === false\n ) {\n isEnabled = false;\n }\n\n return {\n ...builtOptions,\n enabled: isEnabled,\n ..._observableData.dynamicOptions,\n };\n },\n queryFn: async (ctx): Promise<any> => {\n const params = endpoint.getParamsFromContext(ctx);\n\n runInAction(() => {\n _observableData.response = null;\n if (!comparer.structural(params, _observableData.params)) {\n _observableData.params = params;\n }\n });\n\n let requestParams = params.requestParams as Maybe<RequestParams>;\n\n if (requestParams) {\n if (!requestParams.signal) {\n requestParams.signal = ctx.signal;\n }\n } else {\n requestParams = { signal: ctx.signal };\n }\n\n const fixedInput = {\n ...params,\n requestParams,\n };\n\n const response = await endpoint.request(fixedInput);\n\n runInAction(() => {\n _observableData.response = response as TEndpoint['__response'];\n });\n\n return (await transformResponse?.(response)) ?? response.data;\n },\n });\n\n const parentAtom = getMobxAdministration(this);\n\n computed.struct(this, 'params');\n computed.struct(this, 'response');\n makeObservable(this);\n\n if (isQueryOptionsInputFn || typeof params === 'function') {\n const createParamsReaction = () =>\n reaction(\n (): Partial<InternalObservableData<TEndpoint>> => {\n let outDynamicOptions: InternalObservableData<TEndpoint>['dynamicOptions'];\n let outParams: MaybeFn<MaybeFalsy<TEndpoint['__params']>>;\n let uniqKey: Maybe<EndpointQueryUniqKey>;\n\n if (isQueryOptionsInputFn) {\n const result = queryOptionsInput();\n const {\n params,\n abortSignal,\n select,\n onDone,\n onError,\n onInit,\n enableOnDemand,\n uniqKey: _uniqKey,\n ...dynamicOptions\n } = result;\n\n uniqKey = _uniqKey;\n\n if ('params' in result) {\n outParams = result.params;\n } else {\n outParams = {};\n }\n\n outDynamicOptions =\n Object.keys(dynamicOptions).length > 0\n ? dynamicOptions\n : undefined;\n } else if ('params' in unpackedQueryOptionsInput) {\n outParams = unpackedQueryOptionsInput.params;\n uniqKey = unpackedQueryOptionsInput.uniqKey;\n } else {\n outParams = {};\n uniqKey = unpackedQueryOptionsInput.uniqKey;\n }\n\n return {\n params: callFunction(outParams),\n dynamicOptions: outDynamicOptions,\n uniqKey,\n };\n },\n ({ params, dynamicOptions, uniqKey }) => {\n runInAction(() => {\n _observableData.initialized = true;\n _observableData.params = params;\n _observableData.dynamicOptions = dynamicOptions;\n _observableData.uniqKey = uniqKey;\n });\n },\n {\n fireImmediately: true,\n },\n );\n\n if (this.features.lazy) {\n lazyObserve({\n property: parentAtom.values_.get('_result'),\n onStart: createParamsReaction,\n onEnd: (disposeFn) => disposeFn(),\n });\n } else {\n this.abortController.signal.addEventListener(\n 'abort',\n createParamsReaction(),\n );\n }\n }\n\n this._observableData = _observableData;\n }\n\n get params() {\n return this._observableData.params;\n }\n\n get response() {\n return this._observableData.response;\n }\n\n update(\n updateParams: Omit<\n QueryUpdateOptionsAllVariants<TQueryFnData, TError, TData, TQueryData>,\n ExcludedQueryKeys\n > & {\n params?: MaybeFalsy<TEndpoint['__params']>;\n },\n ) {\n if ('params' in updateParams) {\n const { params, ...options } = updateParams;\n runInAction(() => {\n this._observableData.params = params;\n });\n return super.update({\n ...buildOptionsFromParams(\n this.endpoint,\n params,\n this._observableData.uniqKey,\n ),\n ...options,\n });\n } else if (this._observableData) {\n return super.update({\n ...buildOptionsFromParams(\n this.endpoint,\n this._observableData.params,\n this._observableData.uniqKey,\n ),\n ...updateParams,\n });\n } else {\n return super.update(updateParams);\n }\n }\n\n refetch(\n options?: RefetchOptions,\n ): Promise<QueryObserverResult<TData, TError>> {\n if (this.params) {\n return super.refetch(options);\n }\n return Promise.resolve(this.queryObserver.getCurrentResult());\n }\n\n async start(\n params: MaybeFalsy<TEndpoint['__params']>,\n ): Promise<QueryObserverResult<TData, TError>> {\n runInAction(() => {\n this._observableData.params = params;\n });\n return await super.start(\n buildOptionsFromParams(\n this.endpoint,\n params,\n this._observableData.uniqKey,\n ),\n );\n }\n\n protected handleDestroy(): void {\n super.handleDestroy();\n runInAction(() => {\n this._observableData.params = undefined;\n this._observableData.dynamicOptions = undefined;\n });\n }\n}\n\nexport const getParamsFromContext = (ctx: QueryFunctionContext<any, any>) => {\n return (ctx.queryKey.at(-2) || {}) as AnyEndpoint['__params'];\n};\n\nexport const buildOptionsFromParams = (\n endpoint: AnyEndpoint,\n params: MaybeFalsy<AnyObject>,\n uniqKey: Maybe<EndpointQueryUniqKey>,\n): { enabled: boolean; queryKey: any[] } => {\n const { requiredParams } = endpoint.configuration;\n let hasRequiredParams = false;\n\n if (requiredParams.length > 0) {\n hasRequiredParams =\n !!params && requiredParams.every((param) => param in params);\n } else {\n hasRequiredParams = !!params;\n }\n\n return {\n enabled: hasRequiredParams,\n queryKey: endpoint.toQueryKey(params || {}, uniqKey),\n };\n};\n","import type {\n DefaultError,\n InfiniteData,\n QueryObserverResult,\n} from '@tanstack/query-core';\nimport { makeObservable, observable, runInAction } from 'mobx';\nimport { InfiniteQuery } from 'mobx-tanstack-query';\nimport type { Maybe, MaybeFalsy } from 'yummies/types';\nimport type { AnyEndpoint } from './endpoint.types.js';\nimport type {\n EndpointInfiniteQueryFlattenOptions,\n EndpointInfiniteQueryOptions,\n EndpointInfiniteQueryUpdateOptionsAllVariants,\n} from './endpoint-infinite-query.types.js';\nimport { buildOptionsFromParams } from './endpoint-query.js';\nimport type { EndpointQueryUniqKey } from './endpoint-query.types.js';\nimport type { EndpointQueryClient } from './endpoint-query-client.js';\nimport type { RequestParams } from './http-client.js';\n\nexport class EndpointInfiniteQuery<\n TEndpoint extends AnyEndpoint,\n TQueryFnData = TEndpoint['__response']['data'],\n TError = DefaultError,\n TPageParam = unknown,\n TData = InfiniteData<TQueryFnData, TPageParam>,\n> extends InfiniteQuery<TQueryFnData, TError, TPageParam, TData, any[]> {\n response: TEndpoint['__response'] | null = null;\n params: TEndpoint['__params'] | null = null;\n\n private uniqKey?: EndpointQueryUniqKey;\n\n private paramsFn: EndpointInfiniteQueryFlattenOptions<\n TEndpoint,\n TQueryFnData,\n TError,\n TPageParam,\n TData\n >['params'];\n\n constructor(\n private endpoint: AnyEndpoint,\n queryClient: EndpointQueryClient,\n\n queryOptionsInput:\n | EndpointInfiniteQueryOptions<\n TEndpoint,\n TQueryFnData,\n TError,\n TPageParam,\n TData\n >\n | (() => EndpointInfiniteQueryFlattenOptions<\n TEndpoint,\n TQueryFnData,\n TError,\n TPageParam,\n TData\n >),\n ) {\n const {\n uniqKey,\n transform: transformResponse,\n params: paramsFn,\n ...queryOptions\n } = typeof queryOptionsInput === 'function'\n ? queryOptionsInput()\n : queryOptionsInput;\n\n super({\n ...queryOptions,\n queryClient,\n meta: endpoint.toQueryMeta(queryOptions.meta),\n options: (query): any => {\n const extraOptions: any = {};\n let willEnableManually: boolean;\n let params: any;\n\n const pageParam = query.options.initialPageParam;\n\n if (typeof queryOptionsInput === 'function') {\n Object.assign(extraOptions, queryOptionsInput());\n params = paramsFn(pageParam);\n willEnableManually = false;\n } else {\n willEnableManually = queryOptionsInput.enabled === false;\n params = paramsFn(pageParam);\n }\n\n const builtOptions = buildOptionsFromParams(endpoint, params, uniqKey);\n // const dynamicOuterOptions = getDynamicOptions?.(query);\n\n let isEnabled = false;\n\n if (willEnableManually) {\n // if (dynamicOuterOptions?.enabled != null) {\n // isEnabled = dynamicOuterOptions.enabled;\n // }\n } else {\n // const outerDynamicEnabled =\n // dynamicOuterOptions?.enabled == null ||\n // !!dynamicOuterOptions.enabled;\n\n // isEnabled = builtOptions.enabled && outerDynamicEnabled;\n isEnabled = builtOptions.enabled;\n }\n\n return {\n ...query.options,\n ...builtOptions,\n // ...dynamicOuterOptions,\n enabled: isEnabled,\n ...extraOptions,\n } as any;\n },\n queryFn: async (ctx): Promise<any> => {\n const params = paramsFn(\n (ctx.pageParam as any) ?? queryOptions.initialPageParam,\n ) as TEndpoint['__params'];\n\n runInAction(() => {\n this.response = null;\n this.params = params;\n });\n\n let requestParams = params.request as Maybe<RequestParams>;\n\n if (requestParams) {\n if (!requestParams.signal) {\n requestParams.signal = ctx.signal;\n }\n } else {\n requestParams = { signal: ctx.signal };\n }\n\n const fixedInput = {\n ...params,\n request: requestParams,\n };\n\n const response = await endpoint.request(fixedInput);\n\n runInAction(() => {\n this.response = response as TEndpoint['__response'];\n });\n\n return (await transformResponse?.(response)) ?? response.data;\n },\n });\n\n this.paramsFn = paramsFn;\n this.uniqKey = uniqKey;\n\n observable.ref(this, 'response');\n observable.ref(this, 'params');\n makeObservable(this);\n }\n\n update({\n params,\n ...options\n }: EndpointInfiniteQueryUpdateOptionsAllVariants<\n TEndpoint,\n TQueryFnData,\n TError,\n TPageParam,\n TData\n >) {\n return super.update({\n ...buildOptionsFromParams(this.endpoint, params, this.uniqKey),\n ...options,\n });\n }\n\n async start(\n params: MaybeFalsy<TEndpoint['__params']>,\n ): Promise<QueryObserverResult<TData, TError>> {\n return await super.start(\n buildOptionsFromParams(this.endpoint, params, this.uniqKey),\n );\n }\n}\n","import { Mutation } from 'mobx-tanstack-query';\nimport type { AnyObject, Maybe } from 'yummies/types';\nimport type { AnyEndpoint } from './endpoint.types.js';\nimport type {\n EndpointMutationOptions,\n EndpointMutationParams,\n} from './endpoint-mutation.types.js';\nimport type { EndpointQueryClient } from './endpoint-query-client.js';\nimport type { InvalidateEndpointsFilters } from './endpoint-query-client.types.js';\nimport type { RequestParams } from './http-client.js';\n\n/**\n * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-mutations/)\n */\nexport class EndpointMutation<\n TEndpoint extends AnyEndpoint,\n TData = unknown,\n TParams extends AnyObject = AnyObject,\n TMutationMeta extends AnyObject | void = void,\n TOnMutateResult = unknown,\n> extends Mutation<\n TData,\n EndpointMutationParams<TParams, TMutationMeta>,\n TEndpoint['__response']['error'],\n TOnMutateResult\n> {\n constructor(\n private endpoint: AnyEndpoint,\n inputQueryClient: EndpointQueryClient,\n {\n transform: transformResponse,\n invalidateEndpoints,\n queryClient: overridedQueryClient,\n ...mutationOptions\n }: EndpointMutationOptions<\n TEndpoint,\n TData,\n TParams,\n TMutationMeta,\n TOnMutateResult\n >,\n ) {\n const queryClient = overridedQueryClient ?? inputQueryClient;\n super({\n ...mutationOptions,\n queryClient,\n onSuccess: (data, variables, onMutateResult, context) => {\n mutationOptions.onSuccess?.(data, variables, onMutateResult, context);\n if (invalidateEndpoints) {\n if (typeof invalidateEndpoints === 'object') {\n queryClient.invalidateEndpoints(invalidateEndpoints);\n } else {\n let filters: Maybe<InvalidateEndpointsFilters>;\n switch (`${invalidateEndpoints}`) {\n case 'true': {\n filters = endpoint.group\n ? {\n group: endpoint.group,\n }\n : {\n tag: endpoint.tags,\n };\n\n break;\n }\n case 'by-group': {\n filters = {\n group: endpoint.group,\n };\n\n break;\n }\n case 'by-tag': {\n filters = {\n tag: endpoint.tags,\n };\n\n break;\n }\n }\n\n if (filters) {\n queryClient.invalidateEndpoints(filters);\n }\n }\n }\n },\n mutationFn: async (input, context) => {\n let requestParams = input?.requestParams as Maybe<RequestParams>;\n\n if (requestParams) {\n if (!requestParams.signal) {\n requestParams.signal = context.signal;\n }\n } else {\n requestParams = { signal: context.signal };\n }\n\n const fixedInput = {\n ...input,\n requestParams,\n };\n\n const response = await endpoint.request(fixedInput);\n return (await transformResponse?.(response)) ?? response.data;\n },\n });\n }\n}\n","/** biome-ignore-all lint/style/useShorthandFunctionType: this is special trick to add typings for callable class instance */\nimport type {\n DefaultError,\n InvalidateOptions,\n InvalidateQueryFilters,\n QueryFunctionContext,\n QueryKey,\n} from '@tanstack/query-core';\nimport type { IQueryClientCore } from 'mobx-tanstack-query';\nimport { callFunction } from 'yummies/common';\nimport type { AnyObject, IsPartial, Maybe } from 'yummies/types';\nimport type {\n EndpointConfiguration,\n EndpointMutationPresets,\n} from './endpoint.types.js';\nimport { EndpointInfiniteQuery } from './endpoint-infinite-query.js';\nimport type {\n EndpointInfiniteQueryFlattenOptions,\n EndpointInfiniteQueryOptions,\n} from './endpoint-infinite-query.types.js';\nimport { EndpointMutation } from './endpoint-mutation.js';\nimport type { EndpointMutationOptions } from './endpoint-mutation.types.js';\nimport { EndpointQuery } from './endpoint-query.js';\nimport type {\n EndpointQueryFlattenOptions,\n EndpointQueryMeta,\n EndpointQueryOptions,\n EndpointQueryUniqKey,\n} from './endpoint-query.types.js';\nimport type { EndpointQueryClient } from './endpoint-query-client.js';\nimport type { HttpClient, HttpResponse } from './http-client.js';\n\nexport interface Endpoint<\n TResponse extends HttpResponse<any, any>,\n TParams extends AnyObject,\n TMetaData extends AnyObject = AnyObject,\n> {\n (\n ...args: IsPartial<TParams> extends true\n ? [params?: Maybe<TParams>]\n : [params: TParams]\n ): ReturnType<Endpoint<TResponse, TParams, TMetaData>['request']>;\n}\n\n/**\n * This class is a wrapper for your http request.\n *\n * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoints/)\n */\nexport class Endpoint<\n TResponse extends HttpResponse<any, any>,\n TParams extends AnyObject,\n TMetaData extends AnyObject = AnyObject,\n> {\n endpointId: string;\n\n presets: {\n mutations: EndpointMutationPresets;\n } = {\n mutations: {},\n };\n\n __params!: TParams;\n __response!: TResponse;\n\n meta!: TMetaData;\n\n constructor(\n public configuration: EndpointConfiguration<NoInfer<TParams>, TMetaData>,\n public queryClient: EndpointQueryClient,\n public httpClient: HttpClient,\n ) {\n this.endpointId = globalThis.crypto.randomUUID();\n this.meta = configuration.meta ?? ({} as TMetaData);\n // Сохраняем оригинальный инстанс\n const instance = this;\n\n // Создаем функцию-обертку\n const callable = function (\n this: any,\n ...args: IsPartial<TParams> extends true\n ? [params?: Maybe<TParams>]\n : [params: TParams]\n ) {\n return instance.request.apply(instance, args);\n } as unknown as Endpoint<TResponse, TParams, TMetaData>;\n\n // Копируем прототип\n Object.setPrototypeOf(callable, new.target.prototype);\n\n // Копируем методы из оригинального инстанса\n Object.getOwnPropertyNames(instance)\n .concat(Object.getOwnPropertyNames(new.target.prototype))\n .forEach((key) => {\n if (key === 'constructor') return;\n const desc =\n Object.getOwnPropertyDescriptor(instance, key) ||\n Object.getOwnPropertyDescriptor(new.target.prototype, key);\n if (desc) Object.defineProperty(callable, key, desc);\n });\n\n // biome-ignore lint/correctness/noConstructorReturn: this is special trick to add typings for callable class instance\n return callable;\n }\n\n getFullUrl(\n ...args: IsPartial<TParams> extends true\n ? [params?: Maybe<TParams>]\n : [params: TParams]\n ): string {\n const params = this.configuration.params(args[0] ?? ({} as TParams));\n return this.httpClient.buildUrl(params);\n }\n\n getPath(\n ...args: IsPartial<TParams> extends true\n ? [params?: Maybe<TParams>]\n : [params: TParams]\n ): string {\n const params = this.configuration.params(args[0] ?? ({} as TParams));\n return params.path;\n }\n\n getParamsFromContext<\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n >(\n ctx: Omit<QueryFunctionContext<TQueryKey, TPageParam>, 'client'> & {\n client: IQueryClientCore;\n },\n ): TParams {\n return (ctx.queryKey.at(-2) || {}) as TParams;\n }\n\n get tags() {\n return this.configuration.tags;\n }\n\n get path() {\n return this.configuration.path;\n }\n\n get pathDeclaration() {\n return this.path.join('/');\n }\n\n get operationId() {\n return this.configuration.operationId;\n }\n\n get group() {\n return this.configuration.group;\n }\n\n get namespace() {\n return this.configuration.namespace;\n }\n\n request(\n ...args: IsPartial<TParams> extends true\n ? [params?: Maybe<TParams>]\n : [params: TParams]\n ) {\n return this.httpClient.request<TResponse>(\n this.configuration.params(args[0] ?? ({} as TParams)),\n this,\n );\n }\n\n toQueryMeta = (meta?: AnyObject) =>\n ({\n ...meta,\n tags: this.tags,\n operationId: this.operationId,\n path: this.path,\n pathDeclaration: this.pathDeclaration,\n endpointId: this.endpointId,\n endpointQuery: true,\n }) satisfies EndpointQueryMeta;\n\n toQueryKey(params?: Maybe<TParams>, uniqKey?: EndpointQueryUniqKey): any {\n return [\n ...this.configuration.path,\n this.configuration.operationId,\n params ?? {},\n callFunction(uniqKey),\n ];\n }\n\n toInfiniteQueryKey(\n params?: Maybe<TParams>,\n uniqKey?: EndpointQueryUniqKey,\n ): any {\n return [\n { infiniteQuery: true },\n ...this.configuration.path,\n this.configuration.operationId,\n params ?? {},\n callFunction(uniqKey),\n ];\n }\n\n invalidateQuery(\n ...args: IsPartial<TParams> extends true\n ? [\n params?: Maybe<TParams>,\n filters?: InvalidateQueryFilters & { uniqKey?: EndpointQueryUniqKey },\n options?: InvalidateOptions,\n ]\n : [\n params: TParams,\n filters?: InvalidateQueryFilters & { uniqKey?: EndpointQueryUniqKey },\n options?: InvalidateOptions,\n ]\n ) {\n this.queryClient.invalidateQueries(\n {\n queryKey: this.toQueryKey(args[0], args[1]?.uniqKey),\n exact: true,\n ...(args[1] as any),\n },\n args[2],\n );\n }\n\n toMutation<\n TData = TResponse['data'],\n TMutationMeta extends AnyObject | void = void,\n TContext = unknown,\n >(\n options: EndpointMutationOptions<\n this,\n TData,\n TParams,\n TMutationMeta,\n TContext\n >,\n ) {\n return new EndpointMutation<this, TData, TParams, TMutationMeta, TContext>(\n this,\n this.queryClient,\n {\n ...options,\n invalidateEndpoints:\n options.invalidateEndpoints ??\n this.presets.mutations?.invalidateQueries,\n },\n );\n }\n\n toQuery<\n TQueryFnData = TResponse['data'],\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n >(\n options:\n | EndpointQueryOptions<this, TQueryFnData, TError, TData, TQueryData>\n | (() => EndpointQueryFlattenOptions<\n this,\n TQueryFnData,\n TError,\n TData,\n TQueryData\n >),\n ) {\n return new EndpointQuery<this, TQueryFnData, TError, TData, TQueryData>(\n this,\n this.queryClient,\n options,\n );\n }\n\n toInfiniteQuery<\n TData = TResponse['data'],\n TError = DefaultError,\n TPageParam = unknown,\n >(\n options:\n | EndpointInfiniteQueryOptions<this, TData, TError, TPageParam>\n | (() => EndpointInfiniteQueryFlattenOptions<\n this,\n TData,\n TError,\n TPageParam\n >),\n ) {\n return new EndpointInfiniteQuery<this, TData, TError, TPageParam>(\n this,\n this.queryClient,\n options,\n );\n }\n}\n","import { hashKey, type InvalidateOptions } from '@tanstack/query-core';\nimport { QueryClient, type QueryClientConfig } from 'mobx-tanstack-query';\nimport type { Maybe } from 'yummies/types';\nimport type { EndpointQueryMeta } from './endpoint-query.types.js';\nimport type {\n EndpointStringFilter,\n InvalidateEndpointsFilters,\n} from './endpoint-query-client.types.js';\n\n/**\n * Class that extends `QueryClient` and gives a bit more control over endpoint queries and mutations.\n *\n * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/endpoint-query-client/)\n */\nexport class EndpointQueryClient extends QueryClient {\n constructor(config?: QueryClientConfig) {\n super({\n ...config,\n defaultOptions: {\n ...config?.defaultOptions,\n queries: {\n ...config?.defaultOptions?.queries,\n queryKeyHashFn:\n config?.defaultOptions?.queries?.queryKeyHashFn ?? hashKey,\n },\n },\n });\n }\n\n invalidateEndpoints(\n {\n group,\n namespace,\n operationId,\n tag,\n predicate,\n endpoint,\n ...queryFilters\n }: InvalidateEndpointsFilters,\n options?: InvalidateOptions,\n ) {\n let endpointIdsToFilter: Maybe<Set<string>>;\n\n if (Array.isArray(endpoint)) {\n endpointIdsToFilter = new Set(endpoint.map((it) => it.endpointId));\n } else if (endpoint) {\n endpointIdsToFilter = new Set([endpoint.endpointId]);\n }\n\n return this.invalidateQueries(\n {\n ...queryFilters,\n predicate: (query) => {\n if (!query.meta?.endpointQuery) {\n return false;\n }\n\n const meta = query.meta as unknown as EndpointQueryMeta;\n\n if (\n endpointIdsToFilter &&\n !endpointIdsToFilter.has(meta.endpointId)\n ) {\n return false;\n }\n\n if (\n namespace &&\n meta.namespace &&\n !applyStringFilter(namespace, meta.namespace)\n ) {\n return false;\n }\n\n if (group && meta.group && !applyStringFilter(group, meta.group)) {\n return false;\n }\n\n if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {\n return false;\n }\n\n if (tag && meta.tags && !applyStringFilter(tag, meta.tags)) {\n return false;\n }\n\n if (\n operationId &&\n !applyStringFilter(operationId, meta.operationId)\n ) {\n return false;\n }\n\n if (predicate && !predicate(meta, query as any)) {\n return false;\n }\n\n return true;\n },\n },\n options,\n );\n }\n}\n\nconst applyStringFilter = (\n filter: EndpointStringFilter,\n value: string | string[],\n): boolean => {\n const values = Array.isArray(value) ? value : [value];\n\n if (filter instanceof RegExp) {\n return values.some((value) => filter.test(value));\n }\n\n if (Array.isArray(filter)) {\n return filter.some((filter) => values.includes(filter));\n }\n\n return values.includes(filter);\n};\n","import type {\n HttpStatusCode,\n HttpSuccessStatusCode,\n} from 'http-status-code-types';\nimport { action, makeObservable, observable } from 'mobx';\nimport { type BooleanOptional, type IStringifyOptions, stringify } from 'qs';\nimport type { AnyObject, Defined, Maybe, ValueOf } from 'yummies/types';\nimport type { AnyEndpoint } from './endpoint.types.js';\n\nexport type QueryParamsType = Record<string | number, any>;\nexport type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;\n\nexport interface FullRequestParams extends Omit<RequestInit, 'body'> {\n /** set parameter to `true` for call `securityWorker` for this request */\n secure?: boolean;\n /** request path */\n path: string;\n /** content type of request body */\n contentType?: string;\n /** query params */\n query?: QueryParamsType;\n /** format of response (i.e. response.json() -> format: \"json\") */\n format?: ResponseFormat;\n /** request body */\n body?: unknown;\n /** base url */\n baseUrl?: string;\n /** meta data */\n meta?: Record<string, any>;\n}\n\nexport type RequestParams = Omit<\n FullRequestParams,\n 'body' | 'method' | 'query' | 'path' | 'serviceName'\n>;\n\nexport interface HttpClientConfig<TMeta = unknown> {\n baseUrl?: string;\n meta?: TMeta;\n fetch?: typeof globalThis.fetch;\n baseApiParams?: Omit<RequestParams, 'baseUrl' | 'cancelToken' | 'signal'>;\n contentFormatters?: Record<string, (input: any) => any>;\n queryStringifyOptions?: IStringifyOptions<BooleanOptional>;\n toQueryString?: (query?: AnyObject) => string;\n buildUrl?: (\n fullParams: FullRequestParams,\n formattedParts: { baseUrl: string; path: string; query: string },\n metadata: TMeta | null,\n ) => string;\n interceptor?: (\n requestParams: RequestParams,\n metadata: TMeta | null,\n endpoint?: Maybe<AnyEndpoint>,\n ) => Promise<RequestParams | void> | RequestParams | void;\n}\n\nexport interface HttpResponse<TData, TError = null, TStatus = number>\n extends Omit<Response, 'status'> {\n data: TData;\n error: TError;\n status: TStatus;\n request: {\n url: string;\n params: globalThis.RequestInit;\n };\n}\n\nexport type HttpMultistatusResponse<\n TResponsesByStatusMap extends Partial<Record<HttpStatusCode, any>>,\n TDefaultOkResponse,\n TDefaultBadResponse = unknown,\n> = Omit<Response, 'status'> &\n (\n | ValueOf<{\n [K in keyof TResponsesByStatusMap]: {\n status: K;\n data: K extends HttpSuccessStatusCode\n ? TResponsesByStatusMap[K]\n : TDefaultOkResponse;\n error: K extends HttpSuccessStatusCode\n ? TDefaultBadResponse\n : TResponsesByStatusMap[K];\n };\n }>\n | {\n status: Exclude<HttpStatusCode, keyof TResponsesByStatusMap>;\n data: TDefaultOkResponse;\n error: TDefaultBadResponse;\n }\n );\n\nexport type GetHttpResponse<T> = T extends (...args: any[]) => infer R\n ? R extends Promise<HttpResponse<any, any>>\n ? Awaited<R>\n : R extends Promise<HttpMultistatusResponse<any, any, any>>\n ? Awaited<R>\n : HttpResponse<any, any>\n : HttpResponse<any, any>;\n\nexport type HttpBadResponse<T = any> = HttpResponse<null, T>;\n\nexport type AnyHttpResponse = HttpResponse<any, any>;\n\nexport const isHttpResponse = (\n response: unknown,\n status?: number,\n): response is AnyHttpResponse =>\n !!response &&\n typeof response === 'object' &&\n response instanceof Response &&\n 'data' in response &&\n (!status || response.status === status);\n\nexport const isHttpBadResponse = (\n response: unknown,\n): response is HttpResponse<null, any> => {\n return isHttpResponse(response) && (!response.ok || !!response.error);\n};\n\nexport class HttpClient<TMeta = unknown> {\n private config: HttpClientConfig<TMeta>;\n private fetch: Required<HttpClientConfig<TMeta>>['fetch'];\n\n public meta: TMeta | null;\n public baseApiParams: RequestParams;\n\n badResponse: unknown;\n\n protected toQueryString: Defined<HttpClientConfig<TMeta>['toQueryString']>;\n\n constructor(config?: HttpClientConfig<TMeta>) {\n this.config = config ?? {};\n this.badResponse = null;\n this.meta = config?.meta ?? null;\n this.fetch =\n config?.fetch ??\n ((...fetchParams: Parameters<typeof globalThis.fetch>) =>\n globalThis.fetch(...fetchParams));\n this.toQueryString =\n config?.toQueryString ??\n ((query) => stringify(query, config?.queryStringifyOptions));\n\n this.baseApiParams = {\n credentials: 'same-origin',\n headers: {},\n redirect: 'follow',\n referrerPolicy: 'no-referrer',\n };\n\n this.updateConfig(this.config);\n\n observable.ref(this, 'badResponse');\n observable.ref(this, 'meta');\n\n action(this, 'setMeta');\n action(this, 'setBadResponse');\n\n makeObservable(this);\n }\n\n get baseUrl() {\n return this.config.baseUrl ?? '';\n }\n\n public updateConfig(update: Partial<HttpClientConfig<TMeta>>) {\n Object.assign(this.config, update);\n\n if (update.baseApiParams) {\n Object.assign(this.baseApiParams, update.baseApiParams);\n }\n\n if (update.contentFormatters) {\n Object.assign(this.contentFormatters, update.contentFormatters);\n }\n\n if (update.fetch) {\n this.fetch = update.fetch;\n }\n }\n\n public setMeta = (data: TMeta | null) => {\n this.meta = data;\n };\n\n public setBadResponse = (response: unknown) => {\n this.badResponse = response;\n };\n\n private contentFormatters: Record<string, (input: any) => any> = {\n 'application/json': (input: any) =>\n input !== null && (typeof input === 'object' || typeof input === 'string')\n ? JSON.stringify(input)\n : input,\n 'text/plain': (input: any) =>\n input !== null && typeof input !== 'string'\n ? JSON.stringify(input)\n : input,\n 'multipart/form-data': (input: any) =>\n Object.keys(input || {}).reduce((formData, key) => {\n const property = input[key];\n\n if (property instanceof Blob) {\n formData.append(key, property);\n } else if (typeof property === 'object' && property !== null) {\n formData.append(key, JSON.stringify(property));\n } else {\n formData.append(key, `${property}`);\n }\n\n return formData;\n }, new FormData()),\n 'application/x-www-form-urlencoded': (input: any) =>\n this.toQueryString(input),\n 'application/octet-stream': (input: any) => input,\n };\n\n protected mergeRequestParams(\n params1: RequestParams,\n params2?: RequestParams,\n ): RequestParams {\n return {\n ...this.baseApiParams,\n ...params1,\n ...params2,\n headers: {\n ...this.baseApiParams.headers,\n ...params1.headers,\n ...params2?.headers,\n },\n };\n }\n\n protected async createResponse(\n responseFormat: FullRequestParams['format'],\n raw: Response,\n url: string,\n params: RequestInit,\n ): Promise<AnyHttpResponse> {\n const response = raw as AnyHttpResponse;\n\n response.request = {\n url,\n params,\n };\n response.data = null;\n response.error = null;\n\n if (responseFormat) {\n try {\n const formatted = await response[responseFormat]();\n if (response.ok) {\n response.data = formatted;\n } else {\n response.error = formatted;\n }\n } catch (error) {\n if (response.ok) {\n response.error = error;\n } else {\n response.error = null;\n }\n }\n }\n\n if (!response.ok || response.error) {\n this.setBadResponse(response);\n }\n\n return response;\n }\n\n public buildUrl = (params: FullRequestParams) => {\n const baseUrl = params.baseUrl ?? this.baseUrl ?? '';\n\n const path = params.path;\n\n const queryString = params.query && this.toQueryString(params.query);\n\n const query = queryString ? `?${queryString}` : '';\n\n if (this.config.buildUrl) {\n return this.config.buildUrl(params, { baseUrl, path, query }, this.meta);\n }\n\n const url = baseUrl + path + query;\n\n return url;\n };\n\n public request<T, E>(\n fullParams: FullRequestParams,\n endpoint?: Maybe<AnyEndpoint>,\n ): Promise<HttpResponse<T, E>>;\n public request<THttpResponse extends HttpResponse<any, any>>(\n fullParams: FullRequestParams,\n endpoint?: Maybe<AnyEndpoint>,\n ): Promise<THttpResponse>;\n\n public async request(\n fullParams: FullRequestParams,\n endpoint?: Maybe<AnyEndpoint>,\n ): Promise<any> {\n this.setBadResponse(null);\n\n const {\n body,\n contentType = 'application/json',\n format = 'json',\n ...params\n } = fullParams;\n\n let requestParams = this.mergeRequestParams(params);\n\n if (this.config.interceptor) {\n requestParams =\n (await this.config.interceptor(requestParams, this.meta, endpoint)) ??\n requestParams;\n }\n\n const payloadFormatter = this.contentFormatters[contentType];\n const responseFormat = format || requestParams.format;\n\n const url = this.buildUrl(fullParams);\n\n let headers: Headers;\n\n if (requestParams.headers instanceof Headers) {\n headers = requestParams.headers;\n } else if (Array.isArray(requestParams.headers)) {\n headers = new Headers(requestParams.headers);\n } else {\n headers = new Headers(requestParams.headers);\n }\n\n if (!headers.has('Content-Type')) {\n headers.set('Content-Type', contentType);\n }\n\n const fetchUrl: string = url;\n const fetchParams: RequestInit = {\n ...requestParams,\n headers,\n body: body == null ? null : payloadFormatter(body),\n };\n\n let response: Response | undefined;\n\n try {\n response = await this.fetch(fetchUrl, fetchParams);\n } catch (error) {\n response = error as Response;\n }\n\n const httpResponse = await this.createResponse(\n responseFormat,\n response,\n fetchUrl,\n fetchParams,\n );\n\n if (!httpResponse.ok || httpResponse.error) {\n throw httpResponse;\n }\n\n return httpResponse;\n }\n}\n"],"names":["params","uniqKey","value","filter"],"mappings":";;;;;;;AAwCO,MAAM,sBAMH,MAA+C;AAAA,EAGvD,YACU,UACR,kBACA,mBASA;AACA,UAAM,wBAAwB,OAAO,sBAAsB;AAC3D,UAAM,4BAA4B,wBAC9B,kBAAA,IACA;AAEJ,UAAM;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA,aAAa;AAAA,MACb,GAAG;AAAA,IAAA,IACD;AAEJ,UAAM,cAAc,wBAAwB;AAE5C,UAAM,kBAAqD;AAAA,MACzD,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,SAAS,0BAA0B;AAAA,IAAA;AAGrC,QAAI,CAAC,yBAAyB,OAAO,WAAW,YAAY;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IAC7C,OAAO;AACL,gBAAU,IAAI,QAAQ,cAAc,OAAO;AAAA,IAC7C;AAEA,QAAI,CAAC,QAAQ,IAAI,cAAc,GAAG;AAChC,cAAQ,IAAI,gBAAgB,WAAW;AAAA,IACzC;AAEA,UAAM,WAAmB;AACzB,UAAM,cAA2B;AAAA,MAC/B,GAAG;AAAA,MACH;AAAA,MACA,MAAM,QAAQ,OAAO,OAAO,iBAAiB,IAAI;AAAA,IAAA;AAGnD,QAAI;AAEJ,QAAI;AACF,iBAAW,MAAM,KAAK,MAAM,UAAU,WAAW;AAAA,IACnD,SAAS,OAAO;AACd,iBAAW;AAAA,IACb;AAEA,UAAM,eAAe,MAAM,KAAK;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAGF,QAAI,CAAC,aAAa,MAAM,aAAa,OAAO;AAC1C,YAAM;AAAA,IACR;AAEA,WAAO;AAAA,EACT;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.26.0",
|
|
3
3
|
"name": "mobx-tanstack-query-api",
|
|
4
4
|
"description": "OpenAPI/Swagger client codegen + endpoints integration with mobx-tanstack-query",
|
|
5
5
|
"keywords": [
|
|
@@ -38,74 +38,31 @@
|
|
|
38
38
|
"swagger-typescript-api": "13.2.15",
|
|
39
39
|
"ts-morph": "^26.0.0",
|
|
40
40
|
"undici-types": "^7.11.0",
|
|
41
|
-
"yummies": "^
|
|
41
|
+
"yummies": "^6.0.0"
|
|
42
42
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"@changesets/changelog-github": "^0.5.1",
|
|
46
|
-
"@changesets/cli": "^2.29.5",
|
|
47
|
-
"@testing-library/react": "^16.0.1",
|
|
48
|
-
"@types/node": "^20.17.11",
|
|
49
|
-
"@vitejs/plugin-react-swc": "^3.7.2",
|
|
50
|
-
"@vitest/coverage-istanbul": "^3.2.4",
|
|
51
|
-
"commitfmt": "^1.0.0",
|
|
52
|
-
"js2me-biome-config": "^1.0.5",
|
|
53
|
-
"jsdom": "^26.0.0",
|
|
54
|
-
"lefthook": "^1.11.13",
|
|
55
|
-
"nodemon": "^3.1.9",
|
|
56
|
-
"rimraf": "^6.0.1",
|
|
57
|
-
"sborshik": "^1.0.25",
|
|
58
|
-
"typescript": "^5.8.3",
|
|
59
|
-
"unplugin-swc": "^1.5.1",
|
|
60
|
-
"vitest": "^3.2.4",
|
|
61
|
-
"zshy": "^0.4.2"
|
|
62
|
-
},
|
|
63
|
-
"files": [
|
|
64
|
-
"*"
|
|
65
|
-
],
|
|
66
|
-
"main": "./index.cjs",
|
|
67
|
-
"module": "./index.js",
|
|
68
|
-
"types": "./index.d.cts",
|
|
43
|
+
"bin": "./cli.js",
|
|
44
|
+
"main": "index.js",
|
|
69
45
|
"exports": {
|
|
70
|
-
"./package.json": "./package.json",
|
|
71
|
-
".": {
|
|
72
|
-
"types": "./index.d.cts",
|
|
73
|
-
"import": "./index.js",
|
|
74
|
-
"require": "./index.cjs"
|
|
75
|
-
},
|
|
76
46
|
"./builtin": {
|
|
77
|
-
"types": "./builtin
|
|
78
|
-
"import": "./builtin
|
|
79
|
-
"require": "./builtin
|
|
47
|
+
"types": "./builtin.d.ts",
|
|
48
|
+
"import": "./builtin.js",
|
|
49
|
+
"require": "./builtin.cjs",
|
|
50
|
+
"default": "./builtin.js"
|
|
80
51
|
},
|
|
81
52
|
"./cli": {
|
|
82
|
-
"types": "./cli
|
|
83
|
-
"import": "./cli
|
|
84
|
-
"require": "./cli
|
|
53
|
+
"types": "./cli.d.ts",
|
|
54
|
+
"import": "./cli.js",
|
|
55
|
+
"require": "./cli.cjs",
|
|
56
|
+
"default": "./cli.js"
|
|
57
|
+
},
|
|
58
|
+
".": {
|
|
59
|
+
"types": "./index.d.ts",
|
|
60
|
+
"import": "./index.js",
|
|
61
|
+
"require": "./index.cjs",
|
|
62
|
+
"default": "./index.js"
|
|
85
63
|
}
|
|
86
64
|
},
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"lint:check": "pnpm exec biome check --write --no-errors-on-unmatched --files-ignore-unknown=true",
|
|
91
|
-
"ts:check": "tsc --noEmit",
|
|
92
|
-
"check": "npm run lint:check && npm run ts:check",
|
|
93
|
-
"prebuild": "npm run clean && npm run check",
|
|
94
|
-
"build:watch": "pnpm build && nodemon --delay 0.5 --watch src --ext ts,tsx --exec \"pnpm build\"",
|
|
95
|
-
"build": "sborshik build --fillDist",
|
|
96
|
-
"pub": "pnpm build && sborshik publish --useDistDir",
|
|
97
|
-
"pub:patch": "PUBLISH_VERSION=patch pnpm run build",
|
|
98
|
-
"pub:minor": "PUBLISH_VERSION=minor pnpm run build",
|
|
99
|
-
"pub:major": "PUBLISH_VERSION=major pnpm run build",
|
|
100
|
-
"test": "vitest run --config vitest.config.ts",
|
|
101
|
-
"test:watch": "vitest watch --config vitest.config.ts",
|
|
102
|
-
"test:coverage": "vitest run --config vitest.config.ts --coverage",
|
|
103
|
-
"docs": "pnpm build && cd docs && pnpm dev",
|
|
104
|
-
"docs:install": "cd docs && pnpm i",
|
|
105
|
-
"docs:build": "cd docs && pnpm build",
|
|
106
|
-
"docs:serve": "cd docs && pnpm preview",
|
|
107
|
-
"dev": "pnpm build && nodemon --delay 0.5 --watch src --ext ts,tsx --exec \"pnpm build && pnpm playground\"",
|
|
108
|
-
"playground": "node ./playground/index.mjs",
|
|
109
|
-
"dev:install-hooks": "if [ -z \"$CI\" ]; then lefthook install; fi"
|
|
110
|
-
}
|
|
65
|
+
"files": [
|
|
66
|
+
"*"
|
|
67
|
+
]
|
|
111
68
|
}
|
package/builtin/index.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.http = exports.queryClient = void 0;
|
|
4
|
-
const index_js_1 = require("../runtime/index.cjs");
|
|
5
|
-
const MAX_FAILURE_COUNT = 3;
|
|
6
|
-
exports.queryClient = new index_js_1.EndpointQueryClient({
|
|
7
|
-
defaultOptions: {
|
|
8
|
-
queries: {
|
|
9
|
-
throwOnError: true,
|
|
10
|
-
refetchOnWindowFocus: true,
|
|
11
|
-
refetchOnReconnect: true,
|
|
12
|
-
staleTime: 5 * 60 * 1000,
|
|
13
|
-
retry: (failureCount, error) => {
|
|
14
|
-
if ((0, index_js_1.isHttpBadResponse)(error) && error.status >= 500) {
|
|
15
|
-
return MAX_FAILURE_COUNT - failureCount > 0;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
mutations: {
|
|
21
|
-
throwOnError: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
exports.http = new index_js_1.HttpClient({});
|
package/builtin/index.d.cts
DELETED
package/builtin/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,UAAU,EAEX,6BAA4B;AAI7B,eAAO,MAAM,WAAW,qBAkBtB,CAAC;AAEH,eAAO,MAAM,IAAI,qBAAqB,CAAC"}
|
package/builtin/index.d.ts
DELETED
package/builtin/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,UAAU,EAEX,4BAA4B;AAI7B,eAAO,MAAM,WAAW,qBAkBtB,CAAC;AAEH,eAAO,MAAM,IAAI,qBAAqB,CAAC"}
|
package/builtin/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EndpointQueryClient, HttpClient, isHttpBadResponse, } from "../runtime/index.js";
|
|
2
|
-
const MAX_FAILURE_COUNT = 3;
|
|
3
|
-
export const queryClient = new EndpointQueryClient({
|
|
4
|
-
defaultOptions: {
|
|
5
|
-
queries: {
|
|
6
|
-
throwOnError: true,
|
|
7
|
-
refetchOnWindowFocus: true,
|
|
8
|
-
refetchOnReconnect: true,
|
|
9
|
-
staleTime: 5 * 60 * 1000,
|
|
10
|
-
retry: (failureCount, error) => {
|
|
11
|
-
if (isHttpBadResponse(error) && error.status >= 500) {
|
|
12
|
-
return MAX_FAILURE_COUNT - failureCount > 0;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
mutations: {
|
|
18
|
-
throwOnError: true,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
export const http = new HttpClient({});
|
package/cli/bin.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const cac_1 = require("cac");
|
|
4
|
-
const index_js_1 = require("../codegen/index.cjs");
|
|
5
|
-
const define_config_js_1 = require("./utils/define-config.cjs");
|
|
6
|
-
const exec_config_path_js_1 = require("./utils/exec-config-path.cjs");
|
|
7
|
-
const resolve_config_path_js_1 = require("./utils/resolve-config-path.cjs");
|
|
8
|
-
let cli = (0, cac_1.cac)('mobx-tanstack-query-api');
|
|
9
|
-
cli = cli.option('-c, --config <file>', `[string] use specified config file`);
|
|
10
|
-
cli.help();
|
|
11
|
-
const parsed = cli.parse();
|
|
12
|
-
if (!parsed.options.help) {
|
|
13
|
-
const configPath = (0, resolve_config_path_js_1.resolveConfigPath)(typeof parsed.options.config === 'string' ? parsed.options.config : null);
|
|
14
|
-
(0, exec_config_path_js_1.execConfigPath)(configPath).then((generateApiParams) => {
|
|
15
|
-
(0, define_config_js_1.defineConfig)(generateApiParams).forEach(index_js_1.generateApi);
|
|
16
|
-
});
|
|
17
|
-
}
|
package/cli/bin.d.cts
DELETED
package/cli/bin.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
|
package/cli/bin.d.ts
DELETED
package/cli/bin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/cli/bin.ts"],"names":[],"mappings":""}
|
package/cli/bin.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { cac } from 'cac';
|
|
2
|
-
import { generateApi } from "../codegen/index.js";
|
|
3
|
-
import { defineConfig } from "./utils/define-config.js";
|
|
4
|
-
import { execConfigPath } from "./utils/exec-config-path.js";
|
|
5
|
-
import { resolveConfigPath } from "./utils/resolve-config-path.js";
|
|
6
|
-
let cli = cac('mobx-tanstack-query-api');
|
|
7
|
-
cli = cli.option('-c, --config <file>', `[string] use specified config file`);
|
|
8
|
-
cli.help();
|
|
9
|
-
const parsed = cli.parse();
|
|
10
|
-
if (!parsed.options.help) {
|
|
11
|
-
const configPath = resolveConfigPath(typeof parsed.options.config === 'string' ? parsed.options.config : null);
|
|
12
|
-
execConfigPath(configPath).then((generateApiParams) => {
|
|
13
|
-
defineConfig(generateApiParams).forEach(generateApi);
|
|
14
|
-
});
|
|
15
|
-
}
|
package/cli/index.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../codegen/index.cjs"), exports);
|
|
18
|
-
__exportStar(require("./utils/define-config.cjs"), exports);
|
package/cli/index.d.cts
DELETED
package/cli/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,qCAAoC;AACpC,0CAAyC"}
|
package/cli/index.d.ts
DELETED
package/cli/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,yCAAyC"}
|
package/cli/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { GenerateQueryApiParams } from "../../codegen/types/index.cjs";
|
|
3
|
-
export declare const defineConfig: (...configs: Maybe<GenerateQueryApiParams | GenerateQueryApiParams[]>[]) => GenerateQueryApiParams[];
|
|
4
|
-
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,sCAAqC;AAE3E,eAAO,MAAM,YAAY,GACvB,GAAG,SAAS,KAAK,CAAC,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAAE,KACrE,sBAAsB,EAIxB,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Maybe } from 'yummies/utils/types';
|
|
2
|
-
import type { GenerateQueryApiParams } from "../../codegen/types/index.js";
|
|
3
|
-
export declare const defineConfig: (...configs: Maybe<GenerateQueryApiParams | GenerateQueryApiParams[]>[]) => GenerateQueryApiParams[];
|
|
4
|
-
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,qCAAqC;AAE3E,eAAO,MAAM,YAAY,GACvB,GAAG,SAAS,KAAK,CAAC,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAAE,KACrE,sBAAsB,EAIxB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execConfigPath = void 0;
|
|
4
|
-
const jiti_1 = require("jiti");
|
|
5
|
-
const execConfigPath = async (configPath) => {
|
|
6
|
-
const jiti = (0, jiti_1.createJiti)(require("url").pathToFileURL(__filename));
|
|
7
|
-
try {
|
|
8
|
-
const config = await jiti.import(configPath, { default: true });
|
|
9
|
-
return config;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
console.error(error);
|
|
13
|
-
}
|
|
14
|
-
throw new Error(`${configPath} is not valid, This file should return object - result of the defineConfig function`);
|
|
15
|
-
};
|
|
16
|
-
exports.execConfigPath = execConfigPath;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/exec-config-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,qBAatD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/exec-config-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,qBAatD,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createJiti } from 'jiti';
|
|
2
|
-
export const execConfigPath = async (configPath) => {
|
|
3
|
-
const jiti = createJiti(import.meta.url);
|
|
4
|
-
try {
|
|
5
|
-
const config = await jiti.import(configPath, { default: true });
|
|
6
|
-
return config;
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
console.error(error);
|
|
10
|
-
}
|
|
11
|
-
throw new Error(`${configPath} is not valid, This file should return object - result of the defineConfig function`);
|
|
12
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.resolveConfigPath = void 0;
|
|
40
|
-
const node_fs_1 = __importStar(require("node:fs"));
|
|
41
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
42
|
-
const projectDir = process.cwd();
|
|
43
|
-
const resolveConfigPath = (userSpefiedPath) => {
|
|
44
|
-
if (userSpefiedPath) {
|
|
45
|
-
const fullUserSpecifiedPath = node_path_1.default.resolve(projectDir, userSpefiedPath);
|
|
46
|
-
if (!node_fs_1.default.existsSync(fullUserSpecifiedPath)) {
|
|
47
|
-
throw `Config file not found by path - ${userSpefiedPath}`;
|
|
48
|
-
}
|
|
49
|
-
return node_path_1.default.resolve(projectDir, userSpefiedPath);
|
|
50
|
-
}
|
|
51
|
-
if ((0, node_fs_1.existsSync)(node_path_1.default.resolve(projectDir, 'api-codegen.config.js'))) {
|
|
52
|
-
return node_path_1.default.resolve(projectDir, 'api-codegen.config.js');
|
|
53
|
-
}
|
|
54
|
-
else if ((0, node_fs_1.existsSync)(node_path_1.default.resolve(projectDir, 'api-codegen.config.mjs'))) {
|
|
55
|
-
return node_path_1.default.resolve(projectDir, 'api-codegen.config.mjs');
|
|
56
|
-
}
|
|
57
|
-
else if ((0, node_fs_1.existsSync)(node_path_1.default.resolve(projectDir, 'api-codegen.config.json'))) {
|
|
58
|
-
return node_path_1.default.resolve(projectDir, 'api-codegen.config.json');
|
|
59
|
-
}
|
|
60
|
-
else if ((0, node_fs_1.existsSync)(node_path_1.default.resolve(projectDir, 'api-codegen.config.ts'))) {
|
|
61
|
-
return node_path_1.default.resolve(projectDir, 'api-codegen.config.ts');
|
|
62
|
-
}
|
|
63
|
-
throw new Error('api-codegen.config.(js|mjs|json|ts) not found');
|
|
64
|
-
};
|
|
65
|
-
exports.resolveConfigPath = resolveConfigPath;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/resolve-config-path.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAIjD,eAAO,MAAM,iBAAiB,GAAI,kBAAkB,KAAK,CAAC,MAAM,CAAC,WAsBhE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/resolve-config-path.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAIjD,eAAO,MAAM,iBAAiB,GAAI,kBAAkB,KAAK,CAAC,MAAM,CAAC,WAsBhE,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs, { existsSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
const projectDir = process.cwd();
|
|
4
|
-
export const resolveConfigPath = (userSpefiedPath) => {
|
|
5
|
-
if (userSpefiedPath) {
|
|
6
|
-
const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);
|
|
7
|
-
if (!fs.existsSync(fullUserSpecifiedPath)) {
|
|
8
|
-
throw `Config file not found by path - ${userSpefiedPath}`;
|
|
9
|
-
}
|
|
10
|
-
return path.resolve(projectDir, userSpefiedPath);
|
|
11
|
-
}
|
|
12
|
-
if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {
|
|
13
|
-
return path.resolve(projectDir, 'api-codegen.config.js');
|
|
14
|
-
}
|
|
15
|
-
else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {
|
|
16
|
-
return path.resolve(projectDir, 'api-codegen.config.mjs');
|
|
17
|
-
}
|
|
18
|
-
else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {
|
|
19
|
-
return path.resolve(projectDir, 'api-codegen.config.json');
|
|
20
|
-
}
|
|
21
|
-
else if (existsSync(path.resolve(projectDir, 'api-codegen.config.ts'))) {
|
|
22
|
-
return path.resolve(projectDir, 'api-codegen.config.ts');
|
|
23
|
-
}
|
|
24
|
-
throw new Error('api-codegen.config.(js|mjs|json|ts) not found');
|
|
25
|
-
};
|