@arcgis/coding-components 5.1.0-next.54 → 5.1.0-next.56

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.
Files changed (87) hide show
  1. package/dist/cdn/{PKG2K3V2.js → 23B5EVBR.js} +1 -1
  2. package/dist/cdn/2RXM4OOZ.js +2 -0
  3. package/dist/cdn/2XTHR2WZ.js +2 -0
  4. package/dist/cdn/5PWITOEV.js +2 -0
  5. package/dist/cdn/A53COIII.js +6 -0
  6. package/dist/cdn/AESP7B22.js +2 -0
  7. package/dist/cdn/AHN2NEBT.js +2 -0
  8. package/dist/cdn/{54ZOADNQ.js → BXUVVQLE.js} +1 -1
  9. package/dist/cdn/BYHBHJML.js +2 -0
  10. package/dist/cdn/CLBLJN2Z.js +7 -0
  11. package/dist/cdn/CZ2DJPO4.js +2 -0
  12. package/dist/cdn/DGFH2WPL.js +2 -0
  13. package/dist/cdn/{RJRCBNNO.js → DJYSIOXC.js} +1 -1
  14. package/dist/cdn/FLNLMLTL.js +2 -0
  15. package/dist/cdn/ITDFOKJG.js +2 -0
  16. package/dist/cdn/MH4UADDE.js +2 -0
  17. package/dist/cdn/{UZJHWA6T.js → ODKUCLFB.js} +1 -1
  18. package/dist/cdn/{PVL67WGX.js → PD5NEK47.js} +1 -1
  19. package/dist/cdn/PRB6IWVU.js +2 -0
  20. package/dist/cdn/{4A2CLADY.js → QCARFVF7.js} +1 -1
  21. package/dist/cdn/{6YD47X7H.js → QF6ON7LK.js} +1 -1
  22. package/dist/cdn/QRDRCFJZ.js +2 -0
  23. package/dist/cdn/SV4IPD4A.js +2 -0
  24. package/dist/cdn/UH44LJA7.js +4 -0
  25. package/dist/cdn/VF7TALAI.js +12 -0
  26. package/dist/cdn/VPP77CFW.js +2 -0
  27. package/dist/cdn/YPMKBMXS.js +2 -0
  28. package/dist/cdn/ZHZFKZA7.js +2 -0
  29. package/dist/cdn/assets/arcade-editor/t9n/messages.en.json +1 -1
  30. package/dist/cdn/assets/code-editor/sql-expr.worker.js +120 -117
  31. package/dist/cdn/assets/code-editor/sql-layer.worker.js +10087 -0
  32. package/dist/cdn/assets/editor-variables/t9n/messages.en.json +1 -1
  33. package/dist/cdn/assets/sql-expression-editor/t9n/messages.en.json +1 -1
  34. package/dist/cdn/assets/sql-layer-editor/t9n/messages.en.json +1 -0
  35. package/dist/cdn/index.js +1 -1
  36. package/dist/cdn/main.css +1 -1
  37. package/dist/chunks/arcade-defaults.js +98 -96
  38. package/dist/chunks/arcade-service-accessors.js +40 -28
  39. package/dist/chunks/bigquery.js +186 -0
  40. package/dist/chunks/colorize.js +1 -1
  41. package/dist/chunks/fields.js +2 -2
  42. package/dist/chunks/language-defaults-base.js +733 -464
  43. package/dist/chunks/postgres.js +209 -0
  44. package/dist/chunks/setup-monaco-theme.js +28 -20
  45. package/dist/chunks/sql-expr-defaults.js +11 -10
  46. package/dist/chunks/sql-layer-defaults.js +231 -0
  47. package/dist/chunks/sql-layer-mode.js +301 -0
  48. package/dist/chunks/sqlServer.js +288 -0
  49. package/dist/chunks/utils.js +184 -0
  50. package/dist/components/arcgis-arcade-coding-assistant/customElement.js +134 -123
  51. package/dist/components/arcgis-arcade-editor/customElement.d.ts +17 -0
  52. package/dist/components/arcgis-arcade-editor/customElement.js +22 -22
  53. package/dist/components/arcgis-code-editor/customElement.d.ts +2 -1
  54. package/dist/components/arcgis-code-editor/customElement.js +91 -71
  55. package/dist/components/arcgis-editor-variables/customElement.js +50 -47
  56. package/dist/components/arcgis-sql-expression-editor/customElement.d.ts +12 -0
  57. package/dist/components/arcgis-sql-expression-editor/customElement.js +17 -17
  58. package/dist/components/arcgis-sql-layer-editor/customElement.d.ts +50 -0
  59. package/dist/components/arcgis-sql-layer-editor/customElement.js +92 -0
  60. package/dist/components/arcgis-sql-layer-editor/index.d.ts +1 -0
  61. package/dist/components/arcgis-sql-layer-editor/index.js +7 -0
  62. package/dist/components/types.d.ts +79 -2
  63. package/dist/docs/api.json +1 -1
  64. package/dist/docs/docs.json +1 -1
  65. package/dist/docs/vscode.html-custom-data.json +1 -1
  66. package/dist/docs/web-types.json +1 -1
  67. package/dist/index.d.ts +10 -0
  68. package/dist/loader.js +6 -5
  69. package/dist/types/lumina.d.ts +9 -2
  70. package/dist/types/preact.d.ts +10 -2
  71. package/dist/types/react.d.ts +11 -2
  72. package/dist/types/stencil.d.ts +9 -2
  73. package/dist/utils/data-catalog-datastore.d.ts +170 -0
  74. package/package.json +5 -5
  75. package/dist/cdn/5CO7XWOT.js +0 -2
  76. package/dist/cdn/5FXY5U3T.js +0 -2
  77. package/dist/cdn/CYC4AWZE.js +0 -2
  78. package/dist/cdn/GVO3LEFV.js +0 -2
  79. package/dist/cdn/J5X2KSYD.js +0 -2
  80. package/dist/cdn/QHJAF7L3.js +0 -6
  81. package/dist/cdn/T7GEIGWF.js +0 -2
  82. package/dist/cdn/TAXRVBJC.js +0 -2
  83. package/dist/cdn/VR5CATAW.js +0 -2
  84. package/dist/cdn/WTNM2NCZ.js +0 -2
  85. package/dist/cdn/XEUG3X2W.js +0 -2
  86. package/dist/cdn/ZJCI6LP6.js +0 -12
  87. package/dist/cdn/ZSVJAJND.js +0 -4
