@arcgis/coding-components 4.29.0-beta.46 → 4.29.0-beta.48
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/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
- package/dist/arcgis-coding-components/index.esm.js +1 -1
- package/dist/arcgis-coding-components/{p-e475e6cd.js → p-0823fa31.js} +1 -1
- package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
- package/dist/arcgis-coding-components/{p-e6ede32d.js → p-2e99b56e.js} +1 -1
- package/dist/arcgis-coding-components/{p-9eabda86.js → p-30618728.js} +1 -1
- package/dist/arcgis-coding-components/{p-9e242e76.js → p-3dd452e0.js} +1 -1
- package/dist/arcgis-coding-components/{p-ccdf0ac1.entry.js → p-8f729db2.entry.js} +1 -1
- package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-a8d30530.js} +1 -1
- package/dist/arcgis-coding-components/{p-c084ada8.js → p-ae129dfa.js} +1 -1
- package/dist/arcgis-coding-components/{p-71faf9a4.js → p-af7d25aa.js} +1 -1
- package/dist/arcgis-coding-components/{p-10a322ec.js → p-b5479fc4.js} +8 -8
- package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d78367ff.js} +1 -1
- package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-6fa4acb9.js} +1305 -1305
- package/dist/cjs/arcade-mode-15687545.js +598 -0
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1408 -1408
- package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
- package/dist/cjs/{cssMode-e63287bb.js → cssMode-644e4ecf.js} +2 -2
- package/dist/cjs/{html-c0d4db3b.js → html-567706f3.js} +2 -2
- package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-14c95ab8.js} +2 -2
- package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{javascript-a419d064.js → javascript-69c3523c.js} +3 -3
- package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-da8803e7.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{tsMode-37d1b053.js → tsMode-eddf280e.js} +2 -2
- package/dist/cjs/{typescript-53f9f36a.js → typescript-114292ed.js} +2 -2
- package/dist/components/arcade-api.js +160 -160
- package/dist/components/arcade-contribution.js +60 -60
- package/dist/components/arcade-defaults.js +1239 -1239
- package/dist/components/arcade-mode.js +513 -513
- package/dist/components/arcade-results.js +430 -430
- package/dist/components/arcade-suggestions.js +132 -132
- package/dist/components/arcade-variables.js +155 -155
- package/dist/components/arcgis-arcade-api.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.js +390 -390
- package/dist/components/arcgis-arcade-results.d.ts +2 -2
- package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
- package/dist/components/arcgis-arcade-variables.d.ts +2 -2
- package/dist/components/arcgis-code-editor.d.ts +2 -2
- package/dist/components/code-editor.js +251 -251
- package/dist/components/fields.js +69 -69
- package/dist/components/functional-components.js +1 -1
- package/dist/components/markdown.js +28 -28
- package/dist/components/utilities.js +20 -20
- package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-3a952c7e.js} +1305 -1305
- package/dist/esm/arcade-mode-619b0989.js +594 -0
- package/dist/esm/arcgis-arcade-api_6.entry.js +1408 -1408
- package/dist/esm/arcgis-coding-components.js +3 -3
- package/dist/esm/{cssMode-b1771f92.js → cssMode-4100a9c5.js} +2 -2
- package/dist/esm/{html-af635d52.js → html-fbb4fdec.js} +2 -2
- package/dist/esm/{htmlMode-3021c301.js → htmlMode-a896869e.js} +2 -2
- package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
- package/dist/esm/index.js +2 -2
- package/dist/esm/{javascript-70589186.js → javascript-a0bd70ad.js} +3 -3
- package/dist/esm/{jsonMode-cb509b79.js → jsonMode-76fe6af1.js} +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{tsMode-ed90c9aa.js → tsMode-277700f6.js} +2 -2
- package/dist/esm/{typescript-db8a0b18.js → typescript-c9f880aa.js} +2 -2
- package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
- package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
- package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
- package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
- package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
- package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
- package/dist/types/components/code-editor/code-editor.d.ts +73 -73
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/types/utils/arcade-executor.d.ts +79 -79
- package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
- package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
- package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
- package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
- package/dist/types/utils/editor-suggestions.d.ts +24 -24
- package/dist/types/utils/functional-components.d.ts +1 -1
- package/dist/types/utils/markdown.d.ts +1 -1
- package/dist/types/utils/profile/editor-profile.d.ts +185 -185
- package/dist/types/utils/profile/types.d.ts +101 -101
- package/dist/types/utils/utilities.d.ts +1 -1
- package/package.json +7 -7
- package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
- package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
- package/dist/esm/arcade-mode-70e22d22.js +0 -594
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getAssetPath } from './index-
|
|
1
|
+
import { g as getAssetPath } from './index-022fb97b.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns the last element of an array.
|
|
@@ -118028,7 +118028,7 @@ registerLanguage({
|
|
|
118028
118028
|
mimetypes: ["text/html", "text/x-jshtm", "text/template", "text/ng-template"],
|
|
118029
118029
|
loader: () => {
|
|
118030
118030
|
{
|
|
118031
|
-
return import('./html-
|
|
118031
|
+
return import('./html-fbb4fdec.js');
|
|
118032
118032
|
}
|
|
118033
118033
|
}
|
|
118034
118034
|
});
|
|
@@ -118048,7 +118048,7 @@ registerLanguage({
|
|
|
118048
118048
|
mimetypes: ["text/javascript"],
|
|
118049
118049
|
loader: () => {
|
|
118050
118050
|
{
|
|
118051
|
-
return import('./javascript-
|
|
118051
|
+
return import('./javascript-a0bd70ad.js');
|
|
118052
118052
|
}
|
|
118053
118053
|
}
|
|
118054
118054
|
});
|
|
@@ -118066,7 +118066,7 @@ registerLanguage({
|
|
|
118066
118066
|
mimetypes: ["text/typescript"],
|
|
118067
118067
|
loader: () => {
|
|
118068
118068
|
{
|
|
118069
|
-
return import('./typescript-
|
|
118069
|
+
return import('./typescript-c9f880aa.js');
|
|
118070
118070
|
}
|
|
118071
118071
|
}
|
|
118072
118072
|
});
|
|
@@ -118187,7 +118187,7 @@ var lessDefaults = new LanguageServiceDefaultsImpl$3("less", optionsDefault$1, m
|
|
|
118187
118187
|
monaco_editor_core_exports$3.languages.css = { cssDefaults, lessDefaults, scssDefaults };
|
|
118188
118188
|
function getMode$3() {
|
|
118189
118189
|
{
|
|
118190
|
-
return import('./cssMode-
|
|
118190
|
+
return import('./cssMode-4100a9c5.js');
|
|
118191
118191
|
}
|
|
118192
118192
|
}
|
|
118193
118193
|
monaco_editor_core_exports$3.languages.onLanguage("less", () => {
|
|
@@ -118312,7 +118312,7 @@ monaco_editor_core_exports$2.languages.html = {
|
|
|
118312
118312
|
};
|
|
118313
118313
|
function getMode$2() {
|
|
118314
118314
|
{
|
|
118315
|
-
return import('./htmlMode-
|
|
118315
|
+
return import('./htmlMode-a896869e.js');
|
|
118316
118316
|
}
|
|
118317
118317
|
}
|
|
118318
118318
|
function registerHTMLLanguageService(languageId, options = optionsDefault, modeConfiguration = getConfigurationDefault(languageId)) {
|
|
@@ -118414,7 +118414,7 @@ var jsonDefaults = new LanguageServiceDefaultsImpl$1("json", diagnosticDefault,
|
|
|
118414
118414
|
monaco_editor_core_exports$1.languages.json = { jsonDefaults };
|
|
118415
118415
|
function getMode$1() {
|
|
118416
118416
|
{
|
|
118417
|
-
return import('./jsonMode-
|
|
118417
|
+
return import('./jsonMode-76fe6af1.js');
|
|
118418
118418
|
}
|
|
118419
118419
|
}
|
|
118420
118420
|
monaco_editor_core_exports$1.languages.register({
|
|
@@ -118683,7 +118683,7 @@ monaco_editor_core_exports.languages.typescript = {
|
|
|
118683
118683
|
};
|
|
118684
118684
|
function getMode() {
|
|
118685
118685
|
{
|
|
118686
|
-
return import('./tsMode-
|
|
118686
|
+
return import('./tsMode-277700f6.js');
|
|
118687
118687
|
}
|
|
118688
118688
|
}
|
|
118689
118689
|
monaco_editor_core_exports.languages.onLanguage("typescript", () => {
|
|
@@ -167228,63 +167228,63 @@ async function importRequest() {
|
|
|
167228
167228
|
}
|
|
167229
167229
|
|
|
167230
167230
|
async function newPortalItem(definition) {
|
|
167231
|
-
|
|
167232
|
-
|
|
167231
|
+
const PortalItem = await importPortalPortalItem();
|
|
167232
|
+
return new PortalItem(definition);
|
|
167233
167233
|
}
|
|
167234
167234
|
async function newFeatureLayer(definition) {
|
|
167235
|
-
|
|
167236
|
-
|
|
167237
|
-
|
|
167235
|
+
const FeatureLayer = await importLayersFeatureLayer();
|
|
167236
|
+
// Fix title for the layer. Instead of defaulting to the map viewer style.
|
|
167237
|
+
return new FeatureLayer({ ...definition, sublayerTitleMode: "service-name" });
|
|
167238
167238
|
}
|
|
167239
167239
|
async function newWebMap(definition) {
|
|
167240
|
-
|
|
167241
|
-
|
|
167240
|
+
const WebMap = await importWebMap();
|
|
167241
|
+
return new WebMap(definition);
|
|
167242
167242
|
}
|
|
167243
167243
|
function isSupportedLayerInstance(item) {
|
|
167244
|
-
|
|
167245
|
-
|
|
167246
|
-
|
|
167247
|
-
|
|
167244
|
+
return (!!item &&
|
|
167245
|
+
typeof item === "object" &&
|
|
167246
|
+
typeof item.declaredClass === "string" &&
|
|
167247
|
+
item.declaredClass.startsWith("esri.layers."));
|
|
167248
167248
|
}
|
|
167249
167249
|
function isFeatureSetInstance(item) {
|
|
167250
|
-
|
|
167251
|
-
|
|
167252
|
-
|
|
167253
|
-
|
|
167250
|
+
return (!!item &&
|
|
167251
|
+
typeof item === "object" &&
|
|
167252
|
+
typeof item.declaredClass === "string" &&
|
|
167253
|
+
item.declaredClass === "esri.rest.support.FeatureSet");
|
|
167254
167254
|
}
|
|
167255
167255
|
function isFeatureLayerInstance(item) {
|
|
167256
|
-
|
|
167257
|
-
|
|
167258
|
-
|
|
167259
|
-
|
|
167256
|
+
return (!!item &&
|
|
167257
|
+
typeof item === "object" &&
|
|
167258
|
+
typeof item.declaredClass === "string" &&
|
|
167259
|
+
item.declaredClass === "esri.layers.FeatureLayer");
|
|
167260
167260
|
}
|
|
167261
167261
|
function isGroupLayerInstance(item) {
|
|
167262
|
-
|
|
167263
|
-
|
|
167264
|
-
|
|
167265
|
-
|
|
167262
|
+
return (!!item &&
|
|
167263
|
+
typeof item === "object" &&
|
|
167264
|
+
typeof item.declaredClass === "string" &&
|
|
167265
|
+
item.declaredClass === "esri.layers.GroupLayer");
|
|
167266
167266
|
}
|
|
167267
167267
|
function isWebMapInstance(item) {
|
|
167268
|
-
|
|
167268
|
+
return (!!item && typeof item === "object" && typeof item.declaredClass === "string" && item.declaredClass === "esri.WebMap");
|
|
167269
167269
|
}
|
|
167270
167270
|
function isPortalItemDefinition(item) {
|
|
167271
|
-
|
|
167271
|
+
return !!item && typeof item === "object" && item.portalItem != null;
|
|
167272
167272
|
}
|
|
167273
167273
|
function isFeatureLayerItemDefinition(item) {
|
|
167274
|
-
|
|
167274
|
+
return !!item && typeof item === "object" && item.portalItem != null;
|
|
167275
167275
|
}
|
|
167276
167276
|
function isFieldsDefinition(item) {
|
|
167277
|
-
|
|
167277
|
+
return !!item && typeof item === "object" && Array.isArray(item.fields) && !("declaredClass" in item);
|
|
167278
167278
|
}
|
|
167279
167279
|
function isUrlDefinition(item) {
|
|
167280
|
-
|
|
167280
|
+
return !!item && typeof item === "object" && typeof item.url === "string" && !("declaredClass" in item);
|
|
167281
167281
|
}
|
|
167282
167282
|
function isPredefinedProfile(item) {
|
|
167283
|
-
|
|
167284
|
-
|
|
167285
|
-
|
|
167286
|
-
|
|
167287
|
-
|
|
167283
|
+
return (!!item &&
|
|
167284
|
+
typeof item === "object" &&
|
|
167285
|
+
typeof item.id === "string" &&
|
|
167286
|
+
typeof item.definitions === "object" &&
|
|
167287
|
+
!Array.isArray(item.definitions));
|
|
167288
167288
|
}
|
|
167289
167289
|
|
|
167290
167290
|
var p=class{constructor(){this.resolve=()=>{},this.reject=()=>{},this.promise=new Promise((t,n)=>{this.resolve=t,this.reject=n;});}};function S(e,t){let n=e;for(;n;){if(n===t)return !0;if(!n.parentNode)return !1;n.parentNode instanceof ShadowRoot?n=n.parentNode.host:n=n.parentNode;}return !1}function T(e,t,n=()=>{}){if(!t||t.length<=0)return;let r=new MutationObserver(o=>{for(let i of o)S(e,i.target)&&n();});return r.observe(document.documentElement,{attributes:!0,attributeFilter:t,subtree:!0}),r}function E(e,t){let n=e;for(;n;){let r=n.closest(t);if(r)return r;let o=n.getRootNode();if(o===document)return null;n=o.host;}return null}function P(e){let t=E(e,":is(.calcite-mode-light, .calcite-mode-dark)");return t&&t.classList.contains("calcite-mode-dark")?"dark":"light"}function f(e,t,n){return E(e,`[${t}]`)?.getAttribute(t)??n}function M(e){return e.nodeType===Node.ELEMENT_NODE}function c(e,t=""){if(!M(e))return !1;if(e.matches(t))return setTimeout(()=>e?.setFocus(),0),!0;for(let r=0;r<e.children.length;r++)if(c(e.children[r],t))return !0;let n=e.shadowRoot;if(n){for(let r=0;r<n.children.length;r++)if(c(n.children[r],t))return !0}return !1}function O(e,t){if(!e||!e.shadowRoot)return;if(e.hasAttribute("hydrated")||e.hasAttribute("calcite-hydrated")){c(e,t);return}let n=new MutationObserver(()=>{n.disconnect(),c(e,t);});n.observe(e,{attributes:!0,attributeFilter:["hydrated","calcite-hydrated"]});}function d(e){let t="";for(let n=0;n<e;n++)t+=((1+Math.random())*65536|0).toString(16).substring(1);return t}function j(){return [d(2),d(1),d(1),d(1),d(3)].join("-")}var x=new Set(["ar","bg","bs","ca","cs","da","de","el","en","es","et","fi","fr","he","hr","hu","id","it","ja","ko","lt","lv","nl","nb","pl","pt-BR","pt-PT","ro","ru","sk","sl","sr","sv","th","tr","uk","vi","zh-CN","zh-HK","zh-TW"]),a=new Map;async function N(e,t,n=""){let r=`${t}/${n}${e}.json`;if(a.has(r))return a.get(r);try{let o=await fetch(r);if(o.ok){let s=await o.json();return a.set(r,s),s}if(e==="en"){a.set(r,void 0);return}let i=await N("en",t,n);return a.set(r,i),i}catch{a.set(r,void 0);return}}function R(e){let t=f(e,"lang",navigator?.language||"en");if(x.has(t))return {lang:t,t9nLocale:t};let n=t.slice(0,2);return {lang:t,t9nLocale:x.has(n)?n:"en"}}var m=new WeakMap,h=new WeakMap,_=new WeakMap;async function F(e,t,n){h.set(e,t),m.set(e,T(e._hostElement,["lang"],()=>{b(e,n);})),await b(e,n);}function U(e){m.get(e)?.disconnect(),m.delete(e),h.delete(e);}async function b(e,t){let{lang:n,t9nLocale:r}=R(e._hostElement);if(n===e._lang&&r===e._t9nLocale||(n!==e._lang&&(e._lang=n),r===e._t9nLocale))return;let o=_.get(e);if(!o){let i=h.get(e)??"",s=e._hostElement.tagName.toLowerCase().replace("arcgis-",""),u=`${i}/${s}/t9n`,l=`${s}.t9n.`;o=await N(r,u,l);}e._t9nLocale=r,e._t9nStrings=o,await t?.call(e);}var v='"',w="'";function L(e,t){return new Array(t+1).join(e)}function z(e){let t=v,n=w;e.indexOf(t)>=0&&e.indexOf(n)<0&&(n=v,t=w);let o=new RegExp("(^|[^\\\\])((?:\\\\{2})*)((?:\\\\"+n+")+)","g");e=e.replace(o,(s,u,l,g)=>u+l+L(n,g.length/2));let i=new RegExp("(^|[^\\\\])((?:\\\\{2})*)("+t+"+)","g");return e=e.replace(i,(s,u,l,g)=>u+l+L("\\"+t,g.length)),t+e+t}function B(e){let t=e?e.replaceAll(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"):"^.*$";return new RegExp(t,"i")}function H(e,t={}){return (e??"").replace(/\{(.*?)\}/g,(n,r)=>t[r]??n)}function q(e){return "\u200E"+(e??"")+"\u200E"}function D(e){return e!==null}function G(e){return e!==void 0}function V(e,t,n=!1){if(!e||!t)return !1;let r=new URL(e),o=new URL(t);return !n&&r.protocol!==o.protocol||r.host==null||o.host==null?!1:r.host.toLowerCase()===o.host.toLowerCase()&&r.port===o.port}function X(e){try{return new URL(e),!0}catch{return !1}}
|
|
@@ -167293,32 +167293,32 @@ var p=class{constructor(){this.resolve=()=>{},this.reject=()=>{},this.promise=ne
|
|
|
167293
167293
|
* Filters a collection of items by the given keys and filter word.
|
|
167294
167294
|
*/
|
|
167295
167295
|
function filterCollection(collection, keys, filterWord, beforeFilteringFn) {
|
|
167296
|
-
|
|
167297
|
-
|
|
167298
|
-
}
|
|
167299
|
-
const _keys = !Array.isArray(keys) ? [keys] : keys;
|
|
167300
|
-
if (!_keys.length) {
|
|
167301
|
-
return [];
|
|
167302
|
-
}
|
|
167303
|
-
const filterExpression = B(filterWord);
|
|
167304
|
-
return collection.filter((item) => {
|
|
167305
|
-
if (beforeFilteringFn) {
|
|
167306
|
-
const res = beforeFilteringFn(item);
|
|
167307
|
-
if (res !== null || res !== undefined) {
|
|
167308
|
-
return res;
|
|
167309
|
-
}
|
|
167296
|
+
if (!keys) {
|
|
167297
|
+
return [];
|
|
167310
167298
|
}
|
|
167311
|
-
|
|
167312
|
-
|
|
167299
|
+
const _keys = !Array.isArray(keys) ? [keys] : keys;
|
|
167300
|
+
if (!_keys.length) {
|
|
167301
|
+
return [];
|
|
167302
|
+
}
|
|
167303
|
+
const filterExpression = B(filterWord);
|
|
167304
|
+
return collection.filter((item) => {
|
|
167305
|
+
if (beforeFilteringFn) {
|
|
167306
|
+
const res = beforeFilteringFn(item);
|
|
167307
|
+
if (res !== null || res !== undefined) {
|
|
167308
|
+
return res;
|
|
167309
|
+
}
|
|
167310
|
+
}
|
|
167311
|
+
return _keys.some((key) => filterExpression.test(`${item[key] ?? ""}`));
|
|
167312
|
+
});
|
|
167313
167313
|
}
|
|
167314
167314
|
/**
|
|
167315
167315
|
* Returns the url to the portal item.
|
|
167316
167316
|
*/
|
|
167317
167317
|
function portalItemPageUrl(portalItem) {
|
|
167318
|
-
|
|
167319
|
-
|
|
167320
|
-
|
|
167321
|
-
|
|
167318
|
+
if (!portalItem) {
|
|
167319
|
+
return "";
|
|
167320
|
+
}
|
|
167321
|
+
return `${portalItem.portal.url}/home/item.html?id=${portalItem.id}`;
|
|
167322
167322
|
}
|
|
167323
167323
|
//#endregion
|
|
167324
167324
|
|
|
@@ -167326,417 +167326,417 @@ function portalItemPageUrl(portalItem) {
|
|
|
167326
167326
|
* Returns an icon name for the field type
|
|
167327
167327
|
*/
|
|
167328
167328
|
function fieldTypeToIconName(field) {
|
|
167329
|
-
|
|
167330
|
-
|
|
167331
|
-
|
|
167332
|
-
|
|
167333
|
-
|
|
167334
|
-
|
|
167335
|
-
|
|
167336
|
-
|
|
167337
|
-
|
|
167338
|
-
|
|
167339
|
-
|
|
167340
|
-
|
|
167341
|
-
|
|
167342
|
-
|
|
167343
|
-
|
|
167344
|
-
|
|
167345
|
-
|
|
167346
|
-
|
|
167347
|
-
|
|
167348
|
-
|
|
167349
|
-
|
|
167350
|
-
|
|
167351
|
-
|
|
167352
|
-
|
|
167353
|
-
|
|
167354
|
-
|
|
167329
|
+
switch (field?.type) {
|
|
167330
|
+
case "oid":
|
|
167331
|
+
return "key";
|
|
167332
|
+
case "small-integer":
|
|
167333
|
+
case "big-integer":
|
|
167334
|
+
case "integer":
|
|
167335
|
+
case "single":
|
|
167336
|
+
case "double":
|
|
167337
|
+
case "long":
|
|
167338
|
+
return "number";
|
|
167339
|
+
case "global-id":
|
|
167340
|
+
case "guid":
|
|
167341
|
+
return "key";
|
|
167342
|
+
case "string":
|
|
167343
|
+
return "string";
|
|
167344
|
+
case "date":
|
|
167345
|
+
return "date-time";
|
|
167346
|
+
case "date-only":
|
|
167347
|
+
return "calendar";
|
|
167348
|
+
case "time-only":
|
|
167349
|
+
return "clock";
|
|
167350
|
+
case "timestamp-offset":
|
|
167351
|
+
return "time-zone";
|
|
167352
|
+
default:
|
|
167353
|
+
return "cube";
|
|
167354
|
+
}
|
|
167355
167355
|
}
|
|
167356
167356
|
/**
|
|
167357
167357
|
* Returns the Arcade type for the given field.
|
|
167358
167358
|
*/
|
|
167359
167359
|
function fieldTypeToArcadeType(field) {
|
|
167360
|
-
|
|
167361
|
-
|
|
167362
|
-
|
|
167363
|
-
|
|
167364
|
-
|
|
167365
|
-
|
|
167366
|
-
|
|
167367
|
-
|
|
167368
|
-
|
|
167369
|
-
|
|
167370
|
-
|
|
167371
|
-
|
|
167372
|
-
|
|
167373
|
-
|
|
167374
|
-
|
|
167375
|
-
|
|
167376
|
-
|
|
167377
|
-
|
|
167378
|
-
|
|
167379
|
-
|
|
167380
|
-
|
|
167381
|
-
|
|
167360
|
+
switch (field?.type) {
|
|
167361
|
+
case "small-integer":
|
|
167362
|
+
case "integer":
|
|
167363
|
+
case "big-integer":
|
|
167364
|
+
case "single":
|
|
167365
|
+
case "double":
|
|
167366
|
+
case "long":
|
|
167367
|
+
case "oid":
|
|
167368
|
+
return "number";
|
|
167369
|
+
case "global-id":
|
|
167370
|
+
case "guid":
|
|
167371
|
+
case "string":
|
|
167372
|
+
return "text";
|
|
167373
|
+
case "date":
|
|
167374
|
+
return "date";
|
|
167375
|
+
case "date-only":
|
|
167376
|
+
return "dateOnly";
|
|
167377
|
+
case "time-only":
|
|
167378
|
+
return "time";
|
|
167379
|
+
default:
|
|
167380
|
+
return "text";
|
|
167381
|
+
}
|
|
167382
167382
|
}
|
|
167383
167383
|
function supportedFields(fields) {
|
|
167384
|
-
|
|
167385
|
-
|
|
167386
|
-
|
|
167387
|
-
|
|
167388
|
-
|
|
167389
|
-
|
|
167390
|
-
|
|
167391
|
-
|
|
167392
|
-
|
|
167393
|
-
|
|
167394
|
-
|
|
167395
|
-
|
|
167396
|
-
|
|
167397
|
-
|
|
167398
|
-
|
|
167399
|
-
|
|
167400
|
-
|
|
167401
|
-
|
|
167402
|
-
|
|
167403
|
-
|
|
167404
|
-
|
|
167384
|
+
return (fields ?? []).filter((field) => {
|
|
167385
|
+
switch (field.type) {
|
|
167386
|
+
case "string":
|
|
167387
|
+
case "small-integer":
|
|
167388
|
+
case "integer":
|
|
167389
|
+
case "big-integer":
|
|
167390
|
+
case "single":
|
|
167391
|
+
case "double":
|
|
167392
|
+
case "long":
|
|
167393
|
+
case "date":
|
|
167394
|
+
case "date-only":
|
|
167395
|
+
case "time-only":
|
|
167396
|
+
case "timestamp-offset":
|
|
167397
|
+
case "oid":
|
|
167398
|
+
case "guid":
|
|
167399
|
+
case "global-id":
|
|
167400
|
+
return true;
|
|
167401
|
+
default:
|
|
167402
|
+
return false;
|
|
167403
|
+
}
|
|
167404
|
+
});
|
|
167405
167405
|
}
|
|
167406
167406
|
|
|
167407
167407
|
function resolveIntlPath(dictionary, path) {
|
|
167408
|
-
|
|
167409
|
-
|
|
167410
|
-
|
|
167411
|
-
|
|
167412
|
-
|
|
167413
|
-
|
|
167414
|
-
|
|
167415
|
-
|
|
167416
|
-
|
|
167417
|
-
|
|
167418
|
-
|
|
167419
|
-
|
|
167408
|
+
if (!dictionary) {
|
|
167409
|
+
return "";
|
|
167410
|
+
}
|
|
167411
|
+
const pathSegments = path.split(".");
|
|
167412
|
+
let pathSegment = pathSegments.shift();
|
|
167413
|
+
let entry = dictionary;
|
|
167414
|
+
while (entry && pathSegment) {
|
|
167415
|
+
// @ts-expect-error
|
|
167416
|
+
entry = entry[pathSegment];
|
|
167417
|
+
pathSegment = pathSegments.shift();
|
|
167418
|
+
}
|
|
167419
|
+
return typeof entry === "string" ? entry : path;
|
|
167420
167420
|
}
|
|
167421
167421
|
function isTypesCapabaleLayer(item) {
|
|
167422
|
-
|
|
167422
|
+
return !!item?.typeIdField;
|
|
167423
167423
|
}
|
|
167424
167424
|
function isDomainsCapableLayer(item) {
|
|
167425
|
-
|
|
167425
|
+
return typeof item?.getFieldDomain === "function";
|
|
167426
167426
|
}
|
|
167427
167427
|
function isRelationshipsCapableLayer(item) {
|
|
167428
|
-
|
|
167428
|
+
return Array.isArray(item?.relationships) && typeof item?.url === "string";
|
|
167429
167429
|
}
|
|
167430
167430
|
function isTableCapableLayer(item) {
|
|
167431
|
-
|
|
167431
|
+
return typeof item?.isTable === "boolean";
|
|
167432
167432
|
}
|
|
167433
167433
|
function isLoadableSource(item) {
|
|
167434
|
-
|
|
167434
|
+
return typeof item?.load === "function";
|
|
167435
167435
|
}
|
|
167436
167436
|
//#endregion
|
|
167437
167437
|
//#region Support Functions
|
|
167438
167438
|
async function getRelatedFeatureLayer(layer, relationship) {
|
|
167439
|
-
|
|
167440
|
-
|
|
167441
|
-
}
|
|
167442
|
-
const url = `${layer.url}/${relationship.relatedTableId}`;
|
|
167443
|
-
const relatedFeatureLayer = await supportedSourceFromDefinition({ url });
|
|
167444
|
-
if (!isFeatureLayerInstance(relatedFeatureLayer)) {
|
|
167445
|
-
return null;
|
|
167446
|
-
}
|
|
167447
|
-
return relatedFeatureLayer;
|
|
167448
|
-
}
|
|
167449
|
-
function sortFields(layer) {
|
|
167450
|
-
return (firstField, secondField) => {
|
|
167451
|
-
if (firstField.type === "oid") {
|
|
167452
|
-
return -1;
|
|
167453
|
-
}
|
|
167454
|
-
if (secondField.type === "oid") {
|
|
167455
|
-
return 1;
|
|
167439
|
+
if (!relationship) {
|
|
167440
|
+
return null;
|
|
167456
167441
|
}
|
|
167457
|
-
|
|
167458
|
-
|
|
167459
|
-
|
|
167460
|
-
|
|
167461
|
-
if (secondField.name === layer.typeIdField) {
|
|
167462
|
-
return 1;
|
|
167463
|
-
}
|
|
167442
|
+
const url = `${layer.url}/${relationship.relatedTableId}`;
|
|
167443
|
+
const relatedFeatureLayer = await supportedSourceFromDefinition({ url });
|
|
167444
|
+
if (!isFeatureLayerInstance(relatedFeatureLayer)) {
|
|
167445
|
+
return null;
|
|
167464
167446
|
}
|
|
167465
|
-
return
|
|
167466
|
-
|
|
167447
|
+
return relatedFeatureLayer;
|
|
167448
|
+
}
|
|
167449
|
+
function sortFields(layer) {
|
|
167450
|
+
return (firstField, secondField) => {
|
|
167451
|
+
if (firstField.type === "oid") {
|
|
167452
|
+
return -1;
|
|
167453
|
+
}
|
|
167454
|
+
if (secondField.type === "oid") {
|
|
167455
|
+
return 1;
|
|
167456
|
+
}
|
|
167457
|
+
if (isTypesCapabaleLayer(layer)) {
|
|
167458
|
+
if (firstField.name === layer.typeIdField) {
|
|
167459
|
+
return -1;
|
|
167460
|
+
}
|
|
167461
|
+
if (secondField.name === layer.typeIdField) {
|
|
167462
|
+
return 1;
|
|
167463
|
+
}
|
|
167464
|
+
}
|
|
167465
|
+
return firstField.name.localeCompare(secondField.name, "en", { sensitivity: "base" });
|
|
167466
|
+
};
|
|
167467
167467
|
}
|
|
167468
167468
|
function getSubtypesProperties(profile, types, field) {
|
|
167469
|
-
|
|
167470
|
-
|
|
167471
|
-
|
|
167472
|
-
|
|
167473
|
-
|
|
167474
|
-
|
|
167475
|
-
|
|
167476
|
-
|
|
167469
|
+
// Try the coded domain first
|
|
167470
|
+
const group = getDomainValuesProperties(profile, field.domain, { code: "subtypes" });
|
|
167471
|
+
if (group) {
|
|
167472
|
+
return group;
|
|
167473
|
+
}
|
|
167474
|
+
// No coded domain for the subtypes, we will manufacture it
|
|
167475
|
+
const values = types.map((t) => new ValueVariable({ profile, label: `${t.id}`, description: t.name, snippet: `"${t.id}"` }));
|
|
167476
|
+
return new GroupOfVariables(profile, { code: "subtypes" }, values);
|
|
167477
167477
|
}
|
|
167478
167478
|
function getDomainValuesProperties(profile, domain, label) {
|
|
167479
|
-
|
|
167480
|
-
|
|
167481
|
-
|
|
167482
|
-
|
|
167483
|
-
|
|
167484
|
-
|
|
167485
|
-
|
|
167486
|
-
|
|
167487
|
-
|
|
167488
|
-
|
|
167489
|
-
|
|
167479
|
+
if (!domain || domain.type !== "coded-value") {
|
|
167480
|
+
return null;
|
|
167481
|
+
}
|
|
167482
|
+
const values = domain.codedValues.map((v) => new ValueVariable({
|
|
167483
|
+
profile,
|
|
167484
|
+
label: `${v.code}`,
|
|
167485
|
+
description: v.name,
|
|
167486
|
+
snippet: `"${v.code}"`,
|
|
167487
|
+
filterDescription: true
|
|
167488
|
+
}));
|
|
167489
|
+
return new GroupOfVariables(profile, label, values);
|
|
167490
167490
|
}
|
|
167491
167491
|
function getDomainValuesBySubtypeGroup(profile, types, field) {
|
|
167492
|
-
|
|
167493
|
-
|
|
167494
|
-
|
|
167495
|
-
|
|
167496
|
-
|
|
167497
|
-
|
|
167498
|
-
|
|
167499
|
-
|
|
167500
|
-
|
|
167501
|
-
|
|
167502
|
-
|
|
167503
|
-
|
|
167504
|
-
|
|
167505
|
-
|
|
167506
|
-
|
|
167507
|
-
|
|
167492
|
+
const variables = [];
|
|
167493
|
+
types.forEach((t) => {
|
|
167494
|
+
let domain = t.domains?.[field.name];
|
|
167495
|
+
if (!domain) {
|
|
167496
|
+
return;
|
|
167497
|
+
}
|
|
167498
|
+
if (domain.type === "inherited") {
|
|
167499
|
+
domain = field.domain;
|
|
167500
|
+
return;
|
|
167501
|
+
}
|
|
167502
|
+
const domainValuesGroup = getDomainValuesProperties(profile, domain, {
|
|
167503
|
+
code: "domainvaluesfortypeformat",
|
|
167504
|
+
formatValues: {
|
|
167505
|
+
fieldName: field.alias ?? field.name,
|
|
167506
|
+
typeName: t.name
|
|
167507
|
+
}
|
|
167508
|
+
});
|
|
167509
|
+
if (!domainValuesGroup) {
|
|
167510
|
+
return;
|
|
167511
|
+
}
|
|
167512
|
+
const label = `${t.id}`;
|
|
167513
|
+
const snippet = `"${t.id}""`;
|
|
167514
|
+
const subtypeDictionary = new DictionaryVariable({ profile, label, snippet });
|
|
167515
|
+
subtypeDictionary.variables = [domainValuesGroup];
|
|
167516
|
+
variables.push(subtypeDictionary);
|
|
167508
167517
|
});
|
|
167509
|
-
if (!
|
|
167510
|
-
|
|
167518
|
+
if (!variables.length) {
|
|
167519
|
+
return null;
|
|
167511
167520
|
}
|
|
167512
|
-
|
|
167513
|
-
const snippet = `"${t.id}""`;
|
|
167514
|
-
const subtypeDictionary = new DictionaryVariable({ profile, label, snippet });
|
|
167515
|
-
subtypeDictionary.variables = [domainValuesGroup];
|
|
167516
|
-
variables.push(subtypeDictionary);
|
|
167517
|
-
});
|
|
167518
|
-
if (!variables.length) {
|
|
167519
|
-
return null;
|
|
167520
|
-
}
|
|
167521
|
-
return new GroupOfVariables(profile, { code: "domainvaluesbysubtypes" }, variables);
|
|
167521
|
+
return new GroupOfVariables(profile, { code: "domainvaluesbysubtypes" }, variables);
|
|
167522
167522
|
}
|
|
167523
167523
|
// const validIdentifierExpr = new RegExp(/^[a-z_$][\w$]*$/gi);
|
|
167524
167524
|
const validIdentifierExpr = new RegExp(/^[a-z_$][a-z0-9_$]*$/gi);
|
|
167525
167525
|
function getMemberExpressionProperty(prop, includeDot = true) {
|
|
167526
|
-
|
|
167527
|
-
|
|
167528
|
-
|
|
167529
|
-
|
|
167526
|
+
if (prop.match(validIdentifierExpr)) {
|
|
167527
|
+
return `${includeDot ? "." : ""}${prop}`;
|
|
167528
|
+
}
|
|
167529
|
+
return `["${prop}"]`;
|
|
167530
167530
|
}
|
|
167531
167531
|
function assembleMemberExpression(obj, prop) {
|
|
167532
|
-
|
|
167533
|
-
|
|
167534
|
-
|
|
167535
|
-
|
|
167532
|
+
if (!obj) {
|
|
167533
|
+
return prop;
|
|
167534
|
+
}
|
|
167535
|
+
return `${obj}${getMemberExpressionProperty(prop)}`;
|
|
167536
167536
|
}
|
|
167537
167537
|
//#endregion
|
|
167538
167538
|
//#region Sources
|
|
167539
167539
|
async function supportedSourceFromDefinition(definition) {
|
|
167540
|
-
|
|
167541
|
-
|
|
167542
|
-
}
|
|
167543
|
-
let source = null;
|
|
167544
|
-
if (isSupportedLayerInstance(definition) || isFeatureSetInstance(definition) || isFieldsDefinition(definition)) {
|
|
167545
|
-
source = definition;
|
|
167546
|
-
}
|
|
167547
|
-
else {
|
|
167548
|
-
source = await newFeatureLayer(definition);
|
|
167549
|
-
if (!isFeatureLayerInstance(source)) {
|
|
167550
|
-
console.error("Invalid FeatureSetDefinition", definition);
|
|
167551
|
-
return null;
|
|
167540
|
+
if (!definition) {
|
|
167541
|
+
return null;
|
|
167552
167542
|
}
|
|
167553
|
-
|
|
167554
|
-
|
|
167555
|
-
|
|
167556
|
-
|
|
167557
|
-
|
|
167558
|
-
|
|
167559
|
-
|
|
167560
|
-
|
|
167561
|
-
|
|
167543
|
+
let source = null;
|
|
167544
|
+
if (isSupportedLayerInstance(definition) || isFeatureSetInstance(definition) || isFieldsDefinition(definition)) {
|
|
167545
|
+
source = definition;
|
|
167546
|
+
}
|
|
167547
|
+
else {
|
|
167548
|
+
source = await newFeatureLayer(definition);
|
|
167549
|
+
if (!isFeatureLayerInstance(source)) {
|
|
167550
|
+
console.error("Invalid FeatureSetDefinition", definition);
|
|
167551
|
+
return null;
|
|
167552
|
+
}
|
|
167553
|
+
}
|
|
167554
|
+
if (!source) {
|
|
167555
|
+
console.error("Invalid FeatureSetDefinition", definition);
|
|
167556
|
+
return null;
|
|
167557
|
+
}
|
|
167558
|
+
if (isLoadableSource(source)) {
|
|
167559
|
+
await source.load();
|
|
167560
|
+
}
|
|
167561
|
+
return source;
|
|
167562
167562
|
}
|
|
167563
167563
|
async function serviceMetaData(url) {
|
|
167564
|
-
|
|
167565
|
-
|
|
167566
|
-
|
|
167567
|
-
|
|
167568
|
-
|
|
167569
|
-
|
|
167570
|
-
|
|
167571
|
-
|
|
167572
|
-
|
|
167573
|
-
|
|
167574
|
-
|
|
167564
|
+
url += "/layers";
|
|
167565
|
+
const request = await importRequest();
|
|
167566
|
+
const response = await request(url, { responseType: "json", query: { f: "json" } });
|
|
167567
|
+
const data = {
|
|
167568
|
+
layers: response.data?.layers ?? [],
|
|
167569
|
+
tables: response.data?.tables ?? []
|
|
167570
|
+
};
|
|
167571
|
+
const queryCapability = url.endsWith("MapServer/layers") ? "data" : "query";
|
|
167572
|
+
const layers = filterFeatureLayerInfos(data.layers, queryCapability);
|
|
167573
|
+
const tables = filterFeatureLayerInfos(data.tables, queryCapability);
|
|
167574
|
+
return { layers, tables };
|
|
167575
167575
|
}
|
|
167576
167576
|
function filterFeatureLayerInfos(layers, queryCapability) {
|
|
167577
|
-
|
|
167578
|
-
|
|
167579
|
-
|
|
167580
|
-
|
|
167581
|
-
|
|
167582
|
-
|
|
167583
|
-
|
|
167584
|
-
|
|
167585
|
-
|
|
167586
|
-
|
|
167587
|
-
|
|
167588
|
-
|
|
167577
|
+
return layers.filter((layer) => {
|
|
167578
|
+
if (layer.type !== "Feature Layer" && layer.type !== "Table") {
|
|
167579
|
+
return false;
|
|
167580
|
+
}
|
|
167581
|
+
const capabilities = layer.capabilities
|
|
167582
|
+
? layer.capabilities
|
|
167583
|
+
.toLowerCase()
|
|
167584
|
+
.split(",")
|
|
167585
|
+
.map((value) => value.trim())
|
|
167586
|
+
: [];
|
|
167587
|
+
return capabilities.includes(queryCapability);
|
|
167588
|
+
});
|
|
167589
167589
|
}
|
|
167590
167590
|
//#endregion
|
|
167591
167591
|
//#region Functions to Editor Variables to a language service variables
|
|
167592
167592
|
async function variablesToLSVariable(editorVariables, kind = main.CompletionItemKind.Variable) {
|
|
167593
|
-
|
|
167594
|
-
|
|
167595
|
-
|
|
167596
|
-
|
|
167597
|
-
|
|
167598
|
-
|
|
167599
|
-
|
|
167600
|
-
|
|
167601
|
-
|
|
167602
|
-
|
|
167603
|
-
|
|
167604
|
-
|
|
167605
|
-
|
|
167606
|
-
|
|
167593
|
+
if (!editorVariables) {
|
|
167594
|
+
return [];
|
|
167595
|
+
}
|
|
167596
|
+
const properties = await Promise.all(editorVariables.map(async (editorVariable) => {
|
|
167597
|
+
switch (editorVariable.type) {
|
|
167598
|
+
case "dictionary":
|
|
167599
|
+
return dictionaryToLSDictionary(editorVariable, kind);
|
|
167600
|
+
case "feature":
|
|
167601
|
+
return featureToLSFeature(editorVariable, kind);
|
|
167602
|
+
default:
|
|
167603
|
+
return variableToLSVariable(editorVariable, kind);
|
|
167604
|
+
}
|
|
167605
|
+
}));
|
|
167606
|
+
return properties.filter((p) => p);
|
|
167607
167607
|
}
|
|
167608
167608
|
function variableToLSVariable(editorVariable, kind) {
|
|
167609
|
-
|
|
167610
|
-
|
|
167611
|
-
|
|
167612
|
-
|
|
167613
|
-
|
|
167614
|
-
|
|
167615
|
-
|
|
167616
|
-
|
|
167617
|
-
|
|
167618
|
-
|
|
167619
|
-
|
|
167620
|
-
|
|
167621
|
-
|
|
167622
|
-
|
|
167623
|
-
|
|
167624
|
-
|
|
167609
|
+
const { name, type } = editorVariable;
|
|
167610
|
+
const description = editorVariable.getDescription();
|
|
167611
|
+
return {
|
|
167612
|
+
name,
|
|
167613
|
+
description,
|
|
167614
|
+
type,
|
|
167615
|
+
completion: {
|
|
167616
|
+
label: name,
|
|
167617
|
+
detail: name,
|
|
167618
|
+
insertText: name,
|
|
167619
|
+
insertTextMode: main.InsertTextMode.asIs,
|
|
167620
|
+
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167621
|
+
kind,
|
|
167622
|
+
documentation: { kind: "markdown", value: description }
|
|
167623
|
+
}
|
|
167624
|
+
};
|
|
167625
167625
|
}
|
|
167626
167626
|
async function featureToLSFeature(editorFeature, kind) {
|
|
167627
|
-
|
|
167628
|
-
|
|
167629
|
-
|
|
167630
|
-
|
|
167631
|
-
|
|
167632
|
-
|
|
167633
|
-
|
|
167634
|
-
|
|
167635
|
-
insertTextMode: main.InsertTextMode.asIs,
|
|
167636
|
-
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167637
|
-
kind
|
|
167638
|
-
};
|
|
167639
|
-
const result = {
|
|
167640
|
-
name,
|
|
167641
|
-
description,
|
|
167642
|
-
type: "dictionary",
|
|
167643
|
-
properties: [],
|
|
167644
|
-
completion: resultCompletion
|
|
167645
|
-
};
|
|
167646
|
-
// No source definition, then it will be a feature without any known fields
|
|
167647
|
-
if (!source) {
|
|
167648
|
-
return result;
|
|
167649
|
-
}
|
|
167650
|
-
// Create properties for the fields and the aliases
|
|
167651
|
-
// Also improve the feature completion documentation
|
|
167652
|
-
let featureCompletionDescription = description;
|
|
167653
|
-
const fieldProfileValues = [];
|
|
167654
|
-
const aliasProfileValues = [];
|
|
167655
|
-
supportedFields(source.fields).forEach((field) => {
|
|
167656
|
-
let fieldCompletionDescription = `**${field.name}** \n${field.type}`;
|
|
167657
|
-
if (field.description) {
|
|
167658
|
-
fieldCompletionDescription += ` \n'${field.description}`;
|
|
167659
|
-
}
|
|
167660
|
-
if (featureCompletionDescription) {
|
|
167661
|
-
featureCompletionDescription += " \n \n";
|
|
167662
|
-
}
|
|
167663
|
-
featureCompletionDescription += `**${field.name}** (${field.alias ?? field.name}) \n${field.type}`;
|
|
167664
|
-
if (field.description) {
|
|
167665
|
-
featureCompletionDescription += ` \n'${field.description}`;
|
|
167666
|
-
}
|
|
167667
|
-
// The property for the field
|
|
167668
|
-
const type = fieldTypeToArcadeType(field);
|
|
167669
|
-
const insertText = getMemberExpressionProperty(field.name, false);
|
|
167670
|
-
fieldProfileValues.push({
|
|
167671
|
-
name: field.name,
|
|
167672
|
-
description: field.alias || field.name,
|
|
167673
|
-
type,
|
|
167674
|
-
completion: {
|
|
167675
|
-
label: field.name,
|
|
167676
|
-
detail: field.alias || field.name,
|
|
167677
|
-
insertText,
|
|
167627
|
+
// Get the source for the definition
|
|
167628
|
+
const source = await editorFeature.loadSource();
|
|
167629
|
+
const { name } = editorFeature;
|
|
167630
|
+
const description = editorFeature.getDescription();
|
|
167631
|
+
const resultCompletion = {
|
|
167632
|
+
label: name,
|
|
167633
|
+
detail: name,
|
|
167634
|
+
insertText: name,
|
|
167678
167635
|
insertTextMode: main.InsertTextMode.asIs,
|
|
167679
167636
|
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167680
|
-
kind
|
|
167681
|
-
|
|
167682
|
-
|
|
167683
|
-
|
|
167684
|
-
|
|
167685
|
-
|
|
167637
|
+
kind
|
|
167638
|
+
};
|
|
167639
|
+
const result = {
|
|
167640
|
+
name,
|
|
167641
|
+
description,
|
|
167642
|
+
type: "dictionary",
|
|
167643
|
+
properties: [],
|
|
167644
|
+
completion: resultCompletion
|
|
167645
|
+
};
|
|
167646
|
+
// No source definition, then it will be a feature without any known fields
|
|
167647
|
+
if (!source) {
|
|
167648
|
+
return result;
|
|
167686
167649
|
}
|
|
167687
|
-
//
|
|
167688
|
-
|
|
167689
|
-
|
|
167690
|
-
|
|
167691
|
-
|
|
167692
|
-
|
|
167693
|
-
|
|
167694
|
-
|
|
167695
|
-
|
|
167696
|
-
|
|
167697
|
-
|
|
167698
|
-
|
|
167699
|
-
|
|
167700
|
-
|
|
167701
|
-
|
|
167702
|
-
|
|
167703
|
-
|
|
167704
|
-
|
|
167650
|
+
// Create properties for the fields and the aliases
|
|
167651
|
+
// Also improve the feature completion documentation
|
|
167652
|
+
let featureCompletionDescription = description;
|
|
167653
|
+
const fieldProfileValues = [];
|
|
167654
|
+
const aliasProfileValues = [];
|
|
167655
|
+
supportedFields(source.fields).forEach((field) => {
|
|
167656
|
+
let fieldCompletionDescription = `**${field.name}** \n${field.type}`;
|
|
167657
|
+
if (field.description) {
|
|
167658
|
+
fieldCompletionDescription += ` \n'${field.description}`;
|
|
167659
|
+
}
|
|
167660
|
+
if (featureCompletionDescription) {
|
|
167661
|
+
featureCompletionDescription += " \n \n";
|
|
167662
|
+
}
|
|
167663
|
+
featureCompletionDescription += `**${field.name}** (${field.alias ?? field.name}) \n${field.type}`;
|
|
167664
|
+
if (field.description) {
|
|
167665
|
+
featureCompletionDescription += ` \n'${field.description}`;
|
|
167666
|
+
}
|
|
167667
|
+
// The property for the field
|
|
167668
|
+
const type = fieldTypeToArcadeType(field);
|
|
167669
|
+
const insertText = getMemberExpressionProperty(field.name, false);
|
|
167670
|
+
fieldProfileValues.push({
|
|
167671
|
+
name: field.name,
|
|
167672
|
+
description: field.alias || field.name,
|
|
167673
|
+
type,
|
|
167674
|
+
completion: {
|
|
167675
|
+
label: field.name,
|
|
167676
|
+
detail: field.alias || field.name,
|
|
167677
|
+
insertText,
|
|
167678
|
+
insertTextMode: main.InsertTextMode.asIs,
|
|
167679
|
+
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167680
|
+
kind: main.CompletionItemKind.Field,
|
|
167681
|
+
documentation: { kind: "markdown", value: fieldCompletionDescription }
|
|
167682
|
+
}
|
|
167683
|
+
});
|
|
167684
|
+
if (!field.alias || field.alias.toLowerCase() === field.name.toLowerCase()) {
|
|
167685
|
+
return;
|
|
167686
|
+
}
|
|
167687
|
+
// The property for the alias if different than the field name
|
|
167688
|
+
let aliasCompletionDescription = `**${field.alias}** \n${field.type}`;
|
|
167689
|
+
if (field.description) {
|
|
167690
|
+
aliasCompletionDescription += ` \n'${field.description}`;
|
|
167691
|
+
}
|
|
167692
|
+
aliasProfileValues.push({
|
|
167693
|
+
name: field.alias,
|
|
167694
|
+
description: field.name,
|
|
167695
|
+
type,
|
|
167696
|
+
completion: {
|
|
167697
|
+
label: field.alias,
|
|
167698
|
+
detail: field.name,
|
|
167699
|
+
insertText,
|
|
167700
|
+
insertTextMode: main.InsertTextMode.asIs,
|
|
167701
|
+
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167702
|
+
kind: main.CompletionItemKind.Field,
|
|
167703
|
+
documentation: { kind: "markdown", value: aliasCompletionDescription }
|
|
167704
|
+
}
|
|
167705
|
+
});
|
|
167705
167706
|
});
|
|
167706
|
-
|
|
167707
|
-
|
|
167708
|
-
|
|
167709
|
-
return result;
|
|
167707
|
+
result.properties = [...fieldProfileValues, ...aliasProfileValues];
|
|
167708
|
+
resultCompletion.documentation = { kind: "markdown", value: featureCompletionDescription };
|
|
167709
|
+
return result;
|
|
167710
167710
|
}
|
|
167711
167711
|
async function dictionaryToLSDictionary(editorDictionary, kind) {
|
|
167712
|
-
|
|
167713
|
-
|
|
167714
|
-
|
|
167715
|
-
|
|
167716
|
-
|
|
167717
|
-
|
|
167718
|
-
|
|
167719
|
-
|
|
167720
|
-
|
|
167721
|
-
|
|
167722
|
-
|
|
167723
|
-
|
|
167724
|
-
|
|
167725
|
-
|
|
167726
|
-
|
|
167727
|
-
|
|
167728
|
-
|
|
167729
|
-
|
|
167730
|
-
|
|
167731
|
-
|
|
167732
|
-
|
|
167733
|
-
|
|
167734
|
-
|
|
167735
|
-
|
|
167736
|
-
|
|
167737
|
-
|
|
167738
|
-
|
|
167739
|
-
|
|
167712
|
+
const { name, dictionaryVariables: variables } = editorDictionary;
|
|
167713
|
+
const description = editorDictionary.getDescription();
|
|
167714
|
+
const completionDescription = variables.reduce((previous, p) => {
|
|
167715
|
+
if (previous !== "") {
|
|
167716
|
+
previous += " \n \n";
|
|
167717
|
+
}
|
|
167718
|
+
previous += `**${p.name}** \n${p.type}`;
|
|
167719
|
+
const description = p.getDescription();
|
|
167720
|
+
if (description) {
|
|
167721
|
+
previous += ` \n${description}`;
|
|
167722
|
+
}
|
|
167723
|
+
return previous;
|
|
167724
|
+
}, description ?? "");
|
|
167725
|
+
return {
|
|
167726
|
+
name,
|
|
167727
|
+
description,
|
|
167728
|
+
type: "dictionary",
|
|
167729
|
+
properties: await variablesToLSVariable(variables, main.CompletionItemKind.Field),
|
|
167730
|
+
completion: {
|
|
167731
|
+
label: name,
|
|
167732
|
+
detail: name,
|
|
167733
|
+
insertText: name,
|
|
167734
|
+
insertTextMode: main.InsertTextMode.asIs,
|
|
167735
|
+
insertTextFormat: main.InsertTextFormat.PlainText,
|
|
167736
|
+
kind,
|
|
167737
|
+
documentation: { kind: "markdown", value: completionDescription }
|
|
167738
|
+
}
|
|
167739
|
+
};
|
|
167740
167740
|
}
|
|
167741
167741
|
/**
|
|
167742
167742
|
* Represents a item in the EditorProfile. The profile is converted into an optimized way for
|
|
@@ -167744,107 +167744,107 @@ async function dictionaryToLSDictionary(editorDictionary, kind) {
|
|
|
167744
167744
|
* structures are created such as groups.
|
|
167745
167745
|
*/
|
|
167746
167746
|
class ProfileItemBase {
|
|
167747
|
-
|
|
167748
|
-
|
|
167749
|
-
|
|
167750
|
-
|
|
167751
|
-
|
|
167752
|
-
}
|
|
167753
|
-
/**
|
|
167754
|
-
* Returns the label string.
|
|
167755
|
-
*/
|
|
167756
|
-
getLabel() {
|
|
167757
|
-
if (this._label == null) {
|
|
167758
|
-
return "";
|
|
167759
|
-
}
|
|
167760
|
-
if (typeof this._label === "string") {
|
|
167761
|
-
// Some of our variables can start with a $ sign.
|
|
167762
|
-
// If the component is under RTL, the string is messed up.
|
|
167763
|
-
// It is converted from $feature to feature$, This is not acceptable since the label
|
|
167764
|
-
// represents a variable name. We are adding in front of the $ sign a right to left mark.
|
|
167765
|
-
return q(this._label);
|
|
167766
|
-
}
|
|
167767
|
-
return H(this._profile?.intlStrings?.[this._label.code], this._label.formatValues);
|
|
167768
|
-
}
|
|
167769
|
-
/**
|
|
167770
|
-
* Returns the description string.
|
|
167771
|
-
*/
|
|
167772
|
-
getDescription() {
|
|
167773
|
-
if (this.description == null) {
|
|
167774
|
-
return "";
|
|
167747
|
+
constructor(_profile, _label, description) {
|
|
167748
|
+
this._profile = _profile;
|
|
167749
|
+
this._label = _label;
|
|
167750
|
+
this.description = description;
|
|
167751
|
+
this.filterDescription = false;
|
|
167775
167752
|
}
|
|
167776
|
-
|
|
167777
|
-
|
|
167753
|
+
/**
|
|
167754
|
+
* Returns the label string.
|
|
167755
|
+
*/
|
|
167756
|
+
getLabel() {
|
|
167757
|
+
if (this._label == null) {
|
|
167758
|
+
return "";
|
|
167759
|
+
}
|
|
167760
|
+
if (typeof this._label === "string") {
|
|
167761
|
+
// Some of our variables can start with a $ sign.
|
|
167762
|
+
// If the component is under RTL, the string is messed up.
|
|
167763
|
+
// It is converted from $feature to feature$, This is not acceptable since the label
|
|
167764
|
+
// represents a variable name. We are adding in front of the $ sign a right to left mark.
|
|
167765
|
+
return q(this._label);
|
|
167766
|
+
}
|
|
167767
|
+
return H(this._profile?.intlStrings?.[this._label.code], this._label.formatValues);
|
|
167778
167768
|
}
|
|
167779
|
-
|
|
167780
|
-
|
|
167781
|
-
|
|
167782
|
-
|
|
167783
|
-
|
|
167784
|
-
|
|
167785
|
-
|
|
167786
|
-
|
|
167769
|
+
/**
|
|
167770
|
+
* Returns the description string.
|
|
167771
|
+
*/
|
|
167772
|
+
getDescription() {
|
|
167773
|
+
if (this.description == null) {
|
|
167774
|
+
return "";
|
|
167775
|
+
}
|
|
167776
|
+
if (typeof this.description === "string") {
|
|
167777
|
+
return this.description;
|
|
167778
|
+
}
|
|
167779
|
+
return H(this._profile?.intlStrings?.[this.description.code ?? ""], this.description.formatValues);
|
|
167787
167780
|
}
|
|
167788
|
-
|
|
167789
|
-
|
|
167781
|
+
/**
|
|
167782
|
+
* Returns true if the item pass the filter test
|
|
167783
|
+
*/
|
|
167784
|
+
passFilter(filterExpression) {
|
|
167785
|
+
if (!filterExpression) {
|
|
167786
|
+
return true;
|
|
167787
|
+
}
|
|
167788
|
+
if (filterExpression.test(this.getLabel())) {
|
|
167789
|
+
return true;
|
|
167790
|
+
}
|
|
167791
|
+
return this.filterDescription && filterExpression.test(this.getDescription());
|
|
167790
167792
|
}
|
|
167791
|
-
return this.filterDescription && filterExpression.test(this.getDescription());
|
|
167792
|
-
}
|
|
167793
167793
|
}
|
|
167794
167794
|
/**
|
|
167795
167795
|
* The base class for profile variables representation in the EditorProfile.
|
|
167796
167796
|
*/
|
|
167797
167797
|
class VariableBase extends ProfileItemBase {
|
|
167798
|
-
|
|
167799
|
-
|
|
167800
|
-
|
|
167801
|
-
|
|
167802
|
-
|
|
167803
|
-
|
|
167804
|
-
|
|
167805
|
-
|
|
167806
|
-
|
|
167798
|
+
constructor(props) {
|
|
167799
|
+
super(props.profile, props.label, props.description ?? props.declaration?.description);
|
|
167800
|
+
this.declaration = props.declaration ?? {};
|
|
167801
|
+
this.name = props.declaration?.name ?? "";
|
|
167802
|
+
this.snippet = props.snippet || "";
|
|
167803
|
+
this.nonInteractive = props.nonInteractive ?? false;
|
|
167804
|
+
this.filterDescription = props.filterDescription ?? false;
|
|
167805
|
+
this.icon = props.icon;
|
|
167806
|
+
}
|
|
167807
167807
|
}
|
|
167808
167808
|
/**
|
|
167809
167809
|
* Represents the IProfileValue.
|
|
167810
167810
|
*/
|
|
167811
167811
|
class ValueVariable extends VariableBase {
|
|
167812
|
-
|
|
167813
|
-
|
|
167814
|
-
|
|
167815
|
-
|
|
167816
|
-
|
|
167817
|
-
|
|
167818
|
-
|
|
167819
|
-
|
|
167820
|
-
|
|
167812
|
+
constructor(props) {
|
|
167813
|
+
super(props);
|
|
167814
|
+
this.type = "text";
|
|
167815
|
+
this.isCollection = false;
|
|
167816
|
+
this.type = props?.declaration?.type ?? "text";
|
|
167817
|
+
}
|
|
167818
|
+
getDescription() {
|
|
167819
|
+
if (this.description == null) {
|
|
167820
|
+
return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
|
|
167821
|
+
}
|
|
167822
|
+
return super.getDescription();
|
|
167823
|
+
}
|
|
167824
|
+
toProfileVariableDefinition() {
|
|
167825
|
+
return { type: this.type, name: "", ...this.declaration };
|
|
167821
167826
|
}
|
|
167822
|
-
return super.getDescription();
|
|
167823
|
-
}
|
|
167824
|
-
toProfileVariableDefinition() {
|
|
167825
|
-
return { type: this.type, name: "", ...this.declaration };
|
|
167826
|
-
}
|
|
167827
167827
|
}
|
|
167828
167828
|
/**
|
|
167829
167829
|
* Represents the IProfileArray. The main difference is that the IProfileValue type
|
|
167830
167830
|
* is used as valueType.
|
|
167831
167831
|
*/
|
|
167832
167832
|
class ArrayVariable extends VariableBase {
|
|
167833
|
-
|
|
167834
|
-
|
|
167835
|
-
|
|
167836
|
-
|
|
167837
|
-
|
|
167838
|
-
|
|
167839
|
-
|
|
167840
|
-
|
|
167841
|
-
|
|
167833
|
+
constructor(props) {
|
|
167834
|
+
super(props);
|
|
167835
|
+
this.type = "array";
|
|
167836
|
+
this.isCollection = false;
|
|
167837
|
+
this.elementType = props.declaration?.elementType ?? { type: "number", name: "number" };
|
|
167838
|
+
}
|
|
167839
|
+
getDescription() {
|
|
167840
|
+
if (this.description == null) {
|
|
167841
|
+
return resolveIntlPath(this._profile?.intlStrings, this.type.toLowerCase()) ?? "";
|
|
167842
|
+
}
|
|
167843
|
+
return super.getDescription();
|
|
167844
|
+
}
|
|
167845
|
+
toProfileVariableDefinition() {
|
|
167846
|
+
return { type: this.type, elementType: this.elementType, name: "", ...this.declaration };
|
|
167842
167847
|
}
|
|
167843
|
-
return super.getDescription();
|
|
167844
|
-
}
|
|
167845
|
-
toProfileVariableDefinition() {
|
|
167846
|
-
return { type: this.type, elementType: this.elementType, name: "", ...this.declaration };
|
|
167847
|
-
}
|
|
167848
167848
|
}
|
|
167849
167849
|
/**
|
|
167850
167850
|
* Represents a collection of items. The collection of items can be synchronous or
|
|
@@ -167853,595 +167853,595 @@ class ArrayVariable extends VariableBase {
|
|
|
167853
167853
|
* collection is ready or not.
|
|
167854
167854
|
*/
|
|
167855
167855
|
class CollectionBasedVariable extends VariableBase {
|
|
167856
|
-
|
|
167857
|
-
|
|
167858
|
-
|
|
167859
|
-
|
|
167856
|
+
constructor(props) {
|
|
167857
|
+
super(props);
|
|
167858
|
+
this.isCollection = true;
|
|
167859
|
+
this._loaded = true;
|
|
167860
|
+
/**
|
|
167861
|
+
* The collection of items used to display the profile.
|
|
167862
|
+
* If the collection is asynchronous, the 'load' function should
|
|
167863
|
+
* be called first before using the items.
|
|
167864
|
+
*/
|
|
167865
|
+
this.variables = [];
|
|
167866
|
+
}
|
|
167860
167867
|
/**
|
|
167861
|
-
*
|
|
167862
|
-
* If the collection is asynchronous, the 'load' function should
|
|
167863
|
-
* be called first before using the items.
|
|
167868
|
+
* Returns true if the collection has been loaded
|
|
167864
167869
|
*/
|
|
167865
|
-
|
|
167866
|
-
|
|
167867
|
-
|
|
167868
|
-
|
|
167869
|
-
|
|
167870
|
-
|
|
167871
|
-
|
|
167872
|
-
|
|
167873
|
-
|
|
167874
|
-
|
|
167875
|
-
|
|
167876
|
-
|
|
167877
|
-
|
|
167878
|
-
|
|
167879
|
-
|
|
167880
|
-
|
|
167881
|
-
|
|
167882
|
-
|
|
167883
|
-
|
|
167884
|
-
return null;
|
|
167885
|
-
}
|
|
167886
|
-
get informationType() {
|
|
167887
|
-
return "";
|
|
167888
|
-
}
|
|
167870
|
+
get loaded() {
|
|
167871
|
+
return this._loaded;
|
|
167872
|
+
}
|
|
167873
|
+
/**
|
|
167874
|
+
* Loads the items if the collection is asynchronous.
|
|
167875
|
+
* If the colleciton is synchronous then the function is a no-op.
|
|
167876
|
+
*/
|
|
167877
|
+
async loadSource() {
|
|
167878
|
+
return;
|
|
167879
|
+
}
|
|
167880
|
+
/**
|
|
167881
|
+
* Returns an url to the associated information
|
|
167882
|
+
*/
|
|
167883
|
+
get informationUrl() {
|
|
167884
|
+
return null;
|
|
167885
|
+
}
|
|
167886
|
+
get informationType() {
|
|
167887
|
+
return "";
|
|
167888
|
+
}
|
|
167889
167889
|
}
|
|
167890
167890
|
class GroupOfVariables extends ProfileItemBase {
|
|
167891
|
-
|
|
167892
|
-
|
|
167893
|
-
|
|
167894
|
-
|
|
167895
|
-
|
|
167896
|
-
|
|
167897
|
-
|
|
167898
|
-
|
|
167899
|
-
|
|
167891
|
+
constructor(profile, label, variables = []) {
|
|
167892
|
+
super(profile, label);
|
|
167893
|
+
this.variables = variables;
|
|
167894
|
+
this.type = "group";
|
|
167895
|
+
this.isCollection = true;
|
|
167896
|
+
}
|
|
167897
|
+
passFilter() {
|
|
167898
|
+
return true;
|
|
167899
|
+
}
|
|
167900
167900
|
}
|
|
167901
167901
|
class DictionaryVariable extends CollectionBasedVariable {
|
|
167902
|
-
|
|
167903
|
-
|
|
167904
|
-
|
|
167905
|
-
|
|
167906
|
-
|
|
167907
|
-
|
|
167908
|
-
|
|
167909
|
-
|
|
167910
|
-
|
|
167911
|
-
|
|
167912
|
-
|
|
167913
|
-
|
|
167914
|
-
|
|
167902
|
+
constructor(props) {
|
|
167903
|
+
super(props);
|
|
167904
|
+
this.type = "dictionary";
|
|
167905
|
+
/**
|
|
167906
|
+
* The variables that the dictionary holds. It is different than the variables.
|
|
167907
|
+
* The variables may contain grouping.
|
|
167908
|
+
*/
|
|
167909
|
+
this.dictionaryVariables = [];
|
|
167910
|
+
this.loadPropertyDeclarations(props?.declaration?.properties);
|
|
167911
|
+
// If we have a snippet then wrap the properties in a group and use the snippet as the heading
|
|
167912
|
+
// This is not applicable for root Dictionary such as Profile
|
|
167913
|
+
if (this.snippet && this.dictionaryVariables.length) {
|
|
167914
|
+
this.variables = [new GroupOfVariables(this._profile, this.snippet, this.dictionaryVariables)];
|
|
167915
|
+
}
|
|
167915
167916
|
}
|
|
167916
|
-
|
|
167917
|
-
|
|
167918
|
-
|
|
167919
|
-
|
|
167920
|
-
|
|
167921
|
-
|
|
167922
|
-
|
|
167923
|
-
|
|
167924
|
-
|
|
167925
|
-
|
|
167926
|
-
|
|
167927
|
-
|
|
167928
|
-
|
|
167929
|
-
|
|
167930
|
-
|
|
167931
|
-
|
|
167932
|
-
|
|
167933
|
-
|
|
167934
|
-
|
|
167935
|
-
|
|
167936
|
-
|
|
167937
|
-
|
|
167938
|
-
|
|
167939
|
-
|
|
167940
|
-
|
|
167941
|
-
|
|
167942
|
-
|
|
167943
|
-
|
|
167944
|
-
|
|
167945
|
-
|
|
167946
|
-
|
|
167947
|
-
|
|
167948
|
-
|
|
167949
|
-
|
|
167950
|
-
|
|
167951
|
-
|
|
167952
|
-
|
|
167953
|
-
|
|
167954
|
-
|
|
167955
|
-
|
|
167956
|
-
|
|
167957
|
-
|
|
167958
|
-
|
|
167959
|
-
|
|
167960
|
-
|
|
167961
|
-
|
|
167962
|
-
|
|
167963
|
-
|
|
167964
|
-
|
|
167965
|
-
|
|
167966
|
-
|
|
167967
|
-
|
|
167968
|
-
|
|
167969
|
-
|
|
167970
|
-
|
|
167971
|
-
|
|
167972
|
-
|
|
167917
|
+
loadPropertyDeclarations(declarations) {
|
|
167918
|
+
this.dictionaryVariables = this.createVariableInstances(declarations);
|
|
167919
|
+
this.variables = this.dictionaryVariables;
|
|
167920
|
+
}
|
|
167921
|
+
createVariableInstances(declarations) {
|
|
167922
|
+
if (!Array.isArray(declarations)) {
|
|
167923
|
+
return [];
|
|
167924
|
+
}
|
|
167925
|
+
const properties = [];
|
|
167926
|
+
declarations.forEach((declaration) => {
|
|
167927
|
+
const variable = this.createVariableInstance(declaration);
|
|
167928
|
+
if (variable) {
|
|
167929
|
+
properties.push(variable);
|
|
167930
|
+
}
|
|
167931
|
+
});
|
|
167932
|
+
return properties;
|
|
167933
|
+
}
|
|
167934
|
+
createVariableInstance(declaration) {
|
|
167935
|
+
const snippet = assembleMemberExpression(this.snippet, declaration.name);
|
|
167936
|
+
switch (declaration.type) {
|
|
167937
|
+
case "number":
|
|
167938
|
+
case "text":
|
|
167939
|
+
case "boolean":
|
|
167940
|
+
case "date":
|
|
167941
|
+
case "geometry":
|
|
167942
|
+
return new ValueVariable({ profile: this._profile, declaration, label: snippet, snippet });
|
|
167943
|
+
case "feature":
|
|
167944
|
+
return new FeatureVariable({ profile: this._profile, declaration, label: snippet, snippet });
|
|
167945
|
+
case "featureSet":
|
|
167946
|
+
return new FeatureSetVariable({ profile: this._profile, declaration, label: snippet, snippet }, [
|
|
167947
|
+
new ValueVariable({ profile: this._profile, label: snippet, description: "", snippet })
|
|
167948
|
+
]);
|
|
167949
|
+
case "featureSetCollection":
|
|
167950
|
+
return new FeatureSetCollectionVariable({
|
|
167951
|
+
profile: this._profile,
|
|
167952
|
+
declaration,
|
|
167953
|
+
label: snippet,
|
|
167954
|
+
snippet
|
|
167955
|
+
});
|
|
167956
|
+
case "dictionary":
|
|
167957
|
+
return new DictionaryVariable({
|
|
167958
|
+
profile: this._profile,
|
|
167959
|
+
declaration,
|
|
167960
|
+
label: snippet,
|
|
167961
|
+
snippet
|
|
167962
|
+
});
|
|
167963
|
+
case "array":
|
|
167964
|
+
return new ArrayVariable({
|
|
167965
|
+
profile: this._profile,
|
|
167966
|
+
declaration,
|
|
167967
|
+
label: snippet,
|
|
167968
|
+
snippet
|
|
167969
|
+
});
|
|
167970
|
+
default:
|
|
167971
|
+
console.error("Invalid profile variable", declaration);
|
|
167972
|
+
return null;
|
|
167973
|
+
}
|
|
167974
|
+
}
|
|
167975
|
+
toProfileVariableDefinition() {
|
|
167976
|
+
return {
|
|
167977
|
+
type: this.type,
|
|
167978
|
+
name: "",
|
|
167979
|
+
...this.declaration,
|
|
167980
|
+
properties: this.dictionaryVariables.map((variable) => variable.toProfileVariableDefinition())
|
|
167981
|
+
};
|
|
167973
167982
|
}
|
|
167974
|
-
}
|
|
167975
|
-
toProfileVariableDefinition() {
|
|
167976
|
-
return {
|
|
167977
|
-
type: this.type,
|
|
167978
|
-
name: "",
|
|
167979
|
-
...this.declaration,
|
|
167980
|
-
properties: this.dictionaryVariables.map((variable) => variable.toProfileVariableDefinition())
|
|
167981
|
-
};
|
|
167982
|
-
}
|
|
167983
167983
|
}
|
|
167984
167984
|
class SourceBasedVariable extends CollectionBasedVariable {
|
|
167985
|
-
|
|
167986
|
-
|
|
167987
|
-
|
|
167988
|
-
|
|
167989
|
-
|
|
167990
|
-
|
|
167991
|
-
}
|
|
167992
|
-
get title() {
|
|
167993
|
-
return this._source?.title ?? "";
|
|
167994
|
-
}
|
|
167995
|
-
get url() {
|
|
167996
|
-
return this._definition?.url ?? "";
|
|
167997
|
-
}
|
|
167998
|
-
get informationUrl() {
|
|
167999
|
-
if (!this.loaded) {
|
|
168000
|
-
return null;
|
|
167985
|
+
constructor(props, relationshipsProperties) {
|
|
167986
|
+
super(props);
|
|
167987
|
+
this.relationshipsProperties = relationshipsProperties;
|
|
167988
|
+
this._source = null;
|
|
167989
|
+
this._loaded = false;
|
|
167990
|
+
this._definition = props?.declaration?.definition;
|
|
168001
167991
|
}
|
|
168002
|
-
|
|
168003
|
-
|
|
168004
|
-
return null;
|
|
167992
|
+
get title() {
|
|
167993
|
+
return this._source?.title ?? "";
|
|
168005
167994
|
}
|
|
168006
|
-
|
|
168007
|
-
|
|
168008
|
-
}
|
|
168009
|
-
get informationType() {
|
|
168010
|
-
return this._profile?.intlStrings?.layer ?? "layer";
|
|
168011
|
-
}
|
|
168012
|
-
loadSource() {
|
|
168013
|
-
if (D(this._loadPromise) && G(this._loadPromise)) {
|
|
168014
|
-
return this._loadPromise;
|
|
167995
|
+
get url() {
|
|
167996
|
+
return this._definition?.url ?? "";
|
|
168015
167997
|
}
|
|
168016
|
-
|
|
168017
|
-
|
|
168018
|
-
|
|
168019
|
-
|
|
168020
|
-
|
|
168021
|
-
|
|
168022
|
-
|
|
168023
|
-
|
|
168024
|
-
|
|
168025
|
-
|
|
168026
|
-
}
|
|
168027
|
-
// Create the value property
|
|
168028
|
-
const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
|
|
168029
|
-
return new ValueVariable({
|
|
168030
|
-
profile: this._profile,
|
|
168031
|
-
label: valueSnippet,
|
|
168032
|
-
description: field.alias ?? field.name,
|
|
168033
|
-
snippet: valueSnippet,
|
|
168034
|
-
icon: fieldTypeToIconName(field),
|
|
168035
|
-
filterDescription: true
|
|
168036
|
-
});
|
|
168037
|
-
}
|
|
168038
|
-
_getSubtypesOrDomainValuesDictionary(field) {
|
|
168039
|
-
if (!isDomainsCapableLayer(this._source)) {
|
|
168040
|
-
return null;
|
|
167998
|
+
get informationUrl() {
|
|
167999
|
+
if (!this.loaded) {
|
|
168000
|
+
return null;
|
|
168001
|
+
}
|
|
168002
|
+
const url = this._source?.url;
|
|
168003
|
+
if (!url) {
|
|
168004
|
+
return null;
|
|
168005
|
+
}
|
|
168006
|
+
const layerId = this._source?.layerId ?? "";
|
|
168007
|
+
return `${url}/${layerId}`;
|
|
168041
168008
|
}
|
|
168042
|
-
|
|
168043
|
-
|
|
168044
|
-
const domainDictionary = new DictionaryVariable({
|
|
168045
|
-
profile: this._profile,
|
|
168046
|
-
label: valueSnippet,
|
|
168047
|
-
description: field.alias ?? field.name,
|
|
168048
|
-
snippet: valueSnippet,
|
|
168049
|
-
icon: "form-dropdown"
|
|
168050
|
-
});
|
|
168051
|
-
// Add the header group
|
|
168052
|
-
const headerGroup = new GroupOfVariables(this._profile, field.alias ?? field.name, [
|
|
168053
|
-
new ValueVariable({
|
|
168054
|
-
profile: this._profile,
|
|
168055
|
-
label: valueSnippet,
|
|
168056
|
-
description: "",
|
|
168057
|
-
snippet: valueSnippet
|
|
168058
|
-
})
|
|
168059
|
-
]);
|
|
168060
|
-
domainDictionary.variables = [headerGroup];
|
|
168061
|
-
// If it is the subtype field then get its coded domain values
|
|
168062
|
-
if (isTypesCapabaleLayer(this._source) && field.name === this._source.typeIdField) {
|
|
168063
|
-
const subtypesGroup = getSubtypesProperties(this._profile, this._source.types, field);
|
|
168064
|
-
domainDictionary.variables.push(subtypesGroup);
|
|
168065
|
-
return domainDictionary;
|
|
168066
|
-
}
|
|
168067
|
-
// Since its' not the subtype field then add the snippet for the domain name
|
|
168068
|
-
if (this.type === "feature") {
|
|
168069
|
-
const domainNameSnippet = `DomainName(${this.snippet}, "${field.name}")`;
|
|
168070
|
-
headerGroup.variables.push(new ValueVariable({
|
|
168071
|
-
profile: this._profile,
|
|
168072
|
-
label: domainNameSnippet,
|
|
168073
|
-
description: "",
|
|
168074
|
-
snippet: domainNameSnippet
|
|
168075
|
-
}));
|
|
168076
|
-
}
|
|
168077
|
-
if (isTypesCapabaleLayer(this._source)) {
|
|
168078
|
-
// Check if all the domains for the field in the types are inherited.
|
|
168079
|
-
// If it is we can simplify the structure by avoiding splitting in subtypes
|
|
168080
|
-
const allInherited = this._source.types.every((t) => t.domains?.[field.name]?.type === "inherited");
|
|
168081
|
-
if (!allInherited) {
|
|
168082
|
-
// We have domains per subtype
|
|
168083
|
-
// We need to go thru each types and create a dictionary.
|
|
168084
|
-
const domainValuesBySubtypeGroup = getDomainValuesBySubtypeGroup(this._profile, this._source.types, field);
|
|
168085
|
-
if (!domainValuesBySubtypeGroup) {
|
|
168086
|
-
return null;
|
|
168087
|
-
}
|
|
168088
|
-
domainDictionary.variables.push(domainValuesBySubtypeGroup);
|
|
168089
|
-
return domainDictionary;
|
|
168090
|
-
}
|
|
168009
|
+
get informationType() {
|
|
168010
|
+
return this._profile?.intlStrings?.layer ?? "layer";
|
|
168091
168011
|
}
|
|
168092
|
-
|
|
168093
|
-
|
|
168094
|
-
|
|
168095
|
-
|
|
168096
|
-
|
|
168097
|
-
|
|
168012
|
+
loadSource() {
|
|
168013
|
+
if (D(this._loadPromise) && G(this._loadPromise)) {
|
|
168014
|
+
return this._loadPromise;
|
|
168015
|
+
}
|
|
168016
|
+
this._loadPromise = this._loadSource();
|
|
168017
|
+
return this._loadPromise;
|
|
168098
168018
|
}
|
|
168099
|
-
|
|
168100
|
-
|
|
168101
|
-
|
|
168102
|
-
|
|
168103
|
-
|
|
168104
|
-
|
|
168105
|
-
|
|
168019
|
+
_getFieldProperty(field) {
|
|
168020
|
+
// Check if the field is the type id field or of the field has a coded domain.
|
|
168021
|
+
// If it has then the property will be an exanpdable property (dictionary).
|
|
168022
|
+
// Otherwise just return a simple value property.
|
|
168023
|
+
const subtypesOrDomainValuesDictionary = this._getSubtypesOrDomainValuesDictionary(field);
|
|
168024
|
+
if (subtypesOrDomainValuesDictionary) {
|
|
168025
|
+
return subtypesOrDomainValuesDictionary;
|
|
168026
|
+
}
|
|
168027
|
+
// Create the value property
|
|
168028
|
+
const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
|
|
168029
|
+
return new ValueVariable({
|
|
168030
|
+
profile: this._profile,
|
|
168031
|
+
label: valueSnippet,
|
|
168032
|
+
description: field.alias ?? field.name,
|
|
168033
|
+
snippet: valueSnippet,
|
|
168034
|
+
icon: fieldTypeToIconName(field),
|
|
168035
|
+
filterDescription: true
|
|
168036
|
+
});
|
|
168106
168037
|
}
|
|
168107
|
-
|
|
168108
|
-
|
|
168109
|
-
|
|
168038
|
+
_getSubtypesOrDomainValuesDictionary(field) {
|
|
168039
|
+
if (!isDomainsCapableLayer(this._source)) {
|
|
168040
|
+
return null;
|
|
168041
|
+
}
|
|
168042
|
+
// Create the domain dictionary, we may not use it
|
|
168043
|
+
const valueSnippet = this.type === "feature" ? assembleMemberExpression(this.snippet, field.name) : field.name;
|
|
168044
|
+
const domainDictionary = new DictionaryVariable({
|
|
168045
|
+
profile: this._profile,
|
|
168046
|
+
label: valueSnippet,
|
|
168047
|
+
description: field.alias ?? field.name,
|
|
168048
|
+
snippet: valueSnippet,
|
|
168049
|
+
icon: "form-dropdown"
|
|
168050
|
+
});
|
|
168051
|
+
// Add the header group
|
|
168052
|
+
const headerGroup = new GroupOfVariables(this._profile, field.alias ?? field.name, [
|
|
168053
|
+
new ValueVariable({
|
|
168054
|
+
profile: this._profile,
|
|
168055
|
+
label: valueSnippet,
|
|
168056
|
+
description: "",
|
|
168057
|
+
snippet: valueSnippet
|
|
168058
|
+
})
|
|
168059
|
+
]);
|
|
168060
|
+
domainDictionary.variables = [headerGroup];
|
|
168061
|
+
// If it is the subtype field then get its coded domain values
|
|
168062
|
+
if (isTypesCapabaleLayer(this._source) && field.name === this._source.typeIdField) {
|
|
168063
|
+
const subtypesGroup = getSubtypesProperties(this._profile, this._source.types, field);
|
|
168064
|
+
domainDictionary.variables.push(subtypesGroup);
|
|
168065
|
+
return domainDictionary;
|
|
168066
|
+
}
|
|
168067
|
+
// Since its' not the subtype field then add the snippet for the domain name
|
|
168068
|
+
if (this.type === "feature") {
|
|
168069
|
+
const domainNameSnippet = `DomainName(${this.snippet}, "${field.name}")`;
|
|
168070
|
+
headerGroup.variables.push(new ValueVariable({
|
|
168071
|
+
profile: this._profile,
|
|
168072
|
+
label: domainNameSnippet,
|
|
168073
|
+
description: "",
|
|
168074
|
+
snippet: domainNameSnippet
|
|
168075
|
+
}));
|
|
168076
|
+
}
|
|
168077
|
+
if (isTypesCapabaleLayer(this._source)) {
|
|
168078
|
+
// Check if all the domains for the field in the types are inherited.
|
|
168079
|
+
// If it is we can simplify the structure by avoiding splitting in subtypes
|
|
168080
|
+
const allInherited = this._source.types.every((t) => t.domains?.[field.name]?.type === "inherited");
|
|
168081
|
+
if (!allInherited) {
|
|
168082
|
+
// We have domains per subtype
|
|
168083
|
+
// We need to go thru each types and create a dictionary.
|
|
168084
|
+
const domainValuesBySubtypeGroup = getDomainValuesBySubtypeGroup(this._profile, this._source.types, field);
|
|
168085
|
+
if (!domainValuesBySubtypeGroup) {
|
|
168086
|
+
return null;
|
|
168087
|
+
}
|
|
168088
|
+
domainDictionary.variables.push(domainValuesBySubtypeGroup);
|
|
168089
|
+
return domainDictionary;
|
|
168090
|
+
}
|
|
168091
|
+
}
|
|
168092
|
+
// Either we have types but all the domains are inherited or we don't have types
|
|
168093
|
+
const domainValuesGroup = getDomainValuesProperties(this._profile, this._source.getFieldDomain?.(field.name), {
|
|
168094
|
+
code: "domainvalues"
|
|
168095
|
+
});
|
|
168096
|
+
if (!domainValuesGroup) {
|
|
168097
|
+
return null;
|
|
168098
|
+
}
|
|
168099
|
+
domainDictionary.variables.push(domainValuesGroup);
|
|
168100
|
+
return domainDictionary;
|
|
168110
168101
|
}
|
|
168111
|
-
|
|
168112
|
-
|
|
168113
|
-
|
|
168114
|
-
|
|
168115
|
-
|
|
168116
|
-
|
|
168117
|
-
|
|
168118
|
-
|
|
168119
|
-
|
|
168120
|
-
|
|
168121
|
-
|
|
168122
|
-
|
|
168123
|
-
|
|
168124
|
-
|
|
168125
|
-
|
|
168126
|
-
|
|
168127
|
-
|
|
168128
|
-
|
|
168129
|
-
|
|
168130
|
-
|
|
168131
|
-
|
|
168132
|
-
|
|
168102
|
+
async _getRelationshipsProperty() {
|
|
168103
|
+
// We need the data store to find the relationship feature layers
|
|
168104
|
+
if (!this.relationshipsProperties?.exposeRelationships || !this._profile?.supportFeatureSetFunctions) {
|
|
168105
|
+
return null;
|
|
168106
|
+
}
|
|
168107
|
+
const source = this._source;
|
|
168108
|
+
if (!isRelationshipsCapableLayer(source)) {
|
|
168109
|
+
return null;
|
|
168110
|
+
}
|
|
168111
|
+
const relationshipsGroup = new GroupOfVariables(this._profile, { code: "relationships" });
|
|
168112
|
+
const relationshipItems = await Promise.all(source.relationships.map(async (relationship) => {
|
|
168113
|
+
const relatedLayer = await getRelatedFeatureLayer(source, relationship);
|
|
168114
|
+
if (!isFeatureLayerInstance(relatedLayer)) {
|
|
168115
|
+
return null;
|
|
168116
|
+
}
|
|
168117
|
+
if (relationship.relatedTableId === this.relationshipsProperties?.sourceTableId) {
|
|
168118
|
+
// We don't want to show the reverse relationship
|
|
168119
|
+
return null;
|
|
168120
|
+
}
|
|
168121
|
+
const snippet = `FeatureSetByRelationshipName(${this.snippet}, "${relationship.name}")`;
|
|
168122
|
+
return new FeatureSetVariable({
|
|
168123
|
+
profile: this._profile,
|
|
168124
|
+
declaration: { definition: relatedLayer },
|
|
168125
|
+
label: relatedLayer.title,
|
|
168126
|
+
description: "",
|
|
168127
|
+
nonInteractive: true
|
|
168128
|
+
}, [new ValueVariable({ profile: this._profile, label: snippet, description: "", snippet })], { exposeRelationships: true, sourceTableId: source.layerId });
|
|
168129
|
+
}));
|
|
168130
|
+
relationshipsGroup.variables = relationshipItems.filter(D);
|
|
168131
|
+
if (!relationshipsGroup.variables.length) {
|
|
168132
|
+
return null;
|
|
168133
|
+
}
|
|
168134
|
+
return relationshipsGroup;
|
|
168133
168135
|
}
|
|
168134
|
-
return relationshipsGroup;
|
|
168135
|
-
}
|
|
168136
168136
|
}
|
|
168137
168137
|
class FeatureVariable extends SourceBasedVariable {
|
|
168138
|
-
|
|
168139
|
-
|
|
168140
|
-
|
|
168141
|
-
}
|
|
168142
|
-
get title() {
|
|
168143
|
-
if (isSupportedLayerInstance(this._source)) {
|
|
168144
|
-
return this._source.title;
|
|
168145
|
-
}
|
|
168146
|
-
return { code: "feature" };
|
|
168147
|
-
}
|
|
168148
|
-
async _loadSource() {
|
|
168149
|
-
if (this.loaded) {
|
|
168150
|
-
return this._source;
|
|
168138
|
+
constructor(props) {
|
|
168139
|
+
super(props, { exposeRelationships: true });
|
|
168140
|
+
this.type = "feature";
|
|
168151
168141
|
}
|
|
168152
|
-
|
|
168153
|
-
|
|
168154
|
-
|
|
168155
|
-
|
|
168156
|
-
|
|
168157
|
-
// The title group and snippet
|
|
168158
|
-
const title = isSupportedLayerInstance(this._source) ? this._source.title : "";
|
|
168159
|
-
this.variables.push(new GroupOfVariables(this._profile, title, [
|
|
168160
|
-
new ValueVariable({
|
|
168161
|
-
profile: this._profile,
|
|
168162
|
-
label: this.snippet,
|
|
168163
|
-
description: "",
|
|
168164
|
-
snippet: this.snippet
|
|
168165
|
-
})
|
|
168166
|
-
]));
|
|
168167
|
-
// The collection of feature attribute values
|
|
168168
|
-
const valuesGroup = new GroupOfVariables(this._profile, { code: "values" });
|
|
168169
|
-
this.variables.push(valuesGroup);
|
|
168170
|
-
// Add the geometry if it's a feature layer and not a table
|
|
168171
|
-
if (isTableCapableLayer(this._source) && !this._source.isTable) {
|
|
168172
|
-
const snippet = `Geometry(${this.snippet})`;
|
|
168173
|
-
const geometryProperty = new ValueVariable({
|
|
168174
|
-
profile: this._profile,
|
|
168175
|
-
declaration: { name: snippet },
|
|
168176
|
-
label: snippet,
|
|
168177
|
-
description: "Geometry",
|
|
168178
|
-
snippet,
|
|
168179
|
-
icon: "shapes",
|
|
168180
|
-
filterDescription: true
|
|
168181
|
-
});
|
|
168182
|
-
valuesGroup.variables.push(geometryProperty);
|
|
168183
|
-
}
|
|
168184
|
-
this._source.fields.sort(sortFields(this._source)).forEach((field) => {
|
|
168185
|
-
valuesGroup.variables.push(this._getFieldProperty(field));
|
|
168186
|
-
});
|
|
168187
|
-
// The relatonships
|
|
168188
|
-
const relationshipsGroup = await this._getRelationshipsProperty();
|
|
168189
|
-
if (relationshipsGroup) {
|
|
168190
|
-
this.variables.push(relationshipsGroup);
|
|
168191
|
-
}
|
|
168142
|
+
get title() {
|
|
168143
|
+
if (isSupportedLayerInstance(this._source)) {
|
|
168144
|
+
return this._source.title;
|
|
168145
|
+
}
|
|
168146
|
+
return { code: "feature" };
|
|
168192
168147
|
}
|
|
168193
|
-
|
|
168194
|
-
|
|
168195
|
-
|
|
168148
|
+
async _loadSource() {
|
|
168149
|
+
if (this.loaded) {
|
|
168150
|
+
return this._source;
|
|
168151
|
+
}
|
|
168152
|
+
try {
|
|
168153
|
+
this._source = await supportedSourceFromDefinition(this._definition);
|
|
168154
|
+
if (!this._source) {
|
|
168155
|
+
throw new Error("Invalid definition");
|
|
168156
|
+
}
|
|
168157
|
+
// The title group and snippet
|
|
168158
|
+
const title = isSupportedLayerInstance(this._source) ? this._source.title : "";
|
|
168159
|
+
this.variables.push(new GroupOfVariables(this._profile, title, [
|
|
168160
|
+
new ValueVariable({
|
|
168161
|
+
profile: this._profile,
|
|
168162
|
+
label: this.snippet,
|
|
168163
|
+
description: "",
|
|
168164
|
+
snippet: this.snippet
|
|
168165
|
+
})
|
|
168166
|
+
]));
|
|
168167
|
+
// The collection of feature attribute values
|
|
168168
|
+
const valuesGroup = new GroupOfVariables(this._profile, { code: "values" });
|
|
168169
|
+
this.variables.push(valuesGroup);
|
|
168170
|
+
// Add the geometry if it's a feature layer and not a table
|
|
168171
|
+
if (isTableCapableLayer(this._source) && !this._source.isTable) {
|
|
168172
|
+
const snippet = `Geometry(${this.snippet})`;
|
|
168173
|
+
const geometryProperty = new ValueVariable({
|
|
168174
|
+
profile: this._profile,
|
|
168175
|
+
declaration: { name: snippet },
|
|
168176
|
+
label: snippet,
|
|
168177
|
+
description: "Geometry",
|
|
168178
|
+
snippet,
|
|
168179
|
+
icon: "shapes",
|
|
168180
|
+
filterDescription: true
|
|
168181
|
+
});
|
|
168182
|
+
valuesGroup.variables.push(geometryProperty);
|
|
168183
|
+
}
|
|
168184
|
+
this._source.fields.sort(sortFields(this._source)).forEach((field) => {
|
|
168185
|
+
valuesGroup.variables.push(this._getFieldProperty(field));
|
|
168186
|
+
});
|
|
168187
|
+
// The relatonships
|
|
168188
|
+
const relationshipsGroup = await this._getRelationshipsProperty();
|
|
168189
|
+
if (relationshipsGroup) {
|
|
168190
|
+
this.variables.push(relationshipsGroup);
|
|
168191
|
+
}
|
|
168192
|
+
}
|
|
168193
|
+
catch (e) {
|
|
168194
|
+
console.error("Loading issue", e, this);
|
|
168195
|
+
this._source = null;
|
|
168196
|
+
}
|
|
168197
|
+
finally {
|
|
168198
|
+
this._loaded = true;
|
|
168199
|
+
}
|
|
168200
|
+
return this._source;
|
|
168196
168201
|
}
|
|
168197
|
-
|
|
168198
|
-
|
|
168202
|
+
toProfileVariableDefinition() {
|
|
168203
|
+
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168199
168204
|
}
|
|
168200
|
-
return this._source;
|
|
168201
|
-
}
|
|
168202
|
-
toProfileVariableDefinition() {
|
|
168203
|
-
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168204
|
-
}
|
|
168205
168205
|
}
|
|
168206
168206
|
class FeatureSetVariable extends SourceBasedVariable {
|
|
168207
|
-
|
|
168208
|
-
|
|
168209
|
-
|
|
168210
|
-
|
|
168211
|
-
|
|
168212
|
-
|
|
168213
|
-
|
|
168214
|
-
}
|
|
168215
|
-
get title() {
|
|
168216
|
-
if (isSupportedLayerInstance(this._source)) {
|
|
168217
|
-
return this._source.title;
|
|
168207
|
+
constructor(props, featureSetSnippets = [],
|
|
168208
|
+
// Relationships for feature set if only supported if the feature set is actually
|
|
168209
|
+
// representing a relationsip feature layer for a feature source.
|
|
168210
|
+
relationshipProps) {
|
|
168211
|
+
super(props, relationshipProps);
|
|
168212
|
+
this.featureSetSnippets = featureSetSnippets;
|
|
168213
|
+
this.type = "featureSet";
|
|
168218
168214
|
}
|
|
168219
|
-
|
|
168220
|
-
|
|
168221
|
-
|
|
168222
|
-
|
|
168223
|
-
|
|
168224
|
-
}
|
|
168225
|
-
try {
|
|
168226
|
-
this._source = await supportedSourceFromDefinition(this._definition);
|
|
168227
|
-
if (!this._source) {
|
|
168228
|
-
throw new Error("Invalid definition");
|
|
168229
|
-
}
|
|
168230
|
-
// The title group and snippet
|
|
168231
|
-
this.variables.push(new GroupOfVariables(this._profile, this.title, this.featureSetSnippets));
|
|
168232
|
-
// Add the fields
|
|
168233
|
-
const fieldsGroup = new GroupOfVariables(this._profile, { code: "fields" });
|
|
168234
|
-
this.variables.push(fieldsGroup);
|
|
168235
|
-
fieldsGroup.variables = this._source.fields
|
|
168236
|
-
.sort(sortFields(this._source))
|
|
168237
|
-
.map((field) => this._getFieldProperty(field));
|
|
168238
|
-
// Add the relationships if enabled
|
|
168239
|
-
const relationshipsGroup = await this._getRelationshipsProperty();
|
|
168240
|
-
if (relationshipsGroup) {
|
|
168241
|
-
this.variables.push(relationshipsGroup);
|
|
168242
|
-
}
|
|
168215
|
+
get title() {
|
|
168216
|
+
if (isSupportedLayerInstance(this._source)) {
|
|
168217
|
+
return this._source.title;
|
|
168218
|
+
}
|
|
168219
|
+
return { code: "featureset" };
|
|
168243
168220
|
}
|
|
168244
|
-
|
|
168245
|
-
|
|
168246
|
-
|
|
168221
|
+
async _loadSource() {
|
|
168222
|
+
if (this.loaded) {
|
|
168223
|
+
return this._source;
|
|
168224
|
+
}
|
|
168225
|
+
try {
|
|
168226
|
+
this._source = await supportedSourceFromDefinition(this._definition);
|
|
168227
|
+
if (!this._source) {
|
|
168228
|
+
throw new Error("Invalid definition");
|
|
168229
|
+
}
|
|
168230
|
+
// The title group and snippet
|
|
168231
|
+
this.variables.push(new GroupOfVariables(this._profile, this.title, this.featureSetSnippets));
|
|
168232
|
+
// Add the fields
|
|
168233
|
+
const fieldsGroup = new GroupOfVariables(this._profile, { code: "fields" });
|
|
168234
|
+
this.variables.push(fieldsGroup);
|
|
168235
|
+
fieldsGroup.variables = this._source.fields
|
|
168236
|
+
.sort(sortFields(this._source))
|
|
168237
|
+
.map((field) => this._getFieldProperty(field));
|
|
168238
|
+
// Add the relationships if enabled
|
|
168239
|
+
const relationshipsGroup = await this._getRelationshipsProperty();
|
|
168240
|
+
if (relationshipsGroup) {
|
|
168241
|
+
this.variables.push(relationshipsGroup);
|
|
168242
|
+
}
|
|
168243
|
+
}
|
|
168244
|
+
catch (e) {
|
|
168245
|
+
console.error("Loading issue", e, this);
|
|
168246
|
+
this._source = null;
|
|
168247
|
+
}
|
|
168248
|
+
finally {
|
|
168249
|
+
this._loaded = true;
|
|
168250
|
+
}
|
|
168251
|
+
return this._source;
|
|
168247
168252
|
}
|
|
168248
|
-
|
|
168249
|
-
|
|
168253
|
+
toProfileVariableDefinition() {
|
|
168254
|
+
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168250
168255
|
}
|
|
168251
|
-
return this._source;
|
|
168252
|
-
}
|
|
168253
|
-
toProfileVariableDefinition() {
|
|
168254
|
-
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168255
|
-
}
|
|
168256
168256
|
}
|
|
168257
168257
|
class FeatureSetCollectionVariable extends CollectionBasedVariable {
|
|
168258
|
-
|
|
168259
|
-
|
|
168260
|
-
|
|
168261
|
-
|
|
168262
|
-
|
|
168263
|
-
|
|
168264
|
-
|
|
168265
|
-
|
|
168266
|
-
|
|
168267
|
-
|
|
168268
|
-
|
|
168269
|
-
|
|
168270
|
-
|
|
168258
|
+
constructor(props) {
|
|
168259
|
+
super(props);
|
|
168260
|
+
this.type = "featureSetCollection";
|
|
168261
|
+
this._featureSetCollections = null;
|
|
168262
|
+
this._loaded = false;
|
|
168263
|
+
this._definition = props?.declaration?.definition;
|
|
168264
|
+
}
|
|
168265
|
+
get informationUrl() {
|
|
168266
|
+
if (!this.loaded || !this._featureSetCollections) {
|
|
168267
|
+
return null;
|
|
168268
|
+
}
|
|
168269
|
+
if (typeof this._featureSetCollections.source !== "string") {
|
|
168270
|
+
return portalItemPageUrl(this._featureSetCollections.source.portalItem);
|
|
168271
|
+
}
|
|
168272
|
+
// const firstLayer = this._featureSetCollection.layers[0] ?? this._featureSetCollection.tables[0];
|
|
168273
|
+
// if (!firstLayer) {
|
|
168274
|
+
return null;
|
|
168275
|
+
// }
|
|
168276
|
+
// return `${firstLayer.url}`;
|
|
168271
168277
|
}
|
|
168272
|
-
|
|
168273
|
-
|
|
168274
|
-
|
|
168275
|
-
|
|
168276
|
-
|
|
168277
|
-
|
|
168278
|
-
|
|
168279
|
-
|
|
168280
|
-
return "";
|
|
168278
|
+
get informationType() {
|
|
168279
|
+
if (!this.loaded || !this._featureSetCollections) {
|
|
168280
|
+
return "";
|
|
168281
|
+
}
|
|
168282
|
+
if (typeof this._featureSetCollections.source !== "string") {
|
|
168283
|
+
return this._profile?.intlStrings?.webmap ?? "webmap";
|
|
168284
|
+
}
|
|
168285
|
+
return this._profile?.intlStrings?.featureservice ?? "featureservice";
|
|
168281
168286
|
}
|
|
168282
|
-
|
|
168283
|
-
|
|
168287
|
+
async loadSource() {
|
|
168288
|
+
if (D(this._loadPromise) && G(this._loadPromise)) {
|
|
168289
|
+
return this._loadPromise;
|
|
168290
|
+
}
|
|
168291
|
+
this._loadPromise = this._loadSource();
|
|
168292
|
+
return this._loadPromise;
|
|
168284
168293
|
}
|
|
168285
|
-
|
|
168286
|
-
|
|
168287
|
-
|
|
168288
|
-
|
|
168289
|
-
|
|
168294
|
+
async _loadSource() {
|
|
168295
|
+
if (this.loaded) {
|
|
168296
|
+
return this._featureSetCollections;
|
|
168297
|
+
}
|
|
168298
|
+
try {
|
|
168299
|
+
this._featureSetCollections = await this._featureSetCollectionsFromDefinition();
|
|
168300
|
+
if (!this._featureSetCollections) {
|
|
168301
|
+
throw new Error("Invalid definition");
|
|
168302
|
+
}
|
|
168303
|
+
// Create the group for the header
|
|
168304
|
+
const groupLabel = typeof this._featureSetCollections.source === "string"
|
|
168305
|
+
? { code: this._featureSetCollections.source.endsWith("FeatureServer") ? "featureservice" : "mapservice" }
|
|
168306
|
+
: {
|
|
168307
|
+
code: "webmapformat",
|
|
168308
|
+
formatValues: {
|
|
168309
|
+
webMapTitle: this._featureSetCollections.source.portalItem?.title ?? "Untitled map"
|
|
168310
|
+
}
|
|
168311
|
+
};
|
|
168312
|
+
const headerGroup = new GroupOfVariables(this._profile, groupLabel, [
|
|
168313
|
+
new ValueVariable({
|
|
168314
|
+
profile: this._profile,
|
|
168315
|
+
label: this.snippet,
|
|
168316
|
+
description: "",
|
|
168317
|
+
snippet: this.snippet
|
|
168318
|
+
})
|
|
168319
|
+
]);
|
|
168320
|
+
// Creates the groups for the layer and tables
|
|
168321
|
+
const layersGroup = new GroupOfVariables(this._profile, { code: "layers" }, this._featureSetCollections.layers);
|
|
168322
|
+
const tablesGroup = new GroupOfVariables(this._profile, { code: "tables" }, this._featureSetCollections.tables);
|
|
168323
|
+
this.variables.push(headerGroup, layersGroup, tablesGroup);
|
|
168324
|
+
}
|
|
168325
|
+
catch (e) {
|
|
168326
|
+
console.error("Loading issue", e, this);
|
|
168327
|
+
this._featureSetCollections = null;
|
|
168328
|
+
}
|
|
168329
|
+
finally {
|
|
168330
|
+
this._loaded = true;
|
|
168331
|
+
}
|
|
168332
|
+
return this._featureSetCollections;
|
|
168290
168333
|
}
|
|
168291
|
-
|
|
168292
|
-
|
|
168293
|
-
|
|
168294
|
-
|
|
168295
|
-
|
|
168296
|
-
|
|
168334
|
+
async _featureSetCollectionsFromDefinition() {
|
|
168335
|
+
if (!this._definition) {
|
|
168336
|
+
return null;
|
|
168337
|
+
}
|
|
168338
|
+
if (isWebMapInstance(this._definition)) {
|
|
168339
|
+
return this._featureSetCollectionFromWebMap(this._definition);
|
|
168340
|
+
}
|
|
168341
|
+
if (isSupportedLayerInstance(this._definition)) {
|
|
168342
|
+
return this._featureSetCollectionFromUrl(this._definition.url);
|
|
168343
|
+
}
|
|
168344
|
+
if (isPortalItemDefinition(this._definition)) {
|
|
168345
|
+
// Preload the portal item so we can discover if are dealing with a Web Map
|
|
168346
|
+
// or Feature Service
|
|
168347
|
+
return this._featureSetCollectionFromPortalItem(this._definition.portalItem);
|
|
168348
|
+
}
|
|
168349
|
+
if (isUrlDefinition(this._definition)) {
|
|
168350
|
+
// Assume that the url is pointing to a feature server
|
|
168351
|
+
return this._featureSetCollectionFromUrl(this._definition.url);
|
|
168352
|
+
}
|
|
168353
|
+
return null;
|
|
168297
168354
|
}
|
|
168298
|
-
|
|
168299
|
-
|
|
168300
|
-
|
|
168301
|
-
|
|
168302
|
-
|
|
168303
|
-
|
|
168304
|
-
|
|
168305
|
-
|
|
168306
|
-
|
|
168307
|
-
code: "webmapformat",
|
|
168308
|
-
formatValues: {
|
|
168309
|
-
webMapTitle: this._featureSetCollections.source.portalItem?.title ?? "Untitled map"
|
|
168310
|
-
}
|
|
168355
|
+
async _featureSetCollectionFromWebMap(definition) {
|
|
168356
|
+
const webMap = isWebMapInstance(definition) ? definition : await newWebMap({ portalItem: definition });
|
|
168357
|
+
await webMap.loadAll();
|
|
168358
|
+
// Until jsapi fix a bug we have to load the table separately
|
|
168359
|
+
await Promise.all(webMap.tables.map(async (t) => t.load()));
|
|
168360
|
+
return {
|
|
168361
|
+
layers: this._convertWebMapLayersToVariables(webMap.layers),
|
|
168362
|
+
tables: this._convertWebMapLayersToVariables(webMap.tables, true),
|
|
168363
|
+
source: webMap
|
|
168311
168364
|
};
|
|
168312
|
-
const headerGroup = new GroupOfVariables(this._profile, groupLabel, [
|
|
168313
|
-
new ValueVariable({
|
|
168314
|
-
profile: this._profile,
|
|
168315
|
-
label: this.snippet,
|
|
168316
|
-
description: "",
|
|
168317
|
-
snippet: this.snippet
|
|
168318
|
-
})
|
|
168319
|
-
]);
|
|
168320
|
-
// Creates the groups for the layer and tables
|
|
168321
|
-
const layersGroup = new GroupOfVariables(this._profile, { code: "layers" }, this._featureSetCollections.layers);
|
|
168322
|
-
const tablesGroup = new GroupOfVariables(this._profile, { code: "tables" }, this._featureSetCollections.tables);
|
|
168323
|
-
this.variables.push(headerGroup, layersGroup, tablesGroup);
|
|
168324
|
-
}
|
|
168325
|
-
catch (e) {
|
|
168326
|
-
console.error("Loading issue", e, this);
|
|
168327
|
-
this._featureSetCollections = null;
|
|
168328
|
-
}
|
|
168329
|
-
finally {
|
|
168330
|
-
this._loaded = true;
|
|
168331
|
-
}
|
|
168332
|
-
return this._featureSetCollections;
|
|
168333
|
-
}
|
|
168334
|
-
async _featureSetCollectionsFromDefinition() {
|
|
168335
|
-
if (!this._definition) {
|
|
168336
|
-
return null;
|
|
168337
|
-
}
|
|
168338
|
-
if (isWebMapInstance(this._definition)) {
|
|
168339
|
-
return this._featureSetCollectionFromWebMap(this._definition);
|
|
168340
168365
|
}
|
|
168341
|
-
|
|
168342
|
-
|
|
168366
|
+
async _featureSetCollectionFromPortalItem(definition) {
|
|
168367
|
+
const portalItem = await newPortalItem(definition);
|
|
168368
|
+
await portalItem.load();
|
|
168369
|
+
switch (portalItem.type) {
|
|
168370
|
+
case "Web Map":
|
|
168371
|
+
return this._featureSetCollectionFromWebMap(portalItem);
|
|
168372
|
+
case "Feature Service":
|
|
168373
|
+
return this._featureSetCollectionFromUrl(portalItem.url);
|
|
168374
|
+
default:
|
|
168375
|
+
console.error("Unsupported portal item", definition);
|
|
168376
|
+
return null;
|
|
168377
|
+
}
|
|
168343
168378
|
}
|
|
168344
|
-
|
|
168345
|
-
|
|
168346
|
-
|
|
168347
|
-
|
|
168379
|
+
async _featureSetCollectionFromUrl(url) {
|
|
168380
|
+
url = url.replace(/\/featureserver\/[0-9]*/i, "/FeatureServer");
|
|
168381
|
+
url = url.replace(/\/mapserver\/[0-9]*/i, "/MapServer");
|
|
168382
|
+
url = url.split("?")[0];
|
|
168383
|
+
const metadata = await serviceMetaData(url);
|
|
168384
|
+
const layersPromise = Promise.all(metadata.layers.map(async (layerInfo) => {
|
|
168385
|
+
const fl = await newFeatureLayer({ url: `${url}/${layerInfo.id}` });
|
|
168386
|
+
await fl.load();
|
|
168387
|
+
return this._createFeatureSetVariable(fl);
|
|
168388
|
+
}));
|
|
168389
|
+
const tablesPromise = Promise.all(metadata.tables.map(async (layerInfo) => {
|
|
168390
|
+
const fl = await newFeatureLayer({ url: `${url}/${layerInfo.id}` });
|
|
168391
|
+
await fl.load();
|
|
168392
|
+
return this._createFeatureSetVariable(fl);
|
|
168393
|
+
}));
|
|
168394
|
+
const [layers, tables] = await Promise.all([layersPromise, tablesPromise]);
|
|
168395
|
+
return { layers, tables, source: url };
|
|
168396
|
+
}
|
|
168397
|
+
_convertWebMapLayersToVariables(layers, filteringTables = false) {
|
|
168398
|
+
const layerVariables = [];
|
|
168399
|
+
layers
|
|
168400
|
+
.toArray()
|
|
168401
|
+
.reverse()
|
|
168402
|
+
.forEach((layer) => {
|
|
168403
|
+
if (isFeatureLayerInstance(layer)) {
|
|
168404
|
+
layerVariables.push(this._createFeatureSetVariable(layer, true));
|
|
168405
|
+
return;
|
|
168406
|
+
}
|
|
168407
|
+
if (isGroupLayerInstance(layer)) {
|
|
168408
|
+
const groupLayerVariables = filteringTables
|
|
168409
|
+
? this._convertWebMapLayersToVariables(layer.allTables, true)
|
|
168410
|
+
: this._convertWebMapLayersToVariables(layer.allLayers);
|
|
168411
|
+
layerVariables.push(...groupLayerVariables);
|
|
168412
|
+
}
|
|
168413
|
+
});
|
|
168414
|
+
return layerVariables;
|
|
168348
168415
|
}
|
|
168349
|
-
|
|
168350
|
-
|
|
168351
|
-
|
|
168416
|
+
_createFeatureSetVariable(featureLayer, isFromWebMap = false) {
|
|
168417
|
+
return new FeatureSetVariable({
|
|
168418
|
+
profile: this._profile,
|
|
168419
|
+
declaration: { definition: featureLayer },
|
|
168420
|
+
label: featureLayer.title,
|
|
168421
|
+
description: "",
|
|
168422
|
+
nonInteractive: true
|
|
168423
|
+
}, this._makeFeatureSetSnippets(featureLayer, isFromWebMap));
|
|
168352
168424
|
}
|
|
168353
|
-
|
|
168354
|
-
|
|
168355
|
-
|
|
168356
|
-
|
|
168357
|
-
|
|
168358
|
-
|
|
168359
|
-
|
|
168360
|
-
|
|
168361
|
-
|
|
168362
|
-
|
|
168363
|
-
|
|
168364
|
-
|
|
168365
|
-
|
|
168366
|
-
|
|
168367
|
-
|
|
168368
|
-
|
|
168369
|
-
switch (portalItem.type) {
|
|
168370
|
-
case "Web Map":
|
|
168371
|
-
return this._featureSetCollectionFromWebMap(portalItem);
|
|
168372
|
-
case "Feature Service":
|
|
168373
|
-
return this._featureSetCollectionFromUrl(portalItem.url);
|
|
168374
|
-
default:
|
|
168375
|
-
console.error("Unsupported portal item", definition);
|
|
168376
|
-
return null;
|
|
168377
|
-
}
|
|
168378
|
-
}
|
|
168379
|
-
async _featureSetCollectionFromUrl(url) {
|
|
168380
|
-
url = url.replace(/\/featureserver\/[0-9]*/i, "/FeatureServer");
|
|
168381
|
-
url = url.replace(/\/mapserver\/[0-9]*/i, "/MapServer");
|
|
168382
|
-
url = url.split("?")[0];
|
|
168383
|
-
const metadata = await serviceMetaData(url);
|
|
168384
|
-
const layersPromise = Promise.all(metadata.layers.map(async (layerInfo) => {
|
|
168385
|
-
const fl = await newFeatureLayer({ url: `${url}/${layerInfo.id}` });
|
|
168386
|
-
await fl.load();
|
|
168387
|
-
return this._createFeatureSetVariable(fl);
|
|
168388
|
-
}));
|
|
168389
|
-
const tablesPromise = Promise.all(metadata.tables.map(async (layerInfo) => {
|
|
168390
|
-
const fl = await newFeatureLayer({ url: `${url}/${layerInfo.id}` });
|
|
168391
|
-
await fl.load();
|
|
168392
|
-
return this._createFeatureSetVariable(fl);
|
|
168393
|
-
}));
|
|
168394
|
-
const [layers, tables] = await Promise.all([layersPromise, tablesPromise]);
|
|
168395
|
-
return { layers, tables, source: url };
|
|
168396
|
-
}
|
|
168397
|
-
_convertWebMapLayersToVariables(layers, filteringTables = false) {
|
|
168398
|
-
const layerVariables = [];
|
|
168399
|
-
layers
|
|
168400
|
-
.toArray()
|
|
168401
|
-
.reverse()
|
|
168402
|
-
.forEach((layer) => {
|
|
168403
|
-
if (isFeatureLayerInstance(layer)) {
|
|
168404
|
-
layerVariables.push(this._createFeatureSetVariable(layer, true));
|
|
168405
|
-
return;
|
|
168406
|
-
}
|
|
168407
|
-
if (isGroupLayerInstance(layer)) {
|
|
168408
|
-
const groupLayerVariables = filteringTables
|
|
168409
|
-
? this._convertWebMapLayersToVariables(layer.allTables, true)
|
|
168410
|
-
: this._convertWebMapLayersToVariables(layer.allLayers);
|
|
168411
|
-
layerVariables.push(...groupLayerVariables);
|
|
168412
|
-
}
|
|
168413
|
-
});
|
|
168414
|
-
return layerVariables;
|
|
168415
|
-
}
|
|
168416
|
-
_createFeatureSetVariable(featureLayer, isFromWebMap = false) {
|
|
168417
|
-
return new FeatureSetVariable({
|
|
168418
|
-
profile: this._profile,
|
|
168419
|
-
declaration: { definition: featureLayer },
|
|
168420
|
-
label: featureLayer.title,
|
|
168421
|
-
description: "",
|
|
168422
|
-
nonInteractive: true
|
|
168423
|
-
}, this._makeFeatureSetSnippets(featureLayer, isFromWebMap));
|
|
168424
|
-
}
|
|
168425
|
-
_makeFeatureSetSnippets(featureLayer, isFromWebMap = false) {
|
|
168426
|
-
if (!this._profile?.supportFeatureSetFunctions) {
|
|
168427
|
-
return [];
|
|
168428
|
-
}
|
|
168429
|
-
if (isFromWebMap) {
|
|
168430
|
-
const snippetById = `FeatureSetById(${this.snippet}, "${featureLayer.id}")`;
|
|
168431
|
-
const snippetByName = `FeatureSetByName(${this.snippet}, "${featureLayer.title}")`;
|
|
168432
|
-
return [
|
|
168433
|
-
new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById }),
|
|
168434
|
-
new ValueVariable({ profile: this._profile, label: snippetByName, description: "", snippet: snippetByName })
|
|
168435
|
-
];
|
|
168425
|
+
_makeFeatureSetSnippets(featureLayer, isFromWebMap = false) {
|
|
168426
|
+
if (!this._profile?.supportFeatureSetFunctions) {
|
|
168427
|
+
return [];
|
|
168428
|
+
}
|
|
168429
|
+
if (isFromWebMap) {
|
|
168430
|
+
const snippetById = `FeatureSetById(${this.snippet}, "${featureLayer.id}")`;
|
|
168431
|
+
const snippetByName = `FeatureSetByName(${this.snippet}, "${featureLayer.title}")`;
|
|
168432
|
+
return [
|
|
168433
|
+
new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById }),
|
|
168434
|
+
new ValueVariable({ profile: this._profile, label: snippetByName, description: "", snippet: snippetByName })
|
|
168435
|
+
];
|
|
168436
|
+
}
|
|
168437
|
+
else {
|
|
168438
|
+
const snippetById = `FeatureSetById(${this.snippet}, "${featureLayer.layerId}")`;
|
|
168439
|
+
return [new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById })];
|
|
168440
|
+
}
|
|
168436
168441
|
}
|
|
168437
|
-
|
|
168438
|
-
|
|
168439
|
-
return [new ValueVariable({ profile: this._profile, label: snippetById, description: "", snippet: snippetById })];
|
|
168442
|
+
toProfileVariableDefinition() {
|
|
168443
|
+
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168440
168444
|
}
|
|
168441
|
-
}
|
|
168442
|
-
toProfileVariableDefinition() {
|
|
168443
|
-
return { type: this.type, name: "", ...this.declaration, definition: this._definition };
|
|
168444
|
-
}
|
|
168445
168445
|
}
|
|
168446
168446
|
/**
|
|
168447
168447
|
* The EditorProfile is an object that represents an Arcade Profile.
|
|
@@ -168452,64 +168452,64 @@ class FeatureSetCollectionVariable extends CollectionBasedVariable {
|
|
|
168452
168452
|
* They need to be loaded asynchronously to get the metadata necessary for validation and completion.
|
|
168453
168453
|
*/
|
|
168454
168454
|
class EditorProfile extends DictionaryVariable {
|
|
168455
|
-
|
|
168456
|
-
|
|
168457
|
-
|
|
168458
|
-
|
|
168459
|
-
|
|
168460
|
-
|
|
168461
|
-
|
|
168462
|
-
|
|
168463
|
-
|
|
168464
|
-
|
|
168465
|
-
|
|
168466
|
-
|
|
168467
|
-
|
|
168468
|
-
|
|
168469
|
-
|
|
168470
|
-
|
|
168471
|
-
|
|
168472
|
-
|
|
168473
|
-
|
|
168474
|
-
|
|
168475
|
-
|
|
168476
|
-
|
|
168477
|
-
|
|
168478
|
-
|
|
168479
|
-
|
|
168480
|
-
|
|
168481
|
-
|
|
168482
|
-
|
|
168483
|
-
|
|
168484
|
-
|
|
168485
|
-
|
|
168486
|
-
|
|
168487
|
-
|
|
168488
|
-
|
|
168489
|
-
|
|
168490
|
-
|
|
168491
|
-
|
|
168492
|
-
|
|
168493
|
-
|
|
168455
|
+
constructor(definition, intlStrings, locale = "en") {
|
|
168456
|
+
// Delay the load of the variable declarations so we have a `this`
|
|
168457
|
+
super({
|
|
168458
|
+
profile: null,
|
|
168459
|
+
declaration: { properties: [] }
|
|
168460
|
+
});
|
|
168461
|
+
this.definition = definition;
|
|
168462
|
+
this.intlStrings = intlStrings;
|
|
168463
|
+
this.locale = locale;
|
|
168464
|
+
this.variables = [];
|
|
168465
|
+
// We are the root
|
|
168466
|
+
this._profile = this;
|
|
168467
|
+
// Now that `this` is defined, we can load the variables
|
|
168468
|
+
this.loadPropertyDeclarations(definition?.variables);
|
|
168469
|
+
}
|
|
168470
|
+
/**
|
|
168471
|
+
* Returns true if the profile supports feature set functions for snippets.
|
|
168472
|
+
*/
|
|
168473
|
+
get supportFeatureSetFunctions() {
|
|
168474
|
+
return this.definition?.bundles?.includes("data-access") ?? false;
|
|
168475
|
+
}
|
|
168476
|
+
/**
|
|
168477
|
+
* Returns the language service profile. It is different than the editor profile as it is optimized for Monaco.
|
|
168478
|
+
*/
|
|
168479
|
+
async toLSProfile() {
|
|
168480
|
+
const { apiVersion, bundles, hiddenApiItems } = this.definition ?? {};
|
|
168481
|
+
const variables = await variablesToLSVariable(this.dictionaryVariables);
|
|
168482
|
+
return { apiVersion, bundles, variables, hiddenApiItems: hiddenApiItems?.map((s) => s.toLowerCase()) };
|
|
168483
|
+
}
|
|
168484
|
+
/**
|
|
168485
|
+
* Returns the EditorProfile as a json. The EditorProfile may have been updated. This function allows to
|
|
168486
|
+
* get the new json representing mutations.
|
|
168487
|
+
*/
|
|
168488
|
+
toEditorProfileDefinition() {
|
|
168489
|
+
return {
|
|
168490
|
+
...this.definition,
|
|
168491
|
+
variables: this.dictionaryVariables.map((variable) => variable.toProfileVariableDefinition())
|
|
168492
|
+
};
|
|
168493
|
+
}
|
|
168494
168494
|
}
|
|
168495
168495
|
//#endregion
|
|
168496
168496
|
|
|
168497
168497
|
function isFeatureDefinition(item) {
|
|
168498
|
-
|
|
168499
|
-
|
|
168500
|
-
|
|
168501
|
-
|
|
168502
|
-
|
|
168498
|
+
return (isSupportedLayerInstance(item) ||
|
|
168499
|
+
isFeatureSetInstance(item) ||
|
|
168500
|
+
isUrlDefinition(item) ||
|
|
168501
|
+
isFieldsDefinition(item) ||
|
|
168502
|
+
isFeatureLayerItemDefinition(item));
|
|
168503
168503
|
}
|
|
168504
168504
|
function isFeatureSetDefinition(item) {
|
|
168505
|
-
|
|
168506
|
-
|
|
168507
|
-
|
|
168508
|
-
|
|
168509
|
-
|
|
168505
|
+
return (isFeatureLayerInstance(item) ||
|
|
168506
|
+
isFeatureSetInstance(item) ||
|
|
168507
|
+
isUrlDefinition(item) ||
|
|
168508
|
+
isFieldsDefinition(item) ||
|
|
168509
|
+
isFeatureLayerItemDefinition(item));
|
|
168510
168510
|
}
|
|
168511
168511
|
function isFeatureSetCollectionDefinition(item) {
|
|
168512
|
-
|
|
168512
|
+
return isPortalItemDefinition(item) || isWebMapInstance(item) || isFeatureSetDefinition(item);
|
|
168513
168513
|
}
|
|
168514
168514
|
/**
|
|
168515
168515
|
* Get a PredefinedProfile for a locale. If not already loaded then fetch it.
|
|
@@ -168517,26 +168517,26 @@ function isFeatureSetCollectionDefinition(item) {
|
|
|
168517
168517
|
* the english version of the profile.
|
|
168518
168518
|
*/
|
|
168519
168519
|
async function getSdkPredefinedProfiles(locale = "en") {
|
|
168520
|
-
|
|
168521
|
-
|
|
168522
|
-
|
|
168523
|
-
}
|
|
168524
|
-
if (!x.has(locale)) {
|
|
168525
|
-
return getSdkPredefinedProfiles("en");
|
|
168526
|
-
}
|
|
168527
|
-
try {
|
|
168528
|
-
const response = await fetch(getAssetPath(`./assets/arcade-language/profiles/arcade-profiles.t9n.${locale}.json`));
|
|
168529
|
-
if (response.ok) {
|
|
168530
|
-
return cacheSdkPredefinedProfiles(locale, await response.json());
|
|
168520
|
+
const profiles = sdkPredefinedProfilesMap.get(locale);
|
|
168521
|
+
if (profiles) {
|
|
168522
|
+
return profiles;
|
|
168531
168523
|
}
|
|
168532
|
-
if (locale
|
|
168533
|
-
|
|
168524
|
+
if (!x.has(locale)) {
|
|
168525
|
+
return getSdkPredefinedProfiles("en");
|
|
168526
|
+
}
|
|
168527
|
+
try {
|
|
168528
|
+
const response = await fetch(getAssetPath(`./assets/arcade-language/profiles/arcade-profiles.t9n.${locale}.json`));
|
|
168529
|
+
if (response.ok) {
|
|
168530
|
+
return cacheSdkPredefinedProfiles(locale, await response.json());
|
|
168531
|
+
}
|
|
168532
|
+
if (locale === "en") {
|
|
168533
|
+
return null;
|
|
168534
|
+
}
|
|
168535
|
+
return getSdkPredefinedProfiles("en");
|
|
168536
|
+
}
|
|
168537
|
+
catch (e) {
|
|
168538
|
+
return null;
|
|
168534
168539
|
}
|
|
168535
|
-
return getSdkPredefinedProfiles("en");
|
|
168536
|
-
}
|
|
168537
|
-
catch (e) {
|
|
168538
|
-
return null;
|
|
168539
|
-
}
|
|
168540
168540
|
}
|
|
168541
168541
|
const sdkPredefinedProfilesMap = new Map();
|
|
168542
168542
|
/**
|
|
@@ -168544,237 +168544,237 @@ const sdkPredefinedProfilesMap = new Map();
|
|
|
168544
168544
|
* Map of profiles per locale.
|
|
168545
168545
|
*/
|
|
168546
168546
|
function cacheSdkPredefinedProfiles(locale, profiles) {
|
|
168547
|
-
|
|
168548
|
-
|
|
168549
|
-
|
|
168550
|
-
|
|
168551
|
-
|
|
168552
|
-
|
|
168547
|
+
const map = new Map();
|
|
168548
|
+
profiles.forEach((profile) => {
|
|
168549
|
+
map.set(profile.id, profile);
|
|
168550
|
+
});
|
|
168551
|
+
sdkPredefinedProfilesMap.set(locale, map);
|
|
168552
|
+
return map;
|
|
168553
168553
|
}
|
|
168554
168554
|
async function getSdkPredefinedProfile(id, locale = "en") {
|
|
168555
|
-
|
|
168556
|
-
|
|
168555
|
+
const profiles = await getSdkPredefinedProfiles(locale);
|
|
168556
|
+
return profiles?.get(id) ?? null;
|
|
168557
168557
|
}
|
|
168558
168558
|
function isExtendedPredefinedProfileDefinition(predefinedProfileDefinition) {
|
|
168559
|
-
|
|
168559
|
+
return Array.isArray(predefinedProfileDefinition?.additionalVariables);
|
|
168560
168560
|
}
|
|
168561
168561
|
function convertApiVariables(variables) {
|
|
168562
|
-
|
|
168563
|
-
|
|
168564
|
-
|
|
168565
|
-
|
|
168562
|
+
if (!variables) {
|
|
168563
|
+
return [];
|
|
168564
|
+
}
|
|
168565
|
+
return variables.map(convertApiVariable);
|
|
168566
168566
|
}
|
|
168567
168567
|
function convertApiVariable(variable) {
|
|
168568
|
-
|
|
168569
|
-
|
|
168570
|
-
|
|
168571
|
-
|
|
168572
|
-
|
|
168573
|
-
|
|
168574
|
-
|
|
168575
|
-
|
|
168576
|
-
|
|
168577
|
-
|
|
168578
|
-
|
|
168579
|
-
|
|
168580
|
-
|
|
168568
|
+
switch (variable.type) {
|
|
168569
|
+
case "dictionary":
|
|
168570
|
+
return {
|
|
168571
|
+
...variable,
|
|
168572
|
+
type: variable.type,
|
|
168573
|
+
properties: convertApiVariables(variable.properties)
|
|
168574
|
+
};
|
|
168575
|
+
case "array": {
|
|
168576
|
+
return {
|
|
168577
|
+
...variable,
|
|
168578
|
+
type: variable.type,
|
|
168579
|
+
elementType: { type: "number", name: "number" }
|
|
168580
|
+
};
|
|
168581
|
+
}
|
|
168582
|
+
default:
|
|
168583
|
+
return { ...variable, type: variable.type };
|
|
168581
168584
|
}
|
|
168582
|
-
default:
|
|
168583
|
-
return { ...variable, type: variable.type };
|
|
168584
|
-
}
|
|
168585
168585
|
}
|
|
168586
168586
|
async function convertToEditorProfileDefinition(predefinedProfile, locale = "en") {
|
|
168587
|
-
|
|
168588
|
-
|
|
168589
|
-
}
|
|
168590
|
-
const sdkPredefinedProfile = await getSdkPredefinedProfile(predefinedProfile.id, locale);
|
|
168591
|
-
if (!sdkPredefinedProfile) {
|
|
168592
|
-
return undefined;
|
|
168593
|
-
}
|
|
168594
|
-
const editorProfile = {
|
|
168595
|
-
bundles: [...sdkPredefinedProfile.bundles],
|
|
168596
|
-
variables: [],
|
|
168597
|
-
hiddenApiItems: predefinedProfile.hiddenApiItems?.map((s) => s.toLowerCase())
|
|
168598
|
-
};
|
|
168599
|
-
// Merge the SDK variables' definitions/properties with the predefined profile definitions.
|
|
168600
|
-
sdkPredefinedProfile.variables.forEach((sdkVariable) => {
|
|
168601
|
-
// Don't include disabled variables
|
|
168602
|
-
if (predefinedProfile.disabledVariables?.includes(sdkVariable.name)) {
|
|
168603
|
-
return;
|
|
168587
|
+
if (!isPredefinedProfile(predefinedProfile)) {
|
|
168588
|
+
return undefined;
|
|
168604
168589
|
}
|
|
168605
|
-
|
|
168606
|
-
|
|
168607
|
-
|
|
168608
|
-
// despite the type checking from the switch statement.
|
|
168609
|
-
switch (sdkVariable.type) {
|
|
168610
|
-
case "dictionary":
|
|
168611
|
-
// For dictionary, we support properties overrride
|
|
168612
|
-
return editorProfile.variables.push(convertApiVariable({
|
|
168613
|
-
...sdkVariable,
|
|
168614
|
-
type: sdkVariable.type,
|
|
168615
|
-
properties: Array.isArray(definition) ? [...definition] : sdkVariable.properties
|
|
168616
|
-
}));
|
|
168617
|
-
case "feature":
|
|
168618
|
-
if (isFeatureDefinition(definition)) {
|
|
168619
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168620
|
-
}
|
|
168621
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168622
|
-
case "featureSet":
|
|
168623
|
-
if (isFeatureSetDefinition(definition)) {
|
|
168624
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168625
|
-
}
|
|
168626
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168627
|
-
case "featureSetCollection":
|
|
168628
|
-
if (isFeatureSetCollectionDefinition(definition)) {
|
|
168629
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168630
|
-
}
|
|
168631
|
-
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168632
|
-
default:
|
|
168633
|
-
return editorProfile.variables.push(convertApiVariable(sdkVariable));
|
|
168590
|
+
const sdkPredefinedProfile = await getSdkPredefinedProfile(predefinedProfile.id, locale);
|
|
168591
|
+
if (!sdkPredefinedProfile) {
|
|
168592
|
+
return undefined;
|
|
168634
168593
|
}
|
|
168635
|
-
|
|
168636
|
-
|
|
168637
|
-
|
|
168638
|
-
|
|
168639
|
-
|
|
168594
|
+
const editorProfile = {
|
|
168595
|
+
bundles: [...sdkPredefinedProfile.bundles],
|
|
168596
|
+
variables: [],
|
|
168597
|
+
hiddenApiItems: predefinedProfile.hiddenApiItems?.map((s) => s.toLowerCase())
|
|
168598
|
+
};
|
|
168599
|
+
// Merge the SDK variables' definitions/properties with the predefined profile definitions.
|
|
168600
|
+
sdkPredefinedProfile.variables.forEach((sdkVariable) => {
|
|
168601
|
+
// Don't include disabled variables
|
|
168602
|
+
if (predefinedProfile.disabledVariables?.includes(sdkVariable.name)) {
|
|
168603
|
+
return;
|
|
168604
|
+
}
|
|
168605
|
+
// Try to get a definition from the predefined profile.
|
|
168606
|
+
const definition = predefinedProfile.definitions[sdkVariable.name];
|
|
168607
|
+
// Note: Something is weird with TS. The sdkVariables are being casted to the wrong type
|
|
168608
|
+
// despite the type checking from the switch statement.
|
|
168609
|
+
switch (sdkVariable.type) {
|
|
168610
|
+
case "dictionary":
|
|
168611
|
+
// For dictionary, we support properties overrride
|
|
168612
|
+
return editorProfile.variables.push(convertApiVariable({
|
|
168613
|
+
...sdkVariable,
|
|
168614
|
+
type: sdkVariable.type,
|
|
168615
|
+
properties: Array.isArray(definition) ? [...definition] : sdkVariable.properties
|
|
168616
|
+
}));
|
|
168617
|
+
case "feature":
|
|
168618
|
+
if (isFeatureDefinition(definition)) {
|
|
168619
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168620
|
+
}
|
|
168621
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168622
|
+
case "featureSet":
|
|
168623
|
+
if (isFeatureSetDefinition(definition)) {
|
|
168624
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168625
|
+
}
|
|
168626
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168627
|
+
case "featureSetCollection":
|
|
168628
|
+
if (isFeatureSetCollectionDefinition(definition)) {
|
|
168629
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
168630
|
+
}
|
|
168631
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type });
|
|
168632
|
+
default:
|
|
168633
|
+
return editorProfile.variables.push(convertApiVariable(sdkVariable));
|
|
168634
|
+
}
|
|
168635
|
+
});
|
|
168636
|
+
if (isExtendedPredefinedProfileDefinition(predefinedProfile)) {
|
|
168637
|
+
editorProfile.variables.push(...(predefinedProfile.additionalVariables ?? []));
|
|
168638
|
+
}
|
|
168639
|
+
return editorProfile;
|
|
168640
168640
|
}
|
|
168641
168641
|
|
|
168642
168642
|
const arcadeLanguageId = "arcade";
|
|
168643
168643
|
const defaultContext = {
|
|
168644
|
-
|
|
168644
|
+
locale: "en"
|
|
168645
168645
|
};
|
|
168646
168646
|
class ArcadeLanguageServiceDefaults {
|
|
168647
|
-
|
|
168648
|
-
|
|
168649
|
-
|
|
168650
|
-
|
|
168651
|
-
|
|
168652
|
-
|
|
168653
|
-
|
|
168654
|
-
|
|
168655
|
-
}
|
|
168656
|
-
get onDidChange() {
|
|
168657
|
-
return this._onDidChange.event;
|
|
168658
|
-
}
|
|
168659
|
-
get onModelContextDidChange() {
|
|
168660
|
-
return this._onModelContextDidChange.event;
|
|
168661
|
-
}
|
|
168662
|
-
get languageId() {
|
|
168663
|
-
return this._languageId;
|
|
168664
|
-
}
|
|
168665
|
-
get languageOptions() {
|
|
168666
|
-
return this._languageOptions;
|
|
168667
|
-
}
|
|
168668
|
-
_fireModelContextDidChange(key) {
|
|
168669
|
-
if (this._onDidModelContextChangeTimeout !== -1) {
|
|
168670
|
-
return;
|
|
168647
|
+
constructor() {
|
|
168648
|
+
this._languageId = arcadeLanguageId;
|
|
168649
|
+
this._languageOptions = {};
|
|
168650
|
+
this._onDidChange = new Emitter();
|
|
168651
|
+
this._profileMap = new Map();
|
|
168652
|
+
this._apiContextMap = new Map();
|
|
168653
|
+
this._onModelContextDidChange = new Emitter();
|
|
168654
|
+
this._onDidModelContextChangeTimeout = -1;
|
|
168671
168655
|
}
|
|
168672
|
-
|
|
168673
|
-
|
|
168674
|
-
this._onModelContextDidChange.fire(key);
|
|
168675
|
-
}, 0);
|
|
168676
|
-
}
|
|
168677
|
-
_getApiKey(modelId) {
|
|
168678
|
-
if (!Uri.isUri(modelId)) {
|
|
168679
|
-
modelId = Uri.parse(modelId);
|
|
168656
|
+
get onDidChange() {
|
|
168657
|
+
return this._onDidChange.event;
|
|
168680
168658
|
}
|
|
168681
|
-
|
|
168682
|
-
|
|
168683
|
-
/**
|
|
168684
|
-
* Create an EditorProfile for the given model id using the given definition and locale.
|
|
168685
|
-
* The EditorProfile is used by the the Arcade Language service as well by the cosing components.
|
|
168686
|
-
* The definition can be a pre-defined profile or an editor profile definition.
|
|
168687
|
-
* If the locale is not provided then the 'en' locale is used.
|
|
168688
|
-
* @param modelId The model id for which to create the context.
|
|
168689
|
-
* @param definition The definition to use for the model context.
|
|
168690
|
-
* @param locale The locale to use for the model context.
|
|
168691
|
-
* @returns The EditorProfile for the model.
|
|
168692
|
-
*/
|
|
168693
|
-
async setProfileForModel(modelId, definition, apiContext = { locale: "en" }) {
|
|
168694
|
-
// Convert pre-defined profile to a runtime profile
|
|
168695
|
-
if (isPredefinedProfile(definition)) {
|
|
168696
|
-
definition = await convertToEditorProfileDefinition(definition, apiContext.locale);
|
|
168697
|
-
}
|
|
168698
|
-
const intlStrings = await N(apiContext.locale, getAssetPath("./assets/arcade-language/t9n"), "profile.t9n.");
|
|
168699
|
-
if (!intlStrings) {
|
|
168700
|
-
throw new Error(`Failed to load the language bundle for ${apiContext.locale}`);
|
|
168701
|
-
}
|
|
168702
|
-
this.disposeEditorProfileForModel(modelId);
|
|
168703
|
-
const key = this._getApiKey(modelId);
|
|
168704
|
-
const editorProfile = new EditorProfile(definition, intlStrings);
|
|
168705
|
-
this._profileMap.set(key, editorProfile);
|
|
168706
|
-
const apiProfile = await editorProfile.toLSProfile();
|
|
168707
|
-
this.updateApiContextForModel(modelId, {
|
|
168708
|
-
locale: apiContext.locale,
|
|
168709
|
-
profile: apiProfile,
|
|
168710
|
-
snippets: apiContext.snippets
|
|
168711
|
-
});
|
|
168712
|
-
}
|
|
168713
|
-
/**
|
|
168714
|
-
* Dispose the editor profile for the given model id.
|
|
168715
|
-
* It is the responsibility of the caller that created the editor profile to dispose it.
|
|
168716
|
-
* @param modelId The model id for which to dispose the editor profile.
|
|
168717
|
-
*/
|
|
168718
|
-
disposeEditorProfileForModel(modelId) {
|
|
168719
|
-
const key = this._getApiKey(modelId);
|
|
168720
|
-
this._profileMap.delete(key);
|
|
168721
|
-
}
|
|
168722
|
-
/**
|
|
168723
|
-
* Dispose the api context for the given model id.
|
|
168724
|
-
* @param modelId The model id for which to dispose the api context.
|
|
168725
|
-
*/
|
|
168726
|
-
disposeApiContextForModel(modelId) {
|
|
168727
|
-
const key = this._getApiKey(modelId);
|
|
168728
|
-
if (this._apiContextMap.delete(key)) {
|
|
168729
|
-
this._fireModelContextDidChange(key);
|
|
168659
|
+
get onModelContextDidChange() {
|
|
168660
|
+
return this._onModelContextDidChange.event;
|
|
168730
168661
|
}
|
|
168731
|
-
|
|
168732
|
-
|
|
168733
|
-
|
|
168734
|
-
|
|
168735
|
-
|
|
168736
|
-
|
|
168737
|
-
|
|
168738
|
-
|
|
168739
|
-
|
|
168740
|
-
|
|
168741
|
-
|
|
168742
|
-
|
|
168743
|
-
|
|
168744
|
-
|
|
168745
|
-
|
|
168746
|
-
|
|
168747
|
-
|
|
168748
|
-
|
|
168749
|
-
|
|
168750
|
-
|
|
168751
|
-
|
|
168752
|
-
|
|
168753
|
-
|
|
168754
|
-
|
|
168755
|
-
|
|
168756
|
-
|
|
168757
|
-
|
|
168758
|
-
|
|
168759
|
-
|
|
168760
|
-
|
|
168761
|
-
|
|
168762
|
-
|
|
168763
|
-
|
|
168764
|
-
|
|
168765
|
-
|
|
168766
|
-
|
|
168767
|
-
|
|
168768
|
-
|
|
168769
|
-
|
|
168662
|
+
get languageId() {
|
|
168663
|
+
return this._languageId;
|
|
168664
|
+
}
|
|
168665
|
+
get languageOptions() {
|
|
168666
|
+
return this._languageOptions;
|
|
168667
|
+
}
|
|
168668
|
+
_fireModelContextDidChange(key) {
|
|
168669
|
+
if (this._onDidModelContextChangeTimeout !== -1) {
|
|
168670
|
+
return;
|
|
168671
|
+
}
|
|
168672
|
+
this._onDidModelContextChangeTimeout = window.setTimeout(() => {
|
|
168673
|
+
this._onDidModelContextChangeTimeout = -1;
|
|
168674
|
+
this._onModelContextDidChange.fire(key);
|
|
168675
|
+
}, 0);
|
|
168676
|
+
}
|
|
168677
|
+
_getApiKey(modelId) {
|
|
168678
|
+
if (!Uri.isUri(modelId)) {
|
|
168679
|
+
modelId = Uri.parse(modelId);
|
|
168680
|
+
}
|
|
168681
|
+
return modelId.toString();
|
|
168682
|
+
}
|
|
168683
|
+
/**
|
|
168684
|
+
* Create an EditorProfile for the given model id using the given definition and locale.
|
|
168685
|
+
* The EditorProfile is used by the the Arcade Language service as well by the cosing components.
|
|
168686
|
+
* The definition can be a pre-defined profile or an editor profile definition.
|
|
168687
|
+
* If the locale is not provided then the 'en' locale is used.
|
|
168688
|
+
* @param modelId The model id for which to create the context.
|
|
168689
|
+
* @param definition The definition to use for the model context.
|
|
168690
|
+
* @param locale The locale to use for the model context.
|
|
168691
|
+
* @returns The EditorProfile for the model.
|
|
168692
|
+
*/
|
|
168693
|
+
async setProfileForModel(modelId, definition, apiContext = { locale: "en" }) {
|
|
168694
|
+
// Convert pre-defined profile to a runtime profile
|
|
168695
|
+
if (isPredefinedProfile(definition)) {
|
|
168696
|
+
definition = await convertToEditorProfileDefinition(definition, apiContext.locale);
|
|
168697
|
+
}
|
|
168698
|
+
const intlStrings = await N(apiContext.locale, getAssetPath("./assets/arcade-language/t9n"), "profile.t9n.");
|
|
168699
|
+
if (!intlStrings) {
|
|
168700
|
+
throw new Error(`Failed to load the language bundle for ${apiContext.locale}`);
|
|
168701
|
+
}
|
|
168702
|
+
this.disposeEditorProfileForModel(modelId);
|
|
168703
|
+
const key = this._getApiKey(modelId);
|
|
168704
|
+
const editorProfile = new EditorProfile(definition, intlStrings);
|
|
168705
|
+
this._profileMap.set(key, editorProfile);
|
|
168706
|
+
const apiProfile = await editorProfile.toLSProfile();
|
|
168707
|
+
this.updateApiContextForModel(modelId, {
|
|
168708
|
+
locale: apiContext.locale,
|
|
168709
|
+
profile: apiProfile,
|
|
168710
|
+
snippets: apiContext.snippets
|
|
168711
|
+
});
|
|
168712
|
+
}
|
|
168713
|
+
/**
|
|
168714
|
+
* Dispose the editor profile for the given model id.
|
|
168715
|
+
* It is the responsibility of the caller that created the editor profile to dispose it.
|
|
168716
|
+
* @param modelId The model id for which to dispose the editor profile.
|
|
168717
|
+
*/
|
|
168718
|
+
disposeEditorProfileForModel(modelId) {
|
|
168719
|
+
const key = this._getApiKey(modelId);
|
|
168720
|
+
this._profileMap.delete(key);
|
|
168721
|
+
}
|
|
168722
|
+
/**
|
|
168723
|
+
* Dispose the api context for the given model id.
|
|
168724
|
+
* @param modelId The model id for which to dispose the api context.
|
|
168725
|
+
*/
|
|
168726
|
+
disposeApiContextForModel(modelId) {
|
|
168727
|
+
const key = this._getApiKey(modelId);
|
|
168728
|
+
if (this._apiContextMap.delete(key)) {
|
|
168729
|
+
this._fireModelContextDidChange(key);
|
|
168730
|
+
}
|
|
168731
|
+
}
|
|
168732
|
+
/**
|
|
168733
|
+
* Returns the editor profile for the given model id.
|
|
168734
|
+
* @param modelId The model id for which to get the editor profile.
|
|
168735
|
+
* @returns The editor profile for the model.
|
|
168736
|
+
*/
|
|
168737
|
+
getEditorProfileForModel(modelId) {
|
|
168738
|
+
return this._profileMap.get(this._getApiKey(modelId));
|
|
168739
|
+
}
|
|
168740
|
+
/**
|
|
168741
|
+
* Returns the API context for the given model id.
|
|
168742
|
+
* Returns the default context if the model has no context.
|
|
168743
|
+
* @param modelId The model id for which to get the API context.
|
|
168744
|
+
* @returns The API context for the model.
|
|
168745
|
+
*/
|
|
168746
|
+
getApiContextForModel(contextId) {
|
|
168747
|
+
return this._apiContextMap.get(this._getApiKey(contextId)) ?? defaultContext;
|
|
168748
|
+
}
|
|
168749
|
+
/**
|
|
168750
|
+
* Set or update api context for the given model id.
|
|
168751
|
+
* @param modelId The model id for which to set the context.
|
|
168752
|
+
* @param apiContext The api context to set.
|
|
168753
|
+
*/
|
|
168754
|
+
updateApiContextForModel(modelId, apiContext) {
|
|
168755
|
+
const key = this._getApiKey(modelId);
|
|
168756
|
+
const currentApiContext = this._apiContextMap.get(key) ?? {};
|
|
168757
|
+
this._apiContextMap.set(key, { ...currentApiContext, ...apiContext });
|
|
168758
|
+
this._fireModelContextDidChange(key);
|
|
168759
|
+
}
|
|
168760
|
+
/**
|
|
168761
|
+
* Set or update the Arcade language service options.
|
|
168762
|
+
* @param languageOptions The language options to set.
|
|
168763
|
+
*/
|
|
168764
|
+
setLanguageOptions(languageOptions = {}) {
|
|
168765
|
+
// Check if options have actually changed.
|
|
168766
|
+
// Avoid restarting the worker when no updates.
|
|
168767
|
+
// Today we only have the 'assetsPath' as a property
|
|
168768
|
+
if (this._languageOptions.assetsPath === languageOptions.assetsPath) {
|
|
168769
|
+
return;
|
|
168770
|
+
}
|
|
168771
|
+
this._languageOptions = { ...this._languageOptions, ...languageOptions };
|
|
168772
|
+
this._onDidChange.fire(this);
|
|
168770
168773
|
}
|
|
168771
|
-
this._languageOptions = { ...this._languageOptions, ...languageOptions };
|
|
168772
|
-
this._onDidChange.fire(this);
|
|
168773
|
-
}
|
|
168774
168774
|
}
|
|
168775
168775
|
const arcadeDefaults = new ArcadeLanguageServiceDefaults();
|
|
168776
168776
|
const arcade = {
|
|
168777
|
-
|
|
168777
|
+
setProfileForModel: arcadeDefaults.setProfileForModel.bind(arcadeDefaults)
|
|
168778
168778
|
};
|
|
168779
168779
|
|
|
168780
168780
|
export { B, Emitter as E, F, H, IStandaloneThemeService as I, KeyCode as K, MarkerSeverity as M, O, P, Range as R, StandaloneServices as S, T, Uri as U, V, X, arcade as a, commonjsGlobal as b, createCommonjsModule as c, arcadeDefaults as d, editor as e, U as f, generateTokensCSSForColorMap as g, filterCollection as h, importRequest as i, importArcade as j, j as k, languages as l, KeyMod as m, monaco_editor_core_star as n, main as o, p, q, supportedFields as s, typescriptDefaults as t, z };
|