industrial-model 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __typeError = (msg) => {
10
- throw TypeError(msg);
11
- };
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
9
  var __commonJS = (cb, mod) => function __require() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ try {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ } catch (e) {
13
+ throw mod = 0, e;
14
+ }
15
15
  };
16
16
  var __copyProps = (to, from, except, desc) => {
17
17
  if (from && typeof from === "object" || typeof from === "function") {
@@ -29,12 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
30
  mod
31
31
  ));
32
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
33
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
35
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
37
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
38
32
 
39
33
  // node_modules/commander/lib/error.js
40
34
  var require_error = __commonJS({
@@ -3517,12 +3511,10 @@ var require_lib = __commonJS({
3517
3511
  "node_modules/mute-stream/lib/index.js"(exports2, module2) {
3518
3512
  "use strict";
3519
3513
  var Stream = require("stream");
3520
- var _isTTY, _MuteStream_instances, destSrc_fn, proxy_fn;
3521
3514
  var MuteStream2 = class extends Stream {
3515
+ #isTTY = null;
3522
3516
  constructor(opts = {}) {
3523
3517
  super(opts);
3524
- __privateAdd(this, _MuteStream_instances);
3525
- __privateAdd(this, _isTTY, null);
3526
3518
  this.writable = this.readable = true;
3527
3519
  this.muted = false;
3528
3520
  this.on("pipe", this._onpipe);
@@ -3530,21 +3522,38 @@ var require_lib = __commonJS({
3530
3522
  this._prompt = opts.prompt || null;
3531
3523
  this._hadControl = false;
3532
3524
  }
3525
+ #destSrc(key, def) {
3526
+ if (this._dest) {
3527
+ return this._dest[key];
3528
+ }
3529
+ if (this._src) {
3530
+ return this._src[key];
3531
+ }
3532
+ return def;
3533
+ }
3534
+ #proxy(method, ...args) {
3535
+ if (typeof this._dest?.[method] === "function") {
3536
+ this._dest[method](...args);
3537
+ }
3538
+ if (typeof this._src?.[method] === "function") {
3539
+ this._src[method](...args);
3540
+ }
3541
+ }
3533
3542
  get isTTY() {
3534
- if (__privateGet(this, _isTTY) !== null) {
3535
- return __privateGet(this, _isTTY);
3543
+ if (this.#isTTY !== null) {
3544
+ return this.#isTTY;
3536
3545
  }
3537
- return __privateMethod(this, _MuteStream_instances, destSrc_fn).call(this, "isTTY", false);
3546
+ return this.#destSrc("isTTY", false);
3538
3547
  }
3539
3548
  // basically just get replace the getter/setter with a regular value
3540
3549
  set isTTY(val) {
3541
- __privateSet(this, _isTTY, val);
3550
+ this.#isTTY = val;
3542
3551
  }
3543
3552
  get rows() {
3544
- return __privateMethod(this, _MuteStream_instances, destSrc_fn).call(this, "rows");
3553
+ return this.#destSrc("rows");
3545
3554
  }
3546
3555
  get columns() {
3547
- return __privateMethod(this, _MuteStream_instances, destSrc_fn).call(this, "columns");
3556
+ return this.#destSrc("columns");
3548
3557
  }
3549
3558
  mute() {
3550
3559
  this.muted = true;
@@ -3607,32 +3616,13 @@ var require_lib = __commonJS({
3607
3616
  this.emit("end");
3608
3617
  }
3609
3618
  destroy(...args) {
3610
- return __privateMethod(this, _MuteStream_instances, proxy_fn).call(this, "destroy", ...args);
3619
+ return this.#proxy("destroy", ...args);
3611
3620
  }
3612
3621
  destroySoon(...args) {
3613
- return __privateMethod(this, _MuteStream_instances, proxy_fn).call(this, "destroySoon", ...args);
3622
+ return this.#proxy("destroySoon", ...args);
3614
3623
  }
3615
3624
  close(...args) {
3616
- return __privateMethod(this, _MuteStream_instances, proxy_fn).call(this, "close", ...args);
3617
- }
3618
- };
3619
- _isTTY = new WeakMap();
3620
- _MuteStream_instances = new WeakSet();
3621
- destSrc_fn = function(key, def) {
3622
- if (this._dest) {
3623
- return this._dest[key];
3624
- }
3625
- if (this._src) {
3626
- return this._src[key];
3627
- }
3628
- return def;
3629
- };
3630
- proxy_fn = function(method, ...args) {
3631
- if (typeof this._dest?.[method] === "function") {
3632
- this._dest[method](...args);
3633
- }
3634
- if (typeof this._src?.[method] === "function") {
3635
- this._src[method](...args);
3625
+ return this.#proxy("close", ...args);
3636
3626
  }
3637
3627
  };
3638
3628
  module2.exports = MuteStream2;
@@ -214422,37 +214412,25 @@ var isEnterKey = (key) => key.name === "enter" || key.name === "return";
214422
214412
 
214423
214413
  // node_modules/@inquirer/core/dist/lib/errors.js
214424
214414
  var AbortPromptError = class extends Error {
214415
+ name = "AbortPromptError";
214416
+ message = "Prompt was aborted";
214425
214417
  constructor(options) {
214426
214418
  super();
214427
- __publicField(this, "name", "AbortPromptError");
214428
- __publicField(this, "message", "Prompt was aborted");
214429
214419
  this.cause = options?.cause;
214430
214420
  }
214431
214421
  };
214432
214422
  var CancelPromptError = class extends Error {
214433
- constructor() {
214434
- super(...arguments);
214435
- __publicField(this, "name", "CancelPromptError");
214436
- __publicField(this, "message", "Prompt was canceled");
214437
- }
214423
+ name = "CancelPromptError";
214424
+ message = "Prompt was canceled";
214438
214425
  };
214439
214426
  var ExitPromptError = class extends Error {
214440
- constructor() {
214441
- super(...arguments);
214442
- __publicField(this, "name", "ExitPromptError");
214443
- }
214427
+ name = "ExitPromptError";
214444
214428
  };
214445
214429
  var HookError = class extends Error {
214446
- constructor() {
214447
- super(...arguments);
214448
- __publicField(this, "name", "HookError");
214449
- }
214430
+ name = "HookError";
214450
214431
  };
214451
214432
  var ValidationError = class extends Error {
214452
- constructor() {
214453
- super(...arguments);
214454
- __publicField(this, "name", "ValidationError");
214455
- }
214433
+ name = "ValidationError";
214456
214434
  };
214457
214435
 
214458
214436
  // node_modules/@inquirer/core/dist/lib/use-state.js
@@ -215481,17 +215459,17 @@ var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
215481
215459
  var global2 = globalThis;
215482
215460
  var ObjectDefineProperty = Object.defineProperty.bind(Object);
215483
215461
  var Emitter = class {
215462
+ emitted = {
215463
+ afterExit: false,
215464
+ exit: false
215465
+ };
215466
+ listeners = {
215467
+ afterExit: [],
215468
+ exit: []
215469
+ };
215470
+ count = 0;
215471
+ id = Math.random();
215484
215472
  constructor() {
215485
- __publicField(this, "emitted", {
215486
- afterExit: false,
215487
- exit: false
215488
- });
215489
- __publicField(this, "listeners", {
215490
- afterExit: [],
215491
- exit: []
215492
- });
215493
- __publicField(this, "count", 0);
215494
- __publicField(this, "id", Math.random());
215495
215473
  if (global2[kExitEmitter]) {
215496
215474
  return global2[kExitEmitter];
215497
215475
  }
@@ -215557,129 +215535,119 @@ var SignalExitFallback = class extends SignalExitBase {
215557
215535
  unload() {
215558
215536
  }
215559
215537
  };
215560
- var _hupSig, _emitter, _process, _originalProcessEmit, _originalProcessReallyExit, _sigListeners, _loaded, _SignalExit_instances, processReallyExit_fn, processEmit_fn;
215561
215538
  var SignalExit = class extends SignalExitBase {
215539
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
215540
+ // so use a supported signal instead
215541
+ /* c8 ignore start */
215542
+ #hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
215543
+ /* c8 ignore stop */
215544
+ #emitter = new Emitter();
215545
+ #process;
215546
+ #originalProcessEmit;
215547
+ #originalProcessReallyExit;
215548
+ #sigListeners = {};
215549
+ #loaded = false;
215562
215550
  constructor(process4) {
215563
215551
  super();
215564
- __privateAdd(this, _SignalExit_instances);
215565
- // "SIGHUP" throws an `ENOSYS` error on Windows,
215566
- // so use a supported signal instead
215567
- /* c8 ignore start */
215568
- __privateAdd(this, _hupSig, process3.platform === "win32" ? "SIGINT" : "SIGHUP");
215569
- /* c8 ignore stop */
215570
- __privateAdd(this, _emitter, new Emitter());
215571
- __privateAdd(this, _process);
215572
- __privateAdd(this, _originalProcessEmit);
215573
- __privateAdd(this, _originalProcessReallyExit);
215574
- __privateAdd(this, _sigListeners, {});
215575
- __privateAdd(this, _loaded, false);
215576
- __privateSet(this, _process, process4);
215577
- __privateSet(this, _sigListeners, {});
215552
+ this.#process = process4;
215553
+ this.#sigListeners = {};
215578
215554
  for (const sig of signals) {
215579
- __privateGet(this, _sigListeners)[sig] = () => {
215580
- const listeners = __privateGet(this, _process).listeners(sig);
215581
- let { count } = __privateGet(this, _emitter);
215555
+ this.#sigListeners[sig] = () => {
215556
+ const listeners = this.#process.listeners(sig);
215557
+ let { count } = this.#emitter;
215582
215558
  const p = process4;
215583
215559
  if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
215584
215560
  count += p.__signal_exit_emitter__.count;
215585
215561
  }
215586
215562
  if (listeners.length === count) {
215587
215563
  this.unload();
215588
- const ret = __privateGet(this, _emitter).emit("exit", null, sig);
215589
- const s = sig === "SIGHUP" ? __privateGet(this, _hupSig) : sig;
215564
+ const ret = this.#emitter.emit("exit", null, sig);
215565
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
215590
215566
  if (!ret)
215591
215567
  process4.kill(process4.pid, s);
215592
215568
  }
215593
215569
  };
215594
215570
  }
215595
- __privateSet(this, _originalProcessReallyExit, process4.reallyExit);
215596
- __privateSet(this, _originalProcessEmit, process4.emit);
215571
+ this.#originalProcessReallyExit = process4.reallyExit;
215572
+ this.#originalProcessEmit = process4.emit;
215597
215573
  }
215598
215574
  onExit(cb, opts) {
215599
- if (!processOk(__privateGet(this, _process))) {
215575
+ if (!processOk(this.#process)) {
215600
215576
  return () => {
215601
215577
  };
215602
215578
  }
215603
- if (__privateGet(this, _loaded) === false) {
215579
+ if (this.#loaded === false) {
215604
215580
  this.load();
215605
215581
  }
215606
215582
  const ev = opts?.alwaysLast ? "afterExit" : "exit";
215607
- __privateGet(this, _emitter).on(ev, cb);
215583
+ this.#emitter.on(ev, cb);
215608
215584
  return () => {
215609
- __privateGet(this, _emitter).removeListener(ev, cb);
215610
- if (__privateGet(this, _emitter).listeners["exit"].length === 0 && __privateGet(this, _emitter).listeners["afterExit"].length === 0) {
215585
+ this.#emitter.removeListener(ev, cb);
215586
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
215611
215587
  this.unload();
215612
215588
  }
215613
215589
  };
215614
215590
  }
215615
215591
  load() {
215616
- if (__privateGet(this, _loaded)) {
215592
+ if (this.#loaded) {
215617
215593
  return;
215618
215594
  }
215619
- __privateSet(this, _loaded, true);
215620
- __privateGet(this, _emitter).count += 1;
215595
+ this.#loaded = true;
215596
+ this.#emitter.count += 1;
215621
215597
  for (const sig of signals) {
215622
215598
  try {
215623
- const fn = __privateGet(this, _sigListeners)[sig];
215599
+ const fn = this.#sigListeners[sig];
215624
215600
  if (fn)
215625
- __privateGet(this, _process).on(sig, fn);
215601
+ this.#process.on(sig, fn);
215626
215602
  } catch (_) {
215627
215603
  }
215628
215604
  }
215629
- __privateGet(this, _process).emit = (ev, ...a) => {
215630
- return __privateMethod(this, _SignalExit_instances, processEmit_fn).call(this, ev, ...a);
215605
+ this.#process.emit = (ev, ...a) => {
215606
+ return this.#processEmit(ev, ...a);
215631
215607
  };
215632
- __privateGet(this, _process).reallyExit = (code) => {
215633
- return __privateMethod(this, _SignalExit_instances, processReallyExit_fn).call(this, code);
215608
+ this.#process.reallyExit = (code) => {
215609
+ return this.#processReallyExit(code);
215634
215610
  };
215635
215611
  }
215636
215612
  unload() {
215637
- if (!__privateGet(this, _loaded)) {
215613
+ if (!this.#loaded) {
215638
215614
  return;
215639
215615
  }
215640
- __privateSet(this, _loaded, false);
215616
+ this.#loaded = false;
215641
215617
  signals.forEach((sig) => {
215642
- const listener = __privateGet(this, _sigListeners)[sig];
215618
+ const listener = this.#sigListeners[sig];
215643
215619
  if (!listener) {
215644
215620
  throw new Error("Listener not defined for signal: " + sig);
215645
215621
  }
215646
215622
  try {
215647
- __privateGet(this, _process).removeListener(sig, listener);
215623
+ this.#process.removeListener(sig, listener);
215648
215624
  } catch (_) {
215649
215625
  }
215650
215626
  });
215651
- __privateGet(this, _process).emit = __privateGet(this, _originalProcessEmit);
215652
- __privateGet(this, _process).reallyExit = __privateGet(this, _originalProcessReallyExit);
215653
- __privateGet(this, _emitter).count -= 1;
215627
+ this.#process.emit = this.#originalProcessEmit;
215628
+ this.#process.reallyExit = this.#originalProcessReallyExit;
215629
+ this.#emitter.count -= 1;
215654
215630
  }
215655
- };
215656
- _hupSig = new WeakMap();
215657
- _emitter = new WeakMap();
215658
- _process = new WeakMap();
215659
- _originalProcessEmit = new WeakMap();
215660
- _originalProcessReallyExit = new WeakMap();
215661
- _sigListeners = new WeakMap();
215662
- _loaded = new WeakMap();
215663
- _SignalExit_instances = new WeakSet();
215664
- processReallyExit_fn = function(code) {
215665
- if (!processOk(__privateGet(this, _process))) {
215666
- return 0;
215631
+ #processReallyExit(code) {
215632
+ if (!processOk(this.#process)) {
215633
+ return 0;
215634
+ }
215635
+ this.#process.exitCode = code || 0;
215636
+ this.#emitter.emit("exit", this.#process.exitCode, null);
215637
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
215667
215638
  }
215668
- __privateGet(this, _process).exitCode = code || 0;
215669
- __privateGet(this, _emitter).emit("exit", __privateGet(this, _process).exitCode, null);
215670
- return __privateGet(this, _originalProcessReallyExit).call(__privateGet(this, _process), __privateGet(this, _process).exitCode);
215671
- };
215672
- processEmit_fn = function(ev, ...args) {
215673
- const og = __privateGet(this, _originalProcessEmit);
215674
- if (ev === "exit" && processOk(__privateGet(this, _process))) {
215675
- if (typeof args[0] === "number") {
215676
- __privateGet(this, _process).exitCode = args[0];
215639
+ #processEmit(ev, ...args) {
215640
+ const og = this.#originalProcessEmit;
215641
+ if (ev === "exit" && processOk(this.#process)) {
215642
+ if (typeof args[0] === "number") {
215643
+ this.#process.exitCode = args[0];
215644
+ }
215645
+ const ret = og.call(this.#process, ev, ...args);
215646
+ this.#emitter.emit("exit", this.#process.exitCode, null);
215647
+ return ret;
215648
+ } else {
215649
+ return og.call(this.#process, ev, ...args);
215677
215650
  }
215678
- const ret = og.call(__privateGet(this, _process), ev, ...args);
215679
- __privateGet(this, _emitter).emit("exit", __privateGet(this, _process).exitCode, null);
215680
- return ret;
215681
- } else {
215682
- return og.call(__privateGet(this, _process), ev, ...args);
215683
215651
  }
215684
215652
  };
215685
215653
  var process3 = globalThis.process;
@@ -215735,12 +215703,12 @@ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines -
215735
215703
  var height = (content) => content.split("\n").length;
215736
215704
  var lastLine = (content) => content.split("\n").pop() ?? "";
215737
215705
  var ScreenManager = class {
215706
+ // These variables are keeping information to allow correct prompt re-rendering
215707
+ height = 0;
215708
+ extraLinesUnderPrompt = 0;
215709
+ cursorPos;
215710
+ rl;
215738
215711
  constructor(rl) {
215739
- // These variables are keeping information to allow correct prompt re-rendering
215740
- __publicField(this, "height", 0);
215741
- __publicField(this, "extraLinesUnderPrompt", 0);
215742
- __publicField(this, "cursorPos");
215743
- __publicField(this, "rl");
215744
215712
  this.rl = rl;
215745
215713
  this.cursorPos = rl.getCursorPos();
215746
215714
  }
@@ -215922,9 +215890,9 @@ function createPrompt(view) {
215922
215890
  // node_modules/@inquirer/core/dist/lib/Separator.js
215923
215891
  var import_node_util3 = require("util");
215924
215892
  var Separator = class {
215893
+ separator = (0, import_node_util3.styleText)("dim", Array.from({ length: 15 }).join(dist_default.line));
215894
+ type = "separator";
215925
215895
  constructor(separator) {
215926
- __publicField(this, "separator", (0, import_node_util3.styleText)("dim", Array.from({ length: 15 }).join(dist_default.line)));
215927
- __publicField(this, "type", "separator");
215928
215896
  if (separator) {
215929
215897
  this.separator = separator;
215930
215898
  }
@@ -216425,6 +216393,7 @@ var CogniteSdkAdapter = class {
216425
216393
  constructor(client) {
216426
216394
  this.client = client;
216427
216395
  }
216396
+ client;
216428
216397
  async retrieveDataModels(ids, options) {
216429
216398
  const response = await this.client.dataModels.retrieve(ids, options);
216430
216399
  return {
@@ -216434,6 +216403,11 @@ var CogniteSdkAdapter = class {
216434
216403
  }))
216435
216404
  };
216436
216405
  }
216406
+ async retrieveViews(ids) {
216407
+ const cleanIds = ids.map(({ space, externalId, version }) => ({ space, externalId, version }));
216408
+ const response = await this.client.views.retrieve(cleanIds);
216409
+ return { items: response.items };
216410
+ }
216437
216411
  async queryInstances(request) {
216438
216412
  const response = await this.client.instances.query(
216439
216413
  request
@@ -216552,13 +216526,31 @@ function mapDatapointResult(item) {
216552
216526
  };
216553
216527
  }
216554
216528
 
216529
+ // src/utils/view.ts
216530
+ function isViewPropertyDefinition(p) {
216531
+ return "container" in p;
216532
+ }
216533
+ function isReverseDirectRelation(p) {
216534
+ return "through" in p;
216535
+ }
216536
+ function isEdgeConnection(p) {
216537
+ return !isViewPropertyDefinition(p) && !isReverseDirectRelation(p) && "source" in p;
216538
+ }
216539
+ function getDirectRelationSource(p) {
216540
+ const type = p.type;
216541
+ if (type.type === "direct" && type.source) return type.source;
216542
+ return void 0;
216543
+ }
216544
+
216555
216545
  // src/mappers/view-mapper.ts
216556
216546
  var ViewMapper = class {
216557
216547
  constructor(cognite, dataModelId) {
216558
216548
  this.cognite = cognite;
216559
216549
  this.dataModelId = dataModelId;
216560
- this.cachePromise = null;
216561
216550
  }
216551
+ cognite;
216552
+ dataModelId;
216553
+ cachePromise = null;
216562
216554
  async getView(externalId) {
216563
216555
  const views = await this.loadViews();
216564
216556
  const view = views.get(externalId);
@@ -216598,9 +216590,44 @@ var ViewMapper = class {
216598
216590
  for (const view of dm.views ?? []) {
216599
216591
  views.set(view.externalId, view);
216600
216592
  }
216593
+ await this.loadDependencyViews(views);
216601
216594
  return views;
216602
216595
  }
216596
+ async loadDependencyViews(views) {
216597
+ const pending = /* @__PURE__ */ new Map();
216598
+ for (const view of views.values()) {
216599
+ for (const property of Object.values(view.properties)) {
216600
+ for (const ref of collectPropertyRefs(property)) {
216601
+ if (!views.has(ref.externalId) && !pending.has(ref.externalId)) {
216602
+ pending.set(ref.externalId, ref);
216603
+ }
216604
+ }
216605
+ }
216606
+ }
216607
+ if (pending.size === 0) return;
216608
+ const sizeBefore = views.size;
216609
+ const fetched = await this.cognite.retrieveViews(Array.from(pending.values()));
216610
+ for (const view of fetched.items) {
216611
+ views.set(view.externalId, view);
216612
+ }
216613
+ if (views.size > sizeBefore) {
216614
+ await this.loadDependencyViews(views);
216615
+ }
216616
+ }
216603
216617
  };
216618
+ function collectPropertyRefs(property) {
216619
+ if (isViewPropertyDefinition(property)) {
216620
+ const source = getDirectRelationSource(property);
216621
+ return source ? [source] : [];
216622
+ }
216623
+ if (isReverseDirectRelation(property)) {
216624
+ return [property.source, property.through.source];
216625
+ }
216626
+ if (isEdgeConnection(property)) {
216627
+ return [property.source];
216628
+ }
216629
+ return [];
216630
+ }
216604
216631
 
216605
216632
  // src/cli/generator/json-types-parser.ts
216606
216633
  var fs = __toESM(require("fs"), 1);
@@ -216700,22 +216727,6 @@ function toCamel(str) {
216700
216727
  return pascal.charAt(0).toLowerCase() + pascal.slice(1);
216701
216728
  }
216702
216729
 
216703
- // src/utils/view.ts
216704
- function isViewPropertyDefinition(p) {
216705
- return "container" in p;
216706
- }
216707
- function isReverseDirectRelation(p) {
216708
- return "through" in p;
216709
- }
216710
- function isEdgeConnection(p) {
216711
- return !isViewPropertyDefinition(p) && !isReverseDirectRelation(p) && "source" in p;
216712
- }
216713
- function getDirectRelationSource(p) {
216714
- const type = p.type;
216715
- if (type.type === "direct" && type.source) return type.source;
216716
- return void 0;
216717
- }
216718
-
216719
216730
  // src/cli/generator/constants.ts
216720
216731
  var typeMappings = {
216721
216732
  text: "string",
@@ -216735,8 +216746,19 @@ var typeMappings = {
216735
216746
  };
216736
216747
 
216737
216748
  // src/cli/generator/parser.ts
216738
- function parseViews(views) {
216739
- return views.sort((a, b) => a.externalId.localeCompare(b.externalId)).map(parseView);
216749
+ function parseViews(views, knownExternalIds) {
216750
+ const available = knownExternalIds ?? new Set(views.map((v) => v.externalId));
216751
+ const parsed = views.sort((a, b) => a.externalId.localeCompare(b.externalId)).map(parseView);
216752
+ for (const view of parsed) {
216753
+ for (const field of view.fields) {
216754
+ if (field.relationTargetExternalId && !available.has(field.relationTargetExternalId)) {
216755
+ field.relationTarget = null;
216756
+ field.relationTargetSpace = null;
216757
+ field.relationTargetExternalId = null;
216758
+ }
216759
+ }
216760
+ }
216761
+ return parsed;
216740
216762
  }
216741
216763
  function parseView(view) {
216742
216764
  const fields = [];
@@ -217503,7 +217525,7 @@ async function promptAuth(flags) {
217503
217525
  });
217504
217526
  const baseUrl = flags.baseUrl || await dist_default4({
217505
217527
  message: "CDF base URL:",
217506
- default: extracted.baseUrl || "https://az-eastus-1.cognitedata.com"
217528
+ default: extracted.baseUrl || "https://az-phx-001.cognitedata.com"
217507
217529
  });
217508
217530
  return { token, project, baseUrl };
217509
217531
  }
@@ -217621,7 +217643,7 @@ var generateCommand = new Command("generate").description("Generate TypeScript t
217621
217643
  dataModelVersion: dataModel.version,
217622
217644
  clientName: options.clientName,
217623
217645
  outputPath: options.outputPath,
217624
- packageVersion: "0.11.2"
217646
+ packageVersion: "0.12.0"
217625
217647
  });
217626
217648
  console.log(
217627
217649
  `
@@ -217662,7 +217684,7 @@ Error loading JSON types file: ${error instanceof Error ? error.message : error}
217662
217684
  });
217663
217685
 
217664
217686
  // src/cli/index.ts
217665
- var program2 = new Command().name("industrial-model").description("Code generator for Cognite Data Fusion data models").version("0.11.2");
217687
+ var program2 = new Command().name("industrial-model").description("Code generator for Cognite Data Fusion data models").version("0.12.0");
217666
217688
  program2.addCommand(generateCommand);
217667
217689
  program2.parse();
217668
217690
  /*! Bundled license information: