@somewhere-cloud/cli 0.38.151 → 0.38.153
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/CHANGELOG.md +12 -0
- package/README.md +20 -0
- package/dist/lib/bundle.js +1324 -450
- package/dist/lib/bundle.js.map +3 -3
- package/dist/testing.js +1 -1
- package/dist/types/lib/app-test.d.ts +1 -20
- package/dist/types/lib/client.d.ts +2 -0
- package/dist/types/lib/preview-credential.d.ts +3 -1
- package/dist/types/lib/test-control.d.ts +5 -0
- package/dist/types/lib/test-identities.d.ts +9 -2
- package/dist/types/lib/test-response-capture.d.ts +24 -0
- package/dist/types/lib/test-session.d.ts +43 -0
- package/dist/types/lib/testing-app.d.ts +22 -0
- package/dist/types/lib/testing-jobs.d.ts +20 -0
- package/dist/types/testing.d.ts +10 -35
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -3
- package/src/testing.ts +14 -78
package/dist/lib/bundle.js
CHANGED
|
@@ -3614,7 +3614,7 @@ var require_prompt = __commonJS({
|
|
|
3614
3614
|
var require_text = __commonJS({
|
|
3615
3615
|
"node_modules/prompts/dist/elements/text.js"(exports, module) {
|
|
3616
3616
|
"use strict";
|
|
3617
|
-
function asyncGeneratorStep(gen,
|
|
3617
|
+
function asyncGeneratorStep(gen, resolve27, reject, _next, _throw, key, arg) {
|
|
3618
3618
|
try {
|
|
3619
3619
|
var info2 = gen[key](arg);
|
|
3620
3620
|
var value = info2.value;
|
|
@@ -3623,7 +3623,7 @@ var require_text = __commonJS({
|
|
|
3623
3623
|
return;
|
|
3624
3624
|
}
|
|
3625
3625
|
if (info2.done) {
|
|
3626
|
-
|
|
3626
|
+
resolve27(value);
|
|
3627
3627
|
} else {
|
|
3628
3628
|
Promise.resolve(value).then(_next, _throw);
|
|
3629
3629
|
}
|
|
@@ -3632,14 +3632,14 @@ var require_text = __commonJS({
|
|
|
3632
3632
|
function _asyncToGenerator(fn) {
|
|
3633
3633
|
return function() {
|
|
3634
3634
|
var self = this, args = arguments;
|
|
3635
|
-
return new Promise(function(
|
|
3635
|
+
return new Promise(function(resolve27, reject) {
|
|
3636
3636
|
var gen = fn.apply(self, args);
|
|
3637
3637
|
function _next(value) {
|
|
3638
|
-
asyncGeneratorStep(gen,
|
|
3638
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "next", value);
|
|
3639
3639
|
}
|
|
3640
3640
|
__name(_next, "_next");
|
|
3641
3641
|
function _throw(err) {
|
|
3642
|
-
asyncGeneratorStep(gen,
|
|
3642
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "throw", err);
|
|
3643
3643
|
}
|
|
3644
3644
|
__name(_throw, "_throw");
|
|
3645
3645
|
_next(void 0);
|
|
@@ -4393,7 +4393,7 @@ var require_dateparts = __commonJS({
|
|
|
4393
4393
|
var require_date = __commonJS({
|
|
4394
4394
|
"node_modules/prompts/dist/elements/date.js"(exports, module) {
|
|
4395
4395
|
"use strict";
|
|
4396
|
-
function asyncGeneratorStep(gen,
|
|
4396
|
+
function asyncGeneratorStep(gen, resolve27, reject, _next, _throw, key, arg) {
|
|
4397
4397
|
try {
|
|
4398
4398
|
var info2 = gen[key](arg);
|
|
4399
4399
|
var value = info2.value;
|
|
@@ -4402,7 +4402,7 @@ var require_date = __commonJS({
|
|
|
4402
4402
|
return;
|
|
4403
4403
|
}
|
|
4404
4404
|
if (info2.done) {
|
|
4405
|
-
|
|
4405
|
+
resolve27(value);
|
|
4406
4406
|
} else {
|
|
4407
4407
|
Promise.resolve(value).then(_next, _throw);
|
|
4408
4408
|
}
|
|
@@ -4411,14 +4411,14 @@ var require_date = __commonJS({
|
|
|
4411
4411
|
function _asyncToGenerator(fn) {
|
|
4412
4412
|
return function() {
|
|
4413
4413
|
var self = this, args = arguments;
|
|
4414
|
-
return new Promise(function(
|
|
4414
|
+
return new Promise(function(resolve27, reject) {
|
|
4415
4415
|
var gen = fn.apply(self, args);
|
|
4416
4416
|
function _next(value) {
|
|
4417
|
-
asyncGeneratorStep(gen,
|
|
4417
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "next", value);
|
|
4418
4418
|
}
|
|
4419
4419
|
__name(_next, "_next");
|
|
4420
4420
|
function _throw(err) {
|
|
4421
|
-
asyncGeneratorStep(gen,
|
|
4421
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "throw", err);
|
|
4422
4422
|
}
|
|
4423
4423
|
__name(_throw, "_throw");
|
|
4424
4424
|
_next(void 0);
|
|
@@ -4626,7 +4626,7 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
|
|
|
4626
4626
|
var require_number = __commonJS({
|
|
4627
4627
|
"node_modules/prompts/dist/elements/number.js"(exports, module) {
|
|
4628
4628
|
"use strict";
|
|
4629
|
-
function asyncGeneratorStep(gen,
|
|
4629
|
+
function asyncGeneratorStep(gen, resolve27, reject, _next, _throw, key, arg) {
|
|
4630
4630
|
try {
|
|
4631
4631
|
var info2 = gen[key](arg);
|
|
4632
4632
|
var value = info2.value;
|
|
@@ -4635,7 +4635,7 @@ var require_number = __commonJS({
|
|
|
4635
4635
|
return;
|
|
4636
4636
|
}
|
|
4637
4637
|
if (info2.done) {
|
|
4638
|
-
|
|
4638
|
+
resolve27(value);
|
|
4639
4639
|
} else {
|
|
4640
4640
|
Promise.resolve(value).then(_next, _throw);
|
|
4641
4641
|
}
|
|
@@ -4644,14 +4644,14 @@ var require_number = __commonJS({
|
|
|
4644
4644
|
function _asyncToGenerator(fn) {
|
|
4645
4645
|
return function() {
|
|
4646
4646
|
var self = this, args = arguments;
|
|
4647
|
-
return new Promise(function(
|
|
4647
|
+
return new Promise(function(resolve27, reject) {
|
|
4648
4648
|
var gen = fn.apply(self, args);
|
|
4649
4649
|
function _next(value) {
|
|
4650
|
-
asyncGeneratorStep(gen,
|
|
4650
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "next", value);
|
|
4651
4651
|
}
|
|
4652
4652
|
__name(_next, "_next");
|
|
4653
4653
|
function _throw(err) {
|
|
4654
|
-
asyncGeneratorStep(gen,
|
|
4654
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "throw", err);
|
|
4655
4655
|
}
|
|
4656
4656
|
__name(_throw, "_throw");
|
|
4657
4657
|
_next(void 0);
|
|
@@ -5082,7 +5082,7 @@ Instructions:
|
|
|
5082
5082
|
var require_autocomplete = __commonJS({
|
|
5083
5083
|
"node_modules/prompts/dist/elements/autocomplete.js"(exports, module) {
|
|
5084
5084
|
"use strict";
|
|
5085
|
-
function asyncGeneratorStep(gen,
|
|
5085
|
+
function asyncGeneratorStep(gen, resolve27, reject, _next, _throw, key, arg) {
|
|
5086
5086
|
try {
|
|
5087
5087
|
var info2 = gen[key](arg);
|
|
5088
5088
|
var value = info2.value;
|
|
@@ -5091,7 +5091,7 @@ var require_autocomplete = __commonJS({
|
|
|
5091
5091
|
return;
|
|
5092
5092
|
}
|
|
5093
5093
|
if (info2.done) {
|
|
5094
|
-
|
|
5094
|
+
resolve27(value);
|
|
5095
5095
|
} else {
|
|
5096
5096
|
Promise.resolve(value).then(_next, _throw);
|
|
5097
5097
|
}
|
|
@@ -5100,14 +5100,14 @@ var require_autocomplete = __commonJS({
|
|
|
5100
5100
|
function _asyncToGenerator(fn) {
|
|
5101
5101
|
return function() {
|
|
5102
5102
|
var self = this, args = arguments;
|
|
5103
|
-
return new Promise(function(
|
|
5103
|
+
return new Promise(function(resolve27, reject) {
|
|
5104
5104
|
var gen = fn.apply(self, args);
|
|
5105
5105
|
function _next(value) {
|
|
5106
|
-
asyncGeneratorStep(gen,
|
|
5106
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "next", value);
|
|
5107
5107
|
}
|
|
5108
5108
|
__name(_next, "_next");
|
|
5109
5109
|
function _throw(err) {
|
|
5110
|
-
asyncGeneratorStep(gen,
|
|
5110
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "throw", err);
|
|
5111
5111
|
}
|
|
5112
5112
|
__name(_throw, "_throw");
|
|
5113
5113
|
_next(void 0);
|
|
@@ -5756,7 +5756,7 @@ var require_dist = __commonJS({
|
|
|
5756
5756
|
return arr2;
|
|
5757
5757
|
}
|
|
5758
5758
|
__name(_arrayLikeToArray, "_arrayLikeToArray");
|
|
5759
|
-
function asyncGeneratorStep(gen,
|
|
5759
|
+
function asyncGeneratorStep(gen, resolve27, reject, _next, _throw, key, arg) {
|
|
5760
5760
|
try {
|
|
5761
5761
|
var info2 = gen[key](arg);
|
|
5762
5762
|
var value = info2.value;
|
|
@@ -5765,7 +5765,7 @@ var require_dist = __commonJS({
|
|
|
5765
5765
|
return;
|
|
5766
5766
|
}
|
|
5767
5767
|
if (info2.done) {
|
|
5768
|
-
|
|
5768
|
+
resolve27(value);
|
|
5769
5769
|
} else {
|
|
5770
5770
|
Promise.resolve(value).then(_next, _throw);
|
|
5771
5771
|
}
|
|
@@ -5774,14 +5774,14 @@ var require_dist = __commonJS({
|
|
|
5774
5774
|
function _asyncToGenerator(fn) {
|
|
5775
5775
|
return function() {
|
|
5776
5776
|
var self = this, args = arguments;
|
|
5777
|
-
return new Promise(function(
|
|
5777
|
+
return new Promise(function(resolve27, reject) {
|
|
5778
5778
|
var gen = fn.apply(self, args);
|
|
5779
5779
|
function _next(value) {
|
|
5780
|
-
asyncGeneratorStep(gen,
|
|
5780
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "next", value);
|
|
5781
5781
|
}
|
|
5782
5782
|
__name(_next, "_next");
|
|
5783
5783
|
function _throw(err) {
|
|
5784
|
-
asyncGeneratorStep(gen,
|
|
5784
|
+
asyncGeneratorStep(gen, resolve27, reject, _next, _throw, "throw", err);
|
|
5785
5785
|
}
|
|
5786
5786
|
__name(_throw, "_throw");
|
|
5787
5787
|
_next(void 0);
|
|
@@ -8124,7 +8124,7 @@ var require_prompts3 = __commonJS({
|
|
|
8124
8124
|
import { spawn } from "node:child_process";
|
|
8125
8125
|
function open(url3) {
|
|
8126
8126
|
const [command, args] = process.platform === "darwin" ? ["open", [url3]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url3]] : ["xdg-open", [url3]];
|
|
8127
|
-
return new Promise((
|
|
8127
|
+
return new Promise((resolve27, reject) => {
|
|
8128
8128
|
try {
|
|
8129
8129
|
const child = spawn(command, args, {
|
|
8130
8130
|
stdio: "ignore",
|
|
@@ -8133,7 +8133,7 @@ function open(url3) {
|
|
|
8133
8133
|
child.once("error", reject);
|
|
8134
8134
|
child.once("spawn", () => {
|
|
8135
8135
|
child.unref();
|
|
8136
|
-
|
|
8136
|
+
resolve27();
|
|
8137
8137
|
});
|
|
8138
8138
|
} catch (err) {
|
|
8139
8139
|
reject(err);
|
|
@@ -8916,7 +8916,7 @@ var init_device = __esm({
|
|
|
8916
8916
|
// dist/lib/auth.js
|
|
8917
8917
|
import http from "node:http";
|
|
8918
8918
|
async function browserLogin() {
|
|
8919
|
-
return new Promise((
|
|
8919
|
+
return new Promise((resolve27, reject) => {
|
|
8920
8920
|
const server = http.createServer((req, res) => {
|
|
8921
8921
|
const url3 = new URL(req.url ?? "/", `http://localhost`);
|
|
8922
8922
|
if (url3.pathname === "/callback") {
|
|
@@ -9021,7 +9021,7 @@ async function browserLogin() {
|
|
|
9021
9021
|
<script>setTimeout(() => window.close(), 3000);</script>
|
|
9022
9022
|
</body>
|
|
9023
9023
|
</html>`);
|
|
9024
|
-
|
|
9024
|
+
resolve27({
|
|
9025
9025
|
token,
|
|
9026
9026
|
...refreshToken ? { refresh_token: refreshToken } : {},
|
|
9027
9027
|
...accessExpiresAt ? { access_expires_at: accessExpiresAt } : {},
|
|
@@ -9715,9 +9715,9 @@ var require_timers = __commonJS({
|
|
|
9715
9715
|
* before the specified function or code is executed.
|
|
9716
9716
|
* @param {*} arg
|
|
9717
9717
|
*/
|
|
9718
|
-
constructor(callback,
|
|
9718
|
+
constructor(callback, delay2, arg) {
|
|
9719
9719
|
this._onTimeout = callback;
|
|
9720
|
-
this._idleTimeout =
|
|
9720
|
+
this._idleTimeout = delay2;
|
|
9721
9721
|
this._timerArg = arg;
|
|
9722
9722
|
this.refresh();
|
|
9723
9723
|
}
|
|
@@ -9762,8 +9762,8 @@ var require_timers = __commonJS({
|
|
|
9762
9762
|
* when the timer expires.
|
|
9763
9763
|
* @returns {NodeJS.Timeout|FastTimer}
|
|
9764
9764
|
*/
|
|
9765
|
-
setTimeout(callback,
|
|
9766
|
-
return
|
|
9765
|
+
setTimeout(callback, delay2, arg) {
|
|
9766
|
+
return delay2 <= RESOLUTION_MS ? setTimeout(callback, delay2, arg) : new FastTimer(callback, delay2, arg);
|
|
9767
9767
|
},
|
|
9768
9768
|
/**
|
|
9769
9769
|
* The clearTimeout method cancels an instantiated Timer previously created
|
|
@@ -9789,8 +9789,8 @@ var require_timers = __commonJS({
|
|
|
9789
9789
|
* when the timer expires.
|
|
9790
9790
|
* @returns {FastTimer}
|
|
9791
9791
|
*/
|
|
9792
|
-
setFastTimeout(callback,
|
|
9793
|
-
return new FastTimer(callback,
|
|
9792
|
+
setFastTimeout(callback, delay2, arg) {
|
|
9793
|
+
return new FastTimer(callback, delay2, arg);
|
|
9794
9794
|
},
|
|
9795
9795
|
/**
|
|
9796
9796
|
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
@@ -9816,8 +9816,8 @@ var require_timers = __commonJS({
|
|
|
9816
9816
|
* @deprecated
|
|
9817
9817
|
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
9818
9818
|
*/
|
|
9819
|
-
tick(
|
|
9820
|
-
fastNow +=
|
|
9819
|
+
tick(delay2 = 0) {
|
|
9820
|
+
fastNow += delay2 - RESOLUTION_MS + 1;
|
|
9821
9821
|
onTick();
|
|
9822
9822
|
onTick();
|
|
9823
9823
|
},
|
|
@@ -14789,9 +14789,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
14789
14789
|
}
|
|
14790
14790
|
close(callback) {
|
|
14791
14791
|
if (callback === void 0) {
|
|
14792
|
-
return new Promise((
|
|
14792
|
+
return new Promise((resolve27, reject) => {
|
|
14793
14793
|
this.close((err, data2) => {
|
|
14794
|
-
return err ? reject(err) :
|
|
14794
|
+
return err ? reject(err) : resolve27(data2);
|
|
14795
14795
|
});
|
|
14796
14796
|
});
|
|
14797
14797
|
}
|
|
@@ -14829,9 +14829,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
14829
14829
|
err = null;
|
|
14830
14830
|
}
|
|
14831
14831
|
if (callback === void 0) {
|
|
14832
|
-
return new Promise((
|
|
14832
|
+
return new Promise((resolve27, reject) => {
|
|
14833
14833
|
this.destroy(err, (err2, data2) => {
|
|
14834
|
-
return err2 ? reject(err2) :
|
|
14834
|
+
return err2 ? reject(err2) : resolve27(data2);
|
|
14835
14835
|
});
|
|
14836
14836
|
});
|
|
14837
14837
|
}
|
|
@@ -17832,29 +17832,29 @@ var require_parser_h1 = __commonJS({
|
|
|
17832
17832
|
this.updateBuffers();
|
|
17833
17833
|
}
|
|
17834
17834
|
}
|
|
17835
|
-
setTimeout(
|
|
17836
|
-
if (
|
|
17835
|
+
setTimeout(delay2, type) {
|
|
17836
|
+
if (delay2 !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
|
|
17837
17837
|
if (this.timeout) {
|
|
17838
17838
|
timers.clearTimeout(this.timeout);
|
|
17839
17839
|
this.timeout = null;
|
|
17840
17840
|
}
|
|
17841
|
-
if (
|
|
17841
|
+
if (delay2) {
|
|
17842
17842
|
if (type & USE_FAST_TIMER) {
|
|
17843
17843
|
this.timeout = timers.setFastTimeout(
|
|
17844
17844
|
onParserTimeout,
|
|
17845
|
-
|
|
17845
|
+
delay2,
|
|
17846
17846
|
this.timeoutWeakRef
|
|
17847
17847
|
);
|
|
17848
17848
|
} else {
|
|
17849
17849
|
this.timeout = setTimeout(
|
|
17850
17850
|
onParserTimeout,
|
|
17851
|
-
|
|
17851
|
+
delay2,
|
|
17852
17852
|
this.timeoutWeakRef
|
|
17853
17853
|
);
|
|
17854
17854
|
this.timeout?.unref();
|
|
17855
17855
|
}
|
|
17856
17856
|
}
|
|
17857
|
-
this.timeoutValue =
|
|
17857
|
+
this.timeoutValue = delay2;
|
|
17858
17858
|
} else if (this.timeout?.refresh) {
|
|
17859
17859
|
this.timeout.refresh();
|
|
17860
17860
|
}
|
|
@@ -19440,21 +19440,21 @@ var require_client_h1 = __commonJS({
|
|
|
19440
19440
|
this.connection = "";
|
|
19441
19441
|
this.maxResponseSize = client[kMaxResponseSize];
|
|
19442
19442
|
}
|
|
19443
|
-
setTimeout(
|
|
19444
|
-
if (
|
|
19443
|
+
setTimeout(delay2, type) {
|
|
19444
|
+
if (delay2 !== this.timeoutValue || type & USE_FAST_TIMER ^ this.timeoutType & USE_FAST_TIMER) {
|
|
19445
19445
|
if (this.timeout) {
|
|
19446
19446
|
timers.clearTimeout(this.timeout);
|
|
19447
19447
|
this.timeout = null;
|
|
19448
19448
|
}
|
|
19449
|
-
if (
|
|
19449
|
+
if (delay2) {
|
|
19450
19450
|
if (type & USE_FAST_TIMER) {
|
|
19451
|
-
this.timeout = timers.setFastTimeout(onParserTimeout,
|
|
19451
|
+
this.timeout = timers.setFastTimeout(onParserTimeout, delay2, this.timeoutWeakRef);
|
|
19452
19452
|
} else {
|
|
19453
|
-
this.timeout = setTimeout(onParserTimeout,
|
|
19453
|
+
this.timeout = setTimeout(onParserTimeout, delay2, this.timeoutWeakRef);
|
|
19454
19454
|
this.timeout?.unref();
|
|
19455
19455
|
}
|
|
19456
19456
|
}
|
|
19457
|
-
this.timeoutValue =
|
|
19457
|
+
this.timeoutValue = delay2;
|
|
19458
19458
|
} else if (this.timeout) {
|
|
19459
19459
|
if (this.timeout.refresh) {
|
|
19460
19460
|
this.timeout.refresh();
|
|
@@ -20412,12 +20412,12 @@ upgrade: ${upgrade}\r
|
|
|
20412
20412
|
}
|
|
20413
20413
|
}
|
|
20414
20414
|
__name(onDrain, "onDrain");
|
|
20415
|
-
const waitForDrain = /* @__PURE__ */ __name(() => new Promise((
|
|
20415
|
+
const waitForDrain = /* @__PURE__ */ __name(() => new Promise((resolve27, reject) => {
|
|
20416
20416
|
assert2(callback === null);
|
|
20417
20417
|
if (socket[kError]) {
|
|
20418
20418
|
reject(socket[kError]);
|
|
20419
20419
|
} else {
|
|
20420
|
-
callback =
|
|
20420
|
+
callback = resolve27;
|
|
20421
20421
|
}
|
|
20422
20422
|
}), "waitForDrain");
|
|
20423
20423
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -22025,12 +22025,12 @@ var require_client_h2 = __commonJS({
|
|
|
22025
22025
|
}
|
|
22026
22026
|
}
|
|
22027
22027
|
__name(onDrain, "onDrain");
|
|
22028
|
-
const waitForDrain = /* @__PURE__ */ __name(() => new Promise((
|
|
22028
|
+
const waitForDrain = /* @__PURE__ */ __name(() => new Promise((resolve27, reject) => {
|
|
22029
22029
|
assert2(callback === null);
|
|
22030
22030
|
if (socket[kError]) {
|
|
22031
22031
|
reject(socket[kError]);
|
|
22032
22032
|
} else {
|
|
22033
|
-
callback =
|
|
22033
|
+
callback = resolve27;
|
|
22034
22034
|
}
|
|
22035
22035
|
}), "waitForDrain");
|
|
22036
22036
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -22419,16 +22419,16 @@ var require_client = __commonJS({
|
|
|
22419
22419
|
return this[kNeedDrain] < 2;
|
|
22420
22420
|
}
|
|
22421
22421
|
[kClose]() {
|
|
22422
|
-
return new Promise((
|
|
22422
|
+
return new Promise((resolve27) => {
|
|
22423
22423
|
if (this[kSize]) {
|
|
22424
|
-
this[kClosedResolve] =
|
|
22424
|
+
this[kClosedResolve] = resolve27;
|
|
22425
22425
|
} else {
|
|
22426
|
-
|
|
22426
|
+
resolve27(null);
|
|
22427
22427
|
}
|
|
22428
22428
|
});
|
|
22429
22429
|
}
|
|
22430
22430
|
[kDestroy](err) {
|
|
22431
|
-
return new Promise((
|
|
22431
|
+
return new Promise((resolve27) => {
|
|
22432
22432
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
22433
22433
|
for (let i = 0; i < requests.length; i++) {
|
|
22434
22434
|
const request2 = requests[i];
|
|
@@ -22441,7 +22441,7 @@ var require_client = __commonJS({
|
|
|
22441
22441
|
this[kClosedResolve]();
|
|
22442
22442
|
this[kClosedResolve] = null;
|
|
22443
22443
|
}
|
|
22444
|
-
|
|
22444
|
+
resolve27(null);
|
|
22445
22445
|
}, "callback");
|
|
22446
22446
|
if (this[kHTTPContext]) {
|
|
22447
22447
|
this[kHTTPContext].destroy(err, callback);
|
|
@@ -23054,8 +23054,8 @@ var require_pool_base = __commonJS({
|
|
|
23054
23054
|
if (this[kQueued] === 0) {
|
|
23055
23055
|
return closeClients(this);
|
|
23056
23056
|
} else {
|
|
23057
|
-
return new Promise((
|
|
23058
|
-
this[kClosedResolve] =
|
|
23057
|
+
return new Promise((resolve27) => {
|
|
23058
|
+
this[kClosedResolve] = resolve27;
|
|
23059
23059
|
});
|
|
23060
23060
|
}
|
|
23061
23061
|
}
|
|
@@ -23129,8 +23129,8 @@ var require_pool_base = __commonJS({
|
|
|
23129
23129
|
}
|
|
23130
23130
|
let done = false;
|
|
23131
23131
|
let resolveClosed;
|
|
23132
|
-
const closed = new Promise((
|
|
23133
|
-
resolveClosed =
|
|
23132
|
+
const closed = new Promise((resolve27) => {
|
|
23133
|
+
resolveClosed = resolve27;
|
|
23134
23134
|
});
|
|
23135
23135
|
this[kRetiring].set(client, closed);
|
|
23136
23136
|
client.close(() => {
|
|
@@ -26048,7 +26048,7 @@ var require_readable = __commonJS({
|
|
|
26048
26048
|
if (this._readableState.closeEmitted) {
|
|
26049
26049
|
return Promise.resolve(null);
|
|
26050
26050
|
}
|
|
26051
|
-
return new Promise((
|
|
26051
|
+
return new Promise((resolve27, reject) => {
|
|
26052
26052
|
if (this[kContentLength] && this[kContentLength] > limit || this[kBytesRead] > limit) {
|
|
26053
26053
|
this.destroy(new AbortError());
|
|
26054
26054
|
}
|
|
@@ -26062,11 +26062,11 @@ var require_readable = __commonJS({
|
|
|
26062
26062
|
if (signal.aborted) {
|
|
26063
26063
|
reject(signal.reason ?? new AbortError());
|
|
26064
26064
|
} else {
|
|
26065
|
-
|
|
26065
|
+
resolve27(null);
|
|
26066
26066
|
}
|
|
26067
26067
|
});
|
|
26068
26068
|
} else {
|
|
26069
|
-
this.on("close",
|
|
26069
|
+
this.on("close", resolve27);
|
|
26070
26070
|
}
|
|
26071
26071
|
this.on("error", noop2).on("data", () => {
|
|
26072
26072
|
if (this[kBytesRead] > limit) {
|
|
@@ -26096,7 +26096,7 @@ var require_readable = __commonJS({
|
|
|
26096
26096
|
__name(isUnusable, "isUnusable");
|
|
26097
26097
|
function consume(stream, type) {
|
|
26098
26098
|
assert2(!stream[kConsume]);
|
|
26099
|
-
return new Promise((
|
|
26099
|
+
return new Promise((resolve27, reject) => {
|
|
26100
26100
|
if (isUnusable(stream)) {
|
|
26101
26101
|
const rState = stream._readableState;
|
|
26102
26102
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -26111,7 +26111,7 @@ var require_readable = __commonJS({
|
|
|
26111
26111
|
stream[kConsume] = {
|
|
26112
26112
|
type,
|
|
26113
26113
|
stream,
|
|
26114
|
-
resolve:
|
|
26114
|
+
resolve: resolve27,
|
|
26115
26115
|
reject,
|
|
26116
26116
|
length: 0,
|
|
26117
26117
|
body: []
|
|
@@ -26193,18 +26193,18 @@ var require_readable = __commonJS({
|
|
|
26193
26193
|
}
|
|
26194
26194
|
__name(chunksConcat, "chunksConcat");
|
|
26195
26195
|
function consumeEnd(consume2, encoding) {
|
|
26196
|
-
const { type, body, resolve:
|
|
26196
|
+
const { type, body, resolve: resolve27, stream, length } = consume2;
|
|
26197
26197
|
try {
|
|
26198
26198
|
if (type === "text") {
|
|
26199
|
-
|
|
26199
|
+
resolve27(chunksDecode(body, length, encoding));
|
|
26200
26200
|
} else if (type === "json") {
|
|
26201
|
-
|
|
26201
|
+
resolve27(JSON.parse(chunksDecode(body, length, encoding)));
|
|
26202
26202
|
} else if (type === "arrayBuffer") {
|
|
26203
|
-
|
|
26203
|
+
resolve27(chunksConcat(body, length).buffer);
|
|
26204
26204
|
} else if (type === "blob") {
|
|
26205
|
-
|
|
26205
|
+
resolve27(new Blob(body, { type: stream[kContentType] }));
|
|
26206
26206
|
} else if (type === "bytes") {
|
|
26207
|
-
|
|
26207
|
+
resolve27(chunksConcat(body, length));
|
|
26208
26208
|
}
|
|
26209
26209
|
consumeFinish(consume2);
|
|
26210
26210
|
} catch (err) {
|
|
@@ -26520,9 +26520,9 @@ var require_api_request = __commonJS({
|
|
|
26520
26520
|
};
|
|
26521
26521
|
function request2(opts, callback) {
|
|
26522
26522
|
if (callback === void 0) {
|
|
26523
|
-
return new Promise((
|
|
26523
|
+
return new Promise((resolve27, reject) => {
|
|
26524
26524
|
request2.call(this, opts, (err, data2) => {
|
|
26525
|
-
return err ? reject(err) :
|
|
26525
|
+
return err ? reject(err) : resolve27(data2);
|
|
26526
26526
|
});
|
|
26527
26527
|
});
|
|
26528
26528
|
}
|
|
@@ -26743,9 +26743,9 @@ var require_api_stream = __commonJS({
|
|
|
26743
26743
|
};
|
|
26744
26744
|
function stream(opts, factory, callback) {
|
|
26745
26745
|
if (callback === void 0) {
|
|
26746
|
-
return new Promise((
|
|
26746
|
+
return new Promise((resolve27, reject) => {
|
|
26747
26747
|
stream.call(this, opts, factory, (err, data2) => {
|
|
26748
|
-
return err ? reject(err) :
|
|
26748
|
+
return err ? reject(err) : resolve27(data2);
|
|
26749
26749
|
});
|
|
26750
26750
|
});
|
|
26751
26751
|
}
|
|
@@ -27069,9 +27069,9 @@ var require_api_upgrade = __commonJS({
|
|
|
27069
27069
|
};
|
|
27070
27070
|
function upgrade(opts, callback) {
|
|
27071
27071
|
if (callback === void 0) {
|
|
27072
|
-
return new Promise((
|
|
27072
|
+
return new Promise((resolve27, reject) => {
|
|
27073
27073
|
upgrade.call(this, opts, (err, data2) => {
|
|
27074
|
-
return err ? reject(err) :
|
|
27074
|
+
return err ? reject(err) : resolve27(data2);
|
|
27075
27075
|
});
|
|
27076
27076
|
});
|
|
27077
27077
|
}
|
|
@@ -27173,9 +27173,9 @@ var require_api_connect = __commonJS({
|
|
|
27173
27173
|
};
|
|
27174
27174
|
function connect2(opts, callback) {
|
|
27175
27175
|
if (callback === void 0) {
|
|
27176
|
-
return new Promise((
|
|
27176
|
+
return new Promise((resolve27, reject) => {
|
|
27177
27177
|
connect2.call(this, opts, (err, data2) => {
|
|
27178
|
-
return err ? reject(err) :
|
|
27178
|
+
return err ? reject(err) : resolve27(data2);
|
|
27179
27179
|
});
|
|
27180
27180
|
});
|
|
27181
27181
|
}
|
|
@@ -27573,7 +27573,7 @@ var require_mock_utils = __commonJS({
|
|
|
27573
27573
|
}
|
|
27574
27574
|
__name(mockDispatch, "mockDispatch");
|
|
27575
27575
|
function dispatchMockReply(mockDispatches, mockDispatch2, key, opts, handler, resolvedResponse) {
|
|
27576
|
-
const { data: responseData, delay } = mockDispatch2;
|
|
27576
|
+
const { data: responseData, delay: delay2 } = mockDispatch2;
|
|
27577
27577
|
const response = resolvedResponse ?? responseData;
|
|
27578
27578
|
if (response.error !== null) {
|
|
27579
27579
|
deleteMockDispatch(mockDispatches, key);
|
|
@@ -27665,11 +27665,11 @@ var require_mock_utils = __commonJS({
|
|
|
27665
27665
|
handleReply(dispatches, { ...responseDefaults, ...callbackResult });
|
|
27666
27666
|
return;
|
|
27667
27667
|
}
|
|
27668
|
-
if (typeof
|
|
27668
|
+
if (typeof delay2 === "number" && delay2 > 0) {
|
|
27669
27669
|
timer = setTimeout(() => {
|
|
27670
27670
|
timer = null;
|
|
27671
27671
|
handleReply(dispatches);
|
|
27672
|
-
},
|
|
27672
|
+
}, delay2);
|
|
27673
27673
|
} else {
|
|
27674
27674
|
handleReply(dispatches);
|
|
27675
27675
|
}
|
|
@@ -28731,7 +28731,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
28731
28731
|
"node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
28732
28732
|
"use strict";
|
|
28733
28733
|
var { writeFile: writeFile2, readFile: readFile2, mkdir } = __require("node:fs/promises");
|
|
28734
|
-
var { dirname: dirname16, resolve:
|
|
28734
|
+
var { dirname: dirname16, resolve: resolve27 } = __require("node:path");
|
|
28735
28735
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
28736
28736
|
var { InvalidArgumentError: InvalidArgumentError2, UndiciError } = require_errors();
|
|
28737
28737
|
var { setHeader } = require_util3();
|
|
@@ -28957,7 +28957,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
28957
28957
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
28958
28958
|
}
|
|
28959
28959
|
try {
|
|
28960
|
-
const data2 = await readFile2(
|
|
28960
|
+
const data2 = await readFile2(resolve27(path3), "utf8");
|
|
28961
28961
|
const parsed = JSON.parse(data2);
|
|
28962
28962
|
if (Array.isArray(parsed)) {
|
|
28963
28963
|
this.#snapshots.clear();
|
|
@@ -28986,7 +28986,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
28986
28986
|
if (!path3) {
|
|
28987
28987
|
throw new InvalidArgumentError2("Snapshot path is required");
|
|
28988
28988
|
}
|
|
28989
|
-
const resolvedPath =
|
|
28989
|
+
const resolvedPath = resolve27(path3);
|
|
28990
28990
|
await mkdir(dirname16(resolvedPath), { recursive: true });
|
|
28991
28991
|
const data2 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
28992
28992
|
hash,
|
|
@@ -37489,7 +37489,7 @@ var require_fetch = __commonJS({
|
|
|
37489
37489
|
const hasTrailingQuestionMark = url3.search.length === 0 && url3.href[url3.href.length - url3.hash.length - 1] === "?";
|
|
37490
37490
|
return dispatchWithProtocolPreference(body);
|
|
37491
37491
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
37492
|
-
return new Promise((
|
|
37492
|
+
return new Promise((resolve27, reject) => agent.dispatch(
|
|
37493
37493
|
{
|
|
37494
37494
|
path: hasTrailingQuestionMark ? `${path3}?` : path3,
|
|
37495
37495
|
origin: url3.origin,
|
|
@@ -37577,7 +37577,7 @@ var require_fetch = __commonJS({
|
|
|
37577
37577
|
this.nullBodyStatus = nullBodyStatus.includes(status);
|
|
37578
37578
|
this.body = new Readable3({ read: /* @__PURE__ */ __name(() => controller.resume(), "read") });
|
|
37579
37579
|
const onError = /* @__PURE__ */ __name((err) => this.onResponseError(controller, err), "onError");
|
|
37580
|
-
|
|
37580
|
+
resolve27({
|
|
37581
37581
|
status,
|
|
37582
37582
|
statusText,
|
|
37583
37583
|
headersList,
|
|
@@ -37618,7 +37618,7 @@ var require_fetch = __commonJS({
|
|
|
37618
37618
|
return;
|
|
37619
37619
|
}
|
|
37620
37620
|
if (request2.mode === "websocket" && allowH2 !== false && error3?.code === "UND_ERR_INFO" && error3?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
37621
|
-
|
|
37621
|
+
resolve27(dispatchWithProtocolPreference(body2, false));
|
|
37622
37622
|
return;
|
|
37623
37623
|
}
|
|
37624
37624
|
this.body?.destroy(error3);
|
|
@@ -37637,7 +37637,7 @@ var require_fetch = __commonJS({
|
|
|
37637
37637
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
37638
37638
|
const headersList = new HeadersList();
|
|
37639
37639
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
37640
|
-
|
|
37640
|
+
resolve27({
|
|
37641
37641
|
status,
|
|
37642
37642
|
statusText: STATUS_CODES[status],
|
|
37643
37643
|
headersList,
|
|
@@ -42315,6 +42315,27 @@ var init_http = __esm({
|
|
|
42315
42315
|
}
|
|
42316
42316
|
});
|
|
42317
42317
|
|
|
42318
|
+
// dist/lib/poll-delay.js
|
|
42319
|
+
function interactivePollDelay(attempt) {
|
|
42320
|
+
return [150, 300, 600][attempt] ?? 1e3;
|
|
42321
|
+
}
|
|
42322
|
+
function retryAfterMs(value, now2 = Date.now()) {
|
|
42323
|
+
const header = value?.trim();
|
|
42324
|
+
if (!header)
|
|
42325
|
+
return void 0;
|
|
42326
|
+
if (/^\d+$/.test(header))
|
|
42327
|
+
return Number(header) * 1e3;
|
|
42328
|
+
const date4 = Date.parse(header);
|
|
42329
|
+
return Number.isFinite(date4) ? Math.max(0, date4 - now2) : void 0;
|
|
42330
|
+
}
|
|
42331
|
+
var init_poll_delay = __esm({
|
|
42332
|
+
"dist/lib/poll-delay.js"() {
|
|
42333
|
+
"use strict";
|
|
42334
|
+
__name(interactivePollDelay, "interactivePollDelay");
|
|
42335
|
+
__name(retryAfterMs, "retryAfterMs");
|
|
42336
|
+
}
|
|
42337
|
+
});
|
|
42338
|
+
|
|
42318
42339
|
// dist/lib/client.js
|
|
42319
42340
|
function sandboxHint(url3) {
|
|
42320
42341
|
let host = url3;
|
|
@@ -42361,6 +42382,7 @@ var init_client = __esm({
|
|
|
42361
42382
|
init_repro_packet();
|
|
42362
42383
|
init_http();
|
|
42363
42384
|
init_config();
|
|
42385
|
+
init_poll_delay();
|
|
42364
42386
|
API_BASE_URL = process.env.SOMEWHERE_API_URL?.replace(/\/$/, "") || "https://api.somewhere.cloud/v1";
|
|
42365
42387
|
RUNNER_BASE_URL = process.env.SOMEWHERE_RUNNER_URL?.replace(/\/$/, "") || "https://runner.somewhere.cloud";
|
|
42366
42388
|
DEFAULT_TIMEOUT_MS = 6e4;
|
|
@@ -42549,9 +42571,13 @@ var init_client = __esm({
|
|
|
42549
42571
|
const detail = code ?? cause?.message ?? (err instanceof Error ? err.message : String(err));
|
|
42550
42572
|
throw new CliApiError("NETWORK_ERROR", `Could not reach ${method} ${url3.split("?")[0]} \u2014 ${detail}. No HTTP response was received (this is a connection problem, not a server rejection). Check your network and retry; for large deploys a flaky connection can drop the upload mid-request. ${sandboxHint(url3)}`, 0, void 0, void 0, code && NOT_SENT_CAUSES.has(code) ? { notSent: true } : {});
|
|
42551
42573
|
}
|
|
42574
|
+
const retryAfter = retryAfterMs(res.headers.get("retry-after"));
|
|
42575
|
+
if (retryAfter !== void 0)
|
|
42576
|
+
opts?.onRetryAfter?.(retryAfter);
|
|
42552
42577
|
const meta2 = {
|
|
42553
42578
|
requestId: res.headers.get("x-request-id") ?? void 0,
|
|
42554
|
-
traceId: res.headers.get("x-trace-id") ?? void 0
|
|
42579
|
+
traceId: res.headers.get("x-trace-id") ?? void 0,
|
|
42580
|
+
retryAfterMs: retryAfter
|
|
42555
42581
|
};
|
|
42556
42582
|
let text;
|
|
42557
42583
|
try {
|
|
@@ -42578,7 +42604,17 @@ var init_client = __esm({
|
|
|
42578
42604
|
if (typeof retry === "boolean")
|
|
42579
42605
|
meta2.retry = retry;
|
|
42580
42606
|
if (typeof retry_after_ms === "number" && Number.isFinite(retry_after_ms)) {
|
|
42581
|
-
meta2.retryAfterMs = retry_after_ms;
|
|
42607
|
+
meta2.retryAfterMs = Math.max(retryAfter ?? 0, retry_after_ms);
|
|
42608
|
+
}
|
|
42609
|
+
if (res.status === 503 && error3 === "EXEC_CONTROL_PUBLICATION_PENDING") {
|
|
42610
|
+
const retryAfter2 = res.headers.get("retry-after")?.trim();
|
|
42611
|
+
if (retryAfter2 && /^\d+$/.test(retryAfter2)) {
|
|
42612
|
+
meta2.retryAfterMs = Math.min(Number(retryAfter2) * 1e3, Number.MAX_SAFE_INTEGER);
|
|
42613
|
+
} else if (retryAfter2) {
|
|
42614
|
+
const retryAt = Date.parse(retryAfter2);
|
|
42615
|
+
if (Number.isFinite(retryAt))
|
|
42616
|
+
meta2.retryAfterMs = Math.max(0, retryAt - Date.now());
|
|
42617
|
+
}
|
|
42582
42618
|
}
|
|
42583
42619
|
const agentSignIn = `Run \`${cliInvocation()} login\` and ask the account owner to approve it.`;
|
|
42584
42620
|
const agentMessage = error3 === "PROJECT_AGENT_OPERATION_FORBIDDEN" ? `This app connection cannot use that feature. ${agentSignIn}` : error3 === "PROJECT_AGENT_PROJECT_FORBIDDEN" ? `This app is outside this connection or no longer available. ${agentSignIn}` : void 0;
|
|
@@ -42604,7 +42640,8 @@ var init_client = __esm({
|
|
|
42604
42640
|
method,
|
|
42605
42641
|
headers,
|
|
42606
42642
|
body: reqBody,
|
|
42607
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
42643
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
42644
|
+
...opts?.redirect ? { redirect: opts.redirect } : {}
|
|
42608
42645
|
}, timeoutMs);
|
|
42609
42646
|
} catch (err) {
|
|
42610
42647
|
const cause = err.cause;
|
|
@@ -43521,15 +43558,15 @@ function initInstallSpawnSpec(platform2) {
|
|
|
43521
43558
|
};
|
|
43522
43559
|
}
|
|
43523
43560
|
function runInitInstall({ cwd, quiet }) {
|
|
43524
|
-
return new Promise((
|
|
43561
|
+
return new Promise((resolve27) => {
|
|
43525
43562
|
const spec = initInstallSpawnSpec(process.platform);
|
|
43526
43563
|
const child = spawn2(spec.command, spec.args, {
|
|
43527
43564
|
cwd,
|
|
43528
43565
|
shell: spec.shell,
|
|
43529
43566
|
stdio: quiet ? "ignore" : "inherit"
|
|
43530
43567
|
});
|
|
43531
|
-
child.once("error", () =>
|
|
43532
|
-
child.once("exit", (code, signal) =>
|
|
43568
|
+
child.once("error", () => resolve27(127));
|
|
43569
|
+
child.once("exit", (code, signal) => resolve27(signal ? 1 : code ?? 1));
|
|
43533
43570
|
});
|
|
43534
43571
|
}
|
|
43535
43572
|
async function installInitDependencies(options2, runner2 = runInitInstall) {
|
|
@@ -44149,7 +44186,8 @@ ${AGENT_WORKFLOW}
|
|
|
44149
44186
|
${SKILLS_POINTER}
|
|
44150
44187
|
Without a global CLI, use \`npx @somewhere-cloud/cli deploy\` and \`npx @somewhere-cloud/cli test\`.
|
|
44151
44188
|
|
|
44152
|
-
For
|
|
44189
|
+
For Node or Playwright tests, see [Testing your app](https://somewhere.cloud/docs/test).
|
|
44190
|
+
In a generated starter, run \`npm test\` after its first deploy to verify the signed-in session.
|
|
44153
44191
|
|
|
44154
44192
|
${PORTABILITY_POINTER}
|
|
44155
44193
|
${MCP_POINTER}
|
|
@@ -44159,6 +44197,44 @@ ${PREVIEW_POINTER}
|
|
|
44159
44197
|
}
|
|
44160
44198
|
});
|
|
44161
44199
|
|
|
44200
|
+
// dist/lib/init-test-template.js
|
|
44201
|
+
function starterChecks(options2 = {}) {
|
|
44202
|
+
return options2.privateData ? [{ path: "checks/add-a-note.json", content: JSON.stringify(ADD_A_NOTE, null, 2) + "\n" }] : [];
|
|
44203
|
+
}
|
|
44204
|
+
var ADD_A_NOTE, STARTER_AUTH_TEST;
|
|
44205
|
+
var init_init_test_template = __esm({
|
|
44206
|
+
"dist/lib/init-test-template.js"() {
|
|
44207
|
+
"use strict";
|
|
44208
|
+
ADD_A_NOTE = {
|
|
44209
|
+
actions: [
|
|
44210
|
+
{ fill: "[data-testid=note-title]", value: "Lunch with Ana 42" },
|
|
44211
|
+
{ click: "[data-testid=note-save]" },
|
|
44212
|
+
{ expect: { selector: "[data-testid=note-item]", text: "Lunch with Ana 42" } }
|
|
44213
|
+
],
|
|
44214
|
+
viewports: ["desktop", "mobile"],
|
|
44215
|
+
signed_in: true
|
|
44216
|
+
};
|
|
44217
|
+
__name(starterChecks, "starterChecks");
|
|
44218
|
+
STARTER_AUTH_TEST = {
|
|
44219
|
+
path: "tests/starter.mjs",
|
|
44220
|
+
content: `import assert from 'node:assert/strict';
|
|
44221
|
+
import { openTestApp } from '@somewhere-cloud/cli/testing';
|
|
44222
|
+
|
|
44223
|
+
const app = await openTestApp();
|
|
44224
|
+
try {
|
|
44225
|
+
const [person] = await app.users(1);
|
|
44226
|
+
const response = await person.session.request('/api/auth/me');
|
|
44227
|
+
assert.equal(response.status, 200);
|
|
44228
|
+
assert.equal((await response.json()).user.id, person.id);
|
|
44229
|
+
console.log('The deployed app recognizes the test user.');
|
|
44230
|
+
} finally {
|
|
44231
|
+
await app.cleanup();
|
|
44232
|
+
}
|
|
44233
|
+
`
|
|
44234
|
+
};
|
|
44235
|
+
}
|
|
44236
|
+
});
|
|
44237
|
+
|
|
44162
44238
|
// dist/lib/typecheck-version.js
|
|
44163
44239
|
var TYPECHECK_TYPESCRIPT_VERSION;
|
|
44164
44240
|
var init_typecheck_version = __esm({
|
|
@@ -44287,6 +44363,7 @@ declare module '*.${ext}' {
|
|
|
44287
44363
|
function createGreenTemplate(appName = "somewhere-starter") {
|
|
44288
44364
|
return [
|
|
44289
44365
|
{ path: ".gitignore", content: buildScaffoldGitignore() },
|
|
44366
|
+
STARTER_AUTH_TEST,
|
|
44290
44367
|
{ path: "AGENTS.md", content: INIT_AGENTS_MD },
|
|
44291
44368
|
{ path: "CLAUDE.md", content: INIT_CLAUDE_MD },
|
|
44292
44369
|
{ path: "README.md", content: README },
|
|
@@ -44311,6 +44388,7 @@ var packageJson, TSCONFIG, APP_TYPES, SCHEMA, API, SERVICE, APP, MAIN, STYLES, R
|
|
|
44311
44388
|
var init_init_green_template = __esm({
|
|
44312
44389
|
"dist/lib/init-green-template.js"() {
|
|
44313
44390
|
"use strict";
|
|
44391
|
+
init_init_test_template();
|
|
44314
44392
|
init_version();
|
|
44315
44393
|
init_typecheck_version();
|
|
44316
44394
|
init_scaffold();
|
|
@@ -44325,6 +44403,7 @@ var init_init_green_template = __esm({
|
|
|
44325
44403
|
"somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
|
|
44326
44404
|
"scripts": {
|
|
44327
44405
|
"dev": "npx -y @somewhere-cloud/cli dev",
|
|
44406
|
+
"test": "node tests/starter.mjs",
|
|
44328
44407
|
"typecheck": "npx -y @somewhere-cloud/cli typecheck"
|
|
44329
44408
|
},
|
|
44330
44409
|
"dependencies": {
|
|
@@ -44333,6 +44412,7 @@ var init_init_green_template = __esm({
|
|
|
44333
44412
|
"react-dom": "19.2.7"
|
|
44334
44413
|
},
|
|
44335
44414
|
"devDependencies": {
|
|
44415
|
+
"@somewhere-cloud/cli": "${CLI_VERSION}",
|
|
44336
44416
|
"@types/react": "19.2.2",
|
|
44337
44417
|
"@types/react-dom": "19.2.2",
|
|
44338
44418
|
"typescript": "${TYPECHECK_TYPESCRIPT_VERSION}"
|
|
@@ -46761,27 +46841,6 @@ var init_project_pin = __esm({
|
|
|
46761
46841
|
}
|
|
46762
46842
|
});
|
|
46763
46843
|
|
|
46764
|
-
// dist/lib/init-test-template.js
|
|
46765
|
-
function starterChecks(options2 = {}) {
|
|
46766
|
-
return options2.privateData ? [{ path: "checks/add-a-note.json", content: JSON.stringify(ADD_A_NOTE, null, 2) + "\n" }] : [];
|
|
46767
|
-
}
|
|
46768
|
-
var ADD_A_NOTE;
|
|
46769
|
-
var init_init_test_template = __esm({
|
|
46770
|
-
"dist/lib/init-test-template.js"() {
|
|
46771
|
-
"use strict";
|
|
46772
|
-
ADD_A_NOTE = {
|
|
46773
|
-
actions: [
|
|
46774
|
-
{ fill: "[data-testid=note-title]", value: "Lunch with Ana 42" },
|
|
46775
|
-
{ click: "[data-testid=note-save]" },
|
|
46776
|
-
{ expect: { selector: "[data-testid=note-item]", text: "Lunch with Ana 42" } }
|
|
46777
|
-
],
|
|
46778
|
-
viewports: ["desktop", "mobile"],
|
|
46779
|
-
signed_in: true
|
|
46780
|
-
};
|
|
46781
|
-
__name(starterChecks, "starterChecks");
|
|
46782
|
-
}
|
|
46783
|
-
});
|
|
46784
|
-
|
|
46785
46844
|
// dist/lib/init-ui-kit.js
|
|
46786
46845
|
var TOKENS_CSS, APP_CSS, STYLED_AUTH_CARD, PLAIN_AUTH_CARD, STYLED_VERIFY_EMAIL, STYLED_UI_KIT, PLAIN_UI_KIT;
|
|
46787
46846
|
var init_init_ui_kit = __esm({
|
|
@@ -48553,6 +48612,7 @@ function createFeatureTemplate(selection, options2) {
|
|
|
48553
48612
|
const files = [
|
|
48554
48613
|
...starterChecks({ privateData }),
|
|
48555
48614
|
{ path: ".gitignore", content: buildScaffoldGitignore() },
|
|
48615
|
+
STARTER_AUTH_TEST,
|
|
48556
48616
|
{ path: "AGENTS.md", content: INIT_AGENTS_MD },
|
|
48557
48617
|
{ path: "CLAUDE.md", content: INIT_CLAUDE_MD },
|
|
48558
48618
|
{ path: "README.md", content: readme(selection) },
|
|
@@ -48627,6 +48687,7 @@ var init_init_feature_template = __esm({
|
|
|
48627
48687
|
"somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
|
|
48628
48688
|
"scripts": {
|
|
48629
48689
|
"dev": "npx -y @somewhere-cloud/cli dev",
|
|
48690
|
+
"test": "node tests/starter.mjs",
|
|
48630
48691
|
"typecheck": "npx -y @somewhere-cloud/cli typecheck"
|
|
48631
48692
|
},
|
|
48632
48693
|
"dependencies": {
|
|
@@ -48635,6 +48696,7 @@ var init_init_feature_template = __esm({
|
|
|
48635
48696
|
"react-dom": "19.2.7"
|
|
48636
48697
|
},
|
|
48637
48698
|
"devDependencies": {
|
|
48699
|
+
"@somewhere-cloud/cli": "${CLI_VERSION}",
|
|
48638
48700
|
"@types/react": "19.2.2",
|
|
48639
48701
|
"@types/react-dom": "19.2.2",
|
|
48640
48702
|
"typescript": "${TYPECHECK_TYPESCRIPT_VERSION}"
|
|
@@ -54122,9 +54184,9 @@ function formatError(error3, mapper = (issue2) => issue2.message) {
|
|
|
54122
54184
|
let i = 0;
|
|
54123
54185
|
while (i < fullpath.length) {
|
|
54124
54186
|
const el = fullpath[i];
|
|
54125
|
-
const
|
|
54187
|
+
const terminal2 = i === fullpath.length - 1;
|
|
54126
54188
|
if (el === "_errors") {
|
|
54127
|
-
if (
|
|
54189
|
+
if (terminal2)
|
|
54128
54190
|
curr._errors.push(mapper(issue2));
|
|
54129
54191
|
i++;
|
|
54130
54192
|
continue;
|
|
@@ -54138,7 +54200,7 @@ function formatError(error3, mapper = (issue2) => issue2.message) {
|
|
|
54138
54200
|
});
|
|
54139
54201
|
}
|
|
54140
54202
|
const node2 = curr[el];
|
|
54141
|
-
if (
|
|
54203
|
+
if (terminal2) {
|
|
54142
54204
|
node2._errors.push(mapper(issue2));
|
|
54143
54205
|
}
|
|
54144
54206
|
curr = node2;
|
|
@@ -56582,7 +56644,7 @@ function isRef(value) {
|
|
|
56582
56644
|
function cloneIssues(issues) {
|
|
56583
56645
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
56584
56646
|
}
|
|
56585
|
-
function isRecursive(inst, stack,
|
|
56647
|
+
function isRecursive(inst, stack, resolve27) {
|
|
56586
56648
|
const cached2 = recursive.get(inst);
|
|
56587
56649
|
if (cached2 !== void 0)
|
|
56588
56650
|
return cached2 ? PROVEN : NONE;
|
|
@@ -56592,7 +56654,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56592
56654
|
let result = NONE;
|
|
56593
56655
|
const check = /* @__PURE__ */ __name((child) => {
|
|
56594
56656
|
if (result !== PROVEN && child?._zod) {
|
|
56595
|
-
const answer = isRecursive(child, stack,
|
|
56657
|
+
const answer = isRecursive(child, stack, resolve27);
|
|
56596
56658
|
if (answer > result)
|
|
56597
56659
|
result = answer;
|
|
56598
56660
|
}
|
|
@@ -56603,7 +56665,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56603
56665
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
56604
56666
|
if (spread && !desc.enumerable)
|
|
56605
56667
|
continue;
|
|
56606
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
56668
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve27) : NONE;
|
|
56607
56669
|
if (child > answer)
|
|
56608
56670
|
answer = child;
|
|
56609
56671
|
}
|
|
@@ -56667,7 +56729,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56667
56729
|
break;
|
|
56668
56730
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
56669
56731
|
case "lazy": {
|
|
56670
|
-
const inner = def._cachedInner ?? (
|
|
56732
|
+
const inner = def._cachedInner ?? (resolve27 ? inst._zod.innerType : void 0);
|
|
56671
56733
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
56672
56734
|
break;
|
|
56673
56735
|
}
|
|
@@ -63317,13 +63379,13 @@ var init_streamableHttp = __esm({
|
|
|
63317
63379
|
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
63318
63380
|
return;
|
|
63319
63381
|
}
|
|
63320
|
-
const
|
|
63382
|
+
const delay2 = this._getNextReconnectionDelay(attemptCount);
|
|
63321
63383
|
this._reconnectionTimeout = setTimeout(() => {
|
|
63322
63384
|
this._startOrAuthSse(options2).catch((error3) => {
|
|
63323
63385
|
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error3 instanceof Error ? error3.message : String(error3)}`));
|
|
63324
63386
|
this._scheduleReconnection(options2, attemptCount + 1);
|
|
63325
63387
|
});
|
|
63326
|
-
},
|
|
63388
|
+
}, delay2);
|
|
63327
63389
|
}
|
|
63328
63390
|
_handleSseStream(stream, options2, isReconnectable) {
|
|
63329
63391
|
if (!stream) {
|
|
@@ -64656,7 +64718,7 @@ var init_protocol = __esm({
|
|
|
64656
64718
|
return;
|
|
64657
64719
|
}
|
|
64658
64720
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
64659
|
-
await new Promise((
|
|
64721
|
+
await new Promise((resolve27) => setTimeout(resolve27, pollInterval));
|
|
64660
64722
|
options2?.signal?.throwIfAborted();
|
|
64661
64723
|
}
|
|
64662
64724
|
} catch (error3) {
|
|
@@ -64673,7 +64735,7 @@ var init_protocol = __esm({
|
|
|
64673
64735
|
*/
|
|
64674
64736
|
request(request2, resultSchema, options2) {
|
|
64675
64737
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options2 ?? {};
|
|
64676
|
-
return new Promise((
|
|
64738
|
+
return new Promise((resolve27, reject) => {
|
|
64677
64739
|
const earlyReject = /* @__PURE__ */ __name((error3) => {
|
|
64678
64740
|
reject(error3);
|
|
64679
64741
|
}, "earlyReject");
|
|
@@ -64751,7 +64813,7 @@ var init_protocol = __esm({
|
|
|
64751
64813
|
if (!parseResult.success) {
|
|
64752
64814
|
reject(parseResult.error);
|
|
64753
64815
|
} else {
|
|
64754
|
-
|
|
64816
|
+
resolve27(parseResult.data);
|
|
64755
64817
|
}
|
|
64756
64818
|
} catch (error3) {
|
|
64757
64819
|
reject(error3);
|
|
@@ -65013,12 +65075,12 @@ var init_protocol = __esm({
|
|
|
65013
65075
|
}
|
|
65014
65076
|
} catch {
|
|
65015
65077
|
}
|
|
65016
|
-
return new Promise((
|
|
65078
|
+
return new Promise((resolve27, reject) => {
|
|
65017
65079
|
if (signal.aborted) {
|
|
65018
65080
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
65019
65081
|
return;
|
|
65020
65082
|
}
|
|
65021
|
-
const timeoutId = setTimeout(
|
|
65083
|
+
const timeoutId = setTimeout(resolve27, interval);
|
|
65022
65084
|
signal.addEventListener("abort", () => {
|
|
65023
65085
|
clearTimeout(timeoutId);
|
|
65024
65086
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -68304,7 +68366,7 @@ var require_compile = __commonJS({
|
|
|
68304
68366
|
const schOrFunc = root.refs[ref];
|
|
68305
68367
|
if (schOrFunc)
|
|
68306
68368
|
return schOrFunc;
|
|
68307
|
-
let _sch =
|
|
68369
|
+
let _sch = resolve27.call(this, root, ref);
|
|
68308
68370
|
if (_sch === void 0) {
|
|
68309
68371
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
68310
68372
|
const { schemaId } = this.opts;
|
|
@@ -68335,13 +68397,13 @@ var require_compile = __commonJS({
|
|
|
68335
68397
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
68336
68398
|
}
|
|
68337
68399
|
__name(sameSchemaEnv, "sameSchemaEnv");
|
|
68338
|
-
function
|
|
68400
|
+
function resolve27(root, ref) {
|
|
68339
68401
|
let sch;
|
|
68340
68402
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
68341
68403
|
ref = sch;
|
|
68342
68404
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
68343
68405
|
}
|
|
68344
|
-
__name(
|
|
68406
|
+
__name(resolve27, "resolve");
|
|
68345
68407
|
function resolveSchema(root, ref) {
|
|
68346
68408
|
const p2 = this.opts.uriResolver.parse(ref);
|
|
68347
68409
|
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p2);
|
|
@@ -69236,7 +69298,7 @@ var require_fast_uri = __commonJS({
|
|
|
69236
69298
|
return uri;
|
|
69237
69299
|
}
|
|
69238
69300
|
__name(normalize3, "normalize");
|
|
69239
|
-
function
|
|
69301
|
+
function resolve27(baseURI, relativeURI, options2) {
|
|
69240
69302
|
const schemelessOptions = options2 ? Object.assign({ scheme: "null" }, options2) : { scheme: "null" };
|
|
69241
69303
|
const {
|
|
69242
69304
|
parsed: baseParsed,
|
|
@@ -69272,7 +69334,7 @@ var require_fast_uri = __commonJS({
|
|
|
69272
69334
|
schemelessOptions.skipEscape = true;
|
|
69273
69335
|
return serialize(resolved, schemelessOptions);
|
|
69274
69336
|
}
|
|
69275
|
-
__name(
|
|
69337
|
+
__name(resolve27, "resolve");
|
|
69276
69338
|
function resolveComponent(base, relative15, options2, skipNormalization) {
|
|
69277
69339
|
const target = {};
|
|
69278
69340
|
if (!skipNormalization) {
|
|
@@ -69643,7 +69705,7 @@ var require_fast_uri = __commonJS({
|
|
|
69643
69705
|
var fastUri = {
|
|
69644
69706
|
SCHEMES,
|
|
69645
69707
|
normalize: normalize3,
|
|
69646
|
-
resolve:
|
|
69708
|
+
resolve: resolve27,
|
|
69647
69709
|
resolveComponent,
|
|
69648
69710
|
equal,
|
|
69649
69711
|
serialize,
|
|
@@ -73653,7 +73715,12 @@ async function createPlatformMcpTransport(token, options2 = {}) {
|
|
|
73653
73715
|
fetch: /* @__PURE__ */ __name(((url3, init) => {
|
|
73654
73716
|
const request2 = init;
|
|
73655
73717
|
const signal = options2.signal && request2?.signal ? AbortSignal.any([options2.signal, request2.signal]) : options2.signal ?? request2?.signal;
|
|
73656
|
-
return fetchWithProxy(url3, { ...request2, signal }, 6e5)
|
|
73718
|
+
return fetchWithProxy(url3, { ...request2, signal }, 6e5).then((response) => {
|
|
73719
|
+
const retryAfter = retryAfterMs(response.headers.get("retry-after"));
|
|
73720
|
+
if (retryAfter !== void 0)
|
|
73721
|
+
options2.onRetryAfter?.(retryAfter);
|
|
73722
|
+
return response;
|
|
73723
|
+
});
|
|
73657
73724
|
}), "fetch"),
|
|
73658
73725
|
requestInit: {
|
|
73659
73726
|
headers: {
|
|
@@ -73828,6 +73895,7 @@ var init_platform_tools = __esm({
|
|
|
73828
73895
|
"dist/lib/platform-tools.js"() {
|
|
73829
73896
|
"use strict";
|
|
73830
73897
|
init_http();
|
|
73898
|
+
init_poll_delay();
|
|
73831
73899
|
init_client();
|
|
73832
73900
|
init_config();
|
|
73833
73901
|
init_repro_guidance();
|
|
@@ -74514,7 +74582,7 @@ function typecheckTimeoutMs() {
|
|
|
74514
74582
|
}
|
|
74515
74583
|
function runBounded(command, args, cwd, options2 = {}) {
|
|
74516
74584
|
const timeoutMs = options2.timeoutMs ?? typecheckTimeoutMs();
|
|
74517
|
-
return new Promise((
|
|
74585
|
+
return new Promise((resolve27) => {
|
|
74518
74586
|
const posixGroup = process.platform !== "win32";
|
|
74519
74587
|
let child;
|
|
74520
74588
|
try {
|
|
@@ -74528,7 +74596,7 @@ function runBounded(command, args, cwd, options2 = {}) {
|
|
|
74528
74596
|
shell: /\.(cmd|bat)$/i.test(command)
|
|
74529
74597
|
});
|
|
74530
74598
|
} catch (err) {
|
|
74531
|
-
|
|
74599
|
+
resolve27({ code: null, out: "", stdout: "", error: err instanceof Error ? err : new Error(String(err)), timedOut: false });
|
|
74532
74600
|
return;
|
|
74533
74601
|
}
|
|
74534
74602
|
let out = "", stdout = "", timedOut = false, closed = false, settled = false, aborting = false, stopping = null, stopIncomplete = false;
|
|
@@ -74581,7 +74649,7 @@ function runBounded(command, args, cwd, options2 = {}) {
|
|
|
74581
74649
|
clearTimeout(timer);
|
|
74582
74650
|
process.off("SIGINT", onInt);
|
|
74583
74651
|
process.off("SIGTERM", onTerm);
|
|
74584
|
-
|
|
74652
|
+
resolve27({
|
|
74585
74653
|
code: closeCode,
|
|
74586
74654
|
out,
|
|
74587
74655
|
stdout,
|
|
@@ -75681,7 +75749,7 @@ var init_handler = __esm({
|
|
|
75681
75749
|
this._addToNodeFs(path3, initialAdd, wh, depth + 1);
|
|
75682
75750
|
}
|
|
75683
75751
|
}).on(EV.ERROR, this._boundHandleError);
|
|
75684
|
-
return new Promise((
|
|
75752
|
+
return new Promise((resolve27, reject) => {
|
|
75685
75753
|
if (!stream)
|
|
75686
75754
|
return reject();
|
|
75687
75755
|
stream.once(STR_END, () => {
|
|
@@ -75690,7 +75758,7 @@ var init_handler = __esm({
|
|
|
75690
75758
|
return;
|
|
75691
75759
|
}
|
|
75692
75760
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
75693
|
-
|
|
75761
|
+
resolve27(void 0);
|
|
75694
75762
|
previous.getChildren().filter((item) => {
|
|
75695
75763
|
return item !== directory2 && !current.has(item);
|
|
75696
75764
|
}).forEach((item) => {
|
|
@@ -78018,35 +78086,70 @@ async function awaitDeployChecks(client, checks, opts = {}) {
|
|
|
78018
78086
|
if (!target)
|
|
78019
78087
|
return null;
|
|
78020
78088
|
const now2 = opts.now ?? Date.now;
|
|
78021
|
-
const
|
|
78022
|
-
const pollMs = opts.pollMs ?? DEPLOY_CHECKS_POLL_MS;
|
|
78089
|
+
const sleep5 = opts.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
|
|
78023
78090
|
const deadline = now2() + (opts.waitMs ?? TEST_CHECKS_WAIT_MS);
|
|
78024
78091
|
let last = null;
|
|
78025
|
-
|
|
78092
|
+
let delay2 = opts.firstDelayMs ?? 0;
|
|
78093
|
+
let rateLimited = false;
|
|
78094
|
+
for (let attempt = 0; now2() + delay2 <= deadline; attempt++) {
|
|
78095
|
+
if (delay2)
|
|
78096
|
+
await sleep5(delay2);
|
|
78097
|
+
let retryAfter = 0;
|
|
78026
78098
|
try {
|
|
78027
|
-
const read = await client.call("GET", target.path, void 0, target.query, { timeoutMs: Math.max(1e3, deadline - now2())
|
|
78099
|
+
const read = await client.call("GET", target.path, void 0, target.query, { timeoutMs: Math.max(1e3, deadline - now2()), onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
78100
|
+
retryAfter = ms2;
|
|
78101
|
+
}, "onRetryAfter") });
|
|
78028
78102
|
if (read?.access_check)
|
|
78029
78103
|
last = read.access_check;
|
|
78030
78104
|
if (last && last.status !== "pending")
|
|
78031
78105
|
return last;
|
|
78032
|
-
|
|
78106
|
+
if (opts.readStored && !last && !retryAfter)
|
|
78107
|
+
return null;
|
|
78108
|
+
} catch (error3) {
|
|
78109
|
+
if (error3 instanceof CliApiError)
|
|
78110
|
+
retryAfter = Math.max(retryAfter, error3.meta.retryAfterMs ?? 0);
|
|
78111
|
+
if (opts.readStored && !last && !retryAfter && !rateLimited)
|
|
78112
|
+
return null;
|
|
78113
|
+
rateLimited ||= retryAfter > 0;
|
|
78033
78114
|
}
|
|
78034
|
-
|
|
78035
|
-
return last;
|
|
78036
|
-
await sleep3(pollMs);
|
|
78115
|
+
delay2 = Math.max(opts.pollMs ?? interactivePollDelay(attempt), retryAfter);
|
|
78037
78116
|
}
|
|
78117
|
+
return last ?? (rateLimited && opts.readStored ? { status: "unavailable", sentence: "The platform asked us to wait before reading the check again." } : null);
|
|
78038
78118
|
}
|
|
78039
78119
|
async function runChecksNow(client, projectId, opts = {}) {
|
|
78040
|
-
if (!opts.again) {
|
|
78120
|
+
if (!opts.again && opts.only === void 0) {
|
|
78041
78121
|
const read = `GET /v1/deploy/log?project_id=${encodeURIComponent(projectId)}`;
|
|
78042
|
-
const stored = await awaitDeployChecks(client, { read }, { ...opts,
|
|
78043
|
-
if (stored && stored.status !== "pending")
|
|
78044
|
-
return stored;
|
|
78122
|
+
const stored = await awaitDeployChecks(client, { read }, { ...opts, readStored: true });
|
|
78045
78123
|
if (stored)
|
|
78046
|
-
return
|
|
78124
|
+
return stored;
|
|
78125
|
+
}
|
|
78126
|
+
let firstDelayMs = 0;
|
|
78127
|
+
const started = await client.call("POST", opts.only === void 0 ? "/deploy/checks" : "/deploy/checks/targeted", { project_id: projectId, ...opts.only !== void 0 ? { check: opts.only } : {} }, void 0, { onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
78128
|
+
firstDelayMs = ms2;
|
|
78129
|
+
}, "onRetryAfter") });
|
|
78130
|
+
if (opts.only !== void 0 && (started?.scope !== "partial" || started.selection !== opts.only)) {
|
|
78131
|
+
return partialCheckUnavailable(opts.only, "The platform did not confirm a targeted check.");
|
|
78132
|
+
}
|
|
78133
|
+
const result = await awaitDeployChecks(client, { read: started?.read }, { ...opts, firstDelayMs });
|
|
78134
|
+
if (opts.only !== void 0 && (result?.scope !== "partial" || result.selection !== opts.only)) {
|
|
78135
|
+
return partialCheckUnavailable(opts.only, "The platform did not return a result for the selected check.");
|
|
78047
78136
|
}
|
|
78048
|
-
|
|
78049
|
-
|
|
78137
|
+
return result;
|
|
78138
|
+
}
|
|
78139
|
+
function partialCheckUnavailable(selection, sentence) {
|
|
78140
|
+
return {
|
|
78141
|
+
status: "unavailable",
|
|
78142
|
+
scope: "partial",
|
|
78143
|
+
selection,
|
|
78144
|
+
checked_parts: [],
|
|
78145
|
+
sentence,
|
|
78146
|
+
not_checked: {
|
|
78147
|
+
routes_without_read_check: null,
|
|
78148
|
+
routes_without_write_check: null,
|
|
78149
|
+
schedules_not_run: null,
|
|
78150
|
+
other: ["Access probes", "Browser page crawl", "Saved checks"]
|
|
78151
|
+
}
|
|
78152
|
+
};
|
|
78050
78153
|
}
|
|
78051
78154
|
function lineOutcome(line) {
|
|
78052
78155
|
if (line.outcome)
|
|
@@ -78093,6 +78196,13 @@ function resultEvidence(line) {
|
|
|
78093
78196
|
function formatChecksReport(check) {
|
|
78094
78197
|
const summary = deployChecksSummary(check);
|
|
78095
78198
|
const lines = [];
|
|
78199
|
+
if (check?.scope === "partial" && check.selection) {
|
|
78200
|
+
const ran = (check.checked_parts ?? []).map(selectionLabel);
|
|
78201
|
+
lines.push("Partial smoke check requested for " + selectionLabel(check.selection) + ".");
|
|
78202
|
+
lines.push(ran.length ? "Checked " + ran.join(", ") + "." : "No parts ran.");
|
|
78203
|
+
} else {
|
|
78204
|
+
lines.push("App smoke check");
|
|
78205
|
+
}
|
|
78096
78206
|
if (!check || check.status === "pending") {
|
|
78097
78207
|
lines.push(`Could not check: the run did not finish within ${TEST_CHECKS_WAIT_MS / 1e3} s.`);
|
|
78098
78208
|
} else if (check.status !== "checked") {
|
|
@@ -78127,7 +78237,7 @@ function formatChecksReport(check) {
|
|
|
78127
78237
|
}
|
|
78128
78238
|
if (!checks.length)
|
|
78129
78239
|
lines.push("Could not check: no named checks ran.");
|
|
78130
|
-
if (summary.counts.could_not_check && !lines.some((line) => line.startsWith("Could not check")))
|
|
78240
|
+
if (check.scope !== "partial" && summary.counts.could_not_check && !lines.some((line) => line.startsWith("Could not check")))
|
|
78131
78241
|
lines.push(`Could not check: run ${cliInvocation()} test --again to get named results.`);
|
|
78132
78242
|
}
|
|
78133
78243
|
const coverage = check?.not_checked ?? null;
|
|
@@ -78144,30 +78254,35 @@ function formatChecksReport(check) {
|
|
|
78144
78254
|
if (schedules === null)
|
|
78145
78255
|
lines.push("Registered schedules could not be listed.");
|
|
78146
78256
|
if (schedules?.length)
|
|
78147
|
-
lines.push(`${schedules.length} registered ${schedules.length === 1 ? "schedule" : "schedules"} did not run (${schedules.join(", ")}).`);
|
|
78257
|
+
lines.push(`${schedules.length} registered ${schedules.length === 1 ? "schedule" : "schedules"} did not run (${schedules.join(", ")}). Run one on your preview with ${cliInvocation()} cron run <name> --preview --wait.`);
|
|
78148
78258
|
if (other.length)
|
|
78149
78259
|
lines.push(`Other checks skipped or out of scope: ${other.join(", ")}.`);
|
|
78150
78260
|
} else {
|
|
78151
78261
|
lines.push("Coverage details are unavailable for this run.");
|
|
78152
78262
|
}
|
|
78263
|
+
lines.push("For your own app tests, use @somewhere-cloud/cli/testing. See somewhere docs test.");
|
|
78153
78264
|
return [...lines, JSON.stringify({
|
|
78154
78265
|
...summary,
|
|
78155
78266
|
not_checked: coverage,
|
|
78267
|
+
...check?.scope === "partial" ? { scope: check.scope, selection: check.selection, checked_parts: check.checked_parts } : {},
|
|
78156
78268
|
...coverage ? { routes_checked: check?.routes_checked, routes_discovered: check?.routes_discovered } : {}
|
|
78157
78269
|
})];
|
|
78158
78270
|
}
|
|
78159
|
-
var
|
|
78271
|
+
var DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS, selectionLabel, cleanupFindings, functionWarnings;
|
|
78160
78272
|
var init_deploy_checks = __esm({
|
|
78161
78273
|
"dist/lib/deploy-checks.js"() {
|
|
78162
78274
|
"use strict";
|
|
78163
78275
|
init_cli_invocation();
|
|
78276
|
+
init_client();
|
|
78277
|
+
init_poll_delay();
|
|
78164
78278
|
init_check_summary();
|
|
78165
|
-
DEPLOY_CHECKS_POLL_MS = 3e3;
|
|
78166
78279
|
__name(parseChecksRead, "parseChecksRead");
|
|
78167
78280
|
__name(awaitDeployChecks, "awaitDeployChecks");
|
|
78168
78281
|
DEPLOY_CHECKS_RUNNING = `Checks: running in the background; \`${cliInvocation()} test\` shows the result.`;
|
|
78169
78282
|
TEST_CHECKS_WAIT_MS = 15e4;
|
|
78170
78283
|
__name(runChecksNow, "runChecksNow");
|
|
78284
|
+
selectionLabel = /* @__PURE__ */ __name((selection) => selection === "access" ? "Access probes" : selection === "crawl" ? "Browser page crawl" : selection, "selectionLabel");
|
|
78285
|
+
__name(partialCheckUnavailable, "partialCheckUnavailable");
|
|
78171
78286
|
__name(lineOutcome, "lineOutcome");
|
|
78172
78287
|
cleanupFindings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((f2) => f2.kind === "cleanup"), "cleanupFindings");
|
|
78173
78288
|
functionWarnings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((finding) => finding.kind === "function_http_error" || finding.kind === "crash" && Boolean(finding.request_id)), "functionWarnings");
|
|
@@ -78266,13 +78381,13 @@ async function awaitPostLiveRender(client, projectId, result, opts = {}) {
|
|
|
78266
78381
|
if (result.post_live_render?.status !== "pending" || !result.release_id || !projectId)
|
|
78267
78382
|
return { kind: "not_pending" };
|
|
78268
78383
|
const now2 = opts.now ?? Date.now;
|
|
78269
|
-
const
|
|
78384
|
+
const sleep5 = opts.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
|
|
78270
78385
|
let pollMs = opts.pollMs ?? POST_LIVE_RENDER_POLL_MS;
|
|
78271
78386
|
let nextDelayMs = opts.pollMs ?? 0;
|
|
78272
78387
|
const deadline = now2() + (opts.waitMs ?? POST_LIVE_RENDER_WAIT_MS);
|
|
78273
78388
|
while (now2() < deadline) {
|
|
78274
78389
|
if (nextDelayMs)
|
|
78275
|
-
await
|
|
78390
|
+
await sleep5(Math.min(nextDelayMs, Math.max(0, deadline - now2())));
|
|
78276
78391
|
nextDelayMs = pollMs;
|
|
78277
78392
|
pollMs = opts.pollMs ?? Math.min(400, pollMs * 2);
|
|
78278
78393
|
let read;
|
|
@@ -78680,23 +78795,24 @@ function readManifest(root) {
|
|
|
78680
78795
|
}
|
|
78681
78796
|
return value;
|
|
78682
78797
|
}
|
|
78683
|
-
function
|
|
78798
|
+
function preparedActorState(root, target, name) {
|
|
78684
78799
|
const manifest = readManifest(root);
|
|
78685
78800
|
const actor = manifest?.actors.find((item) => item.name === name);
|
|
78686
78801
|
if (!actor || manifest?.project_id !== target.projectId || manifest.origin !== target.origin) {
|
|
78687
78802
|
throw new Error("No prepared actor for this app. Run somewhere test-users prepare with the actor name.");
|
|
78688
78803
|
}
|
|
78804
|
+
const path3 = join24(stateDir(root), actor.state_file);
|
|
78689
78805
|
const domain = new URL(target.origin).hostname;
|
|
78690
78806
|
let state;
|
|
78691
78807
|
try {
|
|
78692
|
-
state = JSON.parse(readFileSync21(
|
|
78808
|
+
state = JSON.parse(readFileSync21(path3, "utf8"));
|
|
78693
78809
|
} catch {
|
|
78694
78810
|
throw new Error("Could not read the saved test user session.");
|
|
78695
78811
|
}
|
|
78696
|
-
const
|
|
78697
|
-
if (typeof
|
|
78812
|
+
const token = Array.isArray(state?.cookies) ? state.cookies.find((cookie) => cookie?.name === ACCESS_COOKIE && cookie.domain === domain && cookie.path === "/" && cookie.secure)?.value : void 0;
|
|
78813
|
+
if (typeof token !== "string" || !token || !state)
|
|
78698
78814
|
throw new Error("The prepared actor has no app session in its saved state.");
|
|
78699
|
-
return
|
|
78815
|
+
return { path: path3, state: { cookies: state.cookies, origins: state.origins ?? [] }, access: token };
|
|
78700
78816
|
}
|
|
78701
78817
|
function writeManifest(root, manifest) {
|
|
78702
78818
|
writePrivateFile(join24(stateDir(root), MANIFEST_FILE), JSON.stringify(manifest, null, 2) + "\n");
|
|
@@ -78712,6 +78828,10 @@ function tokenTimes(accessToken) {
|
|
|
78712
78828
|
return null;
|
|
78713
78829
|
}
|
|
78714
78830
|
}
|
|
78831
|
+
function testAccessNeedsRefresh(token, now2 = Date.now()) {
|
|
78832
|
+
const times = token && tokenTimes(token);
|
|
78833
|
+
return !!times && times.exp * 1e3 <= now2 + 5e3;
|
|
78834
|
+
}
|
|
78715
78835
|
function buildStorageState(origin, host, issued, times) {
|
|
78716
78836
|
const cookie = /* @__PURE__ */ __name((name, value, expiresMs) => ({
|
|
78717
78837
|
name,
|
|
@@ -78836,9 +78956,10 @@ var init_test_identities = __esm({
|
|
|
78836
78956
|
__name(writePrivateFile, "writePrivateFile");
|
|
78837
78957
|
__name(ensureGitignored, "ensureGitignored");
|
|
78838
78958
|
__name(readManifest, "readManifest");
|
|
78839
|
-
__name(
|
|
78959
|
+
__name(preparedActorState, "preparedActorState");
|
|
78840
78960
|
__name(writeManifest, "writeManifest");
|
|
78841
78961
|
__name(tokenTimes, "tokenTimes");
|
|
78962
|
+
__name(testAccessNeedsRefresh, "testAccessNeedsRefresh");
|
|
78842
78963
|
__name(buildStorageState, "buildStorageState");
|
|
78843
78964
|
__name(parseIssued, "parseIssued");
|
|
78844
78965
|
__name(expiryOf, "expiryOf");
|
|
@@ -79200,7 +79321,7 @@ async function mintPreviewCredential(client, projectId, previewSessionId) {
|
|
|
79200
79321
|
}
|
|
79201
79322
|
function previewToolClient(credential) {
|
|
79202
79323
|
const client = new ApiClient(credential);
|
|
79203
|
-
return { call: /* @__PURE__ */ __name((method, path3, body, query) => client.call(method, path3, body, query, { refresh: false }), "call") };
|
|
79324
|
+
return { call: /* @__PURE__ */ __name((method, path3, body, query, opts) => client.call(method, path3, body, query, { ...opts, refresh: false }), "call") };
|
|
79204
79325
|
}
|
|
79205
79326
|
function isDeadPreviewCredential(err) {
|
|
79206
79327
|
return err instanceof CliApiError && (err.code === "PREVIEW_CREDENTIAL_INVALID" || err.code === "PREVIEW_CREDENTIAL_REQUIRED");
|
|
@@ -79530,6 +79651,10 @@ function previewControl(tool, target, _root) {
|
|
|
79530
79651
|
throw previewFailure(error3, "The preview could not be confirmed at the end of the run");
|
|
79531
79652
|
}
|
|
79532
79653
|
},
|
|
79654
|
+
async previewCookie() {
|
|
79655
|
+
const held = await pinned();
|
|
79656
|
+
return { ...held.cookie, expiresAt: held.expires_at };
|
|
79657
|
+
},
|
|
79533
79658
|
createManagedUser: /* @__PURE__ */ __name(() => createPreviewManagedUser(tool), "createManagedUser"),
|
|
79534
79659
|
deleteManagedUser: /* @__PURE__ */ __name((id) => deletePreviewManagedUser(tool, id), "deleteManagedUser"),
|
|
79535
79660
|
async close() {
|
|
@@ -79603,12 +79728,12 @@ var init_test_control = __esm({
|
|
|
79603
79728
|
import { connect } from "node:net";
|
|
79604
79729
|
async function testAddressOrder(origin) {
|
|
79605
79730
|
const url3 = new URL(origin);
|
|
79606
|
-
const probe = /* @__PURE__ */ __name((family) => new Promise((
|
|
79731
|
+
const probe = /* @__PURE__ */ __name((family) => new Promise((resolve27) => {
|
|
79607
79732
|
const socket = connect({ host: url3.hostname, port: Number(url3.port || 443), family });
|
|
79608
79733
|
const finish = /* @__PURE__ */ __name((ok) => {
|
|
79609
79734
|
clearTimeout(deadline);
|
|
79610
79735
|
socket.destroy();
|
|
79611
|
-
|
|
79736
|
+
resolve27(ok);
|
|
79612
79737
|
}, "finish");
|
|
79613
79738
|
const deadline = setTimeout(() => finish(false), 300);
|
|
79614
79739
|
socket.once("connect", () => finish(true));
|
|
@@ -79746,7 +79871,7 @@ ${line}
|
|
|
79746
79871
|
const child = spawn4(process.execPath, args, { cwd: root, stdio: ["inherit", input.toStderr ? "pipe" : "inherit", "inherit"], env: { ...runnerEnv, SW_TEST_TARGET: JSON.stringify(target), SW_TEST_RELEASE: target.releaseId, PLAYWRIGHT_NO_COPY_PROMPT: "1", SW_TEST_ORIGIN: origin, SW_TEST_BROWSER_LAUNCH_MS: String(prepared.browserLaunchMs), SW_TEST_BROWSER: browser, SW_TEST_SUBSET: String(subset), SW_TEST_JSON: String(Boolean(options2.json)), SW_TEST_RESULTS: resultsPath, SW_TEST_RUN: process.env.SW_TEST_RUN, SW_TEST_RUN_PID: String(process.pid), SW_TEST_RERUN_FLAGS: rerunFlags } });
|
|
79747
79872
|
if (input.toStderr)
|
|
79748
79873
|
child.stdout?.pipe(process.stderr);
|
|
79749
|
-
const status = await new Promise((
|
|
79874
|
+
const status = await new Promise((resolve27) => child.on("close", (code) => resolve27(code)));
|
|
79750
79875
|
mark("runner:exit", { status: status ?? -1 });
|
|
79751
79876
|
const after = await span("sweep:after", {}, () => sweepAccounts(control, root).catch((error3) => {
|
|
79752
79877
|
process.stderr.write(`Could not finish form sign-up cleanup: ${error3 instanceof Error ? error3.message : String(error3)}
|
|
@@ -80504,7 +80629,7 @@ function findBrowser(env = process.env, exists = existsSync26) {
|
|
|
80504
80629
|
return null;
|
|
80505
80630
|
}
|
|
80506
80631
|
function readEndpoint(child, timeoutMs) {
|
|
80507
|
-
return new Promise((
|
|
80632
|
+
return new Promise((resolve27, reject) => {
|
|
80508
80633
|
let buffered = "";
|
|
80509
80634
|
const timer = setTimeout(() => {
|
|
80510
80635
|
cleanup();
|
|
@@ -80516,7 +80641,7 @@ function readEndpoint(child, timeoutMs) {
|
|
|
80516
80641
|
if (!match)
|
|
80517
80642
|
return;
|
|
80518
80643
|
cleanup();
|
|
80519
|
-
|
|
80644
|
+
resolve27(match[0]);
|
|
80520
80645
|
}, "onData");
|
|
80521
80646
|
const onExit = /* @__PURE__ */ __name((code) => {
|
|
80522
80647
|
cleanup();
|
|
@@ -80550,9 +80675,9 @@ async function launchLocalBrowser(opts) {
|
|
|
80550
80675
|
], { stdio: ["ignore", "ignore", "pipe"], env: browserEnv });
|
|
80551
80676
|
const cleanup = /* @__PURE__ */ __name(async () => {
|
|
80552
80677
|
if (child.exitCode === null && child.signalCode === null) {
|
|
80553
|
-
const exited = new Promise((
|
|
80554
|
-
child.once("exit", () =>
|
|
80555
|
-
setTimeout(
|
|
80678
|
+
const exited = new Promise((resolve27) => {
|
|
80679
|
+
child.once("exit", () => resolve27());
|
|
80680
|
+
setTimeout(resolve27, 2e3).unref();
|
|
80556
80681
|
});
|
|
80557
80682
|
try {
|
|
80558
80683
|
child.kill("SIGKILL");
|
|
@@ -80616,11 +80741,11 @@ var init_chrome = __esm({
|
|
|
80616
80741
|
}
|
|
80617
80742
|
static async connect(wsUrl, timeoutMs) {
|
|
80618
80743
|
const socket = new import_undici2.WebSocket(wsUrl);
|
|
80619
|
-
await new Promise((
|
|
80744
|
+
await new Promise((resolve27, reject) => {
|
|
80620
80745
|
const timer = setTimeout(() => reject(new Error("Timed out connecting to the browser.")), timeoutMs);
|
|
80621
80746
|
socket.addEventListener("open", () => {
|
|
80622
80747
|
clearTimeout(timer);
|
|
80623
|
-
|
|
80748
|
+
resolve27();
|
|
80624
80749
|
}, { once: true });
|
|
80625
80750
|
socket.addEventListener("error", () => {
|
|
80626
80751
|
clearTimeout(timer);
|
|
@@ -80681,7 +80806,7 @@ var init_chrome = __esm({
|
|
|
80681
80806
|
if (this.closed)
|
|
80682
80807
|
return Promise.reject(new Error("The connection to the browser is closed."));
|
|
80683
80808
|
const id = this.nextId++;
|
|
80684
|
-
return new Promise((
|
|
80809
|
+
return new Promise((resolve27, reject) => {
|
|
80685
80810
|
const timer = setTimeout(() => {
|
|
80686
80811
|
this.pending.delete(id);
|
|
80687
80812
|
reject(new Error(`The browser did not answer \`${method}\` within ${Math.round(timeoutMs / 1e3)}s. The page may be stuck; run it again, and close any browser this command left behind.`));
|
|
@@ -80690,7 +80815,7 @@ var init_chrome = __esm({
|
|
|
80690
80815
|
this.pending.set(id, {
|
|
80691
80816
|
resolve: /* @__PURE__ */ __name((v2) => {
|
|
80692
80817
|
clearTimeout(timer);
|
|
80693
|
-
|
|
80818
|
+
resolve27(v2);
|
|
80694
80819
|
}, "resolve"),
|
|
80695
80820
|
reject: /* @__PURE__ */ __name((e) => {
|
|
80696
80821
|
clearTimeout(timer);
|
|
@@ -80771,8 +80896,8 @@ async function assertLocalTargetReachable(url3, timeoutMs = REACHABILITY_TIMEOUT
|
|
|
80771
80896
|
}
|
|
80772
80897
|
}
|
|
80773
80898
|
function sleep(ms2) {
|
|
80774
|
-
return new Promise((
|
|
80775
|
-
setTimeout(
|
|
80899
|
+
return new Promise((resolve27) => {
|
|
80900
|
+
setTimeout(resolve27, ms2).unref();
|
|
80776
80901
|
});
|
|
80777
80902
|
}
|
|
80778
80903
|
async function evaluate(session, expression) {
|
|
@@ -81112,10 +81237,10 @@ async function runLocalBrowser(req) {
|
|
|
81112
81237
|
mobile: false
|
|
81113
81238
|
});
|
|
81114
81239
|
let loadFired = false;
|
|
81115
|
-
const loaded2 = new Promise((
|
|
81240
|
+
const loaded2 = new Promise((resolve27) => {
|
|
81116
81241
|
session.on("Page.loadEventFired", () => {
|
|
81117
81242
|
loadFired = true;
|
|
81118
|
-
|
|
81243
|
+
resolve27();
|
|
81119
81244
|
});
|
|
81120
81245
|
});
|
|
81121
81246
|
await session.send("Page.navigate", { url: startUrl });
|
|
@@ -81123,8 +81248,8 @@ async function runLocalBrowser(req) {
|
|
|
81123
81248
|
let loadTimer;
|
|
81124
81249
|
await Promise.race([
|
|
81125
81250
|
loaded2,
|
|
81126
|
-
new Promise((
|
|
81127
|
-
loadTimer = setTimeout(
|
|
81251
|
+
new Promise((resolve27) => {
|
|
81252
|
+
loadTimer = setTimeout(resolve27, navigationBudgetMs);
|
|
81128
81253
|
loadTimer.unref();
|
|
81129
81254
|
})
|
|
81130
81255
|
]);
|
|
@@ -85128,16 +85253,51 @@ function deployRetriedAfterTransportFailure(err) {
|
|
|
85128
85253
|
}
|
|
85129
85254
|
async function callDeployWithRetry(client, body, opts) {
|
|
85130
85255
|
let transportFailure = null;
|
|
85131
|
-
|
|
85256
|
+
let attempt = 1;
|
|
85257
|
+
let publicationDeadline;
|
|
85258
|
+
let publicationRetries = 0;
|
|
85259
|
+
let confirmation;
|
|
85260
|
+
let pendingResponse;
|
|
85261
|
+
for (; ; ) {
|
|
85132
85262
|
const startedAt = Date.now();
|
|
85133
85263
|
const stopHeartbeat = startDeployHeartbeat(opts, attempt, startedAt);
|
|
85264
|
+
const timeoutMs = publicationDeadline === void 0 ? deployTimeoutMs() : Math.min(deployTimeoutMs(), Math.max(1, Math.floor(publicationDeadline - performance.now())));
|
|
85134
85265
|
try {
|
|
85135
|
-
return await client.call("POST", "/deploy", body, void 0, {
|
|
85136
|
-
timeoutMs
|
|
85137
|
-
|
|
85266
|
+
return await client.call("POST", "/deploy", confirmation ?? body, void 0, {
|
|
85267
|
+
timeoutMs,
|
|
85268
|
+
...publicationDeadline === void 0 ? {} : { refresh: false }
|
|
85269
|
+
}).finally(stopHeartbeat);
|
|
85138
85270
|
} catch (err) {
|
|
85139
85271
|
if (transportFailure && err && typeof err === "object")
|
|
85140
85272
|
retriedAfterTransportFailure.set(err, transportFailure);
|
|
85273
|
+
if (err instanceof CliApiError && err.statusCode === 503 && err.code === "EXEC_CONTROL_PUBLICATION_PENDING") {
|
|
85274
|
+
const target = err.data?.confirm_publication;
|
|
85275
|
+
if (opts.dryRun || !target || typeof target !== "object" || !("project_id" in target) || typeof target.project_id !== "string" || !("release_id" in target) || typeof target.release_id !== "string" || target.release_id !== err.data?.release_id || target.project_id !== (confirmation?.project_id ?? body.project_id ?? target.project_id) || confirmation && confirmation.confirm_publication !== target.release_id)
|
|
85276
|
+
throw err;
|
|
85277
|
+
confirmation ??= { project_id: target.project_id, confirm_publication: target.release_id };
|
|
85278
|
+
pendingResponse = err;
|
|
85279
|
+
publicationDeadline ??= performance.now() + PUBLICATION_RETRY_BUDGET_MS;
|
|
85280
|
+
const backoffMs = PUBLICATION_RETRY_DELAYS_MS[publicationRetries];
|
|
85281
|
+
if (backoffMs === void 0)
|
|
85282
|
+
throw err;
|
|
85283
|
+
const asked = err.meta.retryAfterMs;
|
|
85284
|
+
const waitMs2 = typeof asked === "number" && Number.isFinite(asked) && asked >= 0 ? Math.ceil(asked) : backoffMs;
|
|
85285
|
+
if (performance.now() + waitMs2 >= publicationDeadline)
|
|
85286
|
+
throw err;
|
|
85287
|
+
if (!opts.json) {
|
|
85288
|
+
opts.spinner?.stop();
|
|
85289
|
+
warn(waitMs2 > 0 ? `Deploy confirmation is pending. Retrying in ${Math.ceil(waitMs2 / 1e3)}s.` : "Deploy confirmation is pending. Retrying now.");
|
|
85290
|
+
}
|
|
85291
|
+
await new Promise((resolve27) => setTimeout(resolve27, waitMs2));
|
|
85292
|
+
if (performance.now() >= publicationDeadline)
|
|
85293
|
+
throw err;
|
|
85294
|
+
if (!opts.json)
|
|
85295
|
+
opts.spinner?.start(opts.baseText);
|
|
85296
|
+
publicationRetries++;
|
|
85297
|
+
continue;
|
|
85298
|
+
}
|
|
85299
|
+
if (pendingResponse)
|
|
85300
|
+
throw outcomeUnknown(err) ? pendingResponse : err;
|
|
85141
85301
|
if (attempt >= DEPLOY_MAX_ATTEMPTS)
|
|
85142
85302
|
throw err;
|
|
85143
85303
|
if (!isRetryableDeployError(err))
|
|
@@ -85153,11 +85313,9 @@ async function callDeployWithRetry(client, body, opts) {
|
|
|
85153
85313
|
}
|
|
85154
85314
|
if (waitMs)
|
|
85155
85315
|
await new Promise((r) => setTimeout(r, waitMs));
|
|
85156
|
-
|
|
85157
|
-
stopHeartbeat();
|
|
85316
|
+
attempt++;
|
|
85158
85317
|
}
|
|
85159
85318
|
}
|
|
85160
|
-
throw new CliApiError("DEPLOY_RETRY_EXHAUSTED", "Deploy retry exhausted.", 0);
|
|
85161
85319
|
}
|
|
85162
85320
|
function outcomeUnknown(err) {
|
|
85163
85321
|
if (!(err instanceof CliApiError))
|
|
@@ -85327,7 +85485,7 @@ ${teal("Dry run")}${dim(scopeNote)} \u2014 nothing was deployed.
|
|
|
85327
85485
|
}
|
|
85328
85486
|
console.log("");
|
|
85329
85487
|
}
|
|
85330
|
-
var import_prompts4, DOTFILE_NOTICE, SERVER_FRAMEWORK_DEPS, SERVER_CODE_PATTERN, NEXT_APP_SIGNAL_PREFIX, NEXT_CONFIG_PATTERN, NEXT_DEPENDENCY_SECTIONS, NEXT_APP_WARNING, DEPLOY_HEARTBEAT_MS, DEPLOY_MAX_ATTEMPTS, RETRYABLE_DEPLOY_CODES, DEPLOY_RETRY_MAX_WAIT_MS, POST_DEPLOY_HINT, SOURCE_WORDS, DEPLOY_PRESTART_TIMEOUT_MS, CANONICAL_PROJECT_ID, PROJECT_SITE_DOMAIN2, retriedAfterTransportFailure, INTERNAL_PREFIXES, isInternalPath;
|
|
85488
|
+
var import_prompts4, DOTFILE_NOTICE, SERVER_FRAMEWORK_DEPS, SERVER_CODE_PATTERN, NEXT_APP_SIGNAL_PREFIX, NEXT_CONFIG_PATTERN, NEXT_DEPENDENCY_SECTIONS, NEXT_APP_WARNING, DEPLOY_HEARTBEAT_MS, DEPLOY_MAX_ATTEMPTS, RETRYABLE_DEPLOY_CODES, DEPLOY_RETRY_MAX_WAIT_MS, PUBLICATION_RETRY_BUDGET_MS, PUBLICATION_RETRY_DELAYS_MS, POST_DEPLOY_HINT, SOURCE_WORDS, DEPLOY_PRESTART_TIMEOUT_MS, CANONICAL_PROJECT_ID, PROJECT_SITE_DOMAIN2, retriedAfterTransportFailure, INTERNAL_PREFIXES, isInternalPath;
|
|
85331
85489
|
var init_deploy = __esm({
|
|
85332
85490
|
"dist/commands/deploy.js"() {
|
|
85333
85491
|
"use strict";
|
|
@@ -85383,6 +85541,8 @@ var init_deploy = __esm({
|
|
|
85383
85541
|
DEPLOY_MAX_ATTEMPTS = 2;
|
|
85384
85542
|
RETRYABLE_DEPLOY_CODES = /* @__PURE__ */ new Set(["TIMEOUT", "SERVER_SLOW", "NETWORK_ERROR"]);
|
|
85385
85543
|
DEPLOY_RETRY_MAX_WAIT_MS = 1e4;
|
|
85544
|
+
PUBLICATION_RETRY_BUDGET_MS = 3e4;
|
|
85545
|
+
PUBLICATION_RETRY_DELAYS_MS = [1e3, 2e3, 4e3, 8e3];
|
|
85386
85546
|
POST_DEPLOY_HINT = `Next: keep building with \`${cliInvocation()} dev\`; run \`${cliInvocation()} deploy\` to update this live app. Once it has real users or data, use \`${cliInvocation()} preview\` before changing what they see.`;
|
|
85387
85547
|
__name(isNextAppShapeSignal, "isNextAppShapeSignal");
|
|
85388
85548
|
__name(detectNextAppShape, "detectNextAppShape");
|
|
@@ -87259,7 +87419,7 @@ async function callAdvisorRun(args) {
|
|
|
87259
87419
|
if (result.status !== "settled" && !result.answer)
|
|
87260
87420
|
args.progress?.(`Advisor is working. To reconnect: ${cliInvocation()} advisor --resume ` + record3.request_id);
|
|
87261
87421
|
while (result.status !== "settled" && !result.answer && !result.payload_expired) {
|
|
87262
|
-
await new Promise((
|
|
87422
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(1e4, Math.max(1e3, (result.retry_after_seconds ?? 2) * 1e3))));
|
|
87263
87423
|
result = await request(record3, result.next_step === "resume" ? "resume" : "status");
|
|
87264
87424
|
}
|
|
87265
87425
|
return result;
|
|
@@ -89543,6 +89703,7 @@ var init_frontend_dev = __esm({
|
|
|
89543
89703
|
});
|
|
89544
89704
|
|
|
89545
89705
|
// dist/lib/preview-jobs.js
|
|
89706
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
89546
89707
|
async function folderPreviewTool(opts) {
|
|
89547
89708
|
const projectId = opts.project ?? loadProjectConfig()?.project_id;
|
|
89548
89709
|
if (!projectId)
|
|
@@ -89556,16 +89717,37 @@ async function folderPreviewTool(opts) {
|
|
|
89556
89717
|
async function previewCurrentVersion(credential) {
|
|
89557
89718
|
return previewToolClient(credential).call("GET", "/preview-tools/whoami");
|
|
89558
89719
|
}
|
|
89559
|
-
async function waitForPreviewJob(credential, jobId, timeoutSeconds) {
|
|
89720
|
+
async function waitForPreviewJob(credential, jobId, timeoutSeconds, firstDelayMs = 0) {
|
|
89560
89721
|
const client = previewToolClient(credential);
|
|
89561
89722
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
89562
|
-
|
|
89563
|
-
|
|
89564
|
-
|
|
89565
|
-
|
|
89566
|
-
if (
|
|
89567
|
-
|
|
89568
|
-
|
|
89723
|
+
let job;
|
|
89724
|
+
let delay2 = firstDelayMs;
|
|
89725
|
+
for (let attempt = 0; ; attempt++) {
|
|
89726
|
+
const remaining = deadline - Date.now();
|
|
89727
|
+
if (delay2 >= remaining) {
|
|
89728
|
+
if (remaining > 0)
|
|
89729
|
+
await sleep2(remaining);
|
|
89730
|
+
if (job)
|
|
89731
|
+
return { job, timedOut: true };
|
|
89732
|
+
throw new Error("The wait expired before the platform returned the preview job status.");
|
|
89733
|
+
}
|
|
89734
|
+
if (delay2)
|
|
89735
|
+
await sleep2(delay2);
|
|
89736
|
+
let retryAfter = 0;
|
|
89737
|
+
try {
|
|
89738
|
+
job = await client.call("GET", `/preview-tools/jobs/${encodeURIComponent(jobId)}`, void 0, void 0, {
|
|
89739
|
+
onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
89740
|
+
retryAfter = ms2;
|
|
89741
|
+
}, "onRetryAfter")
|
|
89742
|
+
});
|
|
89743
|
+
if (TERMINAL.has(job.status))
|
|
89744
|
+
return { job, timedOut: false };
|
|
89745
|
+
} catch (error3) {
|
|
89746
|
+
if (!(error3 instanceof CliApiError) || error3.meta.retryAfterMs === void 0)
|
|
89747
|
+
throw error3;
|
|
89748
|
+
retryAfter = Math.max(retryAfter, error3.meta.retryAfterMs);
|
|
89749
|
+
}
|
|
89750
|
+
delay2 = Math.max(interactivePollDelay(attempt), retryAfter);
|
|
89569
89751
|
}
|
|
89570
89752
|
}
|
|
89571
89753
|
var TERMINAL;
|
|
@@ -89574,6 +89756,7 @@ var init_preview_jobs = __esm({
|
|
|
89574
89756
|
"use strict";
|
|
89575
89757
|
init_cli_invocation();
|
|
89576
89758
|
init_client();
|
|
89759
|
+
init_poll_delay();
|
|
89577
89760
|
init_config();
|
|
89578
89761
|
init_preview_credential();
|
|
89579
89762
|
init_preview_record();
|
|
@@ -91683,12 +91866,12 @@ var init_stdio2 = __esm({
|
|
|
91683
91866
|
this.onclose?.();
|
|
91684
91867
|
}
|
|
91685
91868
|
send(message3) {
|
|
91686
|
-
return new Promise((
|
|
91869
|
+
return new Promise((resolve27) => {
|
|
91687
91870
|
const json = serializeMessage(message3);
|
|
91688
91871
|
if (this._stdout.write(json)) {
|
|
91689
|
-
|
|
91872
|
+
resolve27();
|
|
91690
91873
|
} else {
|
|
91691
|
-
this._stdout.once("drain",
|
|
91874
|
+
this._stdout.once("drain", resolve27);
|
|
91692
91875
|
}
|
|
91693
91876
|
});
|
|
91694
91877
|
}
|
|
@@ -91828,7 +92011,7 @@ async function runStdioBridge() {
|
|
|
91828
92011
|
try {
|
|
91829
92012
|
transport = await createHttpTransport(token);
|
|
91830
92013
|
const id = `somewhere-bridge-probe-${++probeSeq}`;
|
|
91831
|
-
const answered = new Promise((
|
|
92014
|
+
const answered = new Promise((resolve27, reject) => {
|
|
91832
92015
|
const timer = setTimeout(() => {
|
|
91833
92016
|
probes.delete(id);
|
|
91834
92017
|
reject(new Error("no answer to tools/list within 15s"));
|
|
@@ -91836,7 +92019,7 @@ async function runStdioBridge() {
|
|
|
91836
92019
|
probes.set(id, (message3) => {
|
|
91837
92020
|
clearTimeout(timer);
|
|
91838
92021
|
probes.delete(id);
|
|
91839
|
-
|
|
92022
|
+
resolve27(message3);
|
|
91840
92023
|
});
|
|
91841
92024
|
});
|
|
91842
92025
|
await transport.send({ jsonrpc: "2.0", id, method: "tools/list", params: {} });
|
|
@@ -99216,13 +99399,13 @@ var require_lib2 = __commonJS({
|
|
|
99216
99399
|
unref: options2.unref,
|
|
99217
99400
|
maxRetryTime: options2.maxRetryTime
|
|
99218
99401
|
});
|
|
99219
|
-
return new Promise(function(
|
|
99402
|
+
return new Promise(function(resolve27, reject) {
|
|
99220
99403
|
operation.attempt(async (number4) => {
|
|
99221
99404
|
try {
|
|
99222
99405
|
const result = await fn((err) => {
|
|
99223
99406
|
throw Object.assign(new Error("Retrying"), { code: "EPROMISERETRY", retried: err });
|
|
99224
99407
|
}, number4, operation);
|
|
99225
|
-
return
|
|
99408
|
+
return resolve27(result);
|
|
99226
99409
|
} catch (err) {
|
|
99227
99410
|
if (!isRetryError(err)) {
|
|
99228
99411
|
return reject(err);
|
|
@@ -99987,10 +100170,10 @@ var require_commonjs = __commonJS({
|
|
|
99987
100170
|
* Return a void Promise that resolves once the stream ends.
|
|
99988
100171
|
*/
|
|
99989
100172
|
async promise() {
|
|
99990
|
-
return new Promise((
|
|
100173
|
+
return new Promise((resolve27, reject) => {
|
|
99991
100174
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
99992
100175
|
this.on("error", (er2) => reject(er2));
|
|
99993
|
-
this.on("end", () =>
|
|
100176
|
+
this.on("end", () => resolve27());
|
|
99994
100177
|
});
|
|
99995
100178
|
}
|
|
99996
100179
|
/**
|
|
@@ -100014,7 +100197,7 @@ var require_commonjs = __commonJS({
|
|
|
100014
100197
|
return Promise.resolve({ done: false, value: res });
|
|
100015
100198
|
if (this[EOF])
|
|
100016
100199
|
return stop();
|
|
100017
|
-
let
|
|
100200
|
+
let resolve27;
|
|
100018
100201
|
let reject;
|
|
100019
100202
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
100020
100203
|
this.off("data", ondata);
|
|
@@ -100028,19 +100211,19 @@ var require_commonjs = __commonJS({
|
|
|
100028
100211
|
this.off("end", onend);
|
|
100029
100212
|
this.off(DESTROYED, ondestroy);
|
|
100030
100213
|
this.pause();
|
|
100031
|
-
|
|
100214
|
+
resolve27({ value, done: !!this[EOF] });
|
|
100032
100215
|
}, "ondata");
|
|
100033
100216
|
const onend = /* @__PURE__ */ __name(() => {
|
|
100034
100217
|
this.off("error", onerr);
|
|
100035
100218
|
this.off("data", ondata);
|
|
100036
100219
|
this.off(DESTROYED, ondestroy);
|
|
100037
100220
|
stop();
|
|
100038
|
-
|
|
100221
|
+
resolve27({ done: true, value: void 0 });
|
|
100039
100222
|
}, "onend");
|
|
100040
100223
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
100041
100224
|
return new Promise((res2, rej) => {
|
|
100042
100225
|
reject = rej;
|
|
100043
|
-
|
|
100226
|
+
resolve27 = res2;
|
|
100044
100227
|
this.once(DESTROYED, ondestroy);
|
|
100045
100228
|
this.once("error", onerr);
|
|
100046
100229
|
this.once("end", onend);
|
|
@@ -104793,12 +104976,12 @@ var require_body2 = __commonJS({
|
|
|
104793
104976
|
if (resTimeout && resTimeout.unref) {
|
|
104794
104977
|
resTimeout.unref();
|
|
104795
104978
|
}
|
|
104796
|
-
return new Promise((
|
|
104979
|
+
return new Promise((resolve27) => {
|
|
104797
104980
|
if (stream !== upstream) {
|
|
104798
104981
|
upstream.on("error", (er2) => stream.emit("error", er2));
|
|
104799
104982
|
upstream.pipe(stream);
|
|
104800
104983
|
}
|
|
104801
|
-
|
|
104984
|
+
resolve27();
|
|
104802
104985
|
}).then(() => stream.concat()).then((buf) => {
|
|
104803
104986
|
clearTimeout(resTimeout);
|
|
104804
104987
|
return buf;
|
|
@@ -105564,7 +105747,7 @@ var require_lib4 = __commonJS({
|
|
|
105564
105747
|
var fetch2 = /* @__PURE__ */ __name(async (url3, opts) => {
|
|
105565
105748
|
if (/^data:/.test(url3)) {
|
|
105566
105749
|
const request2 = new Request(url3, opts);
|
|
105567
|
-
return Promise.resolve().then(() => new Promise((
|
|
105750
|
+
return Promise.resolve().then(() => new Promise((resolve27, reject) => {
|
|
105568
105751
|
let type, data2;
|
|
105569
105752
|
try {
|
|
105570
105753
|
const { pathname, search } = new URL2(url3);
|
|
@@ -105588,10 +105771,10 @@ var require_lib4 = __commonJS({
|
|
|
105588
105771
|
if (type) {
|
|
105589
105772
|
headers["Content-Type"] = type;
|
|
105590
105773
|
}
|
|
105591
|
-
return
|
|
105774
|
+
return resolve27(new Response2(data2, { headers }));
|
|
105592
105775
|
}));
|
|
105593
105776
|
}
|
|
105594
|
-
return new Promise((
|
|
105777
|
+
return new Promise((resolve27, reject) => {
|
|
105595
105778
|
const request2 = new Request(url3, opts);
|
|
105596
105779
|
let options2;
|
|
105597
105780
|
try {
|
|
@@ -105710,7 +105893,7 @@ var require_lib4 = __commonJS({
|
|
|
105710
105893
|
requestOpts.body = void 0;
|
|
105711
105894
|
requestOpts.headers.delete("content-length");
|
|
105712
105895
|
}
|
|
105713
|
-
|
|
105896
|
+
resolve27(fetch2(new Request(locationURL, requestOpts)));
|
|
105714
105897
|
finalize2();
|
|
105715
105898
|
return;
|
|
105716
105899
|
}
|
|
@@ -105738,7 +105921,7 @@ var require_lib4 = __commonJS({
|
|
|
105738
105921
|
const codings = headers.get("Content-Encoding");
|
|
105739
105922
|
if (!request2.compress || request2.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
105740
105923
|
response = new Response2(body, responseOptions);
|
|
105741
|
-
|
|
105924
|
+
resolve27(response);
|
|
105742
105925
|
return;
|
|
105743
105926
|
}
|
|
105744
105927
|
const zlibOptions = {
|
|
@@ -105757,7 +105940,7 @@ var require_lib4 = __commonJS({
|
|
|
105757
105940
|
).pipe(unzip),
|
|
105758
105941
|
responseOptions
|
|
105759
105942
|
);
|
|
105760
|
-
|
|
105943
|
+
resolve27(response);
|
|
105761
105944
|
return;
|
|
105762
105945
|
}
|
|
105763
105946
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -105769,7 +105952,7 @@ var require_lib4 = __commonJS({
|
|
|
105769
105952
|
(er2) => decoder2.emit("error", er2)
|
|
105770
105953
|
).pipe(decoder2);
|
|
105771
105954
|
response = new Response2(decoder2, responseOptions);
|
|
105772
|
-
|
|
105955
|
+
resolve27(response);
|
|
105773
105956
|
});
|
|
105774
105957
|
return;
|
|
105775
105958
|
}
|
|
@@ -105787,11 +105970,11 @@ var require_lib4 = __commonJS({
|
|
|
105787
105970
|
(er2) => decoder.emit("error", er2)
|
|
105788
105971
|
).pipe(decoder);
|
|
105789
105972
|
response = new Response2(decoder, responseOptions);
|
|
105790
|
-
|
|
105973
|
+
resolve27(response);
|
|
105791
105974
|
return;
|
|
105792
105975
|
}
|
|
105793
105976
|
response = new Response2(body, responseOptions);
|
|
105794
|
-
|
|
105977
|
+
resolve27(response);
|
|
105795
105978
|
});
|
|
105796
105979
|
writeToStream(req, request2);
|
|
105797
105980
|
});
|
|
@@ -107436,7 +107619,7 @@ var require_lib5 = __commonJS({
|
|
|
107436
107619
|
module.exports.fromStream = fromStream;
|
|
107437
107620
|
function fromStream(stream, opts) {
|
|
107438
107621
|
const istream = integrityStream(opts);
|
|
107439
|
-
return new Promise((
|
|
107622
|
+
return new Promise((resolve27, reject) => {
|
|
107440
107623
|
stream.pipe(istream);
|
|
107441
107624
|
stream.on("error", reject);
|
|
107442
107625
|
istream.on("error", reject);
|
|
@@ -107444,7 +107627,7 @@ var require_lib5 = __commonJS({
|
|
|
107444
107627
|
istream.on("integrity", (s3) => {
|
|
107445
107628
|
sri = s3;
|
|
107446
107629
|
});
|
|
107447
|
-
istream.on("end", () =>
|
|
107630
|
+
istream.on("end", () => resolve27(sri));
|
|
107448
107631
|
istream.resume();
|
|
107449
107632
|
});
|
|
107450
107633
|
}
|
|
@@ -107505,7 +107688,7 @@ var require_lib5 = __commonJS({
|
|
|
107505
107688
|
));
|
|
107506
107689
|
}
|
|
107507
107690
|
const checker = integrityStream(opts);
|
|
107508
|
-
return new Promise((
|
|
107691
|
+
return new Promise((resolve27, reject) => {
|
|
107509
107692
|
stream.pipe(checker);
|
|
107510
107693
|
stream.on("error", reject);
|
|
107511
107694
|
checker.on("error", reject);
|
|
@@ -107513,7 +107696,7 @@ var require_lib5 = __commonJS({
|
|
|
107513
107696
|
checker.on("verified", (s3) => {
|
|
107514
107697
|
verified = s3;
|
|
107515
107698
|
});
|
|
107516
|
-
checker.on("end", () =>
|
|
107699
|
+
checker.on("end", () => resolve27(verified));
|
|
107517
107700
|
checker.resume();
|
|
107518
107701
|
});
|
|
107519
107702
|
}
|
|
@@ -108151,10 +108334,10 @@ var require_minipass = __commonJS({
|
|
|
108151
108334
|
}
|
|
108152
108335
|
// stream.promise().then(() => done, er => emitted error)
|
|
108153
108336
|
promise() {
|
|
108154
|
-
return new Promise((
|
|
108337
|
+
return new Promise((resolve27, reject) => {
|
|
108155
108338
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
108156
108339
|
this.on("error", (er2) => reject(er2));
|
|
108157
|
-
this.on("end", () =>
|
|
108340
|
+
this.on("end", () => resolve27());
|
|
108158
108341
|
});
|
|
108159
108342
|
}
|
|
108160
108343
|
// for await (let chunk of stream)
|
|
@@ -108165,7 +108348,7 @@ var require_minipass = __commonJS({
|
|
|
108165
108348
|
return Promise.resolve({ done: false, value: res });
|
|
108166
108349
|
if (this[EOF])
|
|
108167
108350
|
return Promise.resolve({ done: true });
|
|
108168
|
-
let
|
|
108351
|
+
let resolve27 = null;
|
|
108169
108352
|
let reject = null;
|
|
108170
108353
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
108171
108354
|
this.removeListener("data", ondata);
|
|
@@ -108176,17 +108359,17 @@ var require_minipass = __commonJS({
|
|
|
108176
108359
|
this.removeListener("error", onerr);
|
|
108177
108360
|
this.removeListener("end", onend);
|
|
108178
108361
|
this.pause();
|
|
108179
|
-
|
|
108362
|
+
resolve27({ value, done: !!this[EOF] });
|
|
108180
108363
|
}, "ondata");
|
|
108181
108364
|
const onend = /* @__PURE__ */ __name(() => {
|
|
108182
108365
|
this.removeListener("error", onerr);
|
|
108183
108366
|
this.removeListener("data", ondata);
|
|
108184
|
-
|
|
108367
|
+
resolve27({ done: true });
|
|
108185
108368
|
}, "onend");
|
|
108186
108369
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
108187
108370
|
return new Promise((res2, rej) => {
|
|
108188
108371
|
reject = rej;
|
|
108189
|
-
|
|
108372
|
+
resolve27 = res2;
|
|
108190
108373
|
this.once(DESTROYED, ondestroy);
|
|
108191
108374
|
this.once("error", onerr);
|
|
108192
108375
|
this.once("end", onend);
|
|
@@ -108797,10 +108980,10 @@ var require_minipass2 = __commonJS({
|
|
|
108797
108980
|
}
|
|
108798
108981
|
// stream.promise().then(() => done, er => emitted error)
|
|
108799
108982
|
promise() {
|
|
108800
|
-
return new Promise((
|
|
108983
|
+
return new Promise((resolve27, reject) => {
|
|
108801
108984
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
108802
108985
|
this.on("error", (er2) => reject(er2));
|
|
108803
|
-
this.on("end", () =>
|
|
108986
|
+
this.on("end", () => resolve27());
|
|
108804
108987
|
});
|
|
108805
108988
|
}
|
|
108806
108989
|
// for await (let chunk of stream)
|
|
@@ -108811,7 +108994,7 @@ var require_minipass2 = __commonJS({
|
|
|
108811
108994
|
return Promise.resolve({ done: false, value: res });
|
|
108812
108995
|
if (this[EOF])
|
|
108813
108996
|
return Promise.resolve({ done: true });
|
|
108814
|
-
let
|
|
108997
|
+
let resolve27 = null;
|
|
108815
108998
|
let reject = null;
|
|
108816
108999
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
108817
109000
|
this.removeListener("data", ondata);
|
|
@@ -108822,17 +109005,17 @@ var require_minipass2 = __commonJS({
|
|
|
108822
109005
|
this.removeListener("error", onerr);
|
|
108823
109006
|
this.removeListener("end", onend);
|
|
108824
109007
|
this.pause();
|
|
108825
|
-
|
|
109008
|
+
resolve27({ value, done: !!this[EOF] });
|
|
108826
109009
|
}, "ondata");
|
|
108827
109010
|
const onend = /* @__PURE__ */ __name(() => {
|
|
108828
109011
|
this.removeListener("error", onerr);
|
|
108829
109012
|
this.removeListener("data", ondata);
|
|
108830
|
-
|
|
109013
|
+
resolve27({ done: true });
|
|
108831
109014
|
}, "onend");
|
|
108832
109015
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
108833
109016
|
return new Promise((res2, rej) => {
|
|
108834
109017
|
reject = rej;
|
|
108835
|
-
|
|
109018
|
+
resolve27 = res2;
|
|
108836
109019
|
this.once(DESTROYED, ondestroy);
|
|
108837
109020
|
this.once("error", onerr);
|
|
108838
109021
|
this.once("end", onend);
|
|
@@ -109196,7 +109379,7 @@ var require_polyfill = __commonJS({
|
|
|
109196
109379
|
isAbsolute: isAbsolute7,
|
|
109197
109380
|
join: join51,
|
|
109198
109381
|
parse: parse3,
|
|
109199
|
-
resolve:
|
|
109382
|
+
resolve: resolve27,
|
|
109200
109383
|
sep: sep2,
|
|
109201
109384
|
toNamespacedPath
|
|
109202
109385
|
} = __require("path");
|
|
@@ -109314,8 +109497,8 @@ var require_polyfill = __commonJS({
|
|
|
109314
109497
|
}
|
|
109315
109498
|
__name(pathExists, "pathExists");
|
|
109316
109499
|
async function checkParentPaths(src, srcStat, dest) {
|
|
109317
|
-
const srcParent =
|
|
109318
|
-
const destParent =
|
|
109500
|
+
const srcParent = resolve27(dirname16(src));
|
|
109501
|
+
const destParent = resolve27(dirname16(dest));
|
|
109319
109502
|
if (destParent === srcParent || destParent === parse3(destParent).root) {
|
|
109320
109503
|
return;
|
|
109321
109504
|
}
|
|
@@ -109339,7 +109522,7 @@ var require_polyfill = __commonJS({
|
|
|
109339
109522
|
return checkParentPaths(src, srcStat, destParent);
|
|
109340
109523
|
}
|
|
109341
109524
|
__name(checkParentPaths, "checkParentPaths");
|
|
109342
|
-
var normalizePathToArray = /* @__PURE__ */ __name((path3) =>
|
|
109525
|
+
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(sep2).filter(Boolean), "normalizePathToArray");
|
|
109343
109526
|
function isSrcSubdir(src, dest) {
|
|
109344
109527
|
const srcArr = normalizePathToArray(src);
|
|
109345
109528
|
const destArr = normalizePathToArray(dest);
|
|
@@ -109485,7 +109668,7 @@ var require_polyfill = __commonJS({
|
|
|
109485
109668
|
async function onLink(destStat, src, dest) {
|
|
109486
109669
|
let resolvedSrc = await readlink(src);
|
|
109487
109670
|
if (!isAbsolute7(resolvedSrc)) {
|
|
109488
|
-
resolvedSrc =
|
|
109671
|
+
resolvedSrc = resolve27(dirname16(src), resolvedSrc);
|
|
109489
109672
|
}
|
|
109490
109673
|
if (!destStat) {
|
|
109491
109674
|
return symlink(resolvedSrc, dest);
|
|
@@ -109500,7 +109683,7 @@ var require_polyfill = __commonJS({
|
|
|
109500
109683
|
throw err;
|
|
109501
109684
|
}
|
|
109502
109685
|
if (!isAbsolute7(resolvedDest)) {
|
|
109503
|
-
resolvedDest =
|
|
109686
|
+
resolvedDest = resolve27(dirname16(dest), resolvedDest);
|
|
109504
109687
|
}
|
|
109505
109688
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
109506
109689
|
throw new ERR_FS_CP_EINVAL({
|
|
@@ -109606,7 +109789,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
109606
109789
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
109607
109790
|
var require_move_file = __commonJS({
|
|
109608
109791
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
109609
|
-
var { dirname: dirname16, join: join51, resolve:
|
|
109792
|
+
var { dirname: dirname16, join: join51, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
109610
109793
|
var fs2 = __require("fs/promises");
|
|
109611
109794
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
109612
109795
|
try {
|
|
@@ -109651,11 +109834,11 @@ var require_move_file = __commonJS({
|
|
|
109651
109834
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
109652
109835
|
let target = await fs2.readlink(symSource);
|
|
109653
109836
|
if (isAbsolute7(target)) {
|
|
109654
|
-
target =
|
|
109837
|
+
target = resolve27(symDestination, relative15(symSource, target));
|
|
109655
109838
|
}
|
|
109656
109839
|
let targetStat = "file";
|
|
109657
109840
|
try {
|
|
109658
|
-
targetStat = await fs2.stat(
|
|
109841
|
+
targetStat = await fs2.stat(resolve27(dirname16(symSource), target));
|
|
109659
109842
|
if (targetStat.isDirectory()) {
|
|
109660
109843
|
targetStat = "junction";
|
|
109661
109844
|
}
|
|
@@ -109886,7 +110069,7 @@ async function pMap(iterable, mapper, {
|
|
|
109886
110069
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
109887
110070
|
signal?.removeEventListener("abort", signalListener);
|
|
109888
110071
|
}, "cleanup");
|
|
109889
|
-
const
|
|
110072
|
+
const resolve27 = /* @__PURE__ */ __name((value) => {
|
|
109890
110073
|
resolve_(value);
|
|
109891
110074
|
cleanup();
|
|
109892
110075
|
}, "resolve");
|
|
@@ -109918,7 +110101,7 @@ async function pMap(iterable, mapper, {
|
|
|
109918
110101
|
}
|
|
109919
110102
|
isResolved = true;
|
|
109920
110103
|
if (skippedIndexesMap.size === 0) {
|
|
109921
|
-
|
|
110104
|
+
resolve27(result);
|
|
109922
110105
|
return;
|
|
109923
110106
|
}
|
|
109924
110107
|
const pureResult = [];
|
|
@@ -109928,7 +110111,7 @@ async function pMap(iterable, mapper, {
|
|
|
109928
110111
|
}
|
|
109929
110112
|
pureResult.push(value);
|
|
109930
110113
|
}
|
|
109931
|
-
|
|
110114
|
+
resolve27(pureResult);
|
|
109932
110115
|
}
|
|
109933
110116
|
return;
|
|
109934
110117
|
}
|
|
@@ -115274,8 +115457,8 @@ var require_verify = __commonJS({
|
|
|
115274
115457
|
liveContent.add(integrity[algo].toString());
|
|
115275
115458
|
}
|
|
115276
115459
|
});
|
|
115277
|
-
await new Promise((
|
|
115278
|
-
indexStream.on("end",
|
|
115460
|
+
await new Promise((resolve27, reject) => {
|
|
115461
|
+
indexStream.on("end", resolve27).on("error", reject);
|
|
115279
115462
|
});
|
|
115280
115463
|
const contentDir = contentPath.contentDir(cache);
|
|
115281
115464
|
const files = await glob(path3.join(contentDir, "**"), {
|
|
@@ -115665,12 +115848,12 @@ var require_lib9 = __commonJS({
|
|
|
115665
115848
|
return process.emit("input", "end", ...args);
|
|
115666
115849
|
}, "end"),
|
|
115667
115850
|
read: /* @__PURE__ */ __name(function(...args) {
|
|
115668
|
-
let
|
|
115851
|
+
let resolve27, reject;
|
|
115669
115852
|
const promise = new Promise((_resolve, _reject) => {
|
|
115670
|
-
|
|
115853
|
+
resolve27 = _resolve;
|
|
115671
115854
|
reject = _reject;
|
|
115672
115855
|
});
|
|
115673
|
-
process.emit("input", "read",
|
|
115856
|
+
process.emit("input", "read", resolve27, reject, ...args);
|
|
115674
115857
|
return promise;
|
|
115675
115858
|
}, "read")
|
|
115676
115859
|
}
|
|
@@ -116819,8 +117002,8 @@ var require_helpers = __commonJS({
|
|
|
116819
117002
|
function req(url3, opts = {}) {
|
|
116820
117003
|
const href = typeof url3 === "string" ? url3 : url3.href;
|
|
116821
117004
|
const req2 = (href.startsWith("https:") ? https : http2).request(url3, opts);
|
|
116822
|
-
const promise = new Promise((
|
|
116823
|
-
req2.once("response",
|
|
117005
|
+
const promise = new Promise((resolve27, reject) => {
|
|
117006
|
+
req2.once("response", resolve27).once("error", reject).end();
|
|
116824
117007
|
});
|
|
116825
117008
|
req2.then = promise.then.bind(promise);
|
|
116826
117009
|
return req2;
|
|
@@ -117135,7 +117318,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
117135
117318
|
var debug_1 = __importDefault(require_src2());
|
|
117136
117319
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
117137
117320
|
function parseProxyResponse(socket) {
|
|
117138
|
-
return new Promise((
|
|
117321
|
+
return new Promise((resolve27, reject) => {
|
|
117139
117322
|
let buffersLength = 0;
|
|
117140
117323
|
const buffers = [];
|
|
117141
117324
|
function read() {
|
|
@@ -117205,7 +117388,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
117205
117388
|
}
|
|
117206
117389
|
debug("got proxy server response: %o %o", firstLine3, headers);
|
|
117207
117390
|
cleanup();
|
|
117208
|
-
|
|
117391
|
+
resolve27({
|
|
117209
117392
|
connect: {
|
|
117210
117393
|
statusCode,
|
|
117211
117394
|
statusText,
|
|
@@ -121304,12 +121487,12 @@ var require_socksclient = __commonJS({
|
|
|
121304
121487
|
"use strict";
|
|
121305
121488
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
121306
121489
|
function adopt(value) {
|
|
121307
|
-
return value instanceof P2 ? value : new P2(function(
|
|
121308
|
-
|
|
121490
|
+
return value instanceof P2 ? value : new P2(function(resolve27) {
|
|
121491
|
+
resolve27(value);
|
|
121309
121492
|
});
|
|
121310
121493
|
}
|
|
121311
121494
|
__name(adopt, "adopt");
|
|
121312
|
-
return new (P2 || (P2 = Promise))(function(
|
|
121495
|
+
return new (P2 || (P2 = Promise))(function(resolve27, reject) {
|
|
121313
121496
|
function fulfilled(value) {
|
|
121314
121497
|
try {
|
|
121315
121498
|
step2(generator.next(value));
|
|
@@ -121327,7 +121510,7 @@ var require_socksclient = __commonJS({
|
|
|
121327
121510
|
}
|
|
121328
121511
|
__name(rejected, "rejected");
|
|
121329
121512
|
function step2(result) {
|
|
121330
|
-
result.done ?
|
|
121513
|
+
result.done ? resolve27(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
121331
121514
|
}
|
|
121332
121515
|
__name(step2, "step");
|
|
121333
121516
|
step2((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -121365,13 +121548,13 @@ var require_socksclient = __commonJS({
|
|
|
121365
121548
|
* @returns { Promise }
|
|
121366
121549
|
*/
|
|
121367
121550
|
static createConnection(options2, callback) {
|
|
121368
|
-
return new Promise((
|
|
121551
|
+
return new Promise((resolve27, reject) => {
|
|
121369
121552
|
try {
|
|
121370
121553
|
(0, helpers_1.validateSocksClientOptions)(options2, ["connect"]);
|
|
121371
121554
|
} catch (err) {
|
|
121372
121555
|
if (typeof callback === "function") {
|
|
121373
121556
|
callback(err);
|
|
121374
|
-
return
|
|
121557
|
+
return resolve27(err);
|
|
121375
121558
|
} else {
|
|
121376
121559
|
return reject(err);
|
|
121377
121560
|
}
|
|
@@ -121382,16 +121565,16 @@ var require_socksclient = __commonJS({
|
|
|
121382
121565
|
client.removeAllListeners();
|
|
121383
121566
|
if (typeof callback === "function") {
|
|
121384
121567
|
callback(null, info2);
|
|
121385
|
-
|
|
121568
|
+
resolve27(info2);
|
|
121386
121569
|
} else {
|
|
121387
|
-
|
|
121570
|
+
resolve27(info2);
|
|
121388
121571
|
}
|
|
121389
121572
|
});
|
|
121390
121573
|
client.once("error", (err) => {
|
|
121391
121574
|
client.removeAllListeners();
|
|
121392
121575
|
if (typeof callback === "function") {
|
|
121393
121576
|
callback(err);
|
|
121394
|
-
|
|
121577
|
+
resolve27(err);
|
|
121395
121578
|
} else {
|
|
121396
121579
|
reject(err);
|
|
121397
121580
|
}
|
|
@@ -121408,13 +121591,13 @@ var require_socksclient = __commonJS({
|
|
|
121408
121591
|
* @returns { Promise }
|
|
121409
121592
|
*/
|
|
121410
121593
|
static createConnectionChain(options2, callback) {
|
|
121411
|
-
return new Promise((
|
|
121594
|
+
return new Promise((resolve27, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
121412
121595
|
try {
|
|
121413
121596
|
(0, helpers_1.validateSocksClientChainOptions)(options2);
|
|
121414
121597
|
} catch (err) {
|
|
121415
121598
|
if (typeof callback === "function") {
|
|
121416
121599
|
callback(err);
|
|
121417
|
-
return
|
|
121600
|
+
return resolve27(err);
|
|
121418
121601
|
} else {
|
|
121419
121602
|
return reject(err);
|
|
121420
121603
|
}
|
|
@@ -121440,14 +121623,14 @@ var require_socksclient = __commonJS({
|
|
|
121440
121623
|
}
|
|
121441
121624
|
if (typeof callback === "function") {
|
|
121442
121625
|
callback(null, { socket: sock });
|
|
121443
|
-
|
|
121626
|
+
resolve27({ socket: sock });
|
|
121444
121627
|
} else {
|
|
121445
|
-
|
|
121628
|
+
resolve27({ socket: sock });
|
|
121446
121629
|
}
|
|
121447
121630
|
} catch (err) {
|
|
121448
121631
|
if (typeof callback === "function") {
|
|
121449
121632
|
callback(err);
|
|
121450
|
-
|
|
121633
|
+
resolve27(err);
|
|
121451
121634
|
} else {
|
|
121452
121635
|
reject(err);
|
|
121453
121636
|
}
|
|
@@ -122135,12 +122318,12 @@ var require_dist9 = __commonJS({
|
|
|
122135
122318
|
let { host } = opts;
|
|
122136
122319
|
const { port, lookup: lookupFn = dns.lookup } = opts;
|
|
122137
122320
|
if (shouldLookup) {
|
|
122138
|
-
host = await new Promise((
|
|
122321
|
+
host = await new Promise((resolve27, reject) => {
|
|
122139
122322
|
lookupFn(host, {}, (err, res) => {
|
|
122140
122323
|
if (err) {
|
|
122141
122324
|
reject(err);
|
|
122142
122325
|
} else {
|
|
122143
|
-
|
|
122326
|
+
resolve27(res);
|
|
122144
122327
|
}
|
|
122145
122328
|
});
|
|
122146
122329
|
});
|
|
@@ -122997,8 +123180,8 @@ var require_entry = __commonJS({
|
|
|
122997
123180
|
let body = null;
|
|
122998
123181
|
if (this.response.status === 200) {
|
|
122999
123182
|
let cacheWriteResolve, cacheWriteReject;
|
|
123000
|
-
const cacheWritePromise = new Promise((
|
|
123001
|
-
cacheWriteResolve =
|
|
123183
|
+
const cacheWritePromise = new Promise((resolve27, reject) => {
|
|
123184
|
+
cacheWriteResolve = resolve27;
|
|
123002
123185
|
cacheWriteReject = reject;
|
|
123003
123186
|
}).catch((err) => {
|
|
123004
123187
|
body.emit("error", err);
|
|
@@ -128730,12 +128913,12 @@ var require_fetcher = __commonJS({
|
|
|
128730
128913
|
};
|
|
128731
128914
|
exports.DefaultFetcher = DefaultFetcher;
|
|
128732
128915
|
var writeBufferToStream = /* @__PURE__ */ __name(async (stream, buffer) => {
|
|
128733
|
-
return new Promise((
|
|
128916
|
+
return new Promise((resolve27, reject) => {
|
|
128734
128917
|
stream.write(buffer, (err) => {
|
|
128735
128918
|
if (err) {
|
|
128736
128919
|
reject(err);
|
|
128737
128920
|
}
|
|
128738
|
-
|
|
128921
|
+
resolve27(true);
|
|
128739
128922
|
});
|
|
128740
128923
|
});
|
|
128741
128924
|
}, "writeBufferToStream");
|
|
@@ -129440,7 +129623,7 @@ var require_target = __commonJS({
|
|
|
129440
129623
|
var error_1 = require_error9();
|
|
129441
129624
|
async function readTarget(tuf, targetPath) {
|
|
129442
129625
|
const path3 = await getTargetPath(tuf, targetPath);
|
|
129443
|
-
return new Promise((
|
|
129626
|
+
return new Promise((resolve27, reject) => {
|
|
129444
129627
|
fs_1.default.readFile(path3, "utf-8", (err, data2) => {
|
|
129445
129628
|
if (err) {
|
|
129446
129629
|
reject(new error_1.TUFError({
|
|
@@ -129449,7 +129632,7 @@ var require_target = __commonJS({
|
|
|
129449
129632
|
cause: err
|
|
129450
129633
|
}));
|
|
129451
129634
|
} else {
|
|
129452
|
-
|
|
129635
|
+
resolve27(data2);
|
|
129453
129636
|
}
|
|
129454
129637
|
});
|
|
129455
129638
|
});
|
|
@@ -131885,7 +132068,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
131885
132068
|
`--userconfig=${userConfigPath}`,
|
|
131886
132069
|
`--globalconfig=${globalConfigPath}`
|
|
131887
132070
|
];
|
|
131888
|
-
await new Promise((
|
|
132071
|
+
await new Promise((resolve27, reject) => {
|
|
131889
132072
|
const child = spawn6(npmCommand, pinnedArgs, {
|
|
131890
132073
|
cwd,
|
|
131891
132074
|
env: pinnedNpmEnvironment(ambientEnvironment, userConfigPath, globalConfigPath, registry2, proxy),
|
|
@@ -131895,7 +132078,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
131895
132078
|
child.once("error", reject);
|
|
131896
132079
|
child.once("exit", (code, signal) => {
|
|
131897
132080
|
if (code === 0)
|
|
131898
|
-
|
|
132081
|
+
resolve27();
|
|
131899
132082
|
else
|
|
131900
132083
|
reject(new Error(`npm install failed${signal ? ` with signal ${signal}` : ` with exit code ${code ?? "unknown"}`}`));
|
|
131901
132084
|
});
|
|
@@ -131951,12 +132134,12 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
131951
132134
|
unexpected.push(`CONNECT ${request2.url ?? ""}`);
|
|
131952
132135
|
socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n");
|
|
131953
132136
|
});
|
|
131954
|
-
await new Promise((
|
|
132137
|
+
await new Promise((resolve27, reject) => {
|
|
131955
132138
|
const onError = /* @__PURE__ */ __name((cause) => reject(cause), "onError");
|
|
131956
132139
|
server.once("error", onError);
|
|
131957
132140
|
server.listen(0, "127.0.0.1", () => {
|
|
131958
132141
|
server.off("error", onError);
|
|
131959
|
-
|
|
132142
|
+
resolve27();
|
|
131960
132143
|
});
|
|
131961
132144
|
});
|
|
131962
132145
|
const address = server.address();
|
|
@@ -131970,8 +132153,8 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
131970
132153
|
throw new Error(`npm attempted network access outside the authenticated artifact: ${unexpected[0]}`);
|
|
131971
132154
|
}
|
|
131972
132155
|
}, "assertNoUnexpectedRequests"),
|
|
131973
|
-
close: /* @__PURE__ */ __name(() => new Promise((
|
|
131974
|
-
server.close((cause) => cause ? reject(cause) :
|
|
132156
|
+
close: /* @__PURE__ */ __name(() => new Promise((resolve27, reject) => {
|
|
132157
|
+
server.close((cause) => cause ? reject(cause) : resolve27());
|
|
131975
132158
|
}), "close")
|
|
131976
132159
|
};
|
|
131977
132160
|
}
|
|
@@ -132781,8 +132964,8 @@ var init_usage = __esm({
|
|
|
132781
132964
|
|
|
132782
132965
|
// dist/commands/git.js
|
|
132783
132966
|
import { execFileSync } from "node:child_process";
|
|
132784
|
-
function
|
|
132785
|
-
return new Promise((
|
|
132967
|
+
function sleep3(ms2) {
|
|
132968
|
+
return new Promise((resolve27) => setTimeout(resolve27, ms2));
|
|
132786
132969
|
}
|
|
132787
132970
|
function projectRef2(explicit) {
|
|
132788
132971
|
if (explicit)
|
|
@@ -132838,7 +133021,7 @@ async function waitForChoices(client, repoName, quiet) {
|
|
|
132838
133021
|
} else if (choices.length > 0) {
|
|
132839
133022
|
return choices;
|
|
132840
133023
|
}
|
|
132841
|
-
await
|
|
133024
|
+
await sleep3(2e3);
|
|
132842
133025
|
}
|
|
132843
133026
|
throw new Error(`The wait for GitHub authorization ended. Run \`${cliInvocation()} git connect\` again.`);
|
|
132844
133027
|
}
|
|
@@ -132887,7 +133070,7 @@ async function waitForDeploy(client, projectId, commitSha) {
|
|
|
132887
133070
|
throw new Error(connection.last_error || `Deploy of ${commitSha.slice(0, 7)} failed.`);
|
|
132888
133071
|
}
|
|
132889
133072
|
}
|
|
132890
|
-
await
|
|
133073
|
+
await sleep3(DEPLOY_POLL_MS);
|
|
132891
133074
|
}
|
|
132892
133075
|
throw new Error(`The wait ended before deploy of ${commitSha.slice(0, 7)} finished. Check the project logs.`);
|
|
132893
133076
|
}
|
|
@@ -133023,7 +133206,7 @@ var init_git = __esm({
|
|
|
133023
133206
|
DASHBOARD = "https://somewhere.cloud/app";
|
|
133024
133207
|
INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
133025
133208
|
DEPLOY_POLL_MS = 1500;
|
|
133026
|
-
__name(
|
|
133209
|
+
__name(sleep3, "sleep");
|
|
133027
133210
|
__name(projectRef2, "projectRef");
|
|
133028
133211
|
__name(inferGitHubRepo, "inferGitHubRepo");
|
|
133029
133212
|
__name(listInstallations, "listInstallations");
|
|
@@ -133037,7 +133220,125 @@ var init_git = __esm({
|
|
|
133037
133220
|
}
|
|
133038
133221
|
});
|
|
133039
133222
|
|
|
133223
|
+
// dist/lib/test-preview-job.js
|
|
133224
|
+
function rowCountChanges(before, after) {
|
|
133225
|
+
if (!before || !after || Object.keys(before).length !== Object.keys(after).length)
|
|
133226
|
+
return void 0;
|
|
133227
|
+
if (Object.keys(before).some((table2) => !Object.hasOwn(after, table2)))
|
|
133228
|
+
return void 0;
|
|
133229
|
+
return Object.keys(after).sort().filter((table2) => before[table2] !== after[table2]).map((table2) => ({ table: table2, before: before[table2], after: after[table2] }));
|
|
133230
|
+
}
|
|
133231
|
+
async function runPreviewScheduleTest(client, cronId, target, twice, report2, sleep5 = (ms2) => new Promise((resolve27) => setTimeout(resolve27, ms2))) {
|
|
133232
|
+
const path3 = `/cron/${encodeURIComponent(cronId)}/run-preview`;
|
|
133233
|
+
const validTarget = /* @__PURE__ */ __name((value) => value.preview_session_id === target.preview_session_id && value.preview_id === target.preview_id, "validTarget");
|
|
133234
|
+
const first = await client.call("GET", path3, void 0, { ...target, counts: twice ? 1 : void 0 });
|
|
133235
|
+
if (!validTarget(first) || !first.notice)
|
|
133236
|
+
throw new Error("The platform did not confirm the preview job test target.");
|
|
133237
|
+
report2(first.notice);
|
|
133238
|
+
let before = first.row_counts;
|
|
133239
|
+
let countsReason = first.row_counts_reason;
|
|
133240
|
+
const runs = [];
|
|
133241
|
+
for (let index = 0; index < (twice ? 2 : 1); index++) {
|
|
133242
|
+
let requestId;
|
|
133243
|
+
let jobId;
|
|
133244
|
+
let timeoutSeconds = 270;
|
|
133245
|
+
try {
|
|
133246
|
+
const response = await client.callRaw("POST", path3, target, { captureIncompleteBody: true, redirect: "error" });
|
|
133247
|
+
requestId = response.headers["x-request-id"] ?? response.headers["cf-ray"];
|
|
133248
|
+
const envelope = JSON.parse(response.body);
|
|
133249
|
+
if (response.status >= 400 && response.status < 500 && typeof envelope.error === "string") {
|
|
133250
|
+
runs.push({ status: "refused", duration_ms: null, request_id: requestId, detail: envelope.message ?? envelope.error });
|
|
133251
|
+
break;
|
|
133252
|
+
}
|
|
133253
|
+
const data2 = envelope.data;
|
|
133254
|
+
if (response.status === 202 && data2 && data2.preview_session_id === target.preview_session_id && data2.preview_id === target.preview_id && typeof data2.job_id === "string" && data2.job_id.startsWith("job_")) {
|
|
133255
|
+
jobId = data2.job_id;
|
|
133256
|
+
if (typeof data2.timeout_seconds === "number" && data2.timeout_seconds > 0)
|
|
133257
|
+
timeoutSeconds = Math.min(data2.timeout_seconds, timeoutSeconds);
|
|
133258
|
+
}
|
|
133259
|
+
} catch (error3) {
|
|
133260
|
+
if (error3 instanceof CliApiError)
|
|
133261
|
+
requestId = error3.meta.requestId ?? requestId;
|
|
133262
|
+
}
|
|
133263
|
+
if (!jobId) {
|
|
133264
|
+
runs.push({ status: "unknown", duration_ms: null, request_id: requestId, detail: "Job admission is unknown. The request was not resubmitted." });
|
|
133265
|
+
break;
|
|
133266
|
+
}
|
|
133267
|
+
report2(`Queued job ${jobId}${requestId ? ` (request ${requestId})` : ""}.`);
|
|
133268
|
+
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
133269
|
+
let last;
|
|
133270
|
+
let readFailed = false;
|
|
133271
|
+
while (Date.now() < deadline) {
|
|
133272
|
+
try {
|
|
133273
|
+
const result = await client.call("GET", path3, void 0, { ...target, job_id: jobId, counts: twice ? 1 : void 0 }, { timeoutMs: Math.max(1, deadline - Date.now()), refresh: false });
|
|
133274
|
+
if (!validTarget(result) || result.job?.job_id !== jobId)
|
|
133275
|
+
throw new Error("Unexpected job status receipt");
|
|
133276
|
+
last = result;
|
|
133277
|
+
if (result.job.terminal)
|
|
133278
|
+
break;
|
|
133279
|
+
} catch {
|
|
133280
|
+
readFailed = true;
|
|
133281
|
+
break;
|
|
133282
|
+
}
|
|
133283
|
+
if (Date.now() < deadline)
|
|
133284
|
+
await sleep5(Math.min(1e3, deadline - Date.now()));
|
|
133285
|
+
}
|
|
133286
|
+
const job = last?.job;
|
|
133287
|
+
if (!job?.terminal || job.status === "indeterminate") {
|
|
133288
|
+
const detail = readFailed ? "The job status could not be read." : job?.terminal ? "The job\u2019s execution outcome is indeterminate." : "The job did not reach a terminal status before the wait expired.";
|
|
133289
|
+
runs.push({ status: "unknown", duration_ms: job?.duration_ms ?? null, job_id: jobId, request_id: requestId, detail });
|
|
133290
|
+
break;
|
|
133291
|
+
}
|
|
133292
|
+
const changes = twice ? rowCountChanges(before, last?.row_counts) : void 0;
|
|
133293
|
+
runs.push({
|
|
133294
|
+
status: job.status,
|
|
133295
|
+
duration_ms: job.duration_ms,
|
|
133296
|
+
job_id: jobId,
|
|
133297
|
+
request_id: requestId,
|
|
133298
|
+
...job.error_code ? { detail: job.error_code } : {},
|
|
133299
|
+
...twice ? changes ? { row_count_changes: changes } : { row_counts_reason: last?.row_counts_reason ?? countsReason ?? "Two comparable row count snapshots were unavailable." } : {}
|
|
133300
|
+
});
|
|
133301
|
+
before = last?.row_counts;
|
|
133302
|
+
countsReason = last?.row_counts_reason;
|
|
133303
|
+
}
|
|
133304
|
+
return runs;
|
|
133305
|
+
}
|
|
133306
|
+
async function printPreviewScheduleTest(cronId, preview, twice, json) {
|
|
133307
|
+
const { preview_session_id, preview_id } = await previewCurrentVersion(preview.credential);
|
|
133308
|
+
const version2 = { preview_session_id, preview_id };
|
|
133309
|
+
if (preview.previewSessionId !== version2.preview_session_id)
|
|
133310
|
+
throw new Error("The preview credential did not resolve to this folder\u2019s preview.");
|
|
133311
|
+
const runs = await runPreviewScheduleTest(new ApiClient(getToken()), cronId, version2, twice, (message3) => process.stderr.write(message3 + "\n"));
|
|
133312
|
+
if (json)
|
|
133313
|
+
process.stdout.write(JSON.stringify({ cron_id: cronId, ...version2, runs }) + "\n");
|
|
133314
|
+
else
|
|
133315
|
+
runs.forEach((run, i) => {
|
|
133316
|
+
const receipt = [run.job_id && `job ${run.job_id}`, run.request_id && `request ${run.request_id}`].filter(Boolean).join(", ");
|
|
133317
|
+
const duration3 = run.duration_ms !== null ? ` in ${(run.duration_ms / 1e3).toFixed(2)} s` : "";
|
|
133318
|
+
console.log(`Run ${i + 1} ${run.status}${duration3}${receipt ? ` (${receipt})` : ""}.${run.detail ? ` ${run.detail}` : ""}`);
|
|
133319
|
+
if (run.row_count_changes) {
|
|
133320
|
+
const changes = run.row_count_changes.map(({ table: table2, before, after }) => `${table2} ${before} \u2192 ${after}`);
|
|
133321
|
+
console.log(changes.length ? `Observed row counts changed in ${changes.join(", ")}.` : "No declared table row count changed between reads.");
|
|
133322
|
+
}
|
|
133323
|
+
if (run.row_counts_reason)
|
|
133324
|
+
console.log(`Row count observation unavailable. ${run.row_counts_reason}`);
|
|
133325
|
+
});
|
|
133326
|
+
process.exitCode = runs.some((run) => ["failed", "cancelled"].includes(run.status)) ? 1 : runs.every((run) => run.status === "complete") ? 0 : 2;
|
|
133327
|
+
}
|
|
133328
|
+
var init_test_preview_job = __esm({
|
|
133329
|
+
"dist/lib/test-preview-job.js"() {
|
|
133330
|
+
"use strict";
|
|
133331
|
+
init_client();
|
|
133332
|
+
init_config();
|
|
133333
|
+
init_preview_jobs();
|
|
133334
|
+
__name(rowCountChanges, "rowCountChanges");
|
|
133335
|
+
__name(runPreviewScheduleTest, "runPreviewScheduleTest");
|
|
133336
|
+
__name(printPreviewScheduleTest, "printPreviewScheduleTest");
|
|
133337
|
+
}
|
|
133338
|
+
});
|
|
133339
|
+
|
|
133040
133340
|
// dist/commands/cron.js
|
|
133341
|
+
import { setTimeout as sleep4 } from "node:timers/promises";
|
|
133041
133342
|
function parsePayload(value) {
|
|
133042
133343
|
if (value === void 0)
|
|
133043
133344
|
return void 0;
|
|
@@ -133118,16 +133419,38 @@ function parseWaitTimeout(value) {
|
|
|
133118
133419
|
function isTerminalJobStatus(status) {
|
|
133119
133420
|
return status === JOB_SUCCESS_STATUS || JOB_FAILURE_STATUSES.has(status);
|
|
133120
133421
|
}
|
|
133121
|
-
async function waitForJob(
|
|
133422
|
+
async function waitForJob(admitted, timeoutSeconds, firstDelayMs) {
|
|
133423
|
+
const client = new ApiClient(getToken());
|
|
133424
|
+
const path3 = "/jobs/" + encodeURIComponent(admitted.job_id);
|
|
133122
133425
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
133123
|
-
|
|
133124
|
-
|
|
133125
|
-
|
|
133126
|
-
return { job, timedOut: false };
|
|
133426
|
+
let job = admitted;
|
|
133427
|
+
let delay2 = firstDelayMs;
|
|
133428
|
+
for (let attempt = 0; ; attempt++) {
|
|
133127
133429
|
const remaining = deadline - Date.now();
|
|
133128
|
-
if (
|
|
133430
|
+
if (delay2 >= remaining) {
|
|
133431
|
+
if (remaining > 0)
|
|
133432
|
+
await sleep4(remaining);
|
|
133129
133433
|
return { job, timedOut: true };
|
|
133130
|
-
|
|
133434
|
+
}
|
|
133435
|
+
if (delay2)
|
|
133436
|
+
await sleep4(delay2);
|
|
133437
|
+
let retryAfter;
|
|
133438
|
+
try {
|
|
133439
|
+
const view = jobView(await client.call("GET", path3, void 0, void 0, {
|
|
133440
|
+
onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
133441
|
+
retryAfter = Math.max(retryAfter ?? 0, ms2);
|
|
133442
|
+
}, "onRetryAfter")
|
|
133443
|
+
}));
|
|
133444
|
+
if (isTerminalJobStatus(view.status))
|
|
133445
|
+
return { job: view, timedOut: false };
|
|
133446
|
+
job = view;
|
|
133447
|
+
} catch (error3) {
|
|
133448
|
+
const hint = error3 instanceof CliApiError ? error3.meta.retryAfterMs : void 0;
|
|
133449
|
+
if (retryAfter === void 0 && hint === void 0)
|
|
133450
|
+
throw error3;
|
|
133451
|
+
retryAfter = Math.max(retryAfter ?? 0, hint ?? 0);
|
|
133452
|
+
}
|
|
133453
|
+
delay2 = Math.max(interactivePollDelay(attempt), retryAfter ?? 0);
|
|
133131
133454
|
}
|
|
133132
133455
|
}
|
|
133133
133456
|
function observedCronConfig(cron) {
|
|
@@ -133380,7 +133703,13 @@ function printCronMutation(verb, value) {
|
|
|
133380
133703
|
async function runCronInPreview(cronId, opts, timeoutSeconds) {
|
|
133381
133704
|
const tool = await folderPreviewTool({});
|
|
133382
133705
|
const version2 = await previewCurrentVersion(tool.credential);
|
|
133383
|
-
|
|
133706
|
+
let firstDelayMs = 0;
|
|
133707
|
+
const value = await callPlatformTool("cron_run", { cron_id: cronId, preview_session_id: version2.preview_session_id, preview_id: version2.preview_id }, {
|
|
133708
|
+
allTools: true,
|
|
133709
|
+
onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
133710
|
+
firstDelayMs = Math.max(firstDelayMs, ms2);
|
|
133711
|
+
}, "onRetryAfter")
|
|
133712
|
+
});
|
|
133384
133713
|
const result = cronRunResult(value);
|
|
133385
133714
|
if (!opts.wait) {
|
|
133386
133715
|
if (opts.json) {
|
|
@@ -133393,7 +133722,7 @@ async function runCronInPreview(cronId, opts, timeoutSeconds) {
|
|
|
133393
133722
|
}
|
|
133394
133723
|
if (!opts.json)
|
|
133395
133724
|
console.log(dim(`Job ${result.job_id} queued in preview ${version2.preview_session_id} for cron ${result.cron_id}; waiting up to ${timeoutSeconds}s\u2026`));
|
|
133396
|
-
const { job, timedOut } = await waitForPreviewJob(tool.credential, result.job_id, timeoutSeconds);
|
|
133725
|
+
const { job, timedOut } = await waitForPreviewJob(tool.credential, result.job_id, timeoutSeconds, firstDelayMs);
|
|
133397
133726
|
const succeeded = !timedOut && job.status === JOB_SUCCESS_STATUS;
|
|
133398
133727
|
if (!succeeded)
|
|
133399
133728
|
process.exitCode = 1;
|
|
@@ -133458,19 +133787,32 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
|
|
|
133458
133787
|
console.log(dim(policy));
|
|
133459
133788
|
});
|
|
133460
133789
|
});
|
|
133461
|
-
cron.command("run <cron-id-or-name>").description("Queue one run of a scheduled task now without changing its schedule; --wait waits for it to finish").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--wait", "Wait for the queued job to finish and print its result; exits non-zero on failure or timeout").option("--preview", "Run the task's handler and payload once in this folder's open preview instead (its code, data, files and mail); the production schedule never changes").option("--timeout <seconds>", `With --wait, how long to wait before giving up (default ${DEFAULT_WAIT_TIMEOUT_SECONDS})`).option("--json", "Print the complete response as JSON").addHelpText("after", "\nWithout --wait the command returns as soon as the job is queued; the task has not run yet,\nso anything it writes may not be visible for a few seconds. Pass --wait before reading its effects.\n").action(async (target, opts) => {
|
|
133790
|
+
cron.command("run <cron-id-or-name>").description("Queue one run of a scheduled task now without changing its schedule; --wait waits for it to finish").option("-p, --project <project>", "Project slug or ID used to resolve a task name; defaults to the linked project").option("--wait", "Wait for the queued job to finish and print its result; exits non-zero on failure or timeout").option("--preview", "Run the task's handler and payload once in this folder's open preview instead (its code, data, files and mail); the production schedule never changes").option("--twice", "With --preview, wait for each of two runs and report declared table row count changes").option("--timeout <seconds>", `With --wait, how long to wait before giving up (default ${DEFAULT_WAIT_TIMEOUT_SECONDS})`).option("--json", "Print the complete response as JSON").addHelpText("after", "\nWithout --wait the command returns as soon as the job is queued; the task has not run yet,\nso anything it writes may not be visible for a few seconds. Pass --wait before reading its effects.\n").action(async (target, opts) => {
|
|
133462
133791
|
let queued = false;
|
|
133463
133792
|
try {
|
|
133793
|
+
if (opts.twice && (!opts.preview || opts.timeout !== void 0)) {
|
|
133794
|
+
throw new Error("USAGE_ERROR: --twice requires --preview and uses the platform job timeout.");
|
|
133795
|
+
}
|
|
133464
133796
|
const timeoutSeconds = parseWaitTimeout(opts.timeout);
|
|
133465
133797
|
if (opts.timeout !== void 0 && !opts.wait) {
|
|
133466
133798
|
throw new Error("USAGE_ERROR: --timeout only applies with --wait.");
|
|
133467
133799
|
}
|
|
133468
133800
|
const cronId = await resolveCronId(target, opts.project);
|
|
133469
133801
|
if (opts.preview) {
|
|
133802
|
+
if (opts.twice) {
|
|
133803
|
+
await printPreviewScheduleTest(cronId, await folderPreviewTool({}), true, Boolean(opts.json));
|
|
133804
|
+
return;
|
|
133805
|
+
}
|
|
133470
133806
|
await runCronInPreview(cronId, opts, timeoutSeconds);
|
|
133471
133807
|
return;
|
|
133472
133808
|
}
|
|
133473
|
-
|
|
133809
|
+
let firstDelayMs = 0;
|
|
133810
|
+
const value = await callPlatformTool("cron_run", { cron_id: cronId }, {
|
|
133811
|
+
allTools: true,
|
|
133812
|
+
onRetryAfter: /* @__PURE__ */ __name((ms2) => {
|
|
133813
|
+
firstDelayMs = Math.max(firstDelayMs, ms2);
|
|
133814
|
+
}, "onRetryAfter")
|
|
133815
|
+
});
|
|
133474
133816
|
queued = true;
|
|
133475
133817
|
if (!opts.wait) {
|
|
133476
133818
|
if (opts.json) {
|
|
@@ -133486,7 +133828,7 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
|
|
|
133486
133828
|
const result = cronRunResult(value);
|
|
133487
133829
|
if (!opts.json)
|
|
133488
133830
|
console.log(dim(`Job ${result.job_id} queued for cron ${result.cron_id}; waiting up to ${timeoutSeconds}s\u2026`));
|
|
133489
|
-
const { job, timedOut } = await waitForJob(result
|
|
133831
|
+
const { job, timedOut } = await waitForJob(result, timeoutSeconds, firstDelayMs);
|
|
133490
133832
|
const succeeded = !timedOut && job.status === JOB_SUCCESS_STATUS;
|
|
133491
133833
|
if (!succeeded)
|
|
133492
133834
|
process.exitCode = 1;
|
|
@@ -133622,10 +133964,13 @@ var DEFAULT_WAIT_TIMEOUT_SECONDS, WAIT_POLL_INTERVAL_MS, JOB_SUCCESS_STATUS, JOB
|
|
|
133622
133964
|
var init_cron = __esm({
|
|
133623
133965
|
"dist/commands/cron.js"() {
|
|
133624
133966
|
"use strict";
|
|
133967
|
+
init_test_preview_job();
|
|
133625
133968
|
init_cli_invocation();
|
|
133969
|
+
init_client();
|
|
133626
133970
|
init_config();
|
|
133627
133971
|
init_next_actions();
|
|
133628
133972
|
init_platform_tools();
|
|
133973
|
+
init_poll_delay();
|
|
133629
133974
|
init_preview_jobs();
|
|
133630
133975
|
init_platform_command();
|
|
133631
133976
|
init_output();
|
|
@@ -134100,7 +134445,7 @@ async function signUpSteps(run, page, options2) {
|
|
|
134100
134445
|
if (!attempt.submitted)
|
|
134101
134446
|
return;
|
|
134102
134447
|
await registerMailedCodes(run, email2, true);
|
|
134103
|
-
const late = await Promise.race([signedUp, new Promise((
|
|
134448
|
+
const late = await Promise.race([signedUp, new Promise((resolve27) => setTimeout(() => resolve27(new Error("no response yet")), 3e3))]);
|
|
134104
134449
|
if (late instanceof Error)
|
|
134105
134450
|
return;
|
|
134106
134451
|
const known = await outcome(Promise.resolve(late), "sign-up").catch(() => null);
|
|
@@ -134166,7 +134511,7 @@ async function verifySteps(run, page, person) {
|
|
|
134166
134511
|
let confirmed = await step(page, "verify: enter the code in the app", () => post2("/api/auth/verify-email", { code }));
|
|
134167
134512
|
for (let wait = 0; confirmed.status() === 404 && wait < 8; wait++) {
|
|
134168
134513
|
mark("wait", { ms: 250, why: "verify: code not installed yet (404)" });
|
|
134169
|
-
await new Promise((
|
|
134514
|
+
await new Promise((resolve27) => setTimeout(resolve27, 250));
|
|
134170
134515
|
confirmed = await step(page, "verify: enter the code in the app", () => post2("/api/auth/verify-email", { code }));
|
|
134171
134516
|
}
|
|
134172
134517
|
if (confirmed.ok()) {
|
|
@@ -134312,8 +134657,57 @@ var init_form_auth = __esm({
|
|
|
134312
134657
|
}
|
|
134313
134658
|
});
|
|
134314
134659
|
|
|
134315
|
-
// dist/lib/
|
|
134660
|
+
// dist/lib/test-response-capture.js
|
|
134316
134661
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
134662
|
+
function privateMarker() {
|
|
134663
|
+
return "sw-test-" + randomUUID10();
|
|
134664
|
+
}
|
|
134665
|
+
function captureResponses(page) {
|
|
134666
|
+
const pending = [];
|
|
134667
|
+
const listener = /* @__PURE__ */ __name((response) => {
|
|
134668
|
+
const url3 = new URL(response.url());
|
|
134669
|
+
pending.push(response.text().then((body) => ({ url: url3.origin + url3.pathname, status: response.status(), contentType: response.headers()["content-type"] ?? "", body })).catch(() => null));
|
|
134670
|
+
}, "listener");
|
|
134671
|
+
page.on("response", listener);
|
|
134672
|
+
return {
|
|
134673
|
+
/** Every captured response, after each body has been read. */
|
|
134674
|
+
async all() {
|
|
134675
|
+
return (await Promise.all(pending)).filter((c) => c !== null);
|
|
134676
|
+
},
|
|
134677
|
+
/** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
|
|
134678
|
+
async find(secret) {
|
|
134679
|
+
return (await this.all()).filter((c) => c.body.includes(secret)).map((c) => {
|
|
134680
|
+
const at2 = c.body.indexOf(secret);
|
|
134681
|
+
return { url: c.url, status: c.status, contentType: c.contentType, around: c.body.slice(Math.max(0, at2 - 60), at2 + secret.length + 60) };
|
|
134682
|
+
});
|
|
134683
|
+
},
|
|
134684
|
+
stop() {
|
|
134685
|
+
page.off("response", listener);
|
|
134686
|
+
}
|
|
134687
|
+
};
|
|
134688
|
+
}
|
|
134689
|
+
async function assertNoLeak(marker, responses) {
|
|
134690
|
+
if (!marker)
|
|
134691
|
+
throw new Error("Use a nonempty test marker.");
|
|
134692
|
+
for (const response of responses) {
|
|
134693
|
+
const body = response instanceof Response ? await response.clone().text() : response.body;
|
|
134694
|
+
if (body.includes(marker)) {
|
|
134695
|
+
const path3 = new URL(response.url).pathname.replaceAll(marker, ":marker");
|
|
134696
|
+
throw new Error(`Private test marker appeared in ${path3} (HTTP ${response.status}).`);
|
|
134697
|
+
}
|
|
134698
|
+
}
|
|
134699
|
+
}
|
|
134700
|
+
var init_test_response_capture = __esm({
|
|
134701
|
+
"dist/lib/test-response-capture.js"() {
|
|
134702
|
+
"use strict";
|
|
134703
|
+
__name(privateMarker, "privateMarker");
|
|
134704
|
+
__name(captureResponses, "captureResponses");
|
|
134705
|
+
__name(assertNoLeak, "assertNoLeak");
|
|
134706
|
+
}
|
|
134707
|
+
});
|
|
134708
|
+
|
|
134709
|
+
// dist/lib/app-test.js
|
|
134710
|
+
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
134317
134711
|
import { setDefaultResultOrder } from "node:dns";
|
|
134318
134712
|
import { lookup } from "node:dns/promises";
|
|
134319
134713
|
import { existsSync as existsSync37, mkdirSync as mkdirSync19, readFileSync as readFileSync41, writeFileSync as writeFileSync25 } from "node:fs";
|
|
@@ -134415,30 +134809,6 @@ function classifyData(status, raw, operation) {
|
|
|
134415
134809
|
function openAppTest(options2) {
|
|
134416
134810
|
return AppTest.open(options2);
|
|
134417
134811
|
}
|
|
134418
|
-
function captureResponses(page) {
|
|
134419
|
-
const pending = [];
|
|
134420
|
-
const listener = /* @__PURE__ */ __name((response) => {
|
|
134421
|
-
const url3 = new URL(response.url());
|
|
134422
|
-
pending.push(response.text().then((body) => ({ url: url3.origin + url3.pathname, status: response.status(), contentType: response.headers()["content-type"] ?? "", body })).catch(() => null));
|
|
134423
|
-
}, "listener");
|
|
134424
|
-
page.on("response", listener);
|
|
134425
|
-
return {
|
|
134426
|
-
/** Every captured response, after each body has been read. */
|
|
134427
|
-
async all() {
|
|
134428
|
-
return (await Promise.all(pending)).filter((c) => c !== null);
|
|
134429
|
-
},
|
|
134430
|
-
/** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
|
|
134431
|
-
async find(secret) {
|
|
134432
|
-
return (await this.all()).filter((c) => c.body.includes(secret)).map((c) => {
|
|
134433
|
-
const at2 = c.body.indexOf(secret);
|
|
134434
|
-
return { url: c.url, status: c.status, contentType: c.contentType, around: c.body.slice(Math.max(0, at2 - 60), at2 + secret.length + 60) };
|
|
134435
|
-
});
|
|
134436
|
-
},
|
|
134437
|
-
stop() {
|
|
134438
|
-
page.off("response", listener);
|
|
134439
|
-
}
|
|
134440
|
-
};
|
|
134441
|
-
}
|
|
134442
134812
|
async function dataReady(scope, timeout = 5e3) {
|
|
134443
134813
|
const root = typeof scope.goto === "function" ? scope.locator(":root") : scope;
|
|
134444
134814
|
const views = root.locator("[data-sw-data]");
|
|
@@ -134472,6 +134842,7 @@ var init_app_test = __esm({
|
|
|
134472
134842
|
init_form_auth();
|
|
134473
134843
|
init_test_diagnostics();
|
|
134474
134844
|
init_test_timeline();
|
|
134845
|
+
init_test_response_capture();
|
|
134475
134846
|
__name(launchOptions, "launchOptions");
|
|
134476
134847
|
__name(describeCheckFailure, "describeCheckFailure");
|
|
134477
134848
|
__name(pageState, "pageState");
|
|
@@ -134558,7 +134929,7 @@ var init_app_test = __esm({
|
|
|
134558
134929
|
const [ipv4First] = await Promise.all([testAddressOrder(target.origin), lookup(new URL(target.origin).hostname).catch(() => null)]);
|
|
134559
134930
|
if (ipv4First)
|
|
134560
134931
|
setDefaultResultOrder("ipv4first");
|
|
134561
|
-
process.env.SW_TEST_RUN ??=
|
|
134932
|
+
process.env.SW_TEST_RUN ??= randomUUID11();
|
|
134562
134933
|
process.env.SW_TEST_ORIGIN = target.origin;
|
|
134563
134934
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
134564
134935
|
process.stderr.write(line + "\n");
|
|
@@ -134780,11 +135151,229 @@ page ${i + 1}: ${state}`).join("");
|
|
|
134780
135151
|
}
|
|
134781
135152
|
};
|
|
134782
135153
|
__name(openAppTest, "openAppTest");
|
|
134783
|
-
__name(captureResponses, "captureResponses");
|
|
134784
135154
|
__name(dataReady, "dataReady");
|
|
134785
135155
|
}
|
|
134786
135156
|
});
|
|
134787
135157
|
|
|
135158
|
+
// dist/lib/test-session.js
|
|
135159
|
+
async function expectStatus(response, expected) {
|
|
135160
|
+
if (response.status !== expected)
|
|
135161
|
+
throw new Error("Expected HTTP " + expected + ", received " + response.status);
|
|
135162
|
+
}
|
|
135163
|
+
async function expectRefusal(response, status, code) {
|
|
135164
|
+
await expectStatus(response, status);
|
|
135165
|
+
const body = await response.json();
|
|
135166
|
+
if (!body || typeof body !== "object" || !("error" in body) || body.error !== code) {
|
|
135167
|
+
throw new Error("Refusal did not have the exact expected error code: " + code);
|
|
135168
|
+
}
|
|
135169
|
+
}
|
|
135170
|
+
async function signIn2(baseUrl, email2, password) {
|
|
135171
|
+
const session = new UserSession(baseUrl);
|
|
135172
|
+
const response = await session.post("/api/auth/login", { email: email2, password });
|
|
135173
|
+
await expectStatus(response, 200);
|
|
135174
|
+
const body = await response.json();
|
|
135175
|
+
if (!body.cookie_session)
|
|
135176
|
+
throw new Error("Sign-in did not establish a cookie session");
|
|
135177
|
+
return session;
|
|
135178
|
+
}
|
|
135179
|
+
async function createUser(baseUrl) {
|
|
135180
|
+
const session = new UserSession(baseUrl);
|
|
135181
|
+
const email2 = "starter-" + crypto.randomUUID() + "@fixture.test.somewhere.site";
|
|
135182
|
+
const password = `A1!${crypto.randomUUID()}`;
|
|
135183
|
+
const response = await session.post("/api/auth/signup", { email: email2, password });
|
|
135184
|
+
await expectStatus(response, 200);
|
|
135185
|
+
const body = await response.json();
|
|
135186
|
+
if (!body.cookie_session)
|
|
135187
|
+
throw new Error("Signup did not establish a cookie session");
|
|
135188
|
+
return session;
|
|
135189
|
+
}
|
|
135190
|
+
var UserSession;
|
|
135191
|
+
var init_test_session = __esm({
|
|
135192
|
+
"dist/lib/test-session.js"() {
|
|
135193
|
+
"use strict";
|
|
135194
|
+
init_client();
|
|
135195
|
+
init_config();
|
|
135196
|
+
init_test_target();
|
|
135197
|
+
init_test_identities();
|
|
135198
|
+
UserSession = class {
|
|
135199
|
+
static {
|
|
135200
|
+
__name(this, "UserSession");
|
|
135201
|
+
}
|
|
135202
|
+
origin;
|
|
135203
|
+
cookies = /* @__PURE__ */ new Map();
|
|
135204
|
+
target;
|
|
135205
|
+
seed;
|
|
135206
|
+
refreshing;
|
|
135207
|
+
constructor(baseUrl, options2 = {}) {
|
|
135208
|
+
this.origin = new URL(baseUrl).origin;
|
|
135209
|
+
if (options2.target && options2.target.origin !== this.origin)
|
|
135210
|
+
throw new Error("The test target belongs to a different app.");
|
|
135211
|
+
this.target = options2.target ? Promise.resolve(options2.target) : void 0;
|
|
135212
|
+
this.seed = options2.storageState ? structuredClone(options2.storageState) : { cookies: [], origins: [] };
|
|
135213
|
+
for (const cookie of this.seed.cookies) {
|
|
135214
|
+
if (cookie.domain === new URL(this.origin).hostname)
|
|
135215
|
+
this.cookies.set(cookie.name, cookie.value);
|
|
135216
|
+
}
|
|
135217
|
+
}
|
|
135218
|
+
/** Standard Playwright state. Treat this value like a signed-in session. */
|
|
135219
|
+
async storageState() {
|
|
135220
|
+
await this.ensureFresh();
|
|
135221
|
+
const url3 = new URL(this.origin);
|
|
135222
|
+
return {
|
|
135223
|
+
cookies: [...this.cookies].map(([name, value]) => {
|
|
135224
|
+
const seed = this.seed.cookies.find((cookie) => cookie.name === name && cookie.domain === url3.hostname);
|
|
135225
|
+
return seed && seed.value === value ? { ...seed } : { name, value, domain: url3.hostname, path: "/", expires: -1, httpOnly: true, secure: url3.protocol === "https:", sameSite: "Lax" };
|
|
135226
|
+
}),
|
|
135227
|
+
origins: this.seed.origins.map((entry) => ({ ...entry, localStorage: entry.localStorage.map((item) => {
|
|
135228
|
+
if (entry.origin !== this.origin)
|
|
135229
|
+
return { ...item };
|
|
135230
|
+
const access = this.cookies.get(ACCESS_COOKIE);
|
|
135231
|
+
const refresh = this.cookies.get(REFRESH_COOKIE);
|
|
135232
|
+
if (item.name === "sw_access_token" && access)
|
|
135233
|
+
return { ...item, value: access };
|
|
135234
|
+
if (item.name !== "sw_auth" || !access || !refresh)
|
|
135235
|
+
return { ...item };
|
|
135236
|
+
const state = JSON.parse(item.value);
|
|
135237
|
+
const times = tokenTimes(access);
|
|
135238
|
+
return { ...item, value: JSON.stringify({
|
|
135239
|
+
...state,
|
|
135240
|
+
token: access,
|
|
135241
|
+
access_token: access,
|
|
135242
|
+
refresh_token: refresh,
|
|
135243
|
+
...times ? { expires_in: times.exp - times.iat, expires_at: times.exp * 1e3 } : {}
|
|
135244
|
+
}) };
|
|
135245
|
+
}) }))
|
|
135246
|
+
};
|
|
135247
|
+
}
|
|
135248
|
+
async request(path3, init = {}) {
|
|
135249
|
+
const url3 = new URL(path3, this.origin);
|
|
135250
|
+
if (url3.origin !== this.origin)
|
|
135251
|
+
throw new Error("Fixture requests must stay on the app origin");
|
|
135252
|
+
if (url3.pathname !== "/api/auth/refresh")
|
|
135253
|
+
await this.ensureFresh();
|
|
135254
|
+
return this.send(url3, init);
|
|
135255
|
+
}
|
|
135256
|
+
async ensureFresh() {
|
|
135257
|
+
if (this.refreshing)
|
|
135258
|
+
return this.refreshing;
|
|
135259
|
+
if (!this.cookies.has(REFRESH_COOKIE) || !testAccessNeedsRefresh(this.cookies.get(ACCESS_COOKIE)))
|
|
135260
|
+
return;
|
|
135261
|
+
const refreshing = this.refresh();
|
|
135262
|
+
this.refreshing = refreshing;
|
|
135263
|
+
try {
|
|
135264
|
+
await refreshing;
|
|
135265
|
+
} finally {
|
|
135266
|
+
this.refreshing = void 0;
|
|
135267
|
+
}
|
|
135268
|
+
}
|
|
135269
|
+
async refresh() {
|
|
135270
|
+
const previous = this.cookies.get(ACCESS_COOKIE);
|
|
135271
|
+
const response = await this.send(new URL("/api/auth/refresh", this.origin), { method: "POST", signal: AbortSignal.timeout(1e4) });
|
|
135272
|
+
if (!response.ok)
|
|
135273
|
+
throw new Error(`The app test session could not refresh (HTTP ${response.status}).`);
|
|
135274
|
+
await response.body?.cancel();
|
|
135275
|
+
const next = this.cookies.get(ACCESS_COOKIE);
|
|
135276
|
+
if (!next || next === previous || testAccessNeedsRefresh(next) || !this.cookies.has(REFRESH_COOKIE)) {
|
|
135277
|
+
throw new Error("The app did not return renewed test-session cookies.");
|
|
135278
|
+
}
|
|
135279
|
+
}
|
|
135280
|
+
async send(url3, init) {
|
|
135281
|
+
const headers = new Headers(init.headers);
|
|
135282
|
+
headers.set("Origin", this.origin);
|
|
135283
|
+
headers.set("Cookie", [...this.cookies].map(([k2, v2]) => k2 + "=" + v2).join("; "));
|
|
135284
|
+
const response = await fetch(url3, { ...init, headers, redirect: "error" });
|
|
135285
|
+
for (const cookie of response.headers.getSetCookie()) {
|
|
135286
|
+
const pair = cookie.split(";")[0];
|
|
135287
|
+
const split = pair.indexOf("=");
|
|
135288
|
+
if (split <= 0)
|
|
135289
|
+
continue;
|
|
135290
|
+
const name = pair.slice(0, split);
|
|
135291
|
+
const value = pair.slice(split + 1);
|
|
135292
|
+
if (!value || /(?:^|;\s*)max-age=0(?:;|$)/i.test(cookie))
|
|
135293
|
+
this.cookies.delete(name);
|
|
135294
|
+
else
|
|
135295
|
+
this.cookies.set(name, value);
|
|
135296
|
+
}
|
|
135297
|
+
return response;
|
|
135298
|
+
}
|
|
135299
|
+
post(path3, body) {
|
|
135300
|
+
return this.request(path3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
135301
|
+
}
|
|
135302
|
+
async data(table2, requestOrContract, request2) {
|
|
135303
|
+
if (typeof requestOrContract === "string") {
|
|
135304
|
+
return this.post("/__sw/data", { ...request2, table: table2, contract: requestOrContract });
|
|
135305
|
+
}
|
|
135306
|
+
if (!this.target) {
|
|
135307
|
+
const projectId = loadProjectConfig()?.project_id;
|
|
135308
|
+
if (!projectId)
|
|
135309
|
+
throw new Error("Use the data helper from a linked project folder.");
|
|
135310
|
+
this.target = fixtureTestTarget(new ApiClient(process.env.SW_TEST_TARGET ? null : getToken()), projectId);
|
|
135311
|
+
}
|
|
135312
|
+
const target = await this.target;
|
|
135313
|
+
if (target.origin !== this.origin)
|
|
135314
|
+
throw new Error("This session belongs to a different app than the linked test target.");
|
|
135315
|
+
return this.post("/__sw/data", { ...requestOrContract, table: table2, contract: target.contractDigest ?? "" });
|
|
135316
|
+
}
|
|
135317
|
+
};
|
|
135318
|
+
__name(expectStatus, "expectStatus");
|
|
135319
|
+
__name(expectRefusal, "expectRefusal");
|
|
135320
|
+
__name(signIn2, "signIn");
|
|
135321
|
+
__name(createUser, "createUser");
|
|
135322
|
+
}
|
|
135323
|
+
});
|
|
135324
|
+
|
|
135325
|
+
// dist/lib/prepared-actor-session.js
|
|
135326
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
135327
|
+
import { closeSync as closeSync6, openSync as openSync6, rmSync as rmSync15 } from "node:fs";
|
|
135328
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
135329
|
+
async function preparedActorSession(root, target, name) {
|
|
135330
|
+
const read = /* @__PURE__ */ __name(() => preparedActorState(root, target, name), "read");
|
|
135331
|
+
const initial = read();
|
|
135332
|
+
if (!testAccessNeedsRefresh(initial.access))
|
|
135333
|
+
return initial.access;
|
|
135334
|
+
const generation = createHash10("sha256").update(initial.access).digest("hex").slice(0, 12);
|
|
135335
|
+
const lock = initial.path + "." + generation + ".refresh.lock";
|
|
135336
|
+
const deadline = Date.now() + 12e3;
|
|
135337
|
+
while (Date.now() < deadline) {
|
|
135338
|
+
let fd;
|
|
135339
|
+
try {
|
|
135340
|
+
fd = openSync6(lock, "wx", 384);
|
|
135341
|
+
} catch (error3) {
|
|
135342
|
+
if (error3.code !== "EEXIST")
|
|
135343
|
+
throw error3;
|
|
135344
|
+
const latest = read();
|
|
135345
|
+
if (!testAccessNeedsRefresh(latest.access))
|
|
135346
|
+
return latest.access;
|
|
135347
|
+
await delay(100);
|
|
135348
|
+
continue;
|
|
135349
|
+
}
|
|
135350
|
+
try {
|
|
135351
|
+
const latest = read();
|
|
135352
|
+
if (!testAccessNeedsRefresh(latest.access))
|
|
135353
|
+
return latest.access;
|
|
135354
|
+
const session = new UserSession(target.origin, { target, storageState: latest.state });
|
|
135355
|
+
const renewed = await session.storageState();
|
|
135356
|
+
const token = renewed.cookies.find((cookie) => cookie.name === ACCESS_COOKIE)?.value;
|
|
135357
|
+
if (!token || testAccessNeedsRefresh(token))
|
|
135358
|
+
throw new Error("The saved test session could not be renewed.");
|
|
135359
|
+
writePrivateFile(latest.path, JSON.stringify(renewed, null, 2) + "\n");
|
|
135360
|
+
return token;
|
|
135361
|
+
} finally {
|
|
135362
|
+
closeSync6(fd);
|
|
135363
|
+
rmSync15(lock, { force: true });
|
|
135364
|
+
}
|
|
135365
|
+
}
|
|
135366
|
+
throw new Error(`Another command is refreshing test user ${name}. Wait for it to finish, or clean up and prepare the test users again.`);
|
|
135367
|
+
}
|
|
135368
|
+
var init_prepared_actor_session = __esm({
|
|
135369
|
+
"dist/lib/prepared-actor-session.js"() {
|
|
135370
|
+
"use strict";
|
|
135371
|
+
init_test_session();
|
|
135372
|
+
init_test_identities();
|
|
135373
|
+
__name(preparedActorSession, "preparedActorSession");
|
|
135374
|
+
}
|
|
135375
|
+
});
|
|
135376
|
+
|
|
134788
135377
|
// dist/commands/data.js
|
|
134789
135378
|
function parseJson(text, flag) {
|
|
134790
135379
|
try {
|
|
@@ -134817,7 +135406,7 @@ function registerData(program2) {
|
|
|
134817
135406
|
if (origin.protocol !== "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(origin.hostname)) {
|
|
134818
135407
|
throw new Error("The linked app needs an HTTPS address.");
|
|
134819
135408
|
}
|
|
134820
|
-
const session = opts.as ? preparedActorSession(process.cwd(), target, opts.as) : process.env.SOMEWHERE_APP_SESSION;
|
|
135409
|
+
const session = opts.as ? await preparedActorSession(process.cwd(), target, opts.as) : process.env.SOMEWHERE_APP_SESSION;
|
|
134821
135410
|
if (!session || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(session)) {
|
|
134822
135411
|
throw new Error("Supply a valid app session token.");
|
|
134823
135412
|
}
|
|
@@ -134840,7 +135429,7 @@ var init_data = __esm({
|
|
|
134840
135429
|
init_app_test();
|
|
134841
135430
|
init_client();
|
|
134842
135431
|
init_config();
|
|
134843
|
-
|
|
135432
|
+
init_prepared_actor_session();
|
|
134844
135433
|
init_test_target();
|
|
134845
135434
|
__name(parseJson, "parseJson");
|
|
134846
135435
|
__name(registerData, "registerData");
|
|
@@ -134878,7 +135467,7 @@ var init_reference_check_note = __esm({
|
|
|
134878
135467
|
|
|
134879
135468
|
// dist/lib/test-scripts.js
|
|
134880
135469
|
import { createRequire as createRequire9 } from "node:module";
|
|
134881
|
-
import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, readdirSync as readdirSync8, rmSync as
|
|
135470
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync20, readFileSync as readFileSync42, readdirSync as readdirSync8, rmSync as rmSync16, statSync as statSync8, writeFileSync as writeFileSync26 } from "node:fs";
|
|
134882
135471
|
import { dirname as dirname15, join as join45, relative as relative13, resolve as resolve25 } from "node:path";
|
|
134883
135472
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
134884
135473
|
function hasSpecFiles(root) {
|
|
@@ -134950,7 +135539,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
134950
135539
|
let output = "";
|
|
134951
135540
|
const handOver = join45(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
134952
135541
|
mkdirSync20(dirname15(handOver), { recursive: true });
|
|
134953
|
-
|
|
135542
|
+
rmSync16(handOver, { force: true });
|
|
134954
135543
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
134955
135544
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
134956
135545
|
const child = spawn7(process.execPath, [script, ...extraArgs], { cwd: root, env: childEnv, stdio: ["inherit", "pipe", "pipe"] });
|
|
@@ -134982,7 +135571,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
134982
135571
|
} catch {
|
|
134983
135572
|
report2 = null;
|
|
134984
135573
|
}
|
|
134985
|
-
|
|
135574
|
+
rmSync16(handOver, { force: true });
|
|
134986
135575
|
results.push({
|
|
134987
135576
|
script,
|
|
134988
135577
|
ok: exitCode === 0,
|
|
@@ -135050,7 +135639,7 @@ var init_test_scripts = __esm({
|
|
|
135050
135639
|
|
|
135051
135640
|
// dist/commands/test.js
|
|
135052
135641
|
function registerTest(program2) {
|
|
135053
|
-
program2.command("test [files...]").description("Read the
|
|
135642
|
+
program2.command("test [files...]").description("Read the deployed app's smoke check. It checks the built-in data path, pages and saved browser flows, and reports function errors with evidence. Use @somewhere-cloud/cli/testing for your own app tests. A named file runs that script.").option("--preview", "Test this folder's open preview (its own users, data copy and captured mail), pinned to the version saved when the run starts. Production is never touched.").option("--workers <count>", "Parallel workers", "5").option("--again", "Start a fresh run of the checks on the live release instead of reading the result of the last deploy's run").option("--only <check>", "Run just access, crawl, or one saved check, e.g. checks/add-note.json").option("--failed", "Rerun what failed last time: each failed tests/*.mjs or *.cjs script, all its checks (specs: only the failed tests)").option("--fail-fast", "Stop app-check scripts at their first failed check").option("--grep <name>", "Filter test names (subset)").option("--url <url>", "Unsupported in phase 1").option("--phone", "Run every test again in a 390x844 phone viewport ([phone] in results)").option("--json", "Print structured results").option("--verbose", "Also print where the full result file is when everything passed").addHelpText("after", "\nSave each journey you want re-checked after every deploy as checks/<plain-name>.json; the platform runs them in its browser after each deploy and `somewhere test` reads the latest result. Use --again for a fresh run. The last line of a platform run is JSON with outcome and counts.\n").action(async (files, opts) => {
|
|
135054
135643
|
markProcessStart("cli");
|
|
135055
135644
|
mark("cli:action");
|
|
135056
135645
|
if (opts.url)
|
|
@@ -135061,15 +135650,22 @@ function registerTest(program2) {
|
|
|
135061
135650
|
const projectId = loadProjectConfig()?.project_id;
|
|
135062
135651
|
if (!projectId)
|
|
135063
135652
|
throw new Error("Run somewhere test from a linked project folder");
|
|
135064
|
-
if (
|
|
135653
|
+
if (opts.only !== void 0 && (files.length || opts.preview || opts.failed)) {
|
|
135654
|
+
throw new Error("--only runs a single part of the hosted smoke check. Use it without file arguments, --preview, or --failed.");
|
|
135655
|
+
}
|
|
135656
|
+
if (opts.only !== void 0 && opts.only !== "access" && opts.only !== "crawl" && !/^checks\/[^/\\\x00-\x1f\x7f]+\.json$/.test(opts.only)) {
|
|
135657
|
+
throw new Error("Choose --only access, --only crawl, or a saved check path like --only checks/add-note.json.");
|
|
135658
|
+
}
|
|
135659
|
+
if (opts.only !== void 0 || !files.length && !opts.preview && !opts.failed && !hasSpecFiles(root)) {
|
|
135065
135660
|
const unsupported = [opts.phone && "--phone", opts.grep && "--grep", opts.workers !== "5" && "--workers", opts.failFast && "--fail-fast"].filter(Boolean);
|
|
135066
135661
|
if (unsupported.length)
|
|
135067
135662
|
throw new Error(`${unsupported.join(", ")} apply to Playwright specs and scripts; the platform runs checks/*.json as saved.`);
|
|
135068
135663
|
let check;
|
|
135069
135664
|
try {
|
|
135070
|
-
check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true });
|
|
135665
|
+
check = await runChecksNow(new ApiClient(getToken()), projectId, { again: opts.again === true, only: opts.only });
|
|
135071
135666
|
} catch (cause) {
|
|
135072
|
-
|
|
135667
|
+
const sentence = cause instanceof Error ? cause.message : "The platform could not start the checks.";
|
|
135668
|
+
check = opts.only ? partialCheckUnavailable(opts.only, sentence) : { status: "unavailable", sentence };
|
|
135073
135669
|
}
|
|
135074
135670
|
mark("cli:exit");
|
|
135075
135671
|
const summary = deployChecksSummary(check);
|
|
@@ -135130,7 +135726,7 @@ var init_test = __esm({
|
|
|
135130
135726
|
});
|
|
135131
135727
|
|
|
135132
135728
|
// dist/commands/test-users.js
|
|
135133
|
-
import { existsSync as existsSync39, readFileSync as readFileSync43, rmSync as
|
|
135729
|
+
import { existsSync as existsSync39, readFileSync as readFileSync43, rmSync as rmSync17 } from "node:fs";
|
|
135134
135730
|
import { basename as basename10, join as join46 } from "node:path";
|
|
135135
135731
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
135136
135732
|
async function resolveTarget(projectOpt, originOpt) {
|
|
@@ -135171,12 +135767,13 @@ function registerTestUsers(program2) {
|
|
|
135171
135767
|
group.command("prepare <actors...>").description("Create preverified test users and write one Playwright storageState file per actor (e.g. alice bob:admin)").option("-p, --project <project>", "Project slug or ID; defaults to the linked project").option("--origin <url>", "Only the project's production origin is supported; anything else is refused").option("--json", "Print the manifest (no tokens) as JSON").addHelpText("after", [
|
|
135172
135768
|
"",
|
|
135173
135769
|
"From the linked project folder, run somewhere test-users prepare alice. It writes .somewhere/test/<actor>.state.json (a standard Playwright storageState) and manifest.json.",
|
|
135174
|
-
'Playwright: browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
|
|
135770
|
+
'Playwright: const alice = await browser.newContext({ storageState: ".somewhere/test/alice.state.json" })',
|
|
135771
|
+
'With data imported from @somewhere-cloud/cli/testing: await data(alice.request, "notes", { operation: "list" })',
|
|
135175
135772
|
'Save the context back after each run: await context.storageState({ path: ".somewhere/test/alice.state.json" })',
|
|
135176
135773
|
"The app refreshes the short-lived access token and rotates the session on its first refresh, so an unsaved",
|
|
135177
|
-
"file stops working after a run that refreshed it.
|
|
135178
|
-
|
|
135179
|
-
"
|
|
135774
|
+
"file stops working after a run that refreshed it. Prepare prints the access token expiry and the initial",
|
|
135775
|
+
"refresh session expiry separately. A refresh can renew the session, and the saved state carries the",
|
|
135776
|
+
"renewal. Remove the identities to end access",
|
|
135180
135777
|
"with `somewhere test-users cleanup` when you are done. To use the same user in a fresh hosted browser, pass its recorded user ID to browser --auth-user."
|
|
135181
135778
|
].join("\n")).action(async (actorValues, opts) => {
|
|
135182
135779
|
let specs;
|
|
@@ -135264,7 +135861,7 @@ function registerTestUsers(program2) {
|
|
|
135264
135861
|
}
|
|
135265
135862
|
for (const actor of manifest.actors) {
|
|
135266
135863
|
info(`${actor.name} (${actor.role}) ${actor.email} user ${actor.user_id}`);
|
|
135267
|
-
info(` ${TEST_STATE_DIR}/${actor.state_file} session until ${actor.session_expires_at}`);
|
|
135864
|
+
info(` ${TEST_STATE_DIR}/${actor.state_file} access token until ${actor.access_expires_at}, refresh session initially until ${actor.session_expires_at}`);
|
|
135268
135865
|
}
|
|
135269
135866
|
if (gitignore !== "present")
|
|
135270
135867
|
info(`${gitignore === "created" ? "Created" : "Updated"} .gitignore to ignore ${TEST_STATE_DIR}/.`);
|
|
@@ -135398,7 +135995,7 @@ function registerTestUsers(program2) {
|
|
|
135398
135995
|
if (left.length)
|
|
135399
135996
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
135400
135997
|
else
|
|
135401
|
-
|
|
135998
|
+
rmSync17(join46(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
135402
135999
|
if (opts.json) {
|
|
135403
136000
|
printJson(receipt);
|
|
135404
136001
|
if (left.length)
|
|
@@ -136825,12 +137422,64 @@ async function refusedAs(person, target, request2, options2) {
|
|
|
136825
137422
|
throw new Error(`expectRefused: ${said}, but ${target} ${String(id)} ${after === null ? "is gone" : "changed"} for the allowed person afterwards.`);
|
|
136826
137423
|
}
|
|
136827
137424
|
}
|
|
136828
|
-
function
|
|
136829
|
-
|
|
136830
|
-
|
|
136831
|
-
|
|
137425
|
+
async function refreshTestContext(client, origin) {
|
|
137426
|
+
const ongoing = contextRefreshes.get(client);
|
|
137427
|
+
if (ongoing)
|
|
137428
|
+
return ongoing;
|
|
137429
|
+
const work = (async () => {
|
|
137430
|
+
const hostname3 = new URL(origin).hostname;
|
|
137431
|
+
const cookie = /* @__PURE__ */ __name((state2, name) => state2.cookies.find((item) => item.domain === hostname3 && item.path === "/" && item.name === name)?.value, "cookie");
|
|
137432
|
+
const state = await client.storageState();
|
|
137433
|
+
const previous = cookie(state, ACCESS_COOKIE);
|
|
137434
|
+
if (!cookie(state, REFRESH_COOKIE) || !testAccessNeedsRefresh(previous))
|
|
137435
|
+
return;
|
|
137436
|
+
const refresh = await client.post(new URL("/api/auth/refresh", origin).href, {
|
|
137437
|
+
headers: { Origin: origin },
|
|
137438
|
+
maxRedirects: 0,
|
|
137439
|
+
failOnStatusCode: false,
|
|
137440
|
+
timeout: 1e4
|
|
137441
|
+
});
|
|
137442
|
+
if (!refresh.ok())
|
|
137443
|
+
throw new Error(`The app test session could not refresh (HTTP ${refresh.status()}).`);
|
|
137444
|
+
const renewed = await client.storageState();
|
|
137445
|
+
const next = cookie(renewed, ACCESS_COOKIE);
|
|
137446
|
+
if (!next || next === previous || testAccessNeedsRefresh(next) || !cookie(renewed, REFRESH_COOKIE)) {
|
|
137447
|
+
throw new Error("The app did not return renewed test-session cookies.");
|
|
137448
|
+
}
|
|
137449
|
+
})();
|
|
137450
|
+
contextRefreshes.set(client, work);
|
|
137451
|
+
try {
|
|
137452
|
+
await work;
|
|
137453
|
+
} finally {
|
|
137454
|
+
contextRefreshes.delete(client);
|
|
137455
|
+
}
|
|
137456
|
+
}
|
|
137457
|
+
async function data(client, table2, request2) {
|
|
137458
|
+
if (digests.has(client)) {
|
|
137459
|
+
return client.post("/__sw/data", { data: { ...request2, table: table2, contract: digests.get(client) ?? "" } });
|
|
137460
|
+
}
|
|
137461
|
+
const projectId = loadProjectConfig()?.project_id;
|
|
137462
|
+
if (!projectId)
|
|
137463
|
+
throw new Error("Use the data helper from a linked project folder.");
|
|
137464
|
+
let target = contextTargets.get(client);
|
|
137465
|
+
if (!target || target.projectId !== projectId) {
|
|
137466
|
+
const load2 = fixtureTestTarget(new ApiClient(process.env.SW_TEST_TARGET ? null : getToken()), projectId).catch((error3) => {
|
|
137467
|
+
if (contextTargets.get(client)?.load === load2)
|
|
137468
|
+
contextTargets.delete(client);
|
|
137469
|
+
throw error3;
|
|
137470
|
+
});
|
|
137471
|
+
target = { projectId, load: load2 };
|
|
137472
|
+
contextTargets.set(client, target);
|
|
137473
|
+
}
|
|
137474
|
+
const { origin, contractDigest } = await target.load;
|
|
137475
|
+
await refreshTestContext(client, origin);
|
|
137476
|
+
return client.post(new URL("/__sw/data", origin).href, {
|
|
137477
|
+
headers: { Origin: origin },
|
|
137478
|
+
maxRedirects: 0,
|
|
137479
|
+
data: { ...request2, table: table2, contract: contractDigest ?? "" }
|
|
137480
|
+
});
|
|
136832
137481
|
}
|
|
136833
|
-
var loaded, digests, eager, test, expect, ENDPOINT, INCONCLUSIVE, constrained, FormRun;
|
|
137482
|
+
var loaded, digests, eager, test, expect, ENDPOINT, INCONCLUSIVE, contextRefreshes, contextTargets, constrained, FormRun;
|
|
136834
137483
|
var init_playwright_fixtures = __esm({
|
|
136835
137484
|
"dist/lib/playwright-fixtures.js"() {
|
|
136836
137485
|
"use strict";
|
|
@@ -136883,6 +137532,9 @@ var init_playwright_fixtures = __esm({
|
|
|
136883
137532
|
INCONCLUSIVE = "looks the same as an empty table, a missing row or a missing route, so it proves nothing on its own. Pass { allowed: <someone the same request succeeds for> } as the positive control.";
|
|
136884
137533
|
__name(seen, "seen");
|
|
136885
137534
|
__name(refusedAs, "refusedAs");
|
|
137535
|
+
contextRefreshes = /* @__PURE__ */ new WeakMap();
|
|
137536
|
+
__name(refreshTestContext, "refreshTestContext");
|
|
137537
|
+
contextTargets = /* @__PURE__ */ new WeakMap();
|
|
136886
137538
|
__name(data, "data");
|
|
136887
137539
|
constrained = /* @__PURE__ */ new WeakSet();
|
|
136888
137540
|
FormRun = class {
|
|
@@ -136984,109 +137636,331 @@ var init_playwright_fixtures = __esm({
|
|
|
136984
137636
|
}
|
|
136985
137637
|
});
|
|
136986
137638
|
|
|
137639
|
+
// dist/lib/testing-jobs.js
|
|
137640
|
+
function testingDeveloperToken() {
|
|
137641
|
+
const config2 = loadConfig();
|
|
137642
|
+
if (!config2?.token || !hasUsableCredential(config2)) {
|
|
137643
|
+
throw new Error("Use the linked app\u2019s CLI session to run this test.");
|
|
137644
|
+
}
|
|
137645
|
+
return config2.token;
|
|
137646
|
+
}
|
|
137647
|
+
async function runTestJob(target, job, options2 = {}, previewCredential) {
|
|
137648
|
+
const time3 = options2.timeoutSeconds ?? (previewCredential ? 270 : 300);
|
|
137649
|
+
if (!Number.isFinite(time3) || time3 < 1 || time3 > 3600)
|
|
137650
|
+
throw new Error("Choose a job wait from 1 to 3600 seconds.");
|
|
137651
|
+
const preview = target.environment === "preview";
|
|
137652
|
+
if (preview && (!previewCredential || !target.previewSessionId))
|
|
137653
|
+
throw new Error("The test has no preview job credential.");
|
|
137654
|
+
const binding = { preview_session_id: target.previewSessionId, preview_id: target.releaseId };
|
|
137655
|
+
const developer = testingDeveloperToken();
|
|
137656
|
+
const client = new ApiClient(developer);
|
|
137657
|
+
let path3;
|
|
137658
|
+
let body;
|
|
137659
|
+
let credential;
|
|
137660
|
+
let readJob;
|
|
137661
|
+
const liveRead = /* @__PURE__ */ __name((id2, timeoutMs) => client.call("GET", `/jobs/${encodeURIComponent(id2)}`, void 0, void 0, { timeoutMs }), "liveRead");
|
|
137662
|
+
if ("schedule" in job) {
|
|
137663
|
+
const { crons } = await client.call("GET", "/cron", void 0, { project_id: target.projectId });
|
|
137664
|
+
const matches = crons.filter((cron) => cron.cron_id === job.schedule || cron.name === job.schedule);
|
|
137665
|
+
if (matches.length !== 1)
|
|
137666
|
+
throw new Error("Choose one schedule by name or ID in the linked app.");
|
|
137667
|
+
credential = developer;
|
|
137668
|
+
path3 = `/cron/${encodeURIComponent(matches[0].cron_id)}/${preview ? "run-preview" : "run"}`;
|
|
137669
|
+
body = preview ? binding : void 0;
|
|
137670
|
+
if (preview) {
|
|
137671
|
+
const prep = await client.call("GET", path3, void 0, binding);
|
|
137672
|
+
if (prep.preview_session_id !== binding.preview_session_id || prep.preview_id !== binding.preview_id || !prep.notice) {
|
|
137673
|
+
throw new Error("The platform did not confirm the selected preview.");
|
|
137674
|
+
}
|
|
137675
|
+
process.stderr.write(prep.notice + "\n");
|
|
137676
|
+
readJob = /* @__PURE__ */ __name(async (jobId, timeoutMs) => {
|
|
137677
|
+
const result = await client.call("GET", path3, void 0, { ...binding, job_id: jobId }, { timeoutMs });
|
|
137678
|
+
return { ...result.job, preview_id: result.preview_id, preview_session_id: result.preview_session_id };
|
|
137679
|
+
}, "readJob");
|
|
137680
|
+
} else
|
|
137681
|
+
readJob = liveRead;
|
|
137682
|
+
} else {
|
|
137683
|
+
if (!job.handler.startsWith("/") || new URL(job.handler, target.origin).origin !== target.origin)
|
|
137684
|
+
throw new Error("Choose a handler path in this app.");
|
|
137685
|
+
path3 = preview ? `/projects/${encodeURIComponent(target.projectId)}/preview/run-job` : "/jobs";
|
|
137686
|
+
body = { handler: job.handler, payload: job.payload, ...preview ? binding : { project_id: target.projectId } };
|
|
137687
|
+
credential = developer;
|
|
137688
|
+
const tool = new ApiClient(previewCredential ?? null);
|
|
137689
|
+
readJob = preview ? (id2, timeoutMs) => tool.call("GET", `/preview-tools/jobs/${encodeURIComponent(id2)}`, void 0, void 0, { refresh: false, timeoutMs }) : liveRead;
|
|
137690
|
+
}
|
|
137691
|
+
const encoded = body === void 0 ? void 0 : JSON.stringify(body);
|
|
137692
|
+
let requestId;
|
|
137693
|
+
let receipt;
|
|
137694
|
+
try {
|
|
137695
|
+
const response = await fetch(API_BASE_URL + path3, {
|
|
137696
|
+
method: "POST",
|
|
137697
|
+
redirect: "error",
|
|
137698
|
+
signal: AbortSignal.timeout(15e3),
|
|
137699
|
+
headers: { Authorization: `Bearer ${credential}`, ...body === void 0 ? {} : { "Content-Type": "application/json" } },
|
|
137700
|
+
body: encoded
|
|
137701
|
+
});
|
|
137702
|
+
requestId = response.headers.get("x-request-id") ?? response.headers.get("cf-ray") ?? void 0;
|
|
137703
|
+
const answer = await response.json();
|
|
137704
|
+
if (response.status >= 400 && response.status < 500 && answer?.ok === false) {
|
|
137705
|
+
return { status: "refused", request_id: requestId, timed_out: false, error_code: answer.error };
|
|
137706
|
+
}
|
|
137707
|
+
if (response.status === 202 && answer?.ok === true)
|
|
137708
|
+
receipt = answer.data;
|
|
137709
|
+
} catch {
|
|
137710
|
+
}
|
|
137711
|
+
const validTarget = /* @__PURE__ */ __name((value) => !preview || value.preview_session_id === binding.preview_session_id && value.preview_id === binding.preview_id, "validTarget");
|
|
137712
|
+
if (typeof receipt?.job_id !== "string" || !receipt.job_id.startsWith("job_") || !validTarget(receipt))
|
|
137713
|
+
return { status: "unknown", request_id: requestId, timed_out: false };
|
|
137714
|
+
const id = receipt.job_id;
|
|
137715
|
+
const budget = preview ? Math.min(time3, receipt.timeout_seconds || 270) : time3;
|
|
137716
|
+
const deadline = Date.now() + budget * 1e3;
|
|
137717
|
+
let status = "queued";
|
|
137718
|
+
while (Date.now() < deadline) {
|
|
137719
|
+
try {
|
|
137720
|
+
const job2 = await readJob(id, Math.max(1, deadline - Date.now()));
|
|
137721
|
+
if (job2.job_id !== id || !validTarget(job2))
|
|
137722
|
+
throw new Error("Unexpected job receipt.");
|
|
137723
|
+
status = job2.status;
|
|
137724
|
+
if (job2.terminal ?? (terminal.has(status) && typeof job2.completed_at === "string")) {
|
|
137725
|
+
const duration3 = job2.duration_ms ?? (job2.started_at && job2.completed_at ? Date.parse(job2.completed_at) - Date.parse(job2.started_at) : null);
|
|
137726
|
+
return { status, job_id: id, request_id: requestId, duration_ms: duration3, timed_out: false, error_code: job2.error_code };
|
|
137727
|
+
}
|
|
137728
|
+
} catch {
|
|
137729
|
+
return { status: "unknown", job_id: id, request_id: requestId, timed_out: false };
|
|
137730
|
+
}
|
|
137731
|
+
const wait = Math.min(1e3, deadline - Date.now());
|
|
137732
|
+
if (wait > 0)
|
|
137733
|
+
await new Promise((resolve27) => setTimeout(resolve27, wait));
|
|
137734
|
+
}
|
|
137735
|
+
return { status, job_id: id, request_id: requestId, timed_out: true };
|
|
137736
|
+
}
|
|
137737
|
+
var terminal;
|
|
137738
|
+
var init_testing_jobs = __esm({
|
|
137739
|
+
"dist/lib/testing-jobs.js"() {
|
|
137740
|
+
"use strict";
|
|
137741
|
+
init_client();
|
|
137742
|
+
init_config();
|
|
137743
|
+
__name(testingDeveloperToken, "testingDeveloperToken");
|
|
137744
|
+
terminal = /* @__PURE__ */ new Set(["complete", "failed", "cancelled", "indeterminate"]);
|
|
137745
|
+
__name(runTestJob, "runTestJob");
|
|
137746
|
+
}
|
|
137747
|
+
});
|
|
137748
|
+
|
|
137749
|
+
// dist/lib/testing-app.js
|
|
137750
|
+
import { resolve as resolve26 } from "node:path";
|
|
137751
|
+
async function openTestApp(options2 = {}) {
|
|
137752
|
+
const root = resolve26(options2.projectDir ?? process.cwd());
|
|
137753
|
+
const projectId = loadProjectConfig(root)?.project_id;
|
|
137754
|
+
if (!projectId)
|
|
137755
|
+
throw new Error("Run the test from a linked Somewhere app folder.");
|
|
137756
|
+
const setup = options2.preview ? previewCredentialFor(root, projectId) : void 0;
|
|
137757
|
+
const tool = setup && previewToolClient(setup.credential);
|
|
137758
|
+
const client = tool ? void 0 : new ApiClient(testingDeveloperToken());
|
|
137759
|
+
const target = tool && setup ? await readPreviewTarget(tool, projectId, setup.previewSessionId) : await loadTestTarget(client, projectId);
|
|
137760
|
+
const control = tool ? previewControl(tool, target) : void 0;
|
|
137761
|
+
const origin = target.origin;
|
|
137762
|
+
const emptyState = { cookies: [], origins: [] };
|
|
137763
|
+
const cookie = await control?.previewCookie?.();
|
|
137764
|
+
if (cookie) {
|
|
137765
|
+
emptyState.cookies.push({
|
|
137766
|
+
name: cookie.name,
|
|
137767
|
+
value: cookie.value,
|
|
137768
|
+
domain: new URL(origin).hostname,
|
|
137769
|
+
path: "/",
|
|
137770
|
+
expires: Math.floor(cookie.expiresAt / 1e3),
|
|
137771
|
+
httpOnly: true,
|
|
137772
|
+
secure: true,
|
|
137773
|
+
sameSite: "Lax"
|
|
137774
|
+
});
|
|
137775
|
+
}
|
|
137776
|
+
const ids = /* @__PURE__ */ new Set();
|
|
137777
|
+
const actors = /* @__PURE__ */ new Set();
|
|
137778
|
+
const cleanupSteps = [];
|
|
137779
|
+
let closed = false;
|
|
137780
|
+
const open4 = /* @__PURE__ */ __name(() => {
|
|
137781
|
+
if (closed)
|
|
137782
|
+
throw new Error("This test app has already been cleaned up.");
|
|
137783
|
+
}, "open");
|
|
137784
|
+
const add = /* @__PURE__ */ __name((id, email2, session) => {
|
|
137785
|
+
const actor = { id, email: email2, session };
|
|
137786
|
+
actors.add(actor);
|
|
137787
|
+
return actor;
|
|
137788
|
+
}, "add");
|
|
137789
|
+
const onCleanup = /* @__PURE__ */ __name((label, action) => {
|
|
137790
|
+
open4();
|
|
137791
|
+
cleanupSteps.push({ label, action });
|
|
137792
|
+
}, "onCleanup");
|
|
137793
|
+
const create = /* @__PURE__ */ __name(async (user, table2, values, key = "id") => {
|
|
137794
|
+
open4();
|
|
137795
|
+
if (!actors.has(user))
|
|
137796
|
+
throw new Error("Choose a user created by this test app.");
|
|
137797
|
+
const nameUnknownRow = /* @__PURE__ */ __name(() => onCleanup(`row in ${table2} created by ${user.id} with an unknown ID`, async () => {
|
|
137798
|
+
throw new Error("No row ID was returned.");
|
|
137799
|
+
}), "nameUnknownRow");
|
|
137800
|
+
let response;
|
|
137801
|
+
try {
|
|
137802
|
+
response = await user.session.data(table2, { operation: "create", values });
|
|
137803
|
+
} catch (error3) {
|
|
137804
|
+
nameUnknownRow();
|
|
137805
|
+
throw error3;
|
|
137806
|
+
}
|
|
137807
|
+
if (!response.ok) {
|
|
137808
|
+
if (response.status >= 500)
|
|
137809
|
+
nameUnknownRow();
|
|
137810
|
+
throw new Error(`Could not create a row in ${table2} as ${user.id} (HTTP ${response.status}).`);
|
|
137811
|
+
}
|
|
137812
|
+
const body = await response.json().catch(() => null);
|
|
137813
|
+
const rows = body && typeof body === "object" && "data" in body ? body.data : void 0;
|
|
137814
|
+
const row = Array.isArray(rows) ? rows[0] : rows;
|
|
137815
|
+
const id = row && typeof row === "object" && Object.hasOwn(row, key) ? row[key] : void 0;
|
|
137816
|
+
if (typeof id !== "string" && typeof id !== "number") {
|
|
137817
|
+
nameUnknownRow();
|
|
137818
|
+
throw new Error(`A row in ${table2} may remain. The create returned no ${key}.`);
|
|
137819
|
+
}
|
|
137820
|
+
onCleanup(`row ${table2}/${id}`, async () => {
|
|
137821
|
+
const removed = await user.session.data(table2, { operation: "delete", id });
|
|
137822
|
+
if (removed.ok)
|
|
137823
|
+
return;
|
|
137824
|
+
const probe = await user.session.data(table2, { operation: "get", id });
|
|
137825
|
+
const read = await probe.json().catch(() => null);
|
|
137826
|
+
if (probe.ok && read?.data === null)
|
|
137827
|
+
return;
|
|
137828
|
+
throw new Error(`Delete returned HTTP ${removed.status} and the row could not be confirmed gone.`);
|
|
137829
|
+
});
|
|
137830
|
+
return id;
|
|
137831
|
+
}, "create");
|
|
137832
|
+
return {
|
|
137833
|
+
origin,
|
|
137834
|
+
anonymous: new UserSession(origin, { target, storageState: emptyState }),
|
|
137835
|
+
async users(count2) {
|
|
137836
|
+
open4();
|
|
137837
|
+
if (!Number.isInteger(count2) || count2 < 1 || count2 > 25)
|
|
137838
|
+
throw new Error("Choose 1 to 25 test users.");
|
|
137839
|
+
if (control) {
|
|
137840
|
+
const out2 = [];
|
|
137841
|
+
for (let i = 0; i < count2; i++) {
|
|
137842
|
+
const user = await control.createManagedUser();
|
|
137843
|
+
ids.add(user.id);
|
|
137844
|
+
const session = new UserSession(origin, { target, storageState: emptyState });
|
|
137845
|
+
const login = await session.post("/api/auth/login", { email: user.email, password: user.password });
|
|
137846
|
+
if (!login.ok)
|
|
137847
|
+
throw new Error(`Could not sign in preview test user ${user.id} (HTTP ${login.status}).`);
|
|
137848
|
+
out2.push(add(user.id, user.email, session));
|
|
137849
|
+
}
|
|
137850
|
+
return out2;
|
|
137851
|
+
}
|
|
137852
|
+
const out = [];
|
|
137853
|
+
try {
|
|
137854
|
+
for (let offset = 0; offset < count2; offset += MAX_PER_CREATE) {
|
|
137855
|
+
const { issued, receivedAt } = await createTestIdentities(client, projectId, "user", Math.min(MAX_PER_CREATE, count2 - offset), "script");
|
|
137856
|
+
for (const identity of issued)
|
|
137857
|
+
ids.add(identity.user.id);
|
|
137858
|
+
for (const identity of issued) {
|
|
137859
|
+
const state = buildStorageState(origin, new URL(origin).hostname, identity, expiryOf(identity, receivedAt));
|
|
137860
|
+
out.push(add(identity.user.id, identity.user.email, new UserSession(origin, { target, storageState: state })));
|
|
137861
|
+
}
|
|
137862
|
+
}
|
|
137863
|
+
return out;
|
|
137864
|
+
} catch (error3) {
|
|
137865
|
+
if (error3 && typeof error3 === "object" && "createdIds" in error3 && Array.isArray(error3.createdIds)) {
|
|
137866
|
+
for (const id of error3.createdIds)
|
|
137867
|
+
if (typeof id === "string")
|
|
137868
|
+
ids.add(id);
|
|
137869
|
+
}
|
|
137870
|
+
throw error3;
|
|
137871
|
+
}
|
|
137872
|
+
},
|
|
137873
|
+
create,
|
|
137874
|
+
async plantMarker(user, table2, field2, values = {}) {
|
|
137875
|
+
const marker = privateMarker();
|
|
137876
|
+
await create(user, table2, { ...values, [field2]: marker });
|
|
137877
|
+
return marker;
|
|
137878
|
+
},
|
|
137879
|
+
onCleanup,
|
|
137880
|
+
runJob(job, opts) {
|
|
137881
|
+
open4();
|
|
137882
|
+
return runTestJob(target, job, opts, setup?.credential);
|
|
137883
|
+
},
|
|
137884
|
+
async cleanup() {
|
|
137885
|
+
if (closed)
|
|
137886
|
+
return;
|
|
137887
|
+
closed = true;
|
|
137888
|
+
const remains = [];
|
|
137889
|
+
for (const { label, action } of cleanupSteps.reverse()) {
|
|
137890
|
+
try {
|
|
137891
|
+
await action();
|
|
137892
|
+
} catch {
|
|
137893
|
+
remains.push(label);
|
|
137894
|
+
}
|
|
137895
|
+
}
|
|
137896
|
+
if (control) {
|
|
137897
|
+
for (const id of ids)
|
|
137898
|
+
if (await control.deleteManagedUser(id))
|
|
137899
|
+
remains.push(`test user ${id}`);
|
|
137900
|
+
await control.close();
|
|
137901
|
+
} else if (ids.size) {
|
|
137902
|
+
try {
|
|
137903
|
+
await client.call("DELETE", "/auth/test-users", { project_id: projectId, ids: [...ids] });
|
|
137904
|
+
const { identities } = await client.call("GET", "/auth/test-users", void 0, { project_id: projectId });
|
|
137905
|
+
for (const user of identities)
|
|
137906
|
+
if (ids.has(user.id))
|
|
137907
|
+
remains.push(`test user ${user.id}`);
|
|
137908
|
+
} catch {
|
|
137909
|
+
remains.push(...[...ids].map((id) => `test user ${id}`));
|
|
137910
|
+
}
|
|
137911
|
+
}
|
|
137912
|
+
if (remains.length)
|
|
137913
|
+
throw new Error(`Could not confirm cleanup of ${remains.join(", ")}.`);
|
|
137914
|
+
}
|
|
137915
|
+
};
|
|
137916
|
+
}
|
|
137917
|
+
var init_testing_app = __esm({
|
|
137918
|
+
"dist/lib/testing-app.js"() {
|
|
137919
|
+
"use strict";
|
|
137920
|
+
init_client();
|
|
137921
|
+
init_config();
|
|
137922
|
+
init_preview_credential();
|
|
137923
|
+
init_test_control();
|
|
137924
|
+
init_test_identities();
|
|
137925
|
+
init_test_target();
|
|
137926
|
+
init_test_response_capture();
|
|
137927
|
+
init_testing_jobs();
|
|
137928
|
+
init_test_session();
|
|
137929
|
+
__name(openTestApp, "openTestApp");
|
|
137930
|
+
}
|
|
137931
|
+
});
|
|
137932
|
+
|
|
136987
137933
|
// dist/testing.js
|
|
136988
137934
|
var testing_exports = {};
|
|
136989
137935
|
__export(testing_exports, {
|
|
136990
137936
|
UserSession: () => UserSession,
|
|
137937
|
+
assertNoLeak: () => assertNoLeak,
|
|
137938
|
+
captureResponses: () => captureResponses,
|
|
136991
137939
|
createUser: () => createUser,
|
|
136992
137940
|
data: () => data,
|
|
136993
137941
|
expect: () => expect,
|
|
136994
137942
|
expectRefusal: () => expectRefusal,
|
|
136995
137943
|
expectRefused: () => expectRefused,
|
|
136996
137944
|
expectStatus: () => expectStatus,
|
|
137945
|
+
openTestApp: () => openTestApp,
|
|
136997
137946
|
ready: () => ready,
|
|
136998
137947
|
signIn: () => signIn2,
|
|
136999
137948
|
test: () => test,
|
|
137000
137949
|
waitForApp: () => waitForApp
|
|
137001
137950
|
});
|
|
137002
|
-
async function expectStatus(response, expected) {
|
|
137003
|
-
if (response.status !== expected)
|
|
137004
|
-
throw new Error("Expected HTTP " + expected + ", received " + response.status);
|
|
137005
|
-
}
|
|
137006
|
-
async function expectRefusal(response, status, code) {
|
|
137007
|
-
await expectStatus(response, status);
|
|
137008
|
-
const body = await response.json();
|
|
137009
|
-
if (!body || typeof body !== "object" || !("error" in body) || body.error !== code) {
|
|
137010
|
-
throw new Error("Refusal did not have the exact expected error code: " + code);
|
|
137011
|
-
}
|
|
137012
|
-
}
|
|
137013
|
-
async function signIn2(baseUrl, email2, password) {
|
|
137014
|
-
const session = new UserSession(baseUrl);
|
|
137015
|
-
const response = await session.post("/api/auth/login", { email: email2, password });
|
|
137016
|
-
await expectStatus(response, 200);
|
|
137017
|
-
const body = await response.json();
|
|
137018
|
-
if (!body.cookie_session)
|
|
137019
|
-
throw new Error("Sign-in did not establish a cookie session");
|
|
137020
|
-
return session;
|
|
137021
|
-
}
|
|
137022
|
-
async function createUser(baseUrl) {
|
|
137023
|
-
const session = new UserSession(baseUrl);
|
|
137024
|
-
const email2 = "starter-" + crypto.randomUUID() + "@fixture.test.somewhere.site";
|
|
137025
|
-
const password = "Fixture!9-" + crypto.randomUUID();
|
|
137026
|
-
const response = await session.post("/api/auth/signup", { email: email2, password });
|
|
137027
|
-
await expectStatus(response, 200);
|
|
137028
|
-
const body = await response.json();
|
|
137029
|
-
if (!body.cookie_session)
|
|
137030
|
-
throw new Error("Signup did not establish a cookie session");
|
|
137031
|
-
return session;
|
|
137032
|
-
}
|
|
137033
137951
|
function waitForApp(page, state = "ready") {
|
|
137034
|
-
const
|
|
137035
|
-
|
|
137952
|
+
const values = state === "ready" ? ["signed-in", "signed-out"] : [state];
|
|
137953
|
+
const matches = values.flatMap((value) => [`html[data-sw-auth="${value}"]`, `[data-app-state="${value}"]`]);
|
|
137954
|
+
const locator = page.locator(matches.join(", "));
|
|
137955
|
+
return (locator.first?.() ?? locator).waitFor({ state: "visible" });
|
|
137036
137956
|
}
|
|
137037
|
-
var UserSession;
|
|
137038
137957
|
var init_testing = __esm({
|
|
137039
137958
|
"dist/testing.js"() {
|
|
137040
137959
|
"use strict";
|
|
137041
|
-
|
|
137042
|
-
init_config();
|
|
137043
|
-
init_test_target();
|
|
137960
|
+
init_test_session();
|
|
137044
137961
|
init_playwright_fixtures();
|
|
137045
|
-
|
|
137046
|
-
|
|
137047
|
-
__name(this, "UserSession");
|
|
137048
|
-
}
|
|
137049
|
-
origin;
|
|
137050
|
-
cookies = /* @__PURE__ */ new Map();
|
|
137051
|
-
target;
|
|
137052
|
-
constructor(baseUrl) {
|
|
137053
|
-
this.origin = new URL(baseUrl).origin;
|
|
137054
|
-
}
|
|
137055
|
-
async request(path3, init = {}) {
|
|
137056
|
-
const url3 = new URL(path3, this.origin);
|
|
137057
|
-
if (url3.origin !== this.origin)
|
|
137058
|
-
throw new Error("Fixture requests must stay on the app origin");
|
|
137059
|
-
const headers = new Headers(init.headers);
|
|
137060
|
-
headers.set("Origin", this.origin);
|
|
137061
|
-
headers.set("Cookie", [...this.cookies].map(([k2, v2]) => k2 + "=" + v2).join("; "));
|
|
137062
|
-
const response = await fetch(url3, { ...init, headers, redirect: "error" });
|
|
137063
|
-
for (const cookie of response.headers.getSetCookie()) {
|
|
137064
|
-
const pair = cookie.split(";")[0];
|
|
137065
|
-
const split = pair.indexOf("=");
|
|
137066
|
-
this.cookies.set(pair.slice(0, split), pair.slice(split + 1));
|
|
137067
|
-
}
|
|
137068
|
-
return response;
|
|
137069
|
-
}
|
|
137070
|
-
post(path3, body) {
|
|
137071
|
-
return this.request(path3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
137072
|
-
}
|
|
137073
|
-
async data(table2, requestOrContract, request2) {
|
|
137074
|
-
if (typeof requestOrContract === "string") {
|
|
137075
|
-
return this.post("/__sw/data", { ...request2, table: table2, contract: requestOrContract });
|
|
137076
|
-
}
|
|
137077
|
-
const projectId = loadProjectConfig()?.project_id;
|
|
137078
|
-
if (!projectId)
|
|
137079
|
-
throw new Error("Use the data helper from a linked project folder.");
|
|
137080
|
-
const target = await (this.target ??= fixtureTestTarget(new ApiClient(process.env.SW_TEST_TARGET ? null : getToken()), projectId));
|
|
137081
|
-
if (target.origin !== this.origin)
|
|
137082
|
-
throw new Error("This session belongs to a different app than the linked test target.");
|
|
137083
|
-
return this.post("/__sw/data", { ...requestOrContract, table: table2, contract: target.contractDigest ?? "" });
|
|
137084
|
-
}
|
|
137085
|
-
};
|
|
137086
|
-
__name(expectStatus, "expectStatus");
|
|
137087
|
-
__name(expectRefusal, "expectRefusal");
|
|
137088
|
-
__name(signIn2, "signIn");
|
|
137089
|
-
__name(createUser, "createUser");
|
|
137962
|
+
init_testing_app();
|
|
137963
|
+
init_test_response_capture();
|
|
137090
137964
|
__name(waitForApp, "waitForApp");
|
|
137091
137965
|
}
|
|
137092
137966
|
});
|