mulink 1.1.9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/{chunk-2WVV6AOO.js → chunk-4H6HG3HY.js} +95 -18
- package/dist/lib/chunk-4H6HG3HY.js.map +1 -0
- package/dist/lib/{chunk-NC747MZJ.cjs → chunk-SOVBAUFP.cjs} +95 -18
- package/dist/lib/chunk-SOVBAUFP.cjs.map +1 -0
- package/dist/lib/cli.cjs +16 -16
- package/dist/lib/cli.js +1 -1
- package/dist/lib/client.cjs +18 -18
- package/dist/lib/client.js +2 -2
- package/dist/lib/index.cjs +32 -32
- package/dist/lib/index.js +2 -2
- package/package.json +1 -1
- package/dist/lib/chunk-2WVV6AOO.js.map +0 -1
- package/dist/lib/chunk-NC747MZJ.cjs.map +0 -1
|
@@ -2708,6 +2708,61 @@ var SchemaGenerator = class {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
return dependencies;
|
|
2710
2710
|
}
|
|
2711
|
+
extractDependenciesFromDefinition(definition, exportName) {
|
|
2712
|
+
const dependencies = [];
|
|
2713
|
+
const schemaRefRegex = /([A-Z][a-zA-Z0-9]*Schema)\b/g;
|
|
2714
|
+
const matches = definition.matchAll(schemaRefRegex);
|
|
2715
|
+
const selfBaseName = exportName.replace(/Schema$/, "");
|
|
2716
|
+
for (const match of matches) {
|
|
2717
|
+
const schemaName = match[1];
|
|
2718
|
+
if (!schemaName) continue;
|
|
2719
|
+
const baseName = schemaName.replace(/Schema$/, "");
|
|
2720
|
+
if (baseName === selfBaseName) continue;
|
|
2721
|
+
if (!dependencies.includes(baseName)) {
|
|
2722
|
+
dependencies.push(baseName);
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
return dependencies;
|
|
2726
|
+
}
|
|
2727
|
+
orderDefinitionsByDependencies(definitions) {
|
|
2728
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2729
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
2730
|
+
const result = [];
|
|
2731
|
+
const definitionMap = /* @__PURE__ */ new Map();
|
|
2732
|
+
for (const def of definitions) {
|
|
2733
|
+
const baseName = def.exportName.replace(/Schema$/, "");
|
|
2734
|
+
definitionMap.set(baseName, def);
|
|
2735
|
+
}
|
|
2736
|
+
const visit = /* @__PURE__ */ __name((exportName) => {
|
|
2737
|
+
const baseName = exportName.replace(/Schema$/, "");
|
|
2738
|
+
if (visiting.has(baseName)) {
|
|
2739
|
+
console.warn(`Circular dependency detected for schema: ${exportName}`);
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
if (visited.has(baseName)) {
|
|
2743
|
+
return;
|
|
2744
|
+
}
|
|
2745
|
+
visiting.add(baseName);
|
|
2746
|
+
const def = definitionMap.get(baseName);
|
|
2747
|
+
if (def) {
|
|
2748
|
+
for (const dep of def.dependencies) {
|
|
2749
|
+
if (definitionMap.has(dep)) {
|
|
2750
|
+
visit(`${dep}Schema`);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
result.push(def);
|
|
2754
|
+
}
|
|
2755
|
+
visiting.delete(baseName);
|
|
2756
|
+
visited.add(baseName);
|
|
2757
|
+
}, "visit");
|
|
2758
|
+
for (const def of definitions) {
|
|
2759
|
+
const baseName = def.exportName.replace(/Schema$/, "");
|
|
2760
|
+
if (!visited.has(baseName)) {
|
|
2761
|
+
visit(def.exportName);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
return result;
|
|
2765
|
+
}
|
|
2711
2766
|
extractDependenciesFromZodSchema(zodSchema, dependencies, visited = /* @__PURE__ */ new Set()) {
|
|
2712
2767
|
if (!zodSchema?._def) return;
|
|
2713
2768
|
const def = zodSchema._def;
|
|
@@ -2768,18 +2823,27 @@ var SchemaGenerator = class {
|
|
|
2768
2823
|
const { schemas, endpoints } = context.schema;
|
|
2769
2824
|
const imports = ['import { z } from "zod"'];
|
|
2770
2825
|
const schemaExports = [];
|
|
2771
|
-
const
|
|
2826
|
+
const allSchemaDefinitions = [];
|
|
2772
2827
|
const orderedSchemas = this.orderSchemasByDependencies(schemas);
|
|
2773
2828
|
for (const schema of orderedSchemas) {
|
|
2774
2829
|
const { definition, exportName } = this.generateSchemaDefinition(schema);
|
|
2775
|
-
|
|
2830
|
+
const dependencies = this.findSchemaDependencies(schema);
|
|
2831
|
+
allSchemaDefinitions.push({ definition, exportName, dependencies });
|
|
2776
2832
|
schemaExports.push(exportName);
|
|
2777
2833
|
}
|
|
2778
2834
|
for (const endpoint of endpoints) {
|
|
2779
2835
|
const endpointSchemas = this.generateEndpointSchemas(endpoint);
|
|
2780
|
-
|
|
2781
|
-
|
|
2836
|
+
for (let i = 0; i < endpointSchemas.definitions.length; i++) {
|
|
2837
|
+
const definition = endpointSchemas.definitions[i];
|
|
2838
|
+
const exportName = endpointSchemas.exports[i];
|
|
2839
|
+
if (!definition || !exportName) continue;
|
|
2840
|
+
const dependencies = this.extractDependenciesFromDefinition(definition, exportName);
|
|
2841
|
+
allSchemaDefinitions.push({ definition, exportName, dependencies });
|
|
2842
|
+
schemaExports.push(exportName);
|
|
2843
|
+
}
|
|
2782
2844
|
}
|
|
2845
|
+
const orderedDefinitions = this.orderDefinitionsByDependencies(allSchemaDefinitions);
|
|
2846
|
+
const schemaDefinitions = orderedDefinitions.map((item) => item.definition);
|
|
2783
2847
|
const validationHelpers = this.generateValidationHelpers();
|
|
2784
2848
|
const contentWithImports = [
|
|
2785
2849
|
...imports,
|
|
@@ -3778,7 +3842,7 @@ var HookGenerator = class {
|
|
|
3778
3842
|
__name(this, "HookGenerator");
|
|
3779
3843
|
}
|
|
3780
3844
|
buildImportPath(relativePath) {
|
|
3781
|
-
const outputDirectory = this.configuration.outputDir
|
|
3845
|
+
const outputDirectory = this.configuration.outputDir || "generated";
|
|
3782
3846
|
const cleanPath = relativePath.startsWith("/") ? relativePath.slice(1) : relativePath;
|
|
3783
3847
|
let importBasePath = outputDirectory;
|
|
3784
3848
|
if (importBasePath.startsWith("src/")) {
|
|
@@ -3966,6 +4030,18 @@ ${Object.keys(endpointsByTag).map((tag) => `export * from './${toValidIdentifier
|
|
|
3966
4030
|
const enabledCondition = pathParameters.length > 0 && pathParameters[0] ? `!!params?.path?.${pathParameters[0].name}` : "true";
|
|
3967
4031
|
const pathParamsBuild = pathParameters.length > 0 ? `{ ${pathParameters.map((p) => `${p.name}: params.path.${p.name}`).join(", ")} }` : "{}";
|
|
3968
4032
|
const queryParamsBuild = queryParameters.length > 0 ? `{ ${queryParameters.map((p) => `${p.name}: params?.query?.${p.name}`).join(", ")} }` : "{}";
|
|
4033
|
+
const queryKeyParts = [`'${toActionName(endpoint.operationId || endpoint.id)}'`];
|
|
4034
|
+
if (pathParameters.length > 0) {
|
|
4035
|
+
queryKeyParts.push("params?.path");
|
|
4036
|
+
} else {
|
|
4037
|
+
queryKeyParts.push("null");
|
|
4038
|
+
}
|
|
4039
|
+
if (queryParameters.length > 0) {
|
|
4040
|
+
queryKeyParts.push("params?.query");
|
|
4041
|
+
}
|
|
4042
|
+
const queryKeyString = `[${queryKeyParts.join(", ")}]`;
|
|
4043
|
+
const hasAnyParams = pathParameters.length > 0 || queryParameters.length > 0;
|
|
4044
|
+
const actionCallString = pathParameters.length > 0 && queryParameters.length > 0 ? `{ path: ${pathParamsBuild}, query: ${queryParamsBuild} }` : pathParameters.length > 0 ? `{ path: ${pathParamsBuild} }` : queryParameters.length > 0 ? `{ query: ${queryParamsBuild} }` : "";
|
|
3969
4045
|
if (hasSearchParams) {
|
|
3970
4046
|
const queryParamsWithFallback = queryParameters.length > 0 ? `const queryParams = {
|
|
3971
4047
|
${queryParameters.map((param) => {
|
|
@@ -3977,7 +4053,8 @@ ${Object.keys(endpointsByTag).map((tag) => `export * from './${toValidIdentifier
|
|
|
3977
4053
|
return `${param.name}: params?.query?.${param.name}`;
|
|
3978
4054
|
}
|
|
3979
4055
|
}).join(",\n ")}
|
|
3980
|
-
}` : "
|
|
4056
|
+
}` : "";
|
|
4057
|
+
const actionCallForSearchParams = queryParameters.length > 0 ? pathParameters.length > 0 ? `{ path: ${pathParamsBuild}, query: queryParams }` : "{ query: queryParams }" : pathParameters.length > 0 ? `{ path: ${pathParamsBuild} }` : hasAnyParams ? actionCallString : "";
|
|
3981
4058
|
return `/**
|
|
3982
4059
|
* Optimized query hook for ${endpoint.method} ${endpoint.path}
|
|
3983
4060
|
* Features: URL state sync, infinite loading, optimistic updates
|
|
@@ -3990,11 +4067,11 @@ export function ${hookName}(params${pathParameters.length > 0 ? "" : "?"}: ${par
|
|
|
3990
4067
|
const { initialData, ...restOptions } = options ?? {}
|
|
3991
4068
|
|
|
3992
4069
|
return useQuery({
|
|
3993
|
-
queryKey: [
|
|
4070
|
+
queryKey: [${queryKeyString}, searchParams],
|
|
3994
4071
|
queryFn: async ({ signal }: { signal?: AbortSignal }) => {
|
|
3995
4072
|
try {
|
|
3996
4073
|
${queryParamsWithFallback}
|
|
3997
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${
|
|
4074
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallForSearchParams}))
|
|
3998
4075
|
return result
|
|
3999
4076
|
} catch (error) {
|
|
4000
4077
|
handleActionError(error)
|
|
@@ -4031,7 +4108,7 @@ export function ${hookName.replace("use", "useInfinite")}(params${pathParameters
|
|
|
4031
4108
|
const { initialData, ...restOptions } = options ?? {}
|
|
4032
4109
|
|
|
4033
4110
|
return useInfiniteQuery({
|
|
4034
|
-
queryKey: [
|
|
4111
|
+
queryKey: [${queryKeyString}, 'infinite', searchParams],
|
|
4035
4112
|
initialPageParam: 1,
|
|
4036
4113
|
queryFn: async ({ pageParam = 1, signal }: { pageParam?: number; signal?: AbortSignal }) => {
|
|
4037
4114
|
try {
|
|
@@ -4048,7 +4125,7 @@ export function ${hookName.replace("use", "useInfinite")}(params${pathParameters
|
|
|
4048
4125
|
}
|
|
4049
4126
|
}).join(",\n ")}
|
|
4050
4127
|
}
|
|
4051
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${pathParameters.length > 0 ? `{ path: ${pathParamsBuild}, query: queryParams }` : "{ query: queryParams }"}))
|
|
4128
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${queryParameters.length > 0 ? pathParameters.length > 0 ? `{ path: ${pathParamsBuild}, query: queryParams }` : "{ query: queryParams }" : pathParameters.length > 0 ? `{ path: ${pathParamsBuild} }` : hasAnyParams ? actionCallString : ""}))
|
|
4052
4129
|
return result
|
|
4053
4130
|
} catch (error) {
|
|
4054
4131
|
handleActionError(error)
|
|
@@ -4098,9 +4175,9 @@ export function ${hookName.replace("use", "useSuspense")}(params${pathParameters
|
|
|
4098
4175
|
const { initialData, ...restOptions } = options ?? {}
|
|
4099
4176
|
|
|
4100
4177
|
return useSuspenseQuery({
|
|
4101
|
-
queryKey:
|
|
4178
|
+
queryKey: ${queryKeyString},
|
|
4102
4179
|
queryFn: async () => {
|
|
4103
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${
|
|
4180
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallString}))
|
|
4104
4181
|
return result
|
|
4105
4182
|
},
|
|
4106
4183
|
staleTime: ${staleTime},
|
|
@@ -4120,10 +4197,10 @@ export function ${hookName}(params${pathParameters.length > 0 ? "" : "?"}: ${par
|
|
|
4120
4197
|
const { initialData, ...restOptions } = options ?? {}
|
|
4121
4198
|
|
|
4122
4199
|
return useQuery({
|
|
4123
|
-
queryKey:
|
|
4200
|
+
queryKey: ${queryKeyString},
|
|
4124
4201
|
queryFn: async ({ signal }: { signal?: AbortSignal }) => {
|
|
4125
4202
|
try {
|
|
4126
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${
|
|
4203
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${hasAnyParams ? actionCallString : ""}))
|
|
4127
4204
|
return result
|
|
4128
4205
|
} catch (error) {
|
|
4129
4206
|
handleActionError(error)
|
|
@@ -4159,9 +4236,9 @@ export function ${hookName.replace("use", "useSuspense")}(params${pathParameters
|
|
|
4159
4236
|
const { initialData, ...restOptions } = options ?? {}
|
|
4160
4237
|
|
|
4161
4238
|
return useSuspenseQuery({
|
|
4162
|
-
queryKey:
|
|
4239
|
+
queryKey: ${queryKeyString},
|
|
4163
4240
|
queryFn: async () => {
|
|
4164
|
-
const result = await resolveActionResult<${returnType}>(${actionName}(${
|
|
4241
|
+
const result = await resolveActionResult<${returnType}>(${actionName}(${actionCallString}))
|
|
4165
4242
|
return result
|
|
4166
4243
|
},
|
|
4167
4244
|
staleTime: ${staleTime},
|
|
@@ -9994,5 +10071,5 @@ exports.VersionChecker = VersionChecker;
|
|
|
9994
10071
|
exports.__name = __name;
|
|
9995
10072
|
exports.checkAndNotifyUpdates = checkAndNotifyUpdates;
|
|
9996
10073
|
exports.createBridgeVersionChecker = createBridgeVersionChecker;
|
|
9997
|
-
//# sourceMappingURL=chunk-
|
|
9998
|
-
//# sourceMappingURL=chunk-
|
|
10074
|
+
//# sourceMappingURL=chunk-SOVBAUFP.cjs.map
|
|
10075
|
+
//# sourceMappingURL=chunk-SOVBAUFP.cjs.map
|