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