@ancha-labs/cli 0.4.26 → 0.4.27

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.
@@ -9238,13 +9238,13 @@ var require_inspect = __commonJS({
9238
9238
  function isJSONable(value4) {
9239
9239
  return typeof value4.toJSON === "function";
9240
9240
  }
9241
- function formatObject(object17, seenValues) {
9242
- const entries3 = Object.entries(object17);
9241
+ function formatObject(object18, seenValues) {
9242
+ const entries3 = Object.entries(object18);
9243
9243
  if (entries3.length === 0) {
9244
9244
  return "{}";
9245
9245
  }
9246
9246
  if (seenValues.length > MAX_RECURSIVE_DEPTH) {
9247
- return "[" + getObjectTag(object17) + "]";
9247
+ return "[" + getObjectTag(object18) + "]";
9248
9248
  }
9249
9249
  const properties3 = entries3.map(
9250
9250
  ([key4, value4]) => key4 + ": " + formatValue(value4, seenValues)
@@ -9271,10 +9271,10 @@ var require_inspect = __commonJS({
9271
9271
  }
9272
9272
  return "[" + items.join(", ") + "]";
9273
9273
  }
9274
- function getObjectTag(object17) {
9275
- const tag3 = Object.prototype.toString.call(object17).replace(/^\[object /, "").replace(/]$/, "");
9276
- if (tag3 === "Object" && typeof object17.constructor === "function") {
9277
- const name5 = object17.constructor.name;
9274
+ function getObjectTag(object18) {
9275
+ const tag3 = Object.prototype.toString.call(object18).replace(/^\[object /, "").replace(/]$/, "");
9276
+ if (tag3 === "Object" && typeof object18.constructor === "function") {
9277
+ const name5 = object18.constructor.name;
9278
9278
  if (typeof name5 === "string" && name5 !== "") {
9279
9279
  return name5;
9280
9280
  }
@@ -21479,10 +21479,10 @@ var require_promiseForObject = __commonJS({
21479
21479
  value: true
21480
21480
  });
21481
21481
  exports.promiseForObject = promiseForObject;
21482
- function promiseForObject(object17) {
21483
- return Promise.all(Object.values(object17)).then((resolvedValues) => {
21482
+ function promiseForObject(object18) {
21483
+ return Promise.all(Object.values(object18)).then((resolvedValues) => {
21484
21484
  const resolvedObject = /* @__PURE__ */ Object.create(null);
21485
- for (const [i, key4] of Object.keys(object17).entries()) {
21485
+ for (const [i, key4] of Object.keys(object18).entries()) {
21486
21486
  resolvedObject[key4] = resolvedValues[i];
21487
21487
  }
21488
21488
  return resolvedObject;
@@ -27866,9 +27866,9 @@ var require_lodash = __commonJS({
27866
27866
  function asciiWords(string7) {
27867
27867
  return string7.match(reAsciiWord) || [];
27868
27868
  }
27869
- function basePropertyOf(object17) {
27869
+ function basePropertyOf(object18) {
27870
27870
  return function(key4) {
27871
- return object17 == null ? void 0 : object17[key4];
27871
+ return object18 == null ? void 0 : object18[key4];
27872
27872
  };
27873
27873
  }
27874
27874
  var deburrLetter = basePropertyOf(deburredLetters);
@@ -30685,32 +30685,32 @@ var require_namespace = __commonJS({
30685
30685
  return this.nested[name5].values;
30686
30686
  throw Error("no such enum: " + name5);
30687
30687
  };
30688
- Namespace.prototype.add = function add(object17) {
30689
- if (!(object17 instanceof Field && object17.extend !== void 0 || object17 instanceof Type || object17 instanceof OneOf || object17 instanceof Enum || object17 instanceof Service || object17 instanceof Namespace))
30688
+ Namespace.prototype.add = function add(object18) {
30689
+ if (!(object18 instanceof Field && object18.extend !== void 0 || object18 instanceof Type || object18 instanceof OneOf || object18 instanceof Enum || object18 instanceof Service || object18 instanceof Namespace))
30690
30690
  throw TypeError("object must be a valid nested object");
30691
- if (object17.name === "__proto__")
30691
+ if (object18.name === "__proto__")
30692
30692
  return this;
30693
30693
  if (!this.nested)
30694
30694
  this.nested = {};
30695
30695
  else {
30696
- var prev = this.get(object17.name);
30696
+ var prev = this.get(object18.name);
30697
30697
  if (prev) {
30698
- if (prev instanceof Namespace && object17 instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) {
30698
+ if (prev instanceof Namespace && object18 instanceof Namespace && !(prev instanceof Type || prev instanceof Service)) {
30699
30699
  var nested = prev.nestedArray;
30700
30700
  for (var i = 0; i < nested.length; ++i)
30701
- object17.add(nested[i]);
30701
+ object18.add(nested[i]);
30702
30702
  this.remove(prev);
30703
30703
  if (!this.nested)
30704
30704
  this.nested = {};
30705
- object17.setOptions(prev.options, true);
30705
+ object18.setOptions(prev.options, true);
30706
30706
  } else
30707
- throw Error("duplicate name '" + object17.name + "' in " + this);
30707
+ throw Error("duplicate name '" + object18.name + "' in " + this);
30708
30708
  }
30709
30709
  }
30710
- this.nested[object17.name] = object17;
30710
+ this.nested[object18.name] = object18;
30711
30711
  if (!(this instanceof Type || this instanceof Service || this instanceof Enum || this instanceof Field)) {
30712
- if (!object17._edition) {
30713
- object17._edition = object17._defaultEdition;
30712
+ if (!object18._edition) {
30713
+ object18._edition = object18._defaultEdition;
30714
30714
  }
30715
30715
  }
30716
30716
  this._needsRecursiveFeatureResolution = true;
@@ -30720,18 +30720,18 @@ var require_namespace = __commonJS({
30720
30720
  parent2._needsRecursiveFeatureResolution = true;
30721
30721
  parent2._needsRecursiveResolve = true;
30722
30722
  }
30723
- object17.onAdd(this);
30723
+ object18.onAdd(this);
30724
30724
  return clearCache(this);
30725
30725
  };
30726
- Namespace.prototype.remove = function remove5(object17) {
30727
- if (!(object17 instanceof ReflectionObject))
30726
+ Namespace.prototype.remove = function remove5(object18) {
30727
+ if (!(object18 instanceof ReflectionObject))
30728
30728
  throw TypeError("object must be a ReflectionObject");
30729
- if (object17.parent !== this)
30730
- throw Error(object17 + " is not a member of " + this);
30731
- delete this.nested[object17.name];
30729
+ if (object18.parent !== this)
30730
+ throw Error(object18 + " is not a member of " + this);
30731
+ delete this.nested[object18.name];
30732
30732
  if (!Object.keys(this.nested).length)
30733
30733
  this.nested = void 0;
30734
- object17.onRemove(this);
30734
+ object18.onRemove(this);
30735
30735
  return clearCache(this);
30736
30736
  };
30737
30737
  Namespace.prototype.define = function define2(path4, json33) {
@@ -31069,27 +31069,27 @@ var require_service2 = __commonJS({
31069
31069
  });
31070
31070
  return this;
31071
31071
  };
31072
- Service.prototype.add = function add(object17) {
31073
- if (this.get(object17.name))
31074
- throw Error("duplicate name '" + object17.name + "' in " + this);
31075
- if (object17 instanceof Method) {
31076
- if (object17.name === "__proto__")
31072
+ Service.prototype.add = function add(object18) {
31073
+ if (this.get(object18.name))
31074
+ throw Error("duplicate name '" + object18.name + "' in " + this);
31075
+ if (object18 instanceof Method) {
31076
+ if (object18.name === "__proto__")
31077
31077
  return this;
31078
- this.methods[object17.name] = object17;
31079
- object17.parent = this;
31078
+ this.methods[object18.name] = object18;
31079
+ object18.parent = this;
31080
31080
  return clearCache(this);
31081
31081
  }
31082
- return Namespace.prototype.add.call(this, object17);
31082
+ return Namespace.prototype.add.call(this, object18);
31083
31083
  };
31084
- Service.prototype.remove = function remove5(object17) {
31085
- if (object17 instanceof Method) {
31086
- if (this.methods[object17.name] !== object17)
31087
- throw Error(object17 + " is not a member of " + this);
31088
- delete this.methods[object17.name];
31089
- object17.parent = null;
31084
+ Service.prototype.remove = function remove5(object18) {
31085
+ if (object18 instanceof Method) {
31086
+ if (this.methods[object18.name] !== object18)
31087
+ throw Error(object18 + " is not a member of " + this);
31088
+ delete this.methods[object18.name];
31089
+ object18.parent = null;
31090
31090
  return clearCache(this);
31091
31091
  }
31092
- return Namespace.prototype.remove.call(this, object17);
31092
+ return Namespace.prototype.remove.call(this, object18);
31093
31093
  };
31094
31094
  Service.prototype.create = function create3(rpcImpl, requestDelimited, responseDelimited) {
31095
31095
  var rpcService = new rpc2.Service(rpcImpl, requestDelimited, responseDelimited);
@@ -31140,8 +31140,8 @@ var require_message = __commonJS({
31140
31140
  Message.verify = function verify4(message7) {
31141
31141
  return this.$type.verify(message7);
31142
31142
  };
31143
- Message.fromObject = function fromObject(object17) {
31144
- return this.$type.fromObject(object17);
31143
+ Message.fromObject = function fromObject(object18) {
31144
+ return this.$type.fromObject(object18);
31145
31145
  };
31146
31146
  Message.toObject = function toObject(message7, options3) {
31147
31147
  return this.$type.toObject(message7, options3);
@@ -31527,26 +31527,26 @@ var require_wrappers = __commonJS({
31527
31527
  var Message = require_message();
31528
31528
  var util = require_minimal();
31529
31529
  wrappers[".google.protobuf.Any"] = {
31530
- fromObject: function(object17, depth) {
31530
+ fromObject: function(object18, depth) {
31531
31531
  if (depth === void 0)
31532
31532
  depth = 0;
31533
31533
  if (depth > util.recursionLimit)
31534
31534
  throw Error("max depth exceeded");
31535
- if (object17 && object17["@type"]) {
31536
- var name5 = object17["@type"].substring(object17["@type"].lastIndexOf("/") + 1);
31535
+ if (object18 && object18["@type"]) {
31536
+ var name5 = object18["@type"].substring(object18["@type"].lastIndexOf("/") + 1);
31537
31537
  var type = this.lookup(name5);
31538
31538
  if (type) {
31539
- var type_url = object17["@type"].charAt(0) === "." ? object17["@type"].slice(1) : object17["@type"];
31539
+ var type_url = object18["@type"].charAt(0) === "." ? object18["@type"].slice(1) : object18["@type"];
31540
31540
  if (type_url.indexOf("/") === -1) {
31541
31541
  type_url = "/" + type_url;
31542
31542
  }
31543
31543
  return this.create({
31544
31544
  type_url,
31545
- value: type.encode(type.fromObject(object17, depth + 1)).finish()
31545
+ value: type.encode(type.fromObject(object18, depth + 1)).finish()
31546
31546
  });
31547
31547
  }
31548
31548
  }
31549
- return this.fromObject(object17, depth);
31549
+ return this.fromObject(object18, depth);
31550
31550
  },
31551
31551
  toObject: function(message7, options3, depth) {
31552
31552
  if (depth === void 0)
@@ -31564,14 +31564,14 @@ var require_wrappers = __commonJS({
31564
31564
  message7 = type.decode(message7.value, void 0, void 0, depth + 1);
31565
31565
  }
31566
31566
  if (!(message7 instanceof this.ctor) && message7 instanceof Message) {
31567
- var object17 = message7.$type.toObject(message7, options3, depth + 1);
31567
+ var object18 = message7.$type.toObject(message7, options3, depth + 1);
31568
31568
  var messageName = message7.$type.fullName[0] === "." ? message7.$type.fullName.slice(1) : message7.$type.fullName;
31569
31569
  if (prefix2 === "") {
31570
31570
  prefix2 = googleApi;
31571
31571
  }
31572
31572
  name5 = prefix2 + messageName;
31573
- object17["@type"] = name5;
31574
- return object17;
31573
+ object18["@type"] = name5;
31574
+ return object18;
31575
31575
  }
31576
31576
  return this.toObject(message7, options3, depth);
31577
31577
  }
@@ -31801,59 +31801,59 @@ var require_type2 = __commonJS({
31801
31801
  return this.nested[name5];
31802
31802
  return null;
31803
31803
  };
31804
- Type.prototype.add = function add(object17) {
31805
- if (this.get(object17.name))
31806
- throw Error("duplicate name '" + object17.name + "' in " + this);
31807
- if (object17 instanceof Field && object17.extend === void 0) {
31804
+ Type.prototype.add = function add(object18) {
31805
+ if (this.get(object18.name))
31806
+ throw Error("duplicate name '" + object18.name + "' in " + this);
31807
+ if (object18 instanceof Field && object18.extend === void 0) {
31808
31808
  if (this._fieldsById ? (
31809
31809
  /* istanbul ignore next */
31810
- this._fieldsById[object17.id]
31811
- ) : this.fieldsById[object17.id])
31812
- throw Error("duplicate id " + object17.id + " in " + this);
31813
- if (this.isReservedId(object17.id))
31814
- throw Error("id " + object17.id + " is reserved in " + this);
31815
- if (this.isReservedName(object17.name) || object17.name.charAt(0) === "$")
31816
- throw Error("name '" + object17.name + "' is reserved in " + this);
31817
- if (object17.name === "__proto__")
31810
+ this._fieldsById[object18.id]
31811
+ ) : this.fieldsById[object18.id])
31812
+ throw Error("duplicate id " + object18.id + " in " + this);
31813
+ if (this.isReservedId(object18.id))
31814
+ throw Error("id " + object18.id + " is reserved in " + this);
31815
+ if (this.isReservedName(object18.name) || object18.name.charAt(0) === "$")
31816
+ throw Error("name '" + object18.name + "' is reserved in " + this);
31817
+ if (object18.name === "__proto__")
31818
31818
  return this;
31819
- if (object17.parent)
31820
- object17.parent.remove(object17);
31821
- this.fields[object17.name] = object17;
31822
- object17.message = this;
31823
- object17.onAdd(this);
31819
+ if (object18.parent)
31820
+ object18.parent.remove(object18);
31821
+ this.fields[object18.name] = object18;
31822
+ object18.message = this;
31823
+ object18.onAdd(this);
31824
31824
  return clearCache(this);
31825
31825
  }
31826
- if (object17 instanceof OneOf) {
31827
- if (object17.name.charAt(0) === "$")
31828
- throw Error("name '" + object17.name + "' is reserved in " + this);
31829
- if (object17.name === "__proto__")
31826
+ if (object18 instanceof OneOf) {
31827
+ if (object18.name.charAt(0) === "$")
31828
+ throw Error("name '" + object18.name + "' is reserved in " + this);
31829
+ if (object18.name === "__proto__")
31830
31830
  return this;
31831
31831
  if (!this.oneofs)
31832
31832
  this.oneofs = {};
31833
- this.oneofs[object17.name] = object17;
31834
- object17.onAdd(this);
31833
+ this.oneofs[object18.name] = object18;
31834
+ object18.onAdd(this);
31835
31835
  return clearCache(this);
31836
31836
  }
31837
- return Namespace.prototype.add.call(this, object17);
31837
+ return Namespace.prototype.add.call(this, object18);
31838
31838
  };
31839
- Type.prototype.remove = function remove5(object17) {
31840
- if (object17 instanceof Field && object17.extend === void 0) {
31841
- if (!this.fields || this.fields[object17.name] !== object17)
31842
- throw Error(object17 + " is not a member of " + this);
31843
- delete this.fields[object17.name];
31844
- object17.parent = null;
31845
- object17.onRemove(this);
31839
+ Type.prototype.remove = function remove5(object18) {
31840
+ if (object18 instanceof Field && object18.extend === void 0) {
31841
+ if (!this.fields || this.fields[object18.name] !== object18)
31842
+ throw Error(object18 + " is not a member of " + this);
31843
+ delete this.fields[object18.name];
31844
+ object18.parent = null;
31845
+ object18.onRemove(this);
31846
31846
  return clearCache(this);
31847
31847
  }
31848
- if (object17 instanceof OneOf) {
31849
- if (!this.oneofs || this.oneofs[object17.name] !== object17)
31850
- throw Error(object17 + " is not a member of " + this);
31851
- delete this.oneofs[object17.name];
31852
- object17.parent = null;
31853
- object17.onRemove(this);
31848
+ if (object18 instanceof OneOf) {
31849
+ if (!this.oneofs || this.oneofs[object18.name] !== object18)
31850
+ throw Error(object18 + " is not a member of " + this);
31851
+ delete this.oneofs[object18.name];
31852
+ object18.parent = null;
31853
+ object18.onRemove(this);
31854
31854
  return clearCache(this);
31855
31855
  }
31856
- return Namespace.prototype.remove.call(this, object17);
31856
+ return Namespace.prototype.remove.call(this, object18);
31857
31857
  };
31858
31858
  Type.prototype.isReservedId = function isReservedId(id14) {
31859
31859
  return Namespace.isReservedId(this.reserved, id14);
@@ -31918,8 +31918,8 @@ var require_type2 = __commonJS({
31918
31918
  Type.prototype.verify = function verify_setup(message7, depth) {
31919
31919
  return this.setup().verify(message7, depth);
31920
31920
  };
31921
- Type.prototype.fromObject = function fromObject(object17, depth) {
31922
- return this.setup().fromObject(object17, depth);
31921
+ Type.prototype.fromObject = function fromObject(object18, depth) {
31922
+ return this.setup().fromObject(object18, depth);
31923
31923
  };
31924
31924
  Type.prototype.toObject = function toObject(message7, options3) {
31925
31925
  return this.setup().toObject.apply(this, arguments);
@@ -32120,65 +32120,65 @@ var require_root = __commonJS({
32120
32120
  }
32121
32121
  return false;
32122
32122
  }
32123
- Root.prototype._handleAdd = function _handleAdd(object17) {
32124
- if (object17 instanceof Field) {
32123
+ Root.prototype._handleAdd = function _handleAdd(object18) {
32124
+ if (object18 instanceof Field) {
32125
32125
  if (
32126
32126
  /* an extension field (implies not part of a oneof) */
32127
- object17.extend !== void 0 && /* not already handled */
32128
- !object17.extensionField
32127
+ object18.extend !== void 0 && /* not already handled */
32128
+ !object18.extensionField
32129
32129
  ) {
32130
- if (!tryHandleExtension(this, object17))
32131
- this.deferred.push(object17);
32132
- }
32133
- } else if (object17 instanceof Enum) {
32134
- if (exposeRe.test(object17.name))
32135
- object17.parent[object17.name] = object17.values;
32136
- } else if (!(object17 instanceof OneOf)) {
32137
- if (object17 instanceof Type)
32130
+ if (!tryHandleExtension(this, object18))
32131
+ this.deferred.push(object18);
32132
+ }
32133
+ } else if (object18 instanceof Enum) {
32134
+ if (exposeRe.test(object18.name))
32135
+ object18.parent[object18.name] = object18.values;
32136
+ } else if (!(object18 instanceof OneOf)) {
32137
+ if (object18 instanceof Type)
32138
32138
  for (var i = 0; i < this.deferred.length; )
32139
32139
  if (tryHandleExtension(this, this.deferred[i]))
32140
32140
  this.deferred.splice(i, 1);
32141
32141
  else
32142
32142
  ++i;
32143
32143
  for (var j = 0; j < /* initializes */
32144
- object17.nestedArray.length; ++j)
32145
- this._handleAdd(object17._nestedArray[j]);
32146
- if (exposeRe.test(object17.name))
32147
- object17.parent[object17.name] = object17;
32144
+ object18.nestedArray.length; ++j)
32145
+ this._handleAdd(object18._nestedArray[j]);
32146
+ if (exposeRe.test(object18.name))
32147
+ object18.parent[object18.name] = object18;
32148
32148
  }
32149
- if (object17 instanceof Type || object17 instanceof Enum || object17 instanceof Field) {
32150
- this._fullyQualifiedObjects[object17.fullName] = object17;
32149
+ if (object18 instanceof Type || object18 instanceof Enum || object18 instanceof Field) {
32150
+ this._fullyQualifiedObjects[object18.fullName] = object18;
32151
32151
  }
32152
32152
  };
32153
- Root.prototype._handleRemove = function _handleRemove(object17) {
32154
- if (object17 instanceof Field) {
32153
+ Root.prototype._handleRemove = function _handleRemove(object18) {
32154
+ if (object18 instanceof Field) {
32155
32155
  if (
32156
32156
  /* an extension field */
32157
- object17.extend !== void 0
32157
+ object18.extend !== void 0
32158
32158
  ) {
32159
32159
  if (
32160
32160
  /* already handled */
32161
- object17.extensionField
32161
+ object18.extensionField
32162
32162
  ) {
32163
- object17.extensionField.parent.remove(object17.extensionField);
32164
- object17.extensionField = null;
32163
+ object18.extensionField.parent.remove(object18.extensionField);
32164
+ object18.extensionField = null;
32165
32165
  } else {
32166
- var index = this.deferred.indexOf(object17);
32166
+ var index = this.deferred.indexOf(object18);
32167
32167
  if (index > -1)
32168
32168
  this.deferred.splice(index, 1);
32169
32169
  }
32170
32170
  }
32171
- } else if (object17 instanceof Enum) {
32172
- if (exposeRe.test(object17.name))
32173
- delete object17.parent[object17.name];
32174
- } else if (object17 instanceof Namespace) {
32171
+ } else if (object18 instanceof Enum) {
32172
+ if (exposeRe.test(object18.name))
32173
+ delete object18.parent[object18.name];
32174
+ } else if (object18 instanceof Namespace) {
32175
32175
  for (var i = 0; i < /* initializes */
32176
- object17.nestedArray.length; ++i)
32177
- this._handleRemove(object17._nestedArray[i]);
32178
- if (exposeRe.test(object17.name))
32179
- delete object17.parent[object17.name];
32176
+ object18.nestedArray.length; ++i)
32177
+ this._handleRemove(object18._nestedArray[i]);
32178
+ if (exposeRe.test(object18.name))
32179
+ delete object18.parent[object18.name];
32180
32180
  }
32181
- delete this._fullyQualifiedObjects[object17.fullName];
32181
+ delete this._fullyQualifiedObjects[object18.fullName];
32182
32182
  };
32183
32183
  Root._configure = function(Type_, parse_, common_) {
32184
32184
  Type = Type_;
@@ -32209,23 +32209,23 @@ var require_util2 = __commonJS({
32209
32209
  throw Error("max depth exceeded");
32210
32210
  return depth;
32211
32211
  };
32212
- util.toArray = function toArray(object17) {
32213
- if (object17) {
32214
- var keys6 = Object.keys(object17), array3 = new Array(keys6.length), index = 0;
32212
+ util.toArray = function toArray(object18) {
32213
+ if (object18) {
32214
+ var keys6 = Object.keys(object18), array3 = new Array(keys6.length), index = 0;
32215
32215
  while (index < keys6.length)
32216
- array3[index] = object17[keys6[index++]];
32216
+ array3[index] = object18[keys6[index++]];
32217
32217
  return array3;
32218
32218
  }
32219
32219
  return [];
32220
32220
  };
32221
32221
  util.toObject = function toObject(array3) {
32222
- var object17 = {}, index = 0;
32222
+ var object18 = {}, index = 0;
32223
32223
  while (index < array3.length) {
32224
32224
  var key4 = array3[index++], val = array3[index++];
32225
32225
  if (val !== void 0)
32226
- object17[key4] = val;
32226
+ object18[key4] = val;
32227
32227
  }
32228
- return object17;
32228
+ return object18;
32229
32229
  };
32230
32230
  util.isReserved = function isReserved(name5) {
32231
32231
  return reservedRe.test(name5);
@@ -32266,14 +32266,14 @@ var require_util2 = __commonJS({
32266
32266
  return type;
32267
32267
  };
32268
32268
  var decorateEnumIndex = 0;
32269
- util.decorateEnum = function decorateEnum(object17) {
32270
- if (object17.$type)
32271
- return object17.$type;
32269
+ util.decorateEnum = function decorateEnum(object18) {
32270
+ if (object18.$type)
32271
+ return object18.$type;
32272
32272
  if (!Enum)
32273
32273
  Enum = require_enum2();
32274
- var enm = new Enum("Enum" + decorateEnumIndex++, object17);
32274
+ var enm = new Enum("Enum" + decorateEnumIndex++, object18);
32275
32275
  util.decorateRoot.add(enm);
32276
- Object.defineProperty(object17, "$type", { value: enm, enumerable: false });
32276
+ Object.defineProperty(object18, "$type", { value: enm, enumerable: false });
32277
32277
  return enm;
32278
32278
  };
32279
32279
  util.setProperty = function setProperty(dst, path4, value4, ifNotSet) {
@@ -56609,9 +56609,9 @@ function floatSafeRemainder(val, step2) {
56609
56609
  return ratio - roundedRatio;
56610
56610
  }
56611
56611
  var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
56612
- function defineLazy(object17, key4, getter2) {
56612
+ function defineLazy(object18, key4, getter2) {
56613
56613
  let value4 = void 0;
56614
- Object.defineProperty(object17, key4, {
56614
+ Object.defineProperty(object18, key4, {
56615
56615
  get() {
56616
56616
  if (value4 === EVALUATING) {
56617
56617
  return void 0;
@@ -56623,7 +56623,7 @@ function defineLazy(object17, key4, getter2) {
56623
56623
  return value4;
56624
56624
  },
56625
56625
  set(v) {
56626
- Object.defineProperty(object17, key4, {
56626
+ Object.defineProperty(object18, key4, {
56627
56627
  value: v
56628
56628
  // configurable: true,
56629
56629
  });
@@ -71738,8 +71738,8 @@ function foldObjects(members4) {
71738
71738
  }
71739
71739
  const properties3 = {};
71740
71740
  const required4 = /* @__PURE__ */ new Set();
71741
- for (const object17 of objects) {
71742
- for (const key4 in object17.properties) {
71741
+ for (const object18 of objects) {
71742
+ for (const key4 in object18.properties) {
71743
71743
  if (Object.prototype.hasOwnProperty.call(properties3, key4))
71744
71744
  continue;
71745
71745
  const parts3 = [];
@@ -71753,18 +71753,18 @@ function foldObjects(members4) {
71753
71753
  const merged = parts3.length === 1 ? parts3[0] : foldObjects(parts3) ?? { allOf: parts3 };
71754
71754
  assignProp(properties3, key4, merged);
71755
71755
  }
71756
- for (const key4 of object17.required ?? [])
71756
+ for (const key4 of object18.required ?? [])
71757
71757
  required4.add(key4);
71758
71758
  }
71759
71759
  const folded = { type: "object", properties: properties3 };
71760
71760
  if (required4.size)
71761
71761
  folded.required = [...required4];
71762
- if (objects.every((object17) => object17.additionalProperties === false)) {
71762
+ if (objects.every((object18) => object18.additionalProperties === false)) {
71763
71763
  folded.additionalProperties = false;
71764
71764
  } else {
71765
71765
  const constraints = [];
71766
- for (const object17 of objects) {
71767
- const constraint = undeclaredConstraint(object17);
71766
+ for (const object18 of objects) {
71767
+ const constraint = undeclaredConstraint(object18);
71768
71768
  if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))
71769
71769
  constraints.push(constraint);
71770
71770
  }
@@ -93387,8 +93387,8 @@ var HubSpotSeedSchema = external_exports.strictObject({
93387
93387
  const plural4 = { company: "companies", contact: "contacts", deal: "deals" };
93388
93388
  seed43.webhooks?.subscriptions.forEach((subscription2, index) => {
93389
93389
  const [type, property4] = subscription2.split(":");
93390
- const object17 = plural4[type.split(".")[0]];
93391
- if (property4 !== void 0 && !(property4 in hubspotPropertySchemas[object17].shape)) issue8(["webhooks", "subscriptions", index], `${property4} is not a ${object17.slice(0, -1)} property`);
93390
+ const object18 = plural4[type.split(".")[0]];
93391
+ if (property4 !== void 0 && !(property4 in hubspotPropertySchemas[object18].shape)) issue8(["webhooks", "subscriptions", index], `${property4} is not a ${object18.slice(0, -1)} property`);
93392
93392
  if (seed43.webhooks.subscriptions.indexOf(subscription2) !== index) issue8(["webhooks", "subscriptions", index], "duplicate subscription");
93393
93393
  });
93394
93394
  });
@@ -95855,9 +95855,9 @@ var AttioSeedSchema = external_exports.strictObject({
95855
95855
  const members4 = new Set(seed43.members.map((m) => m.ref));
95856
95856
  if (!members4.has(seed43.agent)) issue8(["agent"], "agent must be the ref of a member");
95857
95857
  const recordObject = /* @__PURE__ */ new Map();
95858
- for (const object17 of ["people", "companies", "deals"]) seed43.records[object17].forEach((r2, i) => {
95859
- if (recordObject.has(r2.ref)) issue8(["records", object17, i, "ref"], "duplicate record ref");
95860
- recordObject.set(r2.ref, object17);
95858
+ for (const object18 of ["people", "companies", "deals"]) seed43.records[object18].forEach((r2, i) => {
95859
+ if (recordObject.has(r2.ref)) issue8(["records", object18, i, "ref"], "duplicate record ref");
95860
+ recordObject.set(r2.ref, object18);
95861
95861
  });
95862
95862
  const lists = /* @__PURE__ */ new Set();
95863
95863
  const emails = new Set(seed43.members.map((m) => m.email.toLowerCase()));
@@ -95878,9 +95878,9 @@ var AttioSeedSchema = external_exports.strictObject({
95878
95878
  }
95879
95879
  }
95880
95880
  };
95881
- for (const object17 of ["people", "companies", "deals"]) {
95882
- const standard2 = { ...Object.fromEntries(ATTIO_STANDARD_ATTRIBUTES[object17].map((slug10) => [slug10, {}])), ...STANDARD_LOOKUPS[object17], ...object17 === "deals" && { stage: { options: seed43.deal_stages } } };
95883
- seed43.records[object17].forEach((r2, i) => named4(r2.values, seed43.attributes[object17] ?? [], standard2, ["records", object17, i, "values"]));
95881
+ for (const object18 of ["people", "companies", "deals"]) {
95882
+ const standard2 = { ...Object.fromEntries(ATTIO_STANDARD_ATTRIBUTES[object18].map((slug10) => [slug10, {}])), ...STANDARD_LOOKUPS[object18], ...object18 === "deals" && { stage: { options: seed43.deal_stages } } };
95883
+ seed43.records[object18].forEach((r2, i) => named4(r2.values, seed43.attributes[object18] ?? [], standard2, ["records", object18, i, "values"]));
95884
95884
  }
95885
95885
  seed43.lists.forEach((l, i) => {
95886
95886
  if (lists.has(l.api_slug)) issue8(["lists", i, "api_slug"], "duplicate list slug");
@@ -95905,7 +95905,7 @@ var AttioSeedSchema = external_exports.strictObject({
95905
95905
  });
95906
95906
  });
95907
95907
  function attioSeedRecords(seed43) {
95908
- return ["people", "companies", "deals"].flatMap((object17) => seed43.records[object17].map((r2) => ({ collection: object17, id: r2.ref, label: String(r2.values.name ?? r2.ref) })));
95908
+ return ["people", "companies", "deals"].flatMap((object18) => seed43.records[object18].map((r2) => ({ collection: object18, id: r2.ref, label: String(r2.values.name ?? r2.ref) })));
95909
95909
  }
95910
95910
  var attioStarterSeed = {
95911
95911
  workspace: { name: "Acme", slug: "acme" },
@@ -102936,7 +102936,7 @@ function validateRefs(scene2) {
102936
102936
  for (const field5 of ["charge", "payment_intent"]) localUse(`stripe.refunds.${field5}`, c.state["stripe.refunds"][field5], field5, stripeRefs(field5));
102937
102937
  }
102938
102938
  if ("stripe.balance" in c.state) localUse("stripe.balance.customer", c.state["stripe.balance"].customer, "customer", stripeRefs("customer"));
102939
- if ("stripe.unchanged" in c.state) c.state["stripe.unchanged"].objects.forEach((object17, n2) => localUse(`stripe.unchanged.objects[${n2}].id`, object17.id, object17.type, stripeRefs(object17.type)));
102939
+ if ("stripe.unchanged" in c.state) c.state["stripe.unchanged"].objects.forEach((object18, n2) => localUse(`stripe.unchanged.objects[${n2}].id`, object18.id, object18.type, stripeRefs(object18.type)));
102940
102940
  if ("okta.user" in c.state && c.state["okta.user"].startsWith("$")) use(`${p2}.okta.user`, c.state["okta.user"], "user", "okta");
102941
102941
  });
102942
102942
  const selector2 = (value4, p2) => {
@@ -105296,6 +105296,13 @@ function functionToolWiringIssues(observation) {
105296
105296
  return observation.missing.length ? [{ kind: "tools", owner: "harness", service: "tools", message: functionWiringMessage(observation.missing) }] : [];
105297
105297
  }
105298
105298
 
105299
+ // packages/core/src/function-tool-view.ts
105300
+ var object3 = (value4) => value4 !== null && typeof value4 === "object" && !Array.isArray(value4) ? value4 : {};
105301
+ function functionCallFields(entry2) {
105302
+ const response5 = object3(entry2.response);
105303
+ return { args: object3(entry2.request).args, result: response5.result, error_type: response5.error_type ?? object3(response5.error).type };
105304
+ }
105305
+
105299
105306
  // backend/src/mcp/vendor-http.ts
105300
105307
  function mcpTextResult(text24, isError = false) {
105301
105308
  return { isError, content: [{ type: "text", text: text24 }] };
@@ -107233,8 +107240,8 @@ var Context = class {
107233
107240
  * })
107234
107241
  * ```
107235
107242
  */
107236
- json = (object17, arg, headers) => {
107237
- return this.#newResponse(JSON.stringify(object17), arg, setDefaultContentType("application/json", headers));
107243
+ json = (object18, arg, headers) => {
107244
+ return this.#newResponse(JSON.stringify(object18), arg, setDefaultContentType("application/json", headers));
107238
107245
  };
107239
107246
  html = (html2, arg, headers) => {
107240
107247
  const res = (html3) => this.#newResponse(html3, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
@@ -108578,11 +108585,11 @@ function argumentError(schema, args) {
108578
108585
  if (errors2.every((error64) => error64 !== void 0)) return errors2[0];
108579
108586
  }
108580
108587
  if (value4 !== null && typeof value4 === "object" && !Array.isArray(value4)) {
108581
- const object17 = value4;
108582
- for (const name5 of rule.required ?? []) if (!Object.hasOwn(object17, name5)) return `Missing required argument: ${[...path4, name5].join(".")}`;
108588
+ const object18 = value4;
108589
+ for (const name5 of rule.required ?? []) if (!Object.hasOwn(object18, name5)) return `Missing required argument: ${[...path4, name5].join(".")}`;
108583
108590
  const properties3 = rule.properties ?? {};
108584
108591
  const patterns = Object.entries(rule.patternProperties ?? {}).map(([pattern, child2]) => ({ pattern: new RegExp(pattern), child: child2 }));
108585
- for (const [name5, child2] of Object.entries(object17)) {
108592
+ for (const [name5, child2] of Object.entries(object18)) {
108586
108593
  const children3 = patterns.filter((p2) => p2.pattern.test(name5)).map((p2) => p2.child);
108587
108594
  if (Object.hasOwn(properties3, name5)) children3.unshift(properties3[name5]);
108588
108595
  if (!children3.length) {
@@ -110583,7 +110590,7 @@ function evaluateTrace(trace, calls2, tools) {
110583
110590
  evidence: seqs(parts3.flatMap((p2) => p2.evidence))
110584
110591
  };
110585
110592
  }
110586
- var object3 = (value4) => value4 !== null && typeof value4 === "object" && !Array.isArray(value4) ? value4 : void 0;
110593
+ var object4 = (value4) => value4 !== null && typeof value4 === "object" && !Array.isArray(value4) ? value4 : void 0;
110587
110594
  var jsonValue = (value4) => value4 === void 0 ? "(missing)" : JSON.stringify(value4);
110588
110595
  function toolValueDifferences(have, want, path4, subset) {
110589
110596
  if (Array.isArray(want)) {
@@ -110593,7 +110600,7 @@ function toolValueDifferences(have, want, path4, subset) {
110593
110600
  ...want.flatMap((value4, index) => toolValueDifferences(have[index], value4, `${path4}[${index}]`, false))
110594
110601
  ];
110595
110602
  }
110596
- const desired = object3(want), actual = object3(have);
110603
+ const desired = object4(want), actual = object4(have);
110597
110604
  if (desired && actual) return [
110598
110605
  ...Object.entries(desired).flatMap(([key4, value4]) => Object.hasOwn(actual, key4) ? toolValueDifferences(actual[key4], value4, `${path4}.${key4}`, subset) : [`${path4}.${key4}: expected ${jsonValue(value4)}, got (missing)`]),
110599
110606
  ...!subset ? Object.keys(actual).filter((key4) => !Object.hasOwn(desired, key4)).map((key4) => `${path4}.${key4}: unexpected ${jsonValue(actual[key4])}`) : []
@@ -110605,11 +110612,12 @@ function evaluateToolCall(check3, trace) {
110605
110612
  const status4 = check3.status ?? "succeeded", count4 = check3.count ?? { gte: 1 };
110606
110613
  const expected = `${check3.name}: status ${status4}; count ${JSON.stringify(count4)}` + (check3.args ? `; args ${JSON.stringify(check3.args)}` : "") + (check3.result ? `; result ${JSON.stringify(check3.result)}` : "") + (check3.error ? `; error.type ${JSON.stringify(check3.error.type)}` : "");
110607
110614
  const candidates = calls2.map((entry2) => {
110608
- const response5 = object3(entry2.response), request = object3(entry2.request);
110615
+ const response5 = object4(entry2.response), request = object4(entry2.request);
110609
110616
  const functionCall = entry2.service === "tools" && entry2.path === `/tools/${check3.name}`;
110610
- const params10 = object3(request?.params);
110611
- const args = functionCall ? request?.args : entry2.method === "MCP" ? request?.args ?? request?.arguments : params10?.arguments;
110612
- const result = functionCall || entry2.method === "POST" ? response5?.result : entry2.response;
110617
+ const params10 = object4(request?.params);
110618
+ const fields11 = functionCallFields(entry2);
110619
+ const args = functionCall ? fields11.args : entry2.method === "MCP" ? request?.args ?? request?.arguments : params10?.arguments;
110620
+ const result = functionCall ? fields11.result : entry2.method === "POST" ? response5?.result : entry2.response;
110613
110621
  const unconfirmed = response5?.execution_status === "unknown" || response5?.execution_status === "pending";
110614
110622
  if (unconfirmed) throw new AnchaError("USAGE", `${check3.name} (seq ${entry2.seq}): completion missing. ${functionWiringMessage([check3.name])} Await the wrapped call and its completion report before finishing the task.`);
110615
110623
  const actualStatus = response5?.execution_status === "failed" || failure2(entry2) !== void 0 || response5?.isError === true || response5?.error != null ? "failed" : "succeeded";
@@ -110626,14 +110634,14 @@ function evaluateToolCall(check3, trace) {
110626
110634
  }
110627
110635
  differences2.push(...toolValueDifferences(value4, predicate.equals !== void 0 ? predicate.equals : predicate.contains, field5, predicate.contains !== void 0));
110628
110636
  }
110629
- const errorType = response5?.error_type ?? object3(response5?.error)?.type;
110637
+ const errorType = functionCall ? fields11.error_type : response5?.error_type ?? object4(response5?.error)?.type;
110630
110638
  if (check3.error && errorType !== check3.error.type) differences2.push(`error.type: expected ${jsonValue(check3.error.type)}, got ${jsonValue(errorType)}`);
110631
110639
  return { entry: entry2, differences: differences2, actualStatus };
110632
110640
  });
110633
110641
  const matched = candidates.filter((call2) => call2.differences.length === 0);
110634
110642
  const passed = (count4.eq === void 0 || matched.length === count4.eq) && (count4.gte === void 0 || matched.length >= count4.gte) && (count4.lte === void 0 || matched.length <= count4.lte);
110635
110643
  const closest = [...candidates].sort((a, b) => a.differences.length - b.differences.length || a.entry.seq - b.entry.seq)[0];
110636
- const detail3 = closest ? `closest call ${check3.name} (seq ${closest.entry.seq}${closest.entry.completion ? `, completion seq ${closest.entry.completion.seq}` : ""}${object3(closest.entry.response)?.source ? `, ${object3(closest.entry.response).source}` : ""}): ${list3(closest.differences) || `status ${closest.actualStatus}; all call predicates match`}` : `no call named ${check3.name}`;
110644
+ const detail3 = closest ? `closest call ${check3.name} (seq ${closest.entry.seq}${closest.entry.completion ? `, completion seq ${closest.entry.completion.seq}` : ""}${object4(closest.entry.response)?.source ? `, ${object4(closest.entry.response).source}` : ""}): ${list3(closest.differences) || `status ${closest.actualStatus}; all call predicates match`}` : `no call named ${check3.name}`;
110637
110645
  const actual = `${check3.name}: count ${matched.length} matching of ${calls2.length} named call(s); ${detail3}`;
110638
110646
  return {
110639
110647
  passed,
@@ -112059,13 +112067,13 @@ function githubEvent(ctx, type, payload2, additionalLinks = []) {
112059
112067
  const body6 = structuredClone({ ...payload2, sender: payload2.sender ?? userShape(githubEventContext(ctx), botUser(ctx)) });
112060
112068
  const apiLinks = [];
112061
112069
  const fields11 = (pointer2, keys6) => {
112062
- let object17 = body6;
112070
+ let object18 = body6;
112063
112071
  for (const key4 of pointer2.slice(1).split("/")) {
112064
- if (!object17 || typeof object17 !== "object") return;
112065
- object17 = object17[key4];
112072
+ if (!object18 || typeof object18 !== "object") return;
112073
+ object18 = object18[key4];
112066
112074
  }
112067
- if (!object17 || typeof object17 !== "object") return;
112068
- const resource2 = object17;
112075
+ if (!object18 || typeof object18 !== "object") return;
112076
+ const resource2 = object18;
112069
112077
  for (const key4 of keys6) {
112070
112078
  const value4 = resource2[key4];
112071
112079
  if (typeof value4 !== "string" || !(value4.startsWith(`${semanticOrigin}/`) || value4.startsWith("/"))) continue;
@@ -113364,12 +113372,12 @@ function transitionIncident(ctx, id14, change3, actor3) {
113364
113372
  }
113365
113373
 
113366
113374
  // packages/server/src/twins/pagerduty/ingest.ts
113367
- function object4(value4) {
113375
+ function object5(value4) {
113368
113376
  return value4 !== null && typeof value4 === "object" && !Array.isArray(value4);
113369
113377
  }
113370
113378
  function ingestEvent(ctx, input5) {
113371
113379
  return withMutation(ctx, () => {
113372
- if (!object4(input5)) invalid2("Event must be an object");
113380
+ if (!object5(input5)) invalid2("Event must be an object");
113373
113381
  for (const key5 of Object.keys(input5)) if (!["routing_key", "event_action", "dedup_key", "payload"].includes(key5)) unsupported2(`Events ${key5}`);
113374
113382
  if (typeof input5.routing_key !== "string") invalid2("routing_key is required");
113375
113383
  const service = ctx.store.db.prepare("SELECT * FROM pagerduty_services WHERE routing_key = ?").get(input5.routing_key);
@@ -113378,11 +113386,11 @@ function ingestEvent(ctx, input5) {
113378
113386
  if (input5.dedup_key !== void 0 && (typeof input5.dedup_key !== "string" || !input5.dedup_key.length || input5.dedup_key.length > 255)) invalid2("dedup_key must be 1 to 255 characters");
113379
113387
  if (input5.event_action !== "trigger" && input5.dedup_key === void 0) invalid2("dedup_key is required");
113380
113388
  if (input5.payload !== void 0) {
113381
- if (!object4(input5.payload)) invalid2("payload must be an object");
113389
+ if (!object5(input5.payload)) invalid2("payload must be an object");
113382
113390
  for (const key5 of Object.keys(input5.payload)) if (!["summary", "source", "severity", "timestamp", "component", "group", "class", "custom_details"].includes(key5)) unsupported2(`Events payload.${key5}`);
113383
113391
  for (const key5 of ["component", "group", "class"]) if (input5.payload[key5] !== void 0 && typeof input5.payload[key5] !== "string") invalid2(`Invalid payload.${key5}`);
113384
113392
  if (input5.payload.timestamp !== void 0 && (!/^\d{4}-\d\d-\d\dT/.test(input5.payload.timestamp) || !Number.isFinite(Date.parse(input5.payload.timestamp)))) invalid2("Invalid payload.timestamp");
113385
- if (input5.payload.custom_details !== void 0 && !object4(input5.payload.custom_details)) invalid2("Invalid payload.custom_details");
113393
+ if (input5.payload.custom_details !== void 0 && !object5(input5.payload.custom_details)) invalid2("Invalid payload.custom_details");
113386
113394
  }
113387
113395
  if (input5.event_action === "trigger") {
113388
113396
  const p2 = input5.payload;
@@ -113858,11 +113866,11 @@ function replaceLink(message7, link6, url4) {
113858
113866
  for (const [index, key4] of keys6.entries()) {
113859
113867
  if (typeof target5 !== "object" || target5 === null || !Object.hasOwn(target5, key4) || Array.isArray(target5) && !/^(0|[1-9]\d*)$/.test(key4))
113860
113868
  throw new AnchaError("INTERNAL", "Missing Slack message API link field");
113861
- const object17 = target5;
113869
+ const object18 = target5;
113862
113870
  if (index === keys6.length - 1) {
113863
- if (object17[key4] !== link6.path) throw new AnchaError("INTERNAL", "Slack message API link does not match its semantic path");
113864
- Object.defineProperty(object17, key4, { value: url4, enumerable: true, configurable: true, writable: true });
113865
- } else target5 = object17[key4];
113871
+ if (object18[key4] !== link6.path) throw new AnchaError("INTERNAL", "Slack message API link does not match its semantic path");
113872
+ Object.defineProperty(object18, key4, { value: url4, enumerable: true, configurable: true, writable: true });
113873
+ } else target5 = object18[key4];
113866
113874
  }
113867
113875
  }
113868
113876
  function persistMessageLinks(ctx, row2, links3 = []) {
@@ -114504,7 +114512,7 @@ var SINGULAR = { companies: "company", contacts: "contact", deals: "deal" };
114504
114512
  function emitWebhooks(ctx, type, prior, next2) {
114505
114513
  const seed43 = ctx.scene.seed.hubspot, webhooks = seed43?.webhooks;
114506
114514
  if (!seed43 || !webhooks?.subscriptions.length) return;
114507
- const object17 = SINGULAR[type];
114515
+ const object18 = SINGULAR[type];
114508
114516
  webhooks.subscriptions.forEach((subscription2, index) => {
114509
114517
  const [subscriptionType, propertyName] = subscription2.split(":");
114510
114518
  const event3 = () => ({
@@ -114518,8 +114526,8 @@ function emitWebhooks(ctx, type, prior, next2) {
114518
114526
  objectId: Number(next2.id),
114519
114527
  changeSource: "API"
114520
114528
  });
114521
- if (subscriptionType === `${object17}.creation` && prior === void 0) ctx.events.append({ service: "hubspot", type: subscriptionType, payload: [event3()] });
114522
- if (subscriptionType === `${object17}.propertyChange` && propertyName !== void 0) {
114529
+ if (subscriptionType === `${object18}.creation` && prior === void 0) ctx.events.append({ service: "hubspot", type: subscriptionType, payload: [event3()] });
114530
+ if (subscriptionType === `${object18}.propertyChange` && propertyName !== void 0) {
114523
114531
  const value4 = next2.properties[propertyName];
114524
114532
  if (value4 !== void 0 && value4 !== "" && value4 !== prior?.properties[propertyName]) ctx.events.append({ service: "hubspot", type: subscriptionType, payload: [{ ...event3(), propertyName, propertyValue: value4 }] });
114525
114533
  }
@@ -115812,7 +115820,7 @@ function handleMutation(handler, status4 = 200, applicationKey = true) {
115812
115820
  }
115813
115821
  };
115814
115822
  }
115815
- function object5(value4, field5) {
115823
+ function object6(value4, field5) {
115816
115824
  if (value4 === null || typeof value4 !== "object" || Array.isArray(value4)) throw new DatadogError(400, `Invalid ${field5}: expected object`);
115817
115825
  return value4;
115818
115826
  }
@@ -119346,7 +119354,7 @@ function fields4(value4, allowed2) {
119346
119354
  if (!allowed2.includes(key4))
119347
119355
  gap(`field ${key4}`);
119348
119356
  }
119349
- function object6(value4) {
119357
+ function object7(value4) {
119350
119358
  if (!value4 || typeof value4 !== "object" || Array.isArray(value4))
119351
119359
  invalid5("Expected an object");
119352
119360
  return value4;
@@ -119589,7 +119597,7 @@ function search2(ctx, body6, customer3, stream = false) {
119589
119597
  if (body6.summaryRowSetting && !["UNSPECIFIED", "NO_SUMMARY_ROW"].includes(body6.summaryRowSetting))
119590
119598
  gap("summaryRowSetting");
119591
119599
  if (body6.searchSettings) {
119592
- fields4(object6(body6.searchSettings), ["returnTotalResultsCount"]);
119600
+ fields4(object7(body6.searchSettings), ["returnTotalResultsCount"]);
119593
119601
  if (body6.searchSettings.returnTotalResultsCount !== void 0 && typeof body6.searchSettings.returnTotalResultsCount !== "boolean")
119594
119602
  invalid5("returnTotalResultsCount must be boolean");
119595
119603
  }
@@ -119738,7 +119746,7 @@ function updatePaths(mask2) {
119738
119746
  invalid5("update_mask is required");
119739
119747
  return mask2.split(",").map((p2) => p2.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`));
119740
119748
  }
119741
- const obj = object6(mask2);
119749
+ const obj = object7(mask2);
119742
119750
  fields4(obj, ["paths"]);
119743
119751
  if (!Array.isArray(obj.paths) || !obj.paths.length || obj.paths.some((p2) => typeof p2 !== "string"))
119744
119752
  invalid5("update_mask.paths must contain field paths");
@@ -119768,7 +119776,7 @@ function validateRelationships(ctx, kind, record9, cid) {
119768
119776
  throw new AdsError(3, "fieldError", "INVALID_VALUE", "end_date_time must not precede start_date_time");
119769
119777
  }
119770
119778
  function oneOperation(ctx, kind, cid, raw3, returnResource) {
119771
- const op = object6(raw3);
119779
+ const op = object7(raw3);
119772
119780
  fields4(op, ["create", "update", "remove", "updateMask"]);
119773
119781
  const types = ["create", "update", "remove"].filter((k) => op[k] !== void 0);
119774
119782
  if (types.length !== 1)
@@ -119777,7 +119785,7 @@ function oneOperation(ctx, kind, cid, raw3, returnResource) {
119777
119785
  invalid5("update_mask is only valid with update");
119778
119786
  let record9;
119779
119787
  if (op.create !== void 0) {
119780
- const input5 = object6(op.create);
119788
+ const input5 = object7(op.create);
119781
119789
  for (const k of ["resourceName", "id", "criterionId", "policySummary", "type"]) {
119782
119790
  if (input5[k] !== void 0 && !(k === "type" && kind === "adGroups"))
119783
119791
  throw new AdsError(3, "fieldError", "VALUE_MUST_BE_UNSET", `${k} must not be set on create`);
@@ -119794,7 +119802,7 @@ function oneOperation(ctx, kind, cid, raw3, returnResource) {
119794
119802
  if (kind === "ads") {
119795
119803
  if (input5.ad?.id !== void 0 || input5.ad?.resourceName !== void 0 || input5.ad?.type !== void 0)
119796
119804
  throw new AdsError(3, "fieldError", "VALUE_MUST_BE_UNSET", "Ad id, resource_name and type are assigned on create");
119797
- record9.ad = { ...object6(input5.ad), id: id14, resourceName: `customers/${cid}/ads/${id14}`, type: "RESPONSIVE_SEARCH_AD" };
119805
+ record9.ad = { ...object7(input5.ad), id: id14, resourceName: `customers/${cid}/ads/${id14}`, type: "RESPONSIVE_SEARCH_AD" };
119798
119806
  record9.policySummary = { reviewStatus: "REVIEW_IN_PROGRESS", approvalStatus: "UNKNOWN" };
119799
119807
  }
119800
119808
  if (kind === "criteria")
@@ -119802,7 +119810,7 @@ function oneOperation(ctx, kind, cid, raw3, returnResource) {
119802
119810
  if (kind === "budgets")
119803
119811
  record9.status = "ENABLED";
119804
119812
  } else {
119805
- const input5 = op.update === void 0 ? void 0 : object6(op.update), name5 = parseName(op.remove ?? input5?.resourceName, cid, kind);
119813
+ const input5 = op.update === void 0 ? void 0 : object7(op.update), name5 = parseName(op.remove ?? input5?.resourceName, cid, kind);
119806
119814
  const old = get(ctx, kind, name5);
119807
119815
  if (!old)
119808
119816
  throw new AdsError(3, "mutateError", "RESOURCE_NOT_FOUND", "Resource does not exist");
@@ -119900,7 +119908,7 @@ function execute2(ctx, method2, raw3, headers) {
119900
119908
  const write4 = method2.startsWith("Mutate");
119901
119909
  return (write4 ? withMutation : withRead)(ctx, () => {
119902
119910
  authenticate4(ctx, headers);
119903
- const body6 = object6(raw3);
119911
+ const body6 = object7(raw3);
119904
119912
  if (method2 === "ListAccessibleCustomers") {
119905
119913
  fields4(body6, []);
119906
119914
  return { resourceNames: config3(ctx).access.directCustomerIds.map((id14) => `customers/${id14}`) };
@@ -120345,7 +120353,7 @@ function invalid6(message7, param4 = null) {
120345
120353
  function unsupported6(message7) {
120346
120354
  throw new AdsError2(501, `ancha: not implemented: ${message7}`, "unsupported_operation");
120347
120355
  }
120348
- function object7(value4, field5 = "body") {
120356
+ function object8(value4, field5 = "body") {
120349
120357
  if (!value4 || typeof value4 !== "object" || Array.isArray(value4)) invalid6(`${field5} must be an object`, field5);
120350
120358
  return value4;
120351
120359
  }
@@ -120475,15 +120483,15 @@ var createFields = { campaigns: ["name", "description", "status", "start_time",
120475
120483
  var updateFields = { campaigns: ["name", "description", "status", "start_time", "end_time", "budget", "targeting"], adGroups: ["name", "description", "status", "context_hints", "bidding_config"], ads: ["name", "status", "creative"] };
120476
120484
  function targeting2(value4, previous) {
120477
120485
  if (value4 === null) return {};
120478
- const body6 = object7(value4, "targeting");
120486
+ const body6 = object8(value4, "targeting");
120479
120487
  keys2(body6, ["locations", "platforms"], "targeting");
120480
- if (body6.locations !== void 0) keys2(object7(body6.locations, "locations"), ["countries"], "targeting.locations");
120481
- if (body6.platforms !== void 0 && body6.platforms !== null) keys2(object7(body6.platforms, "platforms"), ["included"], "targeting.platforms");
120488
+ if (body6.locations !== void 0) keys2(object8(body6.locations, "locations"), ["countries"], "targeting.locations");
120489
+ if (body6.platforms !== void 0 && body6.platforms !== null) keys2(object8(body6.platforms, "platforms"), ["included"], "targeting.platforms");
120482
120490
  const parsed3 = parse5(ChatGPTAdsTargetingSchema, body6);
120483
120491
  return { ...parsed3, ...!Object.hasOwn(body6, "platforms") && previous?.platforms !== void 0 ? { platforms: previous.platforms } : {} };
120484
120492
  }
120485
120493
  function bidding(value4, campaign2, access3) {
120486
- const body6 = object7(value4, "bidding_config");
120494
+ const body6 = object8(value4, "bidding_config");
120487
120495
  keys2(body6, ["billing_event_type", "strategy", "max_bid_micros"], "bidding_config");
120488
120496
  if (body6.strategy === "maximize_conversions") unsupported6("conversion bidding");
120489
120497
  const bid = parse5(ChatGPTAdsBiddingSchema, body6), billing = campaign2.bidding_type === "clicks" ? "click" : "impression";
@@ -120495,7 +120503,7 @@ function bidding(value4, campaign2, access3) {
120495
120503
  return { ...bid, strategy };
120496
120504
  }
120497
120505
  function creative(value4, access3, creating) {
120498
- const body6 = object7(value4, "creative");
120506
+ const body6 = object8(value4, "creative");
120499
120507
  keys2(body6, ["type", "title", "body", "target_url", "file_id", "price"], "creative");
120500
120508
  if (body6.type !== void 0 && body6.type !== "chat_card") unsupported6(`creative type ${String(body6.type)}`);
120501
120509
  const parsed3 = parse5(ChatGPTAdsCreativeSchema, body6);
@@ -120516,7 +120524,7 @@ function validateSeed(seed43) {
120516
120524
  return parse5(ChatGPTAdsSeedSchema, seed43);
120517
120525
  }
120518
120526
  function mutate2(c, access3, kind, input5, existing2) {
120519
- const body6 = object7(input5), creating = !existing2;
120527
+ const body6 = object8(input5), creating = !existing2;
120520
120528
  keys2(body6, creating ? createFields[kind] : updateFields[kind], kind);
120521
120529
  if (creating && !["active", "paused"].includes(body6.status)) invalid6("Create status must be active or paused", "status");
120522
120530
  if (creating) {
@@ -120533,7 +120541,7 @@ function mutate2(c, access3, kind, input5, existing2) {
120533
120541
  if (kind === "campaigns") {
120534
120542
  if (creating && body6.bidding_type === void 0) candidate.bidding_type = "impressions";
120535
120543
  if (Object.hasOwn(body6, "targeting")) candidate.targeting = targeting2(body6.targeting, existing2?.targeting);
120536
- if (body6.budget !== void 0) keys2(object7(body6.budget, "budget"), ["daily_spend_limit_micros", "lifetime_spend_limit_micros"], "budget");
120544
+ if (body6.budget !== void 0) keys2(object8(body6.budget, "budget"), ["daily_spend_limit_micros", "lifetime_spend_limit_micros"], "budget");
120537
120545
  if (candidate.end_time !== void 0 && candidate.end_time !== null && Number(candidate.end_time) <= Number(candidate.start_time ?? timestamp4)) invalid6("end_time must follow start_time");
120538
120546
  } else if (kind === "adGroups") {
120539
120547
  if (body6.bidding_config !== void 0) candidate.bidding_config = bidding(body6.bidding_config, ancestor ?? find(access3, "campaigns", existing2.campaign_id), access3);
@@ -120612,7 +120620,7 @@ var levels = ["ad_account", "campaign", "ad_group", "ad"];
120612
120620
  var metrics = ["impressions", "clicks", "spend", "ctr", "cpc", "cpm"];
120613
120621
  function json7(value4, field5) {
120614
120622
  try {
120615
- return object7(JSON.parse(value4), field5);
120623
+ return object8(JSON.parse(value4), field5);
120616
120624
  } catch (error64) {
120617
120625
  if (error64 instanceof SyntaxError) invalid6(`Invalid JSON in ${field5}`);
120618
120626
  throw error64;
@@ -120788,7 +120796,7 @@ function invalid7(message7) {
120788
120796
  function unsupported7(message7) {
120789
120797
  throw new GA4Error(501, "UNIMPLEMENTED", `ancha: not implemented: ${message7}`);
120790
120798
  }
120791
- function object8(value4, field5) {
120799
+ function object9(value4, field5) {
120792
120800
  if (!value4 || typeof value4 !== "object" || Array.isArray(value4)) invalid7(`${field5} must be an object`);
120793
120801
  return value4;
120794
120802
  }
@@ -120912,7 +120920,7 @@ function selectedFields(raw3, kind, required4 = false) {
120912
120920
  if (raw3 === void 0 && !required4) return [];
120913
120921
  if (!Array.isArray(raw3) || raw3.length > (kind === "dimensions" ? 9 : 10) || required4 && !raw3.length) invalid7(`Invalid ${kind} count`);
120914
120922
  const fields11 = raw3.map((entry2, index) => {
120915
- const item2 = object8(entry2, `${kind}[${index}]`);
120923
+ const item2 = object9(entry2, `${kind}[${index}]`);
120916
120924
  keys3(item2, kind === "dimensions" ? ["name", "dimensionExpression"] : ["name", "expression", "invisible"], kind);
120917
120925
  if (item2.dimensionExpression !== void 0 || item2.expression !== void 0 || item2.invisible === true) unsupported7(`${kind} expressions or invisible metrics`);
120918
120926
  if (item2.invisible !== void 0 && typeof item2.invisible !== "boolean") invalid7("Invalid invisible");
@@ -120975,7 +120983,7 @@ function metric2(atoms, name5) {
120975
120983
 
120976
120984
  // packages/server/src/twins/ga4/filter.ts
120977
120985
  function numeric(value4) {
120978
- const item2 = object8(value4, "NumericValue");
120986
+ const item2 = object9(value4, "NumericValue");
120979
120987
  keys3(item2, ["int64Value", "doubleValue"], "NumericValue");
120980
120988
  if (Object.keys(item2).length !== 1) invalid7("NumericValue must contain exactly one value");
120981
120989
  if (item2.int64Value !== void 0) {
@@ -120992,7 +121000,7 @@ function compileFilter(raw3, kind) {
120992
121000
  let count4 = 0;
120993
121001
  const compile2 = (raw4, depth) => {
120994
121002
  if (depth > 8 || ++count4 > 100) invalid7("Filter exceeds supported depth/node limit");
120995
- const expr = object8(raw4, "FilterExpression");
121003
+ const expr = object9(raw4, "FilterExpression");
120996
121004
  keys3(expr, ["andGroup", "orGroup", "notExpression", "filter"], "FilterExpression");
120997
121005
  if (Object.keys(expr).length !== 1) invalid7("FilterExpression requires exactly one expression");
120998
121006
  if (expr.notExpression !== void 0) {
@@ -121000,18 +121008,18 @@ function compileFilter(raw3, kind) {
121000
121008
  return (read6) => !child2(read6);
121001
121009
  }
121002
121010
  for (const op2 of ["andGroup", "orGroup"]) if (expr[op2] !== void 0) {
121003
- const group5 = object8(expr[op2], op2);
121011
+ const group5 = object9(expr[op2], op2);
121004
121012
  keys3(group5, ["expressions"], op2);
121005
121013
  if (!Array.isArray(group5.expressions) || !group5.expressions.length || group5.expressions.length > 20) invalid7("Invalid filter group");
121006
121014
  const children3 = group5.expressions.map((child2) => compile2(child2, depth + 1));
121007
121015
  return op2 === "andGroup" ? (read6) => children3.every((fn) => fn(read6)) : (read6) => children3.some((fn) => fn(read6));
121008
121016
  }
121009
- const filter4 = object8(expr.filter, "filter");
121017
+ const filter4 = object9(expr.filter, "filter");
121010
121018
  keys3(filter4, ["fieldName", "stringFilter", "inListFilter", "numericFilter", "betweenFilter", "emptyFilter"], "filter");
121011
121019
  const field5 = kind === "dimension" ? dimensionName(filter4.fieldName) : metricName(filter4.fieldName);
121012
121020
  const operators = Object.keys(filter4).filter((key4) => key4 !== "fieldName");
121013
121021
  if (operators.length !== 1) invalid7("Filter requires one operator");
121014
- const op = operators[0], value4 = object8(filter4[op], op);
121022
+ const op = operators[0], value4 = object9(filter4[op], op);
121015
121023
  if (op === "stringFilter") {
121016
121024
  if (kind === "metric") invalid7("stringFilter requires a dimension");
121017
121025
  keys3(value4, ["matchType", "value", "caseSensitive"], "stringFilter");
@@ -121077,7 +121085,7 @@ function date9(value4, property4, ctx) {
121077
121085
  function ranges(raw3, property4, ctx) {
121078
121086
  if (!Array.isArray(raw3) || raw3.length < 1 || raw3.length > 4) invalid7("One to four dateRanges are required");
121079
121087
  const result = raw3.map((entry2, i) => {
121080
- const value4 = object8(entry2, "dateRanges");
121088
+ const value4 = object9(entry2, "dateRanges");
121081
121089
  keys3(value4, ["startDate", "endDate", "name"], "dateRanges");
121082
121090
  const start2 = date9(value4.startDate, property4, ctx), end = date9(value4.endDate, property4, ctx);
121083
121091
  if (end < start2) invalid7("startDate must not be after endDate");
@@ -121100,13 +121108,13 @@ function ordering(raw3, dims, mets) {
121100
121108
  if (raw3 === void 0) raw3 = [];
121101
121109
  if (!Array.isArray(raw3) || raw3.length > 20) invalid7("Invalid orderBys");
121102
121110
  const comparisons = raw3.map((entry2) => {
121103
- const value4 = object8(entry2, "orderBys");
121111
+ const value4 = object9(entry2, "orderBys");
121104
121112
  keys3(value4, ["dimension", "metric", "pivot", "desc"], "orderBys");
121105
121113
  if (value4.pivot !== void 0) unsupported7("pivot order");
121106
121114
  if (value4.dimension === void 0 === (value4.metric === void 0)) invalid7("Specify one dimension or metric order");
121107
121115
  const sign3 = bool2(value4.desc, "orderBys.desc") ? -1 : 1;
121108
121116
  if (value4.dimension !== void 0) {
121109
- const order7 = object8(value4.dimension, "dimension order");
121117
+ const order7 = object9(value4.dimension, "dimension order");
121110
121118
  keys3(order7, ["dimensionName", "orderType"], "dimension order");
121111
121119
  const name5 = order7.dimensionName === "dateRange" ? "dateRange" : dimensionName(order7.dimensionName), index2 = dims.indexOf(name5);
121112
121120
  if (index2 < 0) invalid7("Ordered dimension must be selected");
@@ -121121,7 +121129,7 @@ function ordering(raw3, dims, mets) {
121121
121129
  return sign3 * lexical(type === "CASE_INSENSITIVE_ALPHANUMERIC" ? left.toLowerCase() : left, type === "CASE_INSENSITIVE_ALPHANUMERIC" ? right.toLowerCase() : right);
121122
121130
  };
121123
121131
  }
121124
- const order6 = object8(value4.metric, "metric order");
121132
+ const order6 = object9(value4.metric, "metric order");
121125
121133
  keys3(order6, ["metricName"], "metric order");
121126
121134
  const index = mets.indexOf(metricName(order6.metricName));
121127
121135
  if (index < 0) invalid7("Ordered metric must be selected");
@@ -121137,7 +121145,7 @@ function ordering(raw3, dims, mets) {
121137
121145
  }
121138
121146
  var wire = (row2) => ({ dimensionValues: row2.dimensions.map((value4) => ({ value: value4 })), metricValues: row2.metrics.map((value4) => ({ value: String(value4) })) });
121139
121147
  function report2(ctx, property4, raw3, batch3 = false) {
121140
- const value4 = object8(raw3, "RunReportRequest");
121148
+ const value4 = object9(raw3, "RunReportRequest");
121141
121149
  keys3(value4, ["property", "dimensions", "metrics", "dateRanges", "dimensionFilter", "metricFilter", "offset", "limit", "metricAggregations", "orderBys", "currencyCode", "keepEmptyRows", "returnPropertyQuota", "cohortSpec", "comparisons"], "RunReportRequest");
121142
121150
  if (value4.property !== void 0 && (!batch3 || value4.property !== `properties/${property4.id}`)) invalid7("Property must be specified in the path and match the batch");
121143
121151
  if (value4.cohortSpec !== void 0 || value4.comparisons !== void 0) unsupported7("cohorts or comparisons");
@@ -121196,14 +121204,14 @@ var ga4Routes = [
121196
121204
  return { ...result.response, ...result.returnQuota ? { propertyQuota: used } : {} };
121197
121205
  } },
121198
121206
  { method: "POST", path: "/v1beta/properties/:property{[0-9]+:batchRunReports}", notes: "One to five reports for one property; prevalidate all reports before local quota debit.", run: (c, body6) => {
121199
- const p2 = property2(c, c.req.param("property").split(":")[0]), value4 = object8(body6, "BatchRunReportsRequest");
121207
+ const p2 = property2(c, c.req.param("property").split(":")[0]), value4 = object9(body6, "BatchRunReportsRequest");
121200
121208
  keys3(value4, ["requests"], "BatchRunReportsRequest");
121201
121209
  if (!Array.isArray(value4.requests) || !value4.requests.length || value4.requests.length > 5) invalid7("Batch requires one to five report requests");
121202
121210
  const results = value4.requests.map((request) => report2(c.env.ctx, p2, request, true)), used = quota(c.env.ctx, p2.id, results.length);
121203
121211
  return { kind: "analyticsData#batchRunReports", reports: results.map((result) => ({ ...result.response, ...result.returnQuota ? { propertyQuota: used } : {} })) };
121204
121212
  } },
121205
121213
  { method: "POST", path: "/v1beta/properties/:property{[0-9]+:checkCompatibility}", notes: "Compatibility only within the supported metadata subset; all supported combinations are compatible. Unknown fields expose gaps.", run: (c, body6) => {
121206
- const p2 = property2(c, c.req.param("property").split(":")[0]), value4 = object8(body6, "CheckCompatibilityRequest");
121214
+ const p2 = property2(c, c.req.param("property").split(":")[0]), value4 = object9(body6, "CheckCompatibilityRequest");
121207
121215
  keys3(value4, ["dimensions", "metrics", "dimensionFilter", "metricFilter", "compatibilityFilter"], "CheckCompatibilityRequest");
121208
121216
  selectedFields(value4.dimensions, "dimensions");
121209
121217
  selectedFields(value4.metrics, "metrics");
@@ -122764,13 +122772,13 @@ function target(ctx, value4) {
122764
122772
  function parse7(c, body6, version5, old) {
122765
122773
  query4(c, []);
122766
122774
  const ctx = c.env.ctx, now11 = ctx.clock.now().getTime();
122767
- let attrs = object5(body6, "body");
122775
+ let attrs = object6(body6, "body");
122768
122776
  if (version5 === 2) {
122769
122777
  keys(attrs, ["data"], "body");
122770
- const data5 = object5(attrs.data, "data");
122778
+ const data5 = object6(attrs.data, "data");
122771
122779
  keys(data5, ["type", "id", "attributes"], "data");
122772
122780
  if (data5.type !== "downtime" || (old ? data5.id !== old.uuid : data5.id !== void 0)) throw new DatadogError(400, "Invalid downtime type or id");
122773
- attrs = object5(data5.attributes, "attributes");
122781
+ attrs = object6(data5.attributes, "attributes");
122774
122782
  }
122775
122783
  keys(attrs, version5 === 1 ? ["scope", "monitor_id", "monitor_tags", "start", "end", "message", "timezone", "mute_first_recovery_notification", "notify_end_types", "notify_end_states"] : ["scope", "monitor_identifier", "schedule", "message", "display_timezone", "mute_first_recovery_notification", "notify_end_types", "notify_end_states"], "downtime");
122776
122784
  if (!old && attrs.scope === void 0) throw new DatadogError(400, "scope is required");
@@ -122785,7 +122793,7 @@ function parse7(c, body6, version5, old) {
122785
122793
  monitorId = null;
122786
122794
  }
122787
122795
  } else if (attrs.monitor_identifier !== void 0) {
122788
- const identifier4 = object5(attrs.monitor_identifier, "monitor_identifier");
122796
+ const identifier4 = object6(attrs.monitor_identifier, "monitor_identifier");
122789
122797
  keys(identifier4, ["monitor_id", "monitor_tags"], "monitor_identifier");
122790
122798
  if (Object.keys(identifier4).length !== 1) throw new DatadogError(400, "Specify exactly one monitor identifier");
122791
122799
  if (identifier4.monitor_id !== void 0) monitorId = target(ctx, identifier4.monitor_id);
@@ -122795,7 +122803,7 @@ function parse7(c, body6, version5, old) {
122795
122803
  monitorId = null;
122796
122804
  }
122797
122805
  } else if (!old && version5 === 2) throw new DatadogError(400, "monitor_identifier is required");
122798
- const schedule3 = version5 === 1 ? attrs : attrs.schedule === void 0 ? {} : object5(attrs.schedule, "schedule");
122806
+ const schedule3 = version5 === 1 ? attrs : attrs.schedule === void 0 ? {} : object6(attrs.schedule, "schedule");
122799
122807
  if (version5 === 2) keys(schedule3, ["start", "end"], "schedule");
122800
122808
  const start2 = schedule3.start === void 0 ? old?.start ?? now11 : timestamp2(schedule3.start, version5, "start");
122801
122809
  if (schedule3.end === void 0 && !old) unsupported4("indefinite downtime; provide a finite end");
@@ -123156,7 +123164,7 @@ function listEvents(c) {
123156
123164
  }
123157
123165
  function createEvent(c, input5) {
123158
123166
  query4(c, []);
123159
- const body6 = object5(input5, "event");
123167
+ const body6 = object6(input5, "event");
123160
123168
  const title2 = string5(body6.title, "title"), text24 = string5(body6.text, "text");
123161
123169
  if (text24.length > 4e3) throw new DatadogError(400, "Event text exceeds 4000 characters");
123162
123170
  const now11 = c.env.ctx.clock.nowMs();
@@ -123183,10 +123191,10 @@ function find2(c, id14) {
123183
123191
  return row2;
123184
123192
  }
123185
123193
  function attributes(input5, create3, id14) {
123186
- const body6 = object5(input5, "body"), data5 = object5(body6.data, "data");
123194
+ const body6 = object6(input5, "body"), data5 = object6(body6.data, "data");
123187
123195
  if (data5.type !== "incidents") throw new DatadogError(400, "Invalid data.type: expected incidents");
123188
123196
  if (!create3 && incidentId(data5.id) !== id14) throw new DatadogError(400, "Incident id does not match URL");
123189
- const attrs = object5(data5.attributes === void 0 && !create3 ? {} : data5.attributes, "data.attributes");
123197
+ const attrs = object6(data5.attributes === void 0 && !create3 ? {} : data5.attributes, "data.attributes");
123190
123198
  const title2 = attrs.title === void 0 && !create3 ? void 0 : string5(attrs.title, "title");
123191
123199
  if ((create3 || attrs.customer_impacted !== void 0) && typeof attrs.customer_impacted !== "boolean") throw new DatadogError(400, "Invalid customer_impacted: expected boolean");
123192
123200
  if (attrs.customer_impact_scope !== void 0 && typeof attrs.customer_impact_scope !== "string") throw new DatadogError(400, "Invalid customer_impact_scope");
@@ -123194,9 +123202,9 @@ function attributes(input5, create3, id14) {
123194
123202
  if ("state" in attrs || "severity" in attrs || "status" in attrs) throw new DatadogError(400, "Incident state and severity belong in attributes.fields");
123195
123203
  let state2, severity;
123196
123204
  if (attrs.fields !== void 0) {
123197
- const fields11 = object5(attrs.fields, "fields");
123205
+ const fields11 = object6(attrs.fields, "fields");
123198
123206
  for (const [name5, value4] of Object.entries(fields11)) {
123199
- const field5 = object5(value4, `fields.${name5}`);
123207
+ const field5 = object6(value4, `fields.${name5}`);
123200
123208
  if (name5 !== "state" && name5 !== "severity") unsupported4(`incident field ${name5}`);
123201
123209
  if (typeof field5.value !== "string") throw new DatadogError(400, `Invalid fields.${name5}.value`);
123202
123210
  if (field5.type !== void 0 && field5.type !== "dropdown") {
@@ -123333,10 +123341,10 @@ async function searchLogs(c) {
123333
123341
  }
123334
123342
  function listLogs(c, input5) {
123335
123343
  query4(c, []);
123336
- const body6 = object5(input5, "logs search");
123337
- const filter4 = body6.filter === void 0 ? {} : object5(body6.filter, "filter");
123338
- const page18 = body6.page === void 0 ? {} : object5(body6.page, "page");
123339
- const options3 = body6.options === void 0 ? {} : object5(body6.options, "options");
123344
+ const body6 = object6(input5, "logs search");
123345
+ const filter4 = body6.filter === void 0 ? {} : object6(body6.filter, "filter");
123346
+ const page18 = body6.page === void 0 ? {} : object6(body6.page, "page");
123347
+ const options3 = body6.options === void 0 ? {} : object6(body6.options, "options");
123340
123348
  const from = filter4.from === void 0 ? "now-15m" : string5(filter4.from, "filter.from");
123341
123349
  const to = filter4.to === void 0 ? "now" : string5(filter4.to, "filter.to");
123342
123350
  const source = filter4.query === void 0 ? "*" : string5(filter4.query, "filter.query");
@@ -125493,7 +125501,7 @@ function errorBody2(e) {
125493
125501
  function errorResponse3(e) {
125494
125502
  return json8(errorBody2(e), e.status, e.gap ? { [GAP_HEADER]: "1" } : {});
125495
125503
  }
125496
- function object9(input5) {
125504
+ function object10(input5) {
125497
125505
  if (!input5 || typeof input5 !== "object" || Array.isArray(input5)) invalid10("Expected an object");
125498
125506
  return input5;
125499
125507
  }
@@ -125683,11 +125691,11 @@ function create(ctx, kind, account9, body6) {
125683
125691
  }
125684
125692
  function update3(ctx, kind, account9, id14, body6) {
125685
125693
  access(ctx, account9, true);
125686
- const row2 = find3(ctx, kind, id14, account9), original = value2(row2), root3 = object9(body6);
125694
+ const row2 = find3(ctx, kind, id14, account9), original = value2(row2), root3 = object10(body6);
125687
125695
  fields6(root3, ["patch"]);
125688
- const patch = object9(root3.patch);
125696
+ const patch = object10(root3.patch);
125689
125697
  fields6(patch, ["$set"]);
125690
- const changes = object9(patch.$set);
125698
+ const changes = object10(patch.$set);
125691
125699
  fields6(changes, mutable[kind]);
125692
125700
  if (!Object.keys(changes).length) invalid10("patch.$set must not be empty");
125693
125701
  if ((original.status === "CANCELED" || original.intendedStatus === "CANCELED") && (changes.status || changes.intendedStatus)) invalid10("Cannot reactivate a canceled entity");
@@ -125752,7 +125760,7 @@ function collectionWrite(kind, c, body6) {
125752
125760
  const op = method(c, ["CREATE", "BATCH_CREATE"]);
125753
125761
  if (op === "BATCH_CREATE") {
125754
125762
  if (kind === "creatives") gap3("creative batch create");
125755
- const b = object9(body6);
125763
+ const b = object10(body6);
125756
125764
  fields6(b, ["elements"]);
125757
125765
  if (!Array.isArray(b.elements) || !b.elements.length || b.elements.length > 100) invalid10("elements must contain 1..100 objects");
125758
125766
  let hasGap = false;
@@ -125960,7 +125968,7 @@ var GongError = class extends Error {
125960
125968
  function unsupported9(message7) {
125961
125969
  throw new GongError(501, `ancha: not implemented: ${message7}`);
125962
125970
  }
125963
- function object10(value4, field5) {
125971
+ function object11(value4, field5) {
125964
125972
  if (!value4 || typeof value4 !== "object" || Array.isArray(value4)) throw new GongError(400, `Invalid ${field5}: expected object`);
125965
125973
  return value4;
125966
125974
  }
@@ -126076,7 +126084,7 @@ function pageRequest(ctx, principal, op, criteria, raw3) {
126076
126084
 
126077
126085
  // packages/server/src/twins/gong/routes.ts
126078
126086
  function filter2(raw3, mode) {
126079
- const value4 = object10(raw3, "filter");
126087
+ const value4 = object11(raw3, "filter");
126080
126088
  keys4(value4, ["fromDateTime", "toDateTime", "workspaceId", ...mode === "basic" ? [] : ["callIds"], ...mode === "extensive" ? ["primaryUserIds"] : []], "filter");
126081
126089
  if (mode === "basic" && (value4.fromDateTime === void 0 || value4.toDateTime === void 0)) throw new GongError(400, "fromDateTime and toDateTime are required");
126082
126090
  const parsed3 = {
@@ -126100,20 +126108,20 @@ function nonempty(values2) {
126100
126108
  return values2;
126101
126109
  }
126102
126110
  function selector(raw3) {
126103
- const value4 = raw3 === void 0 ? {} : object10(raw3, "contentSelector");
126111
+ const value4 = raw3 === void 0 ? {} : object11(raw3, "contentSelector");
126104
126112
  keys4(value4, ["context", "contextTiming", "exposedFields"], "contentSelector");
126105
126113
  const context3 = value4.context === void 0 ? "None" : value4.context;
126106
126114
  if (!["None", "Basic", "Extended"].includes(context3)) throw new GongError(400, "Invalid contentSelector.context");
126107
126115
  const timing = value4.contextTiming === void 0 ? ["Now"] : value4.contextTiming;
126108
126116
  if (!Array.isArray(timing) || timing.length < 1 || timing.length > 2 || timing.some((v) => !["Now", "TimeOfCall"].includes(v)) || new Set(timing).size !== timing.length) throw new GongError(400, "Invalid contentSelector.contextTiming");
126109
126117
  if (value4.contextTiming !== void 0 && context3 !== "Extended") throw new GongError(400, "contextTiming requires Extended context");
126110
- const exposed = value4.exposedFields === void 0 ? {} : object10(value4.exposedFields, "contentSelector.exposedFields");
126118
+ const exposed = value4.exposedFields === void 0 ? {} : object11(value4.exposedFields, "contentSelector.exposedFields");
126111
126119
  keys4(exposed, ["parties", "content", "interaction", "collaboration", "media"], "contentSelector.exposedFields");
126112
126120
  for (const name5 of ["parties", "media"]) if (exposed[name5] !== void 0 && typeof exposed[name5] !== "boolean") throw new GongError(400, `Invalid exposedFields.${name5}`);
126113
126121
  if (exposed.media === true) unsupported9("contentSelector.exposedFields.media");
126114
126122
  const unsupportedFields = { content: ["structure", "topics", "trackers", "trackerOccurrences", "pointsOfInterest", "brief", "outline", "highlights", "callOutcome", "keyPoints"], interaction: ["speakers", "video", "personInteractionStats", "questions"], collaboration: ["publicComments"] };
126115
126123
  for (const [name5, allowed2] of Object.entries(unsupportedFields)) if (exposed[name5] !== void 0) {
126116
- const fields11 = object10(exposed[name5], `exposedFields.${name5}`);
126124
+ const fields11 = object11(exposed[name5], `exposedFields.${name5}`);
126117
126125
  keys4(fields11, allowed2, `exposedFields.${name5}`);
126118
126126
  for (const [field5, requested2] of Object.entries(fields11)) {
126119
126127
  if (typeof requested2 !== "boolean") throw new GongError(400, `Invalid exposedFields.${name5}.${field5}`);
@@ -126143,7 +126151,7 @@ function extensive(call2, selected2) {
126143
126151
  }
126144
126152
  function post2(c, raw3, allowed2) {
126145
126153
  query7(c, []);
126146
- const value4 = object10(raw3, "body");
126154
+ const value4 = object11(raw3, "body");
126147
126155
  keys4(value4, allowed2, "body");
126148
126156
  return value4;
126149
126157
  }
@@ -134251,8 +134259,8 @@ var docs = (code2) => `https://stripe.com/docs/error-codes/${code2.replace(/_/g,
134251
134259
  function invalid13(message7, param4, code2) {
134252
134260
  throw new StripeError(400, "invalid_request_error", message7, { ...code2 && { code: code2, doc_url: docs(code2) }, ...param4 && { param: param4 } });
134253
134261
  }
134254
- function missing2(object17, id14, param4 = "id", detail3 = "") {
134255
- throw new StripeError(404, "invalid_request_error", `No such ${object17}: '${id14}'${detail3}`, { code: "resource_missing", doc_url: docs("resource_missing"), param: param4 });
134262
+ function missing2(object18, id14, param4 = "id", detail3 = "") {
134263
+ throw new StripeError(404, "invalid_request_error", `No such ${object18}: '${id14}'${detail3}`, { code: "resource_missing", doc_url: docs("resource_missing"), param: param4 });
134256
134264
  }
134257
134265
  function unsupported14(what) {
134258
134266
  throw new StripeError(501, "api_error", `ancha: not implemented: ${what}`, {}, true);
@@ -134278,7 +134286,7 @@ function oneOf(value4, param4, values2) {
134278
134286
  if (typeof value4 !== "string" || !values2.includes(value4)) invalid13(`Invalid ${param4}: must be one of ${values2.slice(0, -1).join(", ")}, or ${values2[values2.length - 1]}`, param4);
134279
134287
  return value4;
134280
134288
  }
134281
- function object11(value4, param4, allowed2) {
134289
+ function object12(value4, param4, allowed2) {
134282
134290
  if (value4 === void 0 || value4 === "") return void 0;
134283
134291
  if (typeof value4 !== "object" || Array.isArray(value4)) invalid13(`Invalid object: ${param4}`, param4);
134284
134292
  for (const key4 of Object.keys(value4)) if (!allowed2.includes(key4)) unsupported14(`parameter ${param4}[${key4}]`);
@@ -134311,7 +134319,7 @@ function range(value4, param4) {
134311
134319
  const n2 = int2(value4, param4);
134312
134320
  return (x) => x === n2;
134313
134321
  }
134314
- const bounds = object11(value4, param4, ["gt", "gte", "lt", "lte"]);
134322
+ const bounds = object12(value4, param4, ["gt", "gte", "lt", "lte"]);
134315
134323
  const b = Object.fromEntries(Object.entries(bounds).map(([k, v]) => [k, int2(v, `${param4}[${k}]`)]));
134316
134324
  return (x) => (b.gt === void 0 || x > b.gt) && (b.gte === void 0 || x >= b.gte) && (b.lt === void 0 || x < b.lt) && (b.lte === void 0 || x <= b.lte);
134317
134325
  }
@@ -135295,7 +135303,7 @@ function customFields(value4) {
135295
135303
  if (value4 === void 0) return void 0;
135296
135304
  if (value4 === "") return null;
135297
135305
  const fields11 = list10(value4, "custom_fields").map((f2, i) => {
135298
- const field5 = object11(f2, `custom_fields[${i}]`, ["name", "value"]);
135306
+ const field5 = object12(f2, `custom_fields[${i}]`, ["name", "value"]);
135299
135307
  const name5 = str(field5.name, `custom_fields[${i}][name]`, 40), v = str(field5.value, `custom_fields[${i}][value]`, 140);
135300
135308
  if (!name5 || !v) invalid13("Each custom field needs a name and a value.", `custom_fields[${i}]`);
135301
135309
  return { name: name5, value: v };
@@ -135319,7 +135327,7 @@ function customerFields(r2, c) {
135319
135327
  }
135320
135328
  if ("preferred_locales" in p2) c.preferred_locales = (list10(p2.preferred_locales, "preferred_locales") ?? []).map((l, i) => str(l, `preferred_locales[${i}]`));
135321
135329
  c.metadata = mergeMetadata(c.metadata, p2.metadata);
135322
- const settings = object11(p2.invoice_settings, "invoice_settings", ["default_payment_method"]);
135330
+ const settings = object12(p2.invoice_settings, "invoice_settings", ["default_payment_method"]);
135323
135331
  if (p2.payment_method !== void 0) {
135324
135332
  const pm = resolvePaymentMethod(r2.ctx, str(p2.payment_method, "payment_method"), c);
135325
135333
  save6(r2.ctx, { ...pm, customer: c.id });
@@ -135400,7 +135408,7 @@ var stripeRoutes = [
135400
135408
  if (proration === "always_invoice") unsupported14("proration_behavior=always_invoice");
135401
135409
  sub2.metadata = mergeMetadata(sub2.metadata, r2.params.metadata);
135402
135410
  if ("description" in r2.params) sub2.description = str(r2.params.description, "description", 500) || null;
135403
- const details = object11(r2.params.cancellation_details, "cancellation_details", ["comment", "feedback"]);
135411
+ const details = object12(r2.params.cancellation_details, "cancellation_details", ["comment", "feedback"]);
135404
135412
  if (details) sub2.cancellation_details = {
135405
135413
  ...sub2.cancellation_details,
135406
135414
  ...details.comment !== void 0 && { comment: str(details.comment, "cancellation_details[comment]") || null },
@@ -135412,7 +135420,7 @@ var stripeRoutes = [
135412
135420
  if (changes) {
135413
135421
  const now11 = nowSeconds(r2.ctx);
135414
135422
  changes.forEach((value4, i) => {
135415
- const change3 = object11(value4, `items[${i}]`, ["id", "price", "quantity", "deleted", "metadata"]);
135423
+ const change3 = object12(value4, `items[${i}]`, ["id", "price", "quantity", "deleted", "metadata"]);
135416
135424
  const id14 = str(change3.id, `items[${i}][id]`), priceId = str(change3.price, `items[${i}][price]`), quantity = int2(change3.quantity, `items[${i}][quantity]`), remove5 = bool3(change3.deleted, `items[${i}][deleted]`);
135417
135425
  if (quantity !== void 0 && quantity < 0) invalid13("Invalid quantity: must be greater than or equal to 0", `items[${i}][quantity]`);
135418
135426
  const newPrice = priceId ? find4(r2.ctx, "price", priceId) : void 0;
@@ -135454,7 +135462,7 @@ var stripeRoutes = [
135454
135462
  if (sub2.status === "canceled") invalid13("A canceled subscription can only update its cancellation_details and metadata.");
135455
135463
  if (bool3(r2.params.invoice_now, "invoice_now")) unsupported14("cancel with invoice_now=true");
135456
135464
  if (bool3(r2.params.prorate, "prorate")) unsupported14("cancel with prorate=true");
135457
- const details = object11(r2.params.cancellation_details, "cancellation_details", ["comment", "feedback"]);
135465
+ const details = object12(r2.params.cancellation_details, "cancellation_details", ["comment", "feedback"]);
135458
135466
  const at3 = nowSeconds(r2.ctx);
135459
135467
  Object.assign(sub2, {
135460
135468
  status: "canceled",
@@ -135542,7 +135550,7 @@ var stripeRoutes = [
135542
135550
  const p2 = r2.params;
135543
135551
  if (p2.customer === void 0) invalid13("Missing required param: customer.", "customer", "parameter_missing");
135544
135552
  const c = liveCustomer(r2.ctx, str(p2.customer, "customer"));
135545
- const pricing = object11(p2.pricing, "pricing", ["price"]);
135553
+ const pricing = object12(p2.pricing, "pricing", ["price"]);
135546
135554
  const price3 = pricing?.price !== void 0 ? find4(r2.ctx, "price", str(pricing.price, "pricing[price]")) : null;
135547
135555
  const amount3 = int2(p2.amount, "amount"), quantity = int2(p2.quantity, "quantity") ?? 1;
135548
135556
  if (price3 && amount3 !== void 0) invalid13("You may only specify one of these parameters: amount, pricing[price].", "amount");
@@ -135553,7 +135561,7 @@ var stripeRoutes = [
135553
135561
  const inv = p2.invoice !== void 0 ? find4(r2.ctx, "invoice", str(p2.invoice, "invoice")) : null;
135554
135562
  if (inv && inv.customer !== c.id) invalid13(`The invoice ${inv.id} belongs to a different customer.`, "invoice");
135555
135563
  if (inv && inv.status !== "draft") invalid13(`You can only add invoice items to draft invoices; ${inv.id} is ${inv.status}.`, "invoice", "invoice_not_editable");
135556
- const periodValue = object11(p2.period, "period", ["start", "end"]);
135564
+ const periodValue = object12(p2.period, "period", ["start", "end"]);
135557
135565
  const now11 = nowSeconds(r2.ctx), period2 = periodValue ? { start: int2(periodValue.start, "period[start]"), end: int2(periodValue.end, "period[end]") } : { start: now11, end: now11 };
135558
135566
  const item2 = save6(r2.ctx, invoiceItem(r2.ctx, {
135559
135567
  customer: c.id,
@@ -135594,7 +135602,7 @@ var stripeRoutes = [
135594
135602
  const c = p2.customer !== void 0 ? liveCustomer(r2.ctx, str(p2.customer, "customer")) : null;
135595
135603
  const types = list10(p2.payment_method_types, "payment_method_types")?.map((t, i) => str(t, `payment_method_types[${i}]`));
135596
135604
  if (types && types.some((t) => t !== "card")) unsupported14(`payment_method_types other than card (${types.join(", ")})`);
135597
- const auto = object11(p2.automatic_payment_methods, "automatic_payment_methods", ["enabled", "allow_redirects"]);
135605
+ const auto = object12(p2.automatic_payment_methods, "automatic_payment_methods", ["enabled", "allow_redirects"]);
135598
135606
  bool3(p2.off_session, "off_session");
135599
135607
  const pm = p2.payment_method !== void 0 ? resolvePaymentMethod(r2.ctx, str(p2.payment_method, "payment_method"), c) : void 0;
135600
135608
  const pi = save6(r2.ctx, paymentIntent(r2.ctx, {
@@ -136084,11 +136092,11 @@ function balance(ctx, args) {
136084
136092
  function unchanged(ctx, args) {
136085
136093
  const baseline = account5(ctx).__baseline;
136086
136094
  if (baseline === void 0) throw new AnchaError("USAGE", "Stripe seed baseline is absent from this checkpoint", { hint: "create a fresh world to evaluate stripe.unchanged" });
136087
- const changes = args.objects.flatMap((object17) => {
136088
- const row2 = resolve4(ctx, object17.type, object17.id);
136095
+ const changes = args.objects.flatMap((object18) => {
136096
+ const row2 = resolve4(ctx, object18.type, object18.id);
136089
136097
  const before = row2 && baseline?.[row2.id];
136090
136098
  const reason2 = !row2 ? "object absent" : !before ? "seed baseline absent" : !isDeepStrictEqual(present(row2), before) ? "object changed" : void 0;
136091
- return reason2 ? [{ ...object17, reason: reason2 }] : [];
136099
+ return reason2 ? [{ ...object18, reason: reason2 }] : [];
136092
136100
  });
136093
136101
  return checkOutcome(changes.length === 0, `objects unchanged from seed: ${JSON.stringify(args.objects)}`, changes.length ? JSON.stringify(changes) : "all named objects equal their seed state");
136094
136102
  }
@@ -139527,14 +139535,14 @@ function writeAll(r2, parentId, attributes2, values2, mode, objectSlug) {
139527
139535
  if (attr.is_required && !currentValues(r2.ctx, parentId, attr.id).length) invalid17(`Required value for attribute with slug "${attr.api_slug}" was not provided.`, "missing_value");
139528
139536
  }
139529
139537
  }
139530
- function findRecord(r2, object17) {
139538
+ function findRecord(r2, object18) {
139531
139539
  const id14 = r2.param("record_id");
139532
- return one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", id14, object17.id) ?? notFound9(`Record with ID "${id14}" not found.`);
139540
+ return one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", id14, object18.id) ?? notFound9(`Record with ID "${id14}" not found.`);
139533
139541
  }
139534
- function createRecord3(r2, object17, values2) {
139542
+ function createRecord3(r2, object18, values2) {
139535
139543
  const id14 = uuid9(r2.ctx);
139536
- run2(r2.ctx, "INSERT INTO attio_records (id, object_id, created_at, created_by) VALUES (?, ?, ?, ?)", id14, object17.id, now5(r2.ctx), JSON.stringify(tokenActor(r2)));
139537
- writeAll(r2, id14, attributesOf(r2.ctx, object17.id), values2, "create", object17.api_slug);
139544
+ run2(r2.ctx, "INSERT INTO attio_records (id, object_id, created_at, created_by) VALUES (?, ?, ?, ?)", id14, object18.id, now5(r2.ctx), JSON.stringify(tokenActor(r2)));
139545
+ writeAll(r2, id14, attributesOf(r2.ctx, object18.id), values2, "create", object18.api_slug);
139538
139546
  return one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ?", id14);
139539
139547
  }
139540
139548
  function query8(r2, rows7, attributes2) {
@@ -139570,7 +139578,7 @@ function query8(r2, rows7, attributes2) {
139570
139578
  const { limit, offset: offset17 } = limitOffset(r2.body);
139571
139579
  return kept.slice(offset17, offset17 + limit);
139572
139580
  }
139573
- var records = (r2, object17) => all5(r2.ctx, "SELECT * FROM attio_records WHERE object_id = ? ORDER BY created_at, rowid", object17.id);
139581
+ var records = (r2, object18) => all5(r2.ctx, "SELECT * FROM attio_records WHERE object_id = ? ORDER BY created_at, rowid", object18.id);
139574
139582
  function memberRef(r2, value4) {
139575
139583
  const key4 = value4?.referenced_actor_id ?? value4?.workspace_member_email_address;
139576
139584
  const m = typeof key4 === "string" ? one2(r2.ctx, "SELECT * FROM attio_members WHERE id = ? OR lower(email) = lower(?)", key4, key4) : void 0;
@@ -139580,10 +139588,10 @@ function memberRef(r2, value4) {
139580
139588
  function linkedRecords(r2, value4) {
139581
139589
  if (!Array.isArray(value4)) invalid17("linked_records must be an array.");
139582
139590
  return value4.map((l) => {
139583
- const object17 = findObject(r2.ctx, String(l?.target_object));
139591
+ const object18 = findObject(r2.ctx, String(l?.target_object));
139584
139592
  if (!l.target_record_id) unsupported18("linking tasks to records by a matching attribute");
139585
- const record9 = one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", l.target_record_id, object17.id) ?? notFound9(`Record with ID "${l.target_record_id}" not found.`);
139586
- return { target_object_id: object17.id, target_record_id: record9.id };
139593
+ const record9 = one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", l.target_record_id, object18.id) ?? notFound9(`Record with ID "${l.target_record_id}" not found.`);
139594
+ return { target_object_id: object18.id, target_record_id: record9.id };
139587
139595
  });
139588
139596
  }
139589
139597
  var deadline = (value4) => {
@@ -139626,8 +139634,8 @@ var attioRoutes = [
139626
139634
  path: "/v2/objects/:object/records/query",
139627
139635
  coverage: { status: "partial", notes: "filter shorthand, operators, value properties, $and/$or/$not; sorts by attribute; path filters through references are gaps" },
139628
139636
  run: (r2) => {
139629
- const object17 = findObject(r2.ctx, r2.param("object"));
139630
- return { data: query8(r2, records(r2, object17), attributesOf(r2.ctx, object17.id)).map((rec) => recordShape(r2.ctx, rec)) };
139637
+ const object18 = findObject(r2.ctx, r2.param("object"));
139638
+ return { data: query8(r2, records(r2, object18), attributesOf(r2.ctx, object18.id)).map((rec) => recordShape(r2.ctx, rec)) };
139631
139639
  }
139632
139640
  },
139633
139641
  {
@@ -139644,10 +139652,10 @@ var attioRoutes = [
139644
139652
  data: { known: ["values"], supported: ["values"] },
139645
139653
  coverage: { status: "partial", notes: "assert by a unique attribute: updates the match (appending to multiselect values) or creates a record" },
139646
139654
  run: (r2) => {
139647
- const object17 = findObject(r2.ctx, r2.param("object"));
139655
+ const object18 = findObject(r2.ctx, r2.param("object"));
139648
139656
  const slug10 = r2.query.get("matching_attribute");
139649
139657
  if (!slug10) invalid17("The matching_attribute query parameter is required.", "missing_value");
139650
- const attr = attributesOf(r2.ctx, object17.id).find((a) => a.api_slug === slug10 || a.id === slug10);
139658
+ const attr = attributesOf(r2.ctx, object18.id).find((a) => a.api_slug === slug10 || a.id === slug10);
139651
139659
  if (!attr) invalid17(`Cannot find attribute with slug/ID "${slug10}".`, "value_not_found");
139652
139660
  if (!attr.is_unique) invalid17(`Attribute with slug "${attr.api_slug}" is not unique and cannot be used to match records.`);
139653
139661
  const given2 = (r2.data.values ?? {})[attr.api_slug] ?? (r2.data.values ?? {})[attr.id];
@@ -139655,9 +139663,9 @@ var attioRoutes = [
139655
139663
  const wanted = (Array.isArray(given2) ? given2 : [given2]).map((v) => primary(r2.ctx, attr, parseValue(r2.ctx, attr, v)));
139656
139664
  const owners = new Set(all5(r2.ctx, "SELECT * FROM attio_values WHERE attribute_id = ? AND active_until IS NULL", attr.id).filter((v) => wanted.includes(primary(r2.ctx, attr, JSON.parse(v.data)))).map((v) => v.parent_id));
139657
139665
  if (owners.size > 1) invalid17("More than one record matches the given value.", "multiple_match_results");
139658
- if (!owners.size) return { data: recordShape(r2.ctx, createRecord3(r2, object17, r2.data.values)) };
139666
+ if (!owners.size) return { data: recordShape(r2.ctx, createRecord3(r2, object18, r2.data.values)) };
139659
139667
  const id14 = [...owners][0];
139660
- writeAll(r2, id14, attributesOf(r2.ctx, object17.id), r2.data.values, "append", object17.api_slug);
139668
+ writeAll(r2, id14, attributesOf(r2.ctx, object18.id), r2.data.values, "append", object18.api_slug);
139661
139669
  return { data: recordShape(r2.ctx, one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ?", id14)) };
139662
139670
  }
139663
139671
  },
@@ -139668,8 +139676,8 @@ var attioRoutes = [
139668
139676
  data: { known: ["values"], supported: ["values"] },
139669
139677
  coverage: { status: "supported", notes: "multiselect values are added to" },
139670
139678
  run: (r2) => {
139671
- const object17 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object17);
139672
- writeAll(r2, rec.id, attributesOf(r2.ctx, object17.id), r2.data.values, "append", object17.api_slug);
139679
+ const object18 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object18);
139680
+ writeAll(r2, rec.id, attributesOf(r2.ctx, object18.id), r2.data.values, "append", object18.api_slug);
139673
139681
  return { data: recordShape(r2.ctx, rec) };
139674
139682
  }
139675
139683
  },
@@ -139679,8 +139687,8 @@ var attioRoutes = [
139679
139687
  data: { known: ["values"], supported: ["values"] },
139680
139688
  coverage: { status: "supported", notes: "multiselect values are replaced" },
139681
139689
  run: (r2) => {
139682
- const object17 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object17);
139683
- writeAll(r2, rec.id, attributesOf(r2.ctx, object17.id), r2.data.values, "replace", object17.api_slug);
139690
+ const object18 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object18);
139691
+ writeAll(r2, rec.id, attributesOf(r2.ctx, object18.id), r2.data.values, "replace", object18.api_slug);
139684
139692
  return { data: recordShape(r2.ctx, rec) };
139685
139693
  }
139686
139694
  },
@@ -139700,8 +139708,8 @@ var attioRoutes = [
139700
139708
  query: { known: ["show_historic", "limit", "offset"], supported: ["show_historic", "limit", "offset"] },
139701
139709
  coverage: { status: "supported" },
139702
139710
  run: (r2) => {
139703
- const object17 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object17);
139704
- const attr = attributesOf(r2.ctx, object17.id).find((a) => a.api_slug === r2.param("attribute") || a.id === r2.param("attribute")) ?? notFound9(`Attribute with slug/ID "${r2.param("attribute")}" not found.`);
139711
+ const object18 = findObject(r2.ctx, r2.param("object")), rec = findRecord(r2, object18);
139712
+ const attr = attributesOf(r2.ctx, object18.id).find((a) => a.api_slug === r2.param("attribute") || a.id === r2.param("attribute")) ?? notFound9(`Attribute with slug/ID "${r2.param("attribute")}" not found.`);
139705
139713
  const historic = r2.query.get("show_historic") === "true";
139706
139714
  const rows7 = all5(r2.ctx, `SELECT * FROM attio_values WHERE parent_id = ? AND attribute_id = ? ${historic ? "" : "AND active_until IS NULL"} ORDER BY id`, rec.id, attr.id);
139707
139715
  const { limit, offset: offset17 } = limitOffset({ limit: r2.query.get("limit") ?? void 0, offset: r2.query.get("offset") ?? void 0 });
@@ -139737,9 +139745,9 @@ var attioRoutes = [
139737
139745
  coverage: { status: "supported" },
139738
139746
  run: (r2) => {
139739
139747
  const list16 = findList(r2.ctx, r2.param("list"));
139740
- const object17 = findObject(r2.ctx, String(r2.data.parent_object ?? list16.parent_object));
139741
- if (object17.api_slug !== list16.parent_object) invalid17(`The list "${list16.api_slug}" holds ${list16.parent_object} records, not ${object17.api_slug}.`);
139742
- const rec = one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", r2.data.parent_record_id, object17.id) ?? notFound9(`Record with ID "${r2.data.parent_record_id}" not found.`);
139748
+ const object18 = findObject(r2.ctx, String(r2.data.parent_object ?? list16.parent_object));
139749
+ if (object18.api_slug !== list16.parent_object) invalid17(`The list "${list16.api_slug}" holds ${list16.parent_object} records, not ${object18.api_slug}.`);
139750
+ const rec = one2(r2.ctx, "SELECT * FROM attio_records WHERE id = ? AND object_id = ?", r2.data.parent_record_id, object18.id) ?? notFound9(`Record with ID "${r2.data.parent_record_id}" not found.`);
139743
139751
  const id14 = uuid9(r2.ctx);
139744
139752
  run2(r2.ctx, "INSERT INTO attio_entries (id, list_id, record_id, created_at) VALUES (?, ?, ?, ?)", id14, list16.id, rec.id, now5(r2.ctx));
139745
139753
  writeAll(r2, id14, attributesOf(r2.ctx, listParent(list16)), r2.data.entry_values ?? {}, "create");
@@ -139779,8 +139787,8 @@ var attioRoutes = [
139779
139787
  query: { known: ["limit", "offset", "parent_object", "parent_record_id"], supported: ["limit", "offset", "parent_object", "parent_record_id"] },
139780
139788
  coverage: { status: "supported" },
139781
139789
  run: (r2) => {
139782
- const object17 = r2.query.get("parent_object"), record9 = r2.query.get("parent_record_id");
139783
- const objectSlug = object17 ? findObject(r2.ctx, object17).api_slug : void 0;
139790
+ const object18 = r2.query.get("parent_object"), record9 = r2.query.get("parent_record_id");
139791
+ const objectSlug = object18 ? findObject(r2.ctx, object18).api_slug : void 0;
139784
139792
  const notes6 = all5(r2.ctx, "SELECT * FROM attio_notes ORDER BY created_at, rowid").filter((n2) => (!objectSlug || n2.parent_object === objectSlug) && (!record9 || n2.parent_record_id === record9));
139785
139793
  const { limit, offset: offset17 } = limitOffset({ limit: r2.query.get("limit") ?? void 0, offset: r2.query.get("offset") ?? void 0 }, 10);
139786
139794
  return { data: notes6.slice(offset17, offset17 + limit).map((n2) => noteShape2(r2.ctx, n2)) };
@@ -139795,14 +139803,14 @@ var attioRoutes = [
139795
139803
  const d = r2.data;
139796
139804
  for (const key4 of ["parent_object", "parent_record_id", "title", "format", "content"]) if (typeof d[key4] !== "string") invalid17(`Body payload validation error: "data.${key4}" is required.`, "missing_value");
139797
139805
  if (d.format !== "plaintext" && d.format !== "markdown") invalid17('format must be "plaintext" or "markdown".');
139798
- const object17 = findObject(r2.ctx, d.parent_object);
139799
- if (!one2(r2.ctx, "SELECT 1 FROM attio_records WHERE id = ? AND object_id = ?", d.parent_record_id, object17.id)) notFound9(`Record with ID "${d.parent_record_id}" not found.`);
139806
+ const object18 = findObject(r2.ctx, d.parent_object);
139807
+ if (!one2(r2.ctx, "SELECT 1 FROM attio_records WHERE id = ? AND object_id = ?", d.parent_record_id, object18.id)) notFound9(`Record with ID "${d.parent_record_id}" not found.`);
139800
139808
  const id14 = uuid9(r2.ctx);
139801
139809
  run2(
139802
139810
  r2.ctx,
139803
139811
  "INSERT INTO attio_notes (id, parent_object, parent_record_id, title, content, created_by, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)",
139804
139812
  id14,
139805
- object17.api_slug,
139813
+ object18.api_slug,
139806
139814
  d.parent_record_id,
139807
139815
  d.title,
139808
139816
  d.content,
@@ -142910,7 +142918,7 @@ var requireFolder = (ctx, mail, key4) => {
142910
142918
  if (!f2) throw missing4();
142911
142919
  return f2;
142912
142920
  };
142913
- var object12 = (value4) => !!value4 && typeof value4 === "object" && !Array.isArray(value4);
142921
+ var object13 = (value4) => !!value4 && typeof value4 === "object" && !Array.isArray(value4);
142914
142922
  function input3(value4, mail) {
142915
142923
  const result = OutlookMessageInputSchema.safeParse(value4);
142916
142924
  if (!result.success) throw invalid20("The request body contains an invalid message property or value.");
@@ -142944,7 +142952,7 @@ function send(ctx, mail, draft2, keep = true) {
142944
142952
  }
142945
142953
  function responseDraft(ctx, mail, original, action, body6) {
142946
142954
  if (body6.comment !== void 0 && (typeof body6.comment !== "string" || body6.message?.body !== void 0)) throw invalid20("Specify either comment or message.body, but not both.");
142947
- if (body6.message !== void 0 && !object12(body6.message)) throw invalid20("message must be an object.");
142955
+ if (body6.message !== void 0 && !object13(body6.message)) throw invalid20("message must be an object.");
142948
142956
  if (body6.toRecipients !== void 0 && !OutlookMessageInputSchema.shape.toRecipients.safeParse(body6.toRecipients).success) throw invalid20("Invalid toRecipients.");
142949
142957
  if (Object.keys(body6).some((k) => !["comment", "message", "toRecipients"].includes(k))) throw invalid20("Invalid message action parameter.");
142950
142958
  const content2 = input3(body6.message ?? {}, mail), forwarding = action.toLowerCase().includes("forward"), all9 = action.toLowerCase().includes("replyall");
@@ -142994,7 +143002,7 @@ function attachmentRoute(ctx, mail, m, tail, method2, url4, headers, body6) {
142994
143002
  }
142995
143003
  if (tail[0] === "createUploadSession" && method2 === "POST") {
142996
143004
  const item2 = body6.AttachmentItem;
142997
- if (!object12(item2) || item2.attachmentType !== "file" || typeof item2.name !== "string" || !Number.isInteger(item2.size) || item2.size < 3 * 1024 * 1024 || item2.size > 150 * 1024 * 1024) throw invalid20("AttachmentItem must describe a file between 3 MB and 150 MB.");
143005
+ if (!object13(item2) || item2.attachmentType !== "file" || typeof item2.name !== "string" || !Number.isInteger(item2.size) || item2.size < 3 * 1024 * 1024 || item2.size > 150 * 1024 * 1024) throw invalid20("AttachmentItem must describe a file between 3 MB and 150 MB.");
142998
143006
  const id14 = ctx.secrets.hex(64), expiry = ctx.clock.nowMs() + 60 * 60 * 1e3;
142999
143007
  ctx.store.db.prepare("INSERT INTO outlook_uploads VALUES (?, ?, ?, ?, ?)").run(id14, mail, m.id, JSON.stringify({ ...item2, expiry }), Buffer.alloc(0));
143000
143008
  return json18({ "@odata.context": context2("microsoft.graph.uploadSession"), uploadUrl: `${ctx.serviceUrl}/upload/${id14}`, expirationDateTime: new Date(expiry).toISOString(), nextExpectedRanges: ["0-"] }, 201);
@@ -143097,7 +143105,7 @@ function route4(ctx, method2, url4, headers, body6, auth = "delegated") {
143097
143105
  const mail = user8.email, resource2 = `users('${user8.id}')`;
143098
143106
  if (!parts3.length && method2 === "GET") return json18({ "@odata.context": context2("users/$entity"), ...project9({ id: user8.id, displayName: user8.name, mail, userPrincipalName: mail, jobTitle: null }, url4, headers) });
143099
143107
  if (parts3[0] === "sendMail" && method2 === "POST") {
143100
- if (!object12(body6.message) || body6.saveToSentItems !== void 0 && typeof body6.saveToSentItems !== "boolean") throw invalid20("A message and a boolean saveToSentItems value are required.");
143108
+ if (!object13(body6.message) || body6.saveToSentItems !== void 0 && typeof body6.saveToSentItems !== "boolean") throw invalid20("A message and a boolean saveToSentItems value are required.");
143101
143109
  const m2 = create2(ctx, mail, input3(body6.message, mail));
143102
143110
  save8(ctx, mail, m2);
143103
143111
  send(ctx, mail, m2, body6.saveToSentItems !== false);
@@ -146362,22 +146370,22 @@ function jsonParameter(value4, field5) {
146362
146370
  }
146363
146371
  function metadataOf(value4, prefix2 = "") {
146364
146372
  if (value4 === void 0 || value4 === null || value4 === "") return {};
146365
- const object17 = jsonParameter(value4, `${prefix2}metadata`);
146366
- if (!isObject3(object17)) throw invalid21(`${prefix2}metadata must be an object`);
146367
- const entries3 = Object.entries(object17);
146373
+ const object18 = jsonParameter(value4, `${prefix2}metadata`);
146374
+ if (!isObject3(object18)) throw invalid21(`${prefix2}metadata must be an object`);
146375
+ const entries3 = Object.entries(object18);
146368
146376
  if (entries3.length > 20) throw invalid21(`${prefix2}metadata must have less than or equal to 20 keys`);
146369
146377
  for (const [key4, item2] of entries3) {
146370
146378
  if (key4.length > 40 || /["\\]/.test(key4)) throw invalid21(`${prefix2}metadata keys must be at most 40 characters and cannot contain " or \\`);
146371
146379
  if (typeof item2 !== "string" || item2.length > 500 || /["\\]/.test(item2)) throw invalid21(`${prefix2}metadata.${key4} must be a string of at most 500 characters without " or \\`);
146372
146380
  }
146373
- return object17;
146381
+ return object18;
146374
146382
  }
146375
146383
  function mergeVariablesOf(value4) {
146376
146384
  if (value4 === void 0 || value4 === null || value4 === "") return null;
146377
- const object17 = jsonParameter(value4, "merge_variables");
146378
- if (!isObject3(object17)) throw invalid21("merge_variables must be an object");
146379
- if (JSON.stringify(object17).length > 25e3) throw invalid21("merge_variables must be at most 25,000 characters");
146380
- return object17;
146385
+ const object18 = jsonParameter(value4, "merge_variables");
146386
+ if (!isObject3(object18)) throw invalid21("merge_variables must be an object");
146387
+ if (JSON.stringify(object18).length > 25e3) throw invalid21("merge_variables must be at most 25,000 characters");
146388
+ return object18;
146381
146389
  }
146382
146390
  var ADDRESS_FIELDS = ["description", "name", "company", "phone", "email", "address_line1", "address_line2", "address_city", "address_state", "address_zip", "address_country", "metadata"];
146383
146391
  function addressInput(body6, prefix2 = "") {
@@ -146444,9 +146452,9 @@ function addressFor(call2, field5, required4) {
146444
146452
  }
146445
146453
  function rangeOf2(value4, field5) {
146446
146454
  if (value4 === void 0) return () => true;
146447
- const object17 = jsonParameter(value4, field5);
146448
- if (!isObject3(object17)) throw invalid21(`${field5} must be an object with gt, gte, lt or lte`);
146449
- const tests = Object.entries(object17).map(([operator2, raw3]) => {
146455
+ const object18 = jsonParameter(value4, field5);
146456
+ if (!isObject3(object18)) throw invalid21(`${field5} must be an object with gt, gte, lt or lte`);
146457
+ const tests = Object.entries(object18).map(([operator2, raw3]) => {
146450
146458
  if (!["gt", "gte", "lt", "lte"].includes(operator2)) throw invalid21(`${field5}.${operator2} is not allowed`);
146451
146459
  const ms = typeof raw3 === "string" ? Date.parse(raw3) : Number.NaN;
146452
146460
  if (Number.isNaN(ms)) throw invalid21(`${field5}.${operator2} must be a valid ISO 8601 date`);
@@ -147239,7 +147247,7 @@ function unknownRoute13(c) {
147239
147247
  }
147240
147248
 
147241
147249
  // packages/server/src/twins/paypal/invoices.ts
147242
- var object13 = (v, field5) => {
147250
+ var object14 = (v, field5) => {
147243
147251
  if (!v || typeof v !== "object" || Array.isArray(v)) invalid22({ field: field5, issue: "INVALID_PARAMETER_SYNTAX", description: "Expected an object.", location: "body" });
147244
147252
  return v;
147245
147253
  };
@@ -147256,7 +147264,7 @@ function decimal3(v, field5) {
147256
147264
  return n2;
147257
147265
  }
147258
147266
  function money10(v, currency, field5) {
147259
- const m = object13(v, field5);
147267
+ const m = object14(v, field5);
147260
147268
  keys5(m, ["currency_code", "value"], field5);
147261
147269
  if (m.currency_code !== currency) refused("CURRENCY_MISMATCH", "Currency must match the invoice currency.", `${field5}/currency_code`);
147262
147270
  return decimal3(m.value, `${field5}/value`);
@@ -147268,31 +147276,31 @@ var rounded = (a, b, denominator) => {
147268
147276
  return result;
147269
147277
  };
147270
147278
  function invoiceFrom(ctx, body6) {
147271
- const b = object13(body6, "/");
147279
+ const b = object14(body6, "/");
147272
147280
  keys5(b, ["detail", "invoicer", "primary_recipients", "items", "configuration"], "invoice");
147273
- const detail3 = object13(b.detail, "/detail");
147281
+ const detail3 = object14(b.detail, "/detail");
147274
147282
  keys5(detail3, ["currency_code", "invoice_number", "reference", "note", "terms_and_conditions", "memo"], "/detail");
147275
147283
  const currency = detail3.currency_code;
147276
147284
  if (!["USD", "EUR", "GBP", "CAD", "AUD"].includes(currency)) unsupported23(`invoice currency ${String(currency)}`);
147277
147285
  for (const key4 of ["invoice_number", "reference", "note", "terms_and_conditions", "memo"]) if (detail3[key4] !== void 0) text21(detail3[key4], `/detail/${key4}`, key4 === "invoice_number" ? 25 : 4e3);
147278
147286
  if (detail3.invoice_number && allOf2(ctx, "invoice").some((i) => i.detail.invoice_number === detail3.invoice_number)) refused("DUPLICATE_INVOICE_NUMBER", "Invoice number must be unique.", "/detail/invoice_number");
147279
147287
  if (b.configuration !== void 0) {
147280
- const c = object13(b.configuration, "/configuration");
147288
+ const c = object14(b.configuration, "/configuration");
147281
147289
  keys5(c, ["tax_calculated_after_discount", "tax_inclusive"], "/configuration");
147282
147290
  if (c.tax_calculated_after_discount !== void 0 && c.tax_calculated_after_discount !== true) unsupported23("configuration.tax_calculated_after_discount=false");
147283
147291
  if (c.tax_inclusive !== void 0 && c.tax_inclusive !== false) unsupported23("configuration.tax_inclusive=true");
147284
147292
  }
147285
147293
  const contact = (v, field5) => {
147286
- const c = object13(v, field5);
147294
+ const c = object14(v, field5);
147287
147295
  keys5(c, ["name", "email_address", "address", "business_name"], field5);
147288
147296
  if (c.email_address !== void 0 && (typeof c.email_address !== "string" || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c.email_address))) invalid22({ field: `${field5}/email_address`, issue: "INVALID_PARAMETER_VALUE", description: "Invalid email address." });
147289
147297
  if (c.name !== void 0) {
147290
- const n2 = object13(c.name, `${field5}/name`);
147298
+ const n2 = object14(c.name, `${field5}/name`);
147291
147299
  keys5(n2, ["given_name", "surname", "full_name"], `${field5}/name`);
147292
147300
  for (const [k, v3] of Object.entries(n2)) text21(v3, `${field5}/name/${k}`, 300);
147293
147301
  }
147294
147302
  if (c.address !== void 0) {
147295
- const a = object13(c.address, `${field5}/address`);
147303
+ const a = object14(c.address, `${field5}/address`);
147296
147304
  keys5(a, ["address_line_1", "address_line_2", "admin_area_1", "admin_area_2", "postal_code", "country_code"], `${field5}/address`);
147297
147305
  for (const [k, v3] of Object.entries(a)) text21(v3, `${field5}/address/${k}`, 300);
147298
147306
  }
@@ -147302,21 +147310,21 @@ function invoiceFrom(ctx, body6) {
147302
147310
  const invoicer = b.invoicer === void 0 ? void 0 : contact(b.invoicer, "/invoicer");
147303
147311
  if (!Array.isArray(b.primary_recipients) || b.primary_recipients.length !== 1) invalid22({ field: "/primary_recipients", issue: "INVALID_ARRAY_SIZE", description: "Supply one primary recipient." });
147304
147312
  const recipients2 = b.primary_recipients.map((raw3) => {
147305
- const r2 = object13(raw3, "/primary_recipients");
147313
+ const r2 = object14(raw3, "/primary_recipients");
147306
147314
  keys5(r2, ["billing_info"], "/primary_recipients");
147307
147315
  const billing = contact(r2.billing_info, "/primary_recipients/billing_info");
147308
147316
  return { billing_info: billing };
147309
147317
  });
147310
147318
  if (!Array.isArray(b.items) || b.items.length === 0 || b.items.length > 100) invalid22({ field: "/items", issue: "INVALID_ARRAY_SIZE", description: "Supply 1 to 100 items." });
147311
147319
  const items = b.items.map((raw3, index) => {
147312
- const path4 = `/items/${index}`, i = object13(raw3, path4);
147320
+ const path4 = `/items/${index}`, i = object14(raw3, path4);
147313
147321
  keys5(i, ["name", "description", "quantity", "unit_amount", "tax", "discount", "unit_of_measure"], path4);
147314
147322
  const name5 = text21(i.name, `${path4}/name`, 200), quantity = decimal3(i.quantity, `${path4}/quantity`);
147315
147323
  if (quantity <= 0 || quantity > 1e6) invalid22({ field: `${path4}/quantity`, issue: "INVALID_PARAMETER_VALUE", description: "Quantity must be positive and at most 10000." });
147316
147324
  const unit = money10(i.unit_amount, currency, `${path4}/unit_amount`), line2 = rounded(unit, quantity, 100);
147317
147325
  let discount = 0, tax = 0;
147318
147326
  if (i.discount !== void 0) {
147319
- const d = object13(i.discount, `${path4}/discount`);
147327
+ const d = object14(i.discount, `${path4}/discount`);
147320
147328
  keys5(d, ["percent", "amount"], `${path4}/discount`);
147321
147329
  if (d.percent === void 0 === (d.amount === void 0)) invalid22({ field: `${path4}/discount`, issue: "INVALID_PARAMETER_VALUE", description: "Supply a discount percent or amount." });
147322
147330
  if (d.percent !== void 0) {
@@ -147327,7 +147335,7 @@ function invoiceFrom(ctx, body6) {
147327
147335
  if (discount > line2) refused("INVALID_DISCOUNT", "Discount cannot exceed the item amount.");
147328
147336
  }
147329
147337
  if (i.tax !== void 0) {
147330
- const t = object13(i.tax, `${path4}/tax`);
147338
+ const t = object14(i.tax, `${path4}/tax`);
147331
147339
  keys5(t, ["name", "percent"], `${path4}/tax`);
147332
147340
  text21(t.name, `${path4}/tax/name`, 100);
147333
147341
  const percent = decimal3(t.percent, `${path4}/tax/percent`);
@@ -147398,7 +147406,7 @@ var invoiceRoutes = [
147398
147406
  return { items: all9.slice((page18 - 1) * size2, page18 * size2).map((i) => invoiceShape(i, r2.base)), ...r2.query.get("total_required") === "true" && { total_items: all9.length, total_pages: Math.ceil(all9.length / size2) } };
147399
147407
  } },
147400
147408
  { method: "POST", path: "/v2/invoicing/invoices/:id/send", coverage: { status: "partial", notes: "Send a draft invoice to its billing recipient" }, run: (r2) => {
147401
- const b = object13(r2.body, "/");
147409
+ const b = object14(r2.body, "/");
147402
147410
  keys5(b, ["send_to_recipient", "send_to_invoicer"], "/send");
147403
147411
  for (const [k, v] of Object.entries(b)) if (typeof v !== "boolean") invalid22({ field: `/${k}`, issue: "INVALID_PARAMETER_VALUE", description: "Expected a boolean." });
147404
147412
  if (b.send_to_recipient === false) unsupported23("send_to_recipient=false");
@@ -161248,10 +161256,10 @@ ${stream}endstream`);
161248
161256
  objects[0] = "<< /Type /Catalog /Pages 2 0 R >>";
161249
161257
  objects[1] = `<< /Type /Pages /Kids [${kids.join(" ")}] /Count ${pages.length} >>`;
161250
161258
  let pdf = "%PDF-1.4\n", offsets = [0];
161251
- objects.forEach((object17, i) => {
161259
+ objects.forEach((object18, i) => {
161252
161260
  offsets.push(Buffer.byteLength(pdf));
161253
161261
  pdf += `${i + 1} 0 obj
161254
- ${object17}
161262
+ ${object18}
161255
161263
  endobj
161256
161264
  `;
161257
161265
  });
@@ -163228,19 +163236,19 @@ var dependents = () => userError("This record cannot be deleted because it has d
163228
163236
  var missing6 = (label7, path4) => userError(`Please enter value(s) for: ${label7}`, path4);
163229
163237
  var permission6 = (field5, element) => new NetsuiteError(403, "INSUFFICIENT_PERMISSION", `Error while accessing a resource. You do not have permissions to set a value for element ${element} due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases.`, field5);
163230
163238
  var malformed = (path4, value4) => Object.assign(invalidValue2(path4, value4), { malformed: true });
163231
- function object14(value4, path4) {
163239
+ function object15(value4, path4) {
163232
163240
  if (value4 && typeof value4 === "object" && !Array.isArray(value4)) return value4;
163233
163241
  if (path4 !== void 0) throw malformed(path4, value4);
163234
163242
  throw new NetsuiteError(400, "INVALID_CONTENT", "The request body must be a JSON object.");
163235
163243
  }
163236
163244
  function entries2(raw3, path4) {
163237
163245
  if (raw3 === null) return [];
163238
- const list16 = object14(raw3, path4).items;
163246
+ const list16 = object15(raw3, path4).items;
163239
163247
  if (!Array.isArray(list16)) throw malformed(`${path4}.items`, list16);
163240
- return list16.map((entry2, index) => object14(entry2, `${path4}.items[${index}]`));
163248
+ return list16.map((entry2, index) => object15(entry2, `${path4}.items[${index}]`));
163241
163249
  }
163242
163250
  function refId(ctx, target5, raw3, path4) {
163243
- const ref22 = object14(raw3, path4);
163251
+ const ref22 = object15(raw3, path4);
163244
163252
  if (ref22.id !== void 0) {
163245
163253
  const id14 = typeof ref22.id === "number" ? ref22.id : typeof ref22.id === "string" && /^\d{1,10}$/.test(ref22.id) ? Number(ref22.id) : Number.NaN;
163246
163254
  if (!Number.isSafeInteger(id14) || id14 <= 0) throw malformed(path4, ref22.id);
@@ -163256,7 +163264,7 @@ function refId(ctx, target5, raw3, path4) {
163256
163264
  }
163257
163265
  var ADDRESS_KEYS = ["addressee", "attention", "addr1", "addr2", "addr3", "city", "state", "zip", "country", "addrPhone", "override"];
163258
163266
  function address7(raw3, path4, strict, warnings2) {
163259
- const given2 = object14(raw3, path4), out = {};
163267
+ const given2 = object15(raw3, path4), out = {};
163260
163268
  for (const [key4, value4] of Object.entries(given2)) {
163261
163269
  if (key4 === "links" || key4 === "addrText" || key4 === "refName") continue;
163262
163270
  if (!ADDRESS_KEYS.includes(key4)) {
@@ -164334,7 +164342,7 @@ function orderStatusChange(ctx, prior, current, requested2) {
164334
164342
  }
164335
164343
  function save12(ctx, type, id14, body6, opts = {}) {
164336
164344
  if (isBanking(type)) return saveBanking(ctx, type, id14, body6);
164337
- const input5 = object14(body6), kept = keptFields(ctx, type), given2 = /* @__PURE__ */ new Map();
164345
+ const input5 = object15(body6), kept = keptFields(ctx, type), given2 = /* @__PURE__ */ new Map();
164338
164346
  const declared = new Set(customFieldsFor(ctx, type).map((f2) => f2.id));
164339
164347
  for (const [name5, value4] of Object.entries(input5)) if (kept.has(name5) && !Object.hasOwn(FIELDS3[type], name5) && !declared.has(name5)) given2.set(name5, value4);
164340
164348
  const saved = saveModeled(ctx, type, id14, given2.size ? without(input5, ...given2.keys()) : input5, opts);
@@ -164414,7 +164422,7 @@ var headerFrom = (t) => ({
164414
164422
  ...t.class !== null && { class: { id: t.class } }
164415
164423
  });
164416
164424
  function transform2(ctx, source, id14, targetName, raw3, base4 = {}) {
164417
- const body6 = object14(raw3), target5 = netsuiteRecordTypes.find((known2) => known2.toLowerCase() === targetName.toLowerCase());
164425
+ const body6 = object15(raw3), target5 = netsuiteRecordTypes.find((known2) => known2.toLowerCase() === targetName.toLowerCase());
164418
164426
  if (!target5 || !(TRANSFORMS[source] ?? []).includes(target5)) throw gap6(`transforming a ${source} into a ${targetName}`);
164419
164427
  const opts = { ...base4, replace: void 0, replaceSelected: void 0 };
164420
164428
  const make = (type, fields11, origin) => ({ type, id: saveTransaction(ctx, type, void 0, fields11, { ...opts, ...origin && { origin } }) });
@@ -164768,15 +164776,15 @@ function match2(ctx, bankIds, gl, source) {
164768
164776
  function saveBanking(ctx, type, id14, body6) {
164769
164777
  if (type !== "transactionMatch" || id14 !== void 0) throw new NetsuiteError(405, "METHOD_NOT_ALLOWED", "Transaction matches are created once; imported bank data and suggestions are read-only.");
164770
164778
  bankPermission(ctx, 2);
164771
- const input5 = object14(body6);
164779
+ const input5 = object15(body6);
164772
164780
  for (const key4 of Object.keys(input5)) if (!["importedTransactionMatch", "generalLedgerTransactionMatch"].includes(key4)) throw new NetsuiteError(403, "INSUFFICIENT_PERMISSION", `The field ${key4} is read-only.`);
164773
164781
  const list16 = (name5) => {
164774
- const items = object14(input5[name5]).items;
164782
+ const items = object15(input5[name5]).items;
164775
164783
  if (!Array.isArray(items) || !items.length || items.length > 500) throw userError(`Provide ${name5}.items.`);
164776
- return items.map((item2) => object14(item2));
164784
+ return items.map((item2) => object15(item2));
164777
164785
  };
164778
164786
  const ref22 = (v) => {
164779
- const n2 = Number(object14(v).id);
164787
+ const n2 = Number(object15(v).id);
164780
164788
  if (!Number.isSafeInteger(n2) || n2 <= 0) throw userError("Provide a valid internal ID.");
164781
164789
  return n2;
164782
164790
  };
@@ -164798,7 +164806,7 @@ function bankingActions(ctx, id14) {
164798
164806
  function bankAction(ctx, id14, action, body6) {
164799
164807
  if (!["accept", "reject"].includes(action)) throw userError("Choose accept or reject.");
164800
164808
  bankPermission(ctx, action === "accept" ? 2 : 3);
164801
- if (Object.keys(object14(body6 ?? {})).length) throw userError("This action takes the record ID only.");
164809
+ if (Object.keys(object15(body6 ?? {})).length) throw userError("This action takes the record ID only.");
164802
164810
  const s2 = suggestion(ctx, id14), db3 = sql(ctx);
164803
164811
  if (s2.status !== "pending") throw userError("This suggestion has already been accepted or rejected.");
164804
164812
  if (action === "reject") {
@@ -170343,20 +170351,20 @@ async function mcpEndpoint(ctx, method2, text24, base4, serve3, caller2, headers
170343
170351
  }
170344
170352
  if (Array.isArray(message7)) return rpcError(null, -32600, "Invalid Request: send one JSON-RPC message per request.", 400);
170345
170353
  if (!message7 || typeof message7 !== "object" || message7.jsonrpc !== "2.0") return rpcError(null, -32600, "Invalid Request", 400);
170346
- const object17 = (value4) => !!value4 && typeof value4 === "object" && !Array.isArray(value4);
170354
+ const object18 = (value4) => !!value4 && typeof value4 === "object" && !Array.isArray(value4);
170347
170355
  if (message7.id !== void 0 && typeof message7.id !== "string" && !(typeof message7.id === "number" && Number.isInteger(message7.id))) return rpcError(null, -32600, "Invalid Request", 400);
170348
170356
  if (message7.method === void 0) {
170349
- const hasResult = object17(message7.result), hasError = object17(message7.error) && Number.isInteger(message7.error.code) && typeof message7.error.message === "string";
170357
+ const hasResult = object18(message7.result), hasError = object18(message7.error) && Number.isInteger(message7.error.code) && typeof message7.error.message === "string";
170350
170358
  if (message7.id !== void 0 && (hasResult && message7.error === void 0 || hasError && message7.result === void 0)) return { status: 202, headers: {}, body: null };
170351
170359
  return rpcError(null, -32600, "Invalid Request", 400);
170352
170360
  }
170353
170361
  if (typeof message7.method !== "string" || message7.result !== void 0 || message7.error !== void 0) return rpcError(null, -32600, "Invalid Request", 400);
170354
- if (message7.params !== void 0 && !object17(message7.params)) return rpcError(message7.id, -32602, "Invalid params", 400);
170362
+ if (message7.params !== void 0 && !object18(message7.params)) return rpcError(message7.id, -32602, "Invalid params", 400);
170355
170363
  if (message7.id === void 0) return { status: 202, headers: {}, body: null };
170356
170364
  const id14 = message7.id, params10 = message7.params ?? {};
170357
170365
  switch (message7.method) {
170358
170366
  case "initialize": {
170359
- if (typeof params10.protocolVersion !== "string" || !object17(params10.capabilities) || !object17(params10.clientInfo) || typeof params10.clientInfo.name !== "string" || typeof params10.clientInfo.version !== "string") return rpcError(id14, -32602, "initialize requires protocolVersion, capabilities and clientInfo.");
170367
+ if (typeof params10.protocolVersion !== "string" || !object18(params10.capabilities) || !object18(params10.clientInfo) || typeof params10.clientInfo.name !== "string" || typeof params10.clientInfo.version !== "string") return rpcError(id14, -32602, "initialize requires protocolVersion, capabilities and clientInfo.");
170360
170368
  const asked = params10.protocolVersion;
170361
170369
  return reply4(id14, {
170362
170370
  protocolVersion: PROTOCOLS.includes(asked) ? asked : PROTOCOLS[0],
@@ -171490,7 +171498,7 @@ function records2(ctx, method2, url4, segments3, body6, opts) {
171490
171498
  async function suiteql(ctx, url4, body6, prefer) {
171491
171499
  if (!/(^|[\s,;])transient($|[\s,;])/i.test(prefer ?? "")) throw new NetsuiteError(400, "INVALID_PARAMETER", "Invalid search query. SuiteQL requests need the header Prefer: transient.", { header: "Prefer" });
171492
171500
  params9(url4, ["limit", "offset"]);
171493
- const window5 = paging(url4), { q, params: values2 } = object14(body6);
171501
+ const window5 = paging(url4), { q, params: values2 } = object15(body6);
171494
171502
  if (typeof q !== "string" || q.trim() === "") throw new NetsuiteError(400, "INVALID_PARAMETER", 'Invalid search query. Send the query as {"q": "SELECT ..."}.', "q");
171495
171503
  if (values2 !== void 0 && (!Array.isArray(values2) || values2.length > 1e3)) throw new NetsuiteError(400, "INVALID_PARAMETER", "Invalid search query. Send params as an array of values for the ? markers.", "params");
171496
171504
  try {
@@ -171764,13 +171772,13 @@ function materializeEvent(event3, info, transportNowMs, targetUrl) {
171764
171772
  for (const [index, key4] of keys6.entries()) {
171765
171773
  if (typeof target5 !== "object" || target5 === null || !Object.hasOwn(target5, key4)) throw new AnchaError("INTERNAL", `event pointer does not exist: ${pointer2}`);
171766
171774
  if (Array.isArray(target5) && !/^(0|[1-9]\d*)$/.test(key4)) throw new AnchaError("INTERNAL", `invalid event array pointer: ${pointer2}`);
171767
- const object17 = target5;
171775
+ const object18 = target5;
171768
171776
  if (index === keys6.length - 1) {
171769
- if (typeof object17[key4] !== "string") throw new AnchaError("INTERNAL", `event URL is not a string: ${pointer2}`);
171777
+ if (typeof object18[key4] !== "string") throw new AnchaError("INTERNAL", `event URL is not a string: ${pointer2}`);
171770
171778
  const targetService = linkService === void 0 ? service : info.services[linkService];
171771
171779
  if (!targetService) throw new AnchaError("INTERNAL", `missing ${linkService} service for event API link`);
171772
- Object.defineProperty(object17, key4, { value: targetService.url.replace(/\/$/, "") + path4, enumerable: true, configurable: true, writable: true });
171773
- } else target5 = object17[key4];
171780
+ Object.defineProperty(object18, key4, { value: targetService.url.replace(/\/$/, "") + path4, enumerable: true, configurable: true, writable: true });
171781
+ } else target5 = object18[key4];
171774
171782
  }
171775
171783
  }
171776
171784
  body6 = JSON.stringify(payload2);
@@ -172819,7 +172827,7 @@ var conflict = (message7) => {
172819
172827
  var bad3 = (message7) => {
172820
172828
  throw new AnchaError("USAGE", message7);
172821
172829
  };
172822
- function object15(value4) {
172830
+ function object16(value4) {
172823
172831
  if (!value4 || typeof value4 !== "object" || Array.isArray(value4)) return bad3("expected a JSON object");
172824
172832
  return value4;
172825
172833
  }
@@ -172898,7 +172906,7 @@ function inspectionRoutes(opts) {
172898
172906
  return c.json(observe(env, revisions.get(env) ?? null));
172899
172907
  });
172900
172908
  routes2.post("/envs/:id/inspect", async (c) => {
172901
- const body6 = object15(await c.req.json().catch(() => bad3("invalid JSON")));
172909
+ const body6 = object16(await c.req.json().catch(() => bad3("invalid JSON")));
172902
172910
  only3(body6, []);
172903
172911
  const env = opts.manager.get(c.req.param("id"));
172904
172912
  return c.json(await env.serialize(() => {
@@ -172911,7 +172919,7 @@ function inspectionRoutes(opts) {
172911
172919
  }));
172912
172920
  });
172913
172921
  routes2.post("/envs/:id/inspect/advance", async (c) => {
172914
- const body6 = object15(await c.req.json().catch(() => bad3("invalid JSON")));
172922
+ const body6 = object16(await c.req.json().catch(() => bad3("invalid JSON")));
172915
172923
  only3(body6, ["revision", "untilMs"]);
172916
172924
  const env = opts.manager.get(c.req.param("id"));
172917
172925
  return c.json(await env.serialize(() => {
@@ -172923,7 +172931,7 @@ function inspectionRoutes(opts) {
172923
172931
  }));
172924
172932
  });
172925
172933
  routes2.post("/envs/:id/inspect/reset", async (c) => {
172926
- const body6 = object15(await c.req.json().catch(() => bad3("invalid JSON")));
172934
+ const body6 = object16(await c.req.json().catch(() => bad3("invalid JSON")));
172927
172935
  only3(body6, ["revision"]);
172928
172936
  const env = opts.manager.get(c.req.param("id"));
172929
172937
  return c.json(await env.serialize(async () => {
@@ -172937,12 +172945,12 @@ function inspectionRoutes(opts) {
172937
172945
  }));
172938
172946
  });
172939
172947
  routes2.post("/envs/:id/inspect/action", async (c) => {
172940
- const body6 = object15(await c.req.json().catch(() => bad3("invalid JSON")));
172948
+ const body6 = object16(await c.req.json().catch(() => bad3("invalid JSON")));
172941
172949
  only3(body6, ["revision", "action"]);
172942
172950
  const env = opts.manager.get(c.req.param("id"));
172943
172951
  return c.json(await env.serialize(async () => {
172944
172952
  const revision = owned2(env, body6.revision);
172945
- const action = object15(body6.action);
172953
+ const action = object16(body6.action);
172946
172954
  const info = envInfo(env, opts.publicUrl(), opts.port());
172947
172955
  let service, path4, method2, payload2;
172948
172956
  switch (action.kind) {
@@ -173055,7 +173063,7 @@ function simulationRoutes({ manager }) {
173055
173063
 
173056
173064
  // packages/server/src/control/session-routes.ts
173057
173065
  import { isAbsolute } from "node:path";
173058
- function object16(value4) {
173066
+ function object17(value4) {
173059
173067
  if (typeof value4 !== "object" || value4 === null || Array.isArray(value4)) throw new AnchaError("USAGE", "request must be a JSON object");
173060
173068
  return value4;
173061
173069
  }
@@ -173063,7 +173071,7 @@ function fields10(value4, allowed2) {
173063
173071
  if (Object.keys(value4).some((key4) => !allowed2.includes(key4))) throw new AnchaError("USAGE", "unknown request field");
173064
173072
  }
173065
173073
  function parseOptions(value4) {
173066
- const input5 = object16(value4);
173074
+ const input5 = object17(value4);
173067
173075
  fields10(input5, ["mode", "idleMs", "delivery", "slackTransport", "clientOrigin", "setupCalls", "clockFile"]);
173068
173076
  if (input5.clockFile !== void 0 && (typeof input5.clockFile !== "string" || !isAbsolute(input5.clockFile) || !input5.clockFile.endsWith("/clock.json") || input5.clockFile.includes("\0"))) {
173069
173077
  throw new AnchaError("USAGE", "clockFile must be an absolute path ending in /clock.json");
@@ -173082,7 +173090,7 @@ function parseOptions(value4) {
173082
173090
  if (input5.idleMs !== void 0 && (typeof input5.idleMs !== "number" || !Number.isFinite(input5.idleMs) || input5.idleMs < 0)) throw new AnchaError("USAGE", "idleMs must be non-negative simulated milliseconds");
173083
173091
  if (input5.slackTransport !== void 0 && (typeof input5.slackTransport !== "string" || !["feed", "http", "socket"].includes(input5.slackTransport))) throw new AnchaError("USAGE", "invalid Slack transport");
173084
173092
  if (input5.delivery !== void 0) {
173085
- const delivery = object16(input5.delivery);
173093
+ const delivery = object17(input5.delivery);
173086
173094
  fields10(delivery, [...SUPPORTED_TWINS, "app"]);
173087
173095
  for (const url4 of Object.values(delivery)) {
173088
173096
  try {
@@ -173095,7 +173103,7 @@ function parseOptions(value4) {
173095
173103
  return input5;
173096
173104
  }
173097
173105
  function parseStartOptions(value4) {
173098
- const input5 = object16(value4);
173106
+ const input5 = object17(value4);
173099
173107
  fields10(input5, ["delivery", "timeoutMs"]);
173100
173108
  if (input5.timeoutMs !== void 0 && (typeof input5.timeoutMs !== "number" || !Number.isSafeInteger(input5.timeoutMs) || input5.timeoutMs <= 0 || input5.timeoutMs > 2147483647)) throw new AnchaError("USAGE", "timeoutMs must be positive real milliseconds (at most 2147483647)");
173101
173109
  if (input5.delivery !== void 0) parseOptions({ mode: "endpoint", delivery: input5.delivery });
@@ -173108,7 +173116,7 @@ function sessionRoutes(opts, sessions) {
173108
173116
  app2.post("/envs/:id/trials", async (c) => {
173109
173117
  let input5;
173110
173118
  try {
173111
- input5 = object16(await c.req.json());
173119
+ input5 = object17(await c.req.json());
173112
173120
  } catch {
173113
173121
  throw new AnchaError("USAGE", "request must be a JSON object");
173114
173122
  }
@@ -173131,7 +173139,7 @@ function sessionRoutes(opts, sessions) {
173131
173139
  app2.post("/envs/:id/trials/:sid/answer", async (c) => {
173132
173140
  let input5;
173133
173141
  try {
173134
- input5 = object16(await c.req.json());
173142
+ input5 = object17(await c.req.json());
173135
173143
  } catch {
173136
173144
  throw new AnchaError("USAGE", "request must be a JSON object");
173137
173145
  }
@@ -173146,7 +173154,7 @@ function sessionRoutes(opts, sessions) {
173146
173154
  app2.post("/envs/:id/trials/:sid/agent", async (c) => {
173147
173155
  let input5;
173148
173156
  try {
173149
- input5 = object16(await c.req.json());
173157
+ input5 = object17(await c.req.json());
173150
173158
  } catch {
173151
173159
  throw new AnchaError("USAGE", "request must be a JSON object");
173152
173160
  }