@dagger.io/dagger 0.19.6 → 0.19.8
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/src/api/client.gen.d.ts +172 -0
- package/dist/src/api/client.gen.d.ts.map +1 -1
- package/dist/src/api/client.gen.js +285 -0
- package/dist/src/common/errors/EngineSessionConnectParamsParseError.d.ts.map +1 -1
- package/dist/src/common/errors/EngineSessionConnectionTimeoutError.d.ts.map +1 -1
- package/dist/src/module/decorators.d.ts +5 -0
- package/dist/src/module/decorators.d.ts.map +1 -1
- package/dist/src/module/decorators.js +5 -0
- package/dist/src/module/entrypoint/register.d.ts.map +1 -1
- package/dist/src/module/entrypoint/register.js +3 -0
- package/dist/src/module/introspector/dagger_module/decorator.d.ts +2 -1
- package/dist/src/module/introspector/dagger_module/decorator.d.ts.map +1 -1
- package/dist/src/module/introspector/dagger_module/decorator.js +2 -1
- package/dist/src/module/introspector/dagger_module/function.d.ts +1 -0
- package/dist/src/module/introspector/dagger_module/function.d.ts.map +1 -1
- package/dist/src/module/introspector/dagger_module/function.js +6 -1
- package/dist/src/module/introspector/typescript_module/ast.d.ts +1 -0
- package/dist/src/module/introspector/typescript_module/ast.d.ts.map +1 -1
- package/dist/src/module/introspector/typescript_module/ast.js +85 -14
- package/dist/src/module/registry.d.ts +4 -0
- package/dist/src/module/registry.d.ts.map +1 -1
- package/dist/src/module/registry.js +6 -0
- package/dist/src/provisioning/default.d.ts +1 -1
- package/dist/src/provisioning/default.js +1 -1
- package/dist/src/telemetry/init.d.ts.map +1 -1
- package/dist/src/telemetry/init.js +21 -0
- package/dist/src/telemetry/live_processor.d.ts +12 -0
- package/dist/src/telemetry/live_processor.d.ts.map +1 -0
- package/dist/src/telemetry/live_processor.js +13 -0
- package/package.json +20 -19
|
@@ -724,6 +724,20 @@ export class Binding extends BaseClient {
|
|
|
724
724
|
const ctx = this._ctx.select("asChangeset");
|
|
725
725
|
return new Changeset(ctx);
|
|
726
726
|
};
|
|
727
|
+
/**
|
|
728
|
+
* Retrieve the binding value, as type Check
|
|
729
|
+
*/
|
|
730
|
+
asCheck = () => {
|
|
731
|
+
const ctx = this._ctx.select("asCheck");
|
|
732
|
+
return new Check(ctx);
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Retrieve the binding value, as type CheckGroup
|
|
736
|
+
*/
|
|
737
|
+
asCheckGroup = () => {
|
|
738
|
+
const ctx = this._ctx.select("asCheckGroup");
|
|
739
|
+
return new CheckGroup(ctx);
|
|
740
|
+
};
|
|
727
741
|
/**
|
|
728
742
|
* Retrieve the binding value, as type Cloud
|
|
729
743
|
*/
|
|
@@ -1036,6 +1050,166 @@ export class Changeset extends BaseClient {
|
|
|
1036
1050
|
return new Client(ctx.copy()).loadChangesetFromID(response);
|
|
1037
1051
|
};
|
|
1038
1052
|
}
|
|
1053
|
+
export class Check extends BaseClient {
|
|
1054
|
+
_id = undefined;
|
|
1055
|
+
_completed = undefined;
|
|
1056
|
+
_description = undefined;
|
|
1057
|
+
_name = undefined;
|
|
1058
|
+
_passed = undefined;
|
|
1059
|
+
_resultEmoji = undefined;
|
|
1060
|
+
/**
|
|
1061
|
+
* Constructor is used for internal usage only, do not create object from it.
|
|
1062
|
+
*/
|
|
1063
|
+
constructor(ctx, _id, _completed, _description, _name, _passed, _resultEmoji) {
|
|
1064
|
+
super(ctx);
|
|
1065
|
+
this._id = _id;
|
|
1066
|
+
this._completed = _completed;
|
|
1067
|
+
this._description = _description;
|
|
1068
|
+
this._name = _name;
|
|
1069
|
+
this._passed = _passed;
|
|
1070
|
+
this._resultEmoji = _resultEmoji;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* A unique identifier for this Check.
|
|
1074
|
+
*/
|
|
1075
|
+
id = async () => {
|
|
1076
|
+
if (this._id) {
|
|
1077
|
+
return this._id;
|
|
1078
|
+
}
|
|
1079
|
+
const ctx = this._ctx.select("id");
|
|
1080
|
+
const response = await ctx.execute();
|
|
1081
|
+
return response;
|
|
1082
|
+
};
|
|
1083
|
+
/**
|
|
1084
|
+
* Whether the check completed
|
|
1085
|
+
*/
|
|
1086
|
+
completed = async () => {
|
|
1087
|
+
if (this._completed) {
|
|
1088
|
+
return this._completed;
|
|
1089
|
+
}
|
|
1090
|
+
const ctx = this._ctx.select("completed");
|
|
1091
|
+
const response = await ctx.execute();
|
|
1092
|
+
return response;
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* The description of the check
|
|
1096
|
+
*/
|
|
1097
|
+
description = async () => {
|
|
1098
|
+
if (this._description) {
|
|
1099
|
+
return this._description;
|
|
1100
|
+
}
|
|
1101
|
+
const ctx = this._ctx.select("description");
|
|
1102
|
+
const response = await ctx.execute();
|
|
1103
|
+
return response;
|
|
1104
|
+
};
|
|
1105
|
+
/**
|
|
1106
|
+
* Return the fully qualified name of the check
|
|
1107
|
+
*/
|
|
1108
|
+
name = async () => {
|
|
1109
|
+
if (this._name) {
|
|
1110
|
+
return this._name;
|
|
1111
|
+
}
|
|
1112
|
+
const ctx = this._ctx.select("name");
|
|
1113
|
+
const response = await ctx.execute();
|
|
1114
|
+
return response;
|
|
1115
|
+
};
|
|
1116
|
+
/**
|
|
1117
|
+
* Whether the check passed
|
|
1118
|
+
*/
|
|
1119
|
+
passed = async () => {
|
|
1120
|
+
if (this._passed) {
|
|
1121
|
+
return this._passed;
|
|
1122
|
+
}
|
|
1123
|
+
const ctx = this._ctx.select("passed");
|
|
1124
|
+
const response = await ctx.execute();
|
|
1125
|
+
return response;
|
|
1126
|
+
};
|
|
1127
|
+
/**
|
|
1128
|
+
* The path of the check within its module
|
|
1129
|
+
*/
|
|
1130
|
+
path = async () => {
|
|
1131
|
+
const ctx = this._ctx.select("path");
|
|
1132
|
+
const response = await ctx.execute();
|
|
1133
|
+
return response;
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* An emoji representing the result of the check
|
|
1137
|
+
*/
|
|
1138
|
+
resultEmoji = async () => {
|
|
1139
|
+
if (this._resultEmoji) {
|
|
1140
|
+
return this._resultEmoji;
|
|
1141
|
+
}
|
|
1142
|
+
const ctx = this._ctx.select("resultEmoji");
|
|
1143
|
+
const response = await ctx.execute();
|
|
1144
|
+
return response;
|
|
1145
|
+
};
|
|
1146
|
+
/**
|
|
1147
|
+
* Execute the check
|
|
1148
|
+
*/
|
|
1149
|
+
run = () => {
|
|
1150
|
+
const ctx = this._ctx.select("run");
|
|
1151
|
+
return new Check(ctx);
|
|
1152
|
+
};
|
|
1153
|
+
/**
|
|
1154
|
+
* Call the provided function with current Check.
|
|
1155
|
+
*
|
|
1156
|
+
* This is useful for reusability and readability by not breaking the calling chain.
|
|
1157
|
+
*/
|
|
1158
|
+
with = (arg) => {
|
|
1159
|
+
return arg(this);
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
export class CheckGroup extends BaseClient {
|
|
1163
|
+
_id = undefined;
|
|
1164
|
+
/**
|
|
1165
|
+
* Constructor is used for internal usage only, do not create object from it.
|
|
1166
|
+
*/
|
|
1167
|
+
constructor(ctx, _id) {
|
|
1168
|
+
super(ctx);
|
|
1169
|
+
this._id = _id;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* A unique identifier for this CheckGroup.
|
|
1173
|
+
*/
|
|
1174
|
+
id = async () => {
|
|
1175
|
+
if (this._id) {
|
|
1176
|
+
return this._id;
|
|
1177
|
+
}
|
|
1178
|
+
const ctx = this._ctx.select("id");
|
|
1179
|
+
const response = await ctx.execute();
|
|
1180
|
+
return response;
|
|
1181
|
+
};
|
|
1182
|
+
/**
|
|
1183
|
+
* Return a list of individual checks and their details
|
|
1184
|
+
*/
|
|
1185
|
+
list = async () => {
|
|
1186
|
+
const ctx = this._ctx.select("list").select("id");
|
|
1187
|
+
const response = await ctx.execute();
|
|
1188
|
+
return response.map((r) => new Client(ctx.copy()).loadCheckFromID(r.id));
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* Generate a markdown report
|
|
1192
|
+
*/
|
|
1193
|
+
report = () => {
|
|
1194
|
+
const ctx = this._ctx.select("report");
|
|
1195
|
+
return new File(ctx);
|
|
1196
|
+
};
|
|
1197
|
+
/**
|
|
1198
|
+
* Execute all selected checks
|
|
1199
|
+
*/
|
|
1200
|
+
run = () => {
|
|
1201
|
+
const ctx = this._ctx.select("run");
|
|
1202
|
+
return new CheckGroup(ctx);
|
|
1203
|
+
};
|
|
1204
|
+
/**
|
|
1205
|
+
* Call the provided function with current CheckGroup.
|
|
1206
|
+
*
|
|
1207
|
+
* This is useful for reusability and readability by not breaking the calling chain.
|
|
1208
|
+
*/
|
|
1209
|
+
with = (arg) => {
|
|
1210
|
+
return arg(this);
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1039
1213
|
/**
|
|
1040
1214
|
* Dagger Cloud configuration and state
|
|
1041
1215
|
*/
|
|
@@ -1623,6 +1797,14 @@ export class Container extends BaseClient {
|
|
|
1623
1797
|
const ctx = this._ctx.select("withEntrypoint", { args, ...opts });
|
|
1624
1798
|
return new Container(ctx);
|
|
1625
1799
|
};
|
|
1800
|
+
/**
|
|
1801
|
+
* Export environment variables from an env-file to the container.
|
|
1802
|
+
* @param source Identifier of the envfile
|
|
1803
|
+
*/
|
|
1804
|
+
withEnvFileVariables = (source) => {
|
|
1805
|
+
const ctx = this._ctx.select("withEnvFileVariables", { source });
|
|
1806
|
+
return new Container(ctx);
|
|
1807
|
+
};
|
|
1626
1808
|
/**
|
|
1627
1809
|
* Set a new environment variable in the container.
|
|
1628
1810
|
* @param name Name of the environment variable (e.g., "HOST").
|
|
@@ -2113,6 +2295,21 @@ export class CurrentModule extends BaseClient {
|
|
|
2113
2295
|
const response = await ctx.execute();
|
|
2114
2296
|
return response;
|
|
2115
2297
|
};
|
|
2298
|
+
/**
|
|
2299
|
+
* The dependencies of the module.
|
|
2300
|
+
*/
|
|
2301
|
+
dependencies = async () => {
|
|
2302
|
+
const ctx = this._ctx.select("dependencies").select("id");
|
|
2303
|
+
const response = await ctx.execute();
|
|
2304
|
+
return response.map((r) => new Client(ctx.copy()).loadModuleFromID(r.id));
|
|
2305
|
+
};
|
|
2306
|
+
/**
|
|
2307
|
+
* The generated files and directories made on top of the module source's context directory.
|
|
2308
|
+
*/
|
|
2309
|
+
generatedContextDirectory = () => {
|
|
2310
|
+
const ctx = this._ctx.select("generatedContextDirectory");
|
|
2311
|
+
return new Directory(ctx);
|
|
2312
|
+
};
|
|
2116
2313
|
/**
|
|
2117
2314
|
* The name of the module being executed in
|
|
2118
2315
|
*/
|
|
@@ -3144,6 +3341,48 @@ export class Env extends BaseClient {
|
|
|
3144
3341
|
const ctx = this._ctx.select("withChangesetOutput", { name, description });
|
|
3145
3342
|
return new Env(ctx);
|
|
3146
3343
|
};
|
|
3344
|
+
/**
|
|
3345
|
+
* Create or update a binding of type CheckGroup in the environment
|
|
3346
|
+
* @param name The name of the binding
|
|
3347
|
+
* @param value The CheckGroup value to assign to the binding
|
|
3348
|
+
* @param description The purpose of the input
|
|
3349
|
+
*/
|
|
3350
|
+
withCheckGroupInput = (name, value, description) => {
|
|
3351
|
+
const ctx = this._ctx.select("withCheckGroupInput", {
|
|
3352
|
+
name,
|
|
3353
|
+
value,
|
|
3354
|
+
description,
|
|
3355
|
+
});
|
|
3356
|
+
return new Env(ctx);
|
|
3357
|
+
};
|
|
3358
|
+
/**
|
|
3359
|
+
* Declare a desired CheckGroup output to be assigned in the environment
|
|
3360
|
+
* @param name The name of the binding
|
|
3361
|
+
* @param description A description of the desired value of the binding
|
|
3362
|
+
*/
|
|
3363
|
+
withCheckGroupOutput = (name, description) => {
|
|
3364
|
+
const ctx = this._ctx.select("withCheckGroupOutput", { name, description });
|
|
3365
|
+
return new Env(ctx);
|
|
3366
|
+
};
|
|
3367
|
+
/**
|
|
3368
|
+
* Create or update a binding of type Check in the environment
|
|
3369
|
+
* @param name The name of the binding
|
|
3370
|
+
* @param value The Check value to assign to the binding
|
|
3371
|
+
* @param description The purpose of the input
|
|
3372
|
+
*/
|
|
3373
|
+
withCheckInput = (name, value, description) => {
|
|
3374
|
+
const ctx = this._ctx.select("withCheckInput", { name, value, description });
|
|
3375
|
+
return new Env(ctx);
|
|
3376
|
+
};
|
|
3377
|
+
/**
|
|
3378
|
+
* Declare a desired Check output to be assigned in the environment
|
|
3379
|
+
* @param name The name of the binding
|
|
3380
|
+
* @param description A description of the desired value of the binding
|
|
3381
|
+
*/
|
|
3382
|
+
withCheckOutput = (name, description) => {
|
|
3383
|
+
const ctx = this._ctx.select("withCheckOutput", { name, description });
|
|
3384
|
+
return new Env(ctx);
|
|
3385
|
+
};
|
|
3147
3386
|
/**
|
|
3148
3387
|
* Create or update a binding of type Cloud in the environment
|
|
3149
3388
|
* @param name The name of the binding
|
|
@@ -3989,6 +4228,13 @@ export class File extends BaseClient {
|
|
|
3989
4228
|
const ctx = this._ctx.select("asEnvFile", { ...opts });
|
|
3990
4229
|
return new EnvFile(ctx);
|
|
3991
4230
|
};
|
|
4231
|
+
/**
|
|
4232
|
+
* Parse the file contents as JSON.
|
|
4233
|
+
*/
|
|
4234
|
+
asJSON = () => {
|
|
4235
|
+
const ctx = this._ctx.select("asJSON");
|
|
4236
|
+
return new JSONValue(ctx);
|
|
4237
|
+
};
|
|
3992
4238
|
/**
|
|
3993
4239
|
* Change the owner of the file recursively.
|
|
3994
4240
|
* @param owner A user:group to set for the file.
|
|
@@ -4255,6 +4501,13 @@ export class Function_ extends BaseClient {
|
|
|
4255
4501
|
});
|
|
4256
4502
|
return new Function_(ctx);
|
|
4257
4503
|
};
|
|
4504
|
+
/**
|
|
4505
|
+
* Returns the function with a flag indicating it's a check.
|
|
4506
|
+
*/
|
|
4507
|
+
withCheck = () => {
|
|
4508
|
+
const ctx = this._ctx.select("withCheck");
|
|
4509
|
+
return new Function_(ctx);
|
|
4510
|
+
};
|
|
4258
4511
|
/**
|
|
4259
4512
|
* Returns the function with the provided deprecation reason.
|
|
4260
4513
|
* @param opts.reason Reason or migration path describing the deprecation.
|
|
@@ -5625,6 +5878,24 @@ export class Module_ extends BaseClient {
|
|
|
5625
5878
|
const response = await ctx.execute();
|
|
5626
5879
|
return response;
|
|
5627
5880
|
};
|
|
5881
|
+
/**
|
|
5882
|
+
* Return the check defined by the module with the given name. Must match to exactly one check.
|
|
5883
|
+
* @param name The name of the check to retrieve
|
|
5884
|
+
* @experimental
|
|
5885
|
+
*/
|
|
5886
|
+
check = (name) => {
|
|
5887
|
+
const ctx = this._ctx.select("check", { name });
|
|
5888
|
+
return new Check(ctx);
|
|
5889
|
+
};
|
|
5890
|
+
/**
|
|
5891
|
+
* Return all checks defined by the module
|
|
5892
|
+
* @param opts.include Only include checks matching the specified patterns
|
|
5893
|
+
* @experimental
|
|
5894
|
+
*/
|
|
5895
|
+
checks = (opts) => {
|
|
5896
|
+
const ctx = this._ctx.select("checks", { ...opts });
|
|
5897
|
+
return new CheckGroup(ctx);
|
|
5898
|
+
};
|
|
5628
5899
|
/**
|
|
5629
5900
|
* The dependencies of the module.
|
|
5630
5901
|
*/
|
|
@@ -6775,6 +7046,20 @@ export class Client extends BaseClient {
|
|
|
6775
7046
|
const ctx = this._ctx.select("loadChangesetFromID", { id });
|
|
6776
7047
|
return new Changeset(ctx);
|
|
6777
7048
|
};
|
|
7049
|
+
/**
|
|
7050
|
+
* Load a Check from its ID.
|
|
7051
|
+
*/
|
|
7052
|
+
loadCheckFromID = (id) => {
|
|
7053
|
+
const ctx = this._ctx.select("loadCheckFromID", { id });
|
|
7054
|
+
return new Check(ctx);
|
|
7055
|
+
};
|
|
7056
|
+
/**
|
|
7057
|
+
* Load a CheckGroup from its ID.
|
|
7058
|
+
*/
|
|
7059
|
+
loadCheckGroupFromID = (id) => {
|
|
7060
|
+
const ctx = this._ctx.select("loadCheckGroupFromID", { id });
|
|
7061
|
+
return new CheckGroup(ctx);
|
|
7062
|
+
};
|
|
6778
7063
|
/**
|
|
6779
7064
|
* Load a Cloud from its ID.
|
|
6780
7065
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineSessionConnectParamsParseError.d.ts","sourceRoot":"","sources":["../../../../src/common/errors/EngineSessionConnectParamsParseError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3E,UAAU,
|
|
1
|
+
{"version":3,"file":"EngineSessionConnectParamsParseError.d.ts","sourceRoot":"","sources":["../../../../src/common/errors/EngineSessionConnectParamsParseError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3E,UAAU,2CAA4C,SAAQ,qBAAqB;IACjF,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,cAAc;IACtE,IAAI,yCAAmD;IACvD,IAAI,SAAmD;IAEvD;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,2CAA2C;CAKvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineSessionConnectionTimeoutError.d.ts","sourceRoot":"","sources":["../../../../src/common/errors/EngineSessionConnectionTimeoutError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3E,UAAU,
|
|
1
|
+
{"version":3,"file":"EngineSessionConnectionTimeoutError.d.ts","sourceRoot":"","sources":["../../../../src/common/errors/EngineSessionConnectionTimeoutError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3E,UAAU,0CAA2C,SAAQ,qBAAqB;IAChF,eAAe,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,cAAc;IACrE,IAAI,wCAAkD;IACtD,IAAI,SAAkD;IAEtD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IAEvB;;OAEG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,0CAA0C;CAKtD"}
|
|
@@ -11,6 +11,11 @@ export declare const object: () => (<T extends import("./registry.js").Class>(co
|
|
|
11
11
|
* @param alias The alias to use for the field when exposed on the API.
|
|
12
12
|
*/
|
|
13
13
|
export declare const func: (alias?: string) => ((target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void);
|
|
14
|
+
/**
|
|
15
|
+
* The definition of @check decorator that marks a function as a check.
|
|
16
|
+
* Checks are functions that return void/error to indicate pass/fail.
|
|
17
|
+
*/
|
|
18
|
+
export declare const check: () => ((target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void);
|
|
14
19
|
/**
|
|
15
20
|
* The definition of @field decorator that should be on top of any
|
|
16
21
|
* class' property that must be exposed to the Dagger API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/module/decorators.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,MAAM,wEAAkB,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/module/decorators.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,MAAM,wEAAkB,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,gFA0CggD,CAAC,8BA1Cj/C,CAAA;AAEjC;;;GAGG;AACH,eAAO,MAAM,KAAK,kEAoCk1D,CAAC,8BApCl0D,CAAA;AAEnC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,qEAAiB,CAAA;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,wEAAoB,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,yIAAoB,CAAA"}
|
|
@@ -15,6 +15,11 @@ export const object = registry.object;
|
|
|
15
15
|
* @param alias The alias to use for the field when exposed on the API.
|
|
16
16
|
*/
|
|
17
17
|
export const func = registry.func;
|
|
18
|
+
/**
|
|
19
|
+
* The definition of @check decorator that marks a function as a check.
|
|
20
|
+
* Checks are functions that return void/error to indicate pass/fail.
|
|
21
|
+
*/
|
|
22
|
+
export const check = registry.check;
|
|
18
23
|
/**
|
|
19
24
|
* The definition of @field decorator that should be on top of any
|
|
20
25
|
* class' property that must be exposed to the Dagger API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAET,QAAQ,EACR,OAAO,EAQR,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,eAAe,IAAI,SAAS,EAC5B,iBAAiB,IAAI,WAAW,EAChC,cAAc,IAAI,MAAM,EACxB,YAAY,EAEZ,cAAc,EACf,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oDAAoD,CAAA;AAU5F,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAEjD;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;IAyF9B;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS;IAInE;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/module/entrypoint/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAET,QAAQ,EACR,OAAO,EAQR,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,eAAe,IAAI,SAAS,EAC5B,iBAAiB,IAAI,WAAW,EAChC,cAAc,IAAI,MAAM,EACxB,YAAY,EAEZ,cAAc,EACf,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oDAAoD,CAAA;AAU5F,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAEjD;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;IAyF9B;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS;IAInE;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;IAoC7D;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,GAAG,EAAE,SAAS,KAAK,SAAS;IAmDtD;;;;;;;OAOG;IACH,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;CA4BjE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export type DaggerDecorators = "object" | "func" | "argument" | "enumType" | "field";
|
|
1
|
+
export type DaggerDecorators = "object" | "func" | "check" | "argument" | "enumType" | "field";
|
|
2
2
|
export declare const OBJECT_DECORATOR: DaggerDecorators;
|
|
3
3
|
export declare const FUNCTION_DECORATOR: DaggerDecorators;
|
|
4
|
+
export declare const CHECK_DECORATOR: DaggerDecorators;
|
|
4
5
|
export declare const FIELD_DECORATOR: DaggerDecorators;
|
|
5
6
|
export declare const ARGUMENT_DECORATOR: DaggerDecorators;
|
|
6
7
|
export declare const ENUM_DECORATOR: DaggerDecorators;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/decorator.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,UAAU,GACV,OAAO,CAAA;AAEX,eAAO,MAAM,gBAAgB,EAAkB,gBAAgB,CAAA;AAC/D,eAAO,MAAM,kBAAkB,EAAgB,gBAAgB,CAAA;AAC/D,eAAO,MAAM,eAAe,EAAiB,gBAAgB,CAAA;AAC7D,eAAO,MAAM,eAAe,EAAiB,gBAAgB,CAAA;AAC7D,eAAO,MAAM,kBAAkB,EAAoB,gBAAgB,CAAA;AACnE,eAAO,MAAM,cAAc,EAAoB,gBAAgB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { argument, func, object, enumType, field } from "../../decorators.js";
|
|
1
|
+
import { argument, func, object, enumType, field, check, } from "../../decorators.js";
|
|
2
2
|
export const OBJECT_DECORATOR = object.name;
|
|
3
3
|
export const FUNCTION_DECORATOR = func.name;
|
|
4
|
+
export const CHECK_DECORATOR = check.name;
|
|
4
5
|
export const FIELD_DECORATOR = field.name;
|
|
5
6
|
export const ARGUMENT_DECORATOR = argument.name;
|
|
6
7
|
export const ENUM_DECORATOR = enumType.name;
|
|
@@ -19,6 +19,7 @@ export declare class DaggerFunction extends Locatable {
|
|
|
19
19
|
arguments: DaggerArguments;
|
|
20
20
|
alias: string | undefined;
|
|
21
21
|
cache: string | undefined;
|
|
22
|
+
isCheck: boolean;
|
|
22
23
|
private signature;
|
|
23
24
|
private symbol;
|
|
24
25
|
constructor(node: ts.MethodDeclaration, ast: AST);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/dagger_module/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,GAAG,EAGJ,MAAM,+BAA+B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,EAAE,OAAO,CAAQ;IAE/B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAW;gBAGN,IAAI,EAAE,EAAE,CAAC,iBAAiB,EAC1B,GAAG,EAAE,GAAG;IAuC3B,OAAO,CAAC,aAAa;IAWd,YAAY,IAAI,MAAM,EAAE;IAIxB,aAAa,IAAI,MAAM,EAAE;IAoBzB,mBAAmB,CAAC,UAAU,EAAE,UAAU;IAuB1C,MAAM;;;;;;;;CAUd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntrospectionError } from "../../../common/errors/index.js";
|
|
2
2
|
import { AST, isTypeDefResolved, resolveTypeDef, } from "../typescript_module/index.js";
|
|
3
3
|
import { DaggerArgument } from "./argument.js";
|
|
4
|
-
import { FUNCTION_DECORATOR } from "./decorator.js";
|
|
4
|
+
import { CHECK_DECORATOR, FUNCTION_DECORATOR } from "./decorator.js";
|
|
5
5
|
import { Locatable } from "./locatable.js";
|
|
6
6
|
export class DaggerFunction extends Locatable {
|
|
7
7
|
node;
|
|
@@ -14,6 +14,7 @@ export class DaggerFunction extends Locatable {
|
|
|
14
14
|
arguments = {};
|
|
15
15
|
alias;
|
|
16
16
|
cache;
|
|
17
|
+
isCheck = false;
|
|
17
18
|
signature;
|
|
18
19
|
symbol;
|
|
19
20
|
constructor(node, ast) {
|
|
@@ -38,6 +39,10 @@ export class DaggerFunction extends Locatable {
|
|
|
38
39
|
this.cache = functionArguments.cache;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
// Parse @check decorator
|
|
43
|
+
if (this.ast.isNodeDecoratedWith(this.node, CHECK_DECORATOR)) {
|
|
44
|
+
this.isCheck = true;
|
|
45
|
+
}
|
|
41
46
|
for (const parameter of this.node.parameters) {
|
|
42
47
|
this.arguments[parameter.name.getText()] = new DaggerArgument(parameter, this.ast);
|
|
43
48
|
}
|
|
@@ -57,6 +57,7 @@ export declare class AST {
|
|
|
57
57
|
typeToStringType(type: ts.Type): string;
|
|
58
58
|
tsTypeToTypeDef(node: ts.Node, type: ts.Type): TypeDef<TypeDefKind> | undefined;
|
|
59
59
|
private resolveParameterDefaultValueTypeReference;
|
|
60
|
+
private getLiteralValueFromExpression;
|
|
60
61
|
private warnUnresolvedDefaultValue;
|
|
61
62
|
resolveParameterDefaultValue(expression: ts.Expression): any;
|
|
62
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../../src/module/introspector/typescript_module/ast.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAmB,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAE9C,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,eAAe,IAAI;IACpE,IAAI,EAAE,CAAC,CAAA;IACP,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,EAAE,EAAE,CAAC,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,CAAC,UAAU,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qBAAa,GAAG;aAMI,KAAK,EAAE,MAAM,EAAE;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU;IANtB,OAAO,EAAE,EAAE,CAAC,WAAW,CAAA;IAE9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;gBAG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E,CAAC,aAAa,EACtB,eAAe,EAAE,gBAAgB,EACjC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,QAAQ,SAAI,GACX,CAAC,GAAG,SAAS;IA4BT,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYjD,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAY/C,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM;IAMvC,eAAe,CACpB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IA4DnC,OAAO,CAAC,yCAAyC;IAuBjD,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,0BAA0B;IAO3B,4BAA4B,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG;CAgIpE"}
|
|
@@ -304,6 +304,62 @@ export class AST {
|
|
|
304
304
|
return undefined;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
+
// Try to extract literal values (enum members, string/number/boolean/bigint
|
|
308
|
+
// literals) directly from the type checker. Returns undefined if the
|
|
309
|
+
// expression is not a literal.
|
|
310
|
+
getLiteralValueFromExpression(expression) {
|
|
311
|
+
const type = this.checker.getTypeAtLocation(expression);
|
|
312
|
+
if (!type) {
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
const resolveLiteral = (t) => {
|
|
316
|
+
if (t.flags & ts.TypeFlags.BooleanLiteral) {
|
|
317
|
+
const intrinsic = t;
|
|
318
|
+
// Handle boolean value
|
|
319
|
+
switch (intrinsic.intrinsicName) {
|
|
320
|
+
case "true":
|
|
321
|
+
return true;
|
|
322
|
+
case "false":
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (t.flags &
|
|
327
|
+
(ts.TypeFlags.EnumLiteral |
|
|
328
|
+
ts.TypeFlags.StringLiteral |
|
|
329
|
+
ts.TypeFlags.NumberLiteral |
|
|
330
|
+
ts.TypeFlags.BigIntLiteral)) {
|
|
331
|
+
const literal = t;
|
|
332
|
+
if (literal.value !== undefined) {
|
|
333
|
+
return literal.value;
|
|
334
|
+
}
|
|
335
|
+
// Some literals only expose `intrinsicName`. Example:
|
|
336
|
+
// const yes = true; function use(flag: boolean = yes) {}
|
|
337
|
+
// The checker reports `intrinsicName: "true"` without a `value`, so we fallback.
|
|
338
|
+
const intrinsic = literal;
|
|
339
|
+
if (intrinsic.intrinsicName !== undefined) {
|
|
340
|
+
return intrinsic.intrinsicName;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return undefined;
|
|
344
|
+
};
|
|
345
|
+
if (type.isUnion()) {
|
|
346
|
+
// Walk union members to surface the literal. Example:
|
|
347
|
+
// ```ts
|
|
348
|
+
// const defaults = { proto: NetworkProtocol.Udp }
|
|
349
|
+
// function use(proto: NetworkProtocol = defaults.proto) {}
|
|
350
|
+
// ```
|
|
351
|
+
// The checker reports `defaults.proto` as `NetworkProtocol.Tcp | NetworkProtocol.Udp`,
|
|
352
|
+
// so we inspect each subtype to recover the actual default value.
|
|
353
|
+
for (const subtype of type.types) {
|
|
354
|
+
const literal = resolveLiteral(subtype);
|
|
355
|
+
if (literal !== undefined) {
|
|
356
|
+
return literal;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
return resolveLiteral(type);
|
|
362
|
+
}
|
|
307
363
|
warnUnresolvedDefaultValue(expression) {
|
|
308
364
|
console.warn(`default value '${expression.getText()}' at ${AST.getNodePosition(expression)} cannot be resolved, dagger does not support object or function as default value.
|
|
309
365
|
The value will be ignored by the introspection and resolve at the runtime.`);
|
|
@@ -377,22 +433,37 @@ export class AST {
|
|
|
377
433
|
return undefined;
|
|
378
434
|
}
|
|
379
435
|
case ts.SyntaxKind.PropertyAccessExpression: {
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.warnUnresolvedDefaultValue(expression);
|
|
386
|
-
return undefined;
|
|
436
|
+
const propertyAccess = expression;
|
|
437
|
+
// Quick path: TypeScript already computed the literal value.
|
|
438
|
+
const directConstant = this.checker.getConstantValue(propertyAccess);
|
|
439
|
+
if (directConstant !== undefined) {
|
|
440
|
+
return directConstant;
|
|
387
441
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
442
|
+
// Otherwise inspect the enum member backing the property accessor.
|
|
443
|
+
const nameSymbol = this.checker.getSymbolAtLocation(propertyAccess.name);
|
|
444
|
+
if (nameSymbol) {
|
|
445
|
+
const declarations = nameSymbol.declarations ?? [];
|
|
446
|
+
const decls = nameSymbol.valueDeclaration
|
|
447
|
+
? [nameSymbol.valueDeclaration, ...declarations]
|
|
448
|
+
: declarations;
|
|
449
|
+
for (const decl of decls) {
|
|
450
|
+
if (ts.isEnumMember(decl)) {
|
|
451
|
+
const val = this.checker.getConstantValue(decl);
|
|
452
|
+
if (val !== undefined) {
|
|
453
|
+
return val;
|
|
454
|
+
}
|
|
455
|
+
if (decl.initializer) {
|
|
456
|
+
return this.resolveParameterDefaultValue(decl.initializer);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
394
460
|
}
|
|
395
|
-
//
|
|
461
|
+
// Fall back to literal type information if available.
|
|
462
|
+
const literal = this.getLiteralValueFromExpression(propertyAccess);
|
|
463
|
+
if (literal !== undefined) {
|
|
464
|
+
return literal;
|
|
465
|
+
}
|
|
466
|
+
// Warn the user if the default value cannot be resolved.
|
|
396
467
|
this.warnUnresolvedDefaultValue(expression);
|
|
397
468
|
return undefined;
|
|
398
469
|
}
|
|
@@ -77,6 +77,10 @@ export declare class Registry {
|
|
|
77
77
|
* class' method that must be exposed to the Dagger API.
|
|
78
78
|
*/
|
|
79
79
|
func: (alias?: string) => ((target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void);
|
|
80
|
+
/**
|
|
81
|
+
* The definition of @check decorator that marks a function as a check.
|
|
82
|
+
*/
|
|
83
|
+
check: () => ((target: object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => void);
|
|
80
84
|
argument: (opts?: ArgumentOptions) => ((target: object, propertyKey: string | undefined, parameterIndex: number) => void);
|
|
81
85
|
/**
|
|
82
86
|
* Build a class that is part of the module itself so you can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/module/registry.ts"],"names":[],"mappings":"AAIA,OAAO,kBAAkB,CAAA;AAIzB,MAAM,MAAM,KAAK,GAAG;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;CAAE,CAAA;AAEjD,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAE/C,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAU1C,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;IACH,MAAM,QAAO,CAAC,CAAC,CAAC,SAAS,KAAK,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAMpD;IAED;;;;;OAKG;IACH,QAAQ,QAAO,CAAC,CAAC,CAA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UG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,GAAG,CAAC;CAiChB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAiB,CAAA"}
|
|
@@ -59,6 +59,12 @@ export class Registry {
|
|
|
59
59
|
func = (alias) => {
|
|
60
60
|
return (target, propertyKey, descriptor) => { };
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The definition of @check decorator that marks a function as a check.
|
|
64
|
+
*/
|
|
65
|
+
check = () => {
|
|
66
|
+
return (target, propertyKey, descriptor) => { };
|
|
67
|
+
};
|
|
62
68
|
argument = (opts) => {
|
|
63
69
|
return (target, propertyKey, parameterIndex) => { };
|
|
64
70
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.19.
|
|
1
|
+
export declare const CLI_VERSION = "0.19.8";
|
|
2
2
|
//# sourceMappingURL=default.d.ts.map
|