@arcgis/coding-components 4.31.0-next.2 → 4.31.0-next.21
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/README.md +22 -3
- package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ar.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bg.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bs.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ca.json +6 -6
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.cs.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.da.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.de.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.el.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.es.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.et.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fi.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.he.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.id.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.it.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ko.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nb.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-BR.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-PT.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ru.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sk.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sl.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sv.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.th.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.tr.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.uk.json +5 -5
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.vi.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-CN.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-HK.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-TW.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.ca.json +2 -2
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.de.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.he.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.ca.json +1 -1
- package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.it.json +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/sql-expr.worker.js +33 -0
- package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
- package/dist/arcgis-coding-components/assets/language-api-panel/t9n/language-api-panel.t9n.ca.json +1 -1
- package/dist/arcgis-coding-components/assets/sql-expression-editor/api/sql-expression-api.t9n.en.json +735 -0
- package/dist/arcgis-coding-components/index.esm.js +2 -2
- package/dist/arcgis-coding-components/{p-7984ea8e.js → p-1b799777.js} +2 -2
- package/dist/arcgis-coding-components/p-4d5cf512.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-60c2a820.js → p-56266a64.js} +2 -2
- package/dist/arcgis-coding-components/{p-e8211ffe.js → p-57b8bcd7.js} +1 -1
- package/dist/arcgis-coding-components/{p-9eced6fc.js → p-5b67b62b.js} +2 -2
- package/dist/arcgis-coding-components/{p-93a97573.js → p-64137fec.js} +3 -3
- package/dist/arcgis-coding-components/{p-e7ee4d64.js → p-6621a80f.js} +3 -3
- package/dist/arcgis-coding-components/p-77dd5521.js +6 -0
- package/dist/arcgis-coding-components/p-8eb7e694.js +6 -0
- package/dist/arcgis-coding-components/p-a2341e0c.js +6 -0
- package/dist/arcgis-coding-components/{p-bb7e832e.js → p-b715834b.js} +3 -3
- package/dist/arcgis-coding-components/p-cbee273f.js +6 -0
- package/dist/arcgis-coding-components/{p-5ef7cce5.js → p-cdc52d2f.js} +1 -1
- package/dist/arcgis-coding-components/{p-36fedc23.js → p-d7d1f130.js} +12 -12
- package/dist/arcgis-coding-components/p-e1f9b463.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-62ee6251.js → p-e5a924a1.js} +1 -1
- package/dist/arcgis-coding-components/p-f2d64a9d.js +6 -0
- package/dist/arcgis-coding-components/{p-03ea6cd7.js → p-ff62d134.js} +3 -3
- package/dist/arcgis-coding-components/p-ffce0588.entry.js +6 -0
- package/dist/cjs/{app-globals-aee5f4b5.js → app-globals-a9ef3ca8.js} +1 -1
- package/dist/cjs/arcade-defaults-f5241680.js +349 -0
- package/dist/cjs/arcade-language-features-0b9f3947.js +274 -0
- package/dist/cjs/arcade-mode-cc08d9cd.js +335 -0
- package/dist/cjs/arcgis-arcade-editor_6.cjs.entry.js +181 -1501
- package/dist/cjs/arcgis-coding-components.cjs.js +4 -4
- package/dist/cjs/arcgis-sql-expression-editor.cjs.entry.js +81 -0
- package/dist/cjs/arcgis-sql-expression-fields.cjs.entry.js +80 -0
- package/dist/cjs/{css-7cc05f76.js → css-bb6a49ec.js} +1 -1
- package/dist/cjs/{cssMode-2b0daeae.js → cssMode-e7fac7d7.js} +3 -4
- package/dist/cjs/{html-f56911e1.js → html-7ff4071d.js} +3 -4
- package/dist/cjs/{htmlMode-43eed674.js → htmlMode-c89193ec.js} +3 -4
- package/dist/cjs/{index-b34238a6.js → index-4b7880ab.js} +9 -1
- package/dist/cjs/index.cjs.js +4 -3
- package/dist/cjs/{javascript-5115cb76.js → javascript-864c0220.js} +3 -4
- package/dist/cjs/{jsonMode-550dda36.js → jsonMode-ac4a7be7.js} +3 -4
- package/dist/cjs/{arcade-defaults-a8d8f8e2.js → language-defaults-base-57b37f9f.js} +842 -1183
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/sql-expr-defaults-245b036d.js +1347 -0
- package/dist/cjs/sql-expr-mode-304f5ce2.js +20844 -0
- package/dist/cjs/{tsMode-336306a9.js → tsMode-d30d4ab1.js} +4 -5
- package/dist/cjs/{typescript-b395242f.js → typescript-6c87ddb3.js} +3 -4
- package/dist/components/arcade-defaults.js +54 -1369
- package/dist/components/arcade-language-features.js +271 -0
- package/dist/components/arcade-mode.js +4 -264
- package/dist/components/arcade-results.js +7 -5
- package/dist/components/arcade-suggestions.js +7 -5
- package/dist/components/arcade-variables.js +8 -6
- package/dist/components/arcgis-arcade-editor.js +37 -35
- package/dist/components/arcgis-arcade-results.js +1 -1
- package/dist/components/arcgis-arcade-suggestions.js +1 -1
- package/dist/components/arcgis-arcade-variables.js +1 -1
- package/dist/components/arcgis-assets.d.ts +1 -1
- package/dist/components/arcgis-assets.js +1 -1
- package/dist/components/arcgis-code-editor.js +1 -1
- package/dist/components/arcgis-language-api-panel.js +1 -1
- package/dist/components/arcgis-sql-expression-editor.d.ts +11 -0
- package/dist/components/arcgis-sql-expression-editor.js +120 -0
- package/dist/components/arcgis-sql-expression-fields.d.ts +11 -0
- package/dist/components/arcgis-sql-expression-fields.js +11 -0
- package/dist/components/chunk-2JTWBRMN.js +1154 -0
- package/dist/components/code-editor.js +40 -13
- package/dist/components/fields.js +5 -5
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +30 -22
- package/dist/components/language-api-panel.js +13 -40
- package/dist/components/language-defaults-base.js +1309 -0
- package/dist/components/markdown.js +1 -1
- package/dist/components/sql-expr-defaults.js +196 -0
- package/dist/components/sql-expr-mode.js +20842 -0
- package/dist/components/sql-expression-fields.js +102 -0
- package/dist/components/useT9n.js +45 -8
- package/dist/components/utilities.js +1 -1
- package/dist/esm/{app-globals-59faaf33.js → app-globals-6d0ca11d.js} +1 -1
- package/dist/esm/arcade-defaults-066445c4.js +344 -0
- package/dist/esm/arcade-language-features-0e00c199.js +269 -0
- package/dist/esm/{arcade-mode-5d46035e.js → arcade-mode-abf1e1cf.js} +3 -263
- package/dist/esm/arcgis-arcade-editor_6.entry.js +127 -1447
- package/dist/esm/arcgis-coding-components.js +5 -5
- package/dist/esm/arcgis-sql-expression-editor.entry.js +77 -0
- package/dist/esm/arcgis-sql-expression-fields.entry.js +76 -0
- package/dist/esm/{css-e257dc49.js → css-c6dae12d.js} +1 -1
- package/dist/esm/{cssMode-c11f7f40.js → cssMode-052bb603.js} +2 -3
- package/dist/esm/{html-a6c37a99.js → html-572696a1.js} +2 -3
- package/dist/esm/{htmlMode-1270bc7d.js → htmlMode-fc184f2d.js} +2 -3
- package/dist/esm/{index-a970952c.js → index-0edd9846.js} +9 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/{javascript-ee179624.js → javascript-8bfc0096.js} +3 -4
- package/dist/esm/{jsonMode-07502ccb.js → jsonMode-7adf94ff.js} +2 -3
- package/dist/esm/{arcade-defaults-9eb28407.js → language-defaults-base-85a7f476.js} +833 -1179
- package/dist/esm/loader.js +5 -5
- package/dist/esm/sql-expr-defaults-be84ec7f.js +1339 -0
- package/dist/esm/sql-expr-mode-a4413e5c.js +20840 -0
- package/dist/esm/{tsMode-96749a12.js → tsMode-d10773c8.js} +2 -3
- package/dist/esm/{typescript-a3cf9881.js → typescript-9491f23e.js} +2 -3
- package/dist/loader/cdn.js +1 -1
- package/dist/loader/index.cjs.js +1 -1
- package/dist/loader/index.es2017.js +1 -1
- package/dist/loader/index.js +1 -1
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +45 -10
- package/dist/types/components/arcade-results/arcade-results.d.ts +43 -1
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +22 -1
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +28 -1
- package/dist/types/components/code-editor/code-editor.d.ts +16 -5
- package/dist/types/components/language-api-panel/language-api-panel.d.ts +34 -8
- package/dist/types/components/sql-expression-editor/sql-expression-editor.d.ts +24 -0
- package/dist/types/components/sql-expression-fields/sql-expression-fields.d.ts +32 -0
- package/dist/types/components.d.ts +98 -24
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/arcade-editor.stories.d.ts +8 -1
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/editorContext.d.ts +5 -1
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/sql-expression-editor/sql-expression-editor.stories.d.ts +13 -0
- package/dist/types/dependencies.d.ts +6 -10
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -0
- package/dist/types/utils/arcade-monaco/arcade-profile-strategy.d.ts +9 -0
- package/dist/types/utils/fields.d.ts +2 -2
- package/dist/types/utils/language-defaults-base.d.ts +2 -9
- package/dist/types/utils/profile/editor-profile.d.ts +7 -6
- package/dist/types/utils/profile/types.d.ts +53 -65
- package/dist/types/utils/profile/utils.d.ts +9 -8
- package/dist/types/utils/sql-expr-monaco/DependentFiles/DateOnly.d.ts +41 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlInterval.d.ts +16 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlTimestampOffset.d.ts +26 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/TimeOnly.d.ts +37 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/UnknownTimeZone.d.ts +11 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/WhereGrammar.d.ts +122 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlCompareUtils.d.ts +5 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlDateParsingUtils.d.ts +18 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlUtils.d.ts +6 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/standardizedFunctions.d.ts +156 -0
- package/dist/types/utils/sql-expr-monaco/DependentFiles/support.d.ts +150 -0
- package/dist/types/utils/sql-expr-monaco/PeggyGrammar/sql92grammar.d.ts +1397 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-completion.d.ts +6 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-constants.d.ts +45 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-contribution.d.ts +1 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-defaults.d.ts +21 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-language-features.d.ts +39 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-language-syntax.d.ts +8 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-mode.d.ts +43 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-service-accessors.d.ts +19 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation-diagnostic-adapter.d.ts +34 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation-utils.d.ts +100 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-validation.d.ts +41 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr-worker-manager.d.ts +17 -0
- package/dist/types/utils/sql-expr-monaco/sql-expr.worker.d.ts +24 -0
- package/dist/types/utils/sql-expr-monaco/sql-expression-profile-strategy.d.ts +13 -0
- package/dist/types/utils/sql-expr-monaco/types.d.ts +89 -0
- package/package.json +27 -21
- package/dist/arcgis-coding-components/p-0c6de9b3.js +0 -6
- package/dist/arcgis-coding-components/p-81c37dab.entry.js +0 -6
- package/dist/cjs/arcade-mode-b85ae7d4.js +0 -595
- package/dist/components/chunk-IHYYRFLQ.js +0 -1363
- package/dist/types/components/arcade-editor/t9n-types.d.ts +0 -8
- package/dist/types/components/arcade-results/t9n-types.d.ts +0 -13
- package/dist/types/components/arcade-suggestions/t9n-types.d.ts +0 -6
- package/dist/types/components/arcade-variables/t9n-types.d.ts +0 -8
- package/dist/types/components/language-api-panel/t9n-types.d.ts +0 -8
- package/dist/types/utils/profile/predefined-profile.d.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
* See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
-
* v4.31.0-next.
|
|
4
|
+
* v4.31.0-next.21
|
|
5
5
|
*/
|
|
6
6
|
import { editor } from 'monaco-editor';
|
|
7
7
|
import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
* See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
|
+
* v4.31.0-next.21
|
|
5
|
+
*/
|
|
6
|
+
import { f as fieldsToProfileValues, i as isPredefinedProfile, b as isFeatureSetDefinition, L as LanguageDefaultsBase, E as EditorProfile } from './language-defaults-base.js';
|
|
7
|
+
import { InsertTextMode, InsertTextFormat, CompletionItemKind } from 'vscode-languageserver-types';
|
|
8
|
+
import { f as fetchT9nStringsBundle } from './index2.js';
|
|
9
|
+
import { Uri } from 'monaco-editor';
|
|
10
|
+
import { getArcgisAssetPath as getAssetPath } from "./arcgis-assets.js";
|
|
11
|
+
|
|
12
|
+
// #region convert editor profile to apiProfile
|
|
13
|
+
/**
|
|
14
|
+
* Converts an editor profile to an api profile.
|
|
15
|
+
* The api profile is an optimized version of the editor profile designed for minimal data transfer between the main thread and the worker.
|
|
16
|
+
*/
|
|
17
|
+
const sqlExprEditorToApiProfile = (editorProfile) => {
|
|
18
|
+
const { apiVersion, bundles, hiddenApiItems } = editorProfile.toEditorProfileDefinition();
|
|
19
|
+
const variable = editorProfile.variables[0];
|
|
20
|
+
if (!variable || !(variable.type === "featureSet")) {
|
|
21
|
+
throw Error("No variable found in the editor profile");
|
|
22
|
+
}
|
|
23
|
+
const hydratedVariable = variableToApiProfile(variable);
|
|
24
|
+
return {
|
|
25
|
+
apiVersion,
|
|
26
|
+
bundles,
|
|
27
|
+
variables: [hydratedVariable],
|
|
28
|
+
hiddenApiItems: hiddenApiItems?.map((s) => s.toLowerCase()),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
function variableToApiProfile(variable) {
|
|
32
|
+
const { name } = variable;
|
|
33
|
+
const description = variable.getDescription();
|
|
34
|
+
const { definition } = variable.toProfileVariableDefinition();
|
|
35
|
+
const resultCompletion = {
|
|
36
|
+
label: name,
|
|
37
|
+
detail: name,
|
|
38
|
+
insertText: name,
|
|
39
|
+
insertTextMode: InsertTextMode.asIs,
|
|
40
|
+
insertTextFormat: InsertTextFormat.PlainText,
|
|
41
|
+
kind: CompletionItemKind.Field,
|
|
42
|
+
};
|
|
43
|
+
const result = {
|
|
44
|
+
name,
|
|
45
|
+
description,
|
|
46
|
+
type: "dictionary",
|
|
47
|
+
properties: [],
|
|
48
|
+
completion: resultCompletion,
|
|
49
|
+
};
|
|
50
|
+
// No fields or definition, then it will be a feature without any known fields
|
|
51
|
+
if (!definition || !("fields" in definition)) {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
// Create properties for the fields
|
|
55
|
+
// Also improve the feature completion documentation
|
|
56
|
+
// TODO: should we add aliases to completion? what about domains?
|
|
57
|
+
const [properties, featureCompletionDescription] = fieldsToProfileValues(definition.fields, description);
|
|
58
|
+
result.properties = properties;
|
|
59
|
+
resultCompletion.documentation = { kind: "markdown", value: featureCompletionDescription };
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
const tempHardcodedProfile = {
|
|
63
|
+
en: {
|
|
64
|
+
id: "field-calculation",
|
|
65
|
+
variables: [
|
|
66
|
+
{
|
|
67
|
+
name: "$layer",
|
|
68
|
+
type: "featureSet",
|
|
69
|
+
description: "The layer being calculated.",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
async function getSdkPredefinedProfile(locale = "en") {
|
|
75
|
+
return await Promise.resolve(tempHardcodedProfile[locale]);
|
|
76
|
+
}
|
|
77
|
+
async function convertToEditorProfileDefinition(predefinedProfile, locale = "en") {
|
|
78
|
+
if (!isPredefinedProfile(predefinedProfile)) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const sdkPredefinedProfile = await getSdkPredefinedProfile(locale);
|
|
82
|
+
if (!sdkPredefinedProfile) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
//
|
|
86
|
+
const editorProfile = {
|
|
87
|
+
variables: [],
|
|
88
|
+
hiddenApiItems: predefinedProfile.hiddenApiItems?.map((s) => s.toLowerCase()),
|
|
89
|
+
};
|
|
90
|
+
// Merge the SDK variables' definitions/properties with the predefined profile definitions.
|
|
91
|
+
sdkPredefinedProfile.variables.forEach((sdkVariable) => {
|
|
92
|
+
// Don't include disabled variables
|
|
93
|
+
if (predefinedProfile.disabledVariables?.includes(sdkVariable.name)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Try to get a definition from the predefined profile.
|
|
97
|
+
const definition = predefinedProfile.definitions[sdkVariable.name];
|
|
98
|
+
switch (sdkVariable.type) {
|
|
99
|
+
case "featureSet":
|
|
100
|
+
if (isFeatureSetDefinition(definition)) {
|
|
101
|
+
return editorProfile.variables.push({ ...sdkVariable, type: sdkVariable.type, definition });
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
default:
|
|
105
|
+
throw Error(`sdkVariable type not supported (yet) type: ${sdkVariable.type}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return editorProfile;
|
|
109
|
+
}
|
|
110
|
+
// #endregion
|
|
111
|
+
// #region profile utils
|
|
112
|
+
/**
|
|
113
|
+
* util to retrieve fields from the $layer variable in the api context.
|
|
114
|
+
*/
|
|
115
|
+
const getFieldsFromLayerVariable = (profile) => {
|
|
116
|
+
if (profile.variables) {
|
|
117
|
+
const layerVar = profile.variables.find((variable) => variable.name === "$layer" && variable.type === "dictionary");
|
|
118
|
+
return layerVar.properties ?? [];
|
|
119
|
+
}
|
|
120
|
+
return [];
|
|
121
|
+
};
|
|
122
|
+
// #endregion
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns the sql-expression worker for the model.
|
|
126
|
+
* Example:
|
|
127
|
+
* ```ts
|
|
128
|
+
* const sqlExpressionWorker = await getSqlExpressionWorker(model.uri);
|
|
129
|
+
* ```
|
|
130
|
+
* @returns sql-expression worker
|
|
131
|
+
*/
|
|
132
|
+
async function getSqlExprWorker(uri) {
|
|
133
|
+
const mode = await getMode();
|
|
134
|
+
return await mode.getSqlExprWorker(uri);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Request the sql-expression mode
|
|
138
|
+
* @returns sql-expression mode module
|
|
139
|
+
*/
|
|
140
|
+
async function getMode() {
|
|
141
|
+
return await import('./sql-expr-mode.js');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const languageId = "arcgis-sql-expression";
|
|
145
|
+
class SqlExprDefaults extends LanguageDefaultsBase {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
this._languageId = languageId;
|
|
149
|
+
this._languageOptions = {};
|
|
150
|
+
this._layerMap = new Map();
|
|
151
|
+
}
|
|
152
|
+
// TODO: try to rely on editor profile instance instead of storing a feature layer
|
|
153
|
+
updateFeatureLayerForModel(modelId, layer) {
|
|
154
|
+
const key = this._getApiKey(modelId);
|
|
155
|
+
this._layerMap.set(key, layer);
|
|
156
|
+
}
|
|
157
|
+
setLanguageOptions(languageOptions) {
|
|
158
|
+
this._languageOptions = languageOptions;
|
|
159
|
+
}
|
|
160
|
+
getFeatureLayerForModel(modelId) {
|
|
161
|
+
const key = this._getApiKey(modelId);
|
|
162
|
+
return this._layerMap.get(key);
|
|
163
|
+
}
|
|
164
|
+
async setProfileForModel(modelId, definition, apiContext = { locale: "en" }) {
|
|
165
|
+
// for now, it can ONLY be a predefined profile
|
|
166
|
+
if (isPredefinedProfile(definition)) {
|
|
167
|
+
definition = await convertToEditorProfileDefinition(definition, apiContext.locale);
|
|
168
|
+
}
|
|
169
|
+
// FIXME: using arcades intlStrings for now...
|
|
170
|
+
const intlStrings = await fetchT9nStringsBundle(apiContext.locale, getAssetPath("./assets/arcade-language/t9n"), "profile.t9n.");
|
|
171
|
+
if (!intlStrings) {
|
|
172
|
+
throw new Error(`Failed to load the language bundle for ${apiContext.locale}`);
|
|
173
|
+
}
|
|
174
|
+
this.disposeForModel(modelId);
|
|
175
|
+
const key = this._getApiKey(modelId);
|
|
176
|
+
const editorProfile = new EditorProfile(definition, intlStrings);
|
|
177
|
+
this._profileMap.set(key, editorProfile);
|
|
178
|
+
const apiProfile = sqlExprEditorToApiProfile(editorProfile);
|
|
179
|
+
this.updateApiContextForModel(modelId, {
|
|
180
|
+
locale: apiContext.locale,
|
|
181
|
+
profile: apiProfile,
|
|
182
|
+
});
|
|
183
|
+
const layer = definition?.variables?.find((variable) => variable.name === "$layer");
|
|
184
|
+
if (layer) {
|
|
185
|
+
this.updateFeatureLayerForModel(modelId, layer.definition);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async getApiLibrary(modelId) {
|
|
189
|
+
const uri = Uri.parse(modelId);
|
|
190
|
+
const worker = await getSqlExprWorker(uri);
|
|
191
|
+
return await worker.getApiLibrary(this.getApiContextForModel(uri));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const sqlExprDefaults = new SqlExprDefaults();
|
|
195
|
+
|
|
196
|
+
export { getFieldsFromLayerVariable as a, getMode as g, sqlExprDefaults as s };
|