zenstack 1.8.2 → 1.10.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/cli/actions/repl.js +31 -4
- package/cli/actions/repl.js.map +1 -1
- package/cli/cli-util.js +1 -1
- package/cli/cli-util.js.map +1 -1
- package/language-server/validator/datamodel-validator.js +22 -16
- package/language-server/validator/datamodel-validator.js.map +1 -1
- package/language-server/validator/function-invocation-validator.js +1 -0
- package/language-server/validator/function-invocation-validator.js.map +1 -1
- package/language-server/validator/schema-validator.js +2 -1
- package/language-server/validator/schema-validator.js.map +1 -1
- package/language-server/zmodel-completion-provider.js +5 -5
- package/language-server/zmodel-completion-provider.js.map +1 -1
- package/language-server/zmodel-linker.js +10 -2
- package/language-server/zmodel-linker.js.map +1 -1
- package/language-server/zmodel-module.js +4 -0
- package/language-server/zmodel-module.js.map +1 -1
- package/package.json +6 -6
- package/plugins/prisma/prisma-builder.d.ts +4 -5
- package/plugins/prisma/prisma-builder.js +2 -3
- package/plugins/prisma/prisma-builder.js.map +1 -1
- package/plugins/prisma/schema-generator.d.ts +1 -0
- package/plugins/prisma/schema-generator.js +10 -7
- package/plugins/prisma/schema-generator.js.map +1 -1
- package/plugins/zod/generator.js +4 -1
- package/plugins/zod/generator.js.map +1 -1
- package/plugins/zod/utils/schema-gen.js +1 -1
- package/plugins/zod/utils/schema-gen.js.map +1 -1
- package/res/stdlib.zmodel +94 -7
- package/utils/exec-utils.d.ts +4 -0
- package/utils/exec-utils.js +11 -1
- package/utils/exec-utils.js.map +1 -1
- package/utils/pkg-utils.d.ts +29 -0
- package/utils/pkg-utils.js +42 -22
- package/utils/pkg-utils.js.map +1 -1
package/utils/pkg-utils.d.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
export type PackageManagers = 'npm' | 'yarn' | 'pnpm';
|
|
2
|
+
/**
|
|
3
|
+
* A type named FindUp that takes a type parameter e which extends boolean.
|
|
4
|
+
* If e extends true, it returns a union type of string[] or undefined.
|
|
5
|
+
* If e does not extend true, it returns a union type of string or undefined.
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @template e A type parameter that extends boolean
|
|
9
|
+
*/
|
|
10
|
+
export type FindUp<e extends boolean> = e extends true ? string[] | undefined : string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Find and return file paths by searching parent directories based on the given names list and current working directory (cwd) path.
|
|
13
|
+
* Optionally return a single path or multiple paths.
|
|
14
|
+
* If multiple allowed, return all paths found.
|
|
15
|
+
* If no paths are found, return undefined.
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
* @template [e=false]
|
|
19
|
+
* @param names An array of strings representing names to search for within the directory
|
|
20
|
+
* @param cwd A string representing the current working directory
|
|
21
|
+
* @param [multiple=false as e] A boolean flag indicating whether to search for multiple levels. Useful for finding node_modules directories...
|
|
22
|
+
* @param [result=[]] An array of strings representing the accumulated results used in multiple results
|
|
23
|
+
* @returns Path(s) to a specific file or folder within the directory or parent directories
|
|
24
|
+
*/
|
|
25
|
+
export declare function findUp<e extends boolean = false>(names: string[], cwd?: string, multiple?: e, result?: string[]): FindUp<e>;
|
|
2
26
|
export declare function installPackage(pkg: string, dev: boolean, pkgManager?: PackageManagers | undefined, tag?: string, projectPath?: string, exactVersion?: boolean): void;
|
|
3
27
|
export declare function ensurePackage(pkg: string, dev: boolean, pkgManager?: PackageManagers | undefined, tag?: string, projectPath?: string, exactVersion?: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* A function that searches for the nearest package.json file starting from the provided search path or the current working directory if no search path is provided.
|
|
30
|
+
* It iterates through the directory structure going one level up at a time until it finds a package.json file. If no package.json file is found, it returns undefined.
|
|
31
|
+
* @deprecated Use findUp instead @see findUp
|
|
32
|
+
*/
|
|
4
33
|
export declare function findPackageJson(searchPath?: string): string | undefined;
|
|
5
34
|
export declare function getPackageJson(searchPath?: string): any;
|
package/utils/pkg-utils.js
CHANGED
|
@@ -3,30 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPackageJson = exports.findPackageJson = exports.ensurePackage = exports.installPackage = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
exports.getPackageJson = exports.findPackageJson = exports.ensurePackage = exports.installPackage = exports.findUp = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const exec_utils_1 = require("./exec-utils");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Find and return file paths by searching parent directories based on the given names list and current working directory (cwd) path.
|
|
12
|
+
* Optionally return a single path or multiple paths.
|
|
13
|
+
* If multiple allowed, return all paths found.
|
|
14
|
+
* If no paths are found, return undefined.
|
|
15
|
+
*
|
|
16
|
+
* @export
|
|
17
|
+
* @template [e=false]
|
|
18
|
+
* @param names An array of strings representing names to search for within the directory
|
|
19
|
+
* @param cwd A string representing the current working directory
|
|
20
|
+
* @param [multiple=false as e] A boolean flag indicating whether to search for multiple levels. Useful for finding node_modules directories...
|
|
21
|
+
* @param [result=[]] An array of strings representing the accumulated results used in multiple results
|
|
22
|
+
* @returns Path(s) to a specific file or folder within the directory or parent directories
|
|
23
|
+
*/
|
|
24
|
+
function findUp(names, cwd = process.cwd(), multiple = false, result = []) {
|
|
25
|
+
if (!names.some((name) => !!name))
|
|
26
|
+
return undefined;
|
|
27
|
+
const target = names.find((name) => node_fs_1.default.existsSync(node_path_1.default.join(cwd, name)));
|
|
28
|
+
if (multiple == false && target)
|
|
29
|
+
return node_path_1.default.join(cwd, target);
|
|
30
|
+
if (target)
|
|
31
|
+
result.push(node_path_1.default.join(cwd, target));
|
|
32
|
+
const up = node_path_1.default.resolve(cwd, '..');
|
|
33
|
+
if (up === cwd)
|
|
34
|
+
return (multiple && result.length > 0 ? result : undefined); // it'll fail anyway
|
|
35
|
+
return findUp(names, up, multiple, result);
|
|
22
36
|
}
|
|
37
|
+
exports.findUp = findUp;
|
|
23
38
|
function getPackageManager(projectPath = '.') {
|
|
24
39
|
const lockFile = findUp(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json'], projectPath);
|
|
25
40
|
if (!lockFile) {
|
|
26
41
|
// default use npm
|
|
27
42
|
return 'npm';
|
|
28
43
|
}
|
|
29
|
-
switch (
|
|
44
|
+
switch (node_path_1.default.basename(lockFile)) {
|
|
30
45
|
case 'yarn.lock':
|
|
31
46
|
return 'yarn';
|
|
32
47
|
case 'pnpm-lock.yaml':
|
|
@@ -52,7 +67,7 @@ function installPackage(pkg, dev, pkgManager = undefined, tag = 'latest', projec
|
|
|
52
67
|
}
|
|
53
68
|
exports.installPackage = installPackage;
|
|
54
69
|
function ensurePackage(pkg, dev, pkgManager = undefined, tag = 'latest', projectPath = '.', exactVersion = false) {
|
|
55
|
-
const resolvePath =
|
|
70
|
+
const resolvePath = node_path_1.default.resolve(projectPath);
|
|
56
71
|
try {
|
|
57
72
|
require.resolve(pkg, { paths: [resolvePath] });
|
|
58
73
|
}
|
|
@@ -61,14 +76,19 @@ function ensurePackage(pkg, dev, pkgManager = undefined, tag = 'latest', project
|
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
78
|
exports.ensurePackage = ensurePackage;
|
|
79
|
+
/**
|
|
80
|
+
* A function that searches for the nearest package.json file starting from the provided search path or the current working directory if no search path is provided.
|
|
81
|
+
* It iterates through the directory structure going one level up at a time until it finds a package.json file. If no package.json file is found, it returns undefined.
|
|
82
|
+
* @deprecated Use findUp instead @see findUp
|
|
83
|
+
*/
|
|
64
84
|
function findPackageJson(searchPath) {
|
|
65
85
|
let currDir = searchPath !== null && searchPath !== void 0 ? searchPath : process.cwd();
|
|
66
86
|
while (currDir) {
|
|
67
|
-
const pkgJsonPath =
|
|
68
|
-
if (
|
|
87
|
+
const pkgJsonPath = node_path_1.default.join(currDir, 'package.json');
|
|
88
|
+
if (node_fs_1.default.existsSync(pkgJsonPath)) {
|
|
69
89
|
return pkgJsonPath;
|
|
70
90
|
}
|
|
71
|
-
const up =
|
|
91
|
+
const up = node_path_1.default.resolve(currDir, '..');
|
|
72
92
|
if (up === currDir) {
|
|
73
93
|
return undefined;
|
|
74
94
|
}
|
|
@@ -78,9 +98,9 @@ function findPackageJson(searchPath) {
|
|
|
78
98
|
}
|
|
79
99
|
exports.findPackageJson = findPackageJson;
|
|
80
100
|
function getPackageJson(searchPath) {
|
|
81
|
-
const pkgJsonPath =
|
|
101
|
+
const pkgJsonPath = findUp(['package.json'], searchPath !== null && searchPath !== void 0 ? searchPath : process.cwd());
|
|
82
102
|
if (pkgJsonPath) {
|
|
83
|
-
return JSON.parse(
|
|
103
|
+
return JSON.parse(node_fs_1.default.readFileSync(pkgJsonPath, 'utf-8'));
|
|
84
104
|
}
|
|
85
105
|
else {
|
|
86
106
|
return undefined;
|
package/utils/pkg-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-utils.js","sourceRoot":"","sources":["../../src/utils/pkg-utils.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"pkg-utils.js","sourceRoot":"","sources":["../../src/utils/pkg-utils.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,6CAAwC;AAaxC;;;;;;;;;;;;;GAaG;AACH,SAAgB,MAAM,CAA4B,KAAe,EAAE,MAAc,OAAO,CAAC,GAAG,EAAE,EAAE,WAAc,KAAU,EAAE,SAAmB,EAAE;IAC3I,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAA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