@minnovate/shadow-publisher 0.11.5 → 0.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "git-publisher",
3
3
  "displayName": "Git Publisher",
4
- "version": "0.11.5",
4
+ "version": "0.11.8",
5
5
  "description": "Publish an app folder's Git history to the serverless Git publishing backend and keep it updated (\"publish my app\", \"update my app\", \"fetch the engineered version\").",
6
6
  "author": { "name": "git-publisher project" },
7
7
  "keywords": ["git", "publish", "deploy", "serverless"]
@@ -211,7 +211,7 @@ var PublisherError = class _PublisherError extends Error {
211
211
  }
212
212
  };
213
213
 
214
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/util.js
214
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
215
215
  function getEnumValues(entries) {
216
216
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
217
217
  const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -225,18 +225,22 @@ function jsonStringifyReplacer(_, value) {
225
225
  return value.toString();
226
226
  return value;
227
227
  }
228
- function cached(getter) {
229
- const set = false;
230
- return {
231
- get value() {
232
- if (!set) {
233
- const value = getter();
234
- Object.defineProperty(this, "value", { value });
235
- return value;
236
- }
237
- throw new Error("cached value already set");
228
+ var Cached = class {
229
+ constructor(getter) {
230
+ this._getter = getter;
231
+ this._value = void 0;
232
+ }
233
+ get value() {
234
+ const getter = this._getter;
235
+ if (getter !== void 0) {
236
+ this._value = getter();
237
+ this._getter = void 0;
238
238
  }
239
- };
239
+ return this._value;
240
+ }
241
+ };
242
+ function cached(getter) {
243
+ return new Cached(getter);
240
244
  }
241
245
  function nullish(input) {
242
246
  return input === null || input === void 0;
@@ -254,6 +258,56 @@ function assignProp(target, prop, value) {
254
258
  configurable: true
255
259
  });
256
260
  }
261
+ function rawShape(def) {
262
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
263
+ return desc?.get ? desc.get.raw : desc?.value;
264
+ }
265
+ function sourceShape(schema) {
266
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
267
+ }
268
+ function deferProp(target, key, getter) {
269
+ Object.defineProperty(target, key, {
270
+ get() {
271
+ const value = getter();
272
+ assignProp(this, key, value);
273
+ return value;
274
+ },
275
+ enumerable: true,
276
+ configurable: true
277
+ });
278
+ }
279
+ function putProp(target, key, value) {
280
+ if (key in target)
281
+ assignProp(target, key, value);
282
+ else
283
+ target[key] = value;
284
+ }
285
+ function mirrorShape(target, source, keys, wrap) {
286
+ const raw = sourceShape(source);
287
+ for (const key of keys) {
288
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
289
+ if (!desc.enumerable)
290
+ continue;
291
+ if (desc.get) {
292
+ deferProp(target, key, () => {
293
+ const value = source._zod.def.shape[key];
294
+ return wrap ? wrap(value, key) : value;
295
+ });
296
+ } else
297
+ putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
298
+ }
299
+ }
300
+ function mirrorProps(target, source) {
301
+ for (const key of Reflect.ownKeys(source)) {
302
+ const desc = Object.getOwnPropertyDescriptor(source, key);
303
+ if (!desc.enumerable)
304
+ continue;
305
+ if (desc.get)
306
+ deferProp(target, key, () => source[key]);
307
+ else
308
+ putProp(target, key, desc.value);
309
+ }
310
+ }
257
311
  function mergeDefs(...defs) {
258
312
  const mergedDescriptors = {};
259
313
  for (const def of defs) {
@@ -346,21 +400,20 @@ function extend(schema, shape) {
346
400
  const checks = schema._zod.def.checks;
347
401
  const hasChecks = checks && checks.length > 0;
348
402
  if (hasChecks) {
349
- const existingShape = schema._zod.def.shape;
403
+ const existingShape = sourceShape(schema);
350
404
  for (const key of Reflect.ownKeys(shape)) {
351
405
  if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
352
406
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
353
407
  }
354
408
  }
355
409
  }
356
- const def = mergeDefs(schema._zod.def, {
357
- get shape() {
358
- const _shape = { ...schema._zod.def.shape, ...shape };
359
- assignProp(this, "shape", _shape);
360
- return _shape;
361
- }
362
- });
363
- return clone(schema, def);
410
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
411
+ }
412
+ function extended(schema, shape) {
413
+ const newShape = {};
414
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
415
+ mirrorProps(newShape, shape);
416
+ return newShape;
364
417
  }
365
418
  function aborted(x, startIndex = 0) {
366
419
  if (x.aborted === true)
@@ -410,13 +463,18 @@ function finalizeIssue(iss, ctx, config2) {
410
463
  }
411
464
  const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
412
465
  const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
413
- const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
414
- rest.path ?? (rest.path = []);
415
- rest.message = message;
466
+ const full = {};
467
+ for (const k of Object.keys(iss)) {
468
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
469
+ continue;
470
+ full[k] = iss[k];
471
+ }
472
+ full.path ?? (full.path = []);
473
+ full.message = message;
416
474
  if (ctx?.reportInput) {
417
- rest.input = _input;
475
+ full.input = iss.input;
418
476
  }
419
- return rest;
477
+ return full;
420
478
  }
421
479
  var highSurrogate = /[\uD800-\uDBFF]/;
422
480
  function codePointLength(str3) {
@@ -563,7 +621,7 @@ function installLazyProp(inst, key, make, enumerable) {
563
621
  });
564
622
  }
565
623
 
566
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/core.js
624
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/core.js
567
625
  var _a;
568
626
  var _zodDesc = { value: void 0, enumerable: false };
569
627
  var _E = "captureStackTrace" in Error ? Error : null;
@@ -606,8 +664,7 @@ function $constructor(name, initializer2, proto, params) {
606
664
  } finally {
607
665
  _zodDesc.value = void 0;
608
666
  }
609
- }
610
- if (inst._zod.traits.has(name)) {
667
+ } else if (inst._zod.traits.has(name)) {
611
668
  return;
612
669
  }
613
670
  inst._zod.traits.add(name);
@@ -676,7 +733,7 @@ function config(newConfig) {
676
733
  return globalConfig;
677
734
  }
678
735
 
679
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/errors.js
736
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/errors.js
680
737
  function _getMessage() {
681
738
  const internals = this._zod;
682
739
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -691,16 +748,12 @@ var _messageDesc = {
691
748
  enumerable: true,
692
749
  configurable: true
693
750
  };
694
- var _zodDesc2 = { value: void 0, enumerable: false };
695
751
  var _issuesDesc = { value: void 0, enumerable: false };
696
752
  var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
697
753
  var initializer = (inst, def) => {
698
754
  inst.name = "$ZodError";
699
- _zodDesc2.value = inst._zod;
700
- Object.defineProperty(inst, "_zod", _zodDesc2);
701
755
  _issuesDesc.value = def;
702
756
  Object.defineProperty(inst, "issues", _issuesDesc);
703
- _zodDesc2.value = void 0;
704
757
  _issuesDesc.value = void 0;
705
758
  Object.defineProperty(inst, "message", _messageDesc);
706
759
  const proto = Object.getPrototypeOf(inst);
@@ -725,7 +778,7 @@ var $ZodRealError = $constructor("$ZodError", initializer, void 0, {
725
778
  Parent: Error
726
779
  });
727
780
 
728
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/parse.js
781
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/parse.js
729
782
  var _parse = (_Err) => {
730
783
  const fn = (schema, value, _ctx, _params) => {
731
784
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
@@ -765,25 +818,38 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
765
818
  if (result instanceof Promise) {
766
819
  throw new $ZodAsyncError();
767
820
  }
768
- return result.issues.length ? {
769
- success: false,
770
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
771
- } : { success: true, data: result.value };
821
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
772
822
  };
773
823
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
824
+ function failure(Err, issues, ctx) {
825
+ let error2;
826
+ return {
827
+ success: false,
828
+ get error() {
829
+ if (!error2) {
830
+ error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
831
+ issues = void 0;
832
+ ctx = void 0;
833
+ }
834
+ return error2;
835
+ },
836
+ set error(e) {
837
+ error2 = e;
838
+ issues = void 0;
839
+ ctx = void 0;
840
+ }
841
+ };
842
+ }
774
843
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
775
844
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
776
845
  let result = schema._zod.run({ value, issues: [] }, ctx);
777
846
  if (result instanceof Promise)
778
847
  result = await result;
779
- return result.issues.length ? {
780
- success: false,
781
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
782
- } : { success: true, data: result.value };
848
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
783
849
  };
784
850
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
785
851
 
786
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/regexes.js
852
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js
787
853
  var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
788
854
  var httpProtocol = /^https?$/;
789
855
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
@@ -807,15 +873,11 @@ function datetime(args) {
807
873
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
808
874
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
809
875
  }
810
- var string = (params) => {
811
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
812
- return new RegExp(`^${regex}$`);
813
- };
814
- var integer = /^-?\d+$/;
876
+ var anyString = /^[\s\S]{0,}$/;
815
877
  var number = /^-?\d+(?:\.\d+)?$/;
816
878
  var boolean = /^(?:true|false)$/i;
817
879
 
818
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/checks.js
880
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/checks.js
819
881
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
820
882
  var _a2;
821
883
  inst._zod ?? (inst._zod = {});
@@ -834,16 +896,6 @@ var numericOriginMap = {
834
896
  var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
835
897
  $ZodCheck.init(inst, def);
836
898
  const origin = numericOriginMap[typeof def.value];
837
- inst._zod.onattach.push((inst2) => {
838
- const bag = inst2._zod.bag;
839
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
840
- if (def.value > curr) {
841
- if (def.inclusive)
842
- bag.minimum = def.value;
843
- else
844
- bag.exclusiveMinimum = def.value;
845
- }
846
- });
847
899
  inst._zod.check = (payload) => {
848
900
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
849
901
  return;
@@ -865,14 +917,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
865
917
  const isInt = def.format?.includes("int");
866
918
  const origin = isInt ? "int" : "number";
867
919
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
868
- inst._zod.onattach.push((inst2) => {
869
- const bag = inst2._zod.bag;
870
- bag.format = def.format;
871
- bag.minimum = minimum;
872
- bag.maximum = maximum;
873
- if (isInt)
874
- bag.pattern = integer;
875
- });
876
920
  inst._zod.check = (payload) => {
877
921
  const input = payload.value;
878
922
  if (isInt) {
@@ -942,11 +986,6 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
942
986
  var _a2;
943
987
  $ZodCheck.init(inst, def);
944
988
  (_a2 = inst._zod.def).when ?? (_a2.when = _whenHasLength);
945
- inst._zod.onattach.push((inst2) => {
946
- const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
947
- if (def.maximum < curr)
948
- inst2._zod.bag.maximum = def.maximum;
949
- });
950
989
  inst._zod.check = (payload) => {
951
990
  const input = payload.value;
952
991
  const units = input.length;
@@ -969,11 +1008,6 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
969
1008
  var _a2;
970
1009
  $ZodCheck.init(inst, def);
971
1010
  (_a2 = inst._zod.def).when ?? (_a2.when = _whenHasLength);
972
- inst._zod.onattach.push((inst2) => {
973
- const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
974
- if (def.minimum > curr)
975
- inst2._zod.bag.minimum = def.minimum;
976
- });
977
1011
  inst._zod.check = (payload) => {
978
1012
  const input = payload.value;
979
1013
  const units = input.length;
@@ -995,14 +1029,6 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
995
1029
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
996
1030
  var _a2, _b;
997
1031
  $ZodCheck.init(inst, def);
998
- inst._zod.onattach.push((inst2) => {
999
- const bag = inst2._zod.bag;
1000
- bag.format = def.format;
1001
- if (def.pattern) {
1002
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1003
- bag.patterns.add(def.pattern);
1004
- }
1005
- });
1006
1032
  if (def.pattern)
1007
1033
  (_a2 = inst._zod).check ?? (_a2.check = (payload) => {
1008
1034
  def.pattern.lastIndex = 0;
@@ -1040,14 +1066,14 @@ var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def)
1040
1066
  };
1041
1067
  });
1042
1068
 
1043
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/versions.js
1069
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/versions.js
1044
1070
  var version = {
1045
1071
  major: 4,
1046
- minor: 5,
1047
- patch: 4
1072
+ minor: 6,
1073
+ patch: 5
1048
1074
  };
1049
1075
 
1050
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/schemas.js
1076
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/schemas.js
1051
1077
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1052
1078
  var _a2;
1053
1079
  inst ?? (inst = {});
@@ -1157,15 +1183,22 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1157
1183
  own(this, "~standard", value);
1158
1184
  }
1159
1185
  });
1160
- var toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
1186
+ var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1187
+ async function validateAsync(inst, value) {
1188
+ const ctx = { async: true };
1189
+ return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
1190
+ }
1161
1191
  function standardProps(inst) {
1162
1192
  return {
1163
1193
  validate: (value) => {
1194
+ const ctx = { async: false };
1164
1195
  try {
1165
- return toStandardResult(safeParse(inst, value));
1196
+ const r = inst._zod.run({ value, issues: [] }, ctx);
1197
+ if (!(r instanceof Promise))
1198
+ return toStandardResult(r, ctx);
1166
1199
  } catch (_) {
1167
- return safeParseAsync(inst, value).then(toStandardResult);
1168
1200
  }
1201
+ return validateAsync(inst, value);
1169
1202
  },
1170
1203
  vendor: "zod",
1171
1204
  version: 1
@@ -1173,7 +1206,7 @@ function standardProps(inst) {
1173
1206
  }
1174
1207
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1175
1208
  $ZodType.init(inst, def);
1176
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
1209
+ inst._zod.pattern = def.pattern ?? anyString;
1177
1210
  inst._zod.parse = (payload, _) => {
1178
1211
  if (def.coerce)
1179
1212
  try {
@@ -1197,11 +1230,32 @@ var $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, d
1197
1230
  });
1198
1231
  var URL_BAD_FORMAT = 1;
1199
1232
  var URL_UNPARSEABLE = 2;
1233
+ function canParseURL(input) {
1234
+ try {
1235
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function")
1236
+ return URL.canParse(input);
1237
+ new URL(input);
1238
+ return true;
1239
+ } catch {
1240
+ return false;
1241
+ }
1242
+ }
1243
+ function validateURL(trimmed, def) {
1244
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
1245
+ return canParseURL(trimmed) || URL_UNPARSEABLE;
1246
+ }
1247
+ return parseURLObject(trimmed, def);
1248
+ }
1200
1249
  function parseURLObject(trimmed, def) {
1201
1250
  if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
1202
1251
  return URL_BAD_FORMAT;
1203
1252
  }
1204
1253
  try {
1254
+ if (typeof URL !== "undefined") {
1255
+ const URLStatic = URL;
1256
+ if (typeof URLStatic.parse === "function")
1257
+ return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
1258
+ }
1205
1259
  return new URL(trimmed);
1206
1260
  } catch {
1207
1261
  return URL_UNPARSEABLE;
@@ -1224,7 +1278,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1224
1278
  inst._zod.check = (payload) => {
1225
1279
  try {
1226
1280
  const trimmed = payload.value.trim();
1227
- const url2 = parseURLObject(trimmed, def);
1281
+ const url2 = validateURL(trimmed, def);
1228
1282
  if (url2 === URL_BAD_FORMAT) {
1229
1283
  payload.issues.push({
1230
1284
  code: "invalid_format",
@@ -1246,6 +1300,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1246
1300
  });
1247
1301
  return;
1248
1302
  }
1303
+ if (url2 === true) {
1304
+ payload.value = stripTabAndNewline(trimmed);
1305
+ return;
1306
+ }
1249
1307
  if (def.hostname && !urlHostnameOk(url2, def.hostname)) {
1250
1308
  payload.issues.push({
1251
1309
  code: "invalid_format",
@@ -1284,12 +1342,6 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1284
1342
  var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1285
1343
  def.pattern ?? (def.pattern = datetime(def));
1286
1344
  $ZodStringFormat.init(inst, def);
1287
- if (def.local || def.precision === -1) {
1288
- inst._zod.bag.laxFormat = true;
1289
- inst._zod.onattach.push((s) => {
1290
- s._zod.bag.laxFormat = true;
1291
- });
1292
- }
1293
1345
  });
1294
1346
  var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1295
1347
  def.pattern ?? (def.pattern = date);
@@ -1305,7 +1357,7 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
1305
1357
  });
1306
1358
  var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1307
1359
  $ZodType.init(inst, def);
1308
- inst._zod.pattern = inst._zod.bag.pattern ?? number;
1360
+ inst._zod.pattern = number;
1309
1361
  inst._zod.parse = (payload, _ctx) => {
1310
1362
  if (def.coerce)
1311
1363
  try {
@@ -1379,6 +1431,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1379
1431
  }
1380
1432
  payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1381
1433
  const proms = [];
1434
+ const abortEarly = ctx?.abortEarly;
1382
1435
  for (let i = 0; i < input.length; i++) {
1383
1436
  const item = input[i];
1384
1437
  const result = def.element._zod.run({
@@ -1389,6 +1442,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1389
1442
  proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
1390
1443
  } else {
1391
1444
  handleArrayResult(result, payload, i);
1445
+ if (abortEarly && result.issues.length !== 0 && aborted(result))
1446
+ break;
1392
1447
  }
1393
1448
  }
1394
1449
  if (proms.length) {
@@ -1421,7 +1476,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
1421
1476
  return;
1422
1477
  }
1423
1478
  if (result.value === void 0) {
1424
- if (isPresent) {
1479
+ if (isPresent || optin === "defaulted" && !isOptionalOut) {
1425
1480
  final.value[key] = void 0;
1426
1481
  }
1427
1482
  } else {
@@ -1450,14 +1505,20 @@ function normalizeDef(def) {
1450
1505
  optionalKeys: new Set(okeys)
1451
1506
  };
1452
1507
  }
1453
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1508
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1454
1509
  const unrecognized = [];
1455
1510
  const keySet = def.keySet;
1456
1511
  const _catchall = def.catchall._zod;
1457
1512
  const t = _catchall.def.type;
1458
1513
  const optin = _catchall.optin;
1459
1514
  const optout = _catchall.optout;
1515
+ let seen = 0;
1460
1516
  for (const key in input) {
1517
+ if (abortEarly && payload.issues.length !== seen) {
1518
+ if (aborted(payload, seen))
1519
+ break;
1520
+ seen = payload.issues.length;
1521
+ }
1461
1522
  if (keySet.has(key))
1462
1523
  continue;
1463
1524
  if (key === "__proto__") {
@@ -1492,23 +1553,19 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1492
1553
  return payload;
1493
1554
  });
1494
1555
  }
1495
- var propShapes = /* @__PURE__ */ new WeakMap();
1496
1556
  var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1497
1557
  $ZodType.init(inst, def);
1498
1558
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
1499
- if (!desc?.get) {
1500
- const sh = def.shape;
1501
- propShapes.set(def, sh);
1502
- Object.defineProperty(def, "shape", {
1503
- get: () => {
1504
- const newSh = { ...sh };
1505
- Object.defineProperty(def, "shape", {
1506
- value: newSh
1507
- });
1508
- propShapes.set(def, newSh);
1509
- return newSh;
1510
- }
1511
- });
1559
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
1560
+ if (sh) {
1561
+ const get = () => {
1562
+ const newSh = { ...sh };
1563
+ Object.defineProperty(def, "shape", { value: newSh });
1564
+ get.raw = newSh;
1565
+ return newSh;
1566
+ };
1567
+ get.raw = sh;
1568
+ Object.defineProperty(def, "shape", { get });
1512
1569
  }
1513
1570
  const _normalized = cached(() => normalizeDef(def));
1514
1571
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -1548,7 +1605,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1548
1605
  payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1549
1606
  const proms = [];
1550
1607
  const shape = value.shape;
1608
+ const abortEarly = ctx?.abortEarly;
1609
+ let seen = payload.issues.length;
1551
1610
  for (const key of value.allKeys) {
1611
+ if (abortEarly && payload.issues.length !== seen) {
1612
+ if (aborted(payload, seen))
1613
+ break;
1614
+ seen = payload.issues.length;
1615
+ }
1552
1616
  if (key === "__proto__")
1553
1617
  continue;
1554
1618
  const el = shape[key];
@@ -1564,7 +1628,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1564
1628
  if (!catchall) {
1565
1629
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
1566
1630
  }
1567
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1631
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1568
1632
  };
1569
1633
  });
1570
1634
  function handleUnionResults(results, final, inst, ctx) {
@@ -1632,16 +1696,37 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1632
1696
  });
1633
1697
  };
1634
1698
  });
1699
+ function discriminatorMap(def) {
1700
+ const map = /* @__PURE__ */ new Map();
1701
+ for (const option of def.options) {
1702
+ const values = option._zod.propValues?.[def.discriminator];
1703
+ if (!values || values.size === 0)
1704
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1705
+ for (const value of values) {
1706
+ if (map.has(value)) {
1707
+ if (value !== void 0)
1708
+ throw new Error(`Duplicate discriminator value "${String(value)}"`);
1709
+ map.set(value, null);
1710
+ } else {
1711
+ map.set(value, option);
1712
+ }
1713
+ }
1714
+ }
1715
+ return map;
1716
+ }
1635
1717
  var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1636
1718
  def.inclusive = false;
1637
1719
  $ZodUnion.init(inst, def);
1638
1720
  const _super = inst._zod.parse;
1639
1721
  defineLazyInternal(inst, "propValues", (zod) => {
1640
1722
  const propValues = {};
1723
+ let undefinedCount = 0;
1641
1724
  for (const option of zod.def.options) {
1642
1725
  const pv = option._zod.propValues;
1643
1726
  if (!pv || Object.keys(pv).length === 0)
1644
1727
  throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1728
+ if (pv[zod.def.discriminator]?.has(void 0))
1729
+ undefinedCount++;
1645
1730
  for (const [k, v] of Object.entries(pv)) {
1646
1731
  if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1647
1732
  assignProp(propValues, k, /* @__PURE__ */ new Set());
@@ -1651,30 +1736,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
1651
1736
  }
1652
1737
  }
1653
1738
  }
1739
+ if (!zod.def.unionFallback && undefinedCount > 1)
1740
+ propValues[zod.def.discriminator]?.delete(void 0);
1654
1741
  return propValues;
1655
1742
  });
1656
1743
  def.options.forEach((option, i) => {
1657
- const propShape = propShapes.get(option._zod.def);
1744
+ const propShape = rawShape(option._zod.def);
1658
1745
  if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1659
1746
  throw new Error(`Invalid discriminated union option at index "${i}"`);
1660
1747
  }
1661
1748
  });
1662
- const disc = cached(() => {
1663
- const opts = def.options;
1664
- const map = /* @__PURE__ */ new Map();
1665
- for (const o of opts) {
1666
- const values = o._zod.propValues?.[def.discriminator];
1667
- if (!values || values.size === 0)
1668
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1669
- for (const v of values) {
1670
- if (map.has(v)) {
1671
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
1672
- }
1673
- map.set(v, o);
1674
- }
1675
- }
1676
- return map;
1677
- });
1749
+ const disc = cached(() => discriminatorMap(def));
1678
1750
  inst._zod.parse = (payload, ctx) => {
1679
1751
  const input = payload.value;
1680
1752
  if (!isObject(input)) {
@@ -1686,8 +1758,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
1686
1758
  });
1687
1759
  return payload;
1688
1760
  }
1689
- const opt = disc.value.get(input?.[def.discriminator]);
1690
- if (opt) {
1761
+ const value = input?.[def.discriminator];
1762
+ const opt = disc.value.get(value);
1763
+ if (opt && (value !== void 0 || ctx.direction !== "backward")) {
1691
1764
  return opt._zod.run(payload, ctx);
1692
1765
  }
1693
1766
  if (def.unionFallback || ctx.direction === "backward") {
@@ -1698,7 +1771,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
1698
1771
  errors: [],
1699
1772
  note: "No matching discriminator",
1700
1773
  discriminator: def.discriminator,
1701
- options: Array.from(disc.value.keys()),
1774
+ options: Array.from(disc.value.keys()).filter((value2) => disc.value.get(value2) !== null),
1702
1775
  input,
1703
1776
  path: [def.discriminator],
1704
1777
  inst
@@ -1866,8 +1939,10 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1866
1939
  const values = getEnumValues(def.entries);
1867
1940
  const valuesSet = new Set(values);
1868
1941
  inst._zod.values = valuesSet;
1869
- const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
1870
- inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
1942
+ defineLazyInternal(inst, "pattern", (zod) => {
1943
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
1944
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
1945
+ });
1871
1946
  inst._zod.parse = (payload, _ctx) => {
1872
1947
  const input = payload.value;
1873
1948
  if (valuesSet.has(input)) {
@@ -1886,7 +1961,10 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
1886
1961
  $ZodType.init(inst, def);
1887
1962
  const values = new Set(def.values);
1888
1963
  inst._zod.values = values;
1889
- inst._zod.pattern = new RegExp(def.values.length ? `^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
1964
+ defineLazyInternal(inst, "pattern", (zod) => {
1965
+ const vals = zod.def.values;
1966
+ return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
1967
+ });
1890
1968
  inst._zod.parse = (payload, _ctx) => {
1891
1969
  const input = payload.value;
1892
1970
  if (values.has(input)) {
@@ -2005,7 +2083,7 @@ function handleRefineResult(result, payload, input, inst) {
2005
2083
  }
2006
2084
  }
2007
2085
 
2008
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/locales/en.js
2086
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/en.js
2009
2087
  var error = () => {
2010
2088
  const Sizable = {
2011
2089
  string: { unit: "characters", verb: "to have" },
@@ -2045,7 +2123,9 @@ var error = () => {
2045
2123
  base64url: "base64url-encoded string",
2046
2124
  json_string: "JSON string",
2047
2125
  e164: "E.164 number",
2126
+ currency_code: "currency code",
2048
2127
  credit_card: "credit card number",
2128
+ iban: "IBAN",
2049
2129
  jwt: "JWT",
2050
2130
  template_literal: "input"
2051
2131
  };
@@ -2128,13 +2208,15 @@ function en_default() {
2128
2208
  };
2129
2209
  }
2130
2210
 
2131
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/api.js
2211
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/api.js
2212
+ function snapshotChecks(def) {
2213
+ if (def.checks)
2214
+ def.checks = [...def.checks];
2215
+ return def;
2216
+ }
2132
2217
  // @__NO_SIDE_EFFECTS__
2133
2218
  function _string(Class, params) {
2134
- return new Class({
2135
- type: "string",
2136
- ...normalizeParams(params)
2137
- });
2219
+ return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
2138
2220
  }
2139
2221
  // @__NO_SIDE_EFFECTS__
2140
2222
  function _url(Class, params) {
@@ -2272,7 +2354,7 @@ function _refine(Class, fn, _params) {
2272
2354
  return schema;
2273
2355
  }
2274
2356
 
2275
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/mini/schemas.js
2357
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/mini/schemas.js
2276
2358
  var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
2277
2359
  if (!inst._zod)
2278
2360
  throw new Error("Uninitialized schema in ZodMiniType.");
@@ -2437,7 +2519,7 @@ function record(keyType, valueType, params) {
2437
2519
  var ZodMiniEnum = /* @__PURE__ */ $constructor("ZodMiniEnum", (inst, def) => {
2438
2520
  $ZodEnum.init(inst, def);
2439
2521
  ZodMiniType.init(inst, def);
2440
- inst.options = Object.values(def.entries);
2522
+ inst.options = [...inst._zod.values];
2441
2523
  });
2442
2524
  // @__NO_SIDE_EFFECTS__
2443
2525
  function _enum(values, params) {
@@ -2505,7 +2587,7 @@ function refine(fn, _params = {}) {
2505
2587
  return _refine(ZodMiniCustom, fn, _params);
2506
2588
  }
2507
2589
 
2508
- // ../../../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/mini/iso.js
2590
+ // ../../../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/mini/iso.js
2509
2591
  var iso_exports = {};
2510
2592
  __export(iso_exports, {
2511
2593
  ZodMiniISODate: () => ZodMiniISODate,
@@ -3825,7 +3907,7 @@ async function packObjectsToFile(repoDir, extraArgs, stdinLines, opts) {
3825
3907
  }, timeoutMs);
3826
3908
  const onAbort = () => terminate(child);
3827
3909
  opts.signal?.addEventListener("abort", onAbort, { once: true });
3828
- let failure = null;
3910
+ let failure2 = null;
3829
3911
  try {
3830
3912
  const finished = new Promise((resolve3, reject) => out.on("finish", () => resolve3()).on("error", reject));
3831
3913
  finished.catch(() => void 0);
@@ -3858,7 +3940,7 @@ async function packObjectsToFile(repoDir, extraArgs, stdinLines, opts) {
3858
3940
  throw new PublisherError("GIT", `pack-objects failed: ${stderr.trim().split("\n").pop() ?? ""}`);
3859
3941
  }
3860
3942
  } catch (e) {
3861
- failure = e;
3943
+ failure2 = e;
3862
3944
  } finally {
3863
3945
  clearTimeout(timer);
3864
3946
  opts.signal?.removeEventListener("abort", onAbort);
@@ -3866,10 +3948,10 @@ async function packObjectsToFile(repoDir, extraArgs, stdinLines, opts) {
3866
3948
  }
3867
3949
  const cleanup = await reapChild(child, opts.groupObserver ? { observer: opts.groupObserver } : {});
3868
3950
  if (!reapSucceeded(cleanup)) {
3869
- throw cleanupFailure("git pack-objects", cleanup, failure ?? void 0);
3951
+ throw cleanupFailure("git pack-objects", cleanup, failure2 ?? void 0);
3870
3952
  }
3871
- if (failure) {
3872
- throw failure;
3953
+ if (failure2) {
3954
+ throw failure2;
3873
3955
  }
3874
3956
  const { sha256, size } = await sha256File(opts.outPath);
3875
3957
  return { sha256, size, objectCount: packObjectCount(await readPackHeader(opts.outPath)) };
@@ -4568,19 +4650,30 @@ var import_node_os2 = require("node:os");
4568
4650
  var import_node_path4 = require("node:path");
4569
4651
 
4570
4652
  // ../client/src/form-post.ts
4653
+ var FORM_POST_TIMEOUT_MS = 1e4;
4571
4654
  async function postForm(base, path, fields, fetchImpl = globalThis.fetch) {
4572
- let res;
4655
+ const bound = new AbortController();
4656
+ const timer = setTimeout(() => bound.abort(new DOMException("the request timed out", "TimeoutError")), FORM_POST_TIMEOUT_MS);
4573
4657
  try {
4574
- res = await fetchImpl(`${base}${path}`, {
4575
- method: "POST",
4576
- headers: { "content-type": "application/x-www-form-urlencoded" },
4577
- body: new URLSearchParams(fields).toString()
4578
- });
4579
- } catch (e) {
4580
- throw new PublisherError("UNAVAILABLE", `could not reach ${base}: ${e instanceof Error ? e.message : String(e)}`, { retryable: true, cause: e });
4658
+ let res;
4659
+ try {
4660
+ res = await fetchImpl(`${base}${path}`, {
4661
+ method: "POST",
4662
+ headers: { "content-type": "application/x-www-form-urlencoded" },
4663
+ body: new URLSearchParams(fields).toString(),
4664
+ signal: bound.signal
4665
+ });
4666
+ } catch (e) {
4667
+ throw new PublisherError("UNAVAILABLE", `could not reach ${base}: ${e instanceof Error ? e.message : String(e)}`, { retryable: true, cause: e });
4668
+ }
4669
+ const body = await res.json().catch(() => ({}));
4670
+ if (bound.signal.aborted) {
4671
+ throw new PublisherError("UNAVAILABLE", `could not reach ${base}: the request timed out`, { retryable: true });
4672
+ }
4673
+ return { status: res.status, body: typeof body === "object" && body !== null ? body : {} };
4674
+ } finally {
4675
+ clearTimeout(timer);
4581
4676
  }
4582
- const body = await res.json().catch(() => ({}));
4583
- return { status: res.status, body: typeof body === "object" && body !== null ? body : {} };
4584
4677
  }
4585
4678
 
4586
4679
  // ../client/src/credentials.ts
@@ -4949,6 +5042,25 @@ async function updateEntry(url2, change) {
4949
5042
  await writeCredentials(file);
4950
5043
  }
4951
5044
 
5045
+ // ../client/src/portal-refusal.ts
5046
+ function portalRefusalCode(body) {
5047
+ if (!isRecord(body)) {
5048
+ return null;
5049
+ }
5050
+ const error2 = body["error"];
5051
+ if (typeof error2 === "string") {
5052
+ return error2 === "" ? null : error2;
5053
+ }
5054
+ if (!isRecord(error2)) {
5055
+ return null;
5056
+ }
5057
+ const { code, message } = error2;
5058
+ return typeof code === "string" && code !== "" && typeof message === "string" ? code : null;
5059
+ }
5060
+ function isRecord(value) {
5061
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5062
+ }
5063
+
4952
5064
  // ../client/src/application.ts
4953
5065
  var APPLICATION_CREATION = "application-creation";
4954
5066
  var ATTEMPTS = 3;
@@ -4973,7 +5085,7 @@ async function createApplication(input, opts) {
4973
5085
  if (answer.status === 200 || answer.status === 201) {
4974
5086
  return read(answer.body, answer.status === 201);
4975
5087
  }
4976
- const code = isRecord(answer.body) && typeof answer.body["error"] === "string" ? answer.body["error"] : "";
5088
+ const code = portalRefusalCode(answer.body) ?? "";
4977
5089
  if (answer.status === 401) {
4978
5090
  throw new PublisherError("UNAUTHORIZED", 'the portal did not accept this credential; run "publisher login" again');
4979
5091
  }
@@ -4995,9 +5107,9 @@ async function createApplication(input, opts) {
4995
5107
  throw new PublisherError("UNAVAILABLE", `could not make the application: ${lastOutage}; run init again`, { retryable: true });
4996
5108
  }
4997
5109
  function read(body, created) {
4998
- const application = isRecord(body) ? body["application"] : void 0;
4999
- const repository = RepositoryInfo.safeParse(isRecord(body) ? body["repository"] : void 0);
5000
- if (!isRecord(application) || typeof application["appId"] !== "string" || !repository.success) {
5110
+ const application = isRecord2(body) ? body["application"] : void 0;
5111
+ const repository = RepositoryInfo.safeParse(isRecord2(body) ? body["repository"] : void 0);
5112
+ if (!isRecord2(application) || typeof application["appId"] !== "string" || !repository.success) {
5001
5113
  throw new PublisherError("UNAVAILABLE", "the portal answered with an application this version cannot read");
5002
5114
  }
5003
5115
  return { appId: application["appId"], created, repository: repository.data };
@@ -5020,7 +5132,7 @@ async function post(fetchImpl, url2, token, body) {
5020
5132
  return { status: 0, body: null };
5021
5133
  }
5022
5134
  }
5023
- function isRecord(value) {
5135
+ function isRecord2(value) {
5024
5136
  return typeof value === "object" && value !== null && !Array.isArray(value);
5025
5137
  }
5026
5138
 
@@ -5156,7 +5268,7 @@ var RUN_STAGES = ["received", "running", "deploying", "live"];
5156
5268
  var STAGE_WORDS = { received: "received", running: "checked", deploying: "going live", live: "live" };
5157
5269
  var STATES = ["pending", "in-progress", "done", "failed", "skipped"];
5158
5270
  function readStages(run) {
5159
- if (!isRecord2(run)) {
5271
+ if (!isRecord3(run)) {
5160
5272
  return { malformed: "a run that is not an object" };
5161
5273
  }
5162
5274
  if (!Object.hasOwn(run, "stages")) {
@@ -5169,7 +5281,7 @@ function readStages(run) {
5169
5281
  const out = [];
5170
5282
  for (const [index, entry] of stages.entries()) {
5171
5283
  const stage = RUN_STAGES[index];
5172
- if (!isRecord2(entry) || entry["stage"] !== stage) {
5284
+ if (!isRecord3(entry) || entry["stage"] !== stage) {
5173
5285
  return { malformed: `stage ${index + 1} is not ${stage}` };
5174
5286
  }
5175
5287
  const state = entry["state"];
@@ -5254,12 +5366,12 @@ async function followRun(input, opts) {
5254
5366
  opts.onStage?.(entry);
5255
5367
  moved = true;
5256
5368
  }
5257
- if (isRecord2(run.run) && run.run["status"] === "awaiting-approval") {
5369
+ if (isRecord3(run.run) && run.run["status"] === "awaiting-approval") {
5258
5370
  return { kind: "waiting", stages: read2.stages };
5259
5371
  }
5260
5372
  const end = ending(read2.stages);
5261
5373
  if (end !== null) {
5262
- const runId = isRecord2(run.run) && typeof run.run["runId"] === "string" ? run.run["runId"] : null;
5374
+ const runId = isRecord3(run.run) && typeof run.run["runId"] === "string" ? run.run["runId"] : null;
5263
5375
  return { kind: "settled", ending: end, failedAt: read2.stages.find((s) => s.state === "failed")?.word ?? null, stages: read2.stages, runId };
5264
5376
  }
5265
5377
  if (opts.untilChange === true && moved && answered) {
@@ -5278,7 +5390,7 @@ async function followRun(input, opts) {
5278
5390
  }
5279
5391
  }
5280
5392
  function soleRun(body) {
5281
- if (!isRecord2(body) || !Array.isArray(body["runs"])) {
5393
+ if (!isRecord3(body) || !Array.isArray(body["runs"])) {
5282
5394
  return { detail: "an answer with no list of runs" };
5283
5395
  }
5284
5396
  const runs = body["runs"];
@@ -5335,7 +5447,7 @@ async function confirmPortal(portal, endpoint, fetchImpl = fetch) {
5335
5447
  return null;
5336
5448
  }
5337
5449
  }
5338
- function isRecord2(value) {
5450
+ function isRecord3(value) {
5339
5451
  return typeof value === "object" && value !== null && !Array.isArray(value);
5340
5452
  }
5341
5453
 
@@ -5372,8 +5484,7 @@ async function call(input, opts, body) {
5372
5484
  return { kind: "moved-on" };
5373
5485
  }
5374
5486
  if (answer.status === 404) {
5375
- const code = isRecord3(answer.body) ? answer.body["error"] : void 0;
5376
- return code === "no-such-application" ? { kind: "no-application" } : { kind: "unavailable", detail: "the portal does not serve this address" };
5487
+ return portalRefusalCode(answer.body) === "no-such-application" ? { kind: "no-application" } : { kind: "unavailable", detail: "the portal does not serve this address" };
5377
5488
  }
5378
5489
  if (answer.status === 200) {
5379
5490
  const view = readView(answer.body);
@@ -5383,7 +5494,7 @@ async function call(input, opts, body) {
5383
5494
  }
5384
5495
  }
5385
5496
  function readView(body) {
5386
- if (!isRecord3(body)) {
5497
+ if (!isRecord4(body)) {
5387
5498
  return { detail: "an answer that is not a preparation" };
5388
5499
  }
5389
5500
  const { id, revision, status, message, questions, publication } = body;
@@ -5404,12 +5515,12 @@ function readView(body) {
5404
5515
  }
5405
5516
  const read2 = [];
5406
5517
  for (const q of questions) {
5407
- if (!isRecord3(q) || typeof q["id"] !== "string" || typeof q["text"] !== "string" || !Array.isArray(q["options"]) || q["options"].length === 0) {
5518
+ if (!isRecord4(q) || typeof q["id"] !== "string" || typeof q["text"] !== "string" || !Array.isArray(q["options"]) || q["options"].length === 0) {
5408
5519
  return { detail: "a question that cannot be answered" };
5409
5520
  }
5410
5521
  const options = [];
5411
5522
  for (const o of q["options"]) {
5412
- if (!isRecord3(o) || typeof o["value"] !== "string" || typeof o["label"] !== "string") {
5523
+ if (!isRecord4(o) || typeof o["value"] !== "string" || typeof o["label"] !== "string") {
5413
5524
  return { detail: "a question with an unreadable option" };
5414
5525
  }
5415
5526
  options.push({ value: o["value"], label: o["label"] });
@@ -5417,7 +5528,7 @@ function readView(body) {
5417
5528
  read2.push({ id: q["id"], text: q["text"], options });
5418
5529
  }
5419
5530
  let pub = null;
5420
- if (isRecord3(publication) && typeof publication["status"] === "string" && typeof publication["message"] === "string") {
5531
+ if (isRecord4(publication) && typeof publication["status"] === "string" && typeof publication["message"] === "string") {
5421
5532
  pub = { status: publication["status"], message: publication["message"], ...typeof publication["url"] === "string" ? { url: publication["url"] } : {} };
5422
5533
  }
5423
5534
  return { id, revision, status, message, questions: read2, publication: pub, findings: readFindings(body["findings"]) };
@@ -5432,7 +5543,7 @@ function readFindings(value) {
5432
5543
  if (out.length === MAX_FINDINGS) {
5433
5544
  break;
5434
5545
  }
5435
- if (!isRecord3(f)) {
5546
+ if (!isRecord4(f)) {
5436
5547
  continue;
5437
5548
  }
5438
5549
  const kind = text(f["kind"]);
@@ -5472,7 +5583,7 @@ async function ask2(fetchImpl, url2, token, body) {
5472
5583
  return { status: 0, body: null };
5473
5584
  }
5474
5585
  }
5475
- function isRecord3(value) {
5586
+ function isRecord4(value) {
5476
5587
  return typeof value === "object" && value !== null && !Array.isArray(value);
5477
5588
  }
5478
5589
 
@@ -6464,21 +6575,28 @@ function createPublisher(opts) {
6464
6575
  }
6465
6576
 
6466
6577
  // ../client/src/migrate.ts
6467
- async function fetchCapabilities(endpoint, fetchImpl = fetch, signal) {
6468
- const res = await fetchImpl(`${normalize(endpoint)}/v1/capabilities`, { method: "GET", ...signal ? { signal } : {} });
6469
- if (!res.ok) {
6470
- throw new Error(`answered ${res.status}`);
6578
+ var CAPABILITIES_TIMEOUT_MS = 1e4;
6579
+ async function fetchCapabilities(endpoint, fetchImpl = fetch, opts = {}) {
6580
+ const bound = new AbortController();
6581
+ const timer = setTimeout(() => bound.abort(new DOMException("the capabilities request timed out", "TimeoutError")), opts.timeoutMs ?? CAPABILITIES_TIMEOUT_MS);
6582
+ const signal = opts.signal ? AbortSignal.any([opts.signal, bound.signal]) : bound.signal;
6583
+ try {
6584
+ const res = await fetchImpl(`${normalize(endpoint)}/v1/capabilities`, { method: "GET", signal });
6585
+ if (!res.ok) {
6586
+ throw new Error(`answered ${res.status}`);
6587
+ }
6588
+ return await res.json();
6589
+ } finally {
6590
+ clearTimeout(timer);
6471
6591
  }
6472
- return await res.json();
6473
6592
  }
6474
6593
  async function probeEndpoint(endpoint, opts = {}) {
6475
6594
  const from = normalize(endpoint);
6476
- const signal = AbortSignal.timeout(opts.timeoutMs ?? 1e4);
6477
6595
  let advertised;
6478
6596
  try {
6479
- advertised = (await fetchCapabilities(from, opts.fetch, signal)).endpoints?.control;
6597
+ advertised = (await fetchCapabilities(from, opts.fetch, opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {})).endpoints?.control;
6480
6598
  } catch (e) {
6481
- return { kind: "unreachable", reason: signal.aborted ? "timed out" : e.message };
6599
+ return { kind: "unreachable", reason: e.name === "TimeoutError" ? "timed out" : e.message };
6482
6600
  }
6483
6601
  if (typeof advertised !== "string" || advertised === "") {
6484
6602
  return { kind: "unreachable", reason: "it advertises no control endpoint" };
@@ -6954,11 +7072,14 @@ var DEFAULT_PORTAL_URL = "https://shadow.minnovate.ai";
6954
7072
  function portalBase(env, flag) {
6955
7073
  return (flag ?? env["GIT_PUBLISHER_PORTAL"] ?? DEFAULT_PORTAL_URL).replace(/\/+$/, "");
6956
7074
  }
7075
+ var DISCOVER_TIMEOUT_MS = 1e4;
6957
7076
  async function discoverEndpoint(portal, fetchImpl = fetch) {
6958
7077
  const url2 = `${portal}/api/v1/config`;
7078
+ const bound = new AbortController();
7079
+ const timer = setTimeout(() => bound.abort(new DOMException("the request timed out", "TimeoutError")), DISCOVER_TIMEOUT_MS);
6959
7080
  let body;
6960
7081
  try {
6961
- const response = await fetchImpl(url2);
7082
+ const response = await fetchImpl(url2, { signal: bound.signal });
6962
7083
  if (!response.ok) {
6963
7084
  throw new PublisherError("UNAVAILABLE", `could not ask ${portal} where to publish (it answered ${response.status})`, { retryable: true });
6964
7085
  }
@@ -6968,6 +7089,8 @@ async function discoverEndpoint(portal, fetchImpl = fetch) {
6968
7089
  throw e;
6969
7090
  }
6970
7091
  throw new PublisherError("NETWORK", `could not reach ${portal}: ${e instanceof Error ? e.message : String(e)}`, { retryable: true });
7092
+ } finally {
7093
+ clearTimeout(timer);
6971
7094
  }
6972
7095
  const endpoint = body?.publishingEndpoint;
6973
7096
  if (endpoint === null || endpoint === void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnovate/shadow-publisher",
3
- "version": "0.11.5",
3
+ "version": "0.11.8",
4
4
  "description": "publisher: publish an app's Git history to the serverless Git backend",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",