canopycms-cdk 0.5.0 → 0.7.0

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.
@@ -67,54 +67,54 @@ var require_polyfills = __commonJS({
67
67
  }
68
68
  var chdir;
69
69
  module.exports = patch;
70
- function patch(fs31) {
70
+ function patch(fs32) {
71
71
  if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
72
- patchLchmod(fs31);
73
- }
74
- if (!fs31.lutimes) {
75
- patchLutimes(fs31);
76
- }
77
- fs31.chown = chownFix(fs31.chown);
78
- fs31.fchown = chownFix(fs31.fchown);
79
- fs31.lchown = chownFix(fs31.lchown);
80
- fs31.chmod = chmodFix(fs31.chmod);
81
- fs31.fchmod = chmodFix(fs31.fchmod);
82
- fs31.lchmod = chmodFix(fs31.lchmod);
83
- fs31.chownSync = chownFixSync(fs31.chownSync);
84
- fs31.fchownSync = chownFixSync(fs31.fchownSync);
85
- fs31.lchownSync = chownFixSync(fs31.lchownSync);
86
- fs31.chmodSync = chmodFixSync(fs31.chmodSync);
87
- fs31.fchmodSync = chmodFixSync(fs31.fchmodSync);
88
- fs31.lchmodSync = chmodFixSync(fs31.lchmodSync);
89
- fs31.stat = statFix(fs31.stat);
90
- fs31.fstat = statFix(fs31.fstat);
91
- fs31.lstat = statFix(fs31.lstat);
92
- fs31.statSync = statFixSync(fs31.statSync);
93
- fs31.fstatSync = statFixSync(fs31.fstatSync);
94
- fs31.lstatSync = statFixSync(fs31.lstatSync);
95
- if (fs31.chmod && !fs31.lchmod) {
96
- fs31.lchmod = function(path34, mode, cb) {
72
+ patchLchmod(fs32);
73
+ }
74
+ if (!fs32.lutimes) {
75
+ patchLutimes(fs32);
76
+ }
77
+ fs32.chown = chownFix(fs32.chown);
78
+ fs32.fchown = chownFix(fs32.fchown);
79
+ fs32.lchown = chownFix(fs32.lchown);
80
+ fs32.chmod = chmodFix(fs32.chmod);
81
+ fs32.fchmod = chmodFix(fs32.fchmod);
82
+ fs32.lchmod = chmodFix(fs32.lchmod);
83
+ fs32.chownSync = chownFixSync(fs32.chownSync);
84
+ fs32.fchownSync = chownFixSync(fs32.fchownSync);
85
+ fs32.lchownSync = chownFixSync(fs32.lchownSync);
86
+ fs32.chmodSync = chmodFixSync(fs32.chmodSync);
87
+ fs32.fchmodSync = chmodFixSync(fs32.fchmodSync);
88
+ fs32.lchmodSync = chmodFixSync(fs32.lchmodSync);
89
+ fs32.stat = statFix(fs32.stat);
90
+ fs32.fstat = statFix(fs32.fstat);
91
+ fs32.lstat = statFix(fs32.lstat);
92
+ fs32.statSync = statFixSync(fs32.statSync);
93
+ fs32.fstatSync = statFixSync(fs32.fstatSync);
94
+ fs32.lstatSync = statFixSync(fs32.lstatSync);
95
+ if (fs32.chmod && !fs32.lchmod) {
96
+ fs32.lchmod = function(path35, mode, cb) {
97
97
  if (cb) process.nextTick(cb);
98
98
  };
99
- fs31.lchmodSync = function() {
99
+ fs32.lchmodSync = function() {
100
100
  };
101
101
  }
102
- if (fs31.chown && !fs31.lchown) {
103
- fs31.lchown = function(path34, uid, gid, cb) {
102
+ if (fs32.chown && !fs32.lchown) {
103
+ fs32.lchown = function(path35, uid, gid, cb) {
104
104
  if (cb) process.nextTick(cb);
105
105
  };
106
- fs31.lchownSync = function() {
106
+ fs32.lchownSync = function() {
107
107
  };
108
108
  }
109
109
  if (platform2 === "win32") {
110
- fs31.rename = typeof fs31.rename !== "function" ? fs31.rename : (function(fs$rename) {
110
+ fs32.rename = typeof fs32.rename !== "function" ? fs32.rename : (function(fs$rename) {
111
111
  function rename(from, to, cb) {
112
112
  var start = Date.now();
113
113
  var backoff = 0;
114
114
  fs$rename(from, to, function CB(er) {
115
115
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
116
116
  setTimeout(function() {
117
- fs31.stat(to, function(stater, st) {
117
+ fs32.stat(to, function(stater, st) {
118
118
  if (stater && stater.code === "ENOENT")
119
119
  fs$rename(from, to, CB);
120
120
  else
@@ -130,9 +130,9 @@ var require_polyfills = __commonJS({
130
130
  }
131
131
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
132
132
  return rename;
133
- })(fs31.rename);
133
+ })(fs32.rename);
134
134
  }
135
- fs31.read = typeof fs31.read !== "function" ? fs31.read : (function(fs$read) {
135
+ fs32.read = typeof fs32.read !== "function" ? fs32.read : (function(fs$read) {
136
136
  function read(fd, buffer, offset, length, position, callback_) {
137
137
  var callback;
138
138
  if (callback_ && typeof callback_ === "function") {
@@ -140,22 +140,22 @@ var require_polyfills = __commonJS({
140
140
  callback = function(er, _3, __) {
141
141
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
142
142
  eagCounter++;
143
- return fs$read.call(fs31, fd, buffer, offset, length, position, callback);
143
+ return fs$read.call(fs32, fd, buffer, offset, length, position, callback);
144
144
  }
145
145
  callback_.apply(this, arguments);
146
146
  };
147
147
  }
148
- return fs$read.call(fs31, fd, buffer, offset, length, position, callback);
148
+ return fs$read.call(fs32, fd, buffer, offset, length, position, callback);
149
149
  }
150
150
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
151
151
  return read;
152
- })(fs31.read);
153
- fs31.readSync = typeof fs31.readSync !== "function" ? fs31.readSync : /* @__PURE__ */ (function(fs$readSync) {
152
+ })(fs32.read);
153
+ fs32.readSync = typeof fs32.readSync !== "function" ? fs32.readSync : /* @__PURE__ */ (function(fs$readSync) {
154
154
  return function(fd, buffer, offset, length, position) {
155
155
  var eagCounter = 0;
156
156
  while (true) {
157
157
  try {
158
- return fs$readSync.call(fs31, fd, buffer, offset, length, position);
158
+ return fs$readSync.call(fs32, fd, buffer, offset, length, position);
159
159
  } catch (er) {
160
160
  if (er.code === "EAGAIN" && eagCounter < 10) {
161
161
  eagCounter++;
@@ -165,11 +165,11 @@ var require_polyfills = __commonJS({
165
165
  }
166
166
  }
167
167
  };
168
- })(fs31.readSync);
169
- function patchLchmod(fs32) {
170
- fs32.lchmod = function(path34, mode, callback) {
171
- fs32.open(
172
- path34,
168
+ })(fs32.readSync);
169
+ function patchLchmod(fs33) {
170
+ fs33.lchmod = function(path35, mode, callback) {
171
+ fs33.open(
172
+ path35,
173
173
  constants2.O_WRONLY | constants2.O_SYMLINK,
174
174
  mode,
175
175
  function(err, fd) {
@@ -177,80 +177,80 @@ var require_polyfills = __commonJS({
177
177
  if (callback) callback(err);
178
178
  return;
179
179
  }
180
- fs32.fchmod(fd, mode, function(err2) {
181
- fs32.close(fd, function(err22) {
180
+ fs33.fchmod(fd, mode, function(err2) {
181
+ fs33.close(fd, function(err22) {
182
182
  if (callback) callback(err2 || err22);
183
183
  });
184
184
  });
185
185
  }
186
186
  );
187
187
  };
188
- fs32.lchmodSync = function(path34, mode) {
189
- var fd = fs32.openSync(path34, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
188
+ fs33.lchmodSync = function(path35, mode) {
189
+ var fd = fs33.openSync(path35, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
190
190
  var threw = true;
191
191
  var ret;
192
192
  try {
193
- ret = fs32.fchmodSync(fd, mode);
193
+ ret = fs33.fchmodSync(fd, mode);
194
194
  threw = false;
195
195
  } finally {
196
196
  if (threw) {
197
197
  try {
198
- fs32.closeSync(fd);
198
+ fs33.closeSync(fd);
199
199
  } catch (er) {
200
200
  }
201
201
  } else {
202
- fs32.closeSync(fd);
202
+ fs33.closeSync(fd);
203
203
  }
204
204
  }
205
205
  return ret;
206
206
  };
207
207
  }
208
- function patchLutimes(fs32) {
209
- if (constants2.hasOwnProperty("O_SYMLINK") && fs32.futimes) {
210
- fs32.lutimes = function(path34, at, mt, cb) {
211
- fs32.open(path34, constants2.O_SYMLINK, function(er, fd) {
208
+ function patchLutimes(fs33) {
209
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs33.futimes) {
210
+ fs33.lutimes = function(path35, at, mt, cb) {
211
+ fs33.open(path35, constants2.O_SYMLINK, function(er, fd) {
212
212
  if (er) {
213
213
  if (cb) cb(er);
214
214
  return;
215
215
  }
216
- fs32.futimes(fd, at, mt, function(er2) {
217
- fs32.close(fd, function(er22) {
216
+ fs33.futimes(fd, at, mt, function(er2) {
217
+ fs33.close(fd, function(er22) {
218
218
  if (cb) cb(er2 || er22);
219
219
  });
220
220
  });
221
221
  });
222
222
  };
223
- fs32.lutimesSync = function(path34, at, mt) {
224
- var fd = fs32.openSync(path34, constants2.O_SYMLINK);
223
+ fs33.lutimesSync = function(path35, at, mt) {
224
+ var fd = fs33.openSync(path35, constants2.O_SYMLINK);
225
225
  var ret;
226
226
  var threw = true;
227
227
  try {
228
- ret = fs32.futimesSync(fd, at, mt);
228
+ ret = fs33.futimesSync(fd, at, mt);
229
229
  threw = false;
230
230
  } finally {
231
231
  if (threw) {
232
232
  try {
233
- fs32.closeSync(fd);
233
+ fs33.closeSync(fd);
234
234
  } catch (er) {
235
235
  }
236
236
  } else {
237
- fs32.closeSync(fd);
237
+ fs33.closeSync(fd);
238
238
  }
239
239
  }
240
240
  return ret;
241
241
  };
242
- } else if (fs32.futimes) {
243
- fs32.lutimes = function(_a4, _b, _c9, cb) {
242
+ } else if (fs33.futimes) {
243
+ fs33.lutimes = function(_a4, _b, _c9, cb) {
244
244
  if (cb) process.nextTick(cb);
245
245
  };
246
- fs32.lutimesSync = function() {
246
+ fs33.lutimesSync = function() {
247
247
  };
248
248
  }
249
249
  }
250
250
  function chmodFix(orig) {
251
251
  if (!orig) return orig;
252
252
  return function(target, mode, cb) {
253
- return orig.call(fs31, target, mode, function(er) {
253
+ return orig.call(fs32, target, mode, function(er) {
254
254
  if (chownErOk(er)) er = null;
255
255
  if (cb) cb.apply(this, arguments);
256
256
  });
@@ -260,7 +260,7 @@ var require_polyfills = __commonJS({
260
260
  if (!orig) return orig;
261
261
  return function(target, mode) {
262
262
  try {
263
- return orig.call(fs31, target, mode);
263
+ return orig.call(fs32, target, mode);
264
264
  } catch (er) {
265
265
  if (!chownErOk(er)) throw er;
266
266
  }
@@ -269,7 +269,7 @@ var require_polyfills = __commonJS({
269
269
  function chownFix(orig) {
270
270
  if (!orig) return orig;
271
271
  return function(target, uid, gid, cb) {
272
- return orig.call(fs31, target, uid, gid, function(er) {
272
+ return orig.call(fs32, target, uid, gid, function(er) {
273
273
  if (chownErOk(er)) er = null;
274
274
  if (cb) cb.apply(this, arguments);
275
275
  });
@@ -279,7 +279,7 @@ var require_polyfills = __commonJS({
279
279
  if (!orig) return orig;
280
280
  return function(target, uid, gid) {
281
281
  try {
282
- return orig.call(fs31, target, uid, gid);
282
+ return orig.call(fs32, target, uid, gid);
283
283
  } catch (er) {
284
284
  if (!chownErOk(er)) throw er;
285
285
  }
@@ -299,13 +299,13 @@ var require_polyfills = __commonJS({
299
299
  }
300
300
  if (cb) cb.apply(this, arguments);
301
301
  }
302
- return options ? orig.call(fs31, target, options, callback) : orig.call(fs31, target, callback);
302
+ return options ? orig.call(fs32, target, options, callback) : orig.call(fs32, target, callback);
303
303
  };
304
304
  }
305
305
  function statFixSync(orig) {
306
306
  if (!orig) return orig;
307
307
  return function(target, options) {
308
- var stats = options ? orig.call(fs31, target, options) : orig.call(fs31, target);
308
+ var stats = options ? orig.call(fs32, target, options) : orig.call(fs32, target);
309
309
  if (stats) {
310
310
  if (stats.uid < 0) stats.uid += 4294967296;
311
311
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -334,16 +334,16 @@ var require_legacy_streams = __commonJS({
334
334
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports, module) {
335
335
  var Stream = __require("stream").Stream;
336
336
  module.exports = legacy;
337
- function legacy(fs31) {
337
+ function legacy(fs32) {
338
338
  return {
339
339
  ReadStream: ReadStream2,
340
340
  WriteStream
341
341
  };
342
- function ReadStream2(path34, options) {
343
- if (!(this instanceof ReadStream2)) return new ReadStream2(path34, options);
342
+ function ReadStream2(path35, options) {
343
+ if (!(this instanceof ReadStream2)) return new ReadStream2(path35, options);
344
344
  Stream.call(this);
345
345
  var self2 = this;
346
- this.path = path34;
346
+ this.path = path35;
347
347
  this.fd = null;
348
348
  this.readable = true;
349
349
  this.paused = false;
@@ -377,7 +377,7 @@ var require_legacy_streams = __commonJS({
377
377
  });
378
378
  return;
379
379
  }
380
- fs31.open(this.path, this.flags, this.mode, function(err, fd) {
380
+ fs32.open(this.path, this.flags, this.mode, function(err, fd) {
381
381
  if (err) {
382
382
  self2.emit("error", err);
383
383
  self2.readable = false;
@@ -388,10 +388,10 @@ var require_legacy_streams = __commonJS({
388
388
  self2._read();
389
389
  });
390
390
  }
391
- function WriteStream(path34, options) {
392
- if (!(this instanceof WriteStream)) return new WriteStream(path34, options);
391
+ function WriteStream(path35, options) {
392
+ if (!(this instanceof WriteStream)) return new WriteStream(path35, options);
393
393
  Stream.call(this);
394
- this.path = path34;
394
+ this.path = path35;
395
395
  this.fd = null;
396
396
  this.writable = true;
397
397
  this.flags = "w";
@@ -416,7 +416,7 @@ var require_legacy_streams = __commonJS({
416
416
  this.busy = false;
417
417
  this._queue = [];
418
418
  if (this.fd === null) {
419
- this._open = fs31.open;
419
+ this._open = fs32.open;
420
420
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
421
421
  this.flush();
422
422
  }
@@ -451,7 +451,7 @@ var require_clone = __commonJS({
451
451
  // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
452
452
  var require_graceful_fs = __commonJS({
453
453
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
454
- var fs31 = __require("fs");
454
+ var fs32 = __require("fs");
455
455
  var polyfills = require_polyfills();
456
456
  var legacy = require_legacy_streams();
457
457
  var clone = require_clone();
@@ -483,12 +483,12 @@ var require_graceful_fs = __commonJS({
483
483
  m7 = "GFS4: " + m7.split(/\n/).join("\nGFS4: ");
484
484
  console.error(m7);
485
485
  };
486
- if (!fs31[gracefulQueue]) {
486
+ if (!fs32[gracefulQueue]) {
487
487
  queue = global[gracefulQueue] || [];
488
- publishQueue(fs31, queue);
489
- fs31.close = (function(fs$close) {
488
+ publishQueue(fs32, queue);
489
+ fs32.close = (function(fs$close) {
490
490
  function close(fd, cb) {
491
- return fs$close.call(fs31, fd, function(err) {
491
+ return fs$close.call(fs32, fd, function(err) {
492
492
  if (!err) {
493
493
  resetQueue();
494
494
  }
@@ -500,48 +500,48 @@ var require_graceful_fs = __commonJS({
500
500
  value: fs$close
501
501
  });
502
502
  return close;
503
- })(fs31.close);
504
- fs31.closeSync = (function(fs$closeSync) {
503
+ })(fs32.close);
504
+ fs32.closeSync = (function(fs$closeSync) {
505
505
  function closeSync(fd) {
506
- fs$closeSync.apply(fs31, arguments);
506
+ fs$closeSync.apply(fs32, arguments);
507
507
  resetQueue();
508
508
  }
509
509
  Object.defineProperty(closeSync, previousSymbol, {
510
510
  value: fs$closeSync
511
511
  });
512
512
  return closeSync;
513
- })(fs31.closeSync);
513
+ })(fs32.closeSync);
514
514
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
515
515
  process.on("exit", function() {
516
- debug2(fs31[gracefulQueue]);
517
- __require("assert").equal(fs31[gracefulQueue].length, 0);
516
+ debug2(fs32[gracefulQueue]);
517
+ __require("assert").equal(fs32[gracefulQueue].length, 0);
518
518
  });
519
519
  }
520
520
  }
521
521
  var queue;
522
522
  if (!global[gracefulQueue]) {
523
- publishQueue(global, fs31[gracefulQueue]);
524
- }
525
- module.exports = patch(clone(fs31));
526
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs31.__patched) {
527
- module.exports = patch(fs31);
528
- fs31.__patched = true;
529
- }
530
- function patch(fs32) {
531
- polyfills(fs32);
532
- fs32.gracefulify = patch;
533
- fs32.createReadStream = createReadStream;
534
- fs32.createWriteStream = createWriteStream;
535
- var fs$readFile = fs32.readFile;
536
- fs32.readFile = readFile3;
537
- function readFile3(path34, options, cb) {
523
+ publishQueue(global, fs32[gracefulQueue]);
524
+ }
525
+ module.exports = patch(clone(fs32));
526
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs32.__patched) {
527
+ module.exports = patch(fs32);
528
+ fs32.__patched = true;
529
+ }
530
+ function patch(fs33) {
531
+ polyfills(fs33);
532
+ fs33.gracefulify = patch;
533
+ fs33.createReadStream = createReadStream;
534
+ fs33.createWriteStream = createWriteStream;
535
+ var fs$readFile = fs33.readFile;
536
+ fs33.readFile = readFile3;
537
+ function readFile3(path35, options, cb) {
538
538
  if (typeof options === "function")
539
539
  cb = options, options = null;
540
- return go$readFile(path34, options, cb);
541
- function go$readFile(path35, options2, cb2, startTime) {
542
- return fs$readFile(path35, options2, function(err) {
540
+ return go$readFile(path35, options, cb);
541
+ function go$readFile(path36, options2, cb2, startTime) {
542
+ return fs$readFile(path36, options2, function(err) {
543
543
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
544
- enqueue([go$readFile, [path35, options2, cb2], err, startTime || Date.now(), Date.now()]);
544
+ enqueue([go$readFile, [path36, options2, cb2], err, startTime || Date.now(), Date.now()]);
545
545
  else {
546
546
  if (typeof cb2 === "function")
547
547
  cb2.apply(this, arguments);
@@ -549,16 +549,16 @@ var require_graceful_fs = __commonJS({
549
549
  });
550
550
  }
551
551
  }
552
- var fs$writeFile = fs32.writeFile;
553
- fs32.writeFile = writeFile;
554
- function writeFile(path34, data3, options, cb) {
552
+ var fs$writeFile = fs33.writeFile;
553
+ fs33.writeFile = writeFile;
554
+ function writeFile(path35, data3, options, cb) {
555
555
  if (typeof options === "function")
556
556
  cb = options, options = null;
557
- return go$writeFile(path34, data3, options, cb);
558
- function go$writeFile(path35, data4, options2, cb2, startTime) {
559
- return fs$writeFile(path35, data4, options2, function(err) {
557
+ return go$writeFile(path35, data3, options, cb);
558
+ function go$writeFile(path36, data4, options2, cb2, startTime) {
559
+ return fs$writeFile(path36, data4, options2, function(err) {
560
560
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
561
- enqueue([go$writeFile, [path35, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
561
+ enqueue([go$writeFile, [path36, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
562
562
  else {
563
563
  if (typeof cb2 === "function")
564
564
  cb2.apply(this, arguments);
@@ -566,17 +566,17 @@ var require_graceful_fs = __commonJS({
566
566
  });
567
567
  }
568
568
  }
569
- var fs$appendFile = fs32.appendFile;
569
+ var fs$appendFile = fs33.appendFile;
570
570
  if (fs$appendFile)
571
- fs32.appendFile = appendFile;
572
- function appendFile(path34, data3, options, cb) {
571
+ fs33.appendFile = appendFile;
572
+ function appendFile(path35, data3, options, cb) {
573
573
  if (typeof options === "function")
574
574
  cb = options, options = null;
575
- return go$appendFile(path34, data3, options, cb);
576
- function go$appendFile(path35, data4, options2, cb2, startTime) {
577
- return fs$appendFile(path35, data4, options2, function(err) {
575
+ return go$appendFile(path35, data3, options, cb);
576
+ function go$appendFile(path36, data4, options2, cb2, startTime) {
577
+ return fs$appendFile(path36, data4, options2, function(err) {
578
578
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
579
- enqueue([go$appendFile, [path35, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
579
+ enqueue([go$appendFile, [path36, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
580
580
  else {
581
581
  if (typeof cb2 === "function")
582
582
  cb2.apply(this, arguments);
@@ -584,9 +584,9 @@ var require_graceful_fs = __commonJS({
584
584
  });
585
585
  }
586
586
  }
587
- var fs$copyFile = fs32.copyFile;
587
+ var fs$copyFile = fs33.copyFile;
588
588
  if (fs$copyFile)
589
- fs32.copyFile = copyFile;
589
+ fs33.copyFile = copyFile;
590
590
  function copyFile(src, dest, flags, cb) {
591
591
  if (typeof flags === "function") {
592
592
  cb = flags;
@@ -604,34 +604,34 @@ var require_graceful_fs = __commonJS({
604
604
  });
605
605
  }
606
606
  }
607
- var fs$readdir = fs32.readdir;
608
- fs32.readdir = readdir;
607
+ var fs$readdir = fs33.readdir;
608
+ fs33.readdir = readdir;
609
609
  var noReaddirOptionVersions = /^v[0-5]\./;
610
- function readdir(path34, options, cb) {
610
+ function readdir(path35, options, cb) {
611
611
  if (typeof options === "function")
612
612
  cb = options, options = null;
613
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path35, options2, cb2, startTime) {
614
- return fs$readdir(path35, fs$readdirCallback(
615
- path35,
613
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path36, options2, cb2, startTime) {
614
+ return fs$readdir(path36, fs$readdirCallback(
615
+ path36,
616
616
  options2,
617
617
  cb2,
618
618
  startTime
619
619
  ));
620
- } : function go$readdir2(path35, options2, cb2, startTime) {
621
- return fs$readdir(path35, options2, fs$readdirCallback(
622
- path35,
620
+ } : function go$readdir2(path36, options2, cb2, startTime) {
621
+ return fs$readdir(path36, options2, fs$readdirCallback(
622
+ path36,
623
623
  options2,
624
624
  cb2,
625
625
  startTime
626
626
  ));
627
627
  };
628
- return go$readdir(path34, options, cb);
629
- function fs$readdirCallback(path35, options2, cb2, startTime) {
628
+ return go$readdir(path35, options, cb);
629
+ function fs$readdirCallback(path36, options2, cb2, startTime) {
630
630
  return function(err, files) {
631
631
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
632
632
  enqueue([
633
633
  go$readdir,
634
- [path35, options2, cb2],
634
+ [path36, options2, cb2],
635
635
  err,
636
636
  startTime || Date.now(),
637
637
  Date.now()
@@ -646,21 +646,21 @@ var require_graceful_fs = __commonJS({
646
646
  }
647
647
  }
648
648
  if (process.version.substr(0, 4) === "v0.8") {
649
- var legStreams = legacy(fs32);
649
+ var legStreams = legacy(fs33);
650
650
  ReadStream2 = legStreams.ReadStream;
651
651
  WriteStream = legStreams.WriteStream;
652
652
  }
653
- var fs$ReadStream = fs32.ReadStream;
653
+ var fs$ReadStream = fs33.ReadStream;
654
654
  if (fs$ReadStream) {
655
655
  ReadStream2.prototype = Object.create(fs$ReadStream.prototype);
656
656
  ReadStream2.prototype.open = ReadStream$open;
657
657
  }
658
- var fs$WriteStream = fs32.WriteStream;
658
+ var fs$WriteStream = fs33.WriteStream;
659
659
  if (fs$WriteStream) {
660
660
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
661
661
  WriteStream.prototype.open = WriteStream$open;
662
662
  }
663
- Object.defineProperty(fs32, "ReadStream", {
663
+ Object.defineProperty(fs33, "ReadStream", {
664
664
  get: function() {
665
665
  return ReadStream2;
666
666
  },
@@ -670,7 +670,7 @@ var require_graceful_fs = __commonJS({
670
670
  enumerable: true,
671
671
  configurable: true
672
672
  });
673
- Object.defineProperty(fs32, "WriteStream", {
673
+ Object.defineProperty(fs33, "WriteStream", {
674
674
  get: function() {
675
675
  return WriteStream;
676
676
  },
@@ -681,7 +681,7 @@ var require_graceful_fs = __commonJS({
681
681
  configurable: true
682
682
  });
683
683
  var FileReadStream = ReadStream2;
684
- Object.defineProperty(fs32, "FileReadStream", {
684
+ Object.defineProperty(fs33, "FileReadStream", {
685
685
  get: function() {
686
686
  return FileReadStream;
687
687
  },
@@ -692,7 +692,7 @@ var require_graceful_fs = __commonJS({
692
692
  configurable: true
693
693
  });
694
694
  var FileWriteStream = WriteStream;
695
- Object.defineProperty(fs32, "FileWriteStream", {
695
+ Object.defineProperty(fs33, "FileWriteStream", {
696
696
  get: function() {
697
697
  return FileWriteStream;
698
698
  },
@@ -702,7 +702,7 @@ var require_graceful_fs = __commonJS({
702
702
  enumerable: true,
703
703
  configurable: true
704
704
  });
705
- function ReadStream2(path34, options) {
705
+ function ReadStream2(path35, options) {
706
706
  if (this instanceof ReadStream2)
707
707
  return fs$ReadStream.apply(this, arguments), this;
708
708
  else
@@ -722,7 +722,7 @@ var require_graceful_fs = __commonJS({
722
722
  }
723
723
  });
724
724
  }
725
- function WriteStream(path34, options) {
725
+ function WriteStream(path35, options) {
726
726
  if (this instanceof WriteStream)
727
727
  return fs$WriteStream.apply(this, arguments), this;
728
728
  else
@@ -740,22 +740,22 @@ var require_graceful_fs = __commonJS({
740
740
  }
741
741
  });
742
742
  }
743
- function createReadStream(path34, options) {
744
- return new fs32.ReadStream(path34, options);
743
+ function createReadStream(path35, options) {
744
+ return new fs33.ReadStream(path35, options);
745
745
  }
746
- function createWriteStream(path34, options) {
747
- return new fs32.WriteStream(path34, options);
746
+ function createWriteStream(path35, options) {
747
+ return new fs33.WriteStream(path35, options);
748
748
  }
749
- var fs$open = fs32.open;
750
- fs32.open = open;
751
- function open(path34, flags, mode, cb) {
749
+ var fs$open = fs33.open;
750
+ fs33.open = open;
751
+ function open(path35, flags, mode, cb) {
752
752
  if (typeof mode === "function")
753
753
  cb = mode, mode = null;
754
- return go$open(path34, flags, mode, cb);
755
- function go$open(path35, flags2, mode2, cb2, startTime) {
756
- return fs$open(path35, flags2, mode2, function(err, fd) {
754
+ return go$open(path35, flags, mode, cb);
755
+ function go$open(path36, flags2, mode2, cb2, startTime) {
756
+ return fs$open(path36, flags2, mode2, function(err, fd) {
757
757
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
758
- enqueue([go$open, [path35, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
758
+ enqueue([go$open, [path36, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
759
759
  else {
760
760
  if (typeof cb2 === "function")
761
761
  cb2.apply(this, arguments);
@@ -763,20 +763,20 @@ var require_graceful_fs = __commonJS({
763
763
  });
764
764
  }
765
765
  }
766
- return fs32;
766
+ return fs33;
767
767
  }
768
768
  function enqueue(elem) {
769
769
  debug2("ENQUEUE", elem[0].name, elem[1]);
770
- fs31[gracefulQueue].push(elem);
770
+ fs32[gracefulQueue].push(elem);
771
771
  retry2();
772
772
  }
773
773
  var retryTimer;
774
774
  function resetQueue() {
775
775
  var now = Date.now();
776
- for (var i10 = 0; i10 < fs31[gracefulQueue].length; ++i10) {
777
- if (fs31[gracefulQueue][i10].length > 2) {
778
- fs31[gracefulQueue][i10][3] = now;
779
- fs31[gracefulQueue][i10][4] = now;
776
+ for (var i10 = 0; i10 < fs32[gracefulQueue].length; ++i10) {
777
+ if (fs32[gracefulQueue][i10].length > 2) {
778
+ fs32[gracefulQueue][i10][3] = now;
779
+ fs32[gracefulQueue][i10][4] = now;
780
780
  }
781
781
  }
782
782
  retry2();
@@ -784,9 +784,9 @@ var require_graceful_fs = __commonJS({
784
784
  function retry2() {
785
785
  clearTimeout(retryTimer);
786
786
  retryTimer = void 0;
787
- if (fs31[gracefulQueue].length === 0)
787
+ if (fs32[gracefulQueue].length === 0)
788
788
  return;
789
- var elem = fs31[gracefulQueue].shift();
789
+ var elem = fs32[gracefulQueue].shift();
790
790
  var fn = elem[0];
791
791
  var args = elem[1];
792
792
  var err = elem[2];
@@ -808,7 +808,7 @@ var require_graceful_fs = __commonJS({
808
808
  debug2("RETRY", fn.name, args);
809
809
  fn.apply(null, args.concat([startTime]));
810
810
  } else {
811
- fs31[gracefulQueue].push(elem);
811
+ fs32[gracefulQueue].push(elem);
812
812
  }
813
813
  }
814
814
  if (retryTimer === void 0) {
@@ -1243,10 +1243,10 @@ var require_mtime_precision = __commonJS({
1243
1243
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
1244
1244
  "use strict";
1245
1245
  var cacheSymbol = Symbol();
1246
- function probe(file, fs31, callback) {
1247
- const cachedPrecision = fs31[cacheSymbol];
1246
+ function probe(file, fs32, callback) {
1247
+ const cachedPrecision = fs32[cacheSymbol];
1248
1248
  if (cachedPrecision) {
1249
- return fs31.stat(file, (err, stat) => {
1249
+ return fs32.stat(file, (err, stat) => {
1250
1250
  if (err) {
1251
1251
  return callback(err);
1252
1252
  }
@@ -1254,16 +1254,16 @@ var require_mtime_precision = __commonJS({
1254
1254
  });
1255
1255
  }
1256
1256
  const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1257
- fs31.utimes(file, mtime, mtime, (err) => {
1257
+ fs32.utimes(file, mtime, mtime, (err) => {
1258
1258
  if (err) {
1259
1259
  return callback(err);
1260
1260
  }
1261
- fs31.stat(file, (err2, stat) => {
1261
+ fs32.stat(file, (err2, stat) => {
1262
1262
  if (err2) {
1263
1263
  return callback(err2);
1264
1264
  }
1265
1265
  const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1266
- Object.defineProperty(fs31, cacheSymbol, { value: precision });
1266
+ Object.defineProperty(fs32, cacheSymbol, { value: precision });
1267
1267
  callback(null, stat.mtime, precision);
1268
1268
  });
1269
1269
  });
@@ -1284,8 +1284,8 @@ var require_mtime_precision = __commonJS({
1284
1284
  var require_lockfile = __commonJS({
1285
1285
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
1286
1286
  "use strict";
1287
- var path34 = __require("path");
1288
- var fs31 = require_graceful_fs();
1287
+ var path35 = __require("path");
1288
+ var fs32 = require_graceful_fs();
1289
1289
  var retry2 = require_retry2();
1290
1290
  var onExit = require_signal_exit();
1291
1291
  var mtimePrecision = require_mtime_precision();
@@ -1295,7 +1295,7 @@ var require_lockfile = __commonJS({
1295
1295
  }
1296
1296
  function resolveCanonicalPath(file, options, callback) {
1297
1297
  if (!options.realpath) {
1298
- return callback(null, path34.resolve(file));
1298
+ return callback(null, path35.resolve(file));
1299
1299
  }
1300
1300
  options.fs.realpath(file, callback);
1301
1301
  }
@@ -1416,7 +1416,7 @@ var require_lockfile = __commonJS({
1416
1416
  update: null,
1417
1417
  realpath: true,
1418
1418
  retries: 0,
1419
- fs: fs31,
1419
+ fs: fs32,
1420
1420
  onCompromised: (err) => {
1421
1421
  throw err;
1422
1422
  },
@@ -1460,7 +1460,7 @@ var require_lockfile = __commonJS({
1460
1460
  }
1461
1461
  function unlock(file, options, callback) {
1462
1462
  options = {
1463
- fs: fs31,
1463
+ fs: fs32,
1464
1464
  realpath: true,
1465
1465
  ...options
1466
1466
  };
@@ -1482,7 +1482,7 @@ var require_lockfile = __commonJS({
1482
1482
  options = {
1483
1483
  stale: 1e4,
1484
1484
  realpath: true,
1485
- fs: fs31,
1485
+ fs: fs32,
1486
1486
  ...options
1487
1487
  };
1488
1488
  options.stale = Math.max(options.stale || 0, 2e3);
@@ -1521,16 +1521,16 @@ var require_lockfile = __commonJS({
1521
1521
  var require_adapter = __commonJS({
1522
1522
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
1523
1523
  "use strict";
1524
- var fs31 = require_graceful_fs();
1525
- function createSyncFs(fs32) {
1524
+ var fs32 = require_graceful_fs();
1525
+ function createSyncFs(fs33) {
1526
1526
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
1527
- const newFs = { ...fs32 };
1527
+ const newFs = { ...fs33 };
1528
1528
  methods.forEach((method) => {
1529
1529
  newFs[method] = (...args) => {
1530
1530
  const callback = args.pop();
1531
1531
  let ret;
1532
1532
  try {
1533
- ret = fs32[`${method}Sync`](...args);
1533
+ ret = fs33[`${method}Sync`](...args);
1534
1534
  } catch (err) {
1535
1535
  return callback(err);
1536
1536
  }
@@ -1568,7 +1568,7 @@ var require_adapter = __commonJS({
1568
1568
  }
1569
1569
  function toSyncOptions(options) {
1570
1570
  options = { ...options };
1571
- options.fs = createSyncFs(options.fs || fs31);
1571
+ options.fs = createSyncFs(options.fs || fs32);
1572
1572
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
1573
1573
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
1574
1574
  }
@@ -2530,10 +2530,10 @@ var require_src2 = __commonJS({
2530
2530
  var fs_1 = __require("fs");
2531
2531
  var debug_1 = __importDefault2(require_src());
2532
2532
  var log6 = debug_1.default("@kwsites/file-exists");
2533
- function check(path34, isFile, isDirectory) {
2534
- log6(`checking %s`, path34);
2533
+ function check(path35, isFile, isDirectory) {
2534
+ log6(`checking %s`, path35);
2535
2535
  try {
2536
- const stat = fs_1.statSync(path34);
2536
+ const stat = fs_1.statSync(path35);
2537
2537
  if (stat.isFile() && isFile) {
2538
2538
  log6(`[OK] path represents a file`);
2539
2539
  return true;
@@ -2553,8 +2553,8 @@ var require_src2 = __commonJS({
2553
2553
  throw e9;
2554
2554
  }
2555
2555
  }
2556
- function exists3(path34, type = exports.READABLE) {
2557
- return check(path34, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
2556
+ function exists3(path35, type = exports.READABLE) {
2557
+ return check(path35, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
2558
2558
  }
2559
2559
  exports.exists = exists3;
2560
2560
  exports.FILE = 1;
@@ -3029,8 +3029,8 @@ var init_parseUtil = __esm({
3029
3029
  init_errors();
3030
3030
  init_en();
3031
3031
  makeIssue = (params) => {
3032
- const { data: data3, path: path34, errorMaps, issueData } = params;
3033
- const fullPath = [...path34, ...issueData.path || []];
3032
+ const { data: data3, path: path35, errorMaps, issueData } = params;
3033
+ const fullPath = [...path35, ...issueData.path || []];
3034
3034
  const fullIssue = {
3035
3035
  ...issueData,
3036
3036
  path: fullPath
@@ -3338,11 +3338,11 @@ var init_types = __esm({
3338
3338
  init_parseUtil();
3339
3339
  init_util2();
3340
3340
  ParseInputLazyPath = class {
3341
- constructor(parent, value, path34, key) {
3341
+ constructor(parent, value, path35, key) {
3342
3342
  this._cachedPath = [];
3343
3343
  this.parent = parent;
3344
3344
  this.data = value;
3345
- this._path = path34;
3345
+ this._path = path35;
3346
3346
  this._key = key;
3347
3347
  }
3348
3348
  get path() {
@@ -7004,8 +7004,8 @@ var require_dist3 = __commonJS({
7004
7004
  });
7005
7005
 
7006
7006
  // ../canopycms/src/paths/normalize.ts
7007
- function normalizeFilesystemPath(path34) {
7008
- return path34.split(/[\\/]+/).filter(Boolean).join("/");
7007
+ function normalizeFilesystemPath(path35) {
7008
+ return path35.split(/[\\/]+/).filter(Boolean).join("/");
7009
7009
  }
7010
7010
  var init_normalize = __esm({
7011
7011
  "../canopycms/src/paths/normalize.ts"() {
@@ -8258,15 +8258,15 @@ var require_dist_node9 = __commonJS({
8258
8258
  octokit.log.debug("request", options);
8259
8259
  const start = Date.now();
8260
8260
  const requestOptions = octokit.request.endpoint.parse(options);
8261
- const path34 = requestOptions.url.replace(options.baseUrl, "");
8261
+ const path35 = requestOptions.url.replace(options.baseUrl, "");
8262
8262
  return request(options).then((response) => {
8263
8263
  octokit.log.info(
8264
- `${requestOptions.method} ${path34} - ${response.status} in ${Date.now() - start}ms`
8264
+ `${requestOptions.method} ${path35} - ${response.status} in ${Date.now() - start}ms`
8265
8265
  );
8266
8266
  return response;
8267
8267
  }).catch((error3) => {
8268
8268
  octokit.log.info(
8269
- `${requestOptions.method} ${path34} - ${error3.status} in ${Date.now() - start}ms`
8269
+ `${requestOptions.method} ${path35} - ${error3.status} in ${Date.now() - start}ms`
8270
8270
  );
8271
8271
  throw error3;
8272
8272
  });
@@ -12360,7 +12360,7 @@ var require_dist_node13 = __commonJS({
12360
12360
  ];
12361
12361
  function routeMatcher(paths) {
12362
12362
  const regexes = paths.map(
12363
- (path34) => path34.split("/").map((c11) => c11.startsWith("{") ? "(?:.+?)" : c11).join("/")
12363
+ (path35) => path35.split("/").map((c11) => c11.startsWith("{") ? "(?:.+?)" : c11).join("/")
12364
12364
  );
12365
12365
  const regex2 = `^(?:${regexes.map((r10) => `(?:${r10})`).join("|")})[^/]*$`;
12366
12366
  return new RegExp(regex2, "i");
@@ -13375,9 +13375,9 @@ var init_createPaginator = __esm({
13375
13375
  command5 = withCommand(command5) ?? command5;
13376
13376
  return await client.send(command5, ...args);
13377
13377
  };
13378
- get = (fromObject, path34) => {
13378
+ get = (fromObject, path35) => {
13379
13379
  let cursor3 = fromObject;
13380
- const pathComponents = path34.split(".");
13380
+ const pathComponents = path35.split(".");
13381
13381
  for (const step of pathComponents) {
13382
13382
  if (!cursor3 || typeof cursor3 !== "object") {
13383
13383
  return void 0;
@@ -14395,12 +14395,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
14395
14395
  const password = request.password ?? "";
14396
14396
  auth = `${username}:${password}`;
14397
14397
  }
14398
- let path34 = request.path;
14398
+ let path35 = request.path;
14399
14399
  if (queryString) {
14400
- path34 += `?${queryString}`;
14400
+ path35 += `?${queryString}`;
14401
14401
  }
14402
14402
  if (request.fragment) {
14403
- path34 += `#${request.fragment}`;
14403
+ path35 += `#${request.fragment}`;
14404
14404
  }
14405
14405
  let hostname = request.hostname ?? "";
14406
14406
  if (hostname[0] === "[" && hostname.endsWith("]")) {
@@ -14412,7 +14412,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
14412
14412
  headers: request.headers,
14413
14413
  host: hostname,
14414
14414
  method: request.method,
14415
- path: path34,
14415
+ path: path35,
14416
14416
  port: request.port,
14417
14417
  agent,
14418
14418
  auth
@@ -14695,16 +14695,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
14695
14695
  reject(err);
14696
14696
  };
14697
14697
  const queryString = querystringBuilder.buildQueryString(query || {});
14698
- let path34 = request.path;
14698
+ let path35 = request.path;
14699
14699
  if (queryString) {
14700
- path34 += `?${queryString}`;
14700
+ path35 += `?${queryString}`;
14701
14701
  }
14702
14702
  if (request.fragment) {
14703
- path34 += `#${request.fragment}`;
14703
+ path35 += `#${request.fragment}`;
14704
14704
  }
14705
14705
  const req = session.request({
14706
14706
  ...request.headers,
14707
- [http2.constants.HTTP2_HEADER_PATH]: path34,
14707
+ [http2.constants.HTTP2_HEADER_PATH]: path35,
14708
14708
  [http2.constants.HTTP2_HEADER_METHOD]: method
14709
14709
  });
14710
14710
  session.ref();
@@ -14891,13 +14891,13 @@ var require_dist_cjs14 = __commonJS({
14891
14891
  const abortError = buildAbortError(abortSignal);
14892
14892
  return Promise.reject(abortError);
14893
14893
  }
14894
- let path34 = request.path;
14894
+ let path35 = request.path;
14895
14895
  const queryString = querystringBuilder.buildQueryString(request.query || {});
14896
14896
  if (queryString) {
14897
- path34 += `?${queryString}`;
14897
+ path35 += `?${queryString}`;
14898
14898
  }
14899
14899
  if (request.fragment) {
14900
- path34 += `#${request.fragment}`;
14900
+ path35 += `#${request.fragment}`;
14901
14901
  }
14902
14902
  let auth = "";
14903
14903
  if (request.username != null || request.password != null) {
@@ -14906,7 +14906,7 @@ var require_dist_cjs14 = __commonJS({
14906
14906
  auth = `${username}:${password}@`;
14907
14907
  }
14908
14908
  const { port, method } = request;
14909
- const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path34}`;
14909
+ const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path35}`;
14910
14910
  const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
14911
14911
  const requestOptions = {
14912
14912
  body,
@@ -17138,13 +17138,13 @@ function __disposeResources(env2) {
17138
17138
  }
17139
17139
  return next();
17140
17140
  }
17141
- function __rewriteRelativeImportExtension(path34, preserveJsx) {
17142
- if (typeof path34 === "string" && /^\.\.?\//.test(path34)) {
17143
- return path34.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m7, tsx, d9, ext, cm) {
17141
+ function __rewriteRelativeImportExtension(path35, preserveJsx) {
17142
+ if (typeof path35 === "string" && /^\.\.?\//.test(path35)) {
17143
+ return path35.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m7, tsx, d9, ext, cm) {
17144
17144
  return tsx ? preserveJsx ? ".jsx" : ".js" : d9 && (!ext || !cm) ? m7 : d9 + ext + "." + cm.toLowerCase() + "js";
17145
17145
  });
17146
17146
  }
17147
- return path34;
17147
+ return path35;
17148
17148
  }
17149
17149
  var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
17150
17150
  var init_tslib_es6 = __esm({
@@ -17250,11 +17250,11 @@ var require_randomUUID = __commonJS({
17250
17250
  var require_dist_cjs19 = __commonJS({
17251
17251
  "../../node_modules/.pnpm/@smithy+uuid@1.1.2/node_modules/@smithy/uuid/dist-cjs/index.js"(exports) {
17252
17252
  "use strict";
17253
- var randomUUID3 = require_randomUUID();
17253
+ var randomUUID4 = require_randomUUID();
17254
17254
  var decimalToHex2 = Array.from({ length: 256 }, (_3, i10) => i10.toString(16).padStart(2, "0"));
17255
17255
  var v43 = () => {
17256
- if (randomUUID3.randomUUID) {
17257
- return randomUUID3.randomUUID();
17256
+ if (randomUUID4.randomUUID) {
17257
+ return randomUUID4.randomUUID();
17258
17258
  }
17259
17259
  const rnds = new Uint8Array(16);
17260
17260
  crypto.getRandomValues(rnds);
@@ -18042,11 +18042,11 @@ var init_HttpBindingProtocol = __esm({
18042
18042
  const opTraits = translateTraits(operationSchema.traits);
18043
18043
  if (opTraits.http) {
18044
18044
  request.method = opTraits.http[0];
18045
- const [path34, search] = opTraits.http[1].split("?");
18045
+ const [path35, search] = opTraits.http[1].split("?");
18046
18046
  if (request.path == "/") {
18047
- request.path = path34;
18047
+ request.path = path35;
18048
18048
  } else {
18049
- request.path += path34;
18049
+ request.path += path35;
18050
18050
  }
18051
18051
  const traitSearchParams = new URLSearchParams(search ?? "");
18052
18052
  Object.assign(query, Object.fromEntries(traitSearchParams));
@@ -18449,8 +18449,8 @@ var init_requestBuilder = __esm({
18449
18449
  return this;
18450
18450
  }
18451
18451
  p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
18452
- this.resolvePathStack.push((path34) => {
18453
- this.path = resolvedPath(path34, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
18452
+ this.resolvePathStack.push((path35) => {
18453
+ this.path = resolvedPath(path35, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
18454
18454
  });
18455
18455
  return this;
18456
18456
  }
@@ -19100,18 +19100,18 @@ var require_dist_cjs20 = __commonJS({
19100
19100
  }
19101
19101
  };
19102
19102
  var booleanEquals2 = (value1, value2) => value1 === value2;
19103
- var getAttrPathList2 = (path34) => {
19104
- const parts = path34.split(".");
19103
+ var getAttrPathList2 = (path35) => {
19104
+ const parts = path35.split(".");
19105
19105
  const pathList = [];
19106
19106
  for (const part of parts) {
19107
19107
  const squareBracketIndex = part.indexOf("[");
19108
19108
  if (squareBracketIndex !== -1) {
19109
19109
  if (part.indexOf("]") !== part.length - 1) {
19110
- throw new EndpointError2(`Path: '${path34}' does not end with ']'`);
19110
+ throw new EndpointError2(`Path: '${path35}' does not end with ']'`);
19111
19111
  }
19112
19112
  const arrayIndex = part.slice(squareBracketIndex + 1, -1);
19113
19113
  if (Number.isNaN(parseInt(arrayIndex))) {
19114
- throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path34}'`);
19114
+ throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path35}'`);
19115
19115
  }
19116
19116
  if (squareBracketIndex !== 0) {
19117
19117
  pathList.push(part.slice(0, squareBracketIndex));
@@ -19123,9 +19123,9 @@ var require_dist_cjs20 = __commonJS({
19123
19123
  }
19124
19124
  return pathList;
19125
19125
  };
19126
- var getAttr2 = (value, path34) => getAttrPathList2(path34).reduce((acc, index) => {
19126
+ var getAttr2 = (value, path35) => getAttrPathList2(path35).reduce((acc, index) => {
19127
19127
  if (typeof acc !== "object") {
19128
- throw new EndpointError2(`Index '${index}' in '${path34}' not found in '${JSON.stringify(value)}'`);
19128
+ throw new EndpointError2(`Index '${index}' in '${path35}' not found in '${JSON.stringify(value)}'`);
19129
19129
  } else if (Array.isArray(acc)) {
19130
19130
  return acc[parseInt(index)];
19131
19131
  }
@@ -19144,8 +19144,8 @@ var require_dist_cjs20 = __commonJS({
19144
19144
  return value;
19145
19145
  }
19146
19146
  if (typeof value === "object" && "hostname" in value) {
19147
- const { hostname: hostname2, port, protocol: protocol2 = "", path: path34 = "", query = {} } = value;
19148
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path34}`);
19147
+ const { hostname: hostname2, port, protocol: protocol2 = "", path: path35 = "", query = {} } = value;
19148
+ const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path35}`);
19149
19149
  url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
19150
19150
  return url;
19151
19151
  }
@@ -20590,10 +20590,10 @@ ${longDate}
20590
20590
  ${credentialScope}
20591
20591
  ${utilHexEncoding.toHex(hashedRequest)}`;
20592
20592
  }
20593
- getCanonicalPath({ path: path34 }) {
20593
+ getCanonicalPath({ path: path35 }) {
20594
20594
  if (this.uriEscapePath) {
20595
20595
  const normalizedPathSegments = [];
20596
- for (const pathSegment of path34.split("/")) {
20596
+ for (const pathSegment of path35.split("/")) {
20597
20597
  if (pathSegment?.length === 0)
20598
20598
  continue;
20599
20599
  if (pathSegment === ".")
@@ -20604,11 +20604,11 @@ ${utilHexEncoding.toHex(hashedRequest)}`;
20604
20604
  normalizedPathSegments.push(pathSegment);
20605
20605
  }
20606
20606
  }
20607
- const normalizedPath = `${path34?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path34?.endsWith("/") ? "/" : ""}`;
20607
+ const normalizedPath = `${path35?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path35?.endsWith("/") ? "/" : ""}`;
20608
20608
  const doubleEncoded = utilUriEscape.escapeUri(normalizedPath);
20609
20609
  return doubleEncoded.replace(/%2F/g, "/");
20610
20610
  }
20611
- return path34;
20611
+ return path35;
20612
20612
  }
20613
20613
  validateResolvedCredentials(credentials) {
20614
20614
  if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
@@ -21912,11 +21912,11 @@ var init_SmithyRpcV2CborProtocol = __esm({
21912
21912
  }
21913
21913
  }
21914
21914
  const { service, operation: operation3 } = (0, import_util_middleware5.getSmithyContext)(context);
21915
- const path34 = `/service/${service}/operation/${operation3}`;
21915
+ const path35 = `/service/${service}/operation/${operation3}`;
21916
21916
  if (request.path.endsWith("/")) {
21917
- request.path += path34.slice(1);
21917
+ request.path += path35.slice(1);
21918
21918
  } else {
21919
- request.path += path34;
21919
+ request.path += path35;
21920
21920
  }
21921
21921
  return request;
21922
21922
  }
@@ -27561,14 +27561,14 @@ var require_readFile = __commonJS({
27561
27561
  var promises_1 = __require("node:fs/promises");
27562
27562
  exports.filePromises = {};
27563
27563
  exports.fileIntercept = {};
27564
- var readFile3 = (path34, options) => {
27565
- if (exports.fileIntercept[path34] !== void 0) {
27566
- return exports.fileIntercept[path34];
27564
+ var readFile3 = (path35, options) => {
27565
+ if (exports.fileIntercept[path35] !== void 0) {
27566
+ return exports.fileIntercept[path35];
27567
27567
  }
27568
- if (!exports.filePromises[path34] || options?.ignoreCache) {
27569
- exports.filePromises[path34] = (0, promises_1.readFile)(path34, "utf8");
27568
+ if (!exports.filePromises[path35] || options?.ignoreCache) {
27569
+ exports.filePromises[path35] = (0, promises_1.readFile)(path35, "utf8");
27570
27570
  }
27571
- return exports.filePromises[path34];
27571
+ return exports.filePromises[path35];
27572
27572
  };
27573
27573
  exports.readFile = readFile3;
27574
27574
  }
@@ -27581,7 +27581,7 @@ var require_dist_cjs33 = __commonJS({
27581
27581
  var getHomeDir2 = require_getHomeDir();
27582
27582
  var getSSOTokenFilepath2 = require_getSSOTokenFilepath();
27583
27583
  var getSSOTokenFromFile2 = require_getSSOTokenFromFile();
27584
- var path34 = __require("path");
27584
+ var path35 = __require("path");
27585
27585
  var types = require_dist_cjs();
27586
27586
  var readFile3 = require_readFile();
27587
27587
  var ENV_PROFILE2 = "AWS_PROFILE";
@@ -27603,9 +27603,9 @@ var require_dist_cjs33 = __commonJS({
27603
27603
  ...data3.default && { default: data3.default }
27604
27604
  });
27605
27605
  var ENV_CONFIG_PATH2 = "AWS_CONFIG_FILE";
27606
- var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] || path34.join(getHomeDir2.getHomeDir(), ".aws", "config");
27606
+ var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] || path35.join(getHomeDir2.getHomeDir(), ".aws", "config");
27607
27607
  var ENV_CREDENTIALS_PATH2 = "AWS_SHARED_CREDENTIALS_FILE";
27608
- var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] || path34.join(getHomeDir2.getHomeDir(), ".aws", "credentials");
27608
+ var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] || path35.join(getHomeDir2.getHomeDir(), ".aws", "credentials");
27609
27609
  var prefixKeyRegex2 = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
27610
27610
  var profileNameBlockList2 = ["__proto__", "profile __proto__"];
27611
27611
  var parseIni2 = (iniData) => {
@@ -27660,11 +27660,11 @@ var require_dist_cjs33 = __commonJS({
27660
27660
  const relativeHomeDirPrefix = "~/";
27661
27661
  let resolvedFilepath = filepath;
27662
27662
  if (filepath.startsWith(relativeHomeDirPrefix)) {
27663
- resolvedFilepath = path34.join(homeDir, filepath.slice(2));
27663
+ resolvedFilepath = path35.join(homeDir, filepath.slice(2));
27664
27664
  }
27665
27665
  let resolvedConfigFilepath = configFilepath;
27666
27666
  if (configFilepath.startsWith(relativeHomeDirPrefix)) {
27667
- resolvedConfigFilepath = path34.join(homeDir, configFilepath.slice(2));
27667
+ resolvedConfigFilepath = path35.join(homeDir, configFilepath.slice(2));
27668
27668
  }
27669
27669
  const parsedFiles = await Promise.all([
27670
27670
  readFile3.readFile(resolvedConfigFilepath, {
@@ -27703,8 +27703,8 @@ var require_dist_cjs33 = __commonJS({
27703
27703
  getFileRecord() {
27704
27704
  return readFile3.fileIntercept;
27705
27705
  },
27706
- interceptFile(path35, contents) {
27707
- readFile3.fileIntercept[path35] = Promise.resolve(contents);
27706
+ interceptFile(path36, contents) {
27707
+ readFile3.fileIntercept[path36] = Promise.resolve(contents);
27708
27708
  },
27709
27709
  getTokenRecord() {
27710
27710
  return getSSOTokenFromFile2.tokenIntercept;
@@ -28029,8 +28029,8 @@ var require_dist_cjs36 = __commonJS({
28029
28029
  return endpoint.url.href;
28030
28030
  }
28031
28031
  if ("hostname" in endpoint) {
28032
- const { protocol, hostname, port, path: path34 } = endpoint;
28033
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path34}`;
28032
+ const { protocol, hostname, port, path: path35 } = endpoint;
28033
+ return `${protocol}//${hostname}${port ? ":" + port : ""}${path35}`;
28034
28034
  }
28035
28035
  }
28036
28036
  return endpoint;
@@ -38064,14 +38064,14 @@ var init_readFile = __esm({
38064
38064
  "../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js"() {
38065
38065
  filePromises = {};
38066
38066
  fileIntercept = {};
38067
- readFile2 = (path34, options) => {
38068
- if (fileIntercept[path34] !== void 0) {
38069
- return fileIntercept[path34];
38067
+ readFile2 = (path35, options) => {
38068
+ if (fileIntercept[path35] !== void 0) {
38069
+ return fileIntercept[path35];
38070
38070
  }
38071
- if (!filePromises[path34] || options?.ignoreCache) {
38072
- filePromises[path34] = fsReadFile(path34, "utf8");
38071
+ if (!filePromises[path35] || options?.ignoreCache) {
38072
+ filePromises[path35] = fsReadFile(path35, "utf8");
38073
38073
  }
38074
- return filePromises[path34];
38074
+ return filePromises[path35];
38075
38075
  };
38076
38076
  }
38077
38077
  });
@@ -38183,8 +38183,8 @@ var init_externalDataInterceptor = __esm({
38183
38183
  getFileRecord() {
38184
38184
  return fileIntercept;
38185
38185
  },
38186
- interceptFile(path34, contents) {
38187
- fileIntercept[path34] = Promise.resolve(contents);
38186
+ interceptFile(path35, contents) {
38187
+ fileIntercept[path35] = Promise.resolve(contents);
38188
38188
  },
38189
38189
  getTokenRecord() {
38190
38190
  return tokenIntercept;
@@ -41118,8 +41118,8 @@ var init_createConfigValueProvider = __esm({
41118
41118
  return endpoint.url.href;
41119
41119
  }
41120
41120
  if ("hostname" in endpoint) {
41121
- const { protocol, hostname, port, path: path34 } = endpoint;
41122
- return `${protocol}//${hostname}${port ? ":" + port : ""}${path34}`;
41121
+ const { protocol, hostname, port, path: path35 } = endpoint;
41122
+ return `${protocol}//${hostname}${port ? ":" + port : ""}${path35}`;
41123
41123
  }
41124
41124
  }
41125
41125
  return endpoint;
@@ -41494,18 +41494,18 @@ var getAttrPathList;
41494
41494
  var init_getAttrPathList = __esm({
41495
41495
  "../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttrPathList.js"() {
41496
41496
  init_types4();
41497
- getAttrPathList = (path34) => {
41498
- const parts = path34.split(".");
41497
+ getAttrPathList = (path35) => {
41498
+ const parts = path35.split(".");
41499
41499
  const pathList = [];
41500
41500
  for (const part of parts) {
41501
41501
  const squareBracketIndex = part.indexOf("[");
41502
41502
  if (squareBracketIndex !== -1) {
41503
41503
  if (part.indexOf("]") !== part.length - 1) {
41504
- throw new EndpointError(`Path: '${path34}' does not end with ']'`);
41504
+ throw new EndpointError(`Path: '${path35}' does not end with ']'`);
41505
41505
  }
41506
41506
  const arrayIndex = part.slice(squareBracketIndex + 1, -1);
41507
41507
  if (Number.isNaN(parseInt(arrayIndex))) {
41508
- throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path34}'`);
41508
+ throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path35}'`);
41509
41509
  }
41510
41510
  if (squareBracketIndex !== 0) {
41511
41511
  pathList.push(part.slice(0, squareBracketIndex));
@@ -41526,9 +41526,9 @@ var init_getAttr = __esm({
41526
41526
  "../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttr.js"() {
41527
41527
  init_types4();
41528
41528
  init_getAttrPathList();
41529
- getAttr = (value, path34) => getAttrPathList(path34).reduce((acc, index) => {
41529
+ getAttr = (value, path35) => getAttrPathList(path35).reduce((acc, index) => {
41530
41530
  if (typeof acc !== "object") {
41531
- throw new EndpointError(`Index '${index}' in '${path34}' not found in '${JSON.stringify(value)}'`);
41531
+ throw new EndpointError(`Index '${index}' in '${path35}' not found in '${JSON.stringify(value)}'`);
41532
41532
  } else if (Array.isArray(acc)) {
41533
41533
  const i10 = parseInt(index);
41534
41534
  return acc[i10 < 0 ? acc.length + i10 : i10];
@@ -41589,8 +41589,8 @@ var init_parseURL = __esm({
41589
41589
  return value;
41590
41590
  }
41591
41591
  if (typeof value === "object" && "hostname" in value) {
41592
- const { hostname: hostname2, port, protocol: protocol2 = "", path: path34 = "", query = {} } = value;
41593
- const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path34}`);
41592
+ const { hostname: hostname2, port, protocol: protocol2 = "", path: path35 = "", query = {} } = value;
41593
+ const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path35}`);
41594
41594
  url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
41595
41595
  return url;
41596
41596
  }
@@ -44827,11 +44827,11 @@ var init_HttpBindingProtocol2 = __esm({
44827
44827
  const opTraits = translateTraits2(operationSchema.traits);
44828
44828
  if (opTraits.http) {
44829
44829
  request.method = opTraits.http[0];
44830
- const [path34, search] = opTraits.http[1].split("?");
44830
+ const [path35, search] = opTraits.http[1].split("?");
44831
44831
  if (request.path == "/") {
44832
- request.path = path34;
44832
+ request.path = path35;
44833
44833
  } else {
44834
- request.path += path34;
44834
+ request.path += path35;
44835
44835
  }
44836
44836
  const traitSearchParams = new URLSearchParams(search ?? "");
44837
44837
  for (const [key, value] of traitSearchParams) {
@@ -45232,8 +45232,8 @@ var init_requestBuilder3 = __esm({
45232
45232
  return this;
45233
45233
  }
45234
45234
  p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
45235
- this.resolvePathStack.push((path34) => {
45236
- this.path = resolvedPath2(path34, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
45235
+ this.resolvePathStack.push((path35) => {
45236
+ this.path = resolvedPath2(path35, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
45237
45237
  });
45238
45238
  return this;
45239
45239
  }
@@ -45872,9 +45872,9 @@ var init_createPaginator2 = __esm({
45872
45872
  command5 = withCommand(command5) ?? command5;
45873
45873
  return await client.send(command5, ...args);
45874
45874
  };
45875
- get2 = (fromObject, path34) => {
45875
+ get2 = (fromObject, path35) => {
45876
45876
  let cursor3 = fromObject;
45877
- const pathComponents = path34.split(".");
45877
+ const pathComponents = path35.split(".");
45878
45878
  for (const step of pathComponents) {
45879
45879
  if (!cursor3 || typeof cursor3 !== "object") {
45880
45880
  return void 0;
@@ -49445,10 +49445,10 @@ ${longDate}
49445
49445
  ${credentialScope}
49446
49446
  ${toHex2(hashedRequest)}`;
49447
49447
  }
49448
- getCanonicalPath({ path: path34 }) {
49448
+ getCanonicalPath({ path: path35 }) {
49449
49449
  if (this.uriEscapePath) {
49450
49450
  const normalizedPathSegments = [];
49451
- for (const pathSegment of path34.split("/")) {
49451
+ for (const pathSegment of path35.split("/")) {
49452
49452
  if (pathSegment?.length === 0)
49453
49453
  continue;
49454
49454
  if (pathSegment === ".")
@@ -49459,11 +49459,11 @@ ${toHex2(hashedRequest)}`;
49459
49459
  normalizedPathSegments.push(pathSegment);
49460
49460
  }
49461
49461
  }
49462
- const normalizedPath = `${path34?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path34?.endsWith("/") ? "/" : ""}`;
49462
+ const normalizedPath = `${path35?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path35?.endsWith("/") ? "/" : ""}`;
49463
49463
  const doubleEncoded = escapeUri2(normalizedPath);
49464
49464
  return doubleEncoded.replace(/%2F/g, "/");
49465
49465
  }
49466
- return path34;
49466
+ return path35;
49467
49467
  }
49468
49468
  validateResolvedCredentials(credentials) {
49469
49469
  if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
@@ -51032,11 +51032,11 @@ var init_SmithyRpcV2CborProtocol2 = __esm({
51032
51032
  }
51033
51033
  }
51034
51034
  const { service, operation: operation3 } = getSmithyContext11(context);
51035
- const path34 = `/service/${service}/operation/${operation3}`;
51035
+ const path35 = `/service/${service}/operation/${operation3}`;
51036
51036
  if (request.path.endsWith("/")) {
51037
- request.path += path34.slice(1);
51037
+ request.path += path35.slice(1);
51038
51038
  } else {
51039
- request.path += path34;
51039
+ request.path += path35;
51040
51040
  }
51041
51041
  return request;
51042
51042
  }
@@ -54440,12 +54440,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
54440
54440
  const password = request.password ?? "";
54441
54441
  auth = `${username}:${password}`;
54442
54442
  }
54443
- let path34 = request.path;
54443
+ let path35 = request.path;
54444
54444
  if (queryString) {
54445
- path34 += `?${queryString}`;
54445
+ path35 += `?${queryString}`;
54446
54446
  }
54447
54447
  if (request.fragment) {
54448
- path34 += `#${request.fragment}`;
54448
+ path35 += `#${request.fragment}`;
54449
54449
  }
54450
54450
  let hostname = request.hostname ?? "";
54451
54451
  if (hostname[0] === "[" && hostname.endsWith("]")) {
@@ -54457,7 +54457,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
54457
54457
  headers: request.headers,
54458
54458
  host: hostname,
54459
54459
  method: request.method,
54460
- path: path34,
54460
+ path: path35,
54461
54461
  port: request.port,
54462
54462
  agent,
54463
54463
  auth
@@ -54860,16 +54860,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
54860
54860
  reject(err);
54861
54861
  };
54862
54862
  const queryString = query ? buildQueryString2(query) : "";
54863
- let path34 = request.path;
54863
+ let path35 = request.path;
54864
54864
  if (queryString) {
54865
- path34 += `?${queryString}`;
54865
+ path35 += `?${queryString}`;
54866
54866
  }
54867
54867
  if (request.fragment) {
54868
- path34 += `#${request.fragment}`;
54868
+ path35 += `#${request.fragment}`;
54869
54869
  }
54870
54870
  const clientHttp2Stream = session.request({
54871
54871
  ...request.headers,
54872
- [constants2.HTTP2_HEADER_PATH]: path34,
54872
+ [constants2.HTTP2_HEADER_PATH]: path35,
54873
54873
  [constants2.HTTP2_HEADER_METHOD]: method
54874
54874
  });
54875
54875
  if (effectiveRequestTimeout) {
@@ -54951,7 +54951,7 @@ var require_dist_cjs60 = __commonJS({
54951
54951
  var { setCredentialFeature: setCredentialFeature3 } = (init_client4(), __toCommonJS(client_exports3));
54952
54952
  var { CredentialsProviderError: CredentialsProviderError2 } = (init_config3(), __toCommonJS(config_exports));
54953
54953
  var { NodeHttpHandler } = require_dist_cjs59();
54954
- var fs31 = __require("node:fs/promises");
54954
+ var fs32 = __require("node:fs/promises");
54955
54955
  var { HttpRequest: HttpRequest11 } = (init_protocols3(), __toCommonJS(protocols_exports3));
54956
54956
  var { sdkStreamMixin: sdkStreamMixin4, parseRfc3339DateTime: parseRfc3339DateTime3 } = (init_serde2(), __toCommonJS(serde_exports2));
54957
54957
  var ECS_CONTAINER_HOST = "169.254.170.2";
@@ -55075,7 +55075,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
55075
55075
  const provider = retryWrapper(async () => {
55076
55076
  const request = createGetRequest(url);
55077
55077
  if (tokenFile) {
55078
- request.headers.Authorization = validateToken((await fs31.readFile(tokenFile)).toString());
55078
+ request.headers.Authorization = validateToken((await fs32.readFile(tokenFile)).toString());
55079
55079
  } else if (token) {
55080
55080
  request.headers.Authorization = validateToken(token);
55081
55081
  }
@@ -69174,7 +69174,7 @@ var require_truncate = __commonJS({
69174
69174
  var parse2 = require_parse();
69175
69175
  var constants2 = require_constants2();
69176
69176
  var SemVer = require_semver();
69177
- var truncate = (version, truncation, options) => {
69177
+ var truncate2 = (version, truncation, options) => {
69178
69178
  if (!constants2.RELEASE_TYPES.includes(truncation)) {
69179
69179
  return null;
69180
69180
  }
@@ -69204,7 +69204,7 @@ var require_truncate = __commonJS({
69204
69204
  var isPrerelease = (type) => {
69205
69205
  return type.startsWith("pre");
69206
69206
  };
69207
- module.exports = truncate;
69207
+ module.exports = truncate2;
69208
69208
  }
69209
69209
  });
69210
69210
 
@@ -70250,7 +70250,7 @@ var require_semver2 = __commonJS({
70250
70250
  var lte = require_lte();
70251
70251
  var cmp = require_cmp();
70252
70252
  var coerce2 = require_coerce();
70253
- var truncate = require_truncate();
70253
+ var truncate2 = require_truncate();
70254
70254
  var Comparator = require_comparator();
70255
70255
  var Range = require_range();
70256
70256
  var satisfies = require_satisfies();
@@ -70289,7 +70289,7 @@ var require_semver2 = __commonJS({
70289
70289
  lte,
70290
70290
  cmp,
70291
70291
  coerce: coerce2,
70292
- truncate,
70292
+ truncate: truncate2,
70293
70293
  Comparator,
70294
70294
  Range,
70295
70295
  satisfies,
@@ -73157,9 +73157,9 @@ var require_dist_node20 = __commonJS({
73157
73157
  // ../canopycms/src/worker/cms-worker.ts
73158
73158
  var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
73159
73159
  import { createHash as createHash2 } from "node:crypto";
73160
- import fs29 from "node:fs/promises";
73160
+ import fs30 from "node:fs/promises";
73161
73161
  import os from "node:os";
73162
- import path31 from "node:path";
73162
+ import path32 from "node:path";
73163
73163
 
73164
73164
  // ../canopycms/src/utils/debug.ts
73165
73165
  var envFlag = (name2) => typeof process !== "undefined" && process.env[name2] === "true";
@@ -74344,8 +74344,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
74344
74344
  function forEachLineWithContent(input, callback) {
74345
74345
  return toLinesWithContent(input, true).map((line) => callback(line));
74346
74346
  }
74347
- function folderExists(path34) {
74348
- return (0, import_file_exists.exists)(path34, import_file_exists.FOLDER);
74347
+ function folderExists(path35) {
74348
+ return (0, import_file_exists.exists)(path35, import_file_exists.FOLDER);
74349
74349
  }
74350
74350
  function append(target, item) {
74351
74351
  if (Array.isArray(target)) {
@@ -74747,8 +74747,8 @@ function checkIsRepoRootTask() {
74747
74747
  commands: commands9,
74748
74748
  format: "utf-8",
74749
74749
  onError,
74750
- parser(path34) {
74751
- return /^\.(git)?$/.test(path34.trim());
74750
+ parser(path35) {
74751
+ return /^\.(git)?$/.test(path35.trim());
74752
74752
  }
74753
74753
  };
74754
74754
  }
@@ -75182,11 +75182,11 @@ function parseGrep(grep) {
75182
75182
  const paths = /* @__PURE__ */ new Set();
75183
75183
  const results = {};
75184
75184
  forEachLineWithContent(grep, (input) => {
75185
- const [path34, line, preview] = input.split(NULL);
75186
- paths.add(path34);
75187
- (results[path34] = results[path34] || []).push({
75185
+ const [path35, line, preview] = input.split(NULL);
75186
+ paths.add(path35);
75187
+ (results[path35] = results[path35] || []).push({
75188
75188
  line: asNumber(line),
75189
- path: path34,
75189
+ path: path35,
75190
75190
  preview
75191
75191
  });
75192
75192
  });
@@ -75950,14 +75950,14 @@ var init_hash_object = __esm2({
75950
75950
  init_task();
75951
75951
  }
75952
75952
  });
75953
- function parseInit(bare, path34, text) {
75953
+ function parseInit(bare, path35, text) {
75954
75954
  const response = String(text).trim();
75955
75955
  let result;
75956
75956
  if (result = initResponseRegex.exec(response)) {
75957
- return new InitSummary(bare, path34, false, result[1]);
75957
+ return new InitSummary(bare, path35, false, result[1]);
75958
75958
  }
75959
75959
  if (result = reInitResponseRegex.exec(response)) {
75960
- return new InitSummary(bare, path34, true, result[1]);
75960
+ return new InitSummary(bare, path35, true, result[1]);
75961
75961
  }
75962
75962
  let gitDir = "";
75963
75963
  const tokens = response.split(" ");
@@ -75968,7 +75968,7 @@ function parseInit(bare, path34, text) {
75968
75968
  break;
75969
75969
  }
75970
75970
  }
75971
- return new InitSummary(bare, path34, /^re/i.test(response), gitDir);
75971
+ return new InitSummary(bare, path35, /^re/i.test(response), gitDir);
75972
75972
  }
75973
75973
  var InitSummary;
75974
75974
  var initResponseRegex;
@@ -75977,9 +75977,9 @@ var init_InitSummary = __esm2({
75977
75977
  "src/lib/responses/InitSummary.ts"() {
75978
75978
  "use strict";
75979
75979
  InitSummary = class {
75980
- constructor(bare, path34, existing, gitDir) {
75980
+ constructor(bare, path35, existing, gitDir) {
75981
75981
  this.bare = bare;
75982
- this.path = path34;
75982
+ this.path = path35;
75983
75983
  this.existing = existing;
75984
75984
  this.gitDir = gitDir;
75985
75985
  }
@@ -75991,7 +75991,7 @@ var init_InitSummary = __esm2({
75991
75991
  function hasBareCommand(command5) {
75992
75992
  return command5.includes(bareCommand);
75993
75993
  }
75994
- function initTask(bare = false, path34, customArgs) {
75994
+ function initTask(bare = false, path35, customArgs) {
75995
75995
  const commands9 = ["init", ...customArgs];
75996
75996
  if (bare && !hasBareCommand(commands9)) {
75997
75997
  commands9.splice(1, 0, bareCommand);
@@ -76000,7 +76000,7 @@ function initTask(bare = false, path34, customArgs) {
76000
76000
  commands: commands9,
76001
76001
  format: "utf-8",
76002
76002
  parser(text) {
76003
- return parseInit(commands9.includes("--bare"), path34, text);
76003
+ return parseInit(commands9.includes("--bare"), path35, text);
76004
76004
  }
76005
76005
  };
76006
76006
  }
@@ -76815,12 +76815,12 @@ var init_FileStatusSummary = __esm2({
76815
76815
  "use strict";
76816
76816
  fromPathRegex = /^(.+)\0(.+)$/;
76817
76817
  FileStatusSummary = class {
76818
- constructor(path34, index, working_dir) {
76819
- this.path = path34;
76818
+ constructor(path35, index, working_dir) {
76819
+ this.path = path35;
76820
76820
  this.index = index;
76821
76821
  this.working_dir = working_dir;
76822
76822
  if (index === "R" || working_dir === "R") {
76823
- const detail = fromPathRegex.exec(path34) || [null, path34, path34];
76823
+ const detail = fromPathRegex.exec(path35) || [null, path35, path35];
76824
76824
  this.from = detail[2] || "";
76825
76825
  this.path = detail[1] || "";
76826
76826
  }
@@ -76851,14 +76851,14 @@ function splitLine(result, lineStr) {
76851
76851
  default:
76852
76852
  return;
76853
76853
  }
76854
- function data3(index, workingDir, path34) {
76854
+ function data3(index, workingDir, path35) {
76855
76855
  const raw = `${index}${workingDir}`;
76856
76856
  const handler = parsers6.get(raw);
76857
76857
  if (handler) {
76858
- handler(result, path34);
76858
+ handler(result, path35);
76859
76859
  }
76860
76860
  if (raw !== "##" && raw !== "!!") {
76861
- result.files.push(new FileStatusSummary(path34, index, workingDir));
76861
+ result.files.push(new FileStatusSummary(path35, index, workingDir));
76862
76862
  }
76863
76863
  }
76864
76864
  }
@@ -77209,9 +77209,9 @@ var init_simple_git_api = __esm2({
77209
77209
  next
77210
77210
  );
77211
77211
  }
77212
- hashObject(path34, write) {
77212
+ hashObject(path35, write) {
77213
77213
  return this._runTask(
77214
- hashObjectTask(path34, write === true),
77214
+ hashObjectTask(path35, write === true),
77215
77215
  trailingFunctionArgument(arguments)
77216
77216
  );
77217
77217
  }
@@ -77565,8 +77565,8 @@ var init_branch = __esm2({
77565
77565
  }
77566
77566
  });
77567
77567
  function toPath(input) {
77568
- const path34 = input.trim().replace(/^["']|["']$/g, "");
77569
- return path34 && normalize(path34);
77568
+ const path35 = input.trim().replace(/^["']|["']$/g, "");
77569
+ return path35 && normalize(path35);
77570
77570
  }
77571
77571
  var parseCheckIgnore;
77572
77572
  var init_CheckIgnore = __esm2({
@@ -77851,8 +77851,8 @@ __export2(sub_module_exports, {
77851
77851
  subModuleTask: () => subModuleTask,
77852
77852
  updateSubModuleTask: () => updateSubModuleTask
77853
77853
  });
77854
- function addSubModuleTask(repo, path34) {
77855
- return subModuleTask(["add", repo, path34]);
77854
+ function addSubModuleTask(repo, path35) {
77855
+ return subModuleTask(["add", repo, path35]);
77856
77856
  }
77857
77857
  function initSubModuleTask(customArgs) {
77858
77858
  return subModuleTask(["init", ...customArgs]);
@@ -78166,8 +78166,8 @@ var require_git = __commonJS2({
78166
78166
  }
78167
78167
  return this._runTask(straightThroughStringTask2(command5, this._trimmed), next);
78168
78168
  };
78169
- Git2.prototype.submoduleAdd = function(repo, path34, then) {
78170
- return this._runTask(addSubModuleTask2(repo, path34), trailingFunctionArgument2(arguments));
78169
+ Git2.prototype.submoduleAdd = function(repo, path35, then) {
78170
+ return this._runTask(addSubModuleTask2(repo, path35), trailingFunctionArgument2(arguments));
78171
78171
  };
78172
78172
  Git2.prototype.submoduleUpdate = function(args, then) {
78173
78173
  return this._runTask(
@@ -78796,7 +78796,18 @@ function isValidContentId(id) {
78796
78796
  // ../canopycms/src/id.ts
78797
78797
  var isValidId = isValidContentId;
78798
78798
 
78799
+ // ../canopycms/src/utils/format.ts
78800
+ var getFormatExtension = (format3) => {
78801
+ if (format3 === "md") return ".md";
78802
+ if (format3 === "mdx") return ".mdx";
78803
+ if (format3 === "yaml") return ".yaml";
78804
+ return ".json";
78805
+ };
78806
+
78799
78807
  // ../canopycms/src/content-id-index.ts
78808
+ var ENTRY_EXTENSIONS = new Set(
78809
+ Object.keys({ md: true, mdx: true, json: true, yaml: true }).map((format3) => getFormatExtension(format3))
78810
+ );
78800
78811
  function extractIdFromFilename(filename) {
78801
78812
  if (filename.startsWith(".")) {
78802
78813
  return null;
@@ -79115,8 +79126,9 @@ var SPACE = 32;
79115
79126
  var DASH = 45;
79116
79127
  var PREREQUISITE_PREFIX_BYTES = 42;
79117
79128
  var BundleHeaderReader = class {
79118
- constructor(comments) {
79129
+ constructor(comments, maxBytes = BUNDLE_HEADER_MAX_BYTES) {
79119
79130
  this.comments = comments;
79131
+ this.maxBytes = maxBytes;
79120
79132
  this.section = "signature";
79121
79133
  this.sawCapability = false;
79122
79134
  this.prerequisites = [];
@@ -79206,9 +79218,10 @@ var BundleHeaderReader = class {
79206
79218
  this.checkBound();
79207
79219
  }
79208
79220
  checkBound() {
79209
- if (this.counted >= BUNDLE_HEADER_MAX_BYTES) {
79210
- throw new BundleHeaderError(`its header does not end within ${BUNDLE_HEADER_MAX_BYTES} bytes`);
79221
+ if (this.counted >= this.maxBytes) {
79222
+ throw new BundleHeaderError(`its header does not end within ${this.maxBytes} bytes`);
79211
79223
  }
79224
+ if (this.comments === "skip") return;
79212
79225
  const total = this.comments === "refuse" ? this.consumed : this.counted + this.keptBytes;
79213
79226
  if (total >= BUNDLE_HEADER_TOTAL_MAX_BYTES) {
79214
79227
  throw new BundleHeaderError(
@@ -79477,23 +79490,127 @@ var import_plugin_throttling = __toESM(require_dist_node13(), 1);
79477
79490
  init_error();
79478
79491
  init_logger();
79479
79492
 
79493
+ // ../canopycms/src/editor-url.ts
79494
+ function editorDeepLink(editorUrl, branch, entryPath) {
79495
+ const url = new URL(editorUrl);
79496
+ url.searchParams.set("branch", branch);
79497
+ if (entryPath !== void 0) url.searchParams.set("entry", entryPath);
79498
+ return url.href;
79499
+ }
79500
+
79480
79501
  // ../canopycms/src/submission-attribution.ts
79502
+ var MAX_NAME_LENGTH = 80;
79481
79503
  var PR_SECTION_START = "<!-- canopycms:submission:start -->";
79482
79504
  var PR_SECTION_END = "<!-- canopycms:submission:end -->";
79505
+ var PR_COMMENTS_START = "<!-- canopycms:comments:start -->";
79506
+ var PR_COMMENTS_END = "<!-- canopycms:comments:end -->";
79507
+ var INVISIBLE_OR_CONTROL = /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/gu;
79508
+ var STRUCTURAL = /[<>()`\\]/g;
79509
+ function truncate(value, max) {
79510
+ const chars2 = Array.from(value);
79511
+ return chars2.length > max ? `${chars2.slice(0, max - 1).join("")}\u2026` : value;
79512
+ }
79513
+ function cleanPath(raw) {
79514
+ const cleaned = raw.replace(INVISIBLE_OR_CONTROL, " ").replace(/[<>`]/g, "").trim();
79515
+ return cleaned ? truncate(cleaned, 300) : void 0;
79516
+ }
79517
+ function cleanText(raw, max) {
79518
+ if (raw === void 0) return void 0;
79519
+ const cleaned = raw.normalize("NFKC").replace(INVISIBLE_OR_CONTROL, " ").replace(STRUCTURAL, "").replace(/\s+/g, " ").trim();
79520
+ return cleaned ? truncate(cleaned, max) : void 0;
79521
+ }
79522
+ function codeSpan(value) {
79523
+ return `\`${value}\``;
79524
+ }
79525
+ function markdownHref(href) {
79526
+ return href.replace(
79527
+ /[()<>\\\s'"`]/g,
79528
+ (c11) => `%${c11.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`
79529
+ );
79530
+ }
79531
+ function editorLinker(branch, editorUrl) {
79532
+ return (entryPath) => branch && editorUrl ? markdownHref(editorDeepLink(editorUrl, branch, entryPath)) : void 0;
79533
+ }
79534
+ var MAX_LISTED_THREADS = 50;
79535
+ var MAX_EXCERPT_LENGTH = 80;
79536
+ var MAX_COMMENTS_LENGTH = 15e3;
79537
+ var LINE_BREAK = /\r\n?|\n|\u2028|\u2029/;
79538
+ function threadEntryPath(raw) {
79539
+ if (typeof raw !== "string" || cleanPath(raw) !== raw) return void 0;
79540
+ return raw.split("/").every((s7) => s7 !== "" && s7 !== "." && s7 !== "..") ? raw : void 0;
79541
+ }
79542
+ function threadLine(thread, link) {
79543
+ const entryPath = threadEntryPath(thread.entryPath);
79544
+ const field = thread.type === "field" && typeof thread.canopyPath === "string" ? cleanText(thread.canopyPath, MAX_NAME_LENGTH) : void 0;
79545
+ const where = entryPath ? `${codeSpan(entryPath)}${field ? ` \u203A ${codeSpan(field)}` : ""}` : thread.type === "branch" ? "Branch" : "An entry";
79546
+ const [first2] = Array.isArray(thread.comments) ? thread.comments : [];
79547
+ const text = typeof first2?.text === "string" ? first2.text.split(LINE_BREAK)[0] : void 0;
79548
+ const excerpt = cleanText(text, MAX_EXCERPT_LENGTH);
79549
+ const href = entryPath ? link(entryPath) : thread.type === "branch" ? link() : void 0;
79550
+ return [
79551
+ `- ${where}`,
79552
+ excerpt ? ` \u2014 ${codeSpan(excerpt)}` : "",
79553
+ href ? ` ([open in editor](${href}))` : ""
79554
+ ].join("");
79555
+ }
79556
+ function buildCommentsBlock(threads, branch, editorUrl) {
79557
+ if (threads === null) {
79558
+ return `${PR_COMMENTS_START}
79559
+ The editor comments could not be read.
79560
+ ${PR_COMMENTS_END}`;
79561
+ }
79562
+ const open = threads.filter((t6) => typeof t6 === "object" && t6 !== null && !t6.resolved).sort((a9, b10) => String(a9.createdAt).localeCompare(String(b10.createdAt)));
79563
+ let body;
79564
+ if (open.length > 0) {
79565
+ const listed = open.slice(0, MAX_LISTED_THREADS);
79566
+ const linker = editorLinker(branch, editorUrl);
79567
+ let lines = listed.map((t6) => threadLine(t6, linker));
79568
+ if (lines.join("\n").length > MAX_COMMENTS_LENGTH) {
79569
+ lines = listed.map((t6) => threadLine(t6, () => void 0));
79570
+ }
79571
+ let shown = lines.length;
79572
+ while (shown > 0 && lines.slice(0, shown).join("\n").length > MAX_COMMENTS_LENGTH) shown--;
79573
+ lines = lines.slice(0, shown);
79574
+ if (open.length > shown) lines.push(`- \u2026and ${open.length - shown} more`);
79575
+ const noun = open.length === 1 ? "comment thread" : "comment threads";
79576
+ body = `**${open.length} unresolved editor ${noun}**
79577
+
79578
+ ${lines.join("\n")}`;
79579
+ } else {
79580
+ body = threads.length > 0 ? "All editor comments resolved." : "No editor comments.";
79581
+ }
79582
+ return `${PR_COMMENTS_START}
79583
+ ${body}
79584
+ ${PR_COMMENTS_END}`;
79585
+ }
79483
79586
  function mergePrSection(existing, section) {
79484
79587
  const body = existing ?? "";
79485
- for (let end = body.indexOf(PR_SECTION_END); end >= 0; ) {
79486
- const start = body.lastIndexOf(PR_SECTION_START, end - PR_SECTION_START.length);
79487
- if (start >= 0) {
79488
- return body.slice(0, start) + section + body.slice(end + PR_SECTION_END.length);
79489
- }
79490
- end = body.indexOf(PR_SECTION_END, end + PR_SECTION_END.length);
79588
+ const found = findPrSection(body);
79589
+ if (found) {
79590
+ return body.slice(0, found.start) + section + body.slice(found.end + PR_SECTION_END.length);
79491
79591
  }
79492
79592
  const human = body.split(PR_SECTION_START).join("").split(PR_SECTION_END).join("").trimEnd();
79493
79593
  return human ? `${human}
79494
79594
 
79495
79595
  ${section}` : section;
79496
79596
  }
79597
+ function findPrSection(body) {
79598
+ for (let end = body.indexOf(PR_SECTION_END); end >= 0; ) {
79599
+ const start = body.lastIndexOf(PR_SECTION_START, end - PR_SECTION_START.length);
79600
+ if (start >= 0) return { start, end };
79601
+ end = body.indexOf(PR_SECTION_END, end + PR_SECTION_END.length);
79602
+ }
79603
+ return void 0;
79604
+ }
79605
+ function mergeCommentsBlock(existing, block) {
79606
+ const body = existing ?? "";
79607
+ const section = findPrSection(body);
79608
+ if (!section) return void 0;
79609
+ const start = body.indexOf(PR_COMMENTS_START, section.start);
79610
+ const end = start < 0 ? -1 : body.indexOf(PR_COMMENTS_END, start);
79611
+ if (start < 0 || end < 0 || end > section.end) return void 0;
79612
+ return body.slice(0, start) + block + body.slice(end + PR_COMMENTS_END.length);
79613
+ }
79497
79614
 
79498
79615
  // ../canopycms/src/github-service.ts
79499
79616
  var ThrottledOctokit = import_rest.Octokit.plugin(import_plugin_throttling.throttling);
@@ -81753,8 +81870,8 @@ var LocalGitHubGateway = class {
81753
81870
  }
81754
81871
  /**
81755
81872
  * One fetch serves every caller: concurrent callers join it, and its result is answered again
81756
- * for {@link AUTH_SNAPSHOT_REUSE_MS}. A fetch is a request per user, so a worker asking in a loop
81757
- * would otherwise hold the provider's API at its rate limit. The fetch runs apart from every
81873
+ * for {@link AUTH_SNAPSHOT_REUSE_MS}. A fetch pages the provider's whole user and membership lists,
81874
+ * so a worker asking in a loop would otherwise hold the provider's API at its rate limit. The fetch runs apart from every
81758
81875
  * caller's signal, which ends only that caller's wait, so a retry after a timed-out wait joins it.
81759
81876
  */
81760
81877
  async authSnapshot(signal) {
@@ -82351,12 +82468,30 @@ async function causeOf(proc, err, reason) {
82351
82468
  );
82352
82469
  return own !== null && getErrorMessage(own) !== reason ? own : err;
82353
82470
  }
82471
+ var FETCH_BUNDLE_HEADER_MAX_BYTES = 16 * 1024 * 1024;
82354
82472
  async function unbundle(ctx, gitDir, bundleId, signal) {
82355
82473
  const stream = await ctx.github().openBundle(bundleId);
82356
82474
  try {
82357
- await runGit(["bundle", "unbundle", "--progress", "--end-of-options", "-"], {
82475
+ const chunks = stream[Symbol.asyncIterator]();
82476
+ const read = await readHeader(stream, chunks, ctx.taskTimeoutMs, signal);
82477
+ const missing = await missingCommits(ctx, gitDir, read.header.prerequisites, signal);
82478
+ if (missing.length > 0) {
82479
+ throw new Error(`Refusing the bundle: its prerequisite ${missing[0]} is not a commit here`);
82480
+ }
82481
+ const { rest: first2 } = read;
82482
+ const pack = Readable2.from(
82483
+ (async function* () {
82484
+ if (first2.length > 0) yield first2;
82485
+ for (; ; ) {
82486
+ const rest = await chunks.next();
82487
+ if (rest.done) return;
82488
+ yield rest.value;
82489
+ }
82490
+ })()
82491
+ );
82492
+ await runGit(["index-pack", "-v", "--fix-thin", "--stdin"], {
82358
82493
  ...sharedRepoProcessOptions(gitDir, "bare"),
82359
- stdin: stream,
82494
+ stdin: pack,
82360
82495
  inactivityTimeoutMs: ctx.taskTimeoutMs,
82361
82496
  signal
82362
82497
  });
@@ -82364,6 +82499,40 @@ async function unbundle(ctx, gitDir, bundleId, signal) {
82364
82499
  stream.destroy();
82365
82500
  }
82366
82501
  }
82502
+ async function readHeader(stream, chunks, inactivityTimeoutMs, signal) {
82503
+ signal?.throwIfAborted();
82504
+ let timer;
82505
+ const onAbort = () => stream.destroy(new Error("Reading the bundle was aborted"));
82506
+ signal?.addEventListener("abort", onAbort, { once: true });
82507
+ try {
82508
+ const reader = new BundleHeaderReader("skip", FETCH_BUNDLE_HEADER_MAX_BYTES);
82509
+ for (; ; ) {
82510
+ clearTimeout(timer);
82511
+ timer = setTimeout(
82512
+ () => stream.destroy(new Error(`The bundle sent nothing for ${inactivityTimeoutMs}ms`)),
82513
+ inactivityTimeoutMs
82514
+ );
82515
+ const next = await chunks.next();
82516
+ if (next.done) throw new Error("The bundle ended before its header did");
82517
+ const read = reader.push(next.value);
82518
+ if (read !== null) return read;
82519
+ }
82520
+ } finally {
82521
+ clearTimeout(timer);
82522
+ signal?.removeEventListener("abort", onAbort);
82523
+ }
82524
+ }
82525
+ async function missingCommits(ctx, gitDir, ids, signal) {
82526
+ if (ids.length === 0) return [];
82527
+ const lines = (await runGit(["cat-file", "--batch-check=%(objectname) %(objecttype)", "--end-of-options"], {
82528
+ ...sharedRepoProcessOptions(gitDir, "bare"),
82529
+ stdin: ids.map((id) => `${id}
82530
+ `).join(""),
82531
+ inactivityTimeoutMs: ctx.taskTimeoutMs,
82532
+ signal
82533
+ })).split("\n");
82534
+ return ids.filter((id, i10) => lines[i10] !== `${id} commit`);
82535
+ }
82367
82536
  async function moveTrackingRefs(ctx, gitDir, refs, signal) {
82368
82537
  let needsOperator = null;
82369
82538
  const current = /* @__PURE__ */ new Map();
@@ -82491,7 +82660,7 @@ init_error();
82491
82660
  init_worker_status();
82492
82661
 
82493
82662
  // ../canopycms/src/version.ts
82494
- var CANOPYCMS_VERSION = "0.5.0";
82663
+ var CANOPYCMS_VERSION = "0.7.0";
82495
82664
 
82496
82665
  // ../canopycms/src/worker/schema-gate.ts
82497
82666
  import fs14 from "node:fs/promises";
@@ -82741,7 +82910,7 @@ async function decideBaseAdvance(input) {
82741
82910
  }
82742
82911
 
82743
82912
  // ../canopycms/src/worker/task-runner.ts
82744
- import fs19 from "node:fs/promises";
82913
+ import fs20 from "node:fs/promises";
82745
82914
 
82746
82915
  // ../canopycms/src/branch-metadata.ts
82747
82916
  import fs18 from "node:fs/promises";
@@ -82797,6 +82966,7 @@ var branchMetadataShape = {
82797
82966
  pullRequestNumber: external_exports.number().int().optional(),
82798
82967
  submittedAt: external_exports.string().optional(),
82799
82968
  pushedToGitHubAt: external_exports.string().optional(),
82969
+ editorUrl: external_exports.string().optional(),
82800
82970
  syncStatus: enumOf({
82801
82971
  synced: "synced",
82802
82972
  "pending-sync": "pending-sync",
@@ -83532,7 +83702,8 @@ var answers = {
83532
83702
  merged: external_exports.boolean(),
83533
83703
  merged_at: external_exports.string().max(64).nullable(),
83534
83704
  state: external_exports.enum(["open", "closed"]),
83535
- node_id: external_exports.string().max(256)
83705
+ node_id: external_exports.string().max(256),
83706
+ body: pullRequestText.body.nullable()
83536
83707
  }).strict(),
83537
83708
  createOrUpdatePullRequest: pullRequestRef.extend({ created: external_exports.boolean() }).strict(),
83538
83709
  convertPullRequestToDraft: empty,
@@ -83928,6 +84099,249 @@ async function hasPendingHistoryRewrite(ctx, branchName) {
83928
84099
 
83929
84100
  // ../canopycms/src/worker/task-runner.ts
83930
84101
  init_worker_status();
84102
+
84103
+ // ../canopycms/src/comment-store.ts
84104
+ import fs19 from "node:fs/promises";
84105
+ import path21 from "node:path";
84106
+ import { randomUUID as randomUUID3 } from "node:crypto";
84107
+ init_error();
84108
+ var CommentStoreConflictError = class extends Error {
84109
+ constructor() {
84110
+ super("Concurrent modification detected");
84111
+ this.name = "CommentStoreConflictError";
84112
+ }
84113
+ };
84114
+ function ownThread(data3, threadId) {
84115
+ return Object.prototype.hasOwnProperty.call(data3.threads, threadId) ? data3.threads[threadId] : void 0;
84116
+ }
84117
+ var CommentStore = class {
84118
+ constructor(branchRoot, options) {
84119
+ this.filePath = path21.join(path21.resolve(branchRoot), ".canopy-meta", "comments.json");
84120
+ this.settleMs = options?.settleMs;
84121
+ }
84122
+ /**
84123
+ * Every thread, for a summary that must not mistake a failed read for no comments: only a
84124
+ * missing file reads as none, and an unreadable or malformed one throws, unlike load().
84125
+ */
84126
+ async listThreadsStrict() {
84127
+ let content;
84128
+ try {
84129
+ content = await fs19.readFile(this.filePath, "utf-8");
84130
+ } catch (err) {
84131
+ if (isNotFoundError2(err)) return [];
84132
+ throw err;
84133
+ }
84134
+ const parsed = JSON.parse(content);
84135
+ const threads = typeof parsed === "object" && parsed !== null ? parsed.threads : void 0;
84136
+ if (typeof threads !== "object" || threads === null) {
84137
+ throw new Error("comments.json has no threads object");
84138
+ }
84139
+ return Object.values(threads);
84140
+ }
84141
+ /** Read-only load. */
84142
+ async load() {
84143
+ const { data: data3 } = await this.loadWithVersion();
84144
+ return data3;
84145
+ }
84146
+ /**
84147
+ * Load, with the version observed at load time. Mutators thread that version
84148
+ * through their load-modify-write cycle as a LOCAL value, never as instance
84149
+ * state, so concurrent cycles cannot clobber each other's expected version.
84150
+ */
84151
+ async loadWithVersion() {
84152
+ try {
84153
+ const content = await fs19.readFile(this.filePath, "utf-8");
84154
+ const parsed = JSON.parse(content);
84155
+ const version = parsed.version ?? 0;
84156
+ return { data: { ...parsed, version }, version };
84157
+ } catch {
84158
+ return {
84159
+ data: {
84160
+ schemaVersion: 1,
84161
+ version: 0,
84162
+ threads: {}
84163
+ },
84164
+ version: null
84165
+ };
84166
+ }
84167
+ }
84168
+ /**
84169
+ * Write comments.json via the shared OCC helper.
84170
+ *
84171
+ * Throws the helper's raw {@link OccWriteConflictError}, which is what the
84172
+ * surrounding {@link withOccRetry} in withMutation() recognizes and retries;
84173
+ * translation to the public `CommentStoreConflictError` happens at the
84174
+ * withMutation() boundary, once retries are exhausted.
84175
+ *
84176
+ * comments.json is written without a trailing newline (`writeOccJsonFile`'s
84177
+ * default), unlike branch.json.
84178
+ */
84179
+ async writeData(data3, expectedVersion) {
84180
+ await writeOccJsonFile(
84181
+ this.filePath,
84182
+ { ...data3 },
84183
+ {
84184
+ expectedVersion,
84185
+ settleMs: this.settleMs
84186
+ }
84187
+ );
84188
+ }
84189
+ /**
84190
+ * Run a mutate cycle (load -> modify -> write) under the full lock +
84191
+ * OCC-retry stack (class doc). A conflict surviving every retry surfaces as
84192
+ * `CommentStoreConflictError`.
84193
+ */
84194
+ async withMutation(operation3) {
84195
+ try {
84196
+ return await withLock(
84197
+ this.filePath,
84198
+ () => withOccFileLock(
84199
+ this.filePath,
84200
+ () => withOccRetry(async () => {
84201
+ const { data: data3, version } = await this.loadWithVersion();
84202
+ return operation3(data3, version);
84203
+ })
84204
+ )
84205
+ );
84206
+ } catch (err) {
84207
+ if (err instanceof OccWriteConflictError) {
84208
+ throw new CommentStoreConflictError();
84209
+ }
84210
+ throw err;
84211
+ }
84212
+ }
84213
+ async addComment(options) {
84214
+ const threadId = options.threadId || randomUUID3();
84215
+ const commentId = randomUUID3();
84216
+ return this.withMutation(async (data3, version) => {
84217
+ const timestamp2 = (/* @__PURE__ */ new Date()).toISOString();
84218
+ const comment = {
84219
+ id: commentId,
84220
+ threadId,
84221
+ userId: options.userId,
84222
+ timestamp: timestamp2,
84223
+ text: options.text
84224
+ };
84225
+ const existing = ownThread(data3, threadId);
84226
+ if (!existing) {
84227
+ data3.threads[threadId] = {
84228
+ id: threadId,
84229
+ comments: [comment],
84230
+ resolved: false,
84231
+ createdAt: timestamp2,
84232
+ type: options.type,
84233
+ authorId: options.userId,
84234
+ entryPath: options.entryPath,
84235
+ canopyPath: options.canopyPath,
84236
+ ...options.itemKeys?.length ? { itemKeys: options.itemKeys } : {}
84237
+ };
84238
+ } else {
84239
+ existing.comments.push(comment);
84240
+ }
84241
+ await this.writeData(data3, version);
84242
+ return { threadId, commentId };
84243
+ });
84244
+ }
84245
+ /**
84246
+ * Append a comment to an existing thread, or return null when `threadId` names none at write
84247
+ * time. Unlike {@link addComment}, a missing thread is never created, so a reply cannot plant
84248
+ * a thread under an id or entry path nobody checked.
84249
+ */
84250
+ async addReply(options) {
84251
+ const commentId = randomUUID3();
84252
+ return this.withMutation(async (data3, version) => {
84253
+ const thread = ownThread(data3, options.threadId);
84254
+ if (!thread) {
84255
+ return null;
84256
+ }
84257
+ thread.comments.push({
84258
+ id: commentId,
84259
+ threadId: options.threadId,
84260
+ userId: options.userId,
84261
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
84262
+ text: options.text
84263
+ });
84264
+ await this.writeData(data3, version);
84265
+ return { threadId: options.threadId, commentId };
84266
+ });
84267
+ }
84268
+ async resolveThread(threadId, userId) {
84269
+ return this.withMutation(async (data3, version) => {
84270
+ const thread = ownThread(data3, threadId);
84271
+ if (!thread) {
84272
+ return false;
84273
+ }
84274
+ thread.resolved = true;
84275
+ thread.resolvedBy = userId;
84276
+ thread.resolvedAt = (/* @__PURE__ */ new Date()).toISOString();
84277
+ await this.writeData(data3, version);
84278
+ return true;
84279
+ });
84280
+ }
84281
+ async listThreads(options) {
84282
+ const data3 = await this.load();
84283
+ const threads = Object.values(data3.threads);
84284
+ if (options?.includeResolved === false) {
84285
+ return threads.filter((t6) => !t6.resolved);
84286
+ }
84287
+ return threads;
84288
+ }
84289
+ async getThread(threadId) {
84290
+ const data3 = await this.load();
84291
+ return ownThread(data3, threadId) ?? null;
84292
+ }
84293
+ async deleteThread(threadId) {
84294
+ return this.withMutation(async (data3, version) => {
84295
+ if (!ownThread(data3, threadId)) {
84296
+ return false;
84297
+ }
84298
+ delete data3.threads[threadId];
84299
+ await this.writeData(data3, version);
84300
+ return true;
84301
+ });
84302
+ }
84303
+ /** Threads on one field. */
84304
+ async getThreadsForField(entryPath, canopyPath) {
84305
+ const data3 = await this.load();
84306
+ return Object.values(data3.threads).filter((t6) => t6.type === "field" && t6.entryPath === entryPath && t6.canopyPath === canopyPath).sort((a9, b10) => a9.createdAt.localeCompare(b10.createdAt));
84307
+ }
84308
+ /** Threads on one entry, excluding its field threads. */
84309
+ async getThreadsForEntry(entryPath) {
84310
+ const data3 = await this.load();
84311
+ return Object.values(data3.threads).filter((t6) => t6.type === "entry" && t6.entryPath === entryPath).sort((a9, b10) => a9.createdAt.localeCompare(b10.createdAt));
84312
+ }
84313
+ /** Branch-level threads. */
84314
+ async getBranchThreads() {
84315
+ const data3 = await this.load();
84316
+ return Object.values(data3.threads).filter((t6) => t6.type === "branch").sort((a9, b10) => a9.createdAt.localeCompare(b10.createdAt));
84317
+ }
84318
+ };
84319
+
84320
+ // ../canopycms/src/pr-comments.ts
84321
+ init_error();
84322
+ var SYNC_PR_COMMENTS_ACTION = "sync-pr-comments";
84323
+ async function renderPrCommentsBody(options) {
84324
+ const threads = await new CommentStore(options.branchRoot).listThreadsStrict();
84325
+ const next = mergeCommentsBlock(
84326
+ options.body,
84327
+ buildCommentsBlock(threads, options.branch, options.editorUrl)
84328
+ );
84329
+ return next === void 0 || next === options.body ? void 0 : next;
84330
+ }
84331
+ async function refreshCommentsBlock(options) {
84332
+ try {
84333
+ const threads = await new CommentStore(options.branchRoot).listThreadsStrict();
84334
+ const block = buildCommentsBlock(threads, options.branch, options.editorUrl);
84335
+ return mergeCommentsBlock(options.section, block) ?? options.section;
84336
+ } catch (err) {
84337
+ options.warn(
84338
+ `Could not re-read the editor comments of ${options.branch}; the PR gets the summary from submit time: ${getErrorMessage(err)}`
84339
+ );
84340
+ return options.section;
84341
+ }
84342
+ }
84343
+
84344
+ // ../canopycms/src/worker/task-runner.ts
83931
84345
  var PermanentTaskError = class extends Error {
83932
84346
  };
83933
84347
  var TaskAbortedForShutdownError = class extends Error {
@@ -84115,6 +84529,15 @@ async function executeTask(ctx, task, signal) {
84115
84529
  return { pushed: true };
84116
84530
  }
84117
84531
  await ctx.pushBranchToGitHub(branch, signal);
84532
+ const mergeSectionIntoBody = payload3.mergeSectionIntoBody === true;
84533
+ const queuedBody = optionalString(payload3, "body", "");
84534
+ const body = mergeSectionIntoBody ? await refreshCommentsBlock({
84535
+ branchRoot: ctx.branchWorkspacePath(branch),
84536
+ branch,
84537
+ editorUrl: typeof payload3.editorUrl === "string" ? payload3.editorUrl : void 0,
84538
+ section: queuedBody,
84539
+ warn: workerLogWarn
84540
+ }) : queuedBody;
84118
84541
  let result;
84119
84542
  try {
84120
84543
  result = await ctx.github().createOrUpdatePullRequest(
@@ -84122,10 +84545,10 @@ async function executeTask(ctx, task, signal) {
84122
84545
  head: branch,
84123
84546
  base,
84124
84547
  title: optionalString(payload3, "title", `Submit ${branch}`),
84125
- body: optionalString(payload3, "body", ""),
84548
+ body,
84126
84549
  // Content submits (api/github-sync.ts) set both.
84127
84550
  markReadyIfDraft: payload3.markReadyIfDraft === true,
84128
- mergeSectionIntoBody: payload3.mergeSectionIntoBody === true
84551
+ mergeSectionIntoBody
84129
84552
  },
84130
84553
  signal
84131
84554
  );
@@ -84194,12 +84617,42 @@ async function executeTask(ctx, task, signal) {
84194
84617
  workerLog(`Deleted GitHub branch ${branch}`);
84195
84618
  return { deleted: true };
84196
84619
  }
84620
+ case "sync-pr-comments": {
84621
+ const branch = requireString(payload3, "branch");
84622
+ const prNumber2 = requireNumber(payload3, "pullRequestNumber");
84623
+ const editorUrl = typeof payload3.editorUrl === "string" ? payload3.editorUrl : void 0;
84624
+ const branchPath = ctx.branchWorkspacePath(branch);
84625
+ let live = null;
84626
+ try {
84627
+ live = await BranchMetadataFileManager.loadOnly(branchPath);
84628
+ } catch (err) {
84629
+ if (!(err instanceof BranchMetadataCorruptError)) throw err;
84630
+ }
84631
+ if (live?.branch.pullRequestNumber !== prNumber2) {
84632
+ return { updated: false, skipped: "not-this-pr" };
84633
+ }
84634
+ const pr = await ctx.github().getPullRequest(prNumber2, signal);
84635
+ if (pr.state !== "open") return { updated: false, skipped: "not-open" };
84636
+ const body = await renderPrCommentsBody({
84637
+ branchRoot: branchPath,
84638
+ branch,
84639
+ editorUrl,
84640
+ body: pr.body
84641
+ }).catch((err) => {
84642
+ if (err instanceof SyntaxError) throw new PermanentTaskError(getErrorMessage(err));
84643
+ throw err;
84644
+ });
84645
+ if (body === void 0) return { updated: false, skipped: "unchanged" };
84646
+ await ctx.github().updatePullRequest(prNumber2, { body }, signal);
84647
+ workerLog(`Updated the editor comments on PR #${prNumber2} for ${branch}`);
84648
+ return { updated: true };
84649
+ }
84197
84650
  default:
84198
84651
  throw new PermanentTaskError(`Unknown task action: ${action}`);
84199
84652
  }
84200
84653
  }
84201
84654
  function metadataBranchOf(task) {
84202
- if (task.action === "delete-remote-branch") return null;
84655
+ if (task.action === "delete-remote-branch" || task.action === SYNC_PR_COMMENTS_ACTION) return null;
84203
84656
  return typeof task.payload.branch === "string" ? task.payload.branch : null;
84204
84657
  }
84205
84658
  async function updateBranchMetadata(ctx, task, result) {
@@ -84207,7 +84660,7 @@ async function updateBranchMetadata(ctx, task, result) {
84207
84660
  if (!branch) return;
84208
84661
  const branchPath = ctx.branchWorkspacePath(branch);
84209
84662
  try {
84210
- await fs19.stat(branchPath);
84663
+ await fs20.stat(branchPath);
84211
84664
  } catch {
84212
84665
  return;
84213
84666
  }
@@ -84243,7 +84696,7 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
84243
84696
  if (!branch) return;
84244
84697
  const branchPath = ctx.branchWorkspacePath(branch);
84245
84698
  try {
84246
- await fs19.stat(branchPath);
84699
+ await fs20.stat(branchPath);
84247
84700
  } catch {
84248
84701
  return;
84249
84702
  }
@@ -84355,7 +84808,7 @@ function logPushOutcome(ctx, branch, outcome, note) {
84355
84808
  async function recordPushedToGitHub(ctx, branchPath, branch) {
84356
84809
  if (isSettingsBranch(branch)) return;
84357
84810
  try {
84358
- await fs19.stat(branchPath);
84811
+ await fs20.stat(branchPath);
84359
84812
  } catch {
84360
84813
  return;
84361
84814
  }
@@ -84369,18 +84822,18 @@ async function recordPushedToGitHub(ctx, branchPath, branch) {
84369
84822
  }
84370
84823
 
84371
84824
  // ../canopycms/src/worker/rebase.ts
84372
- import fs21 from "node:fs/promises";
84373
- import path23 from "node:path";
84825
+ import fs22 from "node:fs/promises";
84826
+ import path24 from "node:path";
84374
84827
  init_normalize();
84375
84828
  init_types2();
84376
84829
 
84377
84830
  // ../canopycms/src/utils/content-write-lock.ts
84378
84831
  import { AsyncLocalStorage } from "node:async_hooks";
84379
- import path21 from "node:path";
84832
+ import path22 from "node:path";
84380
84833
  var META_DIR2 = ".canopy-meta";
84381
84834
  var CONTENT_WRITE_LOCK_NAME = "content-write.lock";
84382
84835
  function lockTargetDir(branchRoot) {
84383
- return path21.join(path21.resolve(branchRoot), META_DIR2);
84836
+ return path22.join(path22.resolve(branchRoot), META_DIR2);
84384
84837
  }
84385
84838
  var CONTENT_WRITE_LOCK_STALE_MS = 3e4;
84386
84839
  function tryAcquireContentWriteLock(branchRoot, onCompromised) {
@@ -84395,8 +84848,8 @@ function tryAcquireContentWriteLock(branchRoot, onCompromised) {
84395
84848
  var heldRoots = new AsyncLocalStorage();
84396
84849
 
84397
84850
  // ../canopycms/src/worker/provisioned-workspace.ts
84398
- import fs20 from "node:fs/promises";
84399
- import path22 from "node:path";
84851
+ import fs21 from "node:fs/promises";
84852
+ import path23 from "node:path";
84400
84853
  init_error();
84401
84854
  async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
84402
84855
  let release2;
@@ -84416,13 +84869,13 @@ async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
84416
84869
  if (isNodeError(err) && err.code === "ELOCKED") return { kind: "locked" };
84417
84870
  throw err;
84418
84871
  }
84419
- const root5 = path22.join(contentBranchesPath, dirName);
84872
+ const root5 = path23.join(contentBranchesPath, dirName);
84420
84873
  const [gitIsDir, hasMetadata] = await Promise.all([
84421
- fs20.stat(path22.join(root5, ".git")).then(
84874
+ fs21.stat(path23.join(root5, ".git")).then(
84422
84875
  (stat) => stat.isDirectory(),
84423
84876
  () => false
84424
84877
  ),
84425
- fs20.stat(path22.join(root5, BRANCH_META_DIR, BRANCH_META_FILE)).then(
84878
+ fs21.stat(path23.join(root5, BRANCH_META_DIR, BRANCH_META_FILE)).then(
84426
84879
  () => true,
84427
84880
  () => false
84428
84881
  )
@@ -84562,13 +85015,13 @@ async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLock
84562
85015
  function conflictFilesToContentIds(conflictedFiles, contentRoot) {
84563
85016
  const normalizedContentRoot = normalizeFilesystemPath(contentRoot);
84564
85017
  const conflictIds = [...new Set(conflictedFiles)].map((f9) => {
84565
- const fileId = extractIdFromFilename(path23.basename(f9));
85018
+ const fileId = extractIdFromFilename(path24.basename(f9));
84566
85019
  if (fileId) return fileId;
84567
- const parentDir = path23.basename(path23.dirname(f9));
85020
+ const parentDir = path24.basename(path24.dirname(f9));
84568
85021
  const dirId = extractIdFromFilename(parentDir);
84569
85022
  if (dirId) return dirId;
84570
- const parentPath = normalizeFilesystemPath(path23.dirname(f9));
84571
- if (path23.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
85023
+ const parentPath = normalizeFilesystemPath(path24.dirname(f9));
85024
+ if (path24.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
84572
85025
  return ROOT_COLLECTION_ID;
84573
85026
  }
84574
85027
  return null;
@@ -84604,7 +85057,7 @@ async function runRebaseCycle(ctx) {
84604
85057
  const failed = [];
84605
85058
  let branchDirs;
84606
85059
  try {
84607
- branchDirs = await fs21.readdir(ctx.contentBranchesPath);
85060
+ branchDirs = await fs22.readdir(ctx.contentBranchesPath);
84608
85061
  } catch {
84609
85062
  return { rebased, skippedDirty, skippedLocked, failed };
84610
85063
  }
@@ -84616,10 +85069,10 @@ async function runRebaseCycle(ctx) {
84616
85069
  if (branchDir.startsWith(".") || branchDir === "branches.json") {
84617
85070
  continue;
84618
85071
  }
84619
- const branchPath = path23.join(ctx.contentBranchesPath, branchDir);
84620
- const gitDir = path23.join(branchPath, ".git");
85072
+ const branchPath = path24.join(ctx.contentBranchesPath, branchDir);
85073
+ const gitDir = path24.join(branchPath, ".git");
84621
85074
  try {
84622
- const stat = await fs21.stat(gitDir);
85075
+ const stat = await fs22.stat(gitDir);
84623
85076
  if (!stat.isDirectory()) {
84624
85077
  workerLog(` Skipping ${branchDir}: .git is not a directory`);
84625
85078
  continue;
@@ -84858,16 +85311,16 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
84858
85311
  }
84859
85312
 
84860
85313
  // ../canopycms/src/worker/git-sync.ts
84861
- import fs26 from "node:fs/promises";
84862
- import path28 from "node:path";
85314
+ import fs27 from "node:fs/promises";
85315
+ import path29 from "node:path";
84863
85316
 
84864
85317
  // ../canopycms/src/branch-health.ts
84865
85318
  var ORPHAN_YOUTH_THRESHOLD_MS = 15 * 6e4;
84866
85319
 
84867
85320
  // ../canopycms/src/branch-provisioning.ts
84868
85321
  import { createHash, randomBytes as randomBytes2 } from "node:crypto";
84869
- import fs22 from "node:fs/promises";
84870
- import path24 from "node:path";
85322
+ import fs23 from "node:fs/promises";
85323
+ import path25 from "node:path";
84871
85324
  init_error();
84872
85325
  init_logger();
84873
85326
  var STAGING_MAX_AGE_MS = 20 * 6e4;
@@ -84899,7 +85352,7 @@ var DELETING_PREFIX = ".deleting-";
84899
85352
  var NO_GIT = { hasGitDir: false, configLock: false, hasIndex: false };
84900
85353
  async function listDir(dirPath) {
84901
85354
  try {
84902
- return await fs22.readdir(dirPath);
85355
+ return await fs23.readdir(dirPath);
84903
85356
  } catch (err) {
84904
85357
  if (isNodeError(err) && (err.code === "ENOENT" || err.code === "ENOTDIR")) return null;
84905
85358
  throw err;
@@ -84921,19 +85374,19 @@ function gitConfigRemoteUrls(text) {
84921
85374
  }
84922
85375
  function sameRemote(url, expected) {
84923
85376
  if (isNetworkRemoteUrl(url) || isNetworkRemoteUrl(expected)) return url === expected;
84924
- const local = (value) => path24.resolve(value.replace(/^file:\/\//i, ""));
85377
+ const local = (value) => path25.resolve(value.replace(/^file:\/\//i, ""));
84925
85378
  return local(url) === local(expected);
84926
85379
  }
84927
85380
  async function classifyFinalDir(dirPath, expectedRemoteUrl) {
84928
85381
  let stat;
84929
85382
  try {
84930
- stat = await fs22.lstat(dirPath);
85383
+ stat = await fs23.lstat(dirPath);
84931
85384
  } catch (err) {
84932
85385
  if (isNotFoundError2(err)) return { kind: "vacant" };
84933
85386
  throw err;
84934
85387
  }
84935
85388
  if (!stat.isDirectory()) return { kind: "residue", signature: NO_GIT };
84936
- const metaEntries = await listDir(path24.join(dirPath, BRANCH_META_DIR)) ?? [];
85389
+ const metaEntries = await listDir(path25.join(dirPath, BRANCH_META_DIR)) ?? [];
84937
85390
  if (metaEntries.includes(BRANCH_META_FILE)) {
84938
85391
  try {
84939
85392
  return await readBranchMetadataFile(dirPath) ? { kind: "live" } : { kind: "protected" };
@@ -84945,10 +85398,10 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
84945
85398
  if (metaEntries.some((name2) => name2.startsWith(`${BRANCH_META_FILE}.corrupt-`))) {
84946
85399
  return { kind: "protected" };
84947
85400
  }
84948
- const gitPath = path24.join(dirPath, ".git");
85401
+ const gitPath = path25.join(dirPath, ".git");
84949
85402
  let gitStat;
84950
85403
  try {
84951
- gitStat = await fs22.lstat(gitPath);
85404
+ gitStat = await fs23.lstat(gitPath);
84952
85405
  } catch (err) {
84953
85406
  if (isNotFoundError2(err)) return { kind: "residue", signature: NO_GIT };
84954
85407
  throw err;
@@ -84962,7 +85415,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
84962
85415
  };
84963
85416
  let config;
84964
85417
  try {
84965
- config = await fs22.readFile(path24.join(gitPath, "config"), "utf8");
85418
+ config = await fs23.readFile(path25.join(gitPath, "config"), "utf8");
84966
85419
  } catch {
84967
85420
  return { kind: "residue", signature };
84968
85421
  }
@@ -84971,7 +85424,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
84971
85424
  async function quietAgeMs(dirPath, now = Date.now()) {
84972
85425
  const mtimes = await Promise.all(
84973
85426
  ["", ".git", BRANCH_META_DIR].map(
84974
- (sub) => fs22.lstat(path24.join(dirPath, sub)).then(
85427
+ (sub) => fs23.lstat(path25.join(dirPath, sub)).then(
84975
85428
  (stat) => stat.mtimeMs,
84976
85429
  () => 0
84977
85430
  )
@@ -84980,25 +85433,25 @@ async function quietAgeMs(dirPath, now = Date.now()) {
84980
85433
  return now - Math.max(...mtimes);
84981
85434
  }
84982
85435
  async function quarantineResidueAt(baseRoot, dirName, options) {
84983
- const finalPath = path24.join(baseRoot, dirName);
85436
+ const finalPath = path25.join(baseRoot, dirName);
84984
85437
  let inode;
84985
85438
  try {
84986
- inode = (await fs22.lstat(finalPath)).ino;
85439
+ inode = (await fs23.lstat(finalPath)).ino;
84987
85440
  } catch (err) {
84988
85441
  if (isNotFoundError2(err)) return { kind: "vacant" };
84989
85442
  throw err;
84990
85443
  }
84991
85444
  const candidateName = stampedName(REPAIR_PREFIX, dirName, /* @__PURE__ */ new Date());
84992
- const candidate = path24.join(baseRoot, candidateName);
85445
+ const candidate = path25.join(baseRoot, candidateName);
84993
85446
  try {
84994
- await fs22.rename(finalPath, candidate);
85447
+ await fs23.rename(finalPath, candidate);
84995
85448
  } catch (err) {
84996
85449
  if (isNotFoundError2(err)) return { kind: "vacant" };
84997
85450
  throw err;
84998
85451
  }
84999
85452
  const moveBack = async (why) => {
85000
85453
  try {
85001
- await fs22.rename(candidate, finalPath);
85454
+ await fs23.rename(candidate, finalPath);
85002
85455
  } catch (err) {
85003
85456
  canopyLogError(
85004
85457
  `[canopy] Could not move '${dirName}' back from ${candidateName} after ${why}: ${getErrorMessage(err)}. The worker's sweep restores or trashes it.`
@@ -85013,7 +85466,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
85013
85466
  );
85014
85467
  if (reason === void 0 && state3.kind === "residue") {
85015
85468
  const trashName = stampedName(TRASH_PREFIX, dirName, /* @__PURE__ */ new Date());
85016
- await fs22.rename(candidate, path24.join(baseRoot, trashName));
85469
+ await fs23.rename(candidate, path25.join(baseRoot, trashName));
85017
85470
  const { hasGitDir, configLock, hasIndex } = state3.signature;
85018
85471
  canopyLogWarn(
85019
85472
  `[canopy] Quarantined unfinished branch directory '${dirName}' as ${trashName} (git=${hasGitDir} config.lock=${configLock} index=${hasIndex} quiet=${Math.round(quiet / 1e3)}s)`
@@ -85025,7 +85478,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
85025
85478
  }
85026
85479
  async function judgeQuarantineCandidate(candidate, inode, options) {
85027
85480
  const state3 = await classifyFinalDir(candidate, options.expectedRemoteUrl);
85028
- const moved = await fs22.lstat(candidate).catch(() => null);
85481
+ const moved = await fs23.lstat(candidate).catch(() => null);
85029
85482
  const quiet = await quietAgeMs(candidate, options.now);
85030
85483
  let reason;
85031
85484
  if (!moved || moved.ino !== inode) reason = "replaced";
@@ -85042,7 +85495,7 @@ async function sweepByAge(root5, rules, now) {
85042
85495
  const stamp = rule ? parseDirStamp(name2) : null;
85043
85496
  if (!rule || !stamp || now - stamp.getTime() < rule.maxAgeMs) continue;
85044
85497
  try {
85045
- await fs22.rm(path24.join(root5, name2), {
85498
+ await fs23.rm(path25.join(root5, name2), {
85046
85499
  recursive: true,
85047
85500
  force: true,
85048
85501
  maxRetries: 3,
@@ -85056,7 +85509,7 @@ async function sweepByAge(root5, rules, now) {
85056
85509
  return actions;
85057
85510
  }
85058
85511
  async function recoverRepairDir(baseRoot, name2) {
85059
- const repairPath = path24.join(baseRoot, name2);
85512
+ const repairPath = path25.join(baseRoot, name2);
85060
85513
  const meta = await readBranchMetadataFile(repairPath).catch(() => null);
85061
85514
  const dirName = meta ? sanitizeBranchName(meta.branch.name) : void 0;
85062
85515
  if (dirName && name2.startsWith(`${REPAIR_PREFIX}${shortDirName(dirName)}-`)) {
@@ -85070,9 +85523,9 @@ async function recoverRepairDir(baseRoot, name2) {
85070
85523
  throw err;
85071
85524
  }
85072
85525
  try {
85073
- const finalPath = path24.join(baseRoot, dirName);
85074
- if (await fs22.lstat(finalPath).catch(() => null) === null) {
85075
- await fs22.rename(repairPath, finalPath);
85526
+ const finalPath = path25.join(baseRoot, dirName);
85527
+ if (await fs23.lstat(finalPath).catch(() => null) === null) {
85528
+ await fs23.rename(repairPath, finalPath);
85076
85529
  return { name: name2, action: "restored", detail: dirName };
85077
85530
  }
85078
85531
  } finally {
@@ -85081,7 +85534,7 @@ async function recoverRepairDir(baseRoot, name2) {
85081
85534
  }
85082
85535
  }
85083
85536
  const trashName = `${TRASH_PREFIX}${name2.slice(REPAIR_PREFIX.length)}`;
85084
- await fs22.rename(repairPath, path24.join(baseRoot, trashName));
85537
+ await fs23.rename(repairPath, path25.join(baseRoot, trashName));
85085
85538
  return { name: name2, action: "trashed", detail: trashName };
85086
85539
  }
85087
85540
  async function sweepProvisioningLeftovers(baseRoot, workspaceRoot, now = Date.now()) {
@@ -85131,12 +85584,12 @@ async function maintainRemoteGit(gitDir) {
85131
85584
  }
85132
85585
 
85133
85586
  // ../canopycms/src/worker/sparse-cone.ts
85134
- import fs24 from "node:fs/promises";
85135
- import path26 from "node:path";
85587
+ import fs25 from "node:fs/promises";
85588
+ import path27 from "node:path";
85136
85589
 
85137
85590
  // ../canopycms/src/branch-sparse.ts
85138
- import fs23 from "node:fs/promises";
85139
- import path25 from "node:path";
85591
+ import fs24 from "node:fs/promises";
85592
+ import path26 from "node:path";
85140
85593
  init_error();
85141
85594
  function sameCone(a9, b10) {
85142
85595
  if (a9 === null || b10 === null) return a9 === b10;
@@ -85145,12 +85598,12 @@ function sameCone(a9, b10) {
85145
85598
  }
85146
85599
  var SPARSE_CONE_RECORD = ".sparse-cone.json";
85147
85600
  function isConeDir(dir) {
85148
- return typeof dir === "string" && dir.length > 0 && !path25.isAbsolute(dir) && !dir.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
85601
+ return typeof dir === "string" && dir.length > 0 && !path26.isAbsolute(dir) && !dir.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
85149
85602
  }
85150
85603
  async function readRecordedSparseCone(contentBranchesRoot) {
85151
85604
  let raw;
85152
85605
  try {
85153
- raw = await fs23.readFile(path25.join(contentBranchesRoot, SPARSE_CONE_RECORD), "utf8");
85606
+ raw = await fs24.readFile(path26.join(contentBranchesRoot, SPARSE_CONE_RECORD), "utf8");
85154
85607
  } catch (err) {
85155
85608
  if (isNodeError(err) && err.code === "ENOENT") return void 0;
85156
85609
  throw err;
@@ -85183,15 +85636,15 @@ async function reapplySparseCones(ctx) {
85183
85636
  if (!recorded) return report;
85184
85637
  let entries;
85185
85638
  try {
85186
- entries = await fs24.readdir(ctx.contentBranchesPath, { withFileTypes: true });
85639
+ entries = await fs25.readdir(ctx.contentBranchesPath, { withFileTypes: true });
85187
85640
  } catch (err) {
85188
85641
  if (isNodeError(err) && err.code === "ENOENT") return report;
85189
85642
  throw err;
85190
85643
  }
85191
85644
  const dirNames = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort();
85192
85645
  for (const dirName of dirNames) {
85193
- const branchPath = path26.join(ctx.contentBranchesPath, dirName);
85194
- const isClone = await fs24.stat(path26.join(branchPath, ".git")).then(
85646
+ const branchPath = path27.join(ctx.contentBranchesPath, dirName);
85647
+ const isClone = await fs25.stat(path27.join(branchPath, ".git")).then(
85195
85648
  (stat) => stat.isDirectory(),
85196
85649
  () => false
85197
85650
  );
@@ -85223,7 +85676,7 @@ async function reapplySparseCones(ctx) {
85223
85676
  return report;
85224
85677
  }
85225
85678
  async function reapplyOne(contentBranchesPath, dirName, git, target) {
85226
- const branchPath = path26.join(contentBranchesPath, dirName);
85679
+ const branchPath = path27.join(contentBranchesPath, dirName);
85227
85680
  const hold = await holdProvisionedWorkspace(contentBranchesPath, dirName);
85228
85681
  if (hold.kind !== "held") return "skipped";
85229
85682
  try {
@@ -85262,11 +85715,11 @@ async function reapplyOne(contentBranchesPath, dirName, git, target) {
85262
85715
  }
85263
85716
 
85264
85717
  // ../canopycms/src/worker/stale-mirror.ts
85265
- import fs25 from "node:fs/promises";
85266
- import path27 from "node:path";
85718
+ import fs26 from "node:fs/promises";
85719
+ import path28 from "node:path";
85267
85720
  init_error();
85268
85721
  async function readEditorWork(ctx) {
85269
- const workspaces = new Set(await fs25.readdir(ctx.contentBranchesPath).catch(() => []));
85722
+ const workspaces = new Set(await fs26.readdir(ctx.contentBranchesPath).catch(() => []));
85270
85723
  const queuedPushes = /* @__PURE__ */ new Set();
85271
85724
  for (const status of ["pending", "processing"]) {
85272
85725
  for (const task of await listTasks(ctx.taskDir, status, Number.POSITIVE_INFINITY)) {
@@ -85301,7 +85754,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
85301
85754
  throw err;
85302
85755
  }
85303
85756
  try {
85304
- if ((await fs25.readdir(ctx.contentBranchesPath)).includes(dirName)) {
85757
+ if ((await fs26.readdir(ctx.contentBranchesPath)).includes(dirName)) {
85305
85758
  return { kind: "kept", state: "workspace" };
85306
85759
  }
85307
85760
  const ref = `refs/heads/${name2}`;
@@ -85311,7 +85764,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
85311
85764
  );
85312
85765
  } catch (err) {
85313
85766
  const message2 = getErrorMessage(err);
85314
- if (lockHeld(message2) === path27.join(ctx.remoteGitPath, "packed-refs.lock")) {
85767
+ if (lockHeld(message2) === path28.join(ctx.remoteGitPath, "packed-refs.lock")) {
85315
85768
  return { kind: "packed-refs-locked" };
85316
85769
  }
85317
85770
  if (/cannot lock ref|Unable to create '[^']*\.lock': File exists/.test(message2)) {
@@ -85326,7 +85779,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
85326
85779
  }
85327
85780
  function lockHeld(message2) {
85328
85781
  const match2 = /Unable to create '([^']*)': File exists/.exec(message2);
85329
- return match2 ? path27.normalize(match2[1]) : null;
85782
+ return match2 ? path28.normalize(match2[1]) : null;
85330
85783
  }
85331
85784
  async function sharesHistory(git, head, baseTip) {
85332
85785
  try {
@@ -85698,7 +86151,7 @@ var reportedForeignDirs = /* @__PURE__ */ new Set();
85698
86151
  async function repairBranchDirResidue(ctx, now = Date.now()) {
85699
86152
  let entries;
85700
86153
  try {
85701
- entries = await fs26.readdir(ctx.contentBranchesPath, { withFileTypes: true });
86154
+ entries = await fs27.readdir(ctx.contentBranchesPath, { withFileTypes: true });
85702
86155
  } catch (err) {
85703
86156
  if (isNodeError(err) && err.code === "ENOENT") return;
85704
86157
  throw err;
@@ -85713,7 +86166,7 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
85713
86166
  }
85714
86167
  const leftovers = await sweepProvisioningLeftovers(
85715
86168
  ctx.contentBranchesPath,
85716
- path28.dirname(ctx.contentBranchesPath),
86169
+ path29.dirname(ctx.contentBranchesPath),
85717
86170
  now
85718
86171
  );
85719
86172
  for (const { name: name2, action, detail } of leftovers) {
@@ -85724,8 +86177,8 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
85724
86177
  }
85725
86178
  }
85726
86179
  async function repairOneBranchDir(ctx, dirName, now) {
85727
- const dirPath = path28.join(ctx.contentBranchesPath, dirName);
85728
- const hasMeta = await fs26.access(path28.join(dirPath, BRANCH_META_DIR, BRANCH_META_FILE)).then(
86180
+ const dirPath = path29.join(ctx.contentBranchesPath, dirName);
86181
+ const hasMeta = await fs27.access(path29.join(dirPath, BRANCH_META_DIR, BRANCH_META_FILE)).then(
85729
86182
  () => true,
85730
86183
  () => false
85731
86184
  );
@@ -85761,7 +86214,7 @@ async function repairOneBranchDir(ctx, dirName, now) {
85761
86214
  async function cleanupTrashedBranchDirs(ctx) {
85762
86215
  let entries;
85763
86216
  try {
85764
- entries = await fs26.readdir(ctx.contentBranchesPath);
86217
+ entries = await fs27.readdir(ctx.contentBranchesPath);
85765
86218
  } catch (err) {
85766
86219
  if (isNodeError(err) && err.code === "ENOENT") return 0;
85767
86220
  throw err;
@@ -85781,7 +86234,7 @@ async function cleanupTrashedBranchDirs(ctx) {
85781
86234
  }
85782
86235
  if (now - stampDate.getTime() < TRASH_RETENTION_MS) continue;
85783
86236
  try {
85784
- await fs26.rm(path28.join(ctx.contentBranchesPath, name2), {
86237
+ await fs27.rm(path29.join(ctx.contentBranchesPath, name2), {
85785
86238
  recursive: true,
85786
86239
  force: true,
85787
86240
  maxRetries: 3,
@@ -85799,7 +86252,7 @@ async function cleanupTrashedBranchDirs(ctx) {
85799
86252
  }
85800
86253
  var warnedTrackedCanopyState = /* @__PURE__ */ new Set();
85801
86254
  async function refreshBaseBranchWorkspace(ctx) {
85802
- const basePath37 = path28.join(ctx.contentBranchesPath, ctx.sanitizedBaseBranch);
86255
+ const basePath37 = path29.join(ctx.contentBranchesPath, ctx.sanitizedBaseBranch);
85803
86256
  let trackedCanopyMeta;
85804
86257
  let releaseProvisioning;
85805
86258
  let releaseContentLock;
@@ -85957,10 +86410,10 @@ async function refreshBaseBranchWorkspace(ctx) {
85957
86410
  // ../canopycms/src/worker/github-gateway-http.ts
85958
86411
  init_error();
85959
86412
  import { randomBytes as randomBytes3 } from "node:crypto";
85960
- import fs27 from "node:fs/promises";
86413
+ import fs28 from "node:fs/promises";
85961
86414
  import http from "node:http";
85962
86415
  import net from "node:net";
85963
- import path29 from "node:path";
86416
+ import path30 from "node:path";
85964
86417
  import { PassThrough } from "node:stream";
85965
86418
  import { pipeline as pipeline2 } from "node:stream/promises";
85966
86419
  var MAX_POLL_WAIT_MS = 25e3;
@@ -85983,11 +86436,11 @@ async function serveGitHubGateway(gateway, listen, options = {}) {
85983
86436
  if ("fd" in listen) {
85984
86437
  await listenOn(server, { fd: listen.fd });
85985
86438
  } else {
85986
- await assertPrivateDirectory(path29.dirname(listen.path));
86439
+ await assertPrivateDirectory(path30.dirname(listen.path));
85987
86440
  await removeStaleSocket(listen.path);
85988
86441
  await listenOn(server, { path: listen.path });
85989
86442
  try {
85990
- await fs27.chmod(listen.path, 384);
86443
+ await fs28.chmod(listen.path, 384);
85991
86444
  } catch (err) {
85992
86445
  await closeServer(server, handler);
85993
86446
  throw err;
@@ -86028,7 +86481,7 @@ function listenOn(server, options) {
86028
86481
  });
86029
86482
  }
86030
86483
  async function assertPrivateDirectory(dir) {
86031
- const stat = await fs27.lstat(dir);
86484
+ const stat = await fs28.lstat(dir);
86032
86485
  const uid = process.getuid?.();
86033
86486
  if (!stat.isDirectory() || uid !== void 0 && (stat.uid !== uid || (stat.mode & 63) !== 0)) {
86034
86487
  throw new Error(
@@ -86039,7 +86492,7 @@ async function assertPrivateDirectory(dir) {
86039
86492
  async function removeStaleSocket(socketPath) {
86040
86493
  let stat;
86041
86494
  try {
86042
- stat = await fs27.lstat(socketPath);
86495
+ stat = await fs28.lstat(socketPath);
86043
86496
  } catch (err) {
86044
86497
  if (isNodeError(err) && err.code === "ENOENT") return;
86045
86498
  throw err;
@@ -86055,7 +86508,7 @@ async function removeStaleSocket(socketPath) {
86055
86508
  `Refusing to serve the GitHub gateway at ${socketPath}: a gateway already serves there`
86056
86509
  );
86057
86510
  }
86058
- await fs27.unlink(socketPath);
86511
+ await fs28.unlink(socketPath);
86059
86512
  }
86060
86513
  function isServed(socketPath) {
86061
86514
  return new Promise((resolve) => {
@@ -86115,8 +86568,11 @@ var GatewayRequestHandler = class {
86115
86568
  return {};
86116
86569
  },
86117
86570
  getPullRequest: async ({ number }, signal) => {
86118
- const { merged, merged_at, state: state3, node_id } = await gateway.getPullRequest(number, signal);
86119
- return { merged, merged_at, state: state3, node_id };
86571
+ const { merged, merged_at, state: state3, node_id, body } = await gateway.getPullRequest(
86572
+ number,
86573
+ signal
86574
+ );
86575
+ return { merged, merged_at, state: state3, node_id, body: body ?? null };
86120
86576
  },
86121
86577
  createOrUpdatePullRequest: async (input, signal) => {
86122
86578
  const { number, url, created } = await gateway.createOrUpdatePullRequest(input, signal);
@@ -86783,9 +87239,9 @@ async function readAnswer(res, schema, signal) {
86783
87239
 
86784
87240
  // ../canopycms/src/worker/self-checks.ts
86785
87241
  init_error();
86786
- import fs28 from "node:fs/promises";
87242
+ import fs29 from "node:fs/promises";
86787
87243
  import net2 from "node:net";
86788
- import path30 from "node:path";
87244
+ import path31 from "node:path";
86789
87245
  var IMDS_HOST = "169.254.169.254";
86790
87246
  var IMDS_CONNECT_TIMEOUT_MS = 1e3;
86791
87247
  var NO_ROUTE_CODES = /* @__PURE__ */ new Set(["ENETUNREACH", "EAFNOSUPPORT"]);
@@ -86840,10 +87296,10 @@ async function imdsUnreachable(environment = {}) {
86840
87296
  };
86841
87297
  }
86842
87298
  async function onlyLoopback(environment = {}) {
86843
- const file = path30.join(rootOf(environment), "proc", "self", "net", "dev");
87299
+ const file = path31.join(rootOf(environment), "proc", "self", "net", "dev");
86844
87300
  let text;
86845
87301
  try {
86846
- text = await fs28.readFile(file, "utf8");
87302
+ text = await fs29.readFile(file, "utf8");
86847
87303
  } catch (err) {
86848
87304
  return {
86849
87305
  check: "network-namespace",
@@ -86860,21 +87316,21 @@ async function onlyLoopback(environment = {}) {
86860
87316
  };
86861
87317
  }
86862
87318
  async function procShowsOnlyOwnProcesses(environment = {}) {
86863
- const proc = path30.join(rootOf(environment), "proc");
87319
+ const proc = path31.join(rootOf(environment), "proc");
86864
87320
  const uid = environment.uid ?? process.getuid?.();
86865
87321
  if (uid === void 0) {
86866
87322
  return { check: "proc", ok: false, detail: "this platform has no process uid to compare" };
86867
87323
  }
86868
87324
  let entries;
86869
87325
  try {
86870
- entries = await fs28.readdir(proc);
87326
+ entries = await fs29.readdir(proc);
86871
87327
  } catch (err) {
86872
87328
  return { check: "proc", ok: false, detail: `cannot list ${proc}: ${getErrorMessage(err)}` };
86873
87329
  }
86874
87330
  const others = [];
86875
87331
  for (const entry of entries.filter((name2) => /^\d+$/.test(name2))) {
86876
87332
  try {
86877
- const stat = await fs28.stat(path30.join(proc, entry));
87333
+ const stat = await fs29.stat(path31.join(proc, entry));
86878
87334
  if (stat.uid !== uid) others.push(`${entry} (uid ${stat.uid})`);
86879
87335
  } catch (err) {
86880
87336
  if (!(isNodeError(err) && err.code === "ENOENT")) {
@@ -86890,9 +87346,9 @@ async function procShowsOnlyOwnProcesses(environment = {}) {
86890
87346
  };
86891
87347
  }
86892
87348
  async function homeIsEmpty(environment = {}) {
86893
- const home = path30.join(rootOf(environment), "home");
87349
+ const home = path31.join(rootOf(environment), "home");
86894
87350
  try {
86895
- const entries = await fs28.readdir(home);
87351
+ const entries = await fs29.readdir(home);
86896
87352
  return {
86897
87353
  check: "home",
86898
87354
  ok: entries.length === 0,
@@ -86915,9 +87371,9 @@ function noSecretsInEnv(environment = {}) {
86915
87371
  };
86916
87372
  }
86917
87373
  async function efsUnreadable(environment = {}) {
86918
- const efs = path30.join(rootOf(environment), "mnt", "efs");
87374
+ const efs = path31.join(rootOf(environment), "mnt", "efs");
86919
87375
  try {
86920
- await fs28.readdir(efs);
87376
+ await fs29.readdir(efs);
86921
87377
  } catch (err) {
86922
87378
  const code = isNodeError(err) ? err.code : void 0;
86923
87379
  const denied = code === "EACCES" || code === "EPERM";
@@ -86934,9 +87390,9 @@ async function efsUnreadable(environment = {}) {
86934
87390
  };
86935
87391
  }
86936
87392
  async function corePatternNotPiped(environment = {}) {
86937
- const file = path30.join(rootOf(environment), "proc", "sys", "kernel", "core_pattern");
87393
+ const file = path31.join(rootOf(environment), "proc", "sys", "kernel", "core_pattern");
86938
87394
  try {
86939
- const pattern = (await fs28.readFile(file, "utf8")).trim();
87395
+ const pattern = (await fs29.readFile(file, "utf8")).trim();
86940
87396
  const ok = !pattern.startsWith("|");
86941
87397
  return {
86942
87398
  check: "core-pattern",
@@ -86952,10 +87408,10 @@ async function corePatternNotPiped(environment = {}) {
86952
87408
  }
86953
87409
  }
86954
87410
  async function coreLimitZero(environment = {}) {
86955
- const file = path30.join(rootOf(environment), "proc", "self", "limits");
87411
+ const file = path31.join(rootOf(environment), "proc", "self", "limits");
86956
87412
  let text;
86957
87413
  try {
86958
- text = await fs28.readFile(file, "utf8");
87414
+ text = await fs29.readFile(file, "utf8");
86959
87415
  } catch (err) {
86960
87416
  return {
86961
87417
  check: "core-limit",
@@ -86977,11 +87433,11 @@ async function socketAccessIsOthers(environment = {}) {
86977
87433
  const uid = environment.uid ?? process.getuid?.();
86978
87434
  if (uid === void 0) return fail("this platform has no process uid to compare");
86979
87435
  const fd = environment.listenFd ?? 3;
86980
- const proc = path30.join(rootOf(environment), "proc", "self");
87436
+ const proc = path31.join(rootOf(environment), "proc", "self");
86981
87437
  let socketPath;
86982
87438
  try {
86983
- const inode = (await fs28.stat(path30.join(proc, "fd", String(fd)))).ino;
86984
- const table = await fs28.readFile(path30.join(proc, "net", "unix"), "utf8");
87439
+ const inode = (await fs29.stat(path31.join(proc, "fd", String(fd)))).ino;
87440
+ const table = await fs29.readFile(path31.join(proc, "net", "unix"), "utf8");
86985
87441
  for (const line of table.split("\n").slice(1)) {
86986
87442
  const fields = line.trim().split(/\s+/);
86987
87443
  if (fields[6] === String(inode) && fields.length > 7) socketPath = fields.slice(7).join(" ");
@@ -86989,12 +87445,12 @@ async function socketAccessIsOthers(environment = {}) {
86989
87445
  } catch (err) {
86990
87446
  return fail(`cannot find the socket on descriptor ${fd}: ${getErrorMessage(err)}`);
86991
87447
  }
86992
- if (socketPath === void 0 || !path30.isAbsolute(socketPath)) {
87448
+ if (socketPath === void 0 || !path31.isAbsolute(socketPath)) {
86993
87449
  return fail(`the socket on descriptor ${fd} is not bound to a path`);
86994
87450
  }
86995
87451
  let node;
86996
87452
  try {
86997
- node = await fs28.lstat(socketPath);
87453
+ node = await fs29.lstat(socketPath);
86998
87454
  } catch (err) {
86999
87455
  return fail(`cannot read ${socketPath}: ${getErrorMessage(err)}`);
87000
87456
  }
@@ -87041,8 +87497,8 @@ function tcpConnect(host, port, timeoutMs) {
87041
87497
 
87042
87498
  // ../canopycms/src/worker/cms-worker.ts
87043
87499
  function defaultStateDirectory(workspacePath) {
87044
- const key = createHash2("sha256").update(path31.resolve(workspacePath)).digest("hex").slice(0, 16);
87045
- return path31.join(os.tmpdir(), `canopycms-worker-${key}`);
87500
+ const key = createHash2("sha256").update(path32.resolve(workspacePath)).digest("hex").slice(0, 16);
87501
+ return path32.join(os.tmpdir(), `canopycms-worker-${key}`);
87046
87502
  }
87047
87503
  var MAX_REFS_LISTED = 20;
87048
87504
  var RemoteGitKeptError = class extends Error {
@@ -87090,7 +87546,7 @@ function lockWorkerTaskDir(taskDir, lockStaleMs, options) {
87090
87546
  const waitMs = options.waitMs ?? 0;
87091
87547
  const intervalMs = Math.max(250, Math.min(5e3, Math.floor(lockStaleMs / 4)));
87092
87548
  return import_proper_lockfile3.default.lock(taskDir, {
87093
- lockfilePath: path31.join(taskDir, ".worker-lock"),
87549
+ lockfilePath: path32.join(taskDir, ".worker-lock"),
87094
87550
  stale: lockStaleMs,
87095
87551
  onCompromised: options.onCompromised,
87096
87552
  ...waitMs > 0 ? {
@@ -87113,10 +87569,10 @@ async function readCarriedFields(taskDir) {
87113
87569
  };
87114
87570
  }
87115
87571
  async function recordWorkerStartupFailure(options) {
87116
- const taskDir = path31.join(options.workspacePath, ".tasks");
87572
+ const taskDir = path32.join(options.workspacePath, ".tasks");
87117
87573
  let release2;
87118
87574
  try {
87119
- await fs29.mkdir(taskDir, { recursive: true });
87575
+ await fs30.mkdir(taskDir, { recursive: true });
87120
87576
  release2 = await lockWorkerTaskDir(taskDir, 2 * (options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS), {
87121
87577
  onCompromised: (err) => workerLogError("Worker lock lost while recording a startup failure:", getErrorMessage(err))
87122
87578
  });
@@ -87172,17 +87628,17 @@ var CmsWorker = class {
87172
87628
  this.selfStopped = new Promise((resolve) => {
87173
87629
  this.settleSelfStopped = resolve;
87174
87630
  });
87175
- this.taskDir = path31.join(config.workspacePath, ".tasks");
87176
- this.remoteGitPath = path31.join(path31.resolve(config.workspacePath), "remote.git");
87177
- this.stateDirectory = path31.resolve(
87631
+ this.taskDir = path32.join(config.workspacePath, ".tasks");
87632
+ this.remoteGitPath = path32.join(path32.resolve(config.workspacePath), "remote.git");
87633
+ this.stateDirectory = path32.resolve(
87178
87634
  config.stateDirectory ?? defaultStateDirectory(config.workspacePath)
87179
87635
  );
87180
- this.contentBranchesPath = path31.join(config.workspacePath, "content-branches");
87636
+ this.contentBranchesPath = path32.join(config.workspacePath, "content-branches");
87181
87637
  if (config.baseBranch !== void 0) this.setBaseBranch(config.baseBranch);
87182
87638
  this.maxTasksPerCycle = config.maxTasksPerCycle ?? 10;
87183
87639
  this.taskTimeoutMs = config.taskTimeoutMs ?? DEFAULT_TASK_TIMEOUT;
87184
87640
  this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES2;
87185
- this.lockFilePath = path31.join(config.workspacePath, ".tasks", ".worker-lock");
87641
+ this.lockFilePath = path32.join(config.workspacePath, ".tasks", ".worker-lock");
87186
87642
  this.lockStaleMs = config.lockStaleMs ?? DEFAULT_LOCK_STALE_MS;
87187
87643
  this.drainDeadlineMs = config.drainDeadlineMs ?? DEFAULT_DRAIN_DEADLINE_MS;
87188
87644
  this.contentRoot = config.contentRoot ?? "content";
@@ -87476,7 +87932,7 @@ var CmsWorker = class {
87476
87932
  * is negligible at the default TTL; a badly wrong clock misjudges liveness.
87477
87933
  */
87478
87934
  async acquireLock() {
87479
- await fs29.mkdir(this.taskDir, { recursive: true });
87935
+ await fs30.mkdir(this.taskDir, { recursive: true });
87480
87936
  try {
87481
87937
  this.releaseLockFn = await lockWorkerTaskDir(this.taskDir, this.lockStaleMs, {
87482
87938
  onCompromised: (err) => {
@@ -87610,7 +88066,7 @@ var CmsWorker = class {
87610
88066
  );
87611
88067
  let remoteGitExists;
87612
88068
  try {
87613
- remoteGitExists = await fs29.stat(this.remoteGitPath).then(
88069
+ remoteGitExists = await fs30.stat(this.remoteGitPath).then(
87614
88070
  () => true,
87615
88071
  (err) => {
87616
88072
  if (isNodeError(err) && err.code === "ENOENT") return false;
@@ -87688,7 +88144,7 @@ var CmsWorker = class {
87688
88144
  );
87689
88145
  if (current === this.baseBranch) return;
87690
88146
  await sharedRepoGit(gitDir, "bare").raw(["symbolic-ref", "HEAD", ref]);
87691
- workerLog(`${path31.basename(gitDir)} HEAD now names the base branch '${this.baseBranch}'`);
88147
+ workerLog(`${path32.basename(gitDir)} HEAD now names the base branch '${this.baseBranch}'`);
87692
88148
  }
87693
88149
  /**
87694
88150
  * Whether the bare repo at `gitDir` has a local `refs/heads/<baseBranch>`.
@@ -87788,7 +88244,7 @@ var CmsWorker = class {
87788
88244
  async ensureRemoteGit() {
87789
88245
  let exists3;
87790
88246
  try {
87791
- await fs29.stat(this.remoteGitPath);
88247
+ await fs30.stat(this.remoteGitPath);
87792
88248
  exists3 = true;
87793
88249
  } catch {
87794
88250
  exists3 = false;
@@ -87808,7 +88264,7 @@ var CmsWorker = class {
87808
88264
  }
87809
88265
  workerLog("Initializing remote.git from GitHub...");
87810
88266
  const stagingPath = await this.seedRemoteGitStaging();
87811
- await fs29.rename(stagingPath, this.remoteGitPath);
88267
+ await fs30.rename(stagingPath, this.remoteGitPath);
87812
88268
  workerLog("remote.git initialized");
87813
88269
  }
87814
88270
  /**
@@ -87864,7 +88320,7 @@ var CmsWorker = class {
87864
88320
  if (err instanceof RemoteGitKeptError) throw err;
87865
88321
  throw notReplaced(redactCredentials(getErrorMessage(err)));
87866
88322
  });
87867
- const discardStaging = () => fs29.rm(stagingPath, { recursive: true, force: true });
88323
+ const discardStaging = () => fs30.rm(stagingPath, { recursive: true, force: true });
87868
88324
  let current;
87869
88325
  try {
87870
88326
  current = await listRemoteGitRefs(this.remoteGitPath);
@@ -87882,21 +88338,21 @@ var CmsWorker = class {
87882
88338
  }
87883
88339
  const replaced = `${this.remoteGitPath}.replaced-${Date.now()}`;
87884
88340
  try {
87885
- await fs29.rename(this.remoteGitPath, replaced);
88341
+ await fs30.rename(this.remoteGitPath, replaced);
87886
88342
  } catch (err) {
87887
88343
  await discardStaging();
87888
88344
  throw err;
87889
88345
  }
87890
88346
  try {
87891
- await fs29.rename(stagingPath, this.remoteGitPath);
88347
+ await fs30.rename(stagingPath, this.remoteGitPath);
87892
88348
  } catch (err) {
87893
- await fs29.rename(replaced, this.remoteGitPath);
88349
+ await fs30.rename(replaced, this.remoteGitPath);
87894
88350
  await discardStaging();
87895
88351
  throw err;
87896
88352
  }
87897
88353
  const after = await listRemoteGitRefs(replaced).catch(() => null);
87898
88354
  if (after !== null && sameRefs(refs, after)) {
87899
- await fs29.rm(replaced, { recursive: true, force: true, maxRetries: 3 }).catch((err) => {
88355
+ await fs30.rm(replaced, { recursive: true, force: true, maxRetries: 3 }).catch((err) => {
87900
88356
  workerLogWarn(
87901
88357
  `Could not remove the replaced remote.git at ${replaced}: ${getErrorMessage(err)}`
87902
88358
  );
@@ -87916,7 +88372,7 @@ var CmsWorker = class {
87916
88372
  */
87917
88373
  async seedRemoteGitStaging(check) {
87918
88374
  const stagingPath = `${this.remoteGitPath}.cloning`;
87919
- await fs29.rm(stagingPath, { recursive: true, force: true });
88375
+ await fs30.rm(stagingPath, { recursive: true, force: true });
87920
88376
  try {
87921
88377
  const githubBranches = await seedFromGitHub(
87922
88378
  this.transferContext(),
@@ -87932,7 +88388,7 @@ var CmsWorker = class {
87932
88388
  if (!(err instanceof RemoteGitKeptError)) {
87933
88389
  workerLogError(`remote.git seeding failed: ${redactCredentials(getErrorMessage(err))}`);
87934
88390
  }
87935
- await fs29.rm(stagingPath, { recursive: true, force: true });
88391
+ await fs30.rm(stagingPath, { recursive: true, force: true });
87936
88392
  if (err instanceof RemoteGitKeptError) throw err;
87937
88393
  if (err instanceof SharedRepoRefusalError) {
87938
88394
  throw new SharedRepoRefusalError(
@@ -88036,7 +88492,7 @@ var CmsWorker = class {
88036
88492
  * sanitized.
88037
88493
  */
88038
88494
  branchWorkspacePath(branchRefName) {
88039
- return path31.join(this.contentBranchesPath, sanitizeBranchName(branchRefName));
88495
+ return path32.join(this.contentBranchesPath, sanitizeBranchName(branchRefName));
88040
88496
  }
88041
88497
  /**
88042
88498
  * Test-only seam: awaited inside `rebaseActiveBranches()`'s conflict round,
@@ -88111,24 +88567,24 @@ var CmsWorker = class {
88111
88567
  };
88112
88568
 
88113
88569
  // ../canopycms/src/auth/file-based-auth-cache.ts
88114
- import fs30 from "node:fs/promises";
88115
- import path32 from "node:path";
88570
+ import fs31 from "node:fs/promises";
88571
+ import path33 from "node:path";
88116
88572
  var log5 = createDebugLogger({ prefix: "FileBasedAuthCache" });
88117
88573
  async function writeAuthCacheSnapshot(cachePath, files) {
88118
- await fs30.mkdir(cachePath, { recursive: true });
88574
+ await fs31.mkdir(cachePath, { recursive: true });
88119
88575
  const timestamp2 = Date.now();
88120
- const snapshotDir = path32.join(cachePath, `snapshot-${timestamp2}`);
88121
- await fs30.mkdir(snapshotDir, { recursive: true });
88576
+ const snapshotDir = path33.join(cachePath, `snapshot-${timestamp2}`);
88577
+ await fs31.mkdir(snapshotDir, { recursive: true });
88122
88578
  for (const [fileName, data3] of Object.entries(files)) {
88123
- const tmpPath = path32.join(snapshotDir, `${fileName}.tmp`);
88124
- const finalPath = path32.join(snapshotDir, fileName);
88125
- await fs30.writeFile(tmpPath, JSON.stringify(data3, null, 2), "utf-8");
88126
- await fs30.rename(tmpPath, finalPath);
88127
- }
88128
- const currentLink = path32.join(cachePath, "current");
88129
- const tmpLink = path32.join(cachePath, `current-${timestamp2}`);
88130
- await fs30.symlink(path32.basename(snapshotDir), tmpLink);
88131
- await fs30.rename(tmpLink, currentLink);
88579
+ const tmpPath = path33.join(snapshotDir, `${fileName}.tmp`);
88580
+ const finalPath = path33.join(snapshotDir, fileName);
88581
+ await fs31.writeFile(tmpPath, JSON.stringify(data3, null, 2), "utf-8");
88582
+ await fs31.rename(tmpPath, finalPath);
88583
+ }
88584
+ const currentLink = path33.join(cachePath, "current");
88585
+ const tmpLink = path33.join(cachePath, `current-${timestamp2}`);
88586
+ await fs31.symlink(path33.basename(snapshotDir), tmpLink);
88587
+ await fs31.rename(tmpLink, currentLink);
88132
88588
  await cleanupOldSnapshots(cachePath, 2);
88133
88589
  return snapshotDir;
88134
88590
  }
@@ -88145,14 +88601,14 @@ async function writeAuthSnapshot(cachePath, snapshot) {
88145
88601
  async function cleanupOldSnapshots(cachePath, keepCount) {
88146
88602
  let entries;
88147
88603
  try {
88148
- entries = await fs30.readdir(cachePath);
88604
+ entries = await fs31.readdir(cachePath);
88149
88605
  } catch {
88150
88606
  return;
88151
88607
  }
88152
88608
  const snapshots = entries.filter((e9) => e9.startsWith("snapshot-")).sort().reverse();
88153
88609
  for (const snapshot of snapshots.slice(keepCount)) {
88154
88610
  try {
88155
- await fs30.rm(path32.join(cachePath, snapshot), {
88611
+ await fs31.rm(path33.join(cachePath, snapshot), {
88156
88612
  recursive: true,
88157
88613
  force: true
88158
88614
  });
@@ -88403,7 +88859,7 @@ async function completeTerminationLifecycleAction(options = {}) {
88403
88859
 
88404
88860
  // worker/run.ts
88405
88861
  init_error();
88406
- import path33 from "node:path";
88862
+ import path34 from "node:path";
88407
88863
 
88408
88864
  // worker/github-app-auth.ts
88409
88865
  var import_auth_app = __toESM(require_dist_node20(), 1);
@@ -92788,10 +93244,10 @@ var SessionAPI = class extends AbstractAPI {
92788
93244
  */
92789
93245
  async getToken(sessionId, template, expiresInSeconds) {
92790
93246
  this.requireId(sessionId);
92791
- const path34 = template ? joinPaths(basePath29, sessionId, "tokens", template) : joinPaths(basePath29, sessionId, "tokens");
93247
+ const path35 = template ? joinPaths(basePath29, sessionId, "tokens", template) : joinPaths(basePath29, sessionId, "tokens");
92792
93248
  const requestOptions = {
92793
93249
  method: "POST",
92794
- path: path34
93250
+ path: path35
92795
93251
  };
92796
93252
  if (expiresInSeconds !== void 0) {
92797
93253
  requestOptions.bodyParams = { expires_in_seconds: expiresInSeconds };
@@ -95541,12 +95997,12 @@ function buildRequest(options) {
95541
95997
  userAgent = USER_AGENT2,
95542
95998
  skipApiVersionInUrl = false
95543
95999
  } = options;
95544
- const { path: path34, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
96000
+ const { path: path35, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
95545
96001
  const { deepSnakecaseBodyParamKeys = false } = opts || {};
95546
96002
  if (requireSecretKey) {
95547
96003
  assertValidSecretKey(secretKey);
95548
96004
  }
95549
- const url = skipApiVersionInUrl ? joinPaths(apiUrl, path34) : joinPaths(apiUrl, apiVersion, path34);
96005
+ const url = skipApiVersionInUrl ? joinPaths(apiUrl, path35) : joinPaths(apiUrl, apiVersion, path35);
95550
96006
  const finalUrl = new URL(url);
95551
96007
  if (queryParams) {
95552
96008
  const snakecasedQueryParams = snakecase_keys_default({ ...queryParams });
@@ -97747,6 +98203,20 @@ function toUserSearchResult(user) {
97747
98203
  function unwrapClerkResponse(response) {
97748
98204
  return Array.isArray(response) ? response : response.data;
97749
98205
  }
98206
+ function clerkErrorStatus(err) {
98207
+ if (typeof err !== "object" || err === null || !("status" in err)) return void 0;
98208
+ const status = err.status;
98209
+ return typeof status === "number" ? status : void 0;
98210
+ }
98211
+ function clerkErrorCode(err) {
98212
+ if (typeof err !== "object" || err === null || !("errors" in err)) return void 0;
98213
+ const { errors } = err;
98214
+ if (!Array.isArray(errors)) return void 0;
98215
+ const first2 = errors[0];
98216
+ if (typeof first2 !== "object" || first2 === null || !("code" in first2)) return void 0;
98217
+ const { code } = first2;
98218
+ return typeof code === "string" ? code : void 0;
98219
+ }
97750
98220
  async function fetchClerkSnapshot(options) {
97751
98221
  const {
97752
98222
  secretKey,
@@ -97762,50 +98232,62 @@ async function fetchClerkSnapshot(options) {
97762
98232
  limit: pageSize,
97763
98233
  offset
97764
98234
  });
97765
- const page = unwrapClerkResponse(usersResponse);
97766
- clerkUsers.push(...page);
97767
- if (page.length < pageSize) break;
98235
+ const page2 = unwrapClerkResponse(usersResponse);
98236
+ clerkUsers.push(...page2);
98237
+ if (page2.length < pageSize) break;
97768
98238
  offset += pageSize;
97769
98239
  }
97770
98240
  const users = clerkUsers.map(toUserSearchResult);
97771
- let groups = [];
97772
- const memberships = {};
97773
- if (useOrganizationsAsGroups) {
97774
- const clerkOrgs = [];
97775
- let orgOffset = 0;
97776
- const orgPageSize = 100;
97777
- while (true) {
97778
- const orgsResponse = await clerkClient.organizations.getOrganizationList({
97779
- limit: orgPageSize,
97780
- offset: orgOffset
97781
- });
97782
- const page = unwrapClerkResponse(orgsResponse);
97783
- clerkOrgs.push(...page);
97784
- if (page.length < orgPageSize) break;
97785
- orgOffset += orgPageSize;
97786
- }
97787
- groups = clerkOrgs.map((o8) => ({
97788
- id: o8.id,
97789
- name: o8.name,
97790
- memberCount: o8.membersCount ?? o8.members_count
97791
- }));
97792
- for (const user of clerkUsers) {
97793
- try {
97794
- const membershipResponse = await clerkClient.users.getOrganizationMembershipList({
97795
- userId: user.id
97796
- });
97797
- const userMemberships = unwrapClerkResponse(membershipResponse);
97798
- if (userMemberships.length > 0) {
97799
- memberships[user.id] = userMemberships.map((m7) => m7.organization.id);
97800
- }
97801
- } catch (err) {
97802
- warn(
97803
- `Failed to fetch memberships for user ${user.id}:`,
97804
- err instanceof Error ? err.message : err
97805
- );
97806
- }
97807
- }
98241
+ if (!useOrganizationsAsGroups) return { users, groups: [], memberships: {} };
98242
+ const fetchOrgPage = async (orgOffset) => unwrapClerkResponse(
98243
+ await clerkClient.organizations.getOrganizationList({
98244
+ limit: pageSize,
98245
+ offset: orgOffset
98246
+ })
98247
+ );
98248
+ let page;
98249
+ try {
98250
+ page = await fetchOrgPage(0);
98251
+ } catch (err) {
98252
+ if (clerkErrorStatus(err) !== 403) throw err;
98253
+ const code = clerkErrorCode(err);
98254
+ warn(
98255
+ `Clerk refused the Organizations API (403${code ? ` ${code}` : ""}): Organizations is probably disabled on this Clerk instance. Writing users with no groups; set clerkOrganizationsAsGroups: false (CANOPYCMS_CLERK_ORGANIZATIONS_AS_GROUPS=false) to stop asking.`
98256
+ );
98257
+ return { users, groups: [], memberships: {} };
98258
+ }
98259
+ const clerkOrgs = [...page];
98260
+ for (let orgOffset = pageSize; page.length === pageSize; orgOffset += pageSize) {
98261
+ page = await fetchOrgPage(orgOffset);
98262
+ clerkOrgs.push(...page);
98263
+ }
98264
+ const memberSets = /* @__PURE__ */ new Map();
98265
+ let membershipOffset = 0;
98266
+ while (true) {
98267
+ const membershipResponse = await clerkClient.organizations.getInstanceOrganizationMembershipList({
98268
+ limit: pageSize,
98269
+ offset: membershipOffset,
98270
+ orderBy: "+created_at"
98271
+ });
98272
+ const membershipPage = unwrapClerkResponse(membershipResponse);
98273
+ for (const membership of membershipPage) {
98274
+ const userId = membership.publicUserData?.userId;
98275
+ const orgId = membership.organization?.id;
98276
+ if (!userId || !orgId) continue;
98277
+ const orgIds = memberSets.get(userId) ?? /* @__PURE__ */ new Set();
98278
+ orgIds.add(orgId);
98279
+ memberSets.set(userId, orgIds);
98280
+ }
98281
+ if (membershipPage.length < pageSize) break;
98282
+ membershipOffset += pageSize;
97808
98283
  }
98284
+ const memberships = {};
98285
+ for (const [userId, orgIds] of memberSets) memberships[userId] = [...orgIds];
98286
+ const groups = clerkOrgs.map((o8) => ({
98287
+ id: o8.id,
98288
+ name: o8.name,
98289
+ memberCount: o8.membersCount ?? o8.members_count
98290
+ }));
97809
98291
  return { users, groups, memberships };
97810
98292
  }
97811
98293
  async function refreshClerkCache(options) {
@@ -97849,16 +98331,25 @@ async function withKeyReread(secret, key, log6, attempt) {
97849
98331
  return await attempt(rotated);
97850
98332
  }
97851
98333
  }
98334
+ var CLERK_ORGANIZATIONS_AS_GROUPS_ENV = "CANOPYCMS_CLERK_ORGANIZATIONS_AS_GROUPS";
98335
+ function parseClerkOrganizationsAsGroups(env2) {
98336
+ const value = env2[CLERK_ORGANIZATIONS_AS_GROUPS_ENV];
98337
+ if (value === void 0 || value === "" || value === "true") return true;
98338
+ if (value === "false") return false;
98339
+ throw new Error(
98340
+ `${CLERK_ORGANIZATIONS_AS_GROUPS_ENV} is ${JSON.stringify(value)}, but it must be true or false`
98341
+ );
98342
+ }
97852
98343
  function createClerkAuthCacheRefresher(options) {
97853
- const { secret, cachePath } = options;
98344
+ const { secret, cachePath, useOrganizationsAsGroups } = options;
97854
98345
  if (!secret.current()) return void 0;
97855
98346
  const refreshWith = async (secretKey) => {
97856
98347
  const result = await refreshClerkCache({
97857
98348
  secretKey,
97858
98349
  cachePath,
97859
- useOrganizationsAsGroups: true,
98350
+ useOrganizationsAsGroups,
97860
98351
  // Injected rather than left to default `console.warn`: this runs in the
97861
- // worker, so its per-user membership-fetch warning needs the ISO-8601
98352
+ // worker, so its Organizations-refused warning needs the ISO-8601
97862
98353
  // prefix like everything else here. canopycms is only a peer dependency
97863
98354
  // of canopycms-auth-clerk, so the join happens at this entrypoint, which
97864
98355
  // already imports both.
@@ -97873,10 +98364,10 @@ function createClerkAuthCacheRefresher(options) {
97873
98364
  };
97874
98365
  }
97875
98366
  function createClerkSnapshotFetcher(options) {
97876
- const { secret } = options;
98367
+ const { secret, useOrganizationsAsGroups } = options;
97877
98368
  const log6 = options.log ?? WORKER_LOG;
97878
98369
  if (!secret.current()) return void 0;
97879
- const fetchWith = (secretKey) => fetchClerkSnapshot({ secretKey, useOrganizationsAsGroups: true, warn: log6.warn });
98370
+ const fetchWith = (secretKey) => fetchClerkSnapshot({ secretKey, useOrganizationsAsGroups, warn: log6.warn });
97880
98371
  return async () => {
97881
98372
  const key = secret.current();
97882
98373
  if (!key) throw new Error("No Clerk secret key is configured");
@@ -98023,10 +98514,12 @@ async function buildSingleProcessWorker(deps, workspacePath) {
98023
98514
  env2,
98024
98515
  WORKER_STATE_DIRECTORY_MISSING
98025
98516
  );
98517
+ const useOrganizationsAsGroups = parseClerkOrganizationsAsGroups(env2);
98026
98518
  const { githubToken, githubTokenSecret, githubAppAuth, clerkSecret } = await readWorkerCredentials(env2, deps.getSecret);
98027
98519
  const refreshAuthCache = createClerkAuthCacheRefresher({
98028
98520
  secret: clerkSecret,
98029
- cachePath: path33.join(workspacePath, ".cache")
98521
+ cachePath: path34.join(workspacePath, ".cache"),
98522
+ useOrganizationsAsGroups
98030
98523
  });
98031
98524
  const worker = deps.createWorker({
98032
98525
  workspacePath,
@@ -98063,6 +98556,11 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
98063
98556
  `${PROTECTED_BRANCHES_ENV} is set on the worker unit, but beside the GitHub gateway it is the gateway's setting: move it to the gateway's environment (gateway.env)`
98064
98557
  );
98065
98558
  }
98559
+ if (env2[CLERK_ORGANIZATIONS_AS_GROUPS_ENV]) {
98560
+ throw new Error(
98561
+ `${CLERK_ORGANIZATIONS_AS_GROUPS_ENV} is set on the worker unit, but beside the GitHub gateway it is the gateway's setting: move it to the gateway's environment (gateway.env)`
98562
+ );
98563
+ }
98066
98564
  const gateway = deps.connectGateway(socketPath, { fetchInactivityMs: DEFAULT_TASK_TIMEOUT });
98067
98565
  let health;
98068
98566
  onGatewayWait(Date.now());
@@ -98082,7 +98580,7 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
98082
98580
  if (!health.ready) throw new Error("The GitHub gateway is not ready");
98083
98581
  const refreshAuthCache = health.clerkConfigured ? async () => {
98084
98582
  const snapshot = await gateway.authSnapshot();
98085
- await deps.writeAuthSnapshot(path33.join(workspacePath, ".cache"), snapshot);
98583
+ await deps.writeAuthSnapshot(path34.join(workspacePath, ".cache"), snapshot);
98086
98584
  workerLog(` ${snapshot.users.length} users, ${snapshot.groups.length} groups`);
98087
98585
  } : void 0;
98088
98586
  const worker = deps.createWorker({
@@ -98236,6 +98734,7 @@ async function buildGateway(deps, listen) {
98236
98734
  env2,
98237
98735
  GATEWAY_STATE_DIRECTORY_MISSING
98238
98736
  );
98737
+ const useOrganizationsAsGroups = parseClerkOrganizationsAsGroups(env2);
98239
98738
  const { githubToken, githubTokenSecret, githubAppAuth, clerkSecret } = await readWorkerCredentials(env2, deps.getSecret, {
98240
98739
  onAppPrivateKey: (privateKey) => {
98241
98740
  registerPrivateKey(privateKey);
@@ -98264,6 +98763,7 @@ async function buildGateway(deps, listen) {
98264
98763
  protectedBranches: parseProtectedBranches(env2),
98265
98764
  authSnapshot: createClerkSnapshotFetcher({
98266
98765
  secret: clerkSecret,
98766
+ useOrganizationsAsGroups,
98267
98767
  log: { warn: gatewayLogWarn, error: gatewayLogError }
98268
98768
  }),
98269
98769
  ...instanceOptions(deps)