@@ -1,27 +1,28 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import { c as o } from "../../chunks/runtime.js";
3
- import { ref as c } from "lit/directives/ref.js";
4
- import { css as n, html as s } from "lit";
5
- import { LitElement as d, createEvent as a } from "@arcgis/lumina";
6
- import { setFocusOnElement as h } from "@arcgis/toolkit/dom";
7
- import { createFilterExpression as f } from "@arcgis/toolkit/string";
8
- import { u as m } from "../../chunks/useT9n.js";
9
- import { log as u } from "@arcgis/toolkit/log";
10
- const g = n`:host{background-color:var(--calcite-color-foreground-1);.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.sticky{position:sticky;top:0;z-index:10}calcite-flow{height:100%}calcite-list-item-group{background-color:var(--calcite-color-foreground-2);word-break:break-word}}`;
11
- function p(l) {
12
- l.key === "Enter" && l.stopPropagation();
2
+ import { c } from "../../chunks/runtime.js";
3
+ import { ref as d } from "lit/directives/ref.js";
4
+ import { css as h, html as i } from "lit";
5
+ import { LitElement as f, createEvent as l } from "@arcgis/lumina";
6
+ import { focusElement as m, getClosestElement as u } from "@arcgis/toolkit/dom";
7
+ import { createFilterExpression as g } from "@arcgis/toolkit/string";
8
+ import { u as b } from "../../chunks/useT9n.js";
9
+ import { log as p } from "@arcgis/toolkit/log";
10
+ import { g as o, h as n, j as _, k as v } from "../../chunks/utils.js";
11
+ const w = h`:host{background-color:var(--calcite-color-foreground-1);.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.sticky{position:sticky;top:0;z-index:10}calcite-flow{height:100%}calcite-list-item-group{background-color:var(--calcite-color-foreground-2);word-break:break-word}}`;
12
+ function $(a) {
13
+ a.key === "Enter" && a.stopPropagation();
13
14
  }
14
- class b extends d {
15
+ class C extends f {
15
16
  constructor() {
16
17
  super(...arguments), this._beforeBack = async () => {
17
18
  this.removeLastPanelRenderer(), this._filterValue = "";
18
- }, this.messages = m(), this._filterValue = "", this._flowItemRenderers = [], this._mode = "profile", this._mutationCounter = 1, this.loading = !1, this.closed = !1, this.arcgisInternalClosePanel = a({ bubbles: !1, composed: !1 }), this.arcgisInternalItemSelected = a({ bubbles: !1 });
19
+ }, this.messages = b(), this._filterValue = "", this._flowItemRenderers = [], this._rootPresentation = "profile", this._mutationCounter = 1, this.loading = !1, this.closed = !1, this.arcgisInternalClosePanel = l({ bubbles: !1, composed: !1 }), this.arcgisInternalItemSelected = l({ bubbles: !1 });
19
20
  }
20
21
  static {
21
- this.properties = { _filterValue: 16, _flowItemRenderers: 16, _mode: 16, _mutationCounter: 16, loading: 5, modelId: 1, closed: 5, variable: 0 };
22
+ this.properties = { _filterValue: 16, _flowItemRenderers: 16, _rootPresentation: 16, _mutationCounter: 16, loading: 5, modelId: 1, closed: 5, variable: 0, heading: 1, messageOverrides: 0 };
22
23
  }
23
24
  static {
24
- this.styles = g;
25
+ this.styles = w;
25
26
  }
26
27
  load() {
27
28
  this._variableChanged();
@@ -33,7 +34,11 @@ class b extends d {
33
34
  super.disconnectedCallback(), this._flowObserver?.disconnect();
34
35
  }
35
36
  _variableChanged() {
36
- this._mode = this.variable?.type === "featureSet" ? "featureSet" : "profile";
37
+ if (!this.variable || o(this.variable)) {
38
+ this._rootPresentation = "profile";
39
+ return;
40
+ }
41
+ this._rootPresentation = this.variable.type === "featureSet" ? "featureSetRoot" : "collectionRoot";
37
42
  }
38
43
  addPanelRenderer(e) {
39
44
  this._flowItemRenderers = [...this._flowItemRenderers, e];
@@ -41,8 +46,8 @@ class b extends d {
41
46
  removeLastPanelRenderer() {
42
47
  this._flowItemRenderers = this._flowItemRenderers.slice(0, -1);
43
48
  }
44
- _isMode(e) {
45
- return this._mode === e;
49
+ _isRootPresentation(e) {
50
+ return this._rootPresentation === e;
46
51
  }
47
52
  flowFocusHandler(e) {
48
53
  if (!e) {
@@ -50,7 +55,7 @@ class b extends d {
50
55
  return;
51
56
  }
52
57
  this._flowObserver || (this._flowObserver = new MutationObserver(() => {
53
- h(e.querySelector("calcite-flow-item:last-child"), "calcite-input");
58
+ m(u(e.querySelector("calcite-flow-item:last-child") ?? e, "calcite-input"));
54
59
  }), this._flowObserver.observe(e, { attributes: !0, attributeFilter: ["id"], childList: !0 }));
55
60
  }
56
61
  _updateFilterValue(e) {
@@ -65,65 +70,63 @@ class b extends d {
65
70
  _emitItemSelected(e, t) {
66
71
  if (t.nonInteractive)
67
72
  return;
68
- const i = e;
69
- (!i.key || i.key === "Enter") && (e.preventDefault(), this.arcgisInternalItemSelected.emit(t.snippet));
73
+ const s = e;
74
+ (!s.key || s.key === "Enter") && (e.preventDefault(), this.arcgisInternalItemSelected.emit(t.snippet));
70
75
  }
71
76
  _showCollectionPanel(e, t) {
72
77
  e.stopPropagation(), this.addPanelRenderer(
73
78
  // Add a function to render the variable
74
- (i) => this.renderCollectionBasedVariable(t, !1, i)
79
+ (s) => this.renderCollectionBasedVariable(t, !1, s)
75
80
  );
76
81
  }
77
- _getHeadingForCollection(e) {
82
+ _getHeadingForCollection(e, t = !1) {
78
83
  if (!e)
79
84
  return "";
80
- switch (this._mode) {
81
- case "profile":
82
- return this.messages.profilevariables ?? "";
83
- case "featureSet":
84
- return this.messages.fields ?? "";
85
+ if (t) {
86
+ if (this.heading)
87
+ return this.heading;
88
+ if (o(this.variable))
89
+ return this.variable.definition?.label ?? this.messages.profilevariables ?? "Profile variables";
90
+ if (this._isRootPresentation("featureSetRoot"))
91
+ return this.messages.fields ?? "Fields";
92
+ if (this._isRootPresentation("collectionRoot"))
93
+ return this.messages.tables ?? "Tables";
85
94
  }
95
+ return n(e) || _(e) ? this.messages.fields ?? "Fields" : this.messages.profilevariables ?? "Profile variables";
86
96
  }
87
97
  _getDescriptionForCollection(e) {
88
- if (!e)
89
- return "";
90
- switch (this._mode) {
91
- case "profile":
92
- return e.breadcrumb;
93
- case "featureSet":
94
- return e.variables[0]?.getLabel() ?? "";
95
- }
98
+ return e ? n(e) ? e.variables[0]?.getLabel() ?? "" : v(e) ? e.datastoreInfo?.name ?? e.getDescription() ?? "" : e.breadcrumb : "";
96
99
  }
97
- renderCollectionBasedVariable(e, t = !1, i = !1) {
100
+ renderCollectionBasedVariable(e, t = !1, s = !1) {
98
101
  if (!e)
99
102
  return null;
100
103
  let r = this.loading;
101
104
  return !r && !e.loaded && (e.loadSource().then(() => setTimeout(() => {
102
105
  this._mutationCounter += 1;
103
106
  })).catch(() => {
104
- u("error", this, "Error loading collection"), r = !1;
105
- }), r = !0), s`<calcite-flow-item heading-level=2 .heading=${this._getHeadingForCollection(e)} .description=${this._getDescriptionForCollection(e)} .beforeBack=${this._beforeBack} closable @calciteFlowItemClose=${this._emitClose} .selected=${i}><calcite-action slot=header-actions-end .text=${this.messages.backtotop ?? ""} scale=m .hidden=${t || this._isMode("featureSet")} icon=chevrons-left icon-flip-rtl @click=${this._backToTop}></calcite-action><calcite-input .value=${this._filterValue} icon=magnifying-glass clearable @calciteInputInput=${this._updateFilterValue} class="sticky" scale=m .label=${this.messages.filterthevariablesbyname ?? ""} name=variable-filter></calcite-input>${r ? s`<calcite-loader scale=s type=indeterminate .label=${this.messages.loading ?? ""}></calcite-loader>` : s`<calcite-list .label=${this.messages.profilevariables ?? "Profile variables"}>${this.renderEditorVariables(e)}</calcite-list>`}</calcite-flow-item>`;
107
+ p("error", this, "Error loading collection"), r = !1;
108
+ }), r = !0), i`<calcite-flow-item heading-level=2 .heading=${this._getHeadingForCollection(e, t)} .description=${this._getDescriptionForCollection(e)} .beforeBack=${this._beforeBack} closable @calciteFlowItemClose=${this._emitClose} .selected=${s}><calcite-action slot=header-actions-end .text=${this.messages.backtotop ?? ""} scale=m .hidden=${t || this._isRootPresentation("featureSetRoot")} icon=chevrons-left icon-flip-rtl @click=${this._backToTop}></calcite-action><calcite-input .value=${this._filterValue} icon=magnifying-glass clearable @calciteInputInput=${this._updateFilterValue} class="sticky" scale=m .label=${this.messages.filterthevariablesbyname ?? ""} name=variable-filter></calcite-input>${r ? i`<calcite-loader scale=s type=indeterminate .label=${this.messages.loading ?? ""}></calcite-loader>` : i`<calcite-list .label=${this.messages.profilevariables ?? "Profile variables"}>${this.renderEditorVariables(e)}</calcite-list>`}</calcite-flow-item>`;
106
109
  }
107
110
  renderEditorVariables(e) {
108
- const t = f(this._filterValue), i = e.variables.filter((r) => r.passFilter(t));
109
- return i.length ? i.map((r) => this.renderEditorVariable(r)) : s`<div class="notice-container">${this.messages.noitems}</div>`;
111
+ const t = g(this._filterValue), s = e.variables.filter((r) => r.passFilter(t));
112
+ return s.length ? s.map((r) => this.renderEditorVariable(r)) : i`<div class="notice-container">${this.messages.noitems}</div>`;
110
113
  }
111
114
  renderEditorVariable(e) {
112
115
  switch (e.type) {
113
116
  case "group":
114
- return this._isMode("featureSet") && e.isHeader ? s`<calcite-list-item-group .heading=${e.getLabel()}></calcite-list-item-group>` : this._isMode("featureSet") && e._label?.code === "fields" ? this.renderEditorVariables(e) : s`<calcite-list-item-group .heading=${e.getLabel()}>${this.renderEditorVariables(e)}</calcite-list-item-group>`;
117
+ return this._isRootPresentation("featureSetRoot") && e.isHeader ? i`<calcite-list-item-group .heading=${e.getLabel()}></calcite-list-item-group>` : this._isRootPresentation("featureSetRoot") && e._label?.code === "fields" ? this.renderEditorVariables(e) : i`<calcite-list-item-group .heading=${e.getLabel()}>${this.renderEditorVariables(e)}</calcite-list-item-group>`;
115
118
  default:
116
- return s`<calcite-list-item .label=${e.getLabel()} .description=${e.getDescription()} @calciteListItemSelect=${(t) => this._emitItemSelected(t, e)} @keydown=${(t) => this._emitItemSelected(t, e)}>${e.isCollection ? s`<calcite-action slot=actions-end .text=${this.messages.expand ?? ""} scale=s icon=chevron-right icon-flip-rtl @click=${(t) => this._showCollectionPanel(t, e)} @keydown=${p}></calcite-action>` : null}${e.icon ? s`<calcite-icon .icon=${e.icon} scale=s slot=content-start></calcite-icon>` : null}</calcite-list-item>`;
119
+ return i`<calcite-list-item .label=${e.getLabel()} .description=${e.getDescription()} @calciteListItemSelect=${(t) => this._emitItemSelected(t, e)} @keydown=${(t) => this._emitItemSelected(t, e)}>${e.isCollection ? i`<calcite-action slot=actions-end .text=${this.messages.expand ?? ""} scale=s icon=chevron-right icon-flip-rtl @click=${(t) => this._showCollectionPanel(t, e)} @keydown=${$}></calcite-action>` : null}${e.icon ? i`<calcite-icon .icon=${e.icon} scale=s slot=content-start></calcite-icon>` : null}</calcite-list-item>`;
117
120
  }
118
121
  }
119
122
  render() {
120
- return this.closed ? null : !this.loading && this.variable?.loaded && !this.variable?.variables.length ? s`<calcite-flow><calcite-flow-item heading-level=2 .heading=${this.messages.profilevariables} closable @calciteFlowItemClose=${this._emitClose}><div class="notice-container">${this.messages.noprofilevariablesmessage}</div></calcite-flow-item></calcite-flow>` : s`<calcite-flow ${c(this.flowFocusHandler)}>${this.renderCollectionBasedVariable(this.variable, !0, this._flowItemRenderers.length === 0)}${this._flowItemRenderers.map((e, t, i) => (
123
+ return this.closed ? null : this.loading && !this.variable ? i`<calcite-flow><calcite-flow-item heading-level=2 .heading=${this.heading ?? this.messages.profilevariables} closable @calciteFlowItemClose=${this._emitClose}><calcite-loader scale=s type=indeterminate .label=${this.messages.loading ?? ""}></calcite-loader></calcite-flow-item></calcite-flow>` : !this.loading && (!this.variable || this.variable?.loaded && !this.variable?.variables.length) ? i`<calcite-flow><calcite-flow-item heading-level=2 .heading=${this.heading ?? this.messages.profilevariables} closable @calciteFlowItemClose=${this._emitClose}><div class="notice-container">${this.messages.profileempty}</div></calcite-flow-item></calcite-flow>` : i`<calcite-flow ${d(this.flowFocusHandler)}>${this.renderCollectionBasedVariable(this.variable, !0, this._flowItemRenderers.length === 0)}${this._flowItemRenderers.map((e, t, s) => (
121
124
  // check if the current flow item is the last one, if so, renderer will set selected = true
122
- e(t === i.length - 1)
125
+ e(t === s.length - 1)
123
126
  ))}</calcite-flow>`;
124
127
  }
125
128
  }
126
- o("arcgis-editor-variables", b);
129
+ c("arcgis-editor-variables", C);
127
130
  export {
128
- b as ArcgisEditorVariables
131
+ C as ArcgisEditorVariables
129
132
  };
@@ -22,13 +22,25 @@ export abstract class ArcgisSqlExpressionEditor extends LitElement {
22
22
  * ```
23
23
  */
24
24
  accessor hideSideBar: boolean;
25
+ /**
26
+ * Replace localized message strings with your own strings.
27
+ *
28
+ * **Note**: Individual message keys may change between releases.
29
+ */
30
+ accessor messageOverrides: {
31
+ fields?: string | undefined;
32
+ functions?: string | undefined;
33
+ profileempty?: string | undefined;
34
+ };
25
35
  /** @internal */
26
36
  protected messages: Partial<{
27
37
  fields: string;
28
38
  functions: string;
39
+ profileempty: string;
29
40
  }> & T9nMeta<{
30
41
  fields: string;
31
42
  functions: string;
43
+ profileempty: string;
32
44
  }>;
33
45
  /**
34
46
  * The profile to use for the editor. The profile defines the variables and functions that are available to the editor.
@@ -3,18 +3,18 @@ import { c as n } from "../../chunks/runtime.js";
3
3
  import { css as c, html as t } from "lit";
4
4
  import { LitElement as l, createEvent as o, safeClassMap as r } from "@arcgis/lumina";
5
5
  import { generateGuid as d } from "@arcgis/toolkit/string";
6
- import { a } from "../../chunks/sql-expr-defaults.js";
7
- import { u as h } from "../../chunks/useT9n.js";
8
- import { createRef as p, ref as g } from "lit/directives/ref.js";
6
+ import { a as s } from "../../chunks/sql-expr-defaults.js";
7
+ import { u as p } from "../../chunks/useT9n.js";
8
+ import { createRef as h, ref as g } from "lit/directives/ref.js";
9
9
  import { getSqlExprDiagnosticService as _ } from "../../chunks/sql-expr-mode.js";
10
- import { rethrowError as s } from "@arcgis/toolkit/log";
10
+ import { rethrowError as a } from "@arcgis/toolkit/log";
11
11
  const f = c`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}`;
12
- class u extends l {
12
+ class m extends l {
13
13
  constructor() {
14
- super(...arguments), this._codeEditorElt = p(), this._disposables = [], this.messages = h(), this._modelId = d(), this._preparing = !1, this.sideActionBarExpanded = !1, this.script = "", this.hideSideBar = !1, this.arcgisDiagnosticsChange = o({ bubbles: !1 }), this.arcgisScriptChange = o({ bubbles: !1 });
14
+ super(...arguments), this._codeEditorElt = h(), this._disposables = [], this.messages = p(), this._modelId = d(), this._preparing = !1, this.sideActionBarExpanded = !1, this.script = "", this.hideSideBar = !1, this.arcgisDiagnosticsChange = o({ bubbles: !1 }), this.arcgisScriptChange = o({ bubbles: !1 });
15
15
  }
16
16
  static {
17
- this.properties = { _activeAction: 16, _apiLibrary: 16, _editorProfile: 16, _preparing: 16, sideActionBarExpanded: 16, profile: 0, script: 1, hideSideBar: 5 };
17
+ this.properties = { _activeAction: 16, _apiLibrary: 16, _editorProfile: 16, _preparing: 16, sideActionBarExpanded: 16, profile: 0, script: 1, hideSideBar: 5, messageOverrides: 0 };
18
18
  }
19
19
  static {
20
20
  this.styles = [f];
@@ -23,7 +23,7 @@ class u extends l {
23
23
  await this._codeEditorElt.value?.setFocus();
24
24
  }
25
25
  async load() {
26
- await this._updateEditorProfile().catch(s(this));
26
+ await this._updateEditorProfile().catch(a(this));
27
27
  }
28
28
  willUpdate(i) {
29
29
  (i.has("messages") || i.has("profile")) && this._updateDataModelDeps();
@@ -42,7 +42,7 @@ class u extends l {
42
42
  async _updateEditorProfile() {
43
43
  this._preparing = !0;
44
44
  try {
45
- await a.setProfileForModel(this._modelId, this.profile, { locale: this.messages._t9nLocale }), this._editorProfile = a.getEditorProfileForModel(this._modelId);
45
+ await s.setProfileForModel(this._modelId, this.profile, { locale: this.messages._t9nLocale }), this._editorProfile = s.getEditorProfileForModel(this._modelId);
46
46
  } catch {
47
47
  this._editorProfile = void 0;
48
48
  } finally {
@@ -61,31 +61,31 @@ class u extends l {
61
61
  this._setActiveAction(e.dataset.panelName);
62
62
  }
63
63
  _insertAsSnippet(i) {
64
- this._codeEditorElt.value?.insertSnippet(i.detail).catch(s(this));
64
+ this._codeEditorElt.value?.insertSnippet(i.detail).catch(a(this));
65
65
  }
66
66
  _insertAsText(i) {
67
- this._codeEditorElt.value?.insertText(i.detail.replaceAll('"', "'")).catch(s(this));
67
+ this._codeEditorElt.value?.insertText(i.detail.replaceAll('"', "'")).catch(a(this));
68
68
  }
69
69
  async _updateApiLibrary() {
70
- this._apiLibrary = await a.getApiLibraryForModel(this._modelId);
70
+ this._apiLibrary = await s.getApiLibraryForModel(this._modelId);
71
71
  }
72
72
  _onCodeEditorValueChange(i) {
73
73
  i.stopPropagation(), this.script = i.detail, this.arcgisScriptChange.emit(i.detail);
74
74
  }
75
75
  _getFeatureSetVariable() {
76
76
  let i;
77
- const e = a.getEditorProfileForModel(this._modelId);
78
- return e?.variables?.length && e?.variables?.[0]?.type !== "featureSet" ? s(this)("Encountered unexpected editor profile") : i = e?.variables?.[0], i;
77
+ const e = s.getEditorProfileForModel(this._modelId);
78
+ return e?.variables?.length && e?.variables?.[0]?.type !== "featureSet" ? a(this)("Encountered unexpected editor profile") : i = e?.variables?.[0], i;
79
79
  }
80
80
  _toggleSideActionBarExpanded() {
81
81
  this.sideActionBarExpanded = !this.sideActionBarExpanded;
82
82
  }
83
83
  render() {
84
84
  const i = this._getFeatureSetVariable();
85
- return t`<arcgis-code-editor-shell><arcgis-code-editor slot=editor language=arcgis-sql-expression .modelId=${this._modelId} .value=${this.script ?? ""} @arcgisValueChange=${this._onCodeEditorValueChange} ${g(this._codeEditorElt)}></arcgis-code-editor>${!this.hideSideBar && i && t`<arcgis-editor-variables slot=side-panel .variable=${i} .closed=${this._activeAction !== "fields"} class=${r(this._activeAction === "fields" ? "" : "hidden")} .loading=${this._preparing} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${() => this._setActiveAction(void 0)} data-panel-name=none></arcgis-editor-variables>` || ""}${!this.hideSideBar && t`<arcgis-language-api-panel slot=side-panel class=${r(this._activeAction === "functions" ? "" : "hidden")} .closed=${this._activeAction !== "functions"} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${() => this._setActiveAction(void 0)} .loading=${this._preparing} .apiLibrary=${this._apiLibrary} data-panel-name=none hide-documentation-actions .languageId=${a.languageId}></arcgis-language-api-panel>` || ""}${!this.hideSideBar && t`<calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}>${i && t`<calcite-action id=fields-action .text=${this.messages.fields ?? "Fields"} icon=profile-variables .active=${this._activeAction === "fields"} data-panel-name=fields @click=${this._handleActionClick}></calcite-action>` || ""}${i && !this.sideActionBarExpanded && t`<calcite-tooltip reference-element=fields-action><span>${this.messages.fields ?? "Fields"}</span></calcite-tooltip>` || ""}<calcite-action id=functions-action .text=${this.messages.functions ?? "Functions"} icon=function .active=${this._activeAction === "functions"} data-panel-name=functions @click=${this._handleActionClick}></calcite-action>${!this.sideActionBarExpanded && t`<calcite-tooltip reference-element=functions-action><span>${this.messages.functions ?? "Functions"}</span></calcite-tooltip>` || ""}</calcite-action-bar>` || ""}</arcgis-code-editor-shell>`;
85
+ return t`<arcgis-code-editor-shell><arcgis-code-editor slot=editor language=arcgis-sql-expression .modelId=${this._modelId} .value=${this.script ?? ""} @arcgisValueChange=${this._onCodeEditorValueChange} ${g(this._codeEditorElt)}></arcgis-code-editor>${!this.hideSideBar && i && t`<arcgis-editor-variables slot=side-panel .variable=${i} .closed=${this._activeAction !== "fields"} class=${r(this._activeAction === "fields" ? "" : "hidden")} .loading=${this._preparing} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${() => this._setActiveAction(void 0)} data-panel-name=none .messageOverrides=${{ profileempty: this.messages.profileempty }}></arcgis-editor-variables>` || ""}${!this.hideSideBar && t`<arcgis-language-api-panel slot=side-panel class=${r(this._activeAction === "functions" ? "" : "hidden")} .closed=${this._activeAction !== "functions"} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${() => this._setActiveAction(void 0)} .loading=${this._preparing} .apiLibrary=${this._apiLibrary} data-panel-name=none hide-documentation-actions .languageId=${s.languageId}></arcgis-language-api-panel>` || ""}${!this.hideSideBar && t`<calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}>${i && t`<calcite-action id=fields-action .text=${this.messages.fields ?? "Fields"} icon=profile-variables .active=${this._activeAction === "fields"} data-panel-name=fields @click=${this._handleActionClick}></calcite-action>` || ""}${i && !this.sideActionBarExpanded && t`<calcite-tooltip reference-element=fields-action><span>${this.messages.fields ?? "Fields"}</span></calcite-tooltip>` || ""}<calcite-action id=functions-action .text=${this.messages.functions ?? "Functions"} icon=function .active=${this._activeAction === "functions"} data-panel-name=functions @click=${this._handleActionClick}></calcite-action>${!this.sideActionBarExpanded && t`<calcite-tooltip reference-element=functions-action><span>${this.messages.functions ?? "Functions"}</span></calcite-tooltip>` || ""}</calcite-action-bar>` || ""}</arcgis-code-editor-shell>`;
86
86
  }
87
87
  }
88
- n("arcgis-sql-expression-editor", u);
88
+ n("arcgis-sql-expression-editor", m);
89
89
  export {
90
- u as ArcgisSqlExpressionEditor
90
+ m as ArcgisSqlExpressionEditor
91
91
  };
@@ -0,0 +1,50 @@
1
+ /// <reference path="../../index.d.ts" />
2
+ import type { PublicLitElement as LitElement } from "@arcgis/lumina";
3
+ import type { editor } from "monaco-editor";
4
+ import type { IEditorProfileDefinition, SidePanelName } from "../types.js";
5
+ import type { T9nMeta } from "@arcgis/lumina/controllers";
6
+
7
+ /**
8
+ * The ArcGIS SQL Layer Editor is a code editor for writing and editing sql query layer scripts
9
+ * If the user provides a profile with a variable of type `dataCatalogDatastore`. The editor will
10
+ * configure monaco language support for the dialect specified in the data catalog datastore.
11
+ * Otherwise it will default to postgres.
12
+ *
13
+ * @internal
14
+ */
15
+ export abstract class ArcgisSqlLayerEditor extends LitElement {
16
+ /** @default false */
17
+ accessor hideSideBar: boolean;
18
+ /**
19
+ * Replace localized message strings with your own strings.
20
+ *
21
+ * **Note**: Individual message keys may change between releases.
22
+ */
23
+ accessor messageOverrides: {
24
+ loading?: string | undefined;
25
+ profileempty?: string | undefined;
26
+ tables?: string | undefined;
27
+ };
28
+ /** @internal */
29
+ protected messages: Partial<{
30
+ loading: string;
31
+ profileempty: string;
32
+ tables: string;
33
+ }> & T9nMeta<{
34
+ loading: string;
35
+ profileempty: string;
36
+ tables: string;
37
+ }>;
38
+ /** @default "none" */
39
+ accessor openedSidePanel: SidePanelName;
40
+ accessor profile: IEditorProfileDefinition | undefined;
41
+ /** @default "" */
42
+ accessor script: string;
43
+ setFocus(): Promise<void>;
44
+ readonly arcgisDiagnosticsChange: import("@arcgis/lumina").TargetedEvent<this, editor.IMarkerData[]>;
45
+ readonly arcgisScriptChange: import("@arcgis/lumina").TargetedEvent<this, string>;
46
+ readonly "@eventTypes": {
47
+ arcgisDiagnosticsChange: ArcgisSqlLayerEditor["arcgisDiagnosticsChange"]["detail"];
48
+ arcgisScriptChange: ArcgisSqlLayerEditor["arcgisScriptChange"]["detail"];
49
+ };
50
+ }
@@ -0,0 +1,92 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import { c as r } from "../../chunks/runtime.js";
3
+ import { css as l, html as a } from "lit";
4
+ import { LitElement as d, createEvent as s, safeClassMap as n } from "@arcgis/lumina";
5
+ import { generateGuid as c } from "@arcgis/toolkit/string";
6
+ import { u as h } from "../../chunks/useT9n.js";
7
+ import { createRef as p, ref as g } from "lit/directives/ref.js";
8
+ import { k as m } from "../../chunks/utils.js";
9
+ import "@arcgis/arcade-languageservice";
10
+ import "@arcgis/core/portal/PortalItem.js";
11
+ import "@arcgis/core/WebMap.js";
12
+ import "@arcgis/core/WebScene.js";
13
+ import "@arcgis/core/layers/FeatureLayer.js";
14
+ import "@arcgis/core/applications/Components/arcadeEditorUtils.js";
15
+ import "@arcgis/toolkit/predicate";
16
+ import "vscode-languageserver-types";
17
+ import { rethrowError as t } from "@arcgis/toolkit/log";
18
+ import "@arcgis/core/core/Error.js";
19
+ import { d as o } from "../../chunks/language-defaults-base.js";
20
+ import "@arcgis/core/portal/Portal.js";
21
+ import { g as _, a as f, b as u, c as b } from "../../chunks/sql-layer-defaults.js";
22
+ import { getSqlLayerDiagnosticService as v } from "../../chunks/sql-layer-mode.js";
23
+ const S = l`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}`;
24
+ class E extends d {
25
+ constructor() {
26
+ super(...arguments), this._codeEditorElt = p(), this._disposables = [], this._modelId = c(), this.messages = h(), this._preparing = !1, this._resolvedLanguage = o, this.sideActionBarExpanded = !1, this.script = "", this.hideSideBar = !1, this.openedSidePanel = "none", this.arcgisDiagnosticsChange = s({ bubbles: !1 }), this.arcgisScriptChange = s({ bubbles: !1 });
27
+ }
28
+ static {
29
+ this.properties = { _editorProfile: 16, _preparing: 16, _resolvedLanguage: 16, sideActionBarExpanded: 16, profile: 0, script: 1, hideSideBar: 5, messageOverrides: 0, openedSidePanel: 3 };
30
+ }
31
+ static {
32
+ this.styles = [S];
33
+ }
34
+ async setFocus() {
35
+ await this._codeEditorElt.value?.setFocus();
36
+ }
37
+ async load() {
38
+ await this._updateDataModelDeps().catch(t(this));
39
+ }
40
+ willUpdate(e) {
41
+ e.has("profile") && this._updateDataModelDeps().catch(t(this));
42
+ }
43
+ async loaded() {
44
+ const e = v();
45
+ this._disposables.push(e.onDiagnosticsChange((i) => {
46
+ i.uri.toString() === this._modelId && !this._preparing && this.arcgisDiagnosticsChange.emit(i.diagnostics);
47
+ }));
48
+ }
49
+ disconnectedCallback() {
50
+ for (super.disconnectedCallback(); this._disposables.length; )
51
+ this._disposables.pop()?.dispose();
52
+ _().forEach((e) => e.disposeForModel(this._modelId));
53
+ }
54
+ async _updateDataModelDeps() {
55
+ this._preparing = !0;
56
+ try {
57
+ const e = await f(this.profile);
58
+ e !== this._resolvedLanguage && (u(this._resolvedLanguage)?.disposeForModel(this._modelId), this._resolvedLanguage = e);
59
+ const i = b(this._resolvedLanguage);
60
+ await i.setProfileForModel(this._modelId, this.profile, { locale: this.messages._t9nLocale }), this._editorProfile = i.getEditorProfileForModel(this._modelId);
61
+ } catch {
62
+ this._editorProfile = void 0, this._resolvedLanguage = o;
63
+ } finally {
64
+ this._preparing = !1;
65
+ }
66
+ }
67
+ _toggleSideActionBarExpanded() {
68
+ this.sideActionBarExpanded = !this.sideActionBarExpanded;
69
+ }
70
+ _toggleSidePanel(e) {
71
+ this.openedSidePanel = this.openedSidePanel === e ? "none" : e, this.openedSidePanel === "none" && this._codeEditorElt.value?.setFocus().catch(t(this));
72
+ }
73
+ _onCodeEditorValueChange(e) {
74
+ e.stopPropagation(), this.script = e.detail, this.arcgisScriptChange.emit(e.detail);
75
+ }
76
+ _insertAsText(e) {
77
+ this._codeEditorElt.value?.insertText(e.detail).catch(t(this));
78
+ }
79
+ _getTablesVariable() {
80
+ return this._editorProfile?.variables.find(m);
81
+ }
82
+ render() {
83
+ const e = this._getTablesVariable();
84
+ return a`<arcgis-code-editor-shell><arcgis-code-editor slot=editor .language=${this._resolvedLanguage} .modelId=${this._modelId} .value=${this.script ?? ""} @arcgisValueChange=${this._onCodeEditorValueChange} ${g(this._codeEditorElt)}></arcgis-code-editor>${!this.hideSideBar && a`<arcgis-editor-variables slot=side-panel .variable=${e} .heading=${this.messages.tables ?? "Tables"} .messageOverrides=${{ profileempty: this.messages.profileempty }} .closed=${this.openedSidePanel !== "variables"} class=${n(this.openedSidePanel === "variables" ? "" : "hidden")} .loading=${this._preparing} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${() => {
85
+ this.openedSidePanel = "none";
86
+ }} data-panel-name=none></arcgis-editor-variables><calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action id=tables-action .text=${this.messages.tables ?? "Tables"} icon=table .active=${this.openedSidePanel === "variables"} data-panel-name=variables @click=${() => this._toggleSidePanel("variables")}></calcite-action>${!this.sideActionBarExpanded && a`<calcite-tooltip reference-element=tables-action><span>${this.messages.tables ?? "Tables"}</span></calcite-tooltip>` || ""}</calcite-action-bar>` || ""}</arcgis-code-editor-shell>`;
87
+ }
88
+ }
89
+ r("arcgis-sql-layer-editor", E);
90
+ export {
91
+ E as ArcgisSqlLayerEditor
92
+ };
@@ -0,0 +1 @@
1
+ export * from "./customElement.js";
@@ -0,0 +1,7 @@
1
+ import "../arcgis-code-editor-shell/index.js";
2
+ import "../arcgis-code-editor/index.js";
3
+ import "../arcgis-editor-variables/index.js";
4
+ import "@esri/calcite-components/components/calcite-action-bar";
5
+ import "@esri/calcite-components/components/calcite-action";
6
+ import "@esri/calcite-components/components/calcite-tooltip";
7
+ export * from "./customElement.js";
@@ -9,6 +9,7 @@ import type SpatialReference from "@arcgis/core/geometry/SpatialReference.js";
9
9
  import type { Diagnostic as ArcadeLanguageServiceDiagnostic } from "@arcgis/arcade-languageservice";
10
10
  import type { ApiItem, BundleType, ProfileId } from "@arcgis/languages-api-utils";
11
11
  import type { ProfileVariableInstances, ArcadeServices } from "@arcgis/core/arcade.js";
12
+ import type { DataCatalogDatastoreInfo } from "../utils/data-catalog-datastore.js";
12
13
 
13
14
  export type Diagnostic = ArcadeLanguageServiceDiagnostic;
14
15
 
@@ -54,9 +55,9 @@ export type ProfileVariableValueType = "boolean" | "date" | "dateOnly" | "geomet
54
55
  /**
55
56
  * The supported profile variable types.
56
57
  *
57
- * @internalremarks TODO: hopefully align with \@arcgis/core's Variable type in the future
58
+ * @internalremarks TODO: hopefully align with \@arcgis/core's Arcade variable type in the future
58
59
  */
59
- export type IProfileVariable = IProfileArray | IProfileDictionary | IProfileFeature | IProfileFeatureSet | IProfileFeatureSetCollection | IProfilePixel | IProfileValue | IProfileVoxel;
60
+ export type IProfileVariable = IProfileArray | IProfileDataCatalogDatastore | IProfileDictionary | IProfileFeature | IProfileFeatureSet | IProfileFeatureSetCollection | IProfilePixel | IProfileValue | IProfileVoxel;
60
61
 
61
62
  /** Properties common to all profile variables. */
62
63
  export interface IProfileVariableBase {
@@ -134,6 +135,82 @@ export interface IProfilePixel extends IProfileVariableBase {
134
135
 
135
136
  export type IFeatureLikeProfile = IProfileFeature | IProfilePixel | IProfileVoxel;
136
137
 
138
+ /** Data catalog datastore profile variable declaration. */
139
+ export interface IProfileDataCatalogDatastore extends IProfileVariableBase {
140
+ readonly type: "dataCatalogDatastore";
141
+ /** Describes how the editor will find the definition for the data catalog datastore. */
142
+ definition?: DataCatalogDatastoreSource;
143
+ }
144
+
145
+ export type DataCatalogDatabasePlatform = DataCatalogDatastoreInfo["databasePlatform"];
146
+
147
+ export interface IDataCatalogDatastoreInfoLike {
148
+ /** The unique data catalog datastore id. */
149
+ datastoreId: string;
150
+ /** The datastore name. */
151
+ name: string;
152
+ /** The datastore type. */
153
+ type: string;
154
+ /** The database platform identifier. */
155
+ databasePlatform: DataCatalogDatabasePlatform;
156
+ }
157
+
158
+ export interface IDataCatalogDatasetInfoLike {
159
+ /** The dataset name. */
160
+ name: string;
161
+ /** The dataset type. */
162
+ type: string;
163
+ }
164
+
165
+ export interface IDataCatalogFieldInfoLike {
166
+ /** The field name. */
167
+ name: string;
168
+ /** The normalized field type used by the editor. */
169
+ type: FeatureLayer["fields"][number]["type"];
170
+ /** The raw field type returned by the service. */
171
+ serverType: string;
172
+ /** Indicates whether the field allows null values. */
173
+ nullable: boolean;
174
+ }
175
+
176
+ export interface IDataCatalogTableDescriptionLike {
177
+ /** The fields available in the table. */
178
+ fields: IDataCatalogFieldInfoLike[];
179
+ }
180
+
181
+ /**
182
+ * Data catalog datastore instance shape accepted by the editor.
183
+ *
184
+ * Consumers can supply either a serialized datastore definition or a live datastore-like
185
+ * object exposing the methods needed to fetch datastore metadata, datasets, and table descriptions.
186
+ */
187
+ export interface IDataCatalogDatastoreInstance {
188
+ /** The unique data catalog datastore id. */
189
+ itemId?: string;
190
+ /** The url for the data catalog service on the portal. */
191
+ serviceUrl?: string;
192
+ /** The portal hosting the data catalog service. */
193
+ portal?: { url: string; };
194
+ /** Fetches datastore metadata. */
195
+ fetchInfo: () => Promise<IDataCatalogDatastoreInfoLike>;
196
+ /** Fetches datasets exposed by the datastore. */
197
+ fetchDatasets: () => Promise<IDataCatalogDatasetInfoLike[]>;
198
+ /** Fetches a table description for the provided dataset name. */
199
+ fetchTableDescription: (tableName: string) => Promise<IDataCatalogTableDescriptionLike>;
200
+ }
201
+
202
+ export type DataCatalogDatastoreSource = IDataCatalogDatastoreDefinition | IDataCatalogDatastoreInstance;
203
+
204
+ /** Data catalog datastore definition. */
205
+ export interface IDataCatalogDatastoreDefinition {
206
+ /** The unique data catalog datastore id. */
207
+ id: string;
208
+ /** The url for the data catalog service on the portal */
209
+ serviceUrl: string;
210
+ /** The portal url. This is required for accessing the data catalog service */
211
+ portal: { url: string; };
212
+ }
213
+
137
214
  /** Describes a portal item. */
138
215
  export interface IPortalItemProperties {
139
216
  /** The unique portal item id. */