@somewhere-cloud/cli 0.38.152 → 0.38.154
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 +11 -0
- package/README.md +6 -0
- package/dist/lib/bundle.js +1171 -444
- 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 +1 -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/runtime/DECLARED-DATA-VENDOR.json +5 -5
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/SOURCE-LINT-VENDOR.json +2 -2
- package/runtime/declared-data.cjs +37 -19
- package/runtime/source-lint.cjs +1 -1
- 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;
|
|
@@ -43522,15 +43558,15 @@ function initInstallSpawnSpec(platform2) {
|
|
|
43522
43558
|
};
|
|
43523
43559
|
}
|
|
43524
43560
|
function runInitInstall({ cwd, quiet }) {
|
|
43525
|
-
return new Promise((
|
|
43561
|
+
return new Promise((resolve27) => {
|
|
43526
43562
|
const spec = initInstallSpawnSpec(process.platform);
|
|
43527
43563
|
const child = spawn2(spec.command, spec.args, {
|
|
43528
43564
|
cwd,
|
|
43529
43565
|
shell: spec.shell,
|
|
43530
43566
|
stdio: quiet ? "ignore" : "inherit"
|
|
43531
43567
|
});
|
|
43532
|
-
child.once("error", () =>
|
|
43533
|
-
child.once("exit", (code, signal) =>
|
|
43568
|
+
child.once("error", () => resolve27(127));
|
|
43569
|
+
child.once("exit", (code, signal) => resolve27(signal ? 1 : code ?? 1));
|
|
43534
43570
|
});
|
|
43535
43571
|
}
|
|
43536
43572
|
async function installInitDependencies(options2, runner2 = runInitInstall) {
|
|
@@ -44150,7 +44186,8 @@ ${AGENT_WORKFLOW}
|
|
|
44150
44186
|
${SKILLS_POINTER}
|
|
44151
44187
|
Without a global CLI, use \`npx @somewhere-cloud/cli deploy\` and \`npx @somewhere-cloud/cli test\`.
|
|
44152
44188
|
|
|
44153
|
-
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.
|
|
44154
44191
|
|
|
44155
44192
|
${PORTABILITY_POINTER}
|
|
44156
44193
|
${MCP_POINTER}
|
|
@@ -44160,6 +44197,44 @@ ${PREVIEW_POINTER}
|
|
|
44160
44197
|
}
|
|
44161
44198
|
});
|
|
44162
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
|
+
|
|
44163
44238
|
// dist/lib/typecheck-version.js
|
|
44164
44239
|
var TYPECHECK_TYPESCRIPT_VERSION;
|
|
44165
44240
|
var init_typecheck_version = __esm({
|
|
@@ -44288,6 +44363,7 @@ declare module '*.${ext}' {
|
|
|
44288
44363
|
function createGreenTemplate(appName = "somewhere-starter") {
|
|
44289
44364
|
return [
|
|
44290
44365
|
{ path: ".gitignore", content: buildScaffoldGitignore() },
|
|
44366
|
+
STARTER_AUTH_TEST,
|
|
44291
44367
|
{ path: "AGENTS.md", content: INIT_AGENTS_MD },
|
|
44292
44368
|
{ path: "CLAUDE.md", content: INIT_CLAUDE_MD },
|
|
44293
44369
|
{ path: "README.md", content: README },
|
|
@@ -44312,6 +44388,7 @@ var packageJson, TSCONFIG, APP_TYPES, SCHEMA, API, SERVICE, APP, MAIN, STYLES, R
|
|
|
44312
44388
|
var init_init_green_template = __esm({
|
|
44313
44389
|
"dist/lib/init-green-template.js"() {
|
|
44314
44390
|
"use strict";
|
|
44391
|
+
init_init_test_template();
|
|
44315
44392
|
init_version();
|
|
44316
44393
|
init_typecheck_version();
|
|
44317
44394
|
init_scaffold();
|
|
@@ -44326,6 +44403,7 @@ var init_init_green_template = __esm({
|
|
|
44326
44403
|
"somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
|
|
44327
44404
|
"scripts": {
|
|
44328
44405
|
"dev": "npx -y @somewhere-cloud/cli dev",
|
|
44406
|
+
"test": "node tests/starter.mjs",
|
|
44329
44407
|
"typecheck": "npx -y @somewhere-cloud/cli typecheck"
|
|
44330
44408
|
},
|
|
44331
44409
|
"dependencies": {
|
|
@@ -44334,6 +44412,7 @@ var init_init_green_template = __esm({
|
|
|
44334
44412
|
"react-dom": "19.2.7"
|
|
44335
44413
|
},
|
|
44336
44414
|
"devDependencies": {
|
|
44415
|
+
"@somewhere-cloud/cli": "${CLI_VERSION}",
|
|
44337
44416
|
"@types/react": "19.2.2",
|
|
44338
44417
|
"@types/react-dom": "19.2.2",
|
|
44339
44418
|
"typescript": "${TYPECHECK_TYPESCRIPT_VERSION}"
|
|
@@ -46762,27 +46841,6 @@ var init_project_pin = __esm({
|
|
|
46762
46841
|
}
|
|
46763
46842
|
});
|
|
46764
46843
|
|
|
46765
|
-
// dist/lib/init-test-template.js
|
|
46766
|
-
function starterChecks(options2 = {}) {
|
|
46767
|
-
return options2.privateData ? [{ path: "checks/add-a-note.json", content: JSON.stringify(ADD_A_NOTE, null, 2) + "\n" }] : [];
|
|
46768
|
-
}
|
|
46769
|
-
var ADD_A_NOTE;
|
|
46770
|
-
var init_init_test_template = __esm({
|
|
46771
|
-
"dist/lib/init-test-template.js"() {
|
|
46772
|
-
"use strict";
|
|
46773
|
-
ADD_A_NOTE = {
|
|
46774
|
-
actions: [
|
|
46775
|
-
{ fill: "[data-testid=note-title]", value: "Lunch with Ana 42" },
|
|
46776
|
-
{ click: "[data-testid=note-save]" },
|
|
46777
|
-
{ expect: { selector: "[data-testid=note-item]", text: "Lunch with Ana 42" } }
|
|
46778
|
-
],
|
|
46779
|
-
viewports: ["desktop", "mobile"],
|
|
46780
|
-
signed_in: true
|
|
46781
|
-
};
|
|
46782
|
-
__name(starterChecks, "starterChecks");
|
|
46783
|
-
}
|
|
46784
|
-
});
|
|
46785
|
-
|
|
46786
46844
|
// dist/lib/init-ui-kit.js
|
|
46787
46845
|
var TOKENS_CSS, APP_CSS, STYLED_AUTH_CARD, PLAIN_AUTH_CARD, STYLED_VERIFY_EMAIL, STYLED_UI_KIT, PLAIN_UI_KIT;
|
|
46788
46846
|
var init_init_ui_kit = __esm({
|
|
@@ -48554,6 +48612,7 @@ function createFeatureTemplate(selection, options2) {
|
|
|
48554
48612
|
const files = [
|
|
48555
48613
|
...starterChecks({ privateData }),
|
|
48556
48614
|
{ path: ".gitignore", content: buildScaffoldGitignore() },
|
|
48615
|
+
STARTER_AUTH_TEST,
|
|
48557
48616
|
{ path: "AGENTS.md", content: INIT_AGENTS_MD },
|
|
48558
48617
|
{ path: "CLAUDE.md", content: INIT_CLAUDE_MD },
|
|
48559
48618
|
{ path: "README.md", content: readme(selection) },
|
|
@@ -48628,6 +48687,7 @@ var init_init_feature_template = __esm({
|
|
|
48628
48687
|
"somewhere": { "cli_version": "${CLI_VERSION}", "project_name": ${JSON.stringify(appName)} },
|
|
48629
48688
|
"scripts": {
|
|
48630
48689
|
"dev": "npx -y @somewhere-cloud/cli dev",
|
|
48690
|
+
"test": "node tests/starter.mjs",
|
|
48631
48691
|
"typecheck": "npx -y @somewhere-cloud/cli typecheck"
|
|
48632
48692
|
},
|
|
48633
48693
|
"dependencies": {
|
|
@@ -48636,6 +48696,7 @@ var init_init_feature_template = __esm({
|
|
|
48636
48696
|
"react-dom": "19.2.7"
|
|
48637
48697
|
},
|
|
48638
48698
|
"devDependencies": {
|
|
48699
|
+
"@somewhere-cloud/cli": "${CLI_VERSION}",
|
|
48639
48700
|
"@types/react": "19.2.2",
|
|
48640
48701
|
"@types/react-dom": "19.2.2",
|
|
48641
48702
|
"typescript": "${TYPECHECK_TYPESCRIPT_VERSION}"
|
|
@@ -54123,9 +54184,9 @@ function formatError(error3, mapper = (issue2) => issue2.message) {
|
|
|
54123
54184
|
let i = 0;
|
|
54124
54185
|
while (i < fullpath.length) {
|
|
54125
54186
|
const el = fullpath[i];
|
|
54126
|
-
const
|
|
54187
|
+
const terminal2 = i === fullpath.length - 1;
|
|
54127
54188
|
if (el === "_errors") {
|
|
54128
|
-
if (
|
|
54189
|
+
if (terminal2)
|
|
54129
54190
|
curr._errors.push(mapper(issue2));
|
|
54130
54191
|
i++;
|
|
54131
54192
|
continue;
|
|
@@ -54139,7 +54200,7 @@ function formatError(error3, mapper = (issue2) => issue2.message) {
|
|
|
54139
54200
|
});
|
|
54140
54201
|
}
|
|
54141
54202
|
const node2 = curr[el];
|
|
54142
|
-
if (
|
|
54203
|
+
if (terminal2) {
|
|
54143
54204
|
node2._errors.push(mapper(issue2));
|
|
54144
54205
|
}
|
|
54145
54206
|
curr = node2;
|
|
@@ -56583,7 +56644,7 @@ function isRef(value) {
|
|
|
56583
56644
|
function cloneIssues(issues) {
|
|
56584
56645
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
56585
56646
|
}
|
|
56586
|
-
function isRecursive(inst, stack,
|
|
56647
|
+
function isRecursive(inst, stack, resolve27) {
|
|
56587
56648
|
const cached2 = recursive.get(inst);
|
|
56588
56649
|
if (cached2 !== void 0)
|
|
56589
56650
|
return cached2 ? PROVEN : NONE;
|
|
@@ -56593,7 +56654,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56593
56654
|
let result = NONE;
|
|
56594
56655
|
const check = /* @__PURE__ */ __name((child) => {
|
|
56595
56656
|
if (result !== PROVEN && child?._zod) {
|
|
56596
|
-
const answer = isRecursive(child, stack,
|
|
56657
|
+
const answer = isRecursive(child, stack, resolve27);
|
|
56597
56658
|
if (answer > result)
|
|
56598
56659
|
result = answer;
|
|
56599
56660
|
}
|
|
@@ -56604,7 +56665,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56604
56665
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
56605
56666
|
if (spread && !desc.enumerable)
|
|
56606
56667
|
continue;
|
|
56607
|
-
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;
|
|
56608
56669
|
if (child > answer)
|
|
56609
56670
|
answer = child;
|
|
56610
56671
|
}
|
|
@@ -56668,7 +56729,7 @@ function isRecursive(inst, stack, resolve26) {
|
|
|
56668
56729
|
break;
|
|
56669
56730
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
56670
56731
|
case "lazy": {
|
|
56671
|
-
const inner = def._cachedInner ?? (
|
|
56732
|
+
const inner = def._cachedInner ?? (resolve27 ? inst._zod.innerType : void 0);
|
|
56672
56733
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
56673
56734
|
break;
|
|
56674
56735
|
}
|
|
@@ -63318,13 +63379,13 @@ var init_streamableHttp = __esm({
|
|
|
63318
63379
|
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
63319
63380
|
return;
|
|
63320
63381
|
}
|
|
63321
|
-
const
|
|
63382
|
+
const delay2 = this._getNextReconnectionDelay(attemptCount);
|
|
63322
63383
|
this._reconnectionTimeout = setTimeout(() => {
|
|
63323
63384
|
this._startOrAuthSse(options2).catch((error3) => {
|
|
63324
63385
|
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error3 instanceof Error ? error3.message : String(error3)}`));
|
|
63325
63386
|
this._scheduleReconnection(options2, attemptCount + 1);
|
|
63326
63387
|
});
|
|
63327
|
-
},
|
|
63388
|
+
}, delay2);
|
|
63328
63389
|
}
|
|
63329
63390
|
_handleSseStream(stream, options2, isReconnectable) {
|
|
63330
63391
|
if (!stream) {
|
|
@@ -64657,7 +64718,7 @@ var init_protocol = __esm({
|
|
|
64657
64718
|
return;
|
|
64658
64719
|
}
|
|
64659
64720
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
64660
|
-
await new Promise((
|
|
64721
|
+
await new Promise((resolve27) => setTimeout(resolve27, pollInterval));
|
|
64661
64722
|
options2?.signal?.throwIfAborted();
|
|
64662
64723
|
}
|
|
64663
64724
|
} catch (error3) {
|
|
@@ -64674,7 +64735,7 @@ var init_protocol = __esm({
|
|
|
64674
64735
|
*/
|
|
64675
64736
|
request(request2, resultSchema, options2) {
|
|
64676
64737
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options2 ?? {};
|
|
64677
|
-
return new Promise((
|
|
64738
|
+
return new Promise((resolve27, reject) => {
|
|
64678
64739
|
const earlyReject = /* @__PURE__ */ __name((error3) => {
|
|
64679
64740
|
reject(error3);
|
|
64680
64741
|
}, "earlyReject");
|
|
@@ -64752,7 +64813,7 @@ var init_protocol = __esm({
|
|
|
64752
64813
|
if (!parseResult.success) {
|
|
64753
64814
|
reject(parseResult.error);
|
|
64754
64815
|
} else {
|
|
64755
|
-
|
|
64816
|
+
resolve27(parseResult.data);
|
|
64756
64817
|
}
|
|
64757
64818
|
} catch (error3) {
|
|
64758
64819
|
reject(error3);
|
|
@@ -65014,12 +65075,12 @@ var init_protocol = __esm({
|
|
|
65014
65075
|
}
|
|
65015
65076
|
} catch {
|
|
65016
65077
|
}
|
|
65017
|
-
return new Promise((
|
|
65078
|
+
return new Promise((resolve27, reject) => {
|
|
65018
65079
|
if (signal.aborted) {
|
|
65019
65080
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
65020
65081
|
return;
|
|
65021
65082
|
}
|
|
65022
|
-
const timeoutId = setTimeout(
|
|
65083
|
+
const timeoutId = setTimeout(resolve27, interval);
|
|
65023
65084
|
signal.addEventListener("abort", () => {
|
|
65024
65085
|
clearTimeout(timeoutId);
|
|
65025
65086
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -68305,7 +68366,7 @@ var require_compile = __commonJS({
|
|
|
68305
68366
|
const schOrFunc = root.refs[ref];
|
|
68306
68367
|
if (schOrFunc)
|
|
68307
68368
|
return schOrFunc;
|
|
68308
|
-
let _sch =
|
|
68369
|
+
let _sch = resolve27.call(this, root, ref);
|
|
68309
68370
|
if (_sch === void 0) {
|
|
68310
68371
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
68311
68372
|
const { schemaId } = this.opts;
|
|
@@ -68336,13 +68397,13 @@ var require_compile = __commonJS({
|
|
|
68336
68397
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
68337
68398
|
}
|
|
68338
68399
|
__name(sameSchemaEnv, "sameSchemaEnv");
|
|
68339
|
-
function
|
|
68400
|
+
function resolve27(root, ref) {
|
|
68340
68401
|
let sch;
|
|
68341
68402
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
68342
68403
|
ref = sch;
|
|
68343
68404
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
68344
68405
|
}
|
|
68345
|
-
__name(
|
|
68406
|
+
__name(resolve27, "resolve");
|
|
68346
68407
|
function resolveSchema(root, ref) {
|
|
68347
68408
|
const p2 = this.opts.uriResolver.parse(ref);
|
|
68348
68409
|
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p2);
|
|
@@ -69237,7 +69298,7 @@ var require_fast_uri = __commonJS({
|
|
|
69237
69298
|
return uri;
|
|
69238
69299
|
}
|
|
69239
69300
|
__name(normalize3, "normalize");
|
|
69240
|
-
function
|
|
69301
|
+
function resolve27(baseURI, relativeURI, options2) {
|
|
69241
69302
|
const schemelessOptions = options2 ? Object.assign({ scheme: "null" }, options2) : { scheme: "null" };
|
|
69242
69303
|
const {
|
|
69243
69304
|
parsed: baseParsed,
|
|
@@ -69273,7 +69334,7 @@ var require_fast_uri = __commonJS({
|
|
|
69273
69334
|
schemelessOptions.skipEscape = true;
|
|
69274
69335
|
return serialize(resolved, schemelessOptions);
|
|
69275
69336
|
}
|
|
69276
|
-
__name(
|
|
69337
|
+
__name(resolve27, "resolve");
|
|
69277
69338
|
function resolveComponent(base, relative15, options2, skipNormalization) {
|
|
69278
69339
|
const target = {};
|
|
69279
69340
|
if (!skipNormalization) {
|
|
@@ -69644,7 +69705,7 @@ var require_fast_uri = __commonJS({
|
|
|
69644
69705
|
var fastUri = {
|
|
69645
69706
|
SCHEMES,
|
|
69646
69707
|
normalize: normalize3,
|
|
69647
|
-
resolve:
|
|
69708
|
+
resolve: resolve27,
|
|
69648
69709
|
resolveComponent,
|
|
69649
69710
|
equal,
|
|
69650
69711
|
serialize,
|
|
@@ -73654,7 +73715,12 @@ async function createPlatformMcpTransport(token, options2 = {}) {
|
|
|
73654
73715
|
fetch: /* @__PURE__ */ __name(((url3, init) => {
|
|
73655
73716
|
const request2 = init;
|
|
73656
73717
|
const signal = options2.signal && request2?.signal ? AbortSignal.any([options2.signal, request2.signal]) : options2.signal ?? request2?.signal;
|
|
73657
|
-
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
|
+
});
|
|
73658
73724
|
}), "fetch"),
|
|
73659
73725
|
requestInit: {
|
|
73660
73726
|
headers: {
|
|
@@ -73829,6 +73895,7 @@ var init_platform_tools = __esm({
|
|
|
73829
73895
|
"dist/lib/platform-tools.js"() {
|
|
73830
73896
|
"use strict";
|
|
73831
73897
|
init_http();
|
|
73898
|
+
init_poll_delay();
|
|
73832
73899
|
init_client();
|
|
73833
73900
|
init_config();
|
|
73834
73901
|
init_repro_guidance();
|
|
@@ -74515,7 +74582,7 @@ function typecheckTimeoutMs() {
|
|
|
74515
74582
|
}
|
|
74516
74583
|
function runBounded(command, args, cwd, options2 = {}) {
|
|
74517
74584
|
const timeoutMs = options2.timeoutMs ?? typecheckTimeoutMs();
|
|
74518
|
-
return new Promise((
|
|
74585
|
+
return new Promise((resolve27) => {
|
|
74519
74586
|
const posixGroup = process.platform !== "win32";
|
|
74520
74587
|
let child;
|
|
74521
74588
|
try {
|
|
@@ -74529,7 +74596,7 @@ function runBounded(command, args, cwd, options2 = {}) {
|
|
|
74529
74596
|
shell: /\.(cmd|bat)$/i.test(command)
|
|
74530
74597
|
});
|
|
74531
74598
|
} catch (err) {
|
|
74532
|
-
|
|
74599
|
+
resolve27({ code: null, out: "", stdout: "", error: err instanceof Error ? err : new Error(String(err)), timedOut: false });
|
|
74533
74600
|
return;
|
|
74534
74601
|
}
|
|
74535
74602
|
let out = "", stdout = "", timedOut = false, closed = false, settled = false, aborting = false, stopping = null, stopIncomplete = false;
|
|
@@ -74582,7 +74649,7 @@ function runBounded(command, args, cwd, options2 = {}) {
|
|
|
74582
74649
|
clearTimeout(timer);
|
|
74583
74650
|
process.off("SIGINT", onInt);
|
|
74584
74651
|
process.off("SIGTERM", onTerm);
|
|
74585
|
-
|
|
74652
|
+
resolve27({
|
|
74586
74653
|
code: closeCode,
|
|
74587
74654
|
out,
|
|
74588
74655
|
stdout,
|
|
@@ -75682,7 +75749,7 @@ var init_handler = __esm({
|
|
|
75682
75749
|
this._addToNodeFs(path3, initialAdd, wh, depth + 1);
|
|
75683
75750
|
}
|
|
75684
75751
|
}).on(EV.ERROR, this._boundHandleError);
|
|
75685
|
-
return new Promise((
|
|
75752
|
+
return new Promise((resolve27, reject) => {
|
|
75686
75753
|
if (!stream)
|
|
75687
75754
|
return reject();
|
|
75688
75755
|
stream.once(STR_END, () => {
|
|
@@ -75691,7 +75758,7 @@ var init_handler = __esm({
|
|
|
75691
75758
|
return;
|
|
75692
75759
|
}
|
|
75693
75760
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
75694
|
-
|
|
75761
|
+
resolve27(void 0);
|
|
75695
75762
|
previous.getChildren().filter((item) => {
|
|
75696
75763
|
return item !== directory2 && !current.has(item);
|
|
75697
75764
|
}).forEach((item) => {
|
|
@@ -78019,35 +78086,70 @@ async function awaitDeployChecks(client, checks, opts = {}) {
|
|
|
78019
78086
|
if (!target)
|
|
78020
78087
|
return null;
|
|
78021
78088
|
const now2 = opts.now ?? Date.now;
|
|
78022
|
-
const
|
|
78023
|
-
const pollMs = opts.pollMs ?? DEPLOY_CHECKS_POLL_MS;
|
|
78089
|
+
const sleep5 = opts.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
|
|
78024
78090
|
const deadline = now2() + (opts.waitMs ?? TEST_CHECKS_WAIT_MS);
|
|
78025
78091
|
let last = null;
|
|
78026
|
-
|
|
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;
|
|
78027
78098
|
try {
|
|
78028
|
-
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") });
|
|
78029
78102
|
if (read?.access_check)
|
|
78030
78103
|
last = read.access_check;
|
|
78031
78104
|
if (last && last.status !== "pending")
|
|
78032
78105
|
return last;
|
|
78033
|
-
|
|
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;
|
|
78034
78114
|
}
|
|
78035
|
-
|
|
78036
|
-
return last;
|
|
78037
|
-
await sleep3(pollMs);
|
|
78115
|
+
delay2 = Math.max(opts.pollMs ?? interactivePollDelay(attempt), retryAfter);
|
|
78038
78116
|
}
|
|
78117
|
+
return last ?? (rateLimited && opts.readStored ? { status: "unavailable", sentence: "The platform asked us to wait before reading the check again." } : null);
|
|
78039
78118
|
}
|
|
78040
78119
|
async function runChecksNow(client, projectId, opts = {}) {
|
|
78041
|
-
if (!opts.again) {
|
|
78120
|
+
if (!opts.again && opts.only === void 0) {
|
|
78042
78121
|
const read = `GET /v1/deploy/log?project_id=${encodeURIComponent(projectId)}`;
|
|
78043
|
-
const stored = await awaitDeployChecks(client, { read }, { ...opts,
|
|
78044
|
-
if (stored && stored.status !== "pending")
|
|
78045
|
-
return stored;
|
|
78122
|
+
const stored = await awaitDeployChecks(client, { read }, { ...opts, readStored: true });
|
|
78046
78123
|
if (stored)
|
|
78047
|
-
return
|
|
78124
|
+
return stored;
|
|
78048
78125
|
}
|
|
78049
|
-
|
|
78050
|
-
|
|
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.");
|
|
78136
|
+
}
|
|
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
|
+
};
|
|
78051
78153
|
}
|
|
78052
78154
|
function lineOutcome(line) {
|
|
78053
78155
|
if (line.outcome)
|
|
@@ -78094,6 +78196,13 @@ function resultEvidence(line) {
|
|
|
78094
78196
|
function formatChecksReport(check) {
|
|
78095
78197
|
const summary = deployChecksSummary(check);
|
|
78096
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
|
+
}
|
|
78097
78206
|
if (!check || check.status === "pending") {
|
|
78098
78207
|
lines.push(`Could not check: the run did not finish within ${TEST_CHECKS_WAIT_MS / 1e3} s.`);
|
|
78099
78208
|
} else if (check.status !== "checked") {
|
|
@@ -78128,7 +78237,7 @@ function formatChecksReport(check) {
|
|
|
78128
78237
|
}
|
|
78129
78238
|
if (!checks.length)
|
|
78130
78239
|
lines.push("Could not check: no named checks ran.");
|
|
78131
|
-
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")))
|
|
78132
78241
|
lines.push(`Could not check: run ${cliInvocation()} test --again to get named results.`);
|
|
78133
78242
|
}
|
|
78134
78243
|
const coverage = check?.not_checked ?? null;
|
|
@@ -78151,24 +78260,29 @@ function formatChecksReport(check) {
|
|
|
78151
78260
|
} else {
|
|
78152
78261
|
lines.push("Coverage details are unavailable for this run.");
|
|
78153
78262
|
}
|
|
78263
|
+
lines.push("For your own app tests, use @somewhere-cloud/cli/testing. See somewhere docs test.");
|
|
78154
78264
|
return [...lines, JSON.stringify({
|
|
78155
78265
|
...summary,
|
|
78156
78266
|
not_checked: coverage,
|
|
78267
|
+
...check?.scope === "partial" ? { scope: check.scope, selection: check.selection, checked_parts: check.checked_parts } : {},
|
|
78157
78268
|
...coverage ? { routes_checked: check?.routes_checked, routes_discovered: check?.routes_discovered } : {}
|
|
78158
78269
|
})];
|
|
78159
78270
|
}
|
|
78160
|
-
var
|
|
78271
|
+
var DEPLOY_CHECKS_RUNNING, TEST_CHECKS_WAIT_MS, selectionLabel, cleanupFindings, functionWarnings;
|
|
78161
78272
|
var init_deploy_checks = __esm({
|
|
78162
78273
|
"dist/lib/deploy-checks.js"() {
|
|
78163
78274
|
"use strict";
|
|
78164
78275
|
init_cli_invocation();
|
|
78276
|
+
init_client();
|
|
78277
|
+
init_poll_delay();
|
|
78165
78278
|
init_check_summary();
|
|
78166
|
-
DEPLOY_CHECKS_POLL_MS = 3e3;
|
|
78167
78279
|
__name(parseChecksRead, "parseChecksRead");
|
|
78168
78280
|
__name(awaitDeployChecks, "awaitDeployChecks");
|
|
78169
78281
|
DEPLOY_CHECKS_RUNNING = `Checks: running in the background; \`${cliInvocation()} test\` shows the result.`;
|
|
78170
78282
|
TEST_CHECKS_WAIT_MS = 15e4;
|
|
78171
78283
|
__name(runChecksNow, "runChecksNow");
|
|
78284
|
+
selectionLabel = /* @__PURE__ */ __name((selection) => selection === "access" ? "Access probes" : selection === "crawl" ? "Browser page crawl" : selection, "selectionLabel");
|
|
78285
|
+
__name(partialCheckUnavailable, "partialCheckUnavailable");
|
|
78172
78286
|
__name(lineOutcome, "lineOutcome");
|
|
78173
78287
|
cleanupFindings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((f2) => f2.kind === "cleanup"), "cleanupFindings");
|
|
78174
78288
|
functionWarnings = /* @__PURE__ */ __name((check) => (check?.findings ?? []).filter((finding) => finding.kind === "function_http_error" || finding.kind === "crash" && Boolean(finding.request_id)), "functionWarnings");
|
|
@@ -78267,13 +78381,13 @@ async function awaitPostLiveRender(client, projectId, result, opts = {}) {
|
|
|
78267
78381
|
if (result.post_live_render?.status !== "pending" || !result.release_id || !projectId)
|
|
78268
78382
|
return { kind: "not_pending" };
|
|
78269
78383
|
const now2 = opts.now ?? Date.now;
|
|
78270
|
-
const
|
|
78384
|
+
const sleep5 = opts.sleep ?? ((ms2) => new Promise((r) => setTimeout(r, ms2)));
|
|
78271
78385
|
let pollMs = opts.pollMs ?? POST_LIVE_RENDER_POLL_MS;
|
|
78272
78386
|
let nextDelayMs = opts.pollMs ?? 0;
|
|
78273
78387
|
const deadline = now2() + (opts.waitMs ?? POST_LIVE_RENDER_WAIT_MS);
|
|
78274
78388
|
while (now2() < deadline) {
|
|
78275
78389
|
if (nextDelayMs)
|
|
78276
|
-
await
|
|
78390
|
+
await sleep5(Math.min(nextDelayMs, Math.max(0, deadline - now2())));
|
|
78277
78391
|
nextDelayMs = pollMs;
|
|
78278
78392
|
pollMs = opts.pollMs ?? Math.min(400, pollMs * 2);
|
|
78279
78393
|
let read;
|
|
@@ -78681,23 +78795,24 @@ function readManifest(root) {
|
|
|
78681
78795
|
}
|
|
78682
78796
|
return value;
|
|
78683
78797
|
}
|
|
78684
|
-
function
|
|
78798
|
+
function preparedActorState(root, target, name) {
|
|
78685
78799
|
const manifest = readManifest(root);
|
|
78686
78800
|
const actor = manifest?.actors.find((item) => item.name === name);
|
|
78687
78801
|
if (!actor || manifest?.project_id !== target.projectId || manifest.origin !== target.origin) {
|
|
78688
78802
|
throw new Error("No prepared actor for this app. Run somewhere test-users prepare with the actor name.");
|
|
78689
78803
|
}
|
|
78804
|
+
const path3 = join24(stateDir(root), actor.state_file);
|
|
78690
78805
|
const domain = new URL(target.origin).hostname;
|
|
78691
78806
|
let state;
|
|
78692
78807
|
try {
|
|
78693
|
-
state = JSON.parse(readFileSync21(
|
|
78808
|
+
state = JSON.parse(readFileSync21(path3, "utf8"));
|
|
78694
78809
|
} catch {
|
|
78695
78810
|
throw new Error("Could not read the saved test user session.");
|
|
78696
78811
|
}
|
|
78697
|
-
const
|
|
78698
|
-
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)
|
|
78699
78814
|
throw new Error("The prepared actor has no app session in its saved state.");
|
|
78700
|
-
return
|
|
78815
|
+
return { path: path3, state: { cookies: state.cookies, origins: state.origins ?? [] }, access: token };
|
|
78701
78816
|
}
|
|
78702
78817
|
function writeManifest(root, manifest) {
|
|
78703
78818
|
writePrivateFile(join24(stateDir(root), MANIFEST_FILE), JSON.stringify(manifest, null, 2) + "\n");
|
|
@@ -78713,6 +78828,10 @@ function tokenTimes(accessToken) {
|
|
|
78713
78828
|
return null;
|
|
78714
78829
|
}
|
|
78715
78830
|
}
|
|
78831
|
+
function testAccessNeedsRefresh(token, now2 = Date.now()) {
|
|
78832
|
+
const times = token && tokenTimes(token);
|
|
78833
|
+
return !!times && times.exp * 1e3 <= now2 + 5e3;
|
|
78834
|
+
}
|
|
78716
78835
|
function buildStorageState(origin, host, issued, times) {
|
|
78717
78836
|
const cookie = /* @__PURE__ */ __name((name, value, expiresMs) => ({
|
|
78718
78837
|
name,
|
|
@@ -78837,9 +78956,10 @@ var init_test_identities = __esm({
|
|
|
78837
78956
|
__name(writePrivateFile, "writePrivateFile");
|
|
78838
78957
|
__name(ensureGitignored, "ensureGitignored");
|
|
78839
78958
|
__name(readManifest, "readManifest");
|
|
78840
|
-
__name(
|
|
78959
|
+
__name(preparedActorState, "preparedActorState");
|
|
78841
78960
|
__name(writeManifest, "writeManifest");
|
|
78842
78961
|
__name(tokenTimes, "tokenTimes");
|
|
78962
|
+
__name(testAccessNeedsRefresh, "testAccessNeedsRefresh");
|
|
78843
78963
|
__name(buildStorageState, "buildStorageState");
|
|
78844
78964
|
__name(parseIssued, "parseIssued");
|
|
78845
78965
|
__name(expiryOf, "expiryOf");
|
|
@@ -79201,7 +79321,7 @@ async function mintPreviewCredential(client, projectId, previewSessionId) {
|
|
|
79201
79321
|
}
|
|
79202
79322
|
function previewToolClient(credential) {
|
|
79203
79323
|
const client = new ApiClient(credential);
|
|
79204
|
-
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") };
|
|
79205
79325
|
}
|
|
79206
79326
|
function isDeadPreviewCredential(err) {
|
|
79207
79327
|
return err instanceof CliApiError && (err.code === "PREVIEW_CREDENTIAL_INVALID" || err.code === "PREVIEW_CREDENTIAL_REQUIRED");
|
|
@@ -79531,6 +79651,10 @@ function previewControl(tool, target, _root) {
|
|
|
79531
79651
|
throw previewFailure(error3, "The preview could not be confirmed at the end of the run");
|
|
79532
79652
|
}
|
|
79533
79653
|
},
|
|
79654
|
+
async previewCookie() {
|
|
79655
|
+
const held = await pinned();
|
|
79656
|
+
return { ...held.cookie, expiresAt: held.expires_at };
|
|
79657
|
+
},
|
|
79534
79658
|
createManagedUser: /* @__PURE__ */ __name(() => createPreviewManagedUser(tool), "createManagedUser"),
|
|
79535
79659
|
deleteManagedUser: /* @__PURE__ */ __name((id) => deletePreviewManagedUser(tool, id), "deleteManagedUser"),
|
|
79536
79660
|
async close() {
|
|
@@ -79604,12 +79728,12 @@ var init_test_control = __esm({
|
|
|
79604
79728
|
import { connect } from "node:net";
|
|
79605
79729
|
async function testAddressOrder(origin) {
|
|
79606
79730
|
const url3 = new URL(origin);
|
|
79607
|
-
const probe = /* @__PURE__ */ __name((family) => new Promise((
|
|
79731
|
+
const probe = /* @__PURE__ */ __name((family) => new Promise((resolve27) => {
|
|
79608
79732
|
const socket = connect({ host: url3.hostname, port: Number(url3.port || 443), family });
|
|
79609
79733
|
const finish = /* @__PURE__ */ __name((ok) => {
|
|
79610
79734
|
clearTimeout(deadline);
|
|
79611
79735
|
socket.destroy();
|
|
79612
|
-
|
|
79736
|
+
resolve27(ok);
|
|
79613
79737
|
}, "finish");
|
|
79614
79738
|
const deadline = setTimeout(() => finish(false), 300);
|
|
79615
79739
|
socket.once("connect", () => finish(true));
|
|
@@ -79747,7 +79871,7 @@ ${line}
|
|
|
79747
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 } });
|
|
79748
79872
|
if (input.toStderr)
|
|
79749
79873
|
child.stdout?.pipe(process.stderr);
|
|
79750
|
-
const status = await new Promise((
|
|
79874
|
+
const status = await new Promise((resolve27) => child.on("close", (code) => resolve27(code)));
|
|
79751
79875
|
mark("runner:exit", { status: status ?? -1 });
|
|
79752
79876
|
const after = await span("sweep:after", {}, () => sweepAccounts(control, root).catch((error3) => {
|
|
79753
79877
|
process.stderr.write(`Could not finish form sign-up cleanup: ${error3 instanceof Error ? error3.message : String(error3)}
|
|
@@ -80505,7 +80629,7 @@ function findBrowser(env = process.env, exists = existsSync26) {
|
|
|
80505
80629
|
return null;
|
|
80506
80630
|
}
|
|
80507
80631
|
function readEndpoint(child, timeoutMs) {
|
|
80508
|
-
return new Promise((
|
|
80632
|
+
return new Promise((resolve27, reject) => {
|
|
80509
80633
|
let buffered = "";
|
|
80510
80634
|
const timer = setTimeout(() => {
|
|
80511
80635
|
cleanup();
|
|
@@ -80517,7 +80641,7 @@ function readEndpoint(child, timeoutMs) {
|
|
|
80517
80641
|
if (!match)
|
|
80518
80642
|
return;
|
|
80519
80643
|
cleanup();
|
|
80520
|
-
|
|
80644
|
+
resolve27(match[0]);
|
|
80521
80645
|
}, "onData");
|
|
80522
80646
|
const onExit = /* @__PURE__ */ __name((code) => {
|
|
80523
80647
|
cleanup();
|
|
@@ -80551,9 +80675,9 @@ async function launchLocalBrowser(opts) {
|
|
|
80551
80675
|
], { stdio: ["ignore", "ignore", "pipe"], env: browserEnv });
|
|
80552
80676
|
const cleanup = /* @__PURE__ */ __name(async () => {
|
|
80553
80677
|
if (child.exitCode === null && child.signalCode === null) {
|
|
80554
|
-
const exited = new Promise((
|
|
80555
|
-
child.once("exit", () =>
|
|
80556
|
-
setTimeout(
|
|
80678
|
+
const exited = new Promise((resolve27) => {
|
|
80679
|
+
child.once("exit", () => resolve27());
|
|
80680
|
+
setTimeout(resolve27, 2e3).unref();
|
|
80557
80681
|
});
|
|
80558
80682
|
try {
|
|
80559
80683
|
child.kill("SIGKILL");
|
|
@@ -80617,11 +80741,11 @@ var init_chrome = __esm({
|
|
|
80617
80741
|
}
|
|
80618
80742
|
static async connect(wsUrl, timeoutMs) {
|
|
80619
80743
|
const socket = new import_undici2.WebSocket(wsUrl);
|
|
80620
|
-
await new Promise((
|
|
80744
|
+
await new Promise((resolve27, reject) => {
|
|
80621
80745
|
const timer = setTimeout(() => reject(new Error("Timed out connecting to the browser.")), timeoutMs);
|
|
80622
80746
|
socket.addEventListener("open", () => {
|
|
80623
80747
|
clearTimeout(timer);
|
|
80624
|
-
|
|
80748
|
+
resolve27();
|
|
80625
80749
|
}, { once: true });
|
|
80626
80750
|
socket.addEventListener("error", () => {
|
|
80627
80751
|
clearTimeout(timer);
|
|
@@ -80682,7 +80806,7 @@ var init_chrome = __esm({
|
|
|
80682
80806
|
if (this.closed)
|
|
80683
80807
|
return Promise.reject(new Error("The connection to the browser is closed."));
|
|
80684
80808
|
const id = this.nextId++;
|
|
80685
|
-
return new Promise((
|
|
80809
|
+
return new Promise((resolve27, reject) => {
|
|
80686
80810
|
const timer = setTimeout(() => {
|
|
80687
80811
|
this.pending.delete(id);
|
|
80688
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.`));
|
|
@@ -80691,7 +80815,7 @@ var init_chrome = __esm({
|
|
|
80691
80815
|
this.pending.set(id, {
|
|
80692
80816
|
resolve: /* @__PURE__ */ __name((v2) => {
|
|
80693
80817
|
clearTimeout(timer);
|
|
80694
|
-
|
|
80818
|
+
resolve27(v2);
|
|
80695
80819
|
}, "resolve"),
|
|
80696
80820
|
reject: /* @__PURE__ */ __name((e) => {
|
|
80697
80821
|
clearTimeout(timer);
|
|
@@ -80772,8 +80896,8 @@ async function assertLocalTargetReachable(url3, timeoutMs = REACHABILITY_TIMEOUT
|
|
|
80772
80896
|
}
|
|
80773
80897
|
}
|
|
80774
80898
|
function sleep(ms2) {
|
|
80775
|
-
return new Promise((
|
|
80776
|
-
setTimeout(
|
|
80899
|
+
return new Promise((resolve27) => {
|
|
80900
|
+
setTimeout(resolve27, ms2).unref();
|
|
80777
80901
|
});
|
|
80778
80902
|
}
|
|
80779
80903
|
async function evaluate(session, expression) {
|
|
@@ -81113,10 +81237,10 @@ async function runLocalBrowser(req) {
|
|
|
81113
81237
|
mobile: false
|
|
81114
81238
|
});
|
|
81115
81239
|
let loadFired = false;
|
|
81116
|
-
const loaded2 = new Promise((
|
|
81240
|
+
const loaded2 = new Promise((resolve27) => {
|
|
81117
81241
|
session.on("Page.loadEventFired", () => {
|
|
81118
81242
|
loadFired = true;
|
|
81119
|
-
|
|
81243
|
+
resolve27();
|
|
81120
81244
|
});
|
|
81121
81245
|
});
|
|
81122
81246
|
await session.send("Page.navigate", { url: startUrl });
|
|
@@ -81124,8 +81248,8 @@ async function runLocalBrowser(req) {
|
|
|
81124
81248
|
let loadTimer;
|
|
81125
81249
|
await Promise.race([
|
|
81126
81250
|
loaded2,
|
|
81127
|
-
new Promise((
|
|
81128
|
-
loadTimer = setTimeout(
|
|
81251
|
+
new Promise((resolve27) => {
|
|
81252
|
+
loadTimer = setTimeout(resolve27, navigationBudgetMs);
|
|
81129
81253
|
loadTimer.unref();
|
|
81130
81254
|
})
|
|
81131
81255
|
]);
|
|
@@ -85129,16 +85253,51 @@ function deployRetriedAfterTransportFailure(err) {
|
|
|
85129
85253
|
}
|
|
85130
85254
|
async function callDeployWithRetry(client, body, opts) {
|
|
85131
85255
|
let transportFailure = null;
|
|
85132
|
-
|
|
85256
|
+
let attempt = 1;
|
|
85257
|
+
let publicationDeadline;
|
|
85258
|
+
let publicationRetries = 0;
|
|
85259
|
+
let confirmation;
|
|
85260
|
+
let pendingResponse;
|
|
85261
|
+
for (; ; ) {
|
|
85133
85262
|
const startedAt = Date.now();
|
|
85134
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())));
|
|
85135
85265
|
try {
|
|
85136
|
-
return await client.call("POST", "/deploy", body, void 0, {
|
|
85137
|
-
timeoutMs
|
|
85138
|
-
|
|
85266
|
+
return await client.call("POST", "/deploy", confirmation ?? body, void 0, {
|
|
85267
|
+
timeoutMs,
|
|
85268
|
+
...publicationDeadline === void 0 ? {} : { refresh: false }
|
|
85269
|
+
}).finally(stopHeartbeat);
|
|
85139
85270
|
} catch (err) {
|
|
85140
85271
|
if (transportFailure && err && typeof err === "object")
|
|
85141
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;
|
|
85142
85301
|
if (attempt >= DEPLOY_MAX_ATTEMPTS)
|
|
85143
85302
|
throw err;
|
|
85144
85303
|
if (!isRetryableDeployError(err))
|
|
@@ -85154,11 +85313,9 @@ async function callDeployWithRetry(client, body, opts) {
|
|
|
85154
85313
|
}
|
|
85155
85314
|
if (waitMs)
|
|
85156
85315
|
await new Promise((r) => setTimeout(r, waitMs));
|
|
85157
|
-
|
|
85158
|
-
stopHeartbeat();
|
|
85316
|
+
attempt++;
|
|
85159
85317
|
}
|
|
85160
85318
|
}
|
|
85161
|
-
throw new CliApiError("DEPLOY_RETRY_EXHAUSTED", "Deploy retry exhausted.", 0);
|
|
85162
85319
|
}
|
|
85163
85320
|
function outcomeUnknown(err) {
|
|
85164
85321
|
if (!(err instanceof CliApiError))
|
|
@@ -85328,7 +85485,7 @@ ${teal("Dry run")}${dim(scopeNote)} \u2014 nothing was deployed.
|
|
|
85328
85485
|
}
|
|
85329
85486
|
console.log("");
|
|
85330
85487
|
}
|
|
85331
|
-
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;
|
|
85332
85489
|
var init_deploy = __esm({
|
|
85333
85490
|
"dist/commands/deploy.js"() {
|
|
85334
85491
|
"use strict";
|
|
@@ -85384,6 +85541,8 @@ var init_deploy = __esm({
|
|
|
85384
85541
|
DEPLOY_MAX_ATTEMPTS = 2;
|
|
85385
85542
|
RETRYABLE_DEPLOY_CODES = /* @__PURE__ */ new Set(["TIMEOUT", "SERVER_SLOW", "NETWORK_ERROR"]);
|
|
85386
85543
|
DEPLOY_RETRY_MAX_WAIT_MS = 1e4;
|
|
85544
|
+
PUBLICATION_RETRY_BUDGET_MS = 3e4;
|
|
85545
|
+
PUBLICATION_RETRY_DELAYS_MS = [1e3, 2e3, 4e3, 8e3];
|
|
85387
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.`;
|
|
85388
85547
|
__name(isNextAppShapeSignal, "isNextAppShapeSignal");
|
|
85389
85548
|
__name(detectNextAppShape, "detectNextAppShape");
|
|
@@ -87260,7 +87419,7 @@ async function callAdvisorRun(args) {
|
|
|
87260
87419
|
if (result.status !== "settled" && !result.answer)
|
|
87261
87420
|
args.progress?.(`Advisor is working. To reconnect: ${cliInvocation()} advisor --resume ` + record3.request_id);
|
|
87262
87421
|
while (result.status !== "settled" && !result.answer && !result.payload_expired) {
|
|
87263
|
-
await new Promise((
|
|
87422
|
+
await new Promise((resolve27) => setTimeout(resolve27, Math.min(1e4, Math.max(1e3, (result.retry_after_seconds ?? 2) * 1e3))));
|
|
87264
87423
|
result = await request(record3, result.next_step === "resume" ? "resume" : "status");
|
|
87265
87424
|
}
|
|
87266
87425
|
return result;
|
|
@@ -89544,6 +89703,7 @@ var init_frontend_dev = __esm({
|
|
|
89544
89703
|
});
|
|
89545
89704
|
|
|
89546
89705
|
// dist/lib/preview-jobs.js
|
|
89706
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
89547
89707
|
async function folderPreviewTool(opts) {
|
|
89548
89708
|
const projectId = opts.project ?? loadProjectConfig()?.project_id;
|
|
89549
89709
|
if (!projectId)
|
|
@@ -89557,16 +89717,37 @@ async function folderPreviewTool(opts) {
|
|
|
89557
89717
|
async function previewCurrentVersion(credential) {
|
|
89558
89718
|
return previewToolClient(credential).call("GET", "/preview-tools/whoami");
|
|
89559
89719
|
}
|
|
89560
|
-
async function waitForPreviewJob(credential, jobId, timeoutSeconds) {
|
|
89720
|
+
async function waitForPreviewJob(credential, jobId, timeoutSeconds, firstDelayMs = 0) {
|
|
89561
89721
|
const client = previewToolClient(credential);
|
|
89562
89722
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
89563
|
-
|
|
89564
|
-
|
|
89565
|
-
|
|
89566
|
-
|
|
89567
|
-
if (
|
|
89568
|
-
|
|
89569
|
-
|
|
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);
|
|
89570
89751
|
}
|
|
89571
89752
|
}
|
|
89572
89753
|
var TERMINAL;
|
|
@@ -89575,6 +89756,7 @@ var init_preview_jobs = __esm({
|
|
|
89575
89756
|
"use strict";
|
|
89576
89757
|
init_cli_invocation();
|
|
89577
89758
|
init_client();
|
|
89759
|
+
init_poll_delay();
|
|
89578
89760
|
init_config();
|
|
89579
89761
|
init_preview_credential();
|
|
89580
89762
|
init_preview_record();
|
|
@@ -91684,12 +91866,12 @@ var init_stdio2 = __esm({
|
|
|
91684
91866
|
this.onclose?.();
|
|
91685
91867
|
}
|
|
91686
91868
|
send(message3) {
|
|
91687
|
-
return new Promise((
|
|
91869
|
+
return new Promise((resolve27) => {
|
|
91688
91870
|
const json = serializeMessage(message3);
|
|
91689
91871
|
if (this._stdout.write(json)) {
|
|
91690
|
-
|
|
91872
|
+
resolve27();
|
|
91691
91873
|
} else {
|
|
91692
|
-
this._stdout.once("drain",
|
|
91874
|
+
this._stdout.once("drain", resolve27);
|
|
91693
91875
|
}
|
|
91694
91876
|
});
|
|
91695
91877
|
}
|
|
@@ -91829,7 +92011,7 @@ async function runStdioBridge() {
|
|
|
91829
92011
|
try {
|
|
91830
92012
|
transport = await createHttpTransport(token);
|
|
91831
92013
|
const id = `somewhere-bridge-probe-${++probeSeq}`;
|
|
91832
|
-
const answered = new Promise((
|
|
92014
|
+
const answered = new Promise((resolve27, reject) => {
|
|
91833
92015
|
const timer = setTimeout(() => {
|
|
91834
92016
|
probes.delete(id);
|
|
91835
92017
|
reject(new Error("no answer to tools/list within 15s"));
|
|
@@ -91837,7 +92019,7 @@ async function runStdioBridge() {
|
|
|
91837
92019
|
probes.set(id, (message3) => {
|
|
91838
92020
|
clearTimeout(timer);
|
|
91839
92021
|
probes.delete(id);
|
|
91840
|
-
|
|
92022
|
+
resolve27(message3);
|
|
91841
92023
|
});
|
|
91842
92024
|
});
|
|
91843
92025
|
await transport.send({ jsonrpc: "2.0", id, method: "tools/list", params: {} });
|
|
@@ -99217,13 +99399,13 @@ var require_lib2 = __commonJS({
|
|
|
99217
99399
|
unref: options2.unref,
|
|
99218
99400
|
maxRetryTime: options2.maxRetryTime
|
|
99219
99401
|
});
|
|
99220
|
-
return new Promise(function(
|
|
99402
|
+
return new Promise(function(resolve27, reject) {
|
|
99221
99403
|
operation.attempt(async (number4) => {
|
|
99222
99404
|
try {
|
|
99223
99405
|
const result = await fn((err) => {
|
|
99224
99406
|
throw Object.assign(new Error("Retrying"), { code: "EPROMISERETRY", retried: err });
|
|
99225
99407
|
}, number4, operation);
|
|
99226
|
-
return
|
|
99408
|
+
return resolve27(result);
|
|
99227
99409
|
} catch (err) {
|
|
99228
99410
|
if (!isRetryError(err)) {
|
|
99229
99411
|
return reject(err);
|
|
@@ -99988,10 +100170,10 @@ var require_commonjs = __commonJS({
|
|
|
99988
100170
|
* Return a void Promise that resolves once the stream ends.
|
|
99989
100171
|
*/
|
|
99990
100172
|
async promise() {
|
|
99991
|
-
return new Promise((
|
|
100173
|
+
return new Promise((resolve27, reject) => {
|
|
99992
100174
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
99993
100175
|
this.on("error", (er2) => reject(er2));
|
|
99994
|
-
this.on("end", () =>
|
|
100176
|
+
this.on("end", () => resolve27());
|
|
99995
100177
|
});
|
|
99996
100178
|
}
|
|
99997
100179
|
/**
|
|
@@ -100015,7 +100197,7 @@ var require_commonjs = __commonJS({
|
|
|
100015
100197
|
return Promise.resolve({ done: false, value: res });
|
|
100016
100198
|
if (this[EOF])
|
|
100017
100199
|
return stop();
|
|
100018
|
-
let
|
|
100200
|
+
let resolve27;
|
|
100019
100201
|
let reject;
|
|
100020
100202
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
100021
100203
|
this.off("data", ondata);
|
|
@@ -100029,19 +100211,19 @@ var require_commonjs = __commonJS({
|
|
|
100029
100211
|
this.off("end", onend);
|
|
100030
100212
|
this.off(DESTROYED, ondestroy);
|
|
100031
100213
|
this.pause();
|
|
100032
|
-
|
|
100214
|
+
resolve27({ value, done: !!this[EOF] });
|
|
100033
100215
|
}, "ondata");
|
|
100034
100216
|
const onend = /* @__PURE__ */ __name(() => {
|
|
100035
100217
|
this.off("error", onerr);
|
|
100036
100218
|
this.off("data", ondata);
|
|
100037
100219
|
this.off(DESTROYED, ondestroy);
|
|
100038
100220
|
stop();
|
|
100039
|
-
|
|
100221
|
+
resolve27({ done: true, value: void 0 });
|
|
100040
100222
|
}, "onend");
|
|
100041
100223
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
100042
100224
|
return new Promise((res2, rej) => {
|
|
100043
100225
|
reject = rej;
|
|
100044
|
-
|
|
100226
|
+
resolve27 = res2;
|
|
100045
100227
|
this.once(DESTROYED, ondestroy);
|
|
100046
100228
|
this.once("error", onerr);
|
|
100047
100229
|
this.once("end", onend);
|
|
@@ -104794,12 +104976,12 @@ var require_body2 = __commonJS({
|
|
|
104794
104976
|
if (resTimeout && resTimeout.unref) {
|
|
104795
104977
|
resTimeout.unref();
|
|
104796
104978
|
}
|
|
104797
|
-
return new Promise((
|
|
104979
|
+
return new Promise((resolve27) => {
|
|
104798
104980
|
if (stream !== upstream) {
|
|
104799
104981
|
upstream.on("error", (er2) => stream.emit("error", er2));
|
|
104800
104982
|
upstream.pipe(stream);
|
|
104801
104983
|
}
|
|
104802
|
-
|
|
104984
|
+
resolve27();
|
|
104803
104985
|
}).then(() => stream.concat()).then((buf) => {
|
|
104804
104986
|
clearTimeout(resTimeout);
|
|
104805
104987
|
return buf;
|
|
@@ -105565,7 +105747,7 @@ var require_lib4 = __commonJS({
|
|
|
105565
105747
|
var fetch2 = /* @__PURE__ */ __name(async (url3, opts) => {
|
|
105566
105748
|
if (/^data:/.test(url3)) {
|
|
105567
105749
|
const request2 = new Request(url3, opts);
|
|
105568
|
-
return Promise.resolve().then(() => new Promise((
|
|
105750
|
+
return Promise.resolve().then(() => new Promise((resolve27, reject) => {
|
|
105569
105751
|
let type, data2;
|
|
105570
105752
|
try {
|
|
105571
105753
|
const { pathname, search } = new URL2(url3);
|
|
@@ -105589,10 +105771,10 @@ var require_lib4 = __commonJS({
|
|
|
105589
105771
|
if (type) {
|
|
105590
105772
|
headers["Content-Type"] = type;
|
|
105591
105773
|
}
|
|
105592
|
-
return
|
|
105774
|
+
return resolve27(new Response2(data2, { headers }));
|
|
105593
105775
|
}));
|
|
105594
105776
|
}
|
|
105595
|
-
return new Promise((
|
|
105777
|
+
return new Promise((resolve27, reject) => {
|
|
105596
105778
|
const request2 = new Request(url3, opts);
|
|
105597
105779
|
let options2;
|
|
105598
105780
|
try {
|
|
@@ -105711,7 +105893,7 @@ var require_lib4 = __commonJS({
|
|
|
105711
105893
|
requestOpts.body = void 0;
|
|
105712
105894
|
requestOpts.headers.delete("content-length");
|
|
105713
105895
|
}
|
|
105714
|
-
|
|
105896
|
+
resolve27(fetch2(new Request(locationURL, requestOpts)));
|
|
105715
105897
|
finalize2();
|
|
105716
105898
|
return;
|
|
105717
105899
|
}
|
|
@@ -105739,7 +105921,7 @@ var require_lib4 = __commonJS({
|
|
|
105739
105921
|
const codings = headers.get("Content-Encoding");
|
|
105740
105922
|
if (!request2.compress || request2.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
105741
105923
|
response = new Response2(body, responseOptions);
|
|
105742
|
-
|
|
105924
|
+
resolve27(response);
|
|
105743
105925
|
return;
|
|
105744
105926
|
}
|
|
105745
105927
|
const zlibOptions = {
|
|
@@ -105758,7 +105940,7 @@ var require_lib4 = __commonJS({
|
|
|
105758
105940
|
).pipe(unzip),
|
|
105759
105941
|
responseOptions
|
|
105760
105942
|
);
|
|
105761
|
-
|
|
105943
|
+
resolve27(response);
|
|
105762
105944
|
return;
|
|
105763
105945
|
}
|
|
105764
105946
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -105770,7 +105952,7 @@ var require_lib4 = __commonJS({
|
|
|
105770
105952
|
(er2) => decoder2.emit("error", er2)
|
|
105771
105953
|
).pipe(decoder2);
|
|
105772
105954
|
response = new Response2(decoder2, responseOptions);
|
|
105773
|
-
|
|
105955
|
+
resolve27(response);
|
|
105774
105956
|
});
|
|
105775
105957
|
return;
|
|
105776
105958
|
}
|
|
@@ -105788,11 +105970,11 @@ var require_lib4 = __commonJS({
|
|
|
105788
105970
|
(er2) => decoder.emit("error", er2)
|
|
105789
105971
|
).pipe(decoder);
|
|
105790
105972
|
response = new Response2(decoder, responseOptions);
|
|
105791
|
-
|
|
105973
|
+
resolve27(response);
|
|
105792
105974
|
return;
|
|
105793
105975
|
}
|
|
105794
105976
|
response = new Response2(body, responseOptions);
|
|
105795
|
-
|
|
105977
|
+
resolve27(response);
|
|
105796
105978
|
});
|
|
105797
105979
|
writeToStream(req, request2);
|
|
105798
105980
|
});
|
|
@@ -107437,7 +107619,7 @@ var require_lib5 = __commonJS({
|
|
|
107437
107619
|
module.exports.fromStream = fromStream;
|
|
107438
107620
|
function fromStream(stream, opts) {
|
|
107439
107621
|
const istream = integrityStream(opts);
|
|
107440
|
-
return new Promise((
|
|
107622
|
+
return new Promise((resolve27, reject) => {
|
|
107441
107623
|
stream.pipe(istream);
|
|
107442
107624
|
stream.on("error", reject);
|
|
107443
107625
|
istream.on("error", reject);
|
|
@@ -107445,7 +107627,7 @@ var require_lib5 = __commonJS({
|
|
|
107445
107627
|
istream.on("integrity", (s3) => {
|
|
107446
107628
|
sri = s3;
|
|
107447
107629
|
});
|
|
107448
|
-
istream.on("end", () =>
|
|
107630
|
+
istream.on("end", () => resolve27(sri));
|
|
107449
107631
|
istream.resume();
|
|
107450
107632
|
});
|
|
107451
107633
|
}
|
|
@@ -107506,7 +107688,7 @@ var require_lib5 = __commonJS({
|
|
|
107506
107688
|
));
|
|
107507
107689
|
}
|
|
107508
107690
|
const checker = integrityStream(opts);
|
|
107509
|
-
return new Promise((
|
|
107691
|
+
return new Promise((resolve27, reject) => {
|
|
107510
107692
|
stream.pipe(checker);
|
|
107511
107693
|
stream.on("error", reject);
|
|
107512
107694
|
checker.on("error", reject);
|
|
@@ -107514,7 +107696,7 @@ var require_lib5 = __commonJS({
|
|
|
107514
107696
|
checker.on("verified", (s3) => {
|
|
107515
107697
|
verified = s3;
|
|
107516
107698
|
});
|
|
107517
|
-
checker.on("end", () =>
|
|
107699
|
+
checker.on("end", () => resolve27(verified));
|
|
107518
107700
|
checker.resume();
|
|
107519
107701
|
});
|
|
107520
107702
|
}
|
|
@@ -108152,10 +108334,10 @@ var require_minipass = __commonJS({
|
|
|
108152
108334
|
}
|
|
108153
108335
|
// stream.promise().then(() => done, er => emitted error)
|
|
108154
108336
|
promise() {
|
|
108155
|
-
return new Promise((
|
|
108337
|
+
return new Promise((resolve27, reject) => {
|
|
108156
108338
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
108157
108339
|
this.on("error", (er2) => reject(er2));
|
|
108158
|
-
this.on("end", () =>
|
|
108340
|
+
this.on("end", () => resolve27());
|
|
108159
108341
|
});
|
|
108160
108342
|
}
|
|
108161
108343
|
// for await (let chunk of stream)
|
|
@@ -108166,7 +108348,7 @@ var require_minipass = __commonJS({
|
|
|
108166
108348
|
return Promise.resolve({ done: false, value: res });
|
|
108167
108349
|
if (this[EOF])
|
|
108168
108350
|
return Promise.resolve({ done: true });
|
|
108169
|
-
let
|
|
108351
|
+
let resolve27 = null;
|
|
108170
108352
|
let reject = null;
|
|
108171
108353
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
108172
108354
|
this.removeListener("data", ondata);
|
|
@@ -108177,17 +108359,17 @@ var require_minipass = __commonJS({
|
|
|
108177
108359
|
this.removeListener("error", onerr);
|
|
108178
108360
|
this.removeListener("end", onend);
|
|
108179
108361
|
this.pause();
|
|
108180
|
-
|
|
108362
|
+
resolve27({ value, done: !!this[EOF] });
|
|
108181
108363
|
}, "ondata");
|
|
108182
108364
|
const onend = /* @__PURE__ */ __name(() => {
|
|
108183
108365
|
this.removeListener("error", onerr);
|
|
108184
108366
|
this.removeListener("data", ondata);
|
|
108185
|
-
|
|
108367
|
+
resolve27({ done: true });
|
|
108186
108368
|
}, "onend");
|
|
108187
108369
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
108188
108370
|
return new Promise((res2, rej) => {
|
|
108189
108371
|
reject = rej;
|
|
108190
|
-
|
|
108372
|
+
resolve27 = res2;
|
|
108191
108373
|
this.once(DESTROYED, ondestroy);
|
|
108192
108374
|
this.once("error", onerr);
|
|
108193
108375
|
this.once("end", onend);
|
|
@@ -108798,10 +108980,10 @@ var require_minipass2 = __commonJS({
|
|
|
108798
108980
|
}
|
|
108799
108981
|
// stream.promise().then(() => done, er => emitted error)
|
|
108800
108982
|
promise() {
|
|
108801
|
-
return new Promise((
|
|
108983
|
+
return new Promise((resolve27, reject) => {
|
|
108802
108984
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
108803
108985
|
this.on("error", (er2) => reject(er2));
|
|
108804
|
-
this.on("end", () =>
|
|
108986
|
+
this.on("end", () => resolve27());
|
|
108805
108987
|
});
|
|
108806
108988
|
}
|
|
108807
108989
|
// for await (let chunk of stream)
|
|
@@ -108812,7 +108994,7 @@ var require_minipass2 = __commonJS({
|
|
|
108812
108994
|
return Promise.resolve({ done: false, value: res });
|
|
108813
108995
|
if (this[EOF])
|
|
108814
108996
|
return Promise.resolve({ done: true });
|
|
108815
|
-
let
|
|
108997
|
+
let resolve27 = null;
|
|
108816
108998
|
let reject = null;
|
|
108817
108999
|
const onerr = /* @__PURE__ */ __name((er2) => {
|
|
108818
109000
|
this.removeListener("data", ondata);
|
|
@@ -108823,17 +109005,17 @@ var require_minipass2 = __commonJS({
|
|
|
108823
109005
|
this.removeListener("error", onerr);
|
|
108824
109006
|
this.removeListener("end", onend);
|
|
108825
109007
|
this.pause();
|
|
108826
|
-
|
|
109008
|
+
resolve27({ value, done: !!this[EOF] });
|
|
108827
109009
|
}, "ondata");
|
|
108828
109010
|
const onend = /* @__PURE__ */ __name(() => {
|
|
108829
109011
|
this.removeListener("error", onerr);
|
|
108830
109012
|
this.removeListener("data", ondata);
|
|
108831
|
-
|
|
109013
|
+
resolve27({ done: true });
|
|
108832
109014
|
}, "onend");
|
|
108833
109015
|
const ondestroy = /* @__PURE__ */ __name(() => onerr(new Error("stream destroyed")), "ondestroy");
|
|
108834
109016
|
return new Promise((res2, rej) => {
|
|
108835
109017
|
reject = rej;
|
|
108836
|
-
|
|
109018
|
+
resolve27 = res2;
|
|
108837
109019
|
this.once(DESTROYED, ondestroy);
|
|
108838
109020
|
this.once("error", onerr);
|
|
108839
109021
|
this.once("end", onend);
|
|
@@ -109197,7 +109379,7 @@ var require_polyfill = __commonJS({
|
|
|
109197
109379
|
isAbsolute: isAbsolute7,
|
|
109198
109380
|
join: join51,
|
|
109199
109381
|
parse: parse3,
|
|
109200
|
-
resolve:
|
|
109382
|
+
resolve: resolve27,
|
|
109201
109383
|
sep: sep2,
|
|
109202
109384
|
toNamespacedPath
|
|
109203
109385
|
} = __require("path");
|
|
@@ -109315,8 +109497,8 @@ var require_polyfill = __commonJS({
|
|
|
109315
109497
|
}
|
|
109316
109498
|
__name(pathExists, "pathExists");
|
|
109317
109499
|
async function checkParentPaths(src, srcStat, dest) {
|
|
109318
|
-
const srcParent =
|
|
109319
|
-
const destParent =
|
|
109500
|
+
const srcParent = resolve27(dirname16(src));
|
|
109501
|
+
const destParent = resolve27(dirname16(dest));
|
|
109320
109502
|
if (destParent === srcParent || destParent === parse3(destParent).root) {
|
|
109321
109503
|
return;
|
|
109322
109504
|
}
|
|
@@ -109340,7 +109522,7 @@ var require_polyfill = __commonJS({
|
|
|
109340
109522
|
return checkParentPaths(src, srcStat, destParent);
|
|
109341
109523
|
}
|
|
109342
109524
|
__name(checkParentPaths, "checkParentPaths");
|
|
109343
|
-
var normalizePathToArray = /* @__PURE__ */ __name((path3) =>
|
|
109525
|
+
var normalizePathToArray = /* @__PURE__ */ __name((path3) => resolve27(path3).split(sep2).filter(Boolean), "normalizePathToArray");
|
|
109344
109526
|
function isSrcSubdir(src, dest) {
|
|
109345
109527
|
const srcArr = normalizePathToArray(src);
|
|
109346
109528
|
const destArr = normalizePathToArray(dest);
|
|
@@ -109486,7 +109668,7 @@ var require_polyfill = __commonJS({
|
|
|
109486
109668
|
async function onLink(destStat, src, dest) {
|
|
109487
109669
|
let resolvedSrc = await readlink(src);
|
|
109488
109670
|
if (!isAbsolute7(resolvedSrc)) {
|
|
109489
|
-
resolvedSrc =
|
|
109671
|
+
resolvedSrc = resolve27(dirname16(src), resolvedSrc);
|
|
109490
109672
|
}
|
|
109491
109673
|
if (!destStat) {
|
|
109492
109674
|
return symlink(resolvedSrc, dest);
|
|
@@ -109501,7 +109683,7 @@ var require_polyfill = __commonJS({
|
|
|
109501
109683
|
throw err;
|
|
109502
109684
|
}
|
|
109503
109685
|
if (!isAbsolute7(resolvedDest)) {
|
|
109504
|
-
resolvedDest =
|
|
109686
|
+
resolvedDest = resolve27(dirname16(dest), resolvedDest);
|
|
109505
109687
|
}
|
|
109506
109688
|
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
109507
109689
|
throw new ERR_FS_CP_EINVAL({
|
|
@@ -109607,7 +109789,7 @@ var require_readdir_scoped = __commonJS({
|
|
|
109607
109789
|
// node_modules/@npmcli/fs/lib/move-file.js
|
|
109608
109790
|
var require_move_file = __commonJS({
|
|
109609
109791
|
"node_modules/@npmcli/fs/lib/move-file.js"(exports, module) {
|
|
109610
|
-
var { dirname: dirname16, join: join51, resolve:
|
|
109792
|
+
var { dirname: dirname16, join: join51, resolve: resolve27, relative: relative15, isAbsolute: isAbsolute7 } = __require("path");
|
|
109611
109793
|
var fs2 = __require("fs/promises");
|
|
109612
109794
|
var pathExists = /* @__PURE__ */ __name(async (path3) => {
|
|
109613
109795
|
try {
|
|
@@ -109652,11 +109834,11 @@ var require_move_file = __commonJS({
|
|
|
109652
109834
|
await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
|
|
109653
109835
|
let target = await fs2.readlink(symSource);
|
|
109654
109836
|
if (isAbsolute7(target)) {
|
|
109655
|
-
target =
|
|
109837
|
+
target = resolve27(symDestination, relative15(symSource, target));
|
|
109656
109838
|
}
|
|
109657
109839
|
let targetStat = "file";
|
|
109658
109840
|
try {
|
|
109659
|
-
targetStat = await fs2.stat(
|
|
109841
|
+
targetStat = await fs2.stat(resolve27(dirname16(symSource), target));
|
|
109660
109842
|
if (targetStat.isDirectory()) {
|
|
109661
109843
|
targetStat = "junction";
|
|
109662
109844
|
}
|
|
@@ -109887,7 +110069,7 @@ async function pMap(iterable, mapper, {
|
|
|
109887
110069
|
const cleanup = /* @__PURE__ */ __name(() => {
|
|
109888
110070
|
signal?.removeEventListener("abort", signalListener);
|
|
109889
110071
|
}, "cleanup");
|
|
109890
|
-
const
|
|
110072
|
+
const resolve27 = /* @__PURE__ */ __name((value) => {
|
|
109891
110073
|
resolve_(value);
|
|
109892
110074
|
cleanup();
|
|
109893
110075
|
}, "resolve");
|
|
@@ -109919,7 +110101,7 @@ async function pMap(iterable, mapper, {
|
|
|
109919
110101
|
}
|
|
109920
110102
|
isResolved = true;
|
|
109921
110103
|
if (skippedIndexesMap.size === 0) {
|
|
109922
|
-
|
|
110104
|
+
resolve27(result);
|
|
109923
110105
|
return;
|
|
109924
110106
|
}
|
|
109925
110107
|
const pureResult = [];
|
|
@@ -109929,7 +110111,7 @@ async function pMap(iterable, mapper, {
|
|
|
109929
110111
|
}
|
|
109930
110112
|
pureResult.push(value);
|
|
109931
110113
|
}
|
|
109932
|
-
|
|
110114
|
+
resolve27(pureResult);
|
|
109933
110115
|
}
|
|
109934
110116
|
return;
|
|
109935
110117
|
}
|
|
@@ -115275,8 +115457,8 @@ var require_verify = __commonJS({
|
|
|
115275
115457
|
liveContent.add(integrity[algo].toString());
|
|
115276
115458
|
}
|
|
115277
115459
|
});
|
|
115278
|
-
await new Promise((
|
|
115279
|
-
indexStream.on("end",
|
|
115460
|
+
await new Promise((resolve27, reject) => {
|
|
115461
|
+
indexStream.on("end", resolve27).on("error", reject);
|
|
115280
115462
|
});
|
|
115281
115463
|
const contentDir = contentPath.contentDir(cache);
|
|
115282
115464
|
const files = await glob(path3.join(contentDir, "**"), {
|
|
@@ -115666,12 +115848,12 @@ var require_lib9 = __commonJS({
|
|
|
115666
115848
|
return process.emit("input", "end", ...args);
|
|
115667
115849
|
}, "end"),
|
|
115668
115850
|
read: /* @__PURE__ */ __name(function(...args) {
|
|
115669
|
-
let
|
|
115851
|
+
let resolve27, reject;
|
|
115670
115852
|
const promise = new Promise((_resolve, _reject) => {
|
|
115671
|
-
|
|
115853
|
+
resolve27 = _resolve;
|
|
115672
115854
|
reject = _reject;
|
|
115673
115855
|
});
|
|
115674
|
-
process.emit("input", "read",
|
|
115856
|
+
process.emit("input", "read", resolve27, reject, ...args);
|
|
115675
115857
|
return promise;
|
|
115676
115858
|
}, "read")
|
|
115677
115859
|
}
|
|
@@ -116820,8 +117002,8 @@ var require_helpers = __commonJS({
|
|
|
116820
117002
|
function req(url3, opts = {}) {
|
|
116821
117003
|
const href = typeof url3 === "string" ? url3 : url3.href;
|
|
116822
117004
|
const req2 = (href.startsWith("https:") ? https : http2).request(url3, opts);
|
|
116823
|
-
const promise = new Promise((
|
|
116824
|
-
req2.once("response",
|
|
117005
|
+
const promise = new Promise((resolve27, reject) => {
|
|
117006
|
+
req2.once("response", resolve27).once("error", reject).end();
|
|
116825
117007
|
});
|
|
116826
117008
|
req2.then = promise.then.bind(promise);
|
|
116827
117009
|
return req2;
|
|
@@ -117136,7 +117318,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
117136
117318
|
var debug_1 = __importDefault(require_src2());
|
|
117137
117319
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
117138
117320
|
function parseProxyResponse(socket) {
|
|
117139
|
-
return new Promise((
|
|
117321
|
+
return new Promise((resolve27, reject) => {
|
|
117140
117322
|
let buffersLength = 0;
|
|
117141
117323
|
const buffers = [];
|
|
117142
117324
|
function read() {
|
|
@@ -117206,7 +117388,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
117206
117388
|
}
|
|
117207
117389
|
debug("got proxy server response: %o %o", firstLine3, headers);
|
|
117208
117390
|
cleanup();
|
|
117209
|
-
|
|
117391
|
+
resolve27({
|
|
117210
117392
|
connect: {
|
|
117211
117393
|
statusCode,
|
|
117212
117394
|
statusText,
|
|
@@ -121305,12 +121487,12 @@ var require_socksclient = __commonJS({
|
|
|
121305
121487
|
"use strict";
|
|
121306
121488
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
121307
121489
|
function adopt(value) {
|
|
121308
|
-
return value instanceof P2 ? value : new P2(function(
|
|
121309
|
-
|
|
121490
|
+
return value instanceof P2 ? value : new P2(function(resolve27) {
|
|
121491
|
+
resolve27(value);
|
|
121310
121492
|
});
|
|
121311
121493
|
}
|
|
121312
121494
|
__name(adopt, "adopt");
|
|
121313
|
-
return new (P2 || (P2 = Promise))(function(
|
|
121495
|
+
return new (P2 || (P2 = Promise))(function(resolve27, reject) {
|
|
121314
121496
|
function fulfilled(value) {
|
|
121315
121497
|
try {
|
|
121316
121498
|
step2(generator.next(value));
|
|
@@ -121328,7 +121510,7 @@ var require_socksclient = __commonJS({
|
|
|
121328
121510
|
}
|
|
121329
121511
|
__name(rejected, "rejected");
|
|
121330
121512
|
function step2(result) {
|
|
121331
|
-
result.done ?
|
|
121513
|
+
result.done ? resolve27(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
121332
121514
|
}
|
|
121333
121515
|
__name(step2, "step");
|
|
121334
121516
|
step2((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
@@ -121366,13 +121548,13 @@ var require_socksclient = __commonJS({
|
|
|
121366
121548
|
* @returns { Promise }
|
|
121367
121549
|
*/
|
|
121368
121550
|
static createConnection(options2, callback) {
|
|
121369
|
-
return new Promise((
|
|
121551
|
+
return new Promise((resolve27, reject) => {
|
|
121370
121552
|
try {
|
|
121371
121553
|
(0, helpers_1.validateSocksClientOptions)(options2, ["connect"]);
|
|
121372
121554
|
} catch (err) {
|
|
121373
121555
|
if (typeof callback === "function") {
|
|
121374
121556
|
callback(err);
|
|
121375
|
-
return
|
|
121557
|
+
return resolve27(err);
|
|
121376
121558
|
} else {
|
|
121377
121559
|
return reject(err);
|
|
121378
121560
|
}
|
|
@@ -121383,16 +121565,16 @@ var require_socksclient = __commonJS({
|
|
|
121383
121565
|
client.removeAllListeners();
|
|
121384
121566
|
if (typeof callback === "function") {
|
|
121385
121567
|
callback(null, info2);
|
|
121386
|
-
|
|
121568
|
+
resolve27(info2);
|
|
121387
121569
|
} else {
|
|
121388
|
-
|
|
121570
|
+
resolve27(info2);
|
|
121389
121571
|
}
|
|
121390
121572
|
});
|
|
121391
121573
|
client.once("error", (err) => {
|
|
121392
121574
|
client.removeAllListeners();
|
|
121393
121575
|
if (typeof callback === "function") {
|
|
121394
121576
|
callback(err);
|
|
121395
|
-
|
|
121577
|
+
resolve27(err);
|
|
121396
121578
|
} else {
|
|
121397
121579
|
reject(err);
|
|
121398
121580
|
}
|
|
@@ -121409,13 +121591,13 @@ var require_socksclient = __commonJS({
|
|
|
121409
121591
|
* @returns { Promise }
|
|
121410
121592
|
*/
|
|
121411
121593
|
static createConnectionChain(options2, callback) {
|
|
121412
|
-
return new Promise((
|
|
121594
|
+
return new Promise((resolve27, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
121413
121595
|
try {
|
|
121414
121596
|
(0, helpers_1.validateSocksClientChainOptions)(options2);
|
|
121415
121597
|
} catch (err) {
|
|
121416
121598
|
if (typeof callback === "function") {
|
|
121417
121599
|
callback(err);
|
|
121418
|
-
return
|
|
121600
|
+
return resolve27(err);
|
|
121419
121601
|
} else {
|
|
121420
121602
|
return reject(err);
|
|
121421
121603
|
}
|
|
@@ -121441,14 +121623,14 @@ var require_socksclient = __commonJS({
|
|
|
121441
121623
|
}
|
|
121442
121624
|
if (typeof callback === "function") {
|
|
121443
121625
|
callback(null, { socket: sock });
|
|
121444
|
-
|
|
121626
|
+
resolve27({ socket: sock });
|
|
121445
121627
|
} else {
|
|
121446
|
-
|
|
121628
|
+
resolve27({ socket: sock });
|
|
121447
121629
|
}
|
|
121448
121630
|
} catch (err) {
|
|
121449
121631
|
if (typeof callback === "function") {
|
|
121450
121632
|
callback(err);
|
|
121451
|
-
|
|
121633
|
+
resolve27(err);
|
|
121452
121634
|
} else {
|
|
121453
121635
|
reject(err);
|
|
121454
121636
|
}
|
|
@@ -122136,12 +122318,12 @@ var require_dist9 = __commonJS({
|
|
|
122136
122318
|
let { host } = opts;
|
|
122137
122319
|
const { port, lookup: lookupFn = dns.lookup } = opts;
|
|
122138
122320
|
if (shouldLookup) {
|
|
122139
|
-
host = await new Promise((
|
|
122321
|
+
host = await new Promise((resolve27, reject) => {
|
|
122140
122322
|
lookupFn(host, {}, (err, res) => {
|
|
122141
122323
|
if (err) {
|
|
122142
122324
|
reject(err);
|
|
122143
122325
|
} else {
|
|
122144
|
-
|
|
122326
|
+
resolve27(res);
|
|
122145
122327
|
}
|
|
122146
122328
|
});
|
|
122147
122329
|
});
|
|
@@ -122998,8 +123180,8 @@ var require_entry = __commonJS({
|
|
|
122998
123180
|
let body = null;
|
|
122999
123181
|
if (this.response.status === 200) {
|
|
123000
123182
|
let cacheWriteResolve, cacheWriteReject;
|
|
123001
|
-
const cacheWritePromise = new Promise((
|
|
123002
|
-
cacheWriteResolve =
|
|
123183
|
+
const cacheWritePromise = new Promise((resolve27, reject) => {
|
|
123184
|
+
cacheWriteResolve = resolve27;
|
|
123003
123185
|
cacheWriteReject = reject;
|
|
123004
123186
|
}).catch((err) => {
|
|
123005
123187
|
body.emit("error", err);
|
|
@@ -128731,12 +128913,12 @@ var require_fetcher = __commonJS({
|
|
|
128731
128913
|
};
|
|
128732
128914
|
exports.DefaultFetcher = DefaultFetcher;
|
|
128733
128915
|
var writeBufferToStream = /* @__PURE__ */ __name(async (stream, buffer) => {
|
|
128734
|
-
return new Promise((
|
|
128916
|
+
return new Promise((resolve27, reject) => {
|
|
128735
128917
|
stream.write(buffer, (err) => {
|
|
128736
128918
|
if (err) {
|
|
128737
128919
|
reject(err);
|
|
128738
128920
|
}
|
|
128739
|
-
|
|
128921
|
+
resolve27(true);
|
|
128740
128922
|
});
|
|
128741
128923
|
});
|
|
128742
128924
|
}, "writeBufferToStream");
|
|
@@ -129441,7 +129623,7 @@ var require_target = __commonJS({
|
|
|
129441
129623
|
var error_1 = require_error9();
|
|
129442
129624
|
async function readTarget(tuf, targetPath) {
|
|
129443
129625
|
const path3 = await getTargetPath(tuf, targetPath);
|
|
129444
|
-
return new Promise((
|
|
129626
|
+
return new Promise((resolve27, reject) => {
|
|
129445
129627
|
fs_1.default.readFile(path3, "utf-8", (err, data2) => {
|
|
129446
129628
|
if (err) {
|
|
129447
129629
|
reject(new error_1.TUFError({
|
|
@@ -129450,7 +129632,7 @@ var require_target = __commonJS({
|
|
|
129450
129632
|
cause: err
|
|
129451
129633
|
}));
|
|
129452
129634
|
} else {
|
|
129453
|
-
|
|
129635
|
+
resolve27(data2);
|
|
129454
129636
|
}
|
|
129455
129637
|
});
|
|
129456
129638
|
});
|
|
@@ -131886,7 +132068,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
131886
132068
|
`--userconfig=${userConfigPath}`,
|
|
131887
132069
|
`--globalconfig=${globalConfigPath}`
|
|
131888
132070
|
];
|
|
131889
|
-
await new Promise((
|
|
132071
|
+
await new Promise((resolve27, reject) => {
|
|
131890
132072
|
const child = spawn6(npmCommand, pinnedArgs, {
|
|
131891
132073
|
cwd,
|
|
131892
132074
|
env: pinnedNpmEnvironment(ambientEnvironment, userConfigPath, globalConfigPath, registry2, proxy),
|
|
@@ -131896,7 +132078,7 @@ async function runPinnedNpm(args, cwd, ambientEnvironment, userConfigPath, globa
|
|
|
131896
132078
|
child.once("error", reject);
|
|
131897
132079
|
child.once("exit", (code, signal) => {
|
|
131898
132080
|
if (code === 0)
|
|
131899
|
-
|
|
132081
|
+
resolve27();
|
|
131900
132082
|
else
|
|
131901
132083
|
reject(new Error(`npm install failed${signal ? ` with signal ${signal}` : ` with exit code ${code ?? "unknown"}`}`));
|
|
131902
132084
|
});
|
|
@@ -131952,12 +132134,12 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
131952
132134
|
unexpected.push(`CONNECT ${request2.url ?? ""}`);
|
|
131953
132135
|
socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n");
|
|
131954
132136
|
});
|
|
131955
|
-
await new Promise((
|
|
132137
|
+
await new Promise((resolve27, reject) => {
|
|
131956
132138
|
const onError = /* @__PURE__ */ __name((cause) => reject(cause), "onError");
|
|
131957
132139
|
server.once("error", onError);
|
|
131958
132140
|
server.listen(0, "127.0.0.1", () => {
|
|
131959
132141
|
server.off("error", onError);
|
|
131960
|
-
|
|
132142
|
+
resolve27();
|
|
131961
132143
|
});
|
|
131962
132144
|
});
|
|
131963
132145
|
const address = server.address();
|
|
@@ -131971,8 +132153,8 @@ async function serveArtifactSnapshot(artifact) {
|
|
|
131971
132153
|
throw new Error(`npm attempted network access outside the authenticated artifact: ${unexpected[0]}`);
|
|
131972
132154
|
}
|
|
131973
132155
|
}, "assertNoUnexpectedRequests"),
|
|
131974
|
-
close: /* @__PURE__ */ __name(() => new Promise((
|
|
131975
|
-
server.close((cause) => cause ? reject(cause) :
|
|
132156
|
+
close: /* @__PURE__ */ __name(() => new Promise((resolve27, reject) => {
|
|
132157
|
+
server.close((cause) => cause ? reject(cause) : resolve27());
|
|
131976
132158
|
}), "close")
|
|
131977
132159
|
};
|
|
131978
132160
|
}
|
|
@@ -132782,8 +132964,8 @@ var init_usage = __esm({
|
|
|
132782
132964
|
|
|
132783
132965
|
// dist/commands/git.js
|
|
132784
132966
|
import { execFileSync } from "node:child_process";
|
|
132785
|
-
function
|
|
132786
|
-
return new Promise((
|
|
132967
|
+
function sleep3(ms2) {
|
|
132968
|
+
return new Promise((resolve27) => setTimeout(resolve27, ms2));
|
|
132787
132969
|
}
|
|
132788
132970
|
function projectRef2(explicit) {
|
|
132789
132971
|
if (explicit)
|
|
@@ -132839,7 +133021,7 @@ async function waitForChoices(client, repoName, quiet) {
|
|
|
132839
133021
|
} else if (choices.length > 0) {
|
|
132840
133022
|
return choices;
|
|
132841
133023
|
}
|
|
132842
|
-
await
|
|
133024
|
+
await sleep3(2e3);
|
|
132843
133025
|
}
|
|
132844
133026
|
throw new Error(`The wait for GitHub authorization ended. Run \`${cliInvocation()} git connect\` again.`);
|
|
132845
133027
|
}
|
|
@@ -132888,7 +133070,7 @@ async function waitForDeploy(client, projectId, commitSha) {
|
|
|
132888
133070
|
throw new Error(connection.last_error || `Deploy of ${commitSha.slice(0, 7)} failed.`);
|
|
132889
133071
|
}
|
|
132890
133072
|
}
|
|
132891
|
-
await
|
|
133073
|
+
await sleep3(DEPLOY_POLL_MS);
|
|
132892
133074
|
}
|
|
132893
133075
|
throw new Error(`The wait ended before deploy of ${commitSha.slice(0, 7)} finished. Check the project logs.`);
|
|
132894
133076
|
}
|
|
@@ -133024,7 +133206,7 @@ var init_git = __esm({
|
|
|
133024
133206
|
DASHBOARD = "https://somewhere.cloud/app";
|
|
133025
133207
|
INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
133026
133208
|
DEPLOY_POLL_MS = 1500;
|
|
133027
|
-
__name(
|
|
133209
|
+
__name(sleep3, "sleep");
|
|
133028
133210
|
__name(projectRef2, "projectRef");
|
|
133029
133211
|
__name(inferGitHubRepo, "inferGitHubRepo");
|
|
133030
133212
|
__name(listInstallations, "listInstallations");
|
|
@@ -133046,7 +133228,7 @@ function rowCountChanges(before, after) {
|
|
|
133046
133228
|
return void 0;
|
|
133047
133229
|
return Object.keys(after).sort().filter((table2) => before[table2] !== after[table2]).map((table2) => ({ table: table2, before: before[table2], after: after[table2] }));
|
|
133048
133230
|
}
|
|
133049
|
-
async function runPreviewScheduleTest(client, cronId, target, twice, report2,
|
|
133231
|
+
async function runPreviewScheduleTest(client, cronId, target, twice, report2, sleep5 = (ms2) => new Promise((resolve27) => setTimeout(resolve27, ms2))) {
|
|
133050
133232
|
const path3 = `/cron/${encodeURIComponent(cronId)}/run-preview`;
|
|
133051
133233
|
const validTarget = /* @__PURE__ */ __name((value) => value.preview_session_id === target.preview_session_id && value.preview_id === target.preview_id, "validTarget");
|
|
133052
133234
|
const first = await client.call("GET", path3, void 0, { ...target, counts: twice ? 1 : void 0 });
|
|
@@ -133099,7 +133281,7 @@ async function runPreviewScheduleTest(client, cronId, target, twice, report2, sl
|
|
|
133099
133281
|
break;
|
|
133100
133282
|
}
|
|
133101
133283
|
if (Date.now() < deadline)
|
|
133102
|
-
await
|
|
133284
|
+
await sleep5(Math.min(1e3, deadline - Date.now()));
|
|
133103
133285
|
}
|
|
133104
133286
|
const job = last?.job;
|
|
133105
133287
|
if (!job?.terminal || job.status === "indeterminate") {
|
|
@@ -133156,6 +133338,7 @@ var init_test_preview_job = __esm({
|
|
|
133156
133338
|
});
|
|
133157
133339
|
|
|
133158
133340
|
// dist/commands/cron.js
|
|
133341
|
+
import { setTimeout as sleep4 } from "node:timers/promises";
|
|
133159
133342
|
function parsePayload(value) {
|
|
133160
133343
|
if (value === void 0)
|
|
133161
133344
|
return void 0;
|
|
@@ -133236,16 +133419,38 @@ function parseWaitTimeout(value) {
|
|
|
133236
133419
|
function isTerminalJobStatus(status) {
|
|
133237
133420
|
return status === JOB_SUCCESS_STATUS || JOB_FAILURE_STATUSES.has(status);
|
|
133238
133421
|
}
|
|
133239
|
-
async function waitForJob(
|
|
133422
|
+
async function waitForJob(admitted, timeoutSeconds, firstDelayMs) {
|
|
133423
|
+
const client = new ApiClient(getToken());
|
|
133424
|
+
const path3 = "/jobs/" + encodeURIComponent(admitted.job_id);
|
|
133240
133425
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
133241
|
-
|
|
133242
|
-
|
|
133243
|
-
|
|
133244
|
-
return { job, timedOut: false };
|
|
133426
|
+
let job = admitted;
|
|
133427
|
+
let delay2 = firstDelayMs;
|
|
133428
|
+
for (let attempt = 0; ; attempt++) {
|
|
133245
133429
|
const remaining = deadline - Date.now();
|
|
133246
|
-
if (
|
|
133430
|
+
if (delay2 >= remaining) {
|
|
133431
|
+
if (remaining > 0)
|
|
133432
|
+
await sleep4(remaining);
|
|
133247
133433
|
return { job, timedOut: true };
|
|
133248
|
-
|
|
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);
|
|
133249
133454
|
}
|
|
133250
133455
|
}
|
|
133251
133456
|
function observedCronConfig(cron) {
|
|
@@ -133498,7 +133703,13 @@ function printCronMutation(verb, value) {
|
|
|
133498
133703
|
async function runCronInPreview(cronId, opts, timeoutSeconds) {
|
|
133499
133704
|
const tool = await folderPreviewTool({});
|
|
133500
133705
|
const version2 = await previewCurrentVersion(tool.credential);
|
|
133501
|
-
|
|
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
|
+
});
|
|
133502
133713
|
const result = cronRunResult(value);
|
|
133503
133714
|
if (!opts.wait) {
|
|
133504
133715
|
if (opts.json) {
|
|
@@ -133511,7 +133722,7 @@ async function runCronInPreview(cronId, opts, timeoutSeconds) {
|
|
|
133511
133722
|
}
|
|
133512
133723
|
if (!opts.json)
|
|
133513
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`));
|
|
133514
|
-
const { job, timedOut } = await waitForPreviewJob(tool.credential, result.job_id, timeoutSeconds);
|
|
133725
|
+
const { job, timedOut } = await waitForPreviewJob(tool.credential, result.job_id, timeoutSeconds, firstDelayMs);
|
|
133515
133726
|
const succeeded = !timedOut && job.status === JOB_SUCCESS_STATUS;
|
|
133516
133727
|
if (!succeeded)
|
|
133517
133728
|
process.exitCode = 1;
|
|
@@ -133595,7 +133806,13 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
|
|
|
133595
133806
|
await runCronInPreview(cronId, opts, timeoutSeconds);
|
|
133596
133807
|
return;
|
|
133597
133808
|
}
|
|
133598
|
-
|
|
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
|
+
});
|
|
133599
133816
|
queued = true;
|
|
133600
133817
|
if (!opts.wait) {
|
|
133601
133818
|
if (opts.json) {
|
|
@@ -133611,7 +133828,7 @@ zone each trigger is stored in, and \`cron update --schedule\` keeps that zone u
|
|
|
133611
133828
|
const result = cronRunResult(value);
|
|
133612
133829
|
if (!opts.json)
|
|
133613
133830
|
console.log(dim(`Job ${result.job_id} queued for cron ${result.cron_id}; waiting up to ${timeoutSeconds}s\u2026`));
|
|
133614
|
-
const { job, timedOut } = await waitForJob(result
|
|
133831
|
+
const { job, timedOut } = await waitForJob(result, timeoutSeconds, firstDelayMs);
|
|
133615
133832
|
const succeeded = !timedOut && job.status === JOB_SUCCESS_STATUS;
|
|
133616
133833
|
if (!succeeded)
|
|
133617
133834
|
process.exitCode = 1;
|
|
@@ -133749,9 +133966,11 @@ var init_cron = __esm({
|
|
|
133749
133966
|
"use strict";
|
|
133750
133967
|
init_test_preview_job();
|
|
133751
133968
|
init_cli_invocation();
|
|
133969
|
+
init_client();
|
|
133752
133970
|
init_config();
|
|
133753
133971
|
init_next_actions();
|
|
133754
133972
|
init_platform_tools();
|
|
133973
|
+
init_poll_delay();
|
|
133755
133974
|
init_preview_jobs();
|
|
133756
133975
|
init_platform_command();
|
|
133757
133976
|
init_output();
|
|
@@ -134226,7 +134445,7 @@ async function signUpSteps(run, page, options2) {
|
|
|
134226
134445
|
if (!attempt.submitted)
|
|
134227
134446
|
return;
|
|
134228
134447
|
await registerMailedCodes(run, email2, true);
|
|
134229
|
-
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))]);
|
|
134230
134449
|
if (late instanceof Error)
|
|
134231
134450
|
return;
|
|
134232
134451
|
const known = await outcome(Promise.resolve(late), "sign-up").catch(() => null);
|
|
@@ -134292,7 +134511,7 @@ async function verifySteps(run, page, person) {
|
|
|
134292
134511
|
let confirmed = await step(page, "verify: enter the code in the app", () => post2("/api/auth/verify-email", { code }));
|
|
134293
134512
|
for (let wait = 0; confirmed.status() === 404 && wait < 8; wait++) {
|
|
134294
134513
|
mark("wait", { ms: 250, why: "verify: code not installed yet (404)" });
|
|
134295
|
-
await new Promise((
|
|
134514
|
+
await new Promise((resolve27) => setTimeout(resolve27, 250));
|
|
134296
134515
|
confirmed = await step(page, "verify: enter the code in the app", () => post2("/api/auth/verify-email", { code }));
|
|
134297
134516
|
}
|
|
134298
134517
|
if (confirmed.ok()) {
|
|
@@ -134438,8 +134657,57 @@ var init_form_auth = __esm({
|
|
|
134438
134657
|
}
|
|
134439
134658
|
});
|
|
134440
134659
|
|
|
134441
|
-
// dist/lib/
|
|
134660
|
+
// dist/lib/test-response-capture.js
|
|
134442
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";
|
|
134443
134711
|
import { setDefaultResultOrder } from "node:dns";
|
|
134444
134712
|
import { lookup } from "node:dns/promises";
|
|
134445
134713
|
import { existsSync as existsSync37, mkdirSync as mkdirSync19, readFileSync as readFileSync41, writeFileSync as writeFileSync25 } from "node:fs";
|
|
@@ -134541,30 +134809,6 @@ function classifyData(status, raw, operation) {
|
|
|
134541
134809
|
function openAppTest(options2) {
|
|
134542
134810
|
return AppTest.open(options2);
|
|
134543
134811
|
}
|
|
134544
|
-
function captureResponses(page) {
|
|
134545
|
-
const pending = [];
|
|
134546
|
-
const listener = /* @__PURE__ */ __name((response) => {
|
|
134547
|
-
const url3 = new URL(response.url());
|
|
134548
|
-
pending.push(response.text().then((body) => ({ url: url3.origin + url3.pathname, status: response.status(), contentType: response.headers()["content-type"] ?? "", body })).catch(() => null));
|
|
134549
|
-
}, "listener");
|
|
134550
|
-
page.on("response", listener);
|
|
134551
|
-
return {
|
|
134552
|
-
/** Every captured response, after each body has been read. */
|
|
134553
|
-
async all() {
|
|
134554
|
-
return (await Promise.all(pending)).filter((c) => c !== null);
|
|
134555
|
-
},
|
|
134556
|
-
/** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
|
|
134557
|
-
async find(secret) {
|
|
134558
|
-
return (await this.all()).filter((c) => c.body.includes(secret)).map((c) => {
|
|
134559
|
-
const at2 = c.body.indexOf(secret);
|
|
134560
|
-
return { url: c.url, status: c.status, contentType: c.contentType, around: c.body.slice(Math.max(0, at2 - 60), at2 + secret.length + 60) };
|
|
134561
|
-
});
|
|
134562
|
-
},
|
|
134563
|
-
stop() {
|
|
134564
|
-
page.off("response", listener);
|
|
134565
|
-
}
|
|
134566
|
-
};
|
|
134567
|
-
}
|
|
134568
134812
|
async function dataReady(scope, timeout = 5e3) {
|
|
134569
134813
|
const root = typeof scope.goto === "function" ? scope.locator(":root") : scope;
|
|
134570
134814
|
const views = root.locator("[data-sw-data]");
|
|
@@ -134598,6 +134842,7 @@ var init_app_test = __esm({
|
|
|
134598
134842
|
init_form_auth();
|
|
134599
134843
|
init_test_diagnostics();
|
|
134600
134844
|
init_test_timeline();
|
|
134845
|
+
init_test_response_capture();
|
|
134601
134846
|
__name(launchOptions, "launchOptions");
|
|
134602
134847
|
__name(describeCheckFailure, "describeCheckFailure");
|
|
134603
134848
|
__name(pageState, "pageState");
|
|
@@ -134684,7 +134929,7 @@ var init_app_test = __esm({
|
|
|
134684
134929
|
const [ipv4First] = await Promise.all([testAddressOrder(target.origin), lookup(new URL(target.origin).hostname).catch(() => null)]);
|
|
134685
134930
|
if (ipv4First)
|
|
134686
134931
|
setDefaultResultOrder("ipv4first");
|
|
134687
|
-
process.env.SW_TEST_RUN ??=
|
|
134932
|
+
process.env.SW_TEST_RUN ??= randomUUID11();
|
|
134688
134933
|
process.env.SW_TEST_ORIGIN = target.origin;
|
|
134689
134934
|
for (const line of describeSweep(await sweepAccounts(control, root), "Before this script"))
|
|
134690
134935
|
process.stderr.write(line + "\n");
|
|
@@ -134906,11 +135151,229 @@ page ${i + 1}: ${state}`).join("");
|
|
|
134906
135151
|
}
|
|
134907
135152
|
};
|
|
134908
135153
|
__name(openAppTest, "openAppTest");
|
|
134909
|
-
__name(captureResponses, "captureResponses");
|
|
134910
135154
|
__name(dataReady, "dataReady");
|
|
134911
135155
|
}
|
|
134912
135156
|
});
|
|
134913
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
|
+
|
|
134914
135377
|
// dist/commands/data.js
|
|
134915
135378
|
function parseJson(text, flag) {
|
|
134916
135379
|
try {
|
|
@@ -134943,7 +135406,7 @@ function registerData(program2) {
|
|
|
134943
135406
|
if (origin.protocol !== "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(origin.hostname)) {
|
|
134944
135407
|
throw new Error("The linked app needs an HTTPS address.");
|
|
134945
135408
|
}
|
|
134946
|
-
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;
|
|
134947
135410
|
if (!session || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(session)) {
|
|
134948
135411
|
throw new Error("Supply a valid app session token.");
|
|
134949
135412
|
}
|
|
@@ -134966,7 +135429,7 @@ var init_data = __esm({
|
|
|
134966
135429
|
init_app_test();
|
|
134967
135430
|
init_client();
|
|
134968
135431
|
init_config();
|
|
134969
|
-
|
|
135432
|
+
init_prepared_actor_session();
|
|
134970
135433
|
init_test_target();
|
|
134971
135434
|
__name(parseJson, "parseJson");
|
|
134972
135435
|
__name(registerData, "registerData");
|
|
@@ -135004,7 +135467,7 @@ var init_reference_check_note = __esm({
|
|
|
135004
135467
|
|
|
135005
135468
|
// dist/lib/test-scripts.js
|
|
135006
135469
|
import { createRequire as createRequire9 } from "node:module";
|
|
135007
|
-
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";
|
|
135008
135471
|
import { dirname as dirname15, join as join45, relative as relative13, resolve as resolve25 } from "node:path";
|
|
135009
135472
|
import { spawn as spawn7, spawnSync as spawnSync5 } from "node:child_process";
|
|
135010
135473
|
function hasSpecFiles(root) {
|
|
@@ -135076,7 +135539,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135076
135539
|
let output = "";
|
|
135077
135540
|
const handOver = join45(root, ".somewhere", "tests", `report-${results.length}.json`);
|
|
135078
135541
|
mkdirSync20(dirname15(handOver), { recursive: true });
|
|
135079
|
-
|
|
135542
|
+
rmSync16(handOver, { force: true });
|
|
135080
135543
|
const askedForBrowserLog = /(^|,)\s*(pw:browser|pw:\*|\*)\s*(,|$)/.test(env.DEBUG ?? "");
|
|
135081
135544
|
const childEnv = { ...env, SW_TEST_REPORT: handOver, DEBUG: askedForBrowserLog ? env.DEBUG : [env.DEBUG, "pw:browser"].filter(Boolean).join(",") };
|
|
135082
135545
|
const child = spawn7(process.execPath, [script, ...extraArgs], { cwd: root, env: childEnv, stdio: ["inherit", "pipe", "pipe"] });
|
|
@@ -135108,7 +135571,7 @@ async function runScripts(root, scripts, extraArgs, env = scriptBrowserEnv(root)
|
|
|
135108
135571
|
} catch {
|
|
135109
135572
|
report2 = null;
|
|
135110
135573
|
}
|
|
135111
|
-
|
|
135574
|
+
rmSync16(handOver, { force: true });
|
|
135112
135575
|
results.push({
|
|
135113
135576
|
script,
|
|
135114
135577
|
ok: exitCode === 0,
|
|
@@ -135176,7 +135639,7 @@ var init_test_scripts = __esm({
|
|
|
135176
135639
|
|
|
135177
135640
|
// dist/commands/test.js
|
|
135178
135641
|
function registerTest(program2) {
|
|
135179
|
-
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) => {
|
|
135180
135643
|
markProcessStart("cli");
|
|
135181
135644
|
mark("cli:action");
|
|
135182
135645
|
if (opts.url)
|
|
@@ -135187,15 +135650,22 @@ function registerTest(program2) {
|
|
|
135187
135650
|
const projectId = loadProjectConfig()?.project_id;
|
|
135188
135651
|
if (!projectId)
|
|
135189
135652
|
throw new Error("Run somewhere test from a linked project folder");
|
|
135190
|
-
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)) {
|
|
135191
135660
|
const unsupported = [opts.phone && "--phone", opts.grep && "--grep", opts.workers !== "5" && "--workers", opts.failFast && "--fail-fast"].filter(Boolean);
|
|
135192
135661
|
if (unsupported.length)
|
|
135193
135662
|
throw new Error(`${unsupported.join(", ")} apply to Playwright specs and scripts; the platform runs checks/*.json as saved.`);
|
|
135194
135663
|
let check;
|
|
135195
135664
|
try {
|
|
135196
|
-
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 });
|
|
135197
135666
|
} catch (cause) {
|
|
135198
|
-
|
|
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 };
|
|
135199
135669
|
}
|
|
135200
135670
|
mark("cli:exit");
|
|
135201
135671
|
const summary = deployChecksSummary(check);
|
|
@@ -135256,7 +135726,7 @@ var init_test = __esm({
|
|
|
135256
135726
|
});
|
|
135257
135727
|
|
|
135258
135728
|
// dist/commands/test-users.js
|
|
135259
|
-
import { existsSync as existsSync39, readFileSync as readFileSync43, rmSync as
|
|
135729
|
+
import { existsSync as existsSync39, readFileSync as readFileSync43, rmSync as rmSync17 } from "node:fs";
|
|
135260
135730
|
import { basename as basename10, join as join46 } from "node:path";
|
|
135261
135731
|
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
135262
135732
|
async function resolveTarget(projectOpt, originOpt) {
|
|
@@ -135301,9 +135771,9 @@ function registerTestUsers(program2) {
|
|
|
135301
135771
|
'With data imported from @somewhere-cloud/cli/testing: await data(alice.request, "notes", { operation: "list" })',
|
|
135302
135772
|
'Save the context back after each run: await context.storageState({ path: ".somewhere/test/alice.state.json" })',
|
|
135303
135773
|
"The app refreshes the short-lived access token and rotates the session on its first refresh, so an unsaved",
|
|
135304
|
-
"file stops working after a run that refreshed it.
|
|
135305
|
-
|
|
135306
|
-
"
|
|
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",
|
|
135307
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."
|
|
135308
135778
|
].join("\n")).action(async (actorValues, opts) => {
|
|
135309
135779
|
let specs;
|
|
@@ -135391,7 +135861,7 @@ function registerTestUsers(program2) {
|
|
|
135391
135861
|
}
|
|
135392
135862
|
for (const actor of manifest.actors) {
|
|
135393
135863
|
info(`${actor.name} (${actor.role}) ${actor.email} user ${actor.user_id}`);
|
|
135394
|
-
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}`);
|
|
135395
135865
|
}
|
|
135396
135866
|
if (gitignore !== "present")
|
|
135397
135867
|
info(`${gitignore === "created" ? "Created" : "Updated"} .gitignore to ignore ${TEST_STATE_DIR}/.`);
|
|
@@ -135525,7 +135995,7 @@ function registerTestUsers(program2) {
|
|
|
135525
135995
|
if (left.length)
|
|
135526
135996
|
writeManifest(target.root, { ...manifest, actors: left, status: "partial" });
|
|
135527
135997
|
else
|
|
135528
|
-
|
|
135998
|
+
rmSync17(join46(stateDir(target.root), MANIFEST_FILE), { force: true });
|
|
135529
135999
|
if (opts.json) {
|
|
135530
136000
|
printJson(receipt);
|
|
135531
136001
|
if (left.length)
|
|
@@ -136952,6 +137422,38 @@ async function refusedAs(person, target, request2, options2) {
|
|
|
136952
137422
|
throw new Error(`expectRefused: ${said}, but ${target} ${String(id)} ${after === null ? "is gone" : "changed"} for the allowed person afterwards.`);
|
|
136953
137423
|
}
|
|
136954
137424
|
}
|
|
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
|
+
}
|
|
136955
137457
|
async function data(client, table2, request2) {
|
|
136956
137458
|
if (digests.has(client)) {
|
|
136957
137459
|
return client.post("/__sw/data", { data: { ...request2, table: table2, contract: digests.get(client) ?? "" } });
|
|
@@ -136970,13 +137472,14 @@ async function data(client, table2, request2) {
|
|
|
136970
137472
|
contextTargets.set(client, target);
|
|
136971
137473
|
}
|
|
136972
137474
|
const { origin, contractDigest } = await target.load;
|
|
137475
|
+
await refreshTestContext(client, origin);
|
|
136973
137476
|
return client.post(new URL("/__sw/data", origin).href, {
|
|
136974
137477
|
headers: { Origin: origin },
|
|
136975
137478
|
maxRedirects: 0,
|
|
136976
137479
|
data: { ...request2, table: table2, contract: contractDigest ?? "" }
|
|
136977
137480
|
});
|
|
136978
137481
|
}
|
|
136979
|
-
var loaded, digests, eager, test, expect, ENDPOINT, INCONCLUSIVE, contextTargets, constrained, FormRun;
|
|
137482
|
+
var loaded, digests, eager, test, expect, ENDPOINT, INCONCLUSIVE, contextRefreshes, contextTargets, constrained, FormRun;
|
|
136980
137483
|
var init_playwright_fixtures = __esm({
|
|
136981
137484
|
"dist/lib/playwright-fixtures.js"() {
|
|
136982
137485
|
"use strict";
|
|
@@ -137029,6 +137532,8 @@ var init_playwright_fixtures = __esm({
|
|
|
137029
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.";
|
|
137030
137533
|
__name(seen, "seen");
|
|
137031
137534
|
__name(refusedAs, "refusedAs");
|
|
137535
|
+
contextRefreshes = /* @__PURE__ */ new WeakMap();
|
|
137536
|
+
__name(refreshTestContext, "refreshTestContext");
|
|
137032
137537
|
contextTargets = /* @__PURE__ */ new WeakMap();
|
|
137033
137538
|
__name(data, "data");
|
|
137034
137539
|
constrained = /* @__PURE__ */ new WeakSet();
|
|
@@ -137131,109 +137636,331 @@ var init_playwright_fixtures = __esm({
|
|
|
137131
137636
|
}
|
|
137132
137637
|
});
|
|
137133
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
|
+
|
|
137134
137933
|
// dist/testing.js
|
|
137135
137934
|
var testing_exports = {};
|
|
137136
137935
|
__export(testing_exports, {
|
|
137137
137936
|
UserSession: () => UserSession,
|
|
137937
|
+
assertNoLeak: () => assertNoLeak,
|
|
137938
|
+
captureResponses: () => captureResponses,
|
|
137138
137939
|
createUser: () => createUser,
|
|
137139
137940
|
data: () => data,
|
|
137140
137941
|
expect: () => expect,
|
|
137141
137942
|
expectRefusal: () => expectRefusal,
|
|
137142
137943
|
expectRefused: () => expectRefused,
|
|
137143
137944
|
expectStatus: () => expectStatus,
|
|
137945
|
+
openTestApp: () => openTestApp,
|
|
137144
137946
|
ready: () => ready,
|
|
137145
137947
|
signIn: () => signIn2,
|
|
137146
137948
|
test: () => test,
|
|
137147
137949
|
waitForApp: () => waitForApp
|
|
137148
137950
|
});
|
|
137149
|
-
async function expectStatus(response, expected) {
|
|
137150
|
-
if (response.status !== expected)
|
|
137151
|
-
throw new Error("Expected HTTP " + expected + ", received " + response.status);
|
|
137152
|
-
}
|
|
137153
|
-
async function expectRefusal(response, status, code) {
|
|
137154
|
-
await expectStatus(response, status);
|
|
137155
|
-
const body = await response.json();
|
|
137156
|
-
if (!body || typeof body !== "object" || !("error" in body) || body.error !== code) {
|
|
137157
|
-
throw new Error("Refusal did not have the exact expected error code: " + code);
|
|
137158
|
-
}
|
|
137159
|
-
}
|
|
137160
|
-
async function signIn2(baseUrl, email2, password) {
|
|
137161
|
-
const session = new UserSession(baseUrl);
|
|
137162
|
-
const response = await session.post("/api/auth/login", { email: email2, password });
|
|
137163
|
-
await expectStatus(response, 200);
|
|
137164
|
-
const body = await response.json();
|
|
137165
|
-
if (!body.cookie_session)
|
|
137166
|
-
throw new Error("Sign-in did not establish a cookie session");
|
|
137167
|
-
return session;
|
|
137168
|
-
}
|
|
137169
|
-
async function createUser(baseUrl) {
|
|
137170
|
-
const session = new UserSession(baseUrl);
|
|
137171
|
-
const email2 = "starter-" + crypto.randomUUID() + "@fixture.test.somewhere.site";
|
|
137172
|
-
const password = "Fixture!9-" + crypto.randomUUID();
|
|
137173
|
-
const response = await session.post("/api/auth/signup", { email: email2, password });
|
|
137174
|
-
await expectStatus(response, 200);
|
|
137175
|
-
const body = await response.json();
|
|
137176
|
-
if (!body.cookie_session)
|
|
137177
|
-
throw new Error("Signup did not establish a cookie session");
|
|
137178
|
-
return session;
|
|
137179
|
-
}
|
|
137180
137951
|
function waitForApp(page, state = "ready") {
|
|
137181
|
-
const
|
|
137182
|
-
|
|
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" });
|
|
137183
137956
|
}
|
|
137184
|
-
var UserSession;
|
|
137185
137957
|
var init_testing = __esm({
|
|
137186
137958
|
"dist/testing.js"() {
|
|
137187
137959
|
"use strict";
|
|
137188
|
-
|
|
137189
|
-
init_config();
|
|
137190
|
-
init_test_target();
|
|
137960
|
+
init_test_session();
|
|
137191
137961
|
init_playwright_fixtures();
|
|
137192
|
-
|
|
137193
|
-
|
|
137194
|
-
__name(this, "UserSession");
|
|
137195
|
-
}
|
|
137196
|
-
origin;
|
|
137197
|
-
cookies = /* @__PURE__ */ new Map();
|
|
137198
|
-
target;
|
|
137199
|
-
constructor(baseUrl) {
|
|
137200
|
-
this.origin = new URL(baseUrl).origin;
|
|
137201
|
-
}
|
|
137202
|
-
async request(path3, init = {}) {
|
|
137203
|
-
const url3 = new URL(path3, this.origin);
|
|
137204
|
-
if (url3.origin !== this.origin)
|
|
137205
|
-
throw new Error("Fixture requests must stay on the app origin");
|
|
137206
|
-
const headers = new Headers(init.headers);
|
|
137207
|
-
headers.set("Origin", this.origin);
|
|
137208
|
-
headers.set("Cookie", [...this.cookies].map(([k2, v2]) => k2 + "=" + v2).join("; "));
|
|
137209
|
-
const response = await fetch(url3, { ...init, headers, redirect: "error" });
|
|
137210
|
-
for (const cookie of response.headers.getSetCookie()) {
|
|
137211
|
-
const pair = cookie.split(";")[0];
|
|
137212
|
-
const split = pair.indexOf("=");
|
|
137213
|
-
this.cookies.set(pair.slice(0, split), pair.slice(split + 1));
|
|
137214
|
-
}
|
|
137215
|
-
return response;
|
|
137216
|
-
}
|
|
137217
|
-
post(path3, body) {
|
|
137218
|
-
return this.request(path3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
|
|
137219
|
-
}
|
|
137220
|
-
async data(table2, requestOrContract, request2) {
|
|
137221
|
-
if (typeof requestOrContract === "string") {
|
|
137222
|
-
return this.post("/__sw/data", { ...request2, table: table2, contract: requestOrContract });
|
|
137223
|
-
}
|
|
137224
|
-
const projectId = loadProjectConfig()?.project_id;
|
|
137225
|
-
if (!projectId)
|
|
137226
|
-
throw new Error("Use the data helper from a linked project folder.");
|
|
137227
|
-
const target = await (this.target ??= fixtureTestTarget(new ApiClient(process.env.SW_TEST_TARGET ? null : getToken()), projectId));
|
|
137228
|
-
if (target.origin !== this.origin)
|
|
137229
|
-
throw new Error("This session belongs to a different app than the linked test target.");
|
|
137230
|
-
return this.post("/__sw/data", { ...requestOrContract, table: table2, contract: target.contractDigest ?? "" });
|
|
137231
|
-
}
|
|
137232
|
-
};
|
|
137233
|
-
__name(expectStatus, "expectStatus");
|
|
137234
|
-
__name(expectRefusal, "expectRefusal");
|
|
137235
|
-
__name(signIn2, "signIn");
|
|
137236
|
-
__name(createUser, "createUser");
|
|
137962
|
+
init_testing_app();
|
|
137963
|
+
init_test_response_capture();
|
|
137237
137964
|
__name(waitForApp, "waitForApp");
|
|
137238
137965
|
}
|
|
137239
137966
|
});
|