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