@zenstackhq/sdk 1.0.0-alpha.28 → 1.0.0-alpha.30
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/package.json +2 -2
- package/utils.d.ts +2 -1
- package/utils.js +12 -1
- package/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
4
4
|
"description": "ZenStack plugin development SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@prisma/generator-helper": "^4.7.1",
|
|
15
|
-
"@zenstackhq/language": "1.0.0-alpha.
|
|
15
|
+
"@zenstackhq/language": "1.0.0-alpha.29"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"copyfiles": "^2.4.1",
|
package/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AstNode, Expression, Reference } from '@zenstackhq/language/ast';
|
|
1
|
+
import { AstNode, DataModelAttribute, DataModelFieldAttribute, Expression, Reference } from '@zenstackhq/language/ast';
|
|
2
2
|
export declare function resolved<T extends AstNode>(ref: Reference<T>): T;
|
|
3
3
|
export declare function getLiteral<T extends string | number | boolean | any = any>(expr: Expression | undefined): T | undefined;
|
|
4
4
|
export declare function getArray(expr: Expression | undefined): Expression[] | undefined;
|
|
5
5
|
export declare function getLiteralArray<T extends string | number | boolean | any = any>(expr: Expression | undefined): (T | undefined)[] | undefined;
|
|
6
6
|
export default function indentString(string: string, count?: number): string;
|
|
7
|
+
export declare function getAttributeArgs(attr: DataModelAttribute | DataModelFieldAttribute): Record<string, Expression>;
|
package/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLiteralArray = exports.getArray = exports.getLiteral = exports.resolved = void 0;
|
|
3
|
+
exports.getAttributeArgs = exports.getLiteralArray = exports.getArray = exports.getLiteral = exports.resolved = void 0;
|
|
4
4
|
const ast_1 = require("@zenstackhq/language/ast");
|
|
5
5
|
function resolved(ref) {
|
|
6
6
|
if (!ref.ref) {
|
|
@@ -34,4 +34,15 @@ function indentString(string, count = 4) {
|
|
|
34
34
|
return string.replace(/^(?!\s*$)/gm, indent.repeat(count));
|
|
35
35
|
}
|
|
36
36
|
exports.default = indentString;
|
|
37
|
+
function getAttributeArgs(attr) {
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const arg of attr.args) {
|
|
40
|
+
if (!arg.$resolvedParam) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
result[arg.$resolvedParam.name] = arg.value;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
exports.getAttributeArgs = getAttributeArgs;
|
|
37
48
|
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,kDAQkC;AAElC,SAAgB,QAAQ,CAAoB,GAAiB;IACzD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;KAC9D;IACD,OAAO,GAAG,CAAC,GAAG,CAAC;AACnB,CAAC;AALD,4BAKC;AAED,8DAA8D;AAC9D,SAAgB,UAAU,CACtB,IAA4B;IAE5B,IAAI,CAAC,IAAA,mBAAa,EAAC,IAAI,CA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