@ancha-labs/cli 0.4.23 → 0.4.25
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/ancha.mjs +64027 -60998
- package/lib/assets/docs/cloud.md +13 -0
- package/lib/assets/docs/scenes.md +118 -3
- package/lib/assets/harbor/companion.mjs +45782 -43648
- package/lib/assets/harbor/suiteql-worker.mjs +32 -3
- package/lib/assets/ui/app.js +107 -61
- package/lib/assets/ui/style.css +2 -0
- package/lib/mcp-entry.mjs +192 -29
- package/lib/suiteql-worker.mjs +32 -3
- package/lib/worker.mjs +62341 -59924
- package/lib/world-server.mjs +45740 -43606
- package/package.json +1 -1
|
@@ -241,6 +241,18 @@ CREATE VIEW ns_q_mediaitemfolder AS SELECT id, name, parent, description, datecr
|
|
|
241
241
|
var col = (name, type, more = {}) => ({ name, type, ...more });
|
|
242
242
|
var ref = (name, table) => col(name, "id", { ref: table });
|
|
243
243
|
var dated = [col("datecreated", "datetime"), col("lastmodifieddate", "datetime")];
|
|
244
|
+
var TRANSACTION_LINKS = `SELECT * FROM ns_q_nexttransactionlinelink
|
|
245
|
+
UNION ALL SELECT l.createdfrom, l.orderline, l."transaction", l.line,
|
|
246
|
+
CASE WHEN t.type IN ('ItemRcpt','ItemShip') THEN 'ShipRcpt' WHEN t.type IN ('VendBill','CustInvc') THEN 'OrdBill' END,
|
|
247
|
+
l.amount, p.type, t.type, t.lastmodifieddate
|
|
248
|
+
FROM ns_lines l JOIN ns_transactions t ON t.id=l."transaction" JOIN ns_transactions p ON p.id=l.createdfrom
|
|
249
|
+
WHERE l.createdfrom IS NOT NULL
|
|
250
|
+
UNION ALL SELECT t.createdfrom, 0, t.id, 0, NULL, t.total, p.type, t.type, t.lastmodifieddate
|
|
251
|
+
FROM ns_transactions t JOIN ns_transactions p ON p.id=t.createdfrom
|
|
252
|
+
WHERE NOT EXISTS (SELECT 1 FROM ns_lines l WHERE l."transaction"=t.id AND l.createdfrom=t.createdfrom)
|
|
253
|
+
AND NOT EXISTS (SELECT 1 FROM ns_applications a WHERE a.source=t.id AND a.doc=t.createdfrom)`;
|
|
254
|
+
var SYSTEM_NOTES = `SELECT ${["id", "recordid", "recordtypeid", "date", "name", "field", "oldvalue", "newvalue", "context", "type"].map((c) => `json_extract(n.value, '$.${c}') AS "${c}"`).join(", ")}
|
|
255
|
+
FROM ns_extra e, json_each(e.fields, '$.notes') n WHERE substr(e.owner,1,20)='netsuite:systemnote:'`;
|
|
244
256
|
var SUITEQL_TABLES = [
|
|
245
257
|
{ name: "customer", view: "ns_q_customer", display: "entityid", columns: [
|
|
246
258
|
col("id", "id"),
|
|
@@ -432,6 +444,9 @@ var SUITEQL_TABLES = [
|
|
|
432
444
|
col("closedondate", "date")
|
|
433
445
|
] },
|
|
434
446
|
{ name: "transaction", view: "ns_q_transaction", display: "tranid", columns: [
|
|
447
|
+
col("createdby", "id", { ref: "employee", sql: `COALESCE(
|
|
448
|
+
(SELECT json_extract(a.fields, '$.createdBy') FROM ns_extra a WHERE a.owner='netsuite:systemnote:' || ns_q_transaction.recordtype AND a.id=ns_q_transaction.id),
|
|
449
|
+
(SELECT COALESCE(json_extract(x.fields, '$.createdBy.id'),json_extract(x.fields, '$.createdby.id'),json_extract(x.fields, '$.createdBy'),json_extract(x.fields, '$.createdby')) FROM ns_extra x WHERE x.owner='transaction' AND x.id=ns_q_transaction.id))` }),
|
|
435
450
|
col("id", "id"),
|
|
436
451
|
col("tranid", "text"),
|
|
437
452
|
col("trandate", "date"),
|
|
@@ -503,7 +518,7 @@ var SUITEQL_TABLES = [
|
|
|
503
518
|
col("posting", "boolean"),
|
|
504
519
|
ref("postingperiod", "accountingperiod")
|
|
505
520
|
] },
|
|
506
|
-
...["nexttransactionlinelink", "previoustransactionlinelink"].map((name) => ({ name, view: `ns_q_${name}`, display: "linktype", columns: [
|
|
521
|
+
...["nexttransactionlinelink", "previoustransactionlinelink"].map((name) => ({ name, view: `ns_q_${name}`, source: TRANSACTION_LINKS, display: "linktype", columns: [
|
|
507
522
|
ref("previousdoc", "transaction"),
|
|
508
523
|
col("previousline", "integer"),
|
|
509
524
|
ref("nextdoc", "transaction"),
|
|
@@ -514,6 +529,18 @@ var SUITEQL_TABLES = [
|
|
|
514
529
|
col("nexttype", "text"),
|
|
515
530
|
col("lastmodifieddate", "datetime")
|
|
516
531
|
] })),
|
|
532
|
+
{ name: "systemnote", view: "ns_extra", source: SYSTEM_NOTES, display: "field", columns: [
|
|
533
|
+
col("id", "id"),
|
|
534
|
+
col("recordid", "id"),
|
|
535
|
+
col("recordtypeid", "integer"),
|
|
536
|
+
col("date", "datetime"),
|
|
537
|
+
ref("name", "entity"),
|
|
538
|
+
col("field", "text"),
|
|
539
|
+
col("oldvalue", "text"),
|
|
540
|
+
col("newvalue", "text"),
|
|
541
|
+
col("context", "text"),
|
|
542
|
+
col("type", "integer")
|
|
543
|
+
] },
|
|
517
544
|
{ name: "file", view: "ns_q_file", display: "name", columns: [
|
|
518
545
|
col("id", "id"),
|
|
519
546
|
col("name", "text"),
|
|
@@ -1293,7 +1320,9 @@ function resolve(scope, name, qualifier) {
|
|
|
1293
1320
|
scope.correlations.push(value);
|
|
1294
1321
|
return value;
|
|
1295
1322
|
}
|
|
1296
|
-
|
|
1323
|
+
const pending = { transaction: ["createdfrom", "total", "amountremaining"], transactionline: ["amount"] };
|
|
1324
|
+
const gap = owners.some((r) => r.columns.some((c) => c.origin && pending[c.origin.table.name]?.includes(name)));
|
|
1325
|
+
invalid(`Field '${qualifier ? `${qualifier}.` : ""}${name}' was not found.`, gap);
|
|
1297
1326
|
}
|
|
1298
1327
|
var key = (b) => JSON.stringify([b.sql, b.params]);
|
|
1299
1328
|
var numeric = (t) => ["id", "integer", "number"].includes(t);
|
|
@@ -1544,7 +1573,7 @@ var Compiler = class {
|
|
|
1544
1573
|
columns = [{ name: "dummy", type: "text", value: sql("") }];
|
|
1545
1574
|
} else {
|
|
1546
1575
|
const table = this.tables.find((t) => t.name === source.table);
|
|
1547
|
-
if (!table) invalid(`Record '${source.table}' was not found
|
|
1576
|
+
if (!table) invalid(`Record '${source.table}' was not found.`, source.table === "transactionlink");
|
|
1548
1577
|
const computed = table.columns.filter((c) => c.sql);
|
|
1549
1578
|
value = table.source ? sql("(", table.source, ")") : computed.length ? sql("(SELECT *, ", computed.map((c) => `${c.sql} AS ${quote(c.name)}`).join(", "), " FROM ", quote(table.view), ")") : sql(quote(table.view));
|
|
1550
1579
|
columns = table.columns.map((column) => ({ name: column.name, type: column.type, value: sql(""), origin: { table, column, relation: alias } }));
|