@ancha-labs/cli 0.4.12 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/mcp-entry.mjs CHANGED
@@ -3129,9 +3129,9 @@ var require_timestamp = __commonJS({
3129
3129
  const match = str.match(timestamp2.test);
3130
3130
  if (!match)
3131
3131
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
3132
- const [, year, month, day6, hour2, minute, second] = match.map(Number);
3132
+ const [, year, month, day7, hour2, minute, second] = match.map(Number);
3133
3133
  const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
3134
- let date9 = Date.UTC(year, month - 1, day6, hour2 || 0, minute || 0, second || 0, millisec);
3134
+ let date9 = Date.UTC(year, month - 1, day7, hour2 || 0, minute || 0, second || 0, millisec);
3135
3135
  const tz = match[8];
3136
3136
  if (tz && tz !== "Z") {
3137
3137
  let d = parseSexagesimal(tz, false);
@@ -23260,10 +23260,10 @@ function compactTypeUnion(schema) {
23260
23260
  var FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
23261
23261
  var UNION_KEYS = ["oneOf", "anyOf"];
23262
23262
  function undeclaredConstraint(member) {
23263
- const extra = member.additionalProperties;
23264
- if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null)
23263
+ const extra2 = member.additionalProperties;
23264
+ if (extra2 === void 0 || extra2 === false || typeof extra2 !== "object" || extra2 === null)
23265
23265
  return null;
23266
- return Object.keys(extra).length ? extra : null;
23266
+ return Object.keys(extra2).length ? extra2 : null;
23267
23267
  }
23268
23268
  function foldObjects(members2) {
23269
23269
  const objects = [];
@@ -32068,11 +32068,11 @@ var Protocol = class {
32068
32068
  this._onerror(error62);
32069
32069
  };
32070
32070
  const _onmessage = this._transport?.onmessage;
32071
- this._transport.onmessage = (message4, extra) => {
32072
- _onmessage?.(message4, extra);
32071
+ this._transport.onmessage = (message4, extra2) => {
32072
+ _onmessage?.(message4, extra2);
32073
32073
  if (isJSONRPCResultResponse(message4) || isJSONRPCErrorResponse(message4)) this._onresponse(message4);
32074
- else if (isJSONRPCRequest(message4)) this._onrequest(message4, extra);
32075
- else if (isJSONRPCNotification(message4)) this._onnotification(message4, extra);
32074
+ else if (isJSONRPCRequest(message4)) this._onrequest(message4, extra2);
32075
+ else if (isJSONRPCNotification(message4)) this._onnotification(message4, extra2);
32076
32076
  else this._onerror(/* @__PURE__ */ new Error(`Unknown message type: ${JSON.stringify(message4)}`));
32077
32077
  };
32078
32078
  transport.setSupportedProtocolVersions?.(this._supportedProtocolVersions);
@@ -32110,12 +32110,12 @@ var Protocol = class {
32110
32110
  * an override that consumes only what it owns and falls through to base
32111
32111
  * dispatch for everything else.
32112
32112
  */
32113
- _onnotification(rawNotification, extra) {
32113
+ _onnotification(rawNotification, extra2) {
32114
32114
  const { message: notification } = liftWireOnlyMaterial(rawNotification, "notification");
32115
32115
  const codec2 = this._negotiatedWireCodec();
32116
- if (extra?.classification === void 0 && this._shouldDropInbound(rawNotification) === "drop") return;
32117
- if (extra?.classification !== void 0) {
32118
- const classified = classifiedWireEra(extra.classification);
32116
+ if (extra2?.classification === void 0 && this._shouldDropInbound(rawNotification) === "drop") return;
32117
+ if (extra2?.classification !== void 0) {
32118
+ const classified = classifiedWireEra(extra2.classification);
32119
32119
  if (classified !== codec2.era) {
32120
32120
  this._onerror(/* @__PURE__ */ new Error(`Era mismatch on inbound notification '${notification.method}': classified as ${classified} but this instance serves ${codec2.era}`));
32121
32121
  return;
@@ -32127,10 +32127,10 @@ var Protocol = class {
32127
32127
  if (handler === void 0 && fallback === void 0) return;
32128
32128
  Promise.resolve().then(() => handler === void 0 ? fallback(notification) : handler(notification, codec2)).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Uncaught error in notification handler: ${error62}`)));
32129
32129
  }
32130
- _onrequest(rawRequest, extra) {
32130
+ _onrequest(rawRequest, extra2) {
32131
32131
  const { message: request, lifted } = liftWireOnlyMaterial(rawRequest, "request");
32132
32132
  const codec2 = this._negotiatedWireCodec();
32133
- if (extra?.classification === void 0 && this._shouldDropInbound(rawRequest) === "drop") {
32133
+ if (extra2?.classification === void 0 && this._shouldDropInbound(rawRequest) === "drop") {
32134
32134
  this._onerror(/* @__PURE__ */ new Error(`Dropped inbound request '${rawRequest.method}': not servable on this connection's protocol era`));
32135
32135
  return;
32136
32136
  }
@@ -32147,11 +32147,11 @@ var Protocol = class {
32147
32147
  };
32148
32148
  capturedTransport?.send(errorResponse).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error62}`)));
32149
32149
  };
32150
- if (extra?.classification !== void 0) {
32151
- const classified = classifiedWireEra(extra.classification);
32150
+ if (extra2?.classification !== void 0) {
32151
+ const classified = classifiedWireEra(extra2.classification);
32152
32152
  if (classified !== codec2.era) {
32153
32153
  this._onerror(/* @__PURE__ */ new Error(`Era mismatch on inbound request '${request.method}': classified as ${classified} but this instance serves ${codec2.era}`));
32154
- const requested = extra.classification.revision ?? classified;
32154
+ const requested = extra2.classification.revision ?? classified;
32155
32155
  sendErrorResponse(ProtocolErrorCode.UnsupportedProtocolVersion, `Unsupported protocol version: ${requested}`, {
32156
32156
  supported: this._supportedProtocolVersions,
32157
32157
  requested
@@ -32205,9 +32205,9 @@ var Protocol = class {
32205
32205
  }),
32206
32206
  notify: sendNotification
32207
32207
  },
32208
- http: extra?.authInfo ? { authInfo: extra.authInfo } : void 0
32208
+ http: extra2?.authInfo ? { authInfo: extra2.authInfo } : void 0
32209
32209
  };
32210
- const ctx = this.buildContext(baseCtx, extra);
32210
+ const ctx = this.buildContext(baseCtx, extra2);
32211
32211
  Promise.resolve().then(() => handler(request, ctx)).then(async (result) => {
32212
32212
  if (abortController.signal.aborted) return;
32213
32213
  let encoded;
@@ -39944,8 +39944,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
39944
39944
  if (!matches) return false;
39945
39945
  const year = +matches[1];
39946
39946
  const month = +matches[2];
39947
- const day6 = +matches[3];
39948
- return month >= 1 && month <= 12 && day6 >= 1 && day6 <= (month === 2 && isLeapYear(year) ? 29 : DAYS2[month]);
39947
+ const day7 = +matches[3];
39948
+ return month >= 1 && month <= 12 && day7 >= 1 && day7 <= (month === 2 && isLeapYear(year) ? 29 : DAYS2[month]);
39949
39949
  }
39950
39950
  function compareDate(d1, d2) {
39951
39951
  if (!(d1 && d2)) return void 0;
@@ -43174,7 +43174,7 @@ var Client = class extends Protocol {
43174
43174
  * `setNotificationHandler` / `fallbackNotificationHandler` instead of
43175
43175
  * being silently swallowed.
43176
43176
  */
43177
- _onnotification(raw, extra) {
43177
+ _onnotification(raw, extra2) {
43178
43178
  const evicted = Object.hasOwn(LIST_CHANGED_EVICTIONS, raw.method) ? LIST_CHANGED_EVICTIONS[raw.method] : void 0;
43179
43179
  if (raw.method === "notifications/resources/updated") {
43180
43180
  const uri = raw.params?.uri;
@@ -43200,7 +43200,7 @@ var Client = class extends Protocol {
43200
43200
  return;
43201
43201
  }
43202
43202
  }
43203
- super._onnotification(raw, extra);
43203
+ super._onnotification(raw, extra2);
43204
43204
  }
43205
43205
  /**
43206
43206
  * Transport-level demux for `subscriptions/listen` responses. A JSON-RPC
@@ -48165,11 +48165,11 @@ var Protocol2 = class {
48165
48165
  this._onerror(error62);
48166
48166
  };
48167
48167
  const _onmessage = this._transport?.onmessage;
48168
- this._transport.onmessage = (message4, extra) => {
48169
- _onmessage?.(message4, extra);
48168
+ this._transport.onmessage = (message4, extra2) => {
48169
+ _onmessage?.(message4, extra2);
48170
48170
  if (isJSONRPCResultResponse2(message4) || isJSONRPCErrorResponse2(message4)) this._onresponse(message4);
48171
- else if (isJSONRPCRequest2(message4)) this._onrequest(message4, extra);
48172
- else if (isJSONRPCNotification2(message4)) this._onnotification(message4, extra);
48171
+ else if (isJSONRPCRequest2(message4)) this._onrequest(message4, extra2);
48172
+ else if (isJSONRPCNotification2(message4)) this._onnotification(message4, extra2);
48173
48173
  else this._onerror(/* @__PURE__ */ new Error(`Unknown message type: ${JSON.stringify(message4)}`));
48174
48174
  };
48175
48175
  transport.setSupportedProtocolVersions?.(this._supportedProtocolVersions);
@@ -48207,12 +48207,12 @@ var Protocol2 = class {
48207
48207
  * an override that consumes only what it owns and falls through to base
48208
48208
  * dispatch for everything else.
48209
48209
  */
48210
- _onnotification(rawNotification, extra) {
48210
+ _onnotification(rawNotification, extra2) {
48211
48211
  const { message: notification } = liftWireOnlyMaterial2(rawNotification, "notification");
48212
48212
  const codec2 = this._negotiatedWireCodec();
48213
- if (extra?.classification === void 0 && this._shouldDropInbound(rawNotification) === "drop") return;
48214
- if (extra?.classification !== void 0) {
48215
- const classified = classifiedWireEra2(extra.classification);
48213
+ if (extra2?.classification === void 0 && this._shouldDropInbound(rawNotification) === "drop") return;
48214
+ if (extra2?.classification !== void 0) {
48215
+ const classified = classifiedWireEra2(extra2.classification);
48216
48216
  if (classified !== codec2.era) {
48217
48217
  this._onerror(/* @__PURE__ */ new Error(`Era mismatch on inbound notification '${notification.method}': classified as ${classified} but this instance serves ${codec2.era}`));
48218
48218
  return;
@@ -48224,10 +48224,10 @@ var Protocol2 = class {
48224
48224
  if (handler === void 0 && fallback === void 0) return;
48225
48225
  Promise.resolve().then(() => handler === void 0 ? fallback(notification) : handler(notification, codec2)).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Uncaught error in notification handler: ${error62}`)));
48226
48226
  }
48227
- _onrequest(rawRequest, extra) {
48227
+ _onrequest(rawRequest, extra2) {
48228
48228
  const { message: request, lifted } = liftWireOnlyMaterial2(rawRequest, "request");
48229
48229
  const codec2 = this._negotiatedWireCodec();
48230
- if (extra?.classification === void 0 && this._shouldDropInbound(rawRequest) === "drop") {
48230
+ if (extra2?.classification === void 0 && this._shouldDropInbound(rawRequest) === "drop") {
48231
48231
  this._onerror(/* @__PURE__ */ new Error(`Dropped inbound request '${rawRequest.method}': not servable on this connection's protocol era`));
48232
48232
  return;
48233
48233
  }
@@ -48244,11 +48244,11 @@ var Protocol2 = class {
48244
48244
  };
48245
48245
  capturedTransport?.send(errorResponse).catch((error62) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error62}`)));
48246
48246
  };
48247
- if (extra?.classification !== void 0) {
48248
- const classified = classifiedWireEra2(extra.classification);
48247
+ if (extra2?.classification !== void 0) {
48248
+ const classified = classifiedWireEra2(extra2.classification);
48249
48249
  if (classified !== codec2.era) {
48250
48250
  this._onerror(/* @__PURE__ */ new Error(`Era mismatch on inbound request '${request.method}': classified as ${classified} but this instance serves ${codec2.era}`));
48251
- const requested = extra.classification.revision ?? classified;
48251
+ const requested = extra2.classification.revision ?? classified;
48252
48252
  sendErrorResponse(ProtocolErrorCode2.UnsupportedProtocolVersion, `Unsupported protocol version: ${requested}`, {
48253
48253
  supported: this._supportedProtocolVersions,
48254
48254
  requested
@@ -48302,9 +48302,9 @@ var Protocol2 = class {
48302
48302
  }),
48303
48303
  notify: sendNotification
48304
48304
  },
48305
- http: extra?.authInfo ? { authInfo: extra.authInfo } : void 0
48305
+ http: extra2?.authInfo ? { authInfo: extra2.authInfo } : void 0
48306
48306
  };
48307
- const ctx = this.buildContext(baseCtx, extra);
48307
+ const ctx = this.buildContext(baseCtx, extra2);
48308
48308
  Promise.resolve().then(() => handler(request, ctx)).then(async (result) => {
48309
48309
  if (abortController.signal.aborted) return;
48310
48310
  let encoded;
@@ -55916,8 +55916,8 @@ var require_formats2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
55916
55916
  if (!matches) return false;
55917
55917
  const year = +matches[1];
55918
55918
  const month = +matches[2];
55919
- const day6 = +matches[3];
55920
- return month >= 1 && month <= 12 && day6 >= 1 && day6 <= (month === 2 && isLeapYear(year) ? 29 : DAYS2[month]);
55919
+ const day7 = +matches[3];
55920
+ return month >= 1 && month <= 12 && day7 >= 1 && day7 <= (month === 2 && isLeapYear(year) ? 29 : DAYS2[month]);
55921
55921
  }
55922
55922
  function compareDate(d1, d2) {
55923
55923
  if (!(d1 && d2)) return void 0;
@@ -56259,20 +56259,20 @@ var PerRequestHTTPServerTransport = class {
56259
56259
  * transport is closed before a response was produced (for example because
56260
56260
  * the client disconnected).
56261
56261
  */
56262
- async handleMessage(message4, extra) {
56262
+ async handleMessage(message4, extra2) {
56263
56263
  if (this._used) throw new Error("PerRequestHTTPServerTransport serves exactly one exchange; construct a new transport per request");
56264
56264
  if (!this._started || this.onmessage === void 0) throw new Error("PerRequestHTTPServerTransport is not connected: connect a server to this transport before handling a message");
56265
56265
  if (this._closed) throw new Error("PerRequestHTTPServerTransport is closed");
56266
56266
  this._used = true;
56267
- const signal = extra?.request?.signal;
56267
+ const signal = extra2?.request?.signal;
56268
56268
  if (signal?.aborted) {
56269
56269
  await this.close();
56270
56270
  throw new SdkError2(SdkErrorCode2.ConnectionClosed, "The request was aborted before it could be handled");
56271
56271
  }
56272
56272
  const messageExtra = {
56273
56273
  classification: this._classification,
56274
- ...extra?.request !== void 0 && { request: extra.request },
56275
- ...extra?.authInfo !== void 0 && { authInfo: extra.authInfo }
56274
+ ...extra2?.request !== void 0 && { request: extra2.request },
56275
+ ...extra2?.authInfo !== void 0 && { authInfo: extra2.authInfo }
56276
56276
  };
56277
56277
  if (isJSONRPCRequest2(message4)) {
56278
56278
  this._requestId = message4.id;
@@ -57347,6 +57347,7 @@ var EXECUTION_SUPPORT = {
57347
57347
  "test.timeout": all,
57348
57348
  "checks.state": all,
57349
57349
  "checks.trace": all,
57350
+ "checks.answer": all,
57350
57351
  "checks.process": all,
57351
57352
  "checks.judge": sceneOnly,
57352
57353
  "agent.input.command": all,
@@ -57385,6 +57386,97 @@ var EXECUTION_SUPPORT = {
57385
57386
  "--bundle-file": { local: false, container: false, managed: false, "cloud-vm": true, reason: "files a cloud run carries besides the project and its tests" }
57386
57387
  };
57387
57388
 
57389
+ // packages/core/src/answer.ts
57390
+ var SYMBOLS = "$\u20AC\xA3\xA5\u20B9\u20A9\u20BD\u20BA\u20AA\u20AB\u0E3F\u20B1\u20A6\u20B4\u20B8\u20A1\u20B2\u20B5\u20AD\xA2";
57391
+ var CODES = [
57392
+ "USD",
57393
+ "EUR",
57394
+ "GBP",
57395
+ "JPY",
57396
+ "CNY",
57397
+ "RMB",
57398
+ "CAD",
57399
+ "AUD",
57400
+ "NZD",
57401
+ "CHF",
57402
+ "HKD",
57403
+ "SGD",
57404
+ "INR",
57405
+ "KRW",
57406
+ "MXN",
57407
+ "BRL",
57408
+ "ZAR",
57409
+ "SEK",
57410
+ "NOK",
57411
+ "DKK",
57412
+ "PLN",
57413
+ "CZK",
57414
+ "HUF",
57415
+ "RON",
57416
+ "BGN",
57417
+ "ISK",
57418
+ "ILS",
57419
+ "AED",
57420
+ "SAR",
57421
+ "QAR",
57422
+ "KWD",
57423
+ "BHD",
57424
+ "OMR",
57425
+ "TRY",
57426
+ "RUB",
57427
+ "UAH",
57428
+ "THB",
57429
+ "PHP",
57430
+ "IDR",
57431
+ "MYR",
57432
+ "TWD",
57433
+ "VND",
57434
+ "PKR",
57435
+ "BDT",
57436
+ "LKR",
57437
+ "NGN",
57438
+ "KES",
57439
+ "EGP",
57440
+ "MAD",
57441
+ "ARS",
57442
+ "CLP",
57443
+ "COP",
57444
+ "PEN"
57445
+ ];
57446
+ var CURRENCY = `(?:${CODES.join("|")}|[A-Z]{0,2}[${SYMBOLS}])`;
57447
+ var NUMBER = new RegExp(
57448
+ String.raw`(?<![\p{L}\p{N}_.,]|\p{L}[-−–+/_])(?<open>\()?(?<sign>[-−–+])?(?:(?<before>${CURRENCY})[ \u00A0]?)?(?<minus>[-−–])?(?<inner>\()?` + String.raw`(?<digits>\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)(?!\p{N}|[eE][-+]?\d|,\d{3}|\.\d)` + String.raw`(?:[ \u00A0]?(?<after>${CODES.join("|")}|[${SYMBOLS}]))?(?<close>\))?`,
57449
+ "gu"
57450
+ );
57451
+ function readNumbers(text12) {
57452
+ const numbers2 = [];
57453
+ for (const match of text12.normalize("NFKC").matchAll(NUMBER)) {
57454
+ const { open: open2, sign, before, minus, inner, digits, after, close } = match.groups;
57455
+ const parenthesized = (open2 !== void 0 || inner !== void 0) && close !== void 0;
57456
+ const amount2 = before !== void 0 || after !== void 0 || /[,.]/.test(digits);
57457
+ const negative = sign !== void 0 && sign !== "+" || minus !== void 0 || parenthesized && amount2;
57458
+ const value2 = Number(digits.replaceAll(",", ""));
57459
+ numbers2.push({
57460
+ value: negative && value2 !== 0 ? -value2 : value2,
57461
+ decimals: digits.split(".")[1]?.length ?? 0,
57462
+ text: match[0].trim(),
57463
+ ...parenthesized && !amount2 && !negative && { either: true }
57464
+ });
57465
+ }
57466
+ return numbers2;
57467
+ }
57468
+ var AnswerNumberSchema = external_exports.strictObject({
57469
+ value: external_exports.union([external_exports.number(), external_exports.string().refine((text12) => readNumbers(text12).length === 1, 'a number, or one number written as text, e.g. "1,240.00" or "(300.00)"')]).describe('The number the answer must state: a number, or one number as text ("1,240.00") to keep its decimal places'),
57470
+ tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)")
57471
+ });
57472
+ var texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]);
57473
+ var AnswerCheckSchema = external_exports.strictObject({
57474
+ contains: texts.optional().describe("Text the final answer must contain, each piece"),
57475
+ not_contains: texts.optional().describe("Text the final answer must not contain"),
57476
+ numbers: external_exports.array(AnswerNumberSchema).min(1).optional().describe("Numbers the final answer must state, each within its tolerance; thousands separators, currency codes and symbols, minus signs and parentheses for negatives are read"),
57477
+ case: external_exports.enum(["insensitive", "sensitive"]).optional().describe("How contains and not_contains compare letters; default insensitive")
57478
+ }).describe("Checks the agent's final answer (what it posts to ANCHA_DONE_URL, its HTTP reply, or the last block it prints on stdout): the text and numbers it states");
57479
+
57388
57480
  // packages/core/src/duration.ts
57389
57481
  var DURATION_RE = /^(-?)(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
57390
57482
  var MS_PER = { d: 864e5, h: 36e5, m: 6e4, s: 1e3, ms: 1 };
@@ -57914,7 +58006,7 @@ var AccountsSchema = external_exports.strictObject({
57914
58006
  github: refUse.optional().describe("Their GitHub identity, from seed.github.users"),
57915
58007
  pagerduty: refUse.optional().describe("Their PagerDuty user, from seed.pagerduty.users"),
57916
58008
  gmail: external_exports.email().optional().describe("Their mailbox, an address in seed.gmail.mailboxes: mail delivered there reaches them and they reply from it")
57917
- }).refine((accounts) => Object.values(accounts).some((account2) => account2 !== void 0), "a person needs at least one account").describe("Who this person is in each tool");
58009
+ }).refine((accounts) => Object.values(accounts).some((account3) => account3 !== void 0), "a person needs at least one account").describe("Who this person is in each tool");
57918
58010
  var PERSON_ACTIONS = ["slack.post", "github.comment", "github.open_issue", "github.approve", "github.pr_merge", "gmail.reply"];
57919
58011
  var WORK_ACTIONS = ["slack.post", "github.comment", "github.open_issue", "github.approve", "github.pr_merge"];
57920
58012
  var WorkSchema = external_exports.strictObject({
@@ -58071,7 +58163,7 @@ var SalesforceSeedSchema = external_exports.strictObject({
58071
58163
  if (members2.has(key2)) ctx.addIssue({ code: "custom", path: ["campaignMembers", index], message: "duplicate campaign membership" });
58072
58164
  members2.add(key2);
58073
58165
  }
58074
- for (const account2 of seed2.access.deniedAccountIds) if (!byType.Account.has(account2)) ctx.addIssue({ code: "custom", path: ["access", "deniedAccountIds"], message: "denied account must exist" });
58166
+ for (const account3 of seed2.access.deniedAccountIds) if (!byType.Account.has(account3)) ctx.addIssue({ code: "custom", path: ["access", "deniedAccountIds"], message: "denied account must exist" });
58075
58167
  });
58076
58168
  var salesforceStarterSeed = {
58077
58169
  org: { id: "00D000000000001AAA", name: "Acme", currency: "USD", timezone: "America/Los_Angeles" },
@@ -59035,7 +59127,7 @@ var GmailThreadCheckSchema = external_exports.strictObject({
59035
59127
  drafts_lte: external_exports.number().int().min(0).optional().describe("At most this many drafts in the thread"),
59036
59128
  messages_gte: external_exports.number().int().min(1).optional().describe("At least this many messages in the thread, drafts included")
59037
59129
  }).refine((check3) => check3.label !== void 0 || check3.drafts_gte !== void 0 || check3.drafts_lte !== void 0 || check3.messages_gte !== void 0, "give label, drafts_gte, drafts_lte or messages_gte").refine((check3) => check3.present === void 0 || check3.label !== void 0, "present applies to label");
59038
- var texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]).transform((value2) => Array.isArray(value2) ? value2 : [value2]);
59130
+ var texts2 = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]).transform((value2) => Array.isArray(value2) ? value2 : [value2]);
59039
59131
  var GmailMessageCheckSchema = external_exports.strictObject({
59040
59132
  mailbox: address.optional().describe("Whose mailbox; defaults to the agent's"),
59041
59133
  label: external_exports.string().min(1).max(225).optional().describe("A system label id (SENT, DRAFT, INBOX ...) or a label name the message has"),
@@ -59044,10 +59136,10 @@ var GmailMessageCheckSchema = external_exports.strictObject({
59044
59136
  in_thread_of: ref7.optional().describe("The ref of a seeded message or a gmail.send: the message is in its thread"),
59045
59137
  count: external_exports.number().int().positive().optional().describe("Exact number of matching messages"),
59046
59138
  recipients: external_exports.array(address).min(1).optional().describe("Exact set of To, Cc and Bcc addresses"),
59047
- subject_contains: texts.optional().describe("Text the subject contains, ignoring case; a list must all appear"),
59048
- text_contains: texts.optional().describe("Text the body contains, ignoring case; a list must all appear"),
59139
+ subject_contains: texts2.optional().describe("Text the subject contains, ignoring case; a list must all appear"),
59140
+ text_contains: texts2.optional().describe("Text the body contains, ignoring case; a list must all appear"),
59049
59141
  attachment_name_contains: external_exports.string().min(1).optional().describe("Text an attachment's file name contains, ignoring case"),
59050
- attachment_contains: texts.optional().describe("Text one attachment's content contains, ignoring case; a list must all appear in it"),
59142
+ attachment_contains: texts2.optional().describe("Text one attachment's content contains, ignoring case; a list must all appear in it"),
59051
59143
  exists: external_exports.boolean().default(true).describe("false asserts no message matches")
59052
59144
  });
59053
59145
  var draft = message.omit({ from: true, labels: true }).extend({ at: when.default("0s") });
@@ -60658,6 +60750,16 @@ var attribute = external_exports.strictObject({
60658
60750
  currency: external_exports.string().regex(/^[A-Z]{3}$/).optional()
60659
60751
  });
60660
60752
  var values = external_exports.record(slug, external_exports.union([external_exports.string().max(5e3), external_exports.number(), external_exports.boolean(), external_exports.array(external_exports.union([external_exports.string().max(500), external_exports.number()])).max(100), external_exports.null()]));
60753
+ var ATTIO_STANDARD_ATTRIBUTES = {
60754
+ people: ["record_id", "name", "email_addresses", "phone_numbers", "job_title", "description", "company", "created_at", "created_by"],
60755
+ companies: ["record_id", "name", "domains", "description", "categories", "team", "created_at", "created_by"],
60756
+ deals: ["record_id", "name", "stage", "owner", "value", "associated_people", "associated_company", "created_at", "created_by"]
60757
+ };
60758
+ var STANDARD_LOOKUPS = {
60759
+ people: { company: { target: "companies" } },
60760
+ companies: { team: { target: "people" } },
60761
+ deals: { owner: { target: "member" }, associated_people: { target: "people" }, associated_company: { target: "companies" } }
60762
+ };
60661
60763
  var AttioSeedSchema = external_exports.strictObject({
60662
60764
  workspace: external_exports.strictObject({ name: external_exports.string().min(1).max(100), slug: external_exports.string().regex(/^[a-z0-9-]{2,40}$/) }),
60663
60765
  members: external_exports.array(external_exports.strictObject({ ref: ref11, first_name: external_exports.string().min(1).max(100), last_name: external_exports.string().max(100), email: external_exports.string().regex(EMAIL5), access_level: external_exports.enum(["admin", "member", "suspended"]).default("member") })).min(1).max(200),
@@ -60701,11 +60803,34 @@ var AttioSeedSchema = external_exports.strictObject({
60701
60803
  recordObject.set(r.ref, object3);
60702
60804
  });
60703
60805
  const lists = /* @__PURE__ */ new Set();
60806
+ const emails = new Set(seed2.members.map((m) => m.email.toLowerCase()));
60807
+ const lookupOf = (a) => a.type === "select" || a.type === "status" ? { options: a.options } : a.type === "record-reference" ? { target: a.target } : a.type === "actor-reference" ? { target: "member" } : {};
60808
+ const named2 = (given, attributes, standard, path2) => {
60809
+ for (const [slug3, value2] of Object.entries(given)) {
60810
+ const custom3 = attributes.find((a) => a.api_slug === slug3);
60811
+ if (custom3 === void 0 && !Object.hasOwn(standard, slug3)) {
60812
+ issue2([...path2, slug3], `no attribute "${slug3}"`);
60813
+ continue;
60814
+ }
60815
+ const { options, target } = custom3 === void 0 ? standard[slug3] : lookupOf(custom3);
60816
+ for (const item2 of Array.isArray(value2) ? value2 : [value2]) {
60817
+ if (typeof item2 !== "string") continue;
60818
+ if (options !== void 0 && !options.includes(item2)) issue2([...path2, slug3], `"${item2}" is not an option of ${slug3}`);
60819
+ if (target === "member" && !members2.has(item2) && !emails.has(item2.toLowerCase())) issue2([...path2, slug3], `unknown member ${item2}`);
60820
+ else if (target !== void 0 && target !== "member" && recordObject.get(item2) !== target) issue2([...path2, slug3], `${item2} is not a ${target} record`);
60821
+ }
60822
+ }
60823
+ };
60824
+ for (const object3 of ["people", "companies", "deals"]) {
60825
+ const standard = { ...Object.fromEntries(ATTIO_STANDARD_ATTRIBUTES[object3].map((slug3) => [slug3, {}])), ...STANDARD_LOOKUPS[object3], ...object3 === "deals" && { stage: { options: seed2.deal_stages } } };
60826
+ seed2.records[object3].forEach((r, i) => named2(r.values, seed2.attributes[object3] ?? [], standard, ["records", object3, i, "values"]));
60827
+ }
60704
60828
  seed2.lists.forEach((l, i) => {
60705
60829
  if (lists.has(l.api_slug)) issue2(["lists", i, "api_slug"], "duplicate list slug");
60706
60830
  lists.add(l.api_slug);
60707
60831
  l.entries.forEach((e, j) => {
60708
60832
  if (recordObject.get(e.record) !== l.parent_object) issue2(["lists", i, "entries", j, "record"], `${e.record} is not a ${l.parent_object} record`);
60833
+ named2(e.values, l.attributes, {}, ["lists", i, "entries", j, "values"]);
60709
60834
  });
60710
60835
  });
60711
60836
  seed2.notes.forEach((n, i) => {
@@ -64566,10 +64691,10 @@ var unitOf = (value2) => {
64566
64691
  return UNITS[text12] ?? UNITS[text12.toLowerCase()] ?? null;
64567
64692
  };
64568
64693
  function addMonths(ms, months) {
64569
- const date9 = new Date(ms), day6 = date9.getUTCDate();
64694
+ const date9 = new Date(ms), day7 = date9.getUTCDate();
64570
64695
  const target = new Date(utc(date9.getUTCFullYear(), date9.getUTCMonth() + months, 1, date9.getUTCHours(), date9.getUTCMinutes(), date9.getUTCSeconds(), date9.getUTCMilliseconds()));
64571
64696
  const last = new Date(utc(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate();
64572
- target.setUTCDate(Math.min(day6, last));
64697
+ target.setUTCDate(Math.min(day7, last));
64573
64698
  return target.getTime();
64574
64699
  }
64575
64700
  function monthsBetween(a, b) {
@@ -64706,14 +64831,14 @@ function parseWithFormat(text12, format) {
64706
64831
  });
64707
64832
  if (mo < 0) return null;
64708
64833
  if (pm !== null) h = h % 12 + (pm ? 12 : 0);
64709
- const day6 = validDay(y, mo, d);
64710
- if (day6 === null) return null;
64834
+ const day7 = validDay(y, mo, d);
64835
+ if (day7 === null) return null;
64711
64836
  const timed2 = parts.some((token) => /^[Hhms]/.test(token));
64712
- return formulaDate(day6 + h * 36e5 + mi * 6e4 + s * 1e3, !timed2);
64837
+ return formulaDate(day7 + h * 36e5 + mi * 6e4 + s * 1e3, !timed2);
64713
64838
  }
64714
64839
  var isWorkday = (ms) => {
64715
- const day6 = new Date(ms).getUTCDay();
64716
- return day6 !== 0 && day6 !== 6;
64840
+ const day7 = new Date(ms).getUTCDay();
64841
+ return day7 !== 0 && day7 !== 6;
64717
64842
  };
64718
64843
  var startOfDay = (ms) => Math.floor(ms / 864e5) * 864e5;
64719
64844
  var text1 = (fn) => ({ min: 1, max: 1, run: (args) => fn(formulaText(args[0])) });
@@ -64940,8 +65065,8 @@ var FUNCTIONS = {
64940
65065
  WEEKDAY: { min: 1, max: 2, run: (args) => {
64941
65066
  const date9 = dateArg(args[0]);
64942
65067
  if (date9 === null || isFormulaError(date9)) return date9;
64943
- const monday = args[1] !== void 0 && formulaText(args[1]).toLowerCase() === "monday", day6 = new Date(date9.ms).getUTCDay();
64944
- return monday ? (day6 + 6) % 7 : day6;
65068
+ const monday = args[1] !== void 0 && formulaText(args[1]).toLowerCase() === "monday", day7 = new Date(date9.ms).getUTCDay();
65069
+ return monday ? (day7 + 6) % 7 : day7;
64945
65070
  } },
64946
65071
  WEEKNUM: { min: 1, max: 2, run: (args) => {
64947
65072
  const date9 = dateArg(args[0]);
@@ -65507,6 +65632,9 @@ var carrierPortalStarterSeed = {
65507
65632
  messages: [{ id: "welcome", policy: "LM-10042", request: "LMR-PRIOR-01", subject: "Mailing address confirmed", body: "The requested mailing address has been approved." }]
65508
65633
  };
65509
65634
 
65635
+ // packages/core/src/tools/netsuite-money.ts
65636
+ var netsuiteRound = (value2) => Math.sign(value2) * Math.round(Number(`${Math.abs(value2).toFixed(10)}e2`)) / 100 || 0;
65637
+
65510
65638
  // packages/core/src/tools/netsuite.ts
65511
65639
  var NETSUITE_ACCOUNT_TYPES = [
65512
65640
  "Bank",
@@ -65595,7 +65723,9 @@ var day5 = external_exports.string().refine(
65595
65723
  "expected YYYY-MM-DD or an offset in days from the start of the test, e.g. -30d"
65596
65724
  );
65597
65725
  var external = text11.optional();
65726
+ var named = external_exports.union([id8, text11]).describe("internal ID or name");
65598
65727
  var custom2 = external_exports.record(external_exports.string().regex(/^cust(?:entity|body|col|item)[a-z0-9_]+$/), external_exports.union([external_exports.string().max(4e3), external_exports.number(), external_exports.boolean(), external_exports.null()])).optional();
65728
+ var extra = external_exports.record(external_exports.string().min(1).max(200), external_exports.json()).optional().describe("other fields by NetSuite field ID, served as given; totals and the books never read them");
65599
65729
  var address5 = external_exports.strictObject({
65600
65730
  label: text11.optional(),
65601
65731
  addressee: text11.optional(),
@@ -65624,7 +65754,9 @@ var entity = {
65624
65754
  comments: long.optional(),
65625
65755
  externalId: external,
65626
65756
  addresses: external_exports.array(address5).max(50).default([]),
65627
- custom: custom2
65757
+ custom: custom2,
65758
+ extra,
65759
+ subsidiary: named.optional()
65628
65760
  };
65629
65761
  var itemLine = external_exports.strictObject({
65630
65762
  item: id8,
@@ -65635,13 +65767,32 @@ var itemLine = external_exports.strictObject({
65635
65767
  department: id8.optional(),
65636
65768
  class: id8.optional(),
65637
65769
  closed: external_exports.boolean().default(false),
65638
- custom: custom2
65770
+ custom: custom2,
65771
+ extra
65639
65772
  });
65640
- var expenseLine = external_exports.strictObject({ account: id8, amount: positive, memo: long.optional(), ...segments, closed: external_exports.boolean().default(false), custom: custom2 });
65773
+ var expenseLine = external_exports.strictObject({ account: id8, amount: positive, memo: long.optional(), ...segments, closed: external_exports.boolean().default(false), custom: custom2, extra });
65641
65774
  var application = external_exports.strictObject({ doc: id8, line: external_exports.number().int().nonnegative().optional(), amount: positive });
65642
- var tx = { id: id8, tranId: text11.optional(), date: day5, memo: long.optional(), externalId: external, ...segments, custom: custom2 };
65643
- var shipLine = external_exports.strictObject({ item: id8, quantity: external_exports.number().positive(), location: id8.optional() });
65644
- var NetsuiteSeedSchema = external_exports.strictObject({
65775
+ var tx = {
65776
+ id: id8,
65777
+ tranId: text11.optional(),
65778
+ date: day5,
65779
+ memo: long.optional(),
65780
+ externalId: external,
65781
+ ...segments,
65782
+ custom: custom2,
65783
+ extra,
65784
+ subsidiary: named.optional().describe("internal ID or name; else the customer's or vendor's"),
65785
+ currency: id8.optional().describe("else the customer's or vendor's"),
65786
+ exchangeRate: external_exports.number().positive().optional().describe("to the base currency; else 1")
65787
+ };
65788
+ var shipLine = external_exports.strictObject({ item: id8, quantity: external_exports.number().positive(), location: id8.optional(), extra });
65789
+ var plainRecord = external_exports.strictObject({
65790
+ type: external_exports.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,99}$/).describe("the REST record type, e.g. customrecord_portfolio_kpi or project"),
65791
+ id: external_exports.union([id8, external_exports.string().regex(/^\d{1,10}$/).transform(Number).pipe(id8)]).describe("internal ID, unique within the type"),
65792
+ externalId: external,
65793
+ fields: external_exports.record(external_exports.string().min(1).max(200), external_exports.json()).default({}).describe("field ID \u2192 value as given: text, number, boolean, null, { id, refName }, objects, sublists")
65794
+ });
65795
+ var NetsuiteSeedFieldsSchema = external_exports.strictObject({
65645
65796
  /** The account ID in NetSuite's realm form: 1234567 for production, 1234567_SB1 for a sandbox. */
65646
65797
  account: external_exports.strictObject({ id: external_exports.string().regex(/^\d{4,10}(?:_SB\d{1,2})?$/), company: text11 }).default({ id: "7654321", company: "Acme" }),
65647
65798
  /** The agent's integration record for OAuth 2.0: its redirect URIs, whether it is a public client (PKCE, one-time refresh tokens), and the refresh token lifetime. */
@@ -65674,18 +65825,19 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65674
65825
  /** Accounting periods through this month (YYYY-MM, or -1m for the month before the scene's) are closed: no posting into them. */
65675
65826
  closedThrough: external_exports.string().regex(/^(?:\d{4}-(?:0[1-9]|1[0-2])|-\d+m)$/).optional()
65676
65827
  }).default({ reconcile: "full", billApproval: true, approveBills: true, salesOrderApproval: false, purchaseOrderApproval: false, returnApproval: false }),
65677
- subsidiaries: external_exports.array(external_exports.strictObject({ id: id8, name: text11, legalName: text11.optional(), country: external_exports.string().regex(/^[A-Z]{2}$/).default("US") })).min(1).max(50).default([{ id: 1, name: "Acme", country: "US" }]),
65678
- currencies: external_exports.array(external_exports.strictObject({ id: id8, name: text11, symbol: external_exports.string().regex(/^[A-Z]{3}$/), exchangeRate: external_exports.number().positive().default(1) })).min(1).max(50).default([{ id: 1, name: "US Dollar", symbol: "USD", exchangeRate: 1 }]),
65828
+ subsidiaries: external_exports.array(external_exports.strictObject({ id: id8, name: text11, legalName: text11.optional(), country: external_exports.string().regex(/^[A-Z]{2}$/).default("US"), extra })).min(1).max(50).default([{ id: 1, name: "Acme", country: "US" }]),
65829
+ currencies: external_exports.array(external_exports.strictObject({ id: id8, name: text11, symbol: external_exports.string().regex(/^[A-Z]{3}$/), exchangeRate: external_exports.number().positive().default(1), extra })).min(1).max(50).default([{ id: 1, name: "US Dollar", symbol: "USD", exchangeRate: 1 }]),
65679
65830
  terms: external_exports.array(external_exports.strictObject({
65680
65831
  id: id8,
65681
65832
  name: text11,
65682
65833
  days: external_exports.number().int().min(0).max(365),
65683
65834
  discountPercent: external_exports.number().min(0).max(100).optional(),
65684
- discountDays: external_exports.number().int().min(0).max(365).optional()
65835
+ discountDays: external_exports.number().int().min(0).max(365).optional(),
65836
+ extra
65685
65837
  })).max(50).default([{ id: 1, name: "Net 15", days: 15 }, { id: 2, name: "Net 30", days: 30 }, { id: 3, name: "Due on receipt", days: 0 }]),
65686
- departments: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false) })).max(500).default([]),
65687
- locations: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false), address: address5.omit({ defaultBilling: true, defaultShipping: true }).optional() })).max(500).default([]),
65688
- classes: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false) })).max(500).default([]),
65838
+ departments: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false), extra })).max(500).default([]),
65839
+ locations: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false), address: address5.omit({ defaultBilling: true, defaultShipping: true }).optional(), extra })).max(500).default([]),
65840
+ classes: external_exports.array(external_exports.strictObject({ id: id8, name: text11, parent: id8.optional(), inactive: external_exports.boolean().default(false), extra })).max(500).default([]),
65689
65841
  accounts: external_exports.array(external_exports.strictObject({
65690
65842
  id: id8,
65691
65843
  number: external_exports.string().max(60).optional(),
@@ -65695,12 +65847,13 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65695
65847
  description: long.optional(),
65696
65848
  inactive: external_exports.boolean().default(false),
65697
65849
  useMatchBankData: external_exports.boolean().default(true),
65698
- externalId: external
65850
+ externalId: external,
65851
+ extra
65699
65852
  })).max(500).default([]),
65700
65853
  /** Expense report categories and the account each one posts to. */
65701
- expenseCategories: external_exports.array(external_exports.strictObject({ id: id8, name: text11, account: id8, inactive: external_exports.boolean().default(false) })).max(200).default([]),
65854
+ expenseCategories: external_exports.array(external_exports.strictObject({ id: id8, name: text11, account: id8, inactive: external_exports.boolean().default(false), extra })).max(200).default([]),
65702
65855
  /** Exchange rates by date: one transaction currency against the base currency. */
65703
- currencyRates: external_exports.array(external_exports.strictObject({ id: id8, currency: id8, rate: external_exports.number().positive(), date: day5 })).max(5e3).default([]),
65856
+ currencyRates: external_exports.array(external_exports.strictObject({ id: id8, currency: id8, rate: external_exports.number().positive(), date: day5, extra })).max(5e3).default([]),
65704
65857
  customers: external_exports.array(external_exports.strictObject({
65705
65858
  ...entity,
65706
65859
  companyName: text11.optional(),
@@ -65725,7 +65878,8 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65725
65878
  inactive: external_exports.boolean().default(false),
65726
65879
  comments: long.optional(),
65727
65880
  externalId: external,
65728
- custom: custom2
65881
+ custom: custom2,
65882
+ extra
65729
65883
  })).max(5e3).default([]),
65730
65884
  employees: external_exports.array(external_exports.strictObject({
65731
65885
  id: id8,
@@ -65742,7 +65896,9 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65742
65896
  purchaseLimit: money6.optional(),
65743
65897
  inactive: external_exports.boolean().default(false),
65744
65898
  externalId: external,
65745
- custom: custom2
65899
+ custom: custom2,
65900
+ extra,
65901
+ subsidiary: named.optional()
65746
65902
  })).max(5e3).default([]),
65747
65903
  items: external_exports.array(external_exports.strictObject({
65748
65904
  id: id8,
@@ -65762,6 +65918,7 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65762
65918
  inactive: external_exports.boolean().default(false),
65763
65919
  externalId: external,
65764
65920
  custom: custom2,
65921
+ extra,
65765
65922
  /** An inventory item's opening quantity by location, at a unit cost (its cost if left out). */
65766
65923
  onHand: external_exports.array(external_exports.strictObject({ location: id8, quantity: external_exports.number().min(0), unitCost: money6.optional() })).max(100).default([])
65767
65924
  })).max(5e3).default([]),
@@ -65824,19 +65981,20 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65824
65981
  apply: external_exports.array(application).max(500).default([])
65825
65982
  })).max(5e3).default([]),
65826
65983
  vendorPayments: external_exports.array(external_exports.strictObject({ ...tx, vendor: id8, amount: money6.refine((v) => v >= 0, "must be nonnegative"), apAcct: id8.optional(), credit: external_exports.array(application).max(500).default([]), account: id8.optional(), apply: external_exports.array(application).max(500).default([]) })).max(5e3).default([]),
65827
- journalEntries: external_exports.array(external_exports.strictObject({ ...tx, currency: id8.optional(), exchangeRate: external_exports.number().positive().optional(), approval: external_exports.enum(["pending", "approved"]).optional(), lines: external_exports.array(external_exports.strictObject({
65984
+ journalEntries: external_exports.array(external_exports.strictObject({ ...tx, approval: external_exports.enum(["pending", "approved"]).optional(), lines: external_exports.array(external_exports.strictObject({
65828
65985
  account: id8,
65829
65986
  debit: positive.optional(),
65830
65987
  credit: positive.optional(),
65831
65988
  memo: long.optional(),
65832
65989
  entity: id8.optional(),
65833
- ...segments
65990
+ ...segments,
65991
+ extra
65834
65992
  })).min(2).max(500) })).max(5e3).default([]),
65835
65993
  expenseReports: external_exports.array(external_exports.strictObject({
65836
65994
  ...tx,
65837
65995
  employee: id8,
65838
65996
  status: external_exports.enum(["inProgress", "pendingSupervisor", "pendingAccounting", "approved", "rejected"]).default("pendingSupervisor"),
65839
- expenses: external_exports.array(external_exports.strictObject({ category: id8, amount: positive, date: day5.optional(), memo: long.optional(), ...segments })).min(1).max(500)
65997
+ expenses: external_exports.array(external_exports.strictObject({ category: id8, amount: positive, date: day5.optional(), memo: long.optional(), ...segments, extra })).min(1).max(500)
65840
65998
  })).max(5e3).default([]),
65841
65999
  bankingTransactions: external_exports.array(external_exports.strictObject({
65842
66000
  id: id8,
@@ -65845,7 +66003,8 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65845
66003
  date: day5,
65846
66004
  amount: money6.refine((v) => v !== 0, "must be nonzero"),
65847
66005
  memo: long.optional(),
65848
- reference: text11.optional()
66006
+ reference: text11.optional(),
66007
+ extra
65849
66008
  })).max(5e3).default([]),
65850
66009
  bankRecSuggestions: external_exports.array(external_exports.strictObject({
65851
66010
  id: id8,
@@ -65890,8 +66049,15 @@ var NetsuiteSeedSchema = external_exports.strictObject({
65890
66049
  size: external_exports.number().int().min(0).optional(),
65891
66050
  /** Records the file is attached to. */
65892
66051
  attachedTo: external_exports.array(external_exports.strictObject({ type: external_exports.string().max(60), id: id8 })).max(50).default([])
65893
- })).max(5e3).default([])
65894
- }).superRefine((seed2, ctx) => checkSeed(seed2, (path2, message4) => ctx.addIssue({ code: "custom", path: path2, message: message4 })));
66052
+ })).max(5e3).default([]),
66053
+ /** Records of every other type, kept and served as given: REST (list, get, create, update, delete, eid:), SuiteQL and the metadata catalog. */
66054
+ records: external_exports.array(plainRecord).max(1e5).default([]).describe("records of other types (customrecord_*, project, timeBill...), served as given")
66055
+ });
66056
+ var NetsuiteSeedSchema = NetsuiteSeedFieldsSchema.superRefine((seed2, ctx) => {
66057
+ const issue2 = (path2, message4) => ctx.addIssue({ code: "custom", path: path2, message: message4 });
66058
+ checkSeed(seed2, issue2);
66059
+ checkRecords(seed2, issue2);
66060
+ });
65895
66061
  var ITEM_USE = {
65896
66062
  serviceSaleItem: { sale: true, purchase: false },
65897
66063
  servicePurchaseItem: { sale: false, purchase: true },
@@ -65904,9 +66070,76 @@ var ITEM_USE = {
65904
66070
  otherChargeResaleItem: { sale: true, purchase: true },
65905
66071
  inventoryItem: { sale: true, purchase: true, inventory: true }
65906
66072
  };
65907
- function checkSeed(seed2, issue2) {
66073
+ var NETSUITE_LISTED_PROBLEMS = 50;
66074
+ var words = (name3) => name3.replace(/[A-Z]/g, (c) => ` ${c.toLowerCase()}`);
66075
+ var singular = (name3) => words(name3).replace(/ies$/, "y").replace(/s$/, "");
66076
+ var pathParts = (path2) => path2.flatMap((part) => typeof part === "number" ? [part] : part.split(".").flatMap((piece2) => {
66077
+ const m = /^(\w+)\[(\d+)\]$/.exec(piece2);
66078
+ return m ? [m[1], Number(m[2])] : [piece2];
66079
+ }));
66080
+ function recordNamer(seed2) {
66081
+ const symbols = new Map(seed2.currencies.map((c) => [c.id, c.symbol ?? c.name]));
66082
+ const parties = /* @__PURE__ */ new Map();
66083
+ const person3 = (e) => [e.firstName, e.lastName].filter(Boolean).join(" ");
66084
+ for (const c of seed2.customers) parties.set(c.id, { kind: "customer", name: c.companyName ?? person3(c), currency: c.currency });
66085
+ for (const v of seed2.vendors) parties.set(v.id, { kind: "vendor", name: v.companyName, currency: v.currency });
66086
+ for (const e of seed2.employees) parties.set(e.id, { kind: "employee", name: person3(e) });
66087
+ const record4 = (path2) => {
66088
+ const [list, index] = pathParts(path2);
66089
+ const rows = typeof list === "string" ? seed2[list] : void 0;
66090
+ return Array.isArray(rows) && typeof index === "number" && rows[index] && typeof rows[index] === "object" ? { list, row: rows[index] } : void 0;
66091
+ };
66092
+ const party2 = (row) => {
66093
+ for (const kind of ["customer", "vendor", "employee", "entity"]) if (typeof row[kind] === "number") return { id: row[kind], ...parties.get(row[kind]) };
66094
+ return void 0;
66095
+ };
66096
+ const currency = (path2) => {
66097
+ const found = record4(path2), id10 = netsuiteListId(seed2.currencies, found?.row.currency) ?? netsuiteListId(seed2.currencies, found && parties.get(party2(found.row)?.id ?? -1)?.currency) ?? seed2.currencies[0]?.id;
66098
+ return (id10 === void 0 ? void 0 : symbols.get(id10)) ?? "USD";
66099
+ };
66100
+ const label5 = (path2) => {
66101
+ const found = record4(path2);
66102
+ if (!found) return void 0;
66103
+ const { list, row } = found, id10 = row.id === void 0 ? "" : `id ${String(row.id)}`;
66104
+ const name3 = row.companyName ?? (row.firstName !== void 0 ? person3(row) : void 0) ?? row.name ?? row.displayName ?? row.title;
66105
+ if (list === "accounts") return `${[row.number, row.name].filter(Boolean).join(" ")} (${id10})`;
66106
+ if (list === "items") return `${String(row.itemId ?? name3 ?? singular(list))} (${id10})`;
66107
+ if (["customers", "vendors", "contacts", "employees"].includes(list)) {
66108
+ return `${String(row.entityId ?? name3 ?? singular(list))} (${[id10, row.externalId !== void 0 && `external ID ${String(row.externalId)}`].filter(Boolean).join(", ")})`;
66109
+ }
66110
+ if ("date" in row || "tranId" in row) {
66111
+ const who = party2(row);
66112
+ return `${String(row.tranId ?? row.externalId ?? singular(list).trim())} (${[id10, who && `${who.kind ?? "entity"} ${who.id}${who.name ? ` ${who.name}` : ""}`].filter(Boolean).join(", ")})`;
66113
+ }
66114
+ return name3 !== void 0 || id10 ? `${name3 ?? singular(list).trim()}${id10 ? ` (${id10})` : ""}` : void 0;
66115
+ };
66116
+ const value2 = (path2) => {
66117
+ let at = seed2;
66118
+ for (const part of pathParts(path2)) at = at && typeof at === "object" ? at[part] : void 0;
66119
+ return typeof at === "number" || typeof at === "string" ? at : void 0;
66120
+ };
66121
+ const money8 = (path2, amount2) => {
66122
+ const cents3 = Math.round(Math.abs(amount2) * 100), whole = Math.floor(cents3 / 100).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
66123
+ return `${currency(path2)} ${amount2 < 0 ? "-" : ""}${whole}.${String(cents3 % 100).padStart(2, "0")}`;
66124
+ };
66125
+ return { label: label5, value: value2, money: money8 };
66126
+ }
66127
+ function checkSeed(seed2, report) {
66128
+ const named2 = recordNamer(seed2), found = [], money8 = named2.money;
66129
+ const issue2 = (path2, message4) => {
66130
+ const label5 = named2.label(path2), value2 = /^(missing|duplicate)\b/.test(message4) ? named2.value(path2) : void 0;
66131
+ found.push({ path: path2, message: `${label5 ? `${label5}: ` : ""}${message4}${value2 === void 0 ? "" : ` ${value2}`}` });
66132
+ };
66133
+ try {
66134
+ books(seed2, issue2, money8);
66135
+ } finally {
66136
+ for (const problem of found.slice(0, NETSUITE_LISTED_PROBLEMS)) report(problem.path, problem.message);
66137
+ if (found.length > NETSUITE_LISTED_PROBLEMS) report([], `and ${found.length - NETSUITE_LISTED_PROBLEMS} more problems`);
66138
+ }
66139
+ }
66140
+ function books(seed2, issue2, money8) {
65908
66141
  if (seed2.integration.customerCreditLimitHandlingOverride && !seed2.policy.allowCustomerCreditLimitHandlingOverride) issue2(["integration", "customerCreditLimitHandlingOverride"], "credit handling override requires policy permission");
65909
- const round2 = (v) => Math.sign(v) * Math.round(Number(`${Math.abs(v).toFixed(10)}e2`)) / 100 || 0;
66142
+ const round2 = netsuiteRound;
65910
66143
  const accountById = new Map(seed2.accounts.map((a) => [a.id, a])), itemById = new Map(seed2.items.map((i) => [i.id, i]));
65911
66144
  const itemTotal = (lines2) => round2(lines2.reduce((sum, line2) => sum + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.rate ?? 0)), 0));
65912
66145
  const buyTotal = (lines2) => round2(lines2.reduce((sum, line2) => sum + round2(line2.quantity * (line2.rate ?? itemById.get(line2.item)?.cost ?? itemById.get(line2.item)?.rate ?? 0)), 0));
@@ -65924,14 +66157,17 @@ function checkSeed(seed2, issue2) {
65924
66157
  const categories = ids(seed2.expenseCategories, "expenseCategories"), folders = ids(seed2.folders, "folders");
65925
66158
  ids(seed2.currencyRates, "currencyRates");
65926
66159
  ids(seed2.files, "files");
65927
- void subsidiaries;
65928
- const account2 = (value2, path2, types, label5 = "account") => {
66160
+ const subsidiaryOf = (value2) => netsuiteListId(seed2.subsidiaries, value2), currencyOf = (value2) => netsuiteListId(seed2.currencies, value2);
66161
+ const known = (value2, path2, what) => {
66162
+ if (value2 !== void 0 && (what === "subsidiary" ? subsidiaryOf : currencyOf)(value2) === void 0) issue2(path2, `missing ${what}`);
66163
+ };
66164
+ const account3 = (value2, path2, types, label5 = "account") => {
65929
66165
  if (value2 === void 0) return void 0;
65930
- const known = accountById.get(value2);
65931
- if (!known) issue2(path2, "missing account");
65932
- else if (known.inactive) issue2(path2, "inactive account");
65933
- else if (types && !types.includes(known.type)) issue2(path2, `${label5} must be ${types.join(" or ")}`);
65934
- return known;
66166
+ const known2 = accountById.get(value2);
66167
+ if (!known2) issue2(path2, "missing account");
66168
+ else if (known2.inactive) issue2(path2, "inactive account");
66169
+ else if (types && !types.includes(known2.type)) issue2(path2, `${label5} must be ${types.join(" or ")}`);
66170
+ return known2;
65935
66171
  };
65936
66172
  const segment = (record4, path2) => {
65937
66173
  if (record4.department !== void 0 && !departments.has(record4.department)) issue2([...path2, "department"], "missing department");
@@ -65962,7 +66198,7 @@ function checkSeed(seed2, issue2) {
65962
66198
  }
65963
66199
  }
65964
66200
  }
65965
- for (const [index, c] of seed2.expenseCategories.entries()) account2(c.account, ["expenseCategories", index, "account"]);
66201
+ for (const [index, c] of seed2.expenseCategories.entries()) account3(c.account, ["expenseCategories", index, "account"]);
65966
66202
  for (const [index, r] of seed2.currencyRates.entries()) if (!currencies.has(r.currency)) issue2(["currencyRates", index, "currency"], "missing currency");
65967
66203
  const customers = new Set(seed2.customers.map((c) => c.id)), vendors = new Set(seed2.vendors.map((v) => v.id)), employees = new Set(seed2.employees.map((e) => e.id)), entities = /* @__PURE__ */ new Set();
65968
66204
  for (const [name3, list] of [["customers", seed2.customers], ["vendors", seed2.vendors], ["contacts", seed2.contacts], ["employees", seed2.employees]]) for (const [index, e] of list.entries()) {
@@ -65972,9 +66208,13 @@ function checkSeed(seed2, issue2) {
65972
66208
  for (const [index, c] of seed2.customers.entries()) {
65973
66209
  if (c.isPerson ? !c.firstName || !c.lastName : !c.companyName) issue2(["customers", index], c.isPerson ? "a person needs firstName and lastName" : "a company needs companyName");
65974
66210
  if (c.salesRep !== void 0 && !employees.has(c.salesRep)) issue2(["customers", index, "salesRep"], "missing employee");
65975
- if (c.currency !== void 0 && !currencies.has(c.currency)) issue2(["customers", index, "currency"], "missing currency");
66211
+ known(c.currency, ["customers", index, "currency"], "currency");
66212
+ known(c.subsidiary, ["customers", index, "subsidiary"], "subsidiary");
66213
+ }
66214
+ for (const [index, v] of seed2.vendors.entries()) {
66215
+ known(v.currency, ["vendors", index, "currency"], "currency");
66216
+ known(v.subsidiary, ["vendors", index, "subsidiary"], "subsidiary");
65976
66217
  }
65977
- for (const [index, v] of seed2.vendors.entries()) if (v.currency !== void 0 && !currencies.has(v.currency)) issue2(["vendors", index, "currency"], "missing currency");
65978
66218
  for (const [list, name3] of [[seed2.customers, "customers"], [seed2.vendors, "vendors"]]) for (const [index, e] of list.entries()) {
65979
66219
  if (e.terms !== void 0 && !terms.has(e.terms)) issue2([name3, index, "terms"], "missing term");
65980
66220
  if (e.addresses.filter((a) => a.defaultBilling).length > 1 || e.addresses.filter((a) => a.defaultShipping).length > 1) issue2([name3, index, "addresses"], "one default billing and one default shipping address");
@@ -65982,14 +66222,15 @@ function checkSeed(seed2, issue2) {
65982
66222
  for (const [index, c] of seed2.contacts.entries()) if (c.company !== void 0 && !customers.has(c.company) && !vendors.has(c.company)) issue2(["contacts", index, "company"], "missing customer or vendor");
65983
66223
  for (const [index, e] of seed2.employees.entries()) {
65984
66224
  if (e.supervisor !== void 0 && (!employees.has(e.supervisor) || e.supervisor === e.id)) issue2(["employees", index, "supervisor"], "missing employee");
66225
+ known(e.subsidiary, ["employees", index, "subsidiary"], "subsidiary");
65985
66226
  segment(e, ["employees", index]);
65986
66227
  }
65987
66228
  for (const [index, item2] of seed2.items.entries()) {
65988
66229
  const use = ITEM_USE[item2.type], path2 = ["items", index];
65989
- account2(item2.incomeAccount, [...path2, "incomeAccount"]);
65990
- account2(item2.expenseAccount, [...path2, "expenseAccount"]);
65991
- account2(item2.assetAccount, [...path2, "assetAccount"], ["OthCurrAsset"]);
65992
- account2(item2.cogsAccount, [...path2, "cogsAccount"], ["COGS", "Expense"]);
66230
+ account3(item2.incomeAccount, [...path2, "incomeAccount"]);
66231
+ account3(item2.expenseAccount, [...path2, "expenseAccount"]);
66232
+ account3(item2.assetAccount, [...path2, "assetAccount"], ["OthCurrAsset"]);
66233
+ account3(item2.cogsAccount, [...path2, "cogsAccount"], ["COGS", "Expense"]);
65993
66234
  if (item2.vendor !== void 0 && !vendors.has(item2.vendor)) issue2([...path2, "vendor"], "missing vendor");
65994
66235
  if (use.inventory && (item2.assetAccount === void 0 || item2.cogsAccount === void 0)) issue2(path2, "an inventory item needs assetAccount and cogsAccount");
65995
66236
  if (!use.inventory && item2.onHand.length) issue2([...path2, "onHand"], "only inventory items keep quantities");
@@ -66033,6 +66274,25 @@ function checkSeed(seed2, issue2) {
66033
66274
  txIds.set(t.id, name3);
66034
66275
  }
66035
66276
  for (const name3 of transactions) for (const [index, t] of seed2[name3].entries()) segment(t, [name3, index]);
66277
+ const homes = /* @__PURE__ */ new Map();
66278
+ for (const e of [...seed2.customers, ...seed2.vendors]) homes.set(e.id, { subsidiary: subsidiaryOf(e.subsidiary), currency: currencyOf(e.currency) });
66279
+ for (const e of seed2.employees) homes.set(e.id, { subsidiary: subsidiaryOf(e.subsidiary) });
66280
+ const places = /* @__PURE__ */ new Map();
66281
+ for (const name3 of transactions) for (const [index, t] of seed2[name3].entries()) {
66282
+ known(t.subsidiary, [name3, index, "subsidiary"], "subsidiary");
66283
+ known(t.currency, [name3, index, "currency"], "currency");
66284
+ const home = homes.get(t.customer ?? t.vendor ?? t.employee ?? 0);
66285
+ places.set(t.id, { subsidiary: subsidiaryOf(t.subsidiary) ?? home?.subsidiary ?? seed2.subsidiaries[0]?.id, currency: currencyOf(t.currency) ?? home?.currency ?? seed2.currencies[0]?.id });
66286
+ }
66287
+ const symbol2 = (currency) => seed2.currencies.find((c) => c.id === currency)?.symbol ?? String(currency);
66288
+ const subsidiaryName = (subsidiary) => seed2.subsidiaries.find((c) => c.id === subsidiary)?.name ?? String(subsidiary);
66289
+ const sameBooks = (payment, doc, path2, label5, what) => {
66290
+ const here = places.get(payment), there = places.get(doc);
66291
+ if (!here || !there) return;
66292
+ if (there.currency !== here.currency) issue2(path2, `${label5} ${doc} is in ${symbol2(there.currency)}, the ${what} in ${symbol2(here.currency)}`);
66293
+ else if (there.subsidiary !== here.subsidiary) issue2(path2, `${label5} ${doc} is in subsidiary ${subsidiaryName(there.subsidiary)}, the ${what} in ${subsidiaryName(here.subsidiary)}`);
66294
+ };
66295
+ const KIND = { creditMemos: "credit memo", customerPayments: "payment", vendorPayments: "bill payment", vendorCredits: "bill credit", customerRefunds: "refund" };
66036
66296
  const lines = (name3, index, list, want) => list.forEach((line2, i) => {
66037
66297
  const item2 = itemById.get(line2.item);
66038
66298
  if (!item2) issue2([name3, index, "lines", i, "item"], "missing item");
@@ -66064,7 +66324,8 @@ function checkSeed(seed2, issue2) {
66064
66324
  if (lines2[0]?.pending) issue2(path2, "order is pending approval");
66065
66325
  for (const [i, l] of list.entries()) {
66066
66326
  const open3 = lines2.find((o) => o.item === l.item && o.quantity - o.shipped >= l.quantity - 1e-9);
66067
- if (!open3) issue2([name3, index, "lines", i, "quantity"], "quantity exceeds what remains on the order");
66327
+ const left = Math.max(0, ...lines2.filter((o) => o.item === l.item).map((o) => o.quantity - o.shipped));
66328
+ if (!open3) issue2([name3, index, "lines", i, "quantity"], `quantity exceeds what remains on the order: ${l.quantity} against ${left} remaining`);
66068
66329
  else open3.shipped += l.quantity;
66069
66330
  if (!(who === "customer" ? needsShipping : needsReceipt)(l.item)) issue2([name3, index, "lines", i, "item"], "item is not shipped or received");
66070
66331
  if (itemById.get(l.item)?.type === "inventoryItem" && l.location === void 0 && !seed2.locations.length) issue2([name3, index, "lines", i, "location"], "inventory moves need a location");
@@ -66090,7 +66351,8 @@ function checkSeed(seed2, issue2) {
66090
66351
  }
66091
66352
  const room = (l) => ((who === "customer" ? needsShipping : needsReceipt)(l.item) ? l.shipped : l.quantity) - l.billed;
66092
66353
  const open3 = lines2.find((l) => l.item === line2.item && room(l) >= line2.quantity - 1e-9);
66093
- if (!open3) issue2([name3, index, "lines", i, "quantity"], `quantity exceeds a remaining ${label5} line`);
66354
+ const left = Math.max(0, ...lines2.filter((l) => l.item === line2.item).map(room));
66355
+ if (!open3) issue2([name3, index, "lines", i, "quantity"], `quantity exceeds a remaining ${label5} line: ${line2.quantity} against ${left} remaining`);
66094
66356
  else open3.billed += line2.quantity;
66095
66357
  }
66096
66358
  };
@@ -66101,14 +66363,14 @@ function checkSeed(seed2, issue2) {
66101
66363
  if (!t.lines.length && !t.expenses.length) issue2(["purchaseOrders", index], "an order needs at least one item or expense line");
66102
66364
  if (t.employee !== void 0 && !employees.has(t.employee)) issue2(["purchaseOrders", index, "employee"], "missing employee");
66103
66365
  lines("purchaseOrders", index, t.lines, "purchase");
66104
- t.expenses.forEach((line2, i) => account2(line2.account, ["purchaseOrders", index, "expenses", i, "account"]));
66366
+ t.expenses.forEach((line2, i) => account3(line2.account, ["purchaseOrders", index, "expenses", i, "account"]));
66105
66367
  }
66106
66368
  for (const name3 of ["vendorBills", "vendorCredits"]) for (const [index, t] of seed2[name3].entries()) {
66107
66369
  if (!vendors.has(t.vendor)) issue2([name3, index, "vendor"], "missing vendor");
66108
66370
  if (!t.expenses.length && !t.lines.length) issue2([name3, index], "needs at least one expense or item line");
66109
66371
  t.expenses.forEach((line2, i) => {
66110
- const known = account2(line2.account, [name3, index, "expenses", i, "account"]);
66111
- if (known?.type === "AcctRec" || known?.type === "AcctPay") issue2([name3, index, "expenses", i, "account"], "expense account cannot be receivables or payables");
66372
+ const known2 = account3(line2.account, [name3, index, "expenses", i, "account"]);
66373
+ if (known2?.type === "AcctRec" || known2?.type === "AcctPay") issue2([name3, index, "expenses", i, "account"], "expense account cannot be receivables or payables");
66112
66374
  });
66113
66375
  lines(name3, index, t.lines, "purchase");
66114
66376
  }
@@ -66131,6 +66393,7 @@ function checkSeed(seed2, issue2) {
66131
66393
  const line2 = a.line === void 0 ? void 0 : candidates.find((l) => l.line === a.line);
66132
66394
  const key2 = `${a.doc}:${a.line === void 0 ? "auto" : line2?.line}`;
66133
66395
  if ((a.line === void 0 ? !candidates.length : !line2) || seen.has(key2) || journal.approval === "pending") issue2(path2, "invalid journal application line");
66396
+ else sameBooks(t.id, a.doc, path2, "journal entry", KIND[name3]);
66134
66397
  seen.add(key2);
66135
66398
  continue;
66136
66399
  }
@@ -66142,6 +66405,7 @@ function checkSeed(seed2, issue2) {
66142
66405
  continue;
66143
66406
  }
66144
66407
  if (doc.owner !== owner) issue2(path2, `${label5} belongs to another ${"vendor" in t ? "vendor" : "customer"}`);
66408
+ else sameBooks(t.id, a.doc, path2, label5, KIND[name3]);
66145
66409
  if (doc.approved === false) issue2(path2, `${label5} is not approved`);
66146
66410
  applied.set(a.doc, (applied.get(a.doc) ?? 0) + a.amount);
66147
66411
  }
@@ -66167,18 +66431,20 @@ function checkSeed(seed2, issue2) {
66167
66431
  continue;
66168
66432
  }
66169
66433
  if (doc.owner !== t.customer) issue2(path2, "credit belongs to another customer");
66434
+ else sameBooks(t.id, a.doc, path2, seed2.creditMemos.some((c) => c.id === a.doc) ? "credit memo" : "payment", "refund");
66170
66435
  spent.set(a.doc, (spent.get(a.doc) ?? 0) + a.amount);
66171
66436
  }
66172
66437
  if (!customers.has(t.customer)) issue2(["customerRefunds", index, "customer"], "missing customer");
66173
- account2(t.account, ["customerRefunds", index, "account"], ["Bank"], "refund account");
66438
+ account3(t.account, ["customerRefunds", index, "account"], ["Bank"], "refund account");
66174
66439
  }
66175
66440
  for (const [id10, amount2] of applied) if (round2(amount2) > (totals.get(id10) ?? 0) + 1e-9) {
66176
- const name3 = seed2.invoices.some((t) => t.id === id10) ? "invoices" : "vendorBills";
66177
- issue2([name3, seed2[name3].findIndex((t) => t.id === id10)], `${name3 === "invoices" ? "invoice" : "vendor bill"} is over-applied`);
66441
+ const name3 = seed2.invoices.some((t) => t.id === id10) ? "invoices" : "vendorBills", path2 = [name3, seed2[name3].findIndex((t) => t.id === id10)], total = totals.get(id10) ?? 0;
66442
+ issue2(path2, `${name3 === "invoices" ? "invoice" : "vendor bill"} is over-applied: applications total ${money8(path2, round2(amount2))} against a total of ${money8(path2, total)} (over by ${money8(path2, round2(amount2 - total))})`);
66178
66443
  }
66179
66444
  for (const name3 of ["creditMemos", "customerPayments", "vendorCredits", "vendorPayments"]) for (const [index, t] of seed2[name3].entries()) {
66180
66445
  const total = ("amount" in t ? t.amount : totals.get(t.id) ?? 0) + ("credit" in t ? t.credit.reduce((sum, a) => sum + a.amount, 0) : 0);
66181
- if (round2(spent.get(t.id) ?? 0) > total + 1e-9) issue2([name3, index, "apply"], `applies more than the ${name3 === "creditMemos" ? "credit memo" : name3 === "vendorCredits" ? "bill credit" : "payment"}`);
66446
+ const used2 = round2(spent.get(t.id) ?? 0), path2 = [name3, index, "apply"];
66447
+ if (used2 > total + 1e-9) issue2(path2, `applies more than the ${name3 === "creditMemos" ? "credit memo" : name3 === "vendorCredits" ? "bill credit" : "payment"}: ${money8(path2, used2)} against ${money8(path2, round2(total))} (over by ${money8(path2, round2(used2 - total))})`);
66182
66448
  }
66183
66449
  const open2 = [];
66184
66450
  const ar = seed2.accounts.find((a) => a.type === "AcctRec" && !a.inactive)?.id, ap = seed2.accounts.find((a) => a.type === "AcctPay" && !a.inactive)?.id;
@@ -66209,7 +66475,7 @@ function checkSeed(seed2, issue2) {
66209
66475
  if (!extended2) continue;
66210
66476
  const owner = "customer" in t ? t.customer : t.vendor, control = "arAcct" in t ? t.arAcct : "apAcct" in t ? t.apAcct : void 0;
66211
66477
  const acct = control ?? ("customer" in t ? ar : ap) ?? 0;
66212
- if (control !== void 0) account2(control, [name3, index, "customer" in t ? "arAcct" : "apAcct"], ["customer" in t ? "AcctRec" : "AcctPay"]);
66478
+ if (control !== void 0) account3(control, [name3, index, "customer" in t ? "arAcct" : "apAcct"], ["customer" in t ? "AcctRec" : "AcctPay"]);
66213
66479
  let gross = 0, credit = 0;
66214
66480
  const before = new Map(used);
66215
66481
  for (const [role2, list] of [["debt", t.apply], ["credit", "credit" in t ? t.credit : []]]) {
@@ -66226,23 +66492,23 @@ function checkSeed(seed2, issue2) {
66226
66492
  seen.add(key2);
66227
66493
  const amount2 = round2((used.get(key2) ?? 0) + a.amount);
66228
66494
  used.set(key2, amount2);
66229
- if (amount2 > item2.amount + 4e-3) issue2(path2, "application exceeds the open line amount");
66495
+ if (amount2 > item2.amount + 4e-3) issue2(path2, `application exceeds the open line amount: ${money8(path2, amount2)} applied against ${money8(path2, item2.amount)} open`);
66230
66496
  if (role2 === "debt") gross += a.amount;
66231
66497
  else credit += a.amount;
66232
66498
  }
66233
66499
  }
66234
66500
  const cash = "amount" in t ? t.amount : totals.get(t.id) ?? 0;
66235
- if (credit > gross + 4e-3 || gross > cash + credit + 4e-3 || cash === 0 && !(gross > 0 && round2(gross) === round2(credit))) issue2([name3, index], "application requires cash or matching selected credits");
66501
+ if (credit > gross + 4e-3 || gross > cash + credit + 4e-3 || cash === 0 && !(gross > 0 && round2(gross) === round2(credit))) issue2([name3, index], `application requires cash or matching selected credits: applies ${money8([name3, index], round2(gross))} with ${money8([name3, index], cash)} in cash and ${money8([name3, index], round2(credit))} in credits`);
66236
66502
  }
66237
66503
  for (const [index, t] of seed2.customerPayments.entries()) {
66238
66504
  if (!customers.has(t.customer)) issue2(["customerPayments", index, "customer"], "missing customer");
66239
- account2(t.account, ["customerPayments", index, "account"], ["Bank", "OthCurrAsset"], "payment account");
66505
+ account3(t.account, ["customerPayments", index, "account"], ["Bank", "OthCurrAsset"], "payment account");
66240
66506
  }
66241
- for (const [index, t] of seed2.cashSales.entries()) account2(t.account, ["cashSales", index, "account"], ["Bank", "OthCurrAsset"], "deposit account");
66507
+ for (const [index, t] of seed2.cashSales.entries()) account3(t.account, ["cashSales", index, "account"], ["Bank", "OthCurrAsset"], "deposit account");
66242
66508
  const refunded = /* @__PURE__ */ new Map();
66243
66509
  if (seed2.cashRefunds.length && !seed2.accounts.some((a) => a.type === "Bank" && !a.inactive)) issue2(["cashRefunds"], "cash refunds require an active bank account");
66244
66510
  for (const [index, t] of seed2.cashRefunds.entries()) {
66245
- account2(t.account, ["cashRefunds", index, "account"], ["Bank"], "refund account");
66511
+ account3(t.account, ["cashRefunds", index, "account"], ["Bank"], "refund account");
66246
66512
  if (t.cashSale === void 0) continue;
66247
66513
  const sale = seed2.cashSales.find((s) => s.id === t.cashSale);
66248
66514
  if (!sale || sale.customer !== t.customer) {
@@ -66252,34 +66518,35 @@ function checkSeed(seed2, issue2) {
66252
66518
  for (const line2 of t.lines) {
66253
66519
  const key2 = `${sale.id}:${line2.item}`, quantity = (refunded.get(key2) ?? 0) + line2.quantity;
66254
66520
  refunded.set(key2, quantity);
66255
- if (quantity > sale.lines.filter((l) => l.item === line2.item).reduce((s, l) => s + l.quantity, 0)) issue2(["cashRefunds", index, "lines"], "refund exceeds the cash sale quantity");
66521
+ const sold = sale.lines.filter((l) => l.item === line2.item).reduce((s, l) => s + l.quantity, 0);
66522
+ if (quantity > sold) issue2(["cashRefunds", index, "lines"], `refund exceeds the cash sale quantity: ${quantity} refunded against ${sold} sold`);
66256
66523
  }
66257
66524
  }
66258
66525
  for (const [index, t] of seed2.customerDeposits.entries()) {
66259
66526
  if (!customers.has(t.customer)) issue2(["customerDeposits", index, "customer"], "missing customer");
66260
- account2(t.account, ["customerDeposits", index, "account"], ["Bank", "OthCurrAsset"], "deposit account");
66527
+ account3(t.account, ["customerDeposits", index, "account"], ["Bank", "OthCurrAsset"], "deposit account");
66261
66528
  if (t.salesOrder !== void 0 && !seed2.salesOrders.some((o) => o.id === t.salesOrder && o.customer === t.customer)) issue2(["customerDeposits", index, "salesOrder"], "missing sales order of this customer");
66262
66529
  }
66263
66530
  for (const [index, t] of seed2.vendorPayments.entries()) {
66264
66531
  if (!vendors.has(t.vendor) && !employees.has(t.vendor)) issue2(["vendorPayments", index, "vendor"], "missing vendor or employee");
66265
- account2(t.account, ["vendorPayments", index, "account"], ["Bank"], "payment account");
66532
+ account3(t.account, ["vendorPayments", index, "account"], ["Bank"], "payment account");
66266
66533
  }
66267
66534
  for (const [index, t] of seed2.journalEntries.entries()) {
66268
- if (t.currency !== void 0 && !currencies.has(t.currency)) issue2(["journalEntries", index, "currency"], "missing currency");
66269
66535
  t.lines.forEach((line2, i) => {
66270
- const known = account2(line2.account, ["journalEntries", index, "lines", i, "account"]);
66271
- const named = line2.entity !== void 0 && (customers.has(line2.entity) || vendors.has(line2.entity) || employees.has(line2.entity));
66272
- if (line2.entity !== void 0 && !named) issue2(["journalEntries", index, "lines", i, "entity"], "missing customer, vendor or employee");
66273
- else if ((known?.type === "AcctRec" || known?.type === "AcctPay") && line2.entity === void 0) issue2(["journalEntries", index, "lines", i, "entity"], "a receivables or payables line names its customer, vendor or employee");
66274
- else if (known?.type === "AcctRec" && line2.entity !== void 0 && !customers.has(line2.entity)) issue2(["journalEntries", index, "lines", i, "entity"], "a receivables line names a customer");
66275
- else if (known?.type === "AcctPay" && line2.entity !== void 0 && customers.has(line2.entity)) issue2(["journalEntries", index, "lines", i, "entity"], "a payables line names a vendor or employee");
66536
+ const known2 = account3(line2.account, ["journalEntries", index, "lines", i, "account"]);
66537
+ const named2 = line2.entity !== void 0 && (customers.has(line2.entity) || vendors.has(line2.entity) || employees.has(line2.entity));
66538
+ if (line2.entity !== void 0 && !named2) issue2(["journalEntries", index, "lines", i, "entity"], "missing customer, vendor or employee");
66539
+ else if ((known2?.type === "AcctRec" || known2?.type === "AcctPay") && line2.entity === void 0) issue2(["journalEntries", index, "lines", i, "entity"], "a receivables or payables line names its customer, vendor or employee");
66540
+ else if (known2?.type === "AcctRec" && line2.entity !== void 0 && !customers.has(line2.entity)) issue2(["journalEntries", index, "lines", i, "entity"], "a receivables line names a customer");
66541
+ else if (known2?.type === "AcctPay" && line2.entity !== void 0 && customers.has(line2.entity)) issue2(["journalEntries", index, "lines", i, "entity"], "a payables line names a vendor or employee");
66276
66542
  const party2 = seed2.customers.find((e) => e.id === line2.entity) ?? seed2.vendors.find((e) => e.id === line2.entity);
66277
- if (named && ["AcctRec", "AcctPay"].includes(known?.type ?? "") && (party2?.currency ?? seed2.currencies[0]?.id) !== (t.currency ?? seed2.currencies[0]?.id)) issue2(["journalEntries", index, "lines", i, "entity"], "journal currency must match the named entity currency");
66543
+ if (named2 && ["AcctRec", "AcctPay"].includes(known2?.type ?? "") && (currencyOf(party2?.currency) ?? seed2.currencies[0]?.id) !== (currencyOf(t.currency) ?? seed2.currencies[0]?.id)) issue2(["journalEntries", index, "lines", i, "entity"], "journal currency must match the named entity currency");
66278
66544
  if (line2.debit === void 0 === (line2.credit === void 0)) issue2(["journalEntries", index, "lines", i], "a line has a debit or a credit");
66279
66545
  segment(line2, ["journalEntries", index, "lines", i]);
66280
66546
  });
66281
66547
  const debit = t.lines.reduce((sum, l) => sum + (l.debit ?? 0), 0), credit = t.lines.reduce((sum, l) => sum + (l.credit ?? 0), 0);
66282
- if (Math.abs(debit - credit) > 5e-3) issue2(["journalEntries", index, "lines"], "debits and credits differ");
66548
+ const path2 = ["journalEntries", index, "lines"];
66549
+ if (Math.abs(debit - credit) > 5e-3) issue2(path2, `debits and credits differ: debits ${money8(path2, round2(debit))}, credits ${money8(path2, round2(credit))} (off by ${money8(path2, round2(Math.abs(debit - credit)))})`);
66283
66550
  }
66284
66551
  for (const [index, t] of seed2.expenseReports.entries()) {
66285
66552
  if (!employees.has(t.employee)) issue2(["expenseReports", index, "employee"], "missing employee");
@@ -66297,10 +66564,7 @@ function checkSeed(seed2, issue2) {
66297
66564
  const customs = (name3, list, prefix2) => list.forEach((record4, index) => {
66298
66565
  for (const [key2, value2] of Object.entries(record4.custom ?? {})) {
66299
66566
  const field2 = fieldById.get(key2), path2 = [name3, index, "custom", key2];
66300
- if (!field2) {
66301
- issue2(path2, "undeclared custom field");
66302
- continue;
66303
- }
66567
+ if (!field2) continue;
66304
66568
  if (!key2.startsWith(prefix2)) issue2(path2, `${prefix2} fields belong here`);
66305
66569
  if (value2 === null) continue;
66306
66570
  const ok = field2.type === "checkbox" ? typeof value2 === "boolean" : ["integer", "decimal", "currency"].includes(field2.type) ? typeof value2 === "number" : field2.type === "select" ? typeof value2 === "number" && (!field2.options || field2.options.some((o) => o.id === value2)) : typeof value2 === "string";
@@ -66319,7 +66583,7 @@ function checkSeed(seed2, issue2) {
66319
66583
  const imported = ids(seed2.bankingTransactions, "bankingTransactions");
66320
66584
  ids(seed2.bankRecSuggestions, "bankRecSuggestions");
66321
66585
  for (const [i, b] of seed2.bankingTransactions.entries()) {
66322
- account2(b.account, ["bankingTransactions", i, "account"], ["Bank", "CredCard"]);
66586
+ account3(b.account, ["bankingTransactions", i, "account"], ["Bank", "CredCard"]);
66323
66587
  if (b.subsidiary !== void 0 && !subsidiaries.has(b.subsidiary)) issue2(["bankingTransactions", i, "subsidiary"], "missing subsidiary");
66324
66588
  }
66325
66589
  for (const [i, b] of seed2.bankRecSuggestions.entries()) {
@@ -66339,6 +66603,72 @@ function checkSeed(seed2, issue2) {
66339
66603
  }
66340
66604
  void items;
66341
66605
  }
66606
+ function netsuiteListId(list, value2) {
66607
+ if (value2 !== null && typeof value2 === "object" && !Array.isArray(value2)) {
66608
+ const reference = value2;
66609
+ return reference.id !== void 0 && reference.id !== null && reference.id !== "" ? netsuiteListId(list, reference.id) : netsuiteListId(list, reference.refName);
66610
+ }
66611
+ if (typeof value2 === "number") return list.some((entry2) => entry2.id === value2) ? value2 : void 0;
66612
+ if (typeof value2 !== "string" || value2.trim() === "") return void 0;
66613
+ const key2 = value2.trim().toLowerCase(), leaf = key2.split(" : ").at(-1);
66614
+ const found = list.find((entry2) => entry2.name.toLowerCase() === key2 || entry2.symbol?.toLowerCase() === key2) ?? list.find((entry2) => entry2.name.toLowerCase() === leaf);
66615
+ return found?.id ?? (/^\d{1,10}$/.test(key2) ? netsuiteListId(list, Number(key2)) : void 0);
66616
+ }
66617
+ var NETSUITE_SEED_LISTS = {
66618
+ customer: "customers",
66619
+ vendor: "vendors",
66620
+ contact: "contacts",
66621
+ employee: "employees",
66622
+ account: "accounts",
66623
+ subsidiary: "subsidiaries",
66624
+ currency: "currencies",
66625
+ term: "terms",
66626
+ department: "departments",
66627
+ location: "locations",
66628
+ classification: "classes",
66629
+ expenseCategory: "expenseCategories",
66630
+ currencyRate: "currencyRates",
66631
+ bankingTransaction: "bankingTransactions",
66632
+ bankRecSuggestion: "bankRecSuggestions",
66633
+ estimate: "estimates",
66634
+ salesOrder: "salesOrders",
66635
+ itemFulfillment: "itemFulfillments",
66636
+ invoice: "invoices",
66637
+ cashSale: "cashSales",
66638
+ cashRefund: "cashRefunds",
66639
+ creditMemo: "creditMemos",
66640
+ customerPayment: "customerPayments",
66641
+ customerDeposit: "customerDeposits",
66642
+ customerRefund: "customerRefunds",
66643
+ purchaseOrder: "purchaseOrders",
66644
+ itemReceipt: "itemReceipts",
66645
+ vendorBill: "vendorBills",
66646
+ vendorCredit: "vendorCredits",
66647
+ vendorPayment: "vendorPayments",
66648
+ journalEntry: "journalEntries",
66649
+ expenseReport: "expenseReports",
66650
+ ...Object.fromEntries(NETSUITE_ITEM_TYPES.map((type) => [type, "items"]))
66651
+ };
66652
+ function netsuiteSeedList(seed2, type) {
66653
+ const list = NETSUITE_SEED_LISTS[type];
66654
+ if (list === void 0) return [];
66655
+ return list === "items" ? seed2.items.filter((item2) => item2.type === type) : seed2[list];
66656
+ }
66657
+ function checkRecords(seed2, issue2) {
66658
+ const seen = /* @__PURE__ */ new Map();
66659
+ for (const [index, record4] of seed2.records.entries()) {
66660
+ const key2 = record4.type.toLowerCase(), ids = seen.get(key2) ?? /* @__PURE__ */ new Set();
66661
+ if (ids.has(record4.id)) issue2(["records", index, "id"], `duplicate ID ${record4.id} for ${record4.type}`);
66662
+ ids.add(record4.id);
66663
+ seen.set(key2, ids);
66664
+ }
66665
+ for (const key2 of seen.keys()) {
66666
+ const modeled = netsuiteRecordTypes.find((type) => type.toLowerCase() === key2);
66667
+ if (modeled === void 0 || !netsuiteSeedList(seed2, modeled).length) continue;
66668
+ const index = seed2.records.findIndex((record4) => record4.type.toLowerCase() === key2);
66669
+ issue2(["records", index, "type"], `${modeled} records are also in ${NETSUITE_SEED_LISTS[modeled]}: keep the type in one of the two`);
66670
+ }
66671
+ }
66342
66672
  var netsuiteStarterSeed = {
66343
66673
  account: { id: "7654321", company: "Acme" },
66344
66674
  policy: { billApproval: true, approveBills: true, salesOrderApproval: false },
@@ -66404,10 +66734,11 @@ var netsuiteStarterSeed = {
66404
66734
  };
66405
66735
  var NetsuiteRecordCheckSchema = external_exports.strictObject({
66406
66736
  type: external_exports.enum(netsuiteRecordTypes),
66407
- id: id8,
66737
+ id: id8.optional(),
66738
+ externalId: text11.optional(),
66408
66739
  fields: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
66409
66740
  apply: external_exports.array(application).optional()
66410
- });
66741
+ }).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both", path: ["id"] });
66411
66742
  var NetsuiteUnchangedCheckSchema = external_exports.strictObject({ types: external_exports.array(external_exports.enum(netsuiteRecordTypes)).min(1) });
66412
66743
  var NetsuiteCountCheckSchema = external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), count: external_exports.number().int().min(0) });
66413
66744
 
@@ -66681,6 +67012,7 @@ var CheckSchema = external_exports.union([
66681
67012
  external_exports.strictObject({ id: external_exports.string(), state: StateCheckSchema }),
66682
67013
  external_exports.strictObject({ id: external_exports.string(), trace: TraceCheckSchema }),
66683
67014
  external_exports.strictObject({ id: external_exports.string(), judge: external_exports.string() }),
67015
+ external_exports.strictObject({ id: external_exports.string(), answer: AnswerCheckSchema }),
66684
67016
  ...ProcessCheckSchemas
66685
67017
  ]);
66686
67018
  var SceneSchema = external_exports.strictObject({
@@ -66721,7 +67053,7 @@ var metric = new RegExp(`^(avg|sum|min|max):([A-Za-z_][A-Za-z0-9_.]*)\\{([^{}]+)
66721
67053
 
66722
67054
  // packages/core/src/scene/load.ts
66723
67055
  var import_yaml = __toESM(require_dist3(), 1);
66724
- var CHECK_KINDS = ["state", "trace", "judge", ...PROCESS_CHECK_KINDS];
67056
+ var CHECK_KINDS = ["state", "trace", "judge", "answer", ...PROCESS_CHECK_KINDS];
66725
67057
  var ChecksSchema = external_exports.array(CheckSchema);
66726
67058
 
66727
67059
  // packages/core/src/addresses.ts
@@ -66767,6 +67099,58 @@ var WorldFileSchema = external_exports.strictObject({ version: external_exports.
66767
67099
  var BODY_KEYS = Object.keys(body2);
66768
67100
  var FILE_KEYS = ["version", "id", ...BODY_KEYS];
66769
67101
 
67102
+ // packages/core/src/datasets/netsuite-pe/generate.ts
67103
+ var ACCOUNTS = [
67104
+ { id: 1, number: "1000", name: "Operating Checking", type: "Bank" },
67105
+ { id: 2, number: "1010", name: "Payroll Checking", type: "Bank" },
67106
+ { id: 3, number: "1020", name: "Lockbox Collections", type: "Bank" },
67107
+ { id: 4, number: "1050", name: "Operating Account EUR", type: "Bank" },
67108
+ { id: 5, number: "1100", name: "Accounts Receivable", type: "AcctRec" },
67109
+ { id: 6, number: "1200", name: "Undeposited Funds", type: "OthCurrAsset" },
67110
+ { id: 7, number: "1300", name: "Inventory Asset", type: "OthCurrAsset" },
67111
+ { id: 8, number: "1400", name: "Prepaid Expenses", type: "OthCurrAsset" },
67112
+ { id: 9, number: "1500", name: "Machinery & Equipment", type: "FixedAsset" },
67113
+ { id: 10, number: "1590", name: "Accumulated Depreciation", type: "FixedAsset" },
67114
+ { id: 11, number: "2000", name: "Accounts Payable", type: "AcctPay" },
67115
+ { id: 12, number: "2050", name: "Inventory Received Not Billed", type: "OthCurrLiab" },
67116
+ { id: 13, number: "2100", name: "Accrued Expenses", type: "OthCurrLiab" },
67117
+ { id: 14, number: "2150", name: "Accrued Payroll", type: "OthCurrLiab" },
67118
+ { id: 15, number: "2200", name: "Customer Deposits", type: "OthCurrLiab" },
67119
+ { id: 16, number: "2500", name: "Revolving Credit Facility", type: "LongTermLiab" },
67120
+ { id: 17, number: "3000", name: "Retained Earnings", type: "Equity" },
67121
+ { id: 18, number: "4000", name: "Product Sales", type: "Income" },
67122
+ { id: 19, number: "4100", name: "Service Revenue", type: "Income" },
67123
+ { id: 20, number: "5000", name: "Cost of Goods Sold", type: "COGS" },
67124
+ { id: 21, number: "5100", name: "Purchase Price Variance", type: "COGS" },
67125
+ { id: 22, number: "6000", name: "Salaries & Wages", type: "Expense" },
67126
+ { id: 23, number: "6050", name: "Temporary Labor", type: "Expense" },
67127
+ { id: 24, number: "6100", name: "Rent", type: "Expense" },
67128
+ { id: 25, number: "6150", name: "Sales Commissions", type: "Expense" },
67129
+ { id: 26, number: "6200", name: "Utilities", type: "Expense" },
67130
+ { id: 27, number: "6300", name: "Freight & Logistics", type: "Expense" },
67131
+ { id: 28, number: "6400", name: "Professional Fees", type: "Expense" },
67132
+ { id: 29, number: "6500", name: "Software & IT", type: "Expense" },
67133
+ { id: 30, number: "6600", name: "Travel", type: "Expense" },
67134
+ { id: 31, number: "6650", name: "Meals", type: "Expense" },
67135
+ { id: 32, number: "6680", name: "Mileage", type: "Expense" },
67136
+ { id: 33, number: "6700", name: "Insurance", type: "Expense" },
67137
+ { id: 34, number: "6800", name: "Repairs & Maintenance", type: "Expense" },
67138
+ { id: 35, number: "6900", name: "Bank Fees", type: "Expense" },
67139
+ { id: 36, number: "6950", name: "Depreciation", type: "Expense" },
67140
+ { id: 37, number: "6970", name: "Management Fees", type: "Expense" },
67141
+ { id: 38, number: "7100", name: "Interest Expense", type: "OthExpense" }
67142
+ ];
67143
+ var account2 = (number6) => ACCOUNTS.find((a) => a.number === number6).id;
67144
+ var SUB = { holdings: 1, flow: 2, kell: 3, europe: 4 };
67145
+ var SEGMENT_SUBSIDIARY = { 1: SUB.flow, 2: SUB.kell, 3: SUB.europe };
67146
+ var CATEGORIES = [
67147
+ { id: 1, name: "Travel", account: account2("6600") },
67148
+ { id: 2, name: "Meals", account: account2("6650") },
67149
+ { id: 3, name: "Lodging", account: account2("6600") },
67150
+ { id: 4, name: "Mileage", account: account2("6680") },
67151
+ { id: 5, name: "Supplies", account: account2("6800") }
67152
+ ];
67153
+
66770
67154
  // packages/core/src/test-file.ts
66771
67155
  var StartSchema = external_exports.strictObject({
66772
67156
  message: external_exports.strictObject({ ref: external_exports.string().min(1).optional(), from: external_exports.string().min(1), in: external_exports.string().min(1), text: external_exports.string().min(1), thread_of: external_exports.string().min(1).optional() }).optional(),
@@ -66809,6 +67193,10 @@ var TestFileDocument = external_exports.strictObject({
66809
67193
  pass: SceneSchema.shape.pass
66810
67194
  });
66811
67195
 
67196
+ // packages/core/src/world/file-check.ts
67197
+ var WORLD_FILE_WARN_BYTES = 16 * 1024 * 1024;
67198
+ var WORLD_BUNDLE_FILE_MAX_BYTES = 32 * 1024 * 1024;
67199
+
66812
67200
  // packages/core/src/test-data/schema.ts
66813
67201
  var id9 = external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
66814
67202
  var version3 = external_exports.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/, "use an exact version, such as 1.0.0");
@@ -67268,6 +67656,23 @@ var SandboxConfigurationSchema = external_exports.strictObject({
67268
67656
  datasets: external_exports.array(DatasetSchema)
67269
67657
  });
67270
67658
 
67659
+ // packages/core/src/tools/netsuite-records.ts
67660
+ var NAMED_TARGETS = {
67661
+ ...Object.fromEntries(netsuiteRecordTypes.map((type) => [type.toLowerCase(), type])),
67662
+ class: "classification",
67663
+ terms: "term",
67664
+ entity: "entity",
67665
+ company: "entity",
67666
+ item: "item",
67667
+ transaction: "transaction",
67668
+ createdfrom: "transaction",
67669
+ salesrep: "employee",
67670
+ supervisor: "employee",
67671
+ postingperiod: "accountingPeriod"
67672
+ };
67673
+ var TRANSACTIONS = new Set(NETSUITE_TRANSACTION_TYPES);
67674
+ var ITEMS = new Set(NETSUITE_ITEM_TYPES);
67675
+
67271
67676
  // backend/src/mcp/configuration.ts
67272
67677
  function validateMcpConnection(connection) {
67273
67678
  let url3;