@arcgis/languages-api-utils 4.31.0-next.100

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/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ # Licensing
2
+
3
+ COPYRIGHT © 2024 Esri
4
+
5
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
+
7
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
8
+
9
+ See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
10
+
11
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
12
+
13
+ email: contracts@esri.com
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # ArcGIS Maps SDK for JavaScript - Languages API Utils
2
+
3
+ This package is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript/latest/).
4
+
5
+ The package provides a set of classes and utilities to work with custom programming languages inside
6
+ monaco-editor.
7
+
8
+ It is not intended to be used directly, but rather used as a dependency by other packages in the SDK.
9
+
10
+ ## License
11
+
12
+ COPYRIGHT © 2024 Esri
13
+
14
+ All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
15
+
16
+ This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
17
+
18
+ See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
19
+
20
+ For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
21
+
22
+ email: contracts@esri.com
@@ -0,0 +1,3 @@
1
+ "use strict";var f=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of x(t))!D.call(e,o)&&o!==n&&f(e,o,{get:()=>t[o],enumerable:!(i=C(t,o))||i.enumerable});return e};var M=e=>k(f({},"__esModule",{value:!0}),e);var w={};h(w,{ApiService:()=>d,filterApiLibraryForContext:()=>A,isDictionaryVariable:()=>V,isValueVariable:()=>S});module.exports=M(w);var s=require("vscode-languageserver-types");async function A(e,t){try{let n=await e,i=new Map,o=new Map,a=[],r=T(t);return n.forEach(c=>{let l=[];c.items.forEach(p=>v(l,o,i,r,p)),l.length&&a.push({...c,items:l})}),{categories:a,functionDefinitions:i,constantDefinitions:o}}catch(n){return console.error(n),{categories:[],functionDefinitions:new Map,constantDefinitions:new Map}}}function T(e){let{profile:{apiVersion:t,bundles:n,hiddenApiItems:i=[]}={}}=e,o=g(t),a=Array.isArray(n)&&n.length>0?new Set(["core",...n]):void 0;return r=>L(o,r.sinceVersion)&&(!a||a.has(r.bundle))&&!i.includes(r.name)}function v(e,t,n,i,o){if(Array.isArray(o)){o.forEach(a=>b(e,n,i,a));return}o.type==="constant"?F(e,t,i,o):b(e,n,i,o)}function b(e,t,n,i){if(!n(i))return;i.disableDocumentation||e.push(i);let{completion:{label:o}}=i,a=o.toLowerCase(),r=t.get(a);r||(r={type:"functionDefinition",key:a,overloads:[]},t.set(a,r)),r.overloads.push(i)}function F(e,t,n,i){if(!n(i))return;e.push(i);let{completion:{label:o}}=i,a=o.toLowerCase();t.set(a,i);let[r,c]=i.completion.label.split(".");if(!c)return;let l=r.toLowerCase(),p=t.get(l);p||(p={type:"namespace",key:l,members:[],completion:{label:r,detail:r,insertText:r,insertTextMode:s.InsertTextMode.adjustIndentation,insertTextFormat:s.InsertTextFormat.PlainText,kind:s.CompletionItemKind.Enum}},t.set(l,p));let u=structuredClone(i);u.name=c,u.completion.label=c,u.completion.insertText=c,u.completion.kind=s.CompletionItemKind.Constant,p.members.push(u),p.completion.documentation=p.members.reduce((m,y)=>(m.value=`${m.value}${m.value?`
2
+
3
+ `:""}**${y.completion.label}**: ${y.description}`,m),{kind:s.MarkupKind.Markdown,value:""})}function g(e){if(!e||typeof e!="string")return null;let t=e.split(".").map(o=>Number.parseInt(o));if(t.some(Number.isNaN))return console.error("Invalid API version string",e),null;let[n,i]=t.slice(0,2);return{major:n,minor:i}}function L(e,t){if(!e)return!0;let n=g(t);return n?e.major>n.major?!1:e.minor===void 0||n.minor===void 0?!0:n.minor<=e.minor:!0}function S(e){return!!e&&e.type!=="dictionary"}function V(e){return e?.type==="dictionary"}var d=class{constructor(t){this._settings=t;this.localeToApiLibraryPromiseMap=new Map}async getApiDatabase(t){let{locale:n="en"}=t,i=this.localeToApiLibraryPromiseMap.get(n);return i||(i=this._settings.getApiLibrary(n),this.localeToApiLibraryPromiseMap.set(n,i)),await A(i,t)}async getApiLibrary(t){let{categories:n}=await this.getApiDatabase(t);return n}};0&&(module.exports={ApiService,filterApiLibraryForContext,isDictionaryVariable,isValueVariable});
@@ -0,0 +1,317 @@
1
+ import { CompletionItem } from 'vscode-languageserver-types';
2
+
3
+ /**
4
+ * Supported function bundles
5
+ */
6
+ type BundleType = "core" | "data-access" | "database" | "geometry" | "knowledge-graph" | "portal-access" | "track";
7
+
8
+ /**
9
+ * The list of supported profiles
10
+ */
11
+ type ProfileId = "minimalist" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "dashboard-data" | "dictionary-renderer" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "popup" | "popup-element" | "popup-feature-reduction" | "popup-element-feature-reduction" | "quick-capture" | "tasks" | "velocity" | "visualization";
12
+ /**
13
+ * Describes a profile
14
+ */
15
+ interface SdkPredefinedProfile {
16
+ /**
17
+ * Profile name for UI
18
+ */
19
+ name: string;
20
+ /**
21
+ * Profile id for docs
22
+ */
23
+ id: ProfileId;
24
+ /**
25
+ * Function bundles enabled for this profile
26
+ */
27
+ bundles: BundleType[];
28
+ /**
29
+ * Variable describing name, type, and providing description
30
+ */
31
+ variables: SdkVariable[];
32
+ }
33
+ /**
34
+ * Supported profile variable types
35
+ */
36
+ type SdkVariableType = "number" | "text" | "date" | "dateOnly" | "time" | "boolean" | "dictionary" | "array" | "geometry" | "feature" | "featureSet" | "featureSetCollection" | "knowledgeGraph";
37
+ /**
38
+ * Describes variables
39
+ */
40
+ interface SdkVariableBase {
41
+ /**
42
+ * Name of the variable.
43
+ */
44
+ name: string;
45
+ /**
46
+ * Type of the variable.
47
+ */
48
+ type: SdkVariableType;
49
+ /**
50
+ * Description of the variable.
51
+ */
52
+ description?: string;
53
+ }
54
+ /**
55
+ * A variable that represents a simple type (boolean, number, feature, etc.)
56
+ */
57
+ interface SdkValueVariable extends SdkVariableBase {
58
+ type: Exclude<SdkVariableType, "dictionary">;
59
+ }
60
+ /**
61
+ * A dictionary variable
62
+ */
63
+ interface SdkDictionaryVariable extends SdkVariableBase {
64
+ type: "dictionary";
65
+ properties: SdkVariable[];
66
+ }
67
+ /**
68
+ * Profile variable
69
+ */
70
+ type SdkVariable = SdkValueVariable | SdkDictionaryVariable;
71
+
72
+ /**
73
+ * Represents an api category and its items
74
+ */
75
+ interface SdkCategory {
76
+ /**
77
+ * The unique ID for the category
78
+ */
79
+ id: string;
80
+ /**
81
+ * The title for the category
82
+ */
83
+ title: string;
84
+ /**
85
+ * The collection of api items for the category
86
+ */
87
+ items: SdkItem[];
88
+ }
89
+ interface SdkItemBase {
90
+ /**
91
+ * The name of the function or constant.
92
+ */
93
+ name: string;
94
+ /**
95
+ * The version string when the api item was introduced. If undefined then it was from the origin.
96
+ */
97
+ sinceVersion?: string;
98
+ /**
99
+ * The api bundle this item belongs to.
100
+ */
101
+ bundle: BundleType;
102
+ /**
103
+ * Markdown description of the item.
104
+ */
105
+ description: string;
106
+ /**
107
+ * Markdown containing examples.
108
+ */
109
+ examples: string;
110
+ /**
111
+ * Link for additional information about the item.
112
+ */
113
+ link: string;
114
+ /**
115
+ * Completion item directly leveraged by the editor.
116
+ */
117
+ completion: CompletionItem;
118
+ /**
119
+ * Indicates if the documentation for this item should be disabled.
120
+ */
121
+ disableDocumentation?: boolean;
122
+ }
123
+ /**
124
+ * Represents a constant in the arcade api.
125
+ */
126
+ interface SdkConstant extends SdkItemBase {
127
+ type: "constant";
128
+ }
129
+ /**
130
+ * Represents a function in the arcade api
131
+ */
132
+ interface SdkFunction extends SdkItemBase {
133
+ type: "function";
134
+ /**
135
+ * Information leveraged by the editor to validate function call.
136
+ * Indicates the minimum number of expected parameters and the maximum number of parameters expected.
137
+ */
138
+ parametersInfo: {
139
+ min: number;
140
+ max: number;
141
+ };
142
+ }
143
+ /**
144
+ * Represents an item in the arcade api.
145
+ */
146
+ type SdkItem = SdkConstant | SdkFunction | SdkFunction[];
147
+
148
+ /**
149
+ * Represent items stored in the library
150
+ */
151
+ type ApiItem = SdkConstant | SdkFunction;
152
+ /**
153
+ * Represent a category of api items in the api library
154
+ */
155
+ interface ApiCategory extends SdkCategory {
156
+ items: ApiItem[];
157
+ }
158
+
159
+ /**
160
+ * The editor can be extended with custom snippets
161
+ */
162
+ interface ApiSnippet {
163
+ /**
164
+ * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
165
+ * It's recommended to keep it short and as close as possible to what the user may be looking for.
166
+ * For example: 'polyline'
167
+ */
168
+ label: string;
169
+ /**
170
+ * A slightly longer description of what the snippet offers.
171
+ */
172
+ detail: string;
173
+ /**
174
+ * A string that should be inserted into the script when selecting
175
+ * this snippet.
176
+ *
177
+ * The `insertText` is subject to interpretation by the editor.
178
+ * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
179
+ */
180
+ insertText: string;
181
+ }
182
+ /**
183
+ * Language service api options
184
+ */
185
+ interface ApiContext {
186
+ /**
187
+ * The profile (variables, additional api items, bundles, etc.)
188
+ */
189
+ profile?: ApiProfile;
190
+ /**
191
+ * The locale for the Api
192
+ */
193
+ locale?: string;
194
+ /**
195
+ * Allows to augment the language snippets with a collection of snippets
196
+ */
197
+ snippets?: ApiSnippet[];
198
+ }
199
+ /**
200
+ * Language service profile
201
+ */
202
+ interface ApiProfile {
203
+ /**
204
+ * The wellknown profile id if applicable
205
+ */
206
+ id?: ProfileId;
207
+ /**
208
+ * The set of profile variables
209
+ */
210
+ variables: ApiVariable[];
211
+ /**
212
+ * The api version to use
213
+ */
214
+ apiVersion?: string;
215
+ /**
216
+ * The api bundles to use
217
+ */
218
+ bundles?: BundleType[];
219
+ /**
220
+ * A collection of api item names to hide.
221
+ */
222
+ hiddenApiItems?: string[];
223
+ }
224
+ /**
225
+ * The type for value variable.
226
+ */
227
+ type ApiValueVariableType = Exclude<SdkVariableType, "dictionary">;
228
+ interface ApiVariableBase {
229
+ /**
230
+ * Name of the variable
231
+ */
232
+ name: string;
233
+ /**
234
+ * Optional short description for the variable
235
+ */
236
+ description?: string;
237
+ /**
238
+ * Completion item for the variable, leveraged bu the editor
239
+ */
240
+ completion?: CompletionItem;
241
+ }
242
+ /**
243
+ * Describes a dictionary type (feature, dictionary)
244
+ */
245
+ interface ApiDictionaryVariable extends ApiVariableBase {
246
+ type: "dictionary";
247
+ /**
248
+ * Dictionary properties
249
+ */
250
+ properties?: ApiVariable[];
251
+ }
252
+ /**
253
+ * Describes a simple variable type (number, featureSet, etc.)
254
+ */
255
+ interface ApiValueVariable extends ApiVariableBase {
256
+ type: ApiValueVariableType;
257
+ }
258
+ /**
259
+ * The profile variable type
260
+ */
261
+ type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
262
+
263
+ interface ApiVersion {
264
+ major: number;
265
+ minor?: number;
266
+ }
267
+ type ApiConstantNamespace = {
268
+ type: "namespace";
269
+ key: string;
270
+ members: SdkConstant[];
271
+ completion: CompletionItem;
272
+ };
273
+ type ApiConstantDefinition = SdkConstant | ApiConstantNamespace;
274
+ type ApiFunctionDefinition = {
275
+ type: "functionDefinition";
276
+ key: string;
277
+ overloads: SdkFunction[];
278
+ };
279
+ /**
280
+ * Describes the API properties
281
+ */
282
+ interface ApiDatabase {
283
+ categories: ApiCategory[];
284
+ functionDefinitions: Map<string, ApiFunctionDefinition>;
285
+ constantDefinitions: Map<string, ApiConstantDefinition>;
286
+ }
287
+ declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
288
+ /**
289
+ * Helper function to test if a variable is a value variable
290
+ */
291
+ declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
292
+ /**
293
+ * Helper function to test if a variable is a dictionary variable
294
+ */
295
+ declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
296
+
297
+ /**
298
+ * Language service settings
299
+ */
300
+ interface LanguageServiceSettings {
301
+ getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
302
+ }
303
+ declare class ApiService<TApiContext extends ApiContext = ApiContext> {
304
+ private _settings;
305
+ private localeToApiLibraryPromiseMap;
306
+ constructor(_settings: LanguageServiceSettings);
307
+ /**
308
+ * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
309
+ */
310
+ getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
311
+ /**
312
+ * Returns the API definitions
313
+ */
314
+ getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
315
+ }
316
+
317
+ export { type ApiCategory, type SdkConstant as ApiConstant, type ApiConstantDefinition, type ApiConstantNamespace, type ApiContext, type ApiDatabase, type ApiDictionaryVariable, type SdkFunction as ApiFunction, type ApiFunctionDefinition, type ApiItem, type ApiProfile, ApiService, type ApiSnippet, type ApiValueVariable, type ApiValueVariableType, type ApiVariable, type SdkVariableType as ApiVariableType, type ApiVersion, type BundleType, type LanguageServiceSettings, type ProfileId, type SdkPredefinedProfile, filterApiLibraryForContext, isDictionaryVariable, isValueVariable };
@@ -0,0 +1,317 @@
1
+ import { CompletionItem } from 'vscode-languageserver-types';
2
+
3
+ /**
4
+ * Supported function bundles
5
+ */
6
+ type BundleType = "core" | "data-access" | "database" | "geometry" | "knowledge-graph" | "portal-access" | "track";
7
+
8
+ /**
9
+ * The list of supported profiles
10
+ */
11
+ type ProfileId = "minimalist" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "dashboard-data" | "dictionary-renderer" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "popup" | "popup-element" | "popup-feature-reduction" | "popup-element-feature-reduction" | "quick-capture" | "tasks" | "velocity" | "visualization";
12
+ /**
13
+ * Describes a profile
14
+ */
15
+ interface SdkPredefinedProfile {
16
+ /**
17
+ * Profile name for UI
18
+ */
19
+ name: string;
20
+ /**
21
+ * Profile id for docs
22
+ */
23
+ id: ProfileId;
24
+ /**
25
+ * Function bundles enabled for this profile
26
+ */
27
+ bundles: BundleType[];
28
+ /**
29
+ * Variable describing name, type, and providing description
30
+ */
31
+ variables: SdkVariable[];
32
+ }
33
+ /**
34
+ * Supported profile variable types
35
+ */
36
+ type SdkVariableType = "number" | "text" | "date" | "dateOnly" | "time" | "boolean" | "dictionary" | "array" | "geometry" | "feature" | "featureSet" | "featureSetCollection" | "knowledgeGraph";
37
+ /**
38
+ * Describes variables
39
+ */
40
+ interface SdkVariableBase {
41
+ /**
42
+ * Name of the variable.
43
+ */
44
+ name: string;
45
+ /**
46
+ * Type of the variable.
47
+ */
48
+ type: SdkVariableType;
49
+ /**
50
+ * Description of the variable.
51
+ */
52
+ description?: string;
53
+ }
54
+ /**
55
+ * A variable that represents a simple type (boolean, number, feature, etc.)
56
+ */
57
+ interface SdkValueVariable extends SdkVariableBase {
58
+ type: Exclude<SdkVariableType, "dictionary">;
59
+ }
60
+ /**
61
+ * A dictionary variable
62
+ */
63
+ interface SdkDictionaryVariable extends SdkVariableBase {
64
+ type: "dictionary";
65
+ properties: SdkVariable[];
66
+ }
67
+ /**
68
+ * Profile variable
69
+ */
70
+ type SdkVariable = SdkValueVariable | SdkDictionaryVariable;
71
+
72
+ /**
73
+ * Represents an api category and its items
74
+ */
75
+ interface SdkCategory {
76
+ /**
77
+ * The unique ID for the category
78
+ */
79
+ id: string;
80
+ /**
81
+ * The title for the category
82
+ */
83
+ title: string;
84
+ /**
85
+ * The collection of api items for the category
86
+ */
87
+ items: SdkItem[];
88
+ }
89
+ interface SdkItemBase {
90
+ /**
91
+ * The name of the function or constant.
92
+ */
93
+ name: string;
94
+ /**
95
+ * The version string when the api item was introduced. If undefined then it was from the origin.
96
+ */
97
+ sinceVersion?: string;
98
+ /**
99
+ * The api bundle this item belongs to.
100
+ */
101
+ bundle: BundleType;
102
+ /**
103
+ * Markdown description of the item.
104
+ */
105
+ description: string;
106
+ /**
107
+ * Markdown containing examples.
108
+ */
109
+ examples: string;
110
+ /**
111
+ * Link for additional information about the item.
112
+ */
113
+ link: string;
114
+ /**
115
+ * Completion item directly leveraged by the editor.
116
+ */
117
+ completion: CompletionItem;
118
+ /**
119
+ * Indicates if the documentation for this item should be disabled.
120
+ */
121
+ disableDocumentation?: boolean;
122
+ }
123
+ /**
124
+ * Represents a constant in the arcade api.
125
+ */
126
+ interface SdkConstant extends SdkItemBase {
127
+ type: "constant";
128
+ }
129
+ /**
130
+ * Represents a function in the arcade api
131
+ */
132
+ interface SdkFunction extends SdkItemBase {
133
+ type: "function";
134
+ /**
135
+ * Information leveraged by the editor to validate function call.
136
+ * Indicates the minimum number of expected parameters and the maximum number of parameters expected.
137
+ */
138
+ parametersInfo: {
139
+ min: number;
140
+ max: number;
141
+ };
142
+ }
143
+ /**
144
+ * Represents an item in the arcade api.
145
+ */
146
+ type SdkItem = SdkConstant | SdkFunction | SdkFunction[];
147
+
148
+ /**
149
+ * Represent items stored in the library
150
+ */
151
+ type ApiItem = SdkConstant | SdkFunction;
152
+ /**
153
+ * Represent a category of api items in the api library
154
+ */
155
+ interface ApiCategory extends SdkCategory {
156
+ items: ApiItem[];
157
+ }
158
+
159
+ /**
160
+ * The editor can be extended with custom snippets
161
+ */
162
+ interface ApiSnippet {
163
+ /**
164
+ * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
165
+ * It's recommended to keep it short and as close as possible to what the user may be looking for.
166
+ * For example: 'polyline'
167
+ */
168
+ label: string;
169
+ /**
170
+ * A slightly longer description of what the snippet offers.
171
+ */
172
+ detail: string;
173
+ /**
174
+ * A string that should be inserted into the script when selecting
175
+ * this snippet.
176
+ *
177
+ * The `insertText` is subject to interpretation by the editor.
178
+ * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
179
+ */
180
+ insertText: string;
181
+ }
182
+ /**
183
+ * Language service api options
184
+ */
185
+ interface ApiContext {
186
+ /**
187
+ * The profile (variables, additional api items, bundles, etc.)
188
+ */
189
+ profile?: ApiProfile;
190
+ /**
191
+ * The locale for the Api
192
+ */
193
+ locale?: string;
194
+ /**
195
+ * Allows to augment the language snippets with a collection of snippets
196
+ */
197
+ snippets?: ApiSnippet[];
198
+ }
199
+ /**
200
+ * Language service profile
201
+ */
202
+ interface ApiProfile {
203
+ /**
204
+ * The wellknown profile id if applicable
205
+ */
206
+ id?: ProfileId;
207
+ /**
208
+ * The set of profile variables
209
+ */
210
+ variables: ApiVariable[];
211
+ /**
212
+ * The api version to use
213
+ */
214
+ apiVersion?: string;
215
+ /**
216
+ * The api bundles to use
217
+ */
218
+ bundles?: BundleType[];
219
+ /**
220
+ * A collection of api item names to hide.
221
+ */
222
+ hiddenApiItems?: string[];
223
+ }
224
+ /**
225
+ * The type for value variable.
226
+ */
227
+ type ApiValueVariableType = Exclude<SdkVariableType, "dictionary">;
228
+ interface ApiVariableBase {
229
+ /**
230
+ * Name of the variable
231
+ */
232
+ name: string;
233
+ /**
234
+ * Optional short description for the variable
235
+ */
236
+ description?: string;
237
+ /**
238
+ * Completion item for the variable, leveraged bu the editor
239
+ */
240
+ completion?: CompletionItem;
241
+ }
242
+ /**
243
+ * Describes a dictionary type (feature, dictionary)
244
+ */
245
+ interface ApiDictionaryVariable extends ApiVariableBase {
246
+ type: "dictionary";
247
+ /**
248
+ * Dictionary properties
249
+ */
250
+ properties?: ApiVariable[];
251
+ }
252
+ /**
253
+ * Describes a simple variable type (number, featureSet, etc.)
254
+ */
255
+ interface ApiValueVariable extends ApiVariableBase {
256
+ type: ApiValueVariableType;
257
+ }
258
+ /**
259
+ * The profile variable type
260
+ */
261
+ type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
262
+
263
+ interface ApiVersion {
264
+ major: number;
265
+ minor?: number;
266
+ }
267
+ type ApiConstantNamespace = {
268
+ type: "namespace";
269
+ key: string;
270
+ members: SdkConstant[];
271
+ completion: CompletionItem;
272
+ };
273
+ type ApiConstantDefinition = SdkConstant | ApiConstantNamespace;
274
+ type ApiFunctionDefinition = {
275
+ type: "functionDefinition";
276
+ key: string;
277
+ overloads: SdkFunction[];
278
+ };
279
+ /**
280
+ * Describes the API properties
281
+ */
282
+ interface ApiDatabase {
283
+ categories: ApiCategory[];
284
+ functionDefinitions: Map<string, ApiFunctionDefinition>;
285
+ constantDefinitions: Map<string, ApiConstantDefinition>;
286
+ }
287
+ declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
288
+ /**
289
+ * Helper function to test if a variable is a value variable
290
+ */
291
+ declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
292
+ /**
293
+ * Helper function to test if a variable is a dictionary variable
294
+ */
295
+ declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
296
+
297
+ /**
298
+ * Language service settings
299
+ */
300
+ interface LanguageServiceSettings {
301
+ getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
302
+ }
303
+ declare class ApiService<TApiContext extends ApiContext = ApiContext> {
304
+ private _settings;
305
+ private localeToApiLibraryPromiseMap;
306
+ constructor(_settings: LanguageServiceSettings);
307
+ /**
308
+ * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
309
+ */
310
+ getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
311
+ /**
312
+ * Returns the API definitions
313
+ */
314
+ getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
315
+ }
316
+
317
+ export { type ApiCategory, type SdkConstant as ApiConstant, type ApiConstantDefinition, type ApiConstantNamespace, type ApiContext, type ApiDatabase, type ApiDictionaryVariable, type SdkFunction as ApiFunction, type ApiFunctionDefinition, type ApiItem, type ApiProfile, ApiService, type ApiSnippet, type ApiValueVariable, type ApiValueVariableType, type ApiVariable, type SdkVariableType as ApiVariableType, type ApiVersion, type BundleType, type LanguageServiceSettings, type ProfileId, type SdkPredefinedProfile, filterApiLibraryForContext, isDictionaryVariable, isValueVariable };
@@ -0,0 +1,3 @@
1
+ import{CompletionItemKind as f,InsertTextFormat as g,InsertTextMode as C,MarkupKind as x}from"vscode-languageserver-types";async function d(t,i){try{let n=await t,e=new Map,o=new Map,a=[],r=D(i);return n.forEach(p=>{let c=[];p.items.forEach(s=>h(c,o,e,r,s)),c.length&&a.push({...p,items:c})}),{categories:a,functionDefinitions:e,constantDefinitions:o}}catch(n){return console.error(n),{categories:[],functionDefinitions:new Map,constantDefinitions:new Map}}}function D(t){let{profile:{apiVersion:i,bundles:n,hiddenApiItems:e=[]}={}}=t,o=y(i),a=Array.isArray(n)&&n.length>0?new Set(["core",...n]):void 0;return r=>M(o,r.sinceVersion)&&(!a||a.has(r.bundle))&&!e.includes(r.name)}function h(t,i,n,e,o){if(Array.isArray(o)){o.forEach(a=>A(t,n,e,a));return}o.type==="constant"?k(t,i,e,o):A(t,n,e,o)}function A(t,i,n,e){if(!n(e))return;e.disableDocumentation||t.push(e);let{completion:{label:o}}=e,a=o.toLowerCase(),r=i.get(a);r||(r={type:"functionDefinition",key:a,overloads:[]},i.set(a,r)),r.overloads.push(e)}function k(t,i,n,e){if(!n(e))return;t.push(e);let{completion:{label:o}}=e,a=o.toLowerCase();i.set(a,e);let[r,p]=e.completion.label.split(".");if(!p)return;let c=r.toLowerCase(),s=i.get(c);s||(s={type:"namespace",key:c,members:[],completion:{label:r,detail:r,insertText:r,insertTextMode:C.adjustIndentation,insertTextFormat:g.PlainText,kind:f.Enum}},i.set(c,s));let l=structuredClone(e);l.name=p,l.completion.label=p,l.completion.insertText=p,l.completion.kind=f.Constant,s.members.push(l),s.completion.documentation=s.members.reduce((u,m)=>(u.value=`${u.value}${u.value?`
2
+
3
+ `:""}**${m.completion.label}**: ${m.description}`,u),{kind:x.Markdown,value:""})}function y(t){if(!t||typeof t!="string")return null;let i=t.split(".").map(o=>Number.parseInt(o));if(i.some(Number.isNaN))return console.error("Invalid API version string",t),null;let[n,e]=i.slice(0,2);return{major:n,minor:e}}function M(t,i){if(!t)return!0;let n=y(i);return n?t.major>n.major?!1:t.minor===void 0||n.minor===void 0?!0:n.minor<=t.minor:!0}function v(t){return!!t&&t.type!=="dictionary"}function F(t){return t?.type==="dictionary"}var b=class{constructor(i){this._settings=i;this.localeToApiLibraryPromiseMap=new Map}async getApiDatabase(i){let{locale:n="en"}=i,e=this.localeToApiLibraryPromiseMap.get(n);return e||(e=this._settings.getApiLibrary(n),this.localeToApiLibraryPromiseMap.set(n,e)),await d(e,i)}async getApiLibrary(i){let{categories:n}=await this.getApiDatabase(i);return n}};export{b as ApiService,d as filterApiLibraryForContext,F as isDictionaryVariable,v as isValueVariable};
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@arcgis/languages-api-utils",
3
+ "version": "4.31.0-next.100",
4
+ "description": "ArcGIS Languages API Utilities",
5
+ "homepage": "https://developers.arcgis.com/javascript/latest/",
6
+ "type": "module",
7
+ "main": "dist/esm/index.js",
8
+ "module": "dist/esm/index.js",
9
+ "types": "dist/esm/index.d.ts",
10
+ "files": [
11
+ "dist/"
12
+ ],
13
+ "publishConfig": {
14
+ "registry": "https://registry.npmjs.org/",
15
+ "access": "public"
16
+ },
17
+ "license": "SEE LICENSE IN LICENSE.md",
18
+ "scripts": {
19
+ "build:dev": "yarn build:esm --sourcemap --no-minify",
20
+ "build:cjs": "tsup --format cjs --outDir dist/cjs --silent --minify",
21
+ "build:esm": "tsup --format esm --outDir dist/esm --silent --minify",
22
+ "build": "npm run build:cjs && npm run build:esm",
23
+ "clean": "rimraf ./node_modules ./turbo ./dist",
24
+ "test": "jest"
25
+ },
26
+ "dependencies": {
27
+ "tslib": "^2.7.0",
28
+ "vscode-languageserver-textdocument": "^1.0.11",
29
+ "vscode-languageserver-types": "^3.17.5"
30
+ },
31
+ "devDependencies": {
32
+ "@arcgis/arcade-sdk": "~1.26.5",
33
+ "@arcgis/typescript-config": "4.31.0-next.100",
34
+ "@swc/core": "^1.7.23",
35
+ "@swc/jest": "^0.2.36",
36
+ "@types/jest": "^29.5.0",
37
+ "@types/node": "^20.2.5",
38
+ "eslint": "^8.55.0",
39
+ "jest": "^29.5.0",
40
+ "rimraf": "^5.0.0",
41
+ "tsup": "^8.2.4",
42
+ "typescript": "~5.4.0"
43
+ },
44
+ "gitHead": "79752e970f09c930d0e1b07e4de53abfb0e32354"
45
+ }