@dagger.io/dagger 0.11.9 → 0.12.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/api/client.gen.d.ts +387 -69
- package/dist/api/client.gen.d.ts.map +1 -1
- package/dist/api/client.gen.js +804 -96
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +1 -2
- package/dist/entrypoint/invoke.d.ts.map +1 -1
- package/dist/entrypoint/invoke.js +7 -3
- package/dist/entrypoint/load.d.ts +3 -2
- package/dist/entrypoint/load.d.ts.map +1 -1
- package/dist/entrypoint/load.js +9 -1
- package/dist/entrypoint/register.d.ts.map +1 -1
- package/dist/entrypoint/register.js +40 -10
- package/dist/introspector/decorators/decorators.d.ts +5 -1
- package/dist/introspector/decorators/decorators.d.ts.map +1 -1
- package/dist/introspector/decorators/decorators.js +4 -0
- package/dist/introspector/registry/registry.d.ts +8 -2
- package/dist/introspector/registry/registry.d.ts.map +1 -1
- package/dist/introspector/registry/registry.js +11 -1
- package/dist/introspector/scanner/abtractions/argument.d.ts +23 -2
- package/dist/introspector/scanner/abtractions/argument.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/argument.js +71 -38
- package/dist/introspector/scanner/abtractions/constructor.d.ts +3 -2
- package/dist/introspector/scanner/abtractions/constructor.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/constructor.js +17 -19
- package/dist/introspector/scanner/abtractions/enum.d.ts +33 -0
- package/dist/introspector/scanner/abtractions/enum.d.ts.map +1 -0
- package/dist/introspector/scanner/abtractions/enum.js +73 -0
- package/dist/introspector/scanner/abtractions/enumValue.d.ts +24 -0
- package/dist/introspector/scanner/abtractions/enumValue.d.ts.map +1 -0
- package/dist/introspector/scanner/abtractions/enumValue.js +51 -0
- package/dist/introspector/scanner/abtractions/method.d.ts +19 -3
- package/dist/introspector/scanner/abtractions/method.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/method.js +61 -33
- package/dist/introspector/scanner/abtractions/module.d.ts +12 -4
- package/dist/introspector/scanner/abtractions/module.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/module.js +58 -14
- package/dist/introspector/scanner/abtractions/object.d.ts +17 -2
- package/dist/introspector/scanner/abtractions/object.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/object.js +57 -33
- package/dist/introspector/scanner/abtractions/property.d.ts +11 -2
- package/dist/introspector/scanner/abtractions/property.d.ts.map +1 -1
- package/dist/introspector/scanner/abtractions/property.js +49 -30
- package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts +8 -0
- package/dist/introspector/scanner/abtractions/typeToTypedef.d.ts.map +1 -0
- package/dist/introspector/scanner/abtractions/typeToTypedef.js +76 -0
- package/dist/introspector/scanner/scan.d.ts +0 -12
- package/dist/introspector/scanner/scan.d.ts.map +1 -1
- package/dist/introspector/scanner/typeDefs.d.ts +8 -53
- package/dist/introspector/scanner/typeDefs.d.ts.map +1 -1
- package/dist/introspector/scanner/utils.d.ts +1 -1
- package/dist/introspector/scanner/utils.d.ts.map +1 -1
- package/dist/introspector/scanner/utils.js +15 -7
- package/dist/provisioning/default.d.ts +1 -1
- package/dist/provisioning/default.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { DaggerEnumValues } from "./enumValue.js";
|
|
3
|
+
export declare const ENUM_DECORATOR: string;
|
|
4
|
+
/**
|
|
5
|
+
* Return true if the given class declaration has the decorator @enum() on
|
|
6
|
+
* top of its declaration.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isEnumDecorated(object: ts.ClassDeclaration): boolean;
|
|
9
|
+
export type DaggerEnums = {
|
|
10
|
+
[name: string]: DaggerEnum;
|
|
11
|
+
};
|
|
12
|
+
export declare class DaggerEnum {
|
|
13
|
+
private checker;
|
|
14
|
+
private enumClass;
|
|
15
|
+
private symbol;
|
|
16
|
+
private file;
|
|
17
|
+
private _name;
|
|
18
|
+
private _description;
|
|
19
|
+
private _values;
|
|
20
|
+
constructor(checker: ts.TypeChecker, file: ts.SourceFile, enumClassDeclaration: ts.ClassDeclaration);
|
|
21
|
+
get name(): string;
|
|
22
|
+
get description(): string;
|
|
23
|
+
get values(): DaggerEnumValues;
|
|
24
|
+
toJSON(): {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
values: DaggerEnumValues;
|
|
28
|
+
};
|
|
29
|
+
private loadName;
|
|
30
|
+
private loadDescription;
|
|
31
|
+
private loadEnumValues;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAI3B,OAAO,EAAmB,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAElE,eAAO,MAAM,cAAc,QAAgB,CAAA;AAE3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAUpE;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAA;AAExD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,SAAS,CAAqB;IAEtC,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,IAAI,CAAe;IAE3B,OAAO,CAAC,KAAK,CAAQ;IAErB,OAAO,CAAC,YAAY,CAAQ;IAE5B,OAAO,CAAC,OAAO,CAAkB;gBAG/B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,oBAAoB,EAAE,EAAE,CAAC,gBAAgB;IA+B3C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,MAAM,IAAI,gBAAgB,CAE7B;IAED,MAAM;;;;;IAQN,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,cAAc;CAYvB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
|
|
3
|
+
import { enumType } from "../../decorators/decorators.js";
|
|
4
|
+
import { DaggerEnumValue } from "./enumValue.js";
|
|
5
|
+
export const ENUM_DECORATOR = enumType.name;
|
|
6
|
+
/**
|
|
7
|
+
* Return true if the given class declaration has the decorator @enum() on
|
|
8
|
+
* top of its declaration.
|
|
9
|
+
*/
|
|
10
|
+
export function isEnumDecorated(object) {
|
|
11
|
+
return (ts.getDecorators(object)?.find((d) => {
|
|
12
|
+
if (ts.isCallExpression(d.expression)) {
|
|
13
|
+
return d.expression.expression.getText() === ENUM_DECORATOR;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}) !== undefined);
|
|
17
|
+
}
|
|
18
|
+
export class DaggerEnum {
|
|
19
|
+
checker;
|
|
20
|
+
enumClass;
|
|
21
|
+
symbol;
|
|
22
|
+
file;
|
|
23
|
+
_name;
|
|
24
|
+
_description;
|
|
25
|
+
_values;
|
|
26
|
+
constructor(checker, file, enumClassDeclaration) {
|
|
27
|
+
this.checker = checker;
|
|
28
|
+
this.enumClass = enumClassDeclaration;
|
|
29
|
+
this.file = file;
|
|
30
|
+
if (!enumClassDeclaration.name) {
|
|
31
|
+
throw new UnknownDaggerError(`could not introspect enum class: ${enumClassDeclaration}`, {});
|
|
32
|
+
}
|
|
33
|
+
const enumClassSymbol = checker.getSymbolAtLocation(enumClassDeclaration.name);
|
|
34
|
+
if (!enumClassSymbol) {
|
|
35
|
+
throw new UnknownDaggerError(`could not get enum class symbol: ${enumClassDeclaration.name.getText()}`, {});
|
|
36
|
+
}
|
|
37
|
+
this.symbol = enumClassSymbol;
|
|
38
|
+
// Preload definition to optimize the introspection.
|
|
39
|
+
this._name = this.loadName();
|
|
40
|
+
this._description = this.loadDescription();
|
|
41
|
+
this._values = this.loadEnumValues();
|
|
42
|
+
}
|
|
43
|
+
get name() {
|
|
44
|
+
return this._name;
|
|
45
|
+
}
|
|
46
|
+
get description() {
|
|
47
|
+
return this._description;
|
|
48
|
+
}
|
|
49
|
+
get values() {
|
|
50
|
+
return this._values;
|
|
51
|
+
}
|
|
52
|
+
toJSON() {
|
|
53
|
+
return {
|
|
54
|
+
name: this.name,
|
|
55
|
+
description: this.description,
|
|
56
|
+
values: this._values,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
loadName() {
|
|
60
|
+
return this.symbol.getName();
|
|
61
|
+
}
|
|
62
|
+
loadDescription() {
|
|
63
|
+
return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
|
|
64
|
+
}
|
|
65
|
+
loadEnumValues() {
|
|
66
|
+
return this.enumClass.members
|
|
67
|
+
.filter((member) => ts.isPropertyDeclaration(member))
|
|
68
|
+
.reduce((acc, member) => {
|
|
69
|
+
const value = new DaggerEnumValue(this.checker, member);
|
|
70
|
+
return { ...acc, [value.name]: value };
|
|
71
|
+
}, {});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
export type DaggerEnumValues = {
|
|
3
|
+
[name: string]: DaggerEnumValue;
|
|
4
|
+
};
|
|
5
|
+
export declare class DaggerEnumValue {
|
|
6
|
+
private checker;
|
|
7
|
+
private property;
|
|
8
|
+
private symbol;
|
|
9
|
+
private _name;
|
|
10
|
+
private _value;
|
|
11
|
+
private _description;
|
|
12
|
+
constructor(checker: ts.TypeChecker, property: ts.PropertyDeclaration);
|
|
13
|
+
get name(): string;
|
|
14
|
+
get value(): string;
|
|
15
|
+
get description(): string;
|
|
16
|
+
toJSON(): {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
private loadName;
|
|
21
|
+
private loadValue;
|
|
22
|
+
private loadDescription;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=enumValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumValue.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/enumValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAI3B,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;CAAE,CAAA;AAElE,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,QAAQ,CAAwB;IAExC,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,KAAK,CAAQ;IAErB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,YAAY,CAAQ;gBAEhB,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,mBAAmB;IAkBrE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,MAAM;;;;IAON,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,eAAe;CAKxB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
|
|
3
|
+
export class DaggerEnumValue {
|
|
4
|
+
checker;
|
|
5
|
+
property;
|
|
6
|
+
symbol;
|
|
7
|
+
_name;
|
|
8
|
+
_value;
|
|
9
|
+
_description;
|
|
10
|
+
constructor(checker, property) {
|
|
11
|
+
this.checker = checker;
|
|
12
|
+
this.property = property;
|
|
13
|
+
const propertySymbol = checker.getSymbolAtLocation(property.name);
|
|
14
|
+
if (!propertySymbol) {
|
|
15
|
+
throw new UnknownDaggerError(`could not get property symbol: ${property.name.getText()}`, {});
|
|
16
|
+
}
|
|
17
|
+
this.symbol = propertySymbol;
|
|
18
|
+
this._name = this.loadName();
|
|
19
|
+
this._value = this.loadValue();
|
|
20
|
+
this._description = this.loadDescription();
|
|
21
|
+
}
|
|
22
|
+
get name() {
|
|
23
|
+
return this._name;
|
|
24
|
+
}
|
|
25
|
+
get value() {
|
|
26
|
+
return this._value;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return this._description;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
name: this.value,
|
|
34
|
+
description: this.description,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
loadName() {
|
|
38
|
+
return this.symbol.getName();
|
|
39
|
+
}
|
|
40
|
+
// Load the value of the enum value from the property initializer.
|
|
41
|
+
// If the initializer is not set, it will throw an error.
|
|
42
|
+
loadValue() {
|
|
43
|
+
if (!this.property.initializer) {
|
|
44
|
+
throw new Error("Dagger enum value has no value set");
|
|
45
|
+
}
|
|
46
|
+
return JSON.parse(this.property.initializer.getText());
|
|
47
|
+
}
|
|
48
|
+
loadDescription() {
|
|
49
|
+
return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { TypeDefKind } from "../../../api/client.gen.js";
|
|
3
|
-
import {
|
|
3
|
+
import { TypeDef } from "../typeDefs.js";
|
|
4
4
|
import { Arguments } from "./argument.js";
|
|
5
|
+
export declare const METHOD_DECORATOR: string;
|
|
6
|
+
/**
|
|
7
|
+
* Return true if the given method has the decorator @fct() on top
|
|
8
|
+
* of its declaration.
|
|
9
|
+
*
|
|
10
|
+
* @param method The method to check
|
|
11
|
+
*/
|
|
12
|
+
export declare function isMethodDecorated(method: ts.MethodDeclaration): boolean;
|
|
5
13
|
export type Methods = {
|
|
6
14
|
[name: string]: Method;
|
|
7
15
|
};
|
|
@@ -13,10 +21,14 @@ export type Methods = {
|
|
|
13
21
|
*/
|
|
14
22
|
export declare class Method {
|
|
15
23
|
private checker;
|
|
16
|
-
private method;
|
|
17
24
|
private symbol;
|
|
18
25
|
private signature;
|
|
19
26
|
private decorator;
|
|
27
|
+
private _name;
|
|
28
|
+
private _description;
|
|
29
|
+
private _alias;
|
|
30
|
+
private _arguments;
|
|
31
|
+
private _returnType;
|
|
20
32
|
/**
|
|
21
33
|
* Create a new Method instance.
|
|
22
34
|
*
|
|
@@ -38,7 +50,6 @@ export declare class Method {
|
|
|
38
50
|
* Return the type of the return value in a Dagger TypeDef format.
|
|
39
51
|
*/
|
|
40
52
|
get returnType(): TypeDef<TypeDefKind>;
|
|
41
|
-
get typeDef(): FunctionTypedef;
|
|
42
53
|
toJSON(): {
|
|
43
54
|
name: string;
|
|
44
55
|
description: string;
|
|
@@ -47,5 +58,10 @@ export declare class Method {
|
|
|
47
58
|
returnType: TypeDef<TypeDefKind>;
|
|
48
59
|
};
|
|
49
60
|
getArgOrder(): string[];
|
|
61
|
+
private loadName;
|
|
62
|
+
private loadDescription;
|
|
63
|
+
private loadAlias;
|
|
64
|
+
private loadArguments;
|
|
65
|
+
private loadReturnType;
|
|
50
66
|
}
|
|
51
67
|
//# sourceMappingURL=method.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAY,SAAS,EAAE,MAAM,eAAe,CAAA;AAGnD,eAAO,MAAM,gBAAgB,QAAY,CAAA;AAEzC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAUvE;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAEhD;;;;;GAKG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,MAAM,CAAW;IAEzB,OAAO,CAAC,SAAS,CAAc;IAE/B,OAAO,CAAC,SAAS,CAA0B;IAG3C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,WAAW,CAAsB;IAEzC;;;;;;;;OAQG;gBACS,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC,iBAAiB;IAuCjE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAED,MAAM;;;;;;;IAUN,WAAW,IAAI,MAAM,EAAE;IAIvB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,cAAc;CAGvB"}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { UnknownDaggerError } from "../../../common/errors/UnknownDaggerError.js";
|
|
3
|
-
import {
|
|
3
|
+
import { func } from "../../decorators/decorators.js";
|
|
4
4
|
import { Argument } from "./argument.js";
|
|
5
|
-
|
|
5
|
+
import { typeToTypedef } from "./typeToTypedef.js";
|
|
6
|
+
export const METHOD_DECORATOR = func.name;
|
|
7
|
+
/**
|
|
8
|
+
* Return true if the given method has the decorator @fct() on top
|
|
9
|
+
* of its declaration.
|
|
10
|
+
*
|
|
11
|
+
* @param method The method to check
|
|
12
|
+
*/
|
|
13
|
+
export function isMethodDecorated(method) {
|
|
14
|
+
return (ts.getDecorators(method)?.find((d) => {
|
|
15
|
+
if (ts.isCallExpression(d.expression)) {
|
|
16
|
+
return d.expression.expression.getText() === METHOD_DECORATOR;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}) !== undefined);
|
|
20
|
+
}
|
|
6
21
|
/**
|
|
7
22
|
* Method is an abstraction of a function or method.
|
|
8
23
|
*
|
|
@@ -11,10 +26,15 @@ const METHOD_DECORATOR = "func";
|
|
|
11
26
|
*/
|
|
12
27
|
export class Method {
|
|
13
28
|
checker;
|
|
14
|
-
method;
|
|
15
29
|
symbol;
|
|
16
30
|
signature;
|
|
17
31
|
decorator;
|
|
32
|
+
// Preloaded values.
|
|
33
|
+
_name;
|
|
34
|
+
_description;
|
|
35
|
+
_alias;
|
|
36
|
+
_arguments;
|
|
37
|
+
_returnType;
|
|
18
38
|
/**
|
|
19
39
|
* Create a new Method instance.
|
|
20
40
|
*
|
|
@@ -26,7 +46,6 @@ export class Method {
|
|
|
26
46
|
*/
|
|
27
47
|
constructor(checker, method) {
|
|
28
48
|
this.checker = checker;
|
|
29
|
-
this.method = method;
|
|
30
49
|
const methodSymbol = checker.getSymbolAtLocation(method.name);
|
|
31
50
|
if (!methodSymbol) {
|
|
32
51
|
throw new UnknownDaggerError(`could not get method symbol: ${method.name.getText()}`, {});
|
|
@@ -43,51 +62,33 @@ export class Method {
|
|
|
43
62
|
}
|
|
44
63
|
return false;
|
|
45
64
|
});
|
|
65
|
+
// Preload to optimize the introspection.
|
|
66
|
+
this._name = this.loadName();
|
|
67
|
+
this._description = this.loadDescription();
|
|
68
|
+
this._alias = this.loadAlias();
|
|
69
|
+
this._arguments = this.loadArguments();
|
|
70
|
+
this._returnType = this.loadReturnType();
|
|
46
71
|
}
|
|
47
72
|
get name() {
|
|
48
|
-
return this.
|
|
73
|
+
return this._name;
|
|
49
74
|
}
|
|
50
75
|
get description() {
|
|
51
|
-
return
|
|
76
|
+
return this._description;
|
|
52
77
|
}
|
|
53
78
|
/**
|
|
54
79
|
* Return the alias of the method if it has one.
|
|
55
80
|
*/
|
|
56
81
|
get alias() {
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
const expression = this.decorator.expression;
|
|
61
|
-
const aliasArg = expression.arguments[0];
|
|
62
|
-
if (!aliasArg) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
return JSON.parse(aliasArg.getText().replace(/'/g, '"'));
|
|
82
|
+
return this._alias;
|
|
66
83
|
}
|
|
67
84
|
get arguments() {
|
|
68
|
-
return this.
|
|
69
|
-
const argument = new Argument(this.checker, param);
|
|
70
|
-
acc[argument.name] = argument;
|
|
71
|
-
return acc;
|
|
72
|
-
}, {});
|
|
85
|
+
return this._arguments;
|
|
73
86
|
}
|
|
74
87
|
/**
|
|
75
88
|
* Return the type of the return value in a Dagger TypeDef format.
|
|
76
89
|
*/
|
|
77
90
|
get returnType() {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
get typeDef() {
|
|
81
|
-
return {
|
|
82
|
-
name: this.name,
|
|
83
|
-
description: this.description,
|
|
84
|
-
alias: this.alias,
|
|
85
|
-
args: Object.entries(this.arguments).reduce((acc, [name, arg]) => {
|
|
86
|
-
acc[name] = arg.typeDef;
|
|
87
|
-
return acc;
|
|
88
|
-
}, {}),
|
|
89
|
-
returnType: this.returnType,
|
|
90
|
-
};
|
|
91
|
+
return this._returnType;
|
|
91
92
|
}
|
|
92
93
|
toJSON() {
|
|
93
94
|
return {
|
|
@@ -101,4 +102,31 @@ export class Method {
|
|
|
101
102
|
getArgOrder() {
|
|
102
103
|
return Object.keys(this.arguments);
|
|
103
104
|
}
|
|
105
|
+
loadName() {
|
|
106
|
+
return this.symbol.getName();
|
|
107
|
+
}
|
|
108
|
+
loadDescription() {
|
|
109
|
+
return ts.displayPartsToString(this.symbol.getDocumentationComment(this.checker));
|
|
110
|
+
}
|
|
111
|
+
loadAlias() {
|
|
112
|
+
if (!this.decorator) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const expression = this.decorator.expression;
|
|
116
|
+
const aliasArg = expression.arguments[0];
|
|
117
|
+
if (!aliasArg) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return JSON.parse(aliasArg.getText().replace(/'/g, '"'));
|
|
121
|
+
}
|
|
122
|
+
loadArguments() {
|
|
123
|
+
return this.signature.parameters.reduce((acc, param) => {
|
|
124
|
+
const argument = new Argument(this.checker, param);
|
|
125
|
+
acc[argument.name] = argument;
|
|
126
|
+
return acc;
|
|
127
|
+
}, {});
|
|
128
|
+
}
|
|
129
|
+
loadReturnType() {
|
|
130
|
+
return typeToTypedef(this.checker, this.signature.getReturnType());
|
|
131
|
+
}
|
|
104
132
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import {
|
|
2
|
+
import { DaggerEnums } from "./enum.js";
|
|
3
|
+
import { DaggerObjects } from "./object.js";
|
|
3
4
|
export declare class DaggerModule {
|
|
4
5
|
private checker;
|
|
5
6
|
private readonly files;
|
|
6
7
|
name: string;
|
|
8
|
+
private _description;
|
|
9
|
+
private _objects;
|
|
10
|
+
private _enums;
|
|
7
11
|
constructor(checker: ts.TypeChecker, name: string | undefined, files: readonly ts.SourceFile[]);
|
|
8
12
|
get objects(): DaggerObjects;
|
|
13
|
+
get enums(): DaggerEnums;
|
|
9
14
|
get description(): string | undefined;
|
|
10
15
|
toJSON(): {
|
|
11
16
|
name: string;
|
|
12
17
|
description: string | undefined;
|
|
13
|
-
objects:
|
|
14
|
-
|
|
15
|
-
};
|
|
18
|
+
objects: DaggerObjects;
|
|
19
|
+
enums: DaggerEnums;
|
|
16
20
|
};
|
|
21
|
+
private loadObjects;
|
|
22
|
+
private loadEnums;
|
|
23
|
+
private loadDescription;
|
|
24
|
+
private toPascalCase;
|
|
17
25
|
}
|
|
18
26
|
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAc,WAAW,EAAmB,MAAM,WAAW,CAAA;AACpE,OAAO,EAAgB,aAAa,EAAqB,MAAM,aAAa,CAAA;AAE5E,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IAEhC,IAAI,EAAE,MAAM,CAAA;IAGnB,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,MAAM,CAAa;gBAGzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,oBAAK,EACT,KAAK,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE;IAYjC,IAAI,OAAO,IAAI,aAAa,CAE3B;IAED,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,MAAM;;;;;;IASN,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,SAAS;IAgBjB,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,YAAY;CAqBrB"}
|
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import {
|
|
3
|
-
import { DaggerObject } from "./object.js";
|
|
2
|
+
import { DaggerEnum, isEnumDecorated } from "./enum.js";
|
|
3
|
+
import { DaggerObject, isObjectDecorated } from "./object.js";
|
|
4
4
|
export class DaggerModule {
|
|
5
5
|
checker;
|
|
6
6
|
files;
|
|
7
7
|
name;
|
|
8
|
+
// Preloaded values.
|
|
9
|
+
_description;
|
|
10
|
+
_objects;
|
|
11
|
+
_enums;
|
|
8
12
|
constructor(checker, name = "", files) {
|
|
9
13
|
this.checker = checker;
|
|
10
14
|
this.files = files.filter((file) => !file.isDeclarationFile);
|
|
11
|
-
this.name = toPascalCase(name);
|
|
15
|
+
this.name = this.toPascalCase(name);
|
|
16
|
+
// Preload values to optimize introspection.
|
|
17
|
+
this._objects = this.loadObjects();
|
|
18
|
+
this._enums = this.loadEnums();
|
|
19
|
+
this._description = this.loadDescription();
|
|
12
20
|
}
|
|
13
21
|
get objects() {
|
|
22
|
+
return this._objects;
|
|
23
|
+
}
|
|
24
|
+
get enums() {
|
|
25
|
+
return this._enums;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return this._description;
|
|
29
|
+
}
|
|
30
|
+
toJSON() {
|
|
31
|
+
return {
|
|
32
|
+
name: this.name,
|
|
33
|
+
description: this.description,
|
|
34
|
+
objects: this._objects,
|
|
35
|
+
enums: this._enums,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
loadObjects() {
|
|
14
39
|
const objects = {};
|
|
15
40
|
for (const file of this.files) {
|
|
16
41
|
ts.forEachChild(file, (node) => {
|
|
17
|
-
if (ts.isClassDeclaration(node) &&
|
|
42
|
+
if (ts.isClassDeclaration(node) && isObjectDecorated(node)) {
|
|
18
43
|
const object = new DaggerObject(this.checker, file, node);
|
|
19
44
|
objects[object.name] = object;
|
|
20
45
|
}
|
|
@@ -22,7 +47,19 @@ export class DaggerModule {
|
|
|
22
47
|
}
|
|
23
48
|
return objects;
|
|
24
49
|
}
|
|
25
|
-
|
|
50
|
+
loadEnums() {
|
|
51
|
+
const daggerEnums = {};
|
|
52
|
+
for (const file of this.files) {
|
|
53
|
+
ts.forEachChild(file, (node) => {
|
|
54
|
+
if (ts.isClassDeclaration(node) && isEnumDecorated(node)) {
|
|
55
|
+
const daggerEnum = new DaggerEnum(this.checker, file, node);
|
|
56
|
+
daggerEnums[daggerEnum.name] = daggerEnum;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return daggerEnums;
|
|
61
|
+
}
|
|
62
|
+
loadDescription() {
|
|
26
63
|
const mainObject = Object.values(this.objects).find((object) => object.name === this.name);
|
|
27
64
|
if (!mainObject) {
|
|
28
65
|
return undefined;
|
|
@@ -46,14 +83,21 @@ export class DaggerModule {
|
|
|
46
83
|
.map((line) => line.replace("*", "").trim()) // Remove leading * and spaces
|
|
47
84
|
.join("\n");
|
|
48
85
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
toPascalCase(input) {
|
|
87
|
+
const words = input
|
|
88
|
+
.replace(/[^a-zA-Z0-9]/g, " ") // Replace non-alphanumeric characters with spaces
|
|
89
|
+
.split(/\s+/)
|
|
90
|
+
.filter((word) => word.length > 0);
|
|
91
|
+
if (words.length === 0) {
|
|
92
|
+
return ""; // No valid words found
|
|
93
|
+
}
|
|
94
|
+
// It's an edge case when moduleName is already in PascalCase or camelCase
|
|
95
|
+
if (words.length === 1) {
|
|
96
|
+
return words[0].charAt(0).toUpperCase() + words[0].slice(1);
|
|
97
|
+
}
|
|
98
|
+
const pascalCase = words
|
|
99
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
100
|
+
.join("");
|
|
101
|
+
return pascalCase;
|
|
58
102
|
}
|
|
59
103
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { ClassTypeDef } from "../typeDefs.js";
|
|
3
2
|
import { Constructor } from "./constructor.js";
|
|
4
3
|
import { Methods } from "./method.js";
|
|
5
4
|
import { Properties } from "./property.js";
|
|
5
|
+
export declare const OBJECT_DECORATOR: string;
|
|
6
|
+
/**
|
|
7
|
+
* Return true if the given class declaration has the decorator @obj() on
|
|
8
|
+
* top of its declaration.
|
|
9
|
+
* @param object
|
|
10
|
+
*/
|
|
11
|
+
export declare function isObjectDecorated(object: ts.ClassDeclaration): boolean;
|
|
6
12
|
export type DaggerObjects = {
|
|
7
13
|
[name: string]: DaggerObject;
|
|
8
14
|
};
|
|
@@ -11,6 +17,11 @@ export declare class DaggerObject {
|
|
|
11
17
|
private class;
|
|
12
18
|
private symbol;
|
|
13
19
|
file: ts.SourceFile;
|
|
20
|
+
private _name;
|
|
21
|
+
private _description;
|
|
22
|
+
private _classConstructor;
|
|
23
|
+
private _methods;
|
|
24
|
+
private _properties;
|
|
14
25
|
/**
|
|
15
26
|
*
|
|
16
27
|
* @param checker The checker to use to introspect the class.
|
|
@@ -25,7 +36,6 @@ export declare class DaggerObject {
|
|
|
25
36
|
get _constructor(): Constructor | undefined;
|
|
26
37
|
get methods(): Methods;
|
|
27
38
|
get properties(): Properties;
|
|
28
|
-
get typeDef(): ClassTypeDef;
|
|
29
39
|
toJSON(): {
|
|
30
40
|
name: string;
|
|
31
41
|
description: string;
|
|
@@ -33,5 +43,10 @@ export declare class DaggerObject {
|
|
|
33
43
|
methods: Methods;
|
|
34
44
|
properties: Properties;
|
|
35
45
|
};
|
|
46
|
+
private loadName;
|
|
47
|
+
private loadDescription;
|
|
48
|
+
private loadConstructor;
|
|
49
|
+
private loadMethods;
|
|
50
|
+
private loadProperties;
|
|
36
51
|
}
|
|
37
52
|
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../introspector/scanner/abtractions/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAI3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAU,OAAO,EAAqB,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,UAAU,EAAY,MAAM,eAAe,CAAA;AAEpD,eAAO,MAAM,gBAAgB,QAAc,CAAA;AAE3C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAUtE;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAA;AAE5D,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,KAAK,CAAqB;IAElC,OAAO,CAAC,MAAM,CAAW;IAElB,IAAI,EAAE,EAAE,CAAC,UAAU,CAAA;IAG1B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAY;IAE/B;;;;;;;OAOG;gBAED,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,gBAAgB,EAAE,EAAE,CAAC,gBAAgB;IA+BvC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,YAAY,IAAI,WAAW,GAAG,SAAS,CAE1C;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED,MAAM;;;;;;;IAUN,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,cAAc;CAavB"}
|