@arcgis/languages-api-utils 4.33.0-next.13 → 4.33.0-next.133

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.
@@ -0,0 +1,21 @@
1
+ import { ApiCategory, ApiContext } from './types';
2
+ import { ApiDatabase } from './utils';
3
+ /**
4
+ * Language service settings
5
+ */
6
+ export interface LanguageServiceSettings {
7
+ getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
8
+ }
9
+ export declare class ApiService<TApiContext extends ApiContext = ApiContext> {
10
+ private _settings;
11
+ private localeToApiLibraryPromiseMap;
12
+ constructor(_settings: LanguageServiceSettings);
13
+ /**
14
+ * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
15
+ */
16
+ getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
17
+ /**
18
+ * Returns the API definitions
19
+ */
20
+ getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
21
+ }
@@ -0,0 +1,21 @@
1
+ import { ApiCategory, ApiContext } from './types';
2
+ import { ApiDatabase } from './utils';
3
+ /**
4
+ * Language service settings
5
+ */
6
+ export interface LanguageServiceSettings {
7
+ getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
8
+ }
9
+ export declare class ApiService<TApiContext extends ApiContext = ApiContext> {
10
+ private _settings;
11
+ private localeToApiLibraryPromiseMap;
12
+ constructor(_settings: LanguageServiceSettings);
13
+ /**
14
+ * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
15
+ */
16
+ getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
17
+ /**
18
+ * Returns the API definitions
19
+ */
20
+ getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
21
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("vscode-languageserver-types");async function d(n,r){try{const t=await n,e=new Map,o=new Map,s=[],i=h(r);return t.forEach(c=>{const l=[];c.items.forEach(a=>g(l,o,e,i,a)),l.length&&s.push({...c,items:l})}),{categories:s,functionDefinitions:e,constantDefinitions:o}}catch(t){return console.error(t),{categories:[],functionDefinitions:new Map,constantDefinitions:new Map}}}function h(n){const{profile:{apiVersion:r,bundles:t,hiddenApiItems:e=[]}={}}=n,o=b(r),s=Array.isArray(t)&&t.length>0?new Set(["core",...t]):void 0;return i=>v(o,i.sinceVersion)&&(!s||s.has(i.bundle))&&!e.includes(i.name)}function g(n,r,t,e,o){if(Array.isArray(o)){o.forEach(s=>y(n,t,e,s));return}o.type==="constant"?A(n,r,e,o):y(n,t,e,o)}function y(n,r,t,e){if(!t(e))return;e.disableDocumentation||n.push(e);const{completion:{label:o}}=e,s=o.toLowerCase();let i=r.get(s);i||(i={type:"functionDefinition",key:s,overloads:[]},r.set(s,i)),i.overloads.push(e)}function A(n,r,t,e){if(!t(e))return;n.push(e);const{completion:{label:o}}=e,s=o.toLowerCase();r.set(s,e);const[i,c]=e.completion.label.split(".");if(!c)return;const l=i.toLowerCase();let a=r.get(l);a||(a={type:"namespace",key:l,members:[],completion:{label:i,detail:i,insertText:i,insertTextMode:p.InsertTextMode.adjustIndentation,insertTextFormat:p.InsertTextFormat.PlainText,kind:p.CompletionItemKind.Enum}},r.set(l,a));const u=structuredClone(e);u.name=c,u.completion.label=c,u.completion.insertText=c,u.completion.kind=p.CompletionItemKind.Constant,a.members.push(u),a.completion.documentation=a.members.reduce((f,m)=>(f.value=`${f.value}${f.value?`
2
+
3
+ `:""}**${m.completion.label}**: ${m.description}`,f),{kind:p.MarkupKind.Markdown,value:""})}function b(n){if(!n||typeof n!="string")return null;const r=n.split(".").map(o=>Number.parseInt(o));if(r.some(Number.isNaN))return console.error("Invalid API version string",n),null;const[t,e]=r.slice(0,2);return{major:t,minor:e}}function v(n,r){if(!n)return!0;const t=b(r);return t?n.major>t.major?!1:n.minor===void 0||t.minor===void 0?!0:t.minor<=n.minor:!0}function w(n){return!!n&&n.type!=="dictionary"}function L(n){return n?.type==="dictionary"}class M{constructor(r){this._settings=r,this.localeToApiLibraryPromiseMap=new Map}async getApiDatabase(r){const{locale:t="en"}=r;let e=this.localeToApiLibraryPromiseMap.get(t);return e||(e=this._settings.getApiLibrary(t),this.localeToApiLibraryPromiseMap.set(t,e)),await d(e,r)}async getApiLibrary(r){const{categories:t}=await this.getApiDatabase(r);return t}}exports.ApiService=M;exports.filterApiLibraryForContext=d;exports.isDictionaryVariable=L;exports.isValueVariable=w;
@@ -0,0 +1,3 @@
1
+ export * from './ApiService';
2
+ export type * from './types';
3
+ export * from './utils';
@@ -0,0 +1,3 @@
1
+ export * from './ApiService';
2
+ export type * from './types';
3
+ export * from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,122 @@
1
+ import { CompletionItemKind as m, InsertTextFormat as b, InsertTextMode as h, MarkupKind as g } from "vscode-languageserver-types";
2
+ async function w(n, r) {
3
+ try {
4
+ const t = await n, e = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = [], i = A(r);
5
+ return t.forEach((c) => {
6
+ const l = [];
7
+ c.items.forEach(
8
+ (a) => M(l, o, e, i, a)
9
+ ), l.length && s.push({ ...c, items: l });
10
+ }), { categories: s, functionDefinitions: e, constantDefinitions: o };
11
+ } catch (t) {
12
+ return console.error(t), { categories: [], functionDefinitions: /* @__PURE__ */ new Map(), constantDefinitions: /* @__PURE__ */ new Map() };
13
+ }
14
+ }
15
+ function A(n) {
16
+ const { profile: { apiVersion: r, bundles: t, hiddenApiItems: e = [] } = {} } = n, o = d(r), s = Array.isArray(t) && t.length > 0 ? /* @__PURE__ */ new Set(["core", ...t]) : void 0;
17
+ return (i) => T(o, i.sinceVersion) && (!s || s.has(i.bundle)) && !e.includes(i.name);
18
+ }
19
+ function M(n, r, t, e, o) {
20
+ if (Array.isArray(o)) {
21
+ o.forEach(
22
+ (s) => y(n, t, e, s)
23
+ );
24
+ return;
25
+ }
26
+ o.type === "constant" ? L(n, r, e, o) : y(n, t, e, o);
27
+ }
28
+ function y(n, r, t, e) {
29
+ if (!t(e))
30
+ return;
31
+ e.disableDocumentation || n.push(e);
32
+ const {
33
+ completion: { label: o }
34
+ } = e, s = o.toLowerCase();
35
+ let i = r.get(s);
36
+ i || (i = {
37
+ type: "functionDefinition",
38
+ key: s,
39
+ overloads: []
40
+ }, r.set(s, i)), i.overloads.push(e);
41
+ }
42
+ function L(n, r, t, e) {
43
+ if (!t(e))
44
+ return;
45
+ n.push(e);
46
+ const {
47
+ completion: { label: o }
48
+ } = e, s = o.toLowerCase();
49
+ r.set(s, e);
50
+ const [i, c] = e.completion.label.split(".");
51
+ if (!c)
52
+ return;
53
+ const l = i.toLowerCase();
54
+ let a = r.get(l);
55
+ a || (a = {
56
+ type: "namespace",
57
+ key: l,
58
+ members: [],
59
+ completion: {
60
+ label: i,
61
+ detail: i,
62
+ insertText: i,
63
+ insertTextMode: h.adjustIndentation,
64
+ insertTextFormat: b.PlainText,
65
+ kind: m.Enum
66
+ }
67
+ }, r.set(l, a));
68
+ const u = structuredClone(e);
69
+ u.name = c, u.completion.label = c, u.completion.insertText = c, u.completion.kind = m.Constant, a.members.push(u), a.completion.documentation = a.members.reduce(
70
+ (f, p) => (f.value = `${f.value}${f.value ? `
71
+
72
+ ` : ""}**${p.completion.label}**: ${p.description}`, f),
73
+ { kind: g.Markdown, value: "" }
74
+ );
75
+ }
76
+ function d(n) {
77
+ if (!n || typeof n != "string")
78
+ return null;
79
+ const r = n.split(".").map((o) => Number.parseInt(o));
80
+ if (r.some(Number.isNaN))
81
+ return console.error("Invalid API version string", n), null;
82
+ const [t, e] = r.slice(0, 2);
83
+ return { major: t, minor: e };
84
+ }
85
+ function T(n, r) {
86
+ if (!n)
87
+ return !0;
88
+ const t = d(r);
89
+ return t ? n.major > t.major ? !1 : n.minor === void 0 || t.minor === void 0 ? !0 : t.minor <= n.minor : !0;
90
+ }
91
+ function x(n) {
92
+ return !!n && n.type !== "dictionary";
93
+ }
94
+ function C(n) {
95
+ return n?.type === "dictionary";
96
+ }
97
+ class D {
98
+ constructor(r) {
99
+ this._settings = r, this.localeToApiLibraryPromiseMap = /* @__PURE__ */ new Map();
100
+ }
101
+ /**
102
+ * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
103
+ */
104
+ async getApiDatabase(r) {
105
+ const { locale: t = "en" } = r;
106
+ let e = this.localeToApiLibraryPromiseMap.get(t);
107
+ return e || (e = this._settings.getApiLibrary(t), this.localeToApiLibraryPromiseMap.set(t, e)), await w(e, r);
108
+ }
109
+ /**
110
+ * Returns the API definitions
111
+ */
112
+ async getApiLibrary(r) {
113
+ const { categories: t } = await this.getApiDatabase(r);
114
+ return t;
115
+ }
116
+ }
117
+ export {
118
+ D as ApiService,
119
+ w as filterApiLibraryForContext,
120
+ C as isDictionaryVariable,
121
+ x as isValueVariable
122
+ };
@@ -0,0 +1,117 @@
1
+ import { SdkConstant as ApiConstant, SdkFunction as ApiFunction, SdkVariableType as ApiVariableType, SdkPredefinedProfile, BundleType, ProfileId, SdkCategory, ArcadeSdkPredefinedProfile, SqlSdkPredefinedProfile } from '@arcgis/languages-sdk-spec';
2
+ import { CompletionItem } from 'vscode-languageserver-types';
3
+ export type { ApiConstant, ApiFunction, BundleType };
4
+ /**
5
+ * Represent items stored in the library
6
+ */
7
+ export type ApiItem = ApiConstant | ApiFunction;
8
+ /**
9
+ * Represent a category of api items in the api library
10
+ */
11
+ export interface ApiCategory extends SdkCategory {
12
+ items: ApiItem[];
13
+ }
14
+ export type { ProfileId, ApiVariableType, SdkPredefinedProfile, ArcadeSdkPredefinedProfile, SqlSdkPredefinedProfile };
15
+ /**
16
+ * The editor can be extended with custom snippets
17
+ */
18
+ export interface ApiSnippet {
19
+ /**
20
+ * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
21
+ * It's recommended to keep it short and as close as possible to what the user may be looking for.
22
+ * For example: 'polyline'
23
+ */
24
+ label: string;
25
+ /**
26
+ * A slightly longer description of what the snippet offers.
27
+ */
28
+ detail: string;
29
+ /**
30
+ * A string that should be inserted into the script when selecting
31
+ * this snippet.
32
+ *
33
+ * The `insertText` is subject to interpretation by the editor.
34
+ * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
35
+ */
36
+ insertText: string;
37
+ }
38
+ /**
39
+ * Language service api options
40
+ */
41
+ export interface ApiContext {
42
+ /**
43
+ * The profile (variables, additional api items, bundles, etc.)
44
+ */
45
+ profile?: ApiProfile;
46
+ /**
47
+ * The locale for the Api
48
+ */
49
+ locale?: string;
50
+ /**
51
+ * Allows to augment the language snippets with a collection of snippets
52
+ */
53
+ snippets?: ApiSnippet[];
54
+ }
55
+ /**
56
+ * Language service profile
57
+ */
58
+ export interface ApiProfile {
59
+ /**
60
+ * The wellknown profile id if applicable
61
+ */
62
+ id?: ProfileId;
63
+ /**
64
+ * The set of profile variables
65
+ */
66
+ variables: ApiVariable[];
67
+ /**
68
+ * The api version to use
69
+ */
70
+ apiVersion?: string;
71
+ /**
72
+ * The api bundles to use
73
+ */
74
+ bundles?: BundleType[];
75
+ /**
76
+ * A collection of api item names to hide.
77
+ */
78
+ hiddenApiItems?: string[];
79
+ }
80
+ /**
81
+ * The type for value variable.
82
+ */
83
+ export type ApiValueVariableType = Exclude<ApiVariableType, "dictionary">;
84
+ interface ApiVariableBase {
85
+ /**
86
+ * Name of the variable
87
+ */
88
+ name: string;
89
+ /**
90
+ * Optional short description for the variable
91
+ */
92
+ description?: string;
93
+ /**
94
+ * Completion item for the variable, leveraged bu the editor
95
+ */
96
+ completion?: CompletionItem;
97
+ }
98
+ /**
99
+ * Describes a dictionary type (feature, dictionary)
100
+ */
101
+ export interface ApiDictionaryVariable extends ApiVariableBase {
102
+ type: "dictionary";
103
+ /**
104
+ * Dictionary properties
105
+ */
106
+ properties?: ApiVariable[];
107
+ }
108
+ /**
109
+ * Describes a simple variable type (number, featureSet, etc.)
110
+ */
111
+ export interface ApiValueVariable extends ApiVariableBase {
112
+ type: ApiValueVariableType;
113
+ }
114
+ /**
115
+ * The profile variable type
116
+ */
117
+ export type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
@@ -0,0 +1,117 @@
1
+ import { SdkConstant as ApiConstant, SdkFunction as ApiFunction, SdkVariableType as ApiVariableType, SdkPredefinedProfile, BundleType, ProfileId, SdkCategory, ArcadeSdkPredefinedProfile, SqlSdkPredefinedProfile } from '@arcgis/languages-sdk-spec';
2
+ import { CompletionItem } from 'vscode-languageserver-types';
3
+ export type { ApiConstant, ApiFunction, BundleType };
4
+ /**
5
+ * Represent items stored in the library
6
+ */
7
+ export type ApiItem = ApiConstant | ApiFunction;
8
+ /**
9
+ * Represent a category of api items in the api library
10
+ */
11
+ export interface ApiCategory extends SdkCategory {
12
+ items: ApiItem[];
13
+ }
14
+ export type { ProfileId, ApiVariableType, SdkPredefinedProfile, ArcadeSdkPredefinedProfile, SqlSdkPredefinedProfile };
15
+ /**
16
+ * The editor can be extended with custom snippets
17
+ */
18
+ export interface ApiSnippet {
19
+ /**
20
+ * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
21
+ * It's recommended to keep it short and as close as possible to what the user may be looking for.
22
+ * For example: 'polyline'
23
+ */
24
+ label: string;
25
+ /**
26
+ * A slightly longer description of what the snippet offers.
27
+ */
28
+ detail: string;
29
+ /**
30
+ * A string that should be inserted into the script when selecting
31
+ * this snippet.
32
+ *
33
+ * The `insertText` is subject to interpretation by the editor.
34
+ * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
35
+ */
36
+ insertText: string;
37
+ }
38
+ /**
39
+ * Language service api options
40
+ */
41
+ export interface ApiContext {
42
+ /**
43
+ * The profile (variables, additional api items, bundles, etc.)
44
+ */
45
+ profile?: ApiProfile;
46
+ /**
47
+ * The locale for the Api
48
+ */
49
+ locale?: string;
50
+ /**
51
+ * Allows to augment the language snippets with a collection of snippets
52
+ */
53
+ snippets?: ApiSnippet[];
54
+ }
55
+ /**
56
+ * Language service profile
57
+ */
58
+ export interface ApiProfile {
59
+ /**
60
+ * The wellknown profile id if applicable
61
+ */
62
+ id?: ProfileId;
63
+ /**
64
+ * The set of profile variables
65
+ */
66
+ variables: ApiVariable[];
67
+ /**
68
+ * The api version to use
69
+ */
70
+ apiVersion?: string;
71
+ /**
72
+ * The api bundles to use
73
+ */
74
+ bundles?: BundleType[];
75
+ /**
76
+ * A collection of api item names to hide.
77
+ */
78
+ hiddenApiItems?: string[];
79
+ }
80
+ /**
81
+ * The type for value variable.
82
+ */
83
+ export type ApiValueVariableType = Exclude<ApiVariableType, "dictionary">;
84
+ interface ApiVariableBase {
85
+ /**
86
+ * Name of the variable
87
+ */
88
+ name: string;
89
+ /**
90
+ * Optional short description for the variable
91
+ */
92
+ description?: string;
93
+ /**
94
+ * Completion item for the variable, leveraged bu the editor
95
+ */
96
+ completion?: CompletionItem;
97
+ }
98
+ /**
99
+ * Describes a dictionary type (feature, dictionary)
100
+ */
101
+ export interface ApiDictionaryVariable extends ApiVariableBase {
102
+ type: "dictionary";
103
+ /**
104
+ * Dictionary properties
105
+ */
106
+ properties?: ApiVariable[];
107
+ }
108
+ /**
109
+ * Describes a simple variable type (number, featureSet, etc.)
110
+ */
111
+ export interface ApiValueVariable extends ApiVariableBase {
112
+ type: ApiValueVariableType;
113
+ }
114
+ /**
115
+ * The profile variable type
116
+ */
117
+ export type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
@@ -0,0 +1,36 @@
1
+ import { SdkConstant as ApiConstant, SdkFunction as ApiFunction, SdkCategory } from '@arcgis/languages-sdk-spec';
2
+ import { ApiCategory, ApiContext, ApiDictionaryVariable, ApiValueVariable, ApiVariable } from './types';
3
+ import { CompletionItem } from 'vscode-languageserver-types';
4
+ export interface ApiVersion {
5
+ major: number;
6
+ minor?: number;
7
+ }
8
+ export type ApiConstantNamespace = {
9
+ type: "namespace";
10
+ key: string;
11
+ members: ApiConstant[];
12
+ completion: CompletionItem;
13
+ };
14
+ export type ApiConstantDefinition = ApiConstant | ApiConstantNamespace;
15
+ export type ApiFunctionDefinition = {
16
+ type: "functionDefinition";
17
+ key: string;
18
+ overloads: ApiFunction[];
19
+ };
20
+ /**
21
+ * Describes the API properties
22
+ */
23
+ export interface ApiDatabase {
24
+ categories: ApiCategory[];
25
+ functionDefinitions: Map<string, ApiFunctionDefinition>;
26
+ constantDefinitions: Map<string, ApiConstantDefinition>;
27
+ }
28
+ export declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
29
+ /**
30
+ * Helper function to test if a variable is a value variable
31
+ */
32
+ export declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
33
+ /**
34
+ * Helper function to test if a variable is a dictionary variable
35
+ */
36
+ export declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
@@ -0,0 +1,36 @@
1
+ import { SdkConstant as ApiConstant, SdkFunction as ApiFunction, SdkCategory } from '@arcgis/languages-sdk-spec';
2
+ import { ApiCategory, ApiContext, ApiDictionaryVariable, ApiValueVariable, ApiVariable } from './types';
3
+ import { CompletionItem } from 'vscode-languageserver-types';
4
+ export interface ApiVersion {
5
+ major: number;
6
+ minor?: number;
7
+ }
8
+ export type ApiConstantNamespace = {
9
+ type: "namespace";
10
+ key: string;
11
+ members: ApiConstant[];
12
+ completion: CompletionItem;
13
+ };
14
+ export type ApiConstantDefinition = ApiConstant | ApiConstantNamespace;
15
+ export type ApiFunctionDefinition = {
16
+ type: "functionDefinition";
17
+ key: string;
18
+ overloads: ApiFunction[];
19
+ };
20
+ /**
21
+ * Describes the API properties
22
+ */
23
+ export interface ApiDatabase {
24
+ categories: ApiCategory[];
25
+ functionDefinitions: Map<string, ApiFunctionDefinition>;
26
+ constantDefinitions: Map<string, ApiConstantDefinition>;
27
+ }
28
+ export declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
29
+ /**
30
+ * Helper function to test if a variable is a value variable
31
+ */
32
+ export declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
33
+ /**
34
+ * Helper function to test if a variable is a dictionary variable
35
+ */
36
+ export declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@arcgis/languages-api-utils",
3
- "version": "4.33.0-next.13",
3
+ "version": "4.33.0-next.133",
4
4
  "description": "ArcGIS Languages API Utilities",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",
7
- "main": "dist/esm/index.js",
8
- "module": "dist/esm/index.js",
9
- "types": "dist/esm/index.d.ts",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
10
  "files": [
11
11
  "dist/"
12
12
  ],
13
13
  "license": "SEE LICENSE IN LICENSE.md",
14
14
  "dependencies": {
15
- "tslib": "^2.7.0",
15
+ "@arcgis/languages-sdk-spec": "4.33.0-next.133",
16
+ "tslib": "^2.8.1",
16
17
  "vscode-languageserver-textdocument": "^1.0.11",
17
18
  "vscode-languageserver-types": "^3.17.5"
18
19
  }
@@ -1,3 +0,0 @@
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:()=>y,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=b(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=>g(e,n,i,a));return}o.type==="constant"?F(e,t,i,o):g(e,n,i,o)}function g(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,d)=>(m.value=`${m.value}${m.value?`
2
-
3
- `:""}**${d.completion.label}**: ${d.description}`,m),{kind:s.MarkupKind.Markdown,value:""})}function b(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=b(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 y=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});
@@ -1,347 +0,0 @@
1
- import { CompletionItem } from 'vscode-languageserver-types';
2
-
3
- /**
4
- * Supported function bundles
5
- */
6
- type SqlBundleType = "core";
7
-
8
- /**
9
- * Union of bundle types that can be used in any sdk schema
10
- */
11
- type BundleType = ArcadeBundleType | SqlBundleType;
12
-
13
- /**
14
- * Supported function bundles
15
- */
16
- type ArcadeBundleType = "core" | "data-access" | "database" | "geometry" | "knowledge-graph" | "portal-access" | "track";
17
-
18
- /**
19
- * Describes a profile
20
- */
21
- interface BaseSdkPredefinedProfile<ProfileId extends string, Bundle extends string> {
22
- /**
23
- * Profile name for UI
24
- */
25
- name: string;
26
- /**
27
- * Profile id for docs
28
- */
29
- id: ProfileId;
30
- /**
31
- * Function bundles enabled for this profile
32
- */
33
- bundles: Bundle[];
34
- /**
35
- * Variable describing name, type, and providing description
36
- */
37
- variables: SdkVariable[];
38
- }
39
- /**
40
- * Supported profile variable types
41
- */
42
- type SdkVariableType = "array" | "boolean" | "date" | "dateOnly" | "dictionary" | "feature" | "featureSet" | "featureSetCollection" | "geometry" | "knowledgeGraph" | "number" | "text" | "time" | "voxel";
43
- /**
44
- * Describes variables
45
- */
46
- interface SdkVariableBase {
47
- /**
48
- * Name of the variable.
49
- */
50
- name: string;
51
- /**
52
- * Type of the variable.
53
- */
54
- type: SdkVariableType;
55
- /**
56
- * Description of the variable.
57
- */
58
- description?: string;
59
- }
60
- /**
61
- * A variable that represents a simple type (boolean, number, feature, etc.)
62
- */
63
- interface SdkValueVariable extends SdkVariableBase {
64
- type: Exclude<SdkVariableType, "dictionary">;
65
- }
66
- /**
67
- * A dictionary variable
68
- */
69
- interface SdkDictionaryVariable extends SdkVariableBase {
70
- type: "dictionary";
71
- properties: SdkVariable[];
72
- }
73
- /**
74
- * Profile variable
75
- */
76
- type SdkVariable = SdkDictionaryVariable | SdkValueVariable;
77
-
78
- /**
79
- * The list of supported profiles
80
- */
81
- type ArcadeProfileId = "aggregate-field" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-data" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "data-pipelines" | "dictionary-renderer" | "feature-display-title" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "minimalist" | "model-builder" | "popup-element-feature-reduction" | "popup-element-voxel" | "popup-element" | "popup-feature-reduction" | "popup-voxel" | "popup" | "quick-capture" | "tasks" | "velocity" | "visualization";
82
- /**
83
- * The predefined profiles for the Arcade language
84
- */
85
- type ArcadeSdkPredefinedProfile = BaseSdkPredefinedProfile<ArcadeProfileId, ArcadeBundleType>;
86
-
87
- /**
88
- * The list of supported profiles
89
- */
90
- type SqlProfileId = "field-calculation";
91
- /**
92
- * The predefined profiles for the SQL language
93
- */
94
- type SqlSdkPredefinedProfile = BaseSdkPredefinedProfile<SqlProfileId, SqlBundleType>;
95
-
96
- type SdkPredefinedProfile = ArcadeSdkPredefinedProfile | SqlSdkPredefinedProfile;
97
- /**
98
- * A union of all language profile ids
99
- */
100
- type ProfileId = ArcadeProfileId | SqlProfileId;
101
-
102
- /**
103
- * Represents an api category and its items
104
- */
105
- interface SdkCategory {
106
- /**
107
- * The unique ID for the category
108
- */
109
- id: string;
110
- /**
111
- * The title for the category
112
- */
113
- title: string;
114
- /**
115
- * The collection of api items for the category
116
- */
117
- items: SdkItem[];
118
- }
119
- interface SdkItemBase {
120
- /**
121
- * The name of the function or constant.
122
- */
123
- name: string;
124
- /**
125
- * The version string when the api item was introduced. If undefined then it was from the origin.
126
- */
127
- sinceVersion?: string;
128
- /**
129
- * The api bundle this item belongs to.
130
- */
131
- bundle: BundleType;
132
- /**
133
- * Markdown description of the item.
134
- */
135
- description: string;
136
- /**
137
- * Markdown containing examples.
138
- */
139
- examples: string;
140
- /**
141
- * Link for additional information about the item.
142
- */
143
- link: string;
144
- /**
145
- * Completion item directly leveraged by the editor.
146
- */
147
- completion: CompletionItem;
148
- /**
149
- * Indicates if the documentation for this item should be disabled.
150
- */
151
- disableDocumentation?: boolean;
152
- }
153
- /**
154
- * Represents a constant in the arcade api.
155
- */
156
- interface SdkConstant extends SdkItemBase {
157
- type: "constant";
158
- }
159
- /**
160
- * Represents a function in the arcade api
161
- */
162
- interface SdkFunction extends SdkItemBase {
163
- type: "function";
164
- /**
165
- * Information leveraged by the editor to validate function call.
166
- * Indicates the minimum number of expected parameters and the maximum number of parameters expected.
167
- */
168
- parametersInfo: {
169
- min: number;
170
- max: number;
171
- };
172
- }
173
- /**
174
- * Represents an item in the arcade api.
175
- */
176
- type SdkItem = SdkConstant | SdkFunction | SdkFunction[];
177
-
178
- /**
179
- * Represent items stored in the library
180
- */
181
- type ApiItem = SdkConstant | SdkFunction;
182
- /**
183
- * Represent a category of api items in the api library
184
- */
185
- interface ApiCategory extends SdkCategory {
186
- items: ApiItem[];
187
- }
188
-
189
- /**
190
- * The editor can be extended with custom snippets
191
- */
192
- interface ApiSnippet {
193
- /**
194
- * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
195
- * It's recommended to keep it short and as close as possible to what the user may be looking for.
196
- * For example: 'polyline'
197
- */
198
- label: string;
199
- /**
200
- * A slightly longer description of what the snippet offers.
201
- */
202
- detail: string;
203
- /**
204
- * A string that should be inserted into the script when selecting
205
- * this snippet.
206
- *
207
- * The `insertText` is subject to interpretation by the editor.
208
- * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
209
- */
210
- insertText: string;
211
- }
212
- /**
213
- * Language service api options
214
- */
215
- interface ApiContext {
216
- /**
217
- * The profile (variables, additional api items, bundles, etc.)
218
- */
219
- profile?: ApiProfile;
220
- /**
221
- * The locale for the Api
222
- */
223
- locale?: string;
224
- /**
225
- * Allows to augment the language snippets with a collection of snippets
226
- */
227
- snippets?: ApiSnippet[];
228
- }
229
- /**
230
- * Language service profile
231
- */
232
- interface ApiProfile {
233
- /**
234
- * The wellknown profile id if applicable
235
- */
236
- id?: ProfileId;
237
- /**
238
- * The set of profile variables
239
- */
240
- variables: ApiVariable[];
241
- /**
242
- * The api version to use
243
- */
244
- apiVersion?: string;
245
- /**
246
- * The api bundles to use
247
- */
248
- bundles?: BundleType[];
249
- /**
250
- * A collection of api item names to hide.
251
- */
252
- hiddenApiItems?: string[];
253
- }
254
- /**
255
- * The type for value variable.
256
- */
257
- type ApiValueVariableType = Exclude<SdkVariableType, "dictionary">;
258
- interface ApiVariableBase {
259
- /**
260
- * Name of the variable
261
- */
262
- name: string;
263
- /**
264
- * Optional short description for the variable
265
- */
266
- description?: string;
267
- /**
268
- * Completion item for the variable, leveraged bu the editor
269
- */
270
- completion?: CompletionItem;
271
- }
272
- /**
273
- * Describes a dictionary type (feature, dictionary)
274
- */
275
- interface ApiDictionaryVariable extends ApiVariableBase {
276
- type: "dictionary";
277
- /**
278
- * Dictionary properties
279
- */
280
- properties?: ApiVariable[];
281
- }
282
- /**
283
- * Describes a simple variable type (number, featureSet, etc.)
284
- */
285
- interface ApiValueVariable extends ApiVariableBase {
286
- type: ApiValueVariableType;
287
- }
288
- /**
289
- * The profile variable type
290
- */
291
- type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
292
-
293
- interface ApiVersion {
294
- major: number;
295
- minor?: number;
296
- }
297
- type ApiConstantNamespace = {
298
- type: "namespace";
299
- key: string;
300
- members: SdkConstant[];
301
- completion: CompletionItem;
302
- };
303
- type ApiConstantDefinition = SdkConstant | ApiConstantNamespace;
304
- type ApiFunctionDefinition = {
305
- type: "functionDefinition";
306
- key: string;
307
- overloads: SdkFunction[];
308
- };
309
- /**
310
- * Describes the API properties
311
- */
312
- interface ApiDatabase {
313
- categories: ApiCategory[];
314
- functionDefinitions: Map<string, ApiFunctionDefinition>;
315
- constantDefinitions: Map<string, ApiConstantDefinition>;
316
- }
317
- declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
318
- /**
319
- * Helper function to test if a variable is a value variable
320
- */
321
- declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
322
- /**
323
- * Helper function to test if a variable is a dictionary variable
324
- */
325
- declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
326
-
327
- /**
328
- * Language service settings
329
- */
330
- interface LanguageServiceSettings {
331
- getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
332
- }
333
- declare class ApiService<TApiContext extends ApiContext = ApiContext> {
334
- private _settings;
335
- private localeToApiLibraryPromiseMap;
336
- constructor(_settings: LanguageServiceSettings);
337
- /**
338
- * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
339
- */
340
- getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
341
- /**
342
- * Returns the API definitions
343
- */
344
- getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
345
- }
346
-
347
- 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 ArcadeSdkPredefinedProfile, type BundleType, type LanguageServiceSettings, type ProfileId, type SdkPredefinedProfile, type SqlSdkPredefinedProfile, filterApiLibraryForContext, isDictionaryVariable, isValueVariable };
@@ -1,347 +0,0 @@
1
- import { CompletionItem } from 'vscode-languageserver-types';
2
-
3
- /**
4
- * Supported function bundles
5
- */
6
- type SqlBundleType = "core";
7
-
8
- /**
9
- * Union of bundle types that can be used in any sdk schema
10
- */
11
- type BundleType = ArcadeBundleType | SqlBundleType;
12
-
13
- /**
14
- * Supported function bundles
15
- */
16
- type ArcadeBundleType = "core" | "data-access" | "database" | "geometry" | "knowledge-graph" | "portal-access" | "track";
17
-
18
- /**
19
- * Describes a profile
20
- */
21
- interface BaseSdkPredefinedProfile<ProfileId extends string, Bundle extends string> {
22
- /**
23
- * Profile name for UI
24
- */
25
- name: string;
26
- /**
27
- * Profile id for docs
28
- */
29
- id: ProfileId;
30
- /**
31
- * Function bundles enabled for this profile
32
- */
33
- bundles: Bundle[];
34
- /**
35
- * Variable describing name, type, and providing description
36
- */
37
- variables: SdkVariable[];
38
- }
39
- /**
40
- * Supported profile variable types
41
- */
42
- type SdkVariableType = "array" | "boolean" | "date" | "dateOnly" | "dictionary" | "feature" | "featureSet" | "featureSetCollection" | "geometry" | "knowledgeGraph" | "number" | "text" | "time" | "voxel";
43
- /**
44
- * Describes variables
45
- */
46
- interface SdkVariableBase {
47
- /**
48
- * Name of the variable.
49
- */
50
- name: string;
51
- /**
52
- * Type of the variable.
53
- */
54
- type: SdkVariableType;
55
- /**
56
- * Description of the variable.
57
- */
58
- description?: string;
59
- }
60
- /**
61
- * A variable that represents a simple type (boolean, number, feature, etc.)
62
- */
63
- interface SdkValueVariable extends SdkVariableBase {
64
- type: Exclude<SdkVariableType, "dictionary">;
65
- }
66
- /**
67
- * A dictionary variable
68
- */
69
- interface SdkDictionaryVariable extends SdkVariableBase {
70
- type: "dictionary";
71
- properties: SdkVariable[];
72
- }
73
- /**
74
- * Profile variable
75
- */
76
- type SdkVariable = SdkDictionaryVariable | SdkValueVariable;
77
-
78
- /**
79
- * The list of supported profiles
80
- */
81
- type ArcadeProfileId = "aggregate-field" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-data" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "data-pipelines" | "dictionary-renderer" | "feature-display-title" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "minimalist" | "model-builder" | "popup-element-feature-reduction" | "popup-element-voxel" | "popup-element" | "popup-feature-reduction" | "popup-voxel" | "popup" | "quick-capture" | "tasks" | "velocity" | "visualization";
82
- /**
83
- * The predefined profiles for the Arcade language
84
- */
85
- type ArcadeSdkPredefinedProfile = BaseSdkPredefinedProfile<ArcadeProfileId, ArcadeBundleType>;
86
-
87
- /**
88
- * The list of supported profiles
89
- */
90
- type SqlProfileId = "field-calculation";
91
- /**
92
- * The predefined profiles for the SQL language
93
- */
94
- type SqlSdkPredefinedProfile = BaseSdkPredefinedProfile<SqlProfileId, SqlBundleType>;
95
-
96
- type SdkPredefinedProfile = ArcadeSdkPredefinedProfile | SqlSdkPredefinedProfile;
97
- /**
98
- * A union of all language profile ids
99
- */
100
- type ProfileId = ArcadeProfileId | SqlProfileId;
101
-
102
- /**
103
- * Represents an api category and its items
104
- */
105
- interface SdkCategory {
106
- /**
107
- * The unique ID for the category
108
- */
109
- id: string;
110
- /**
111
- * The title for the category
112
- */
113
- title: string;
114
- /**
115
- * The collection of api items for the category
116
- */
117
- items: SdkItem[];
118
- }
119
- interface SdkItemBase {
120
- /**
121
- * The name of the function or constant.
122
- */
123
- name: string;
124
- /**
125
- * The version string when the api item was introduced. If undefined then it was from the origin.
126
- */
127
- sinceVersion?: string;
128
- /**
129
- * The api bundle this item belongs to.
130
- */
131
- bundle: BundleType;
132
- /**
133
- * Markdown description of the item.
134
- */
135
- description: string;
136
- /**
137
- * Markdown containing examples.
138
- */
139
- examples: string;
140
- /**
141
- * Link for additional information about the item.
142
- */
143
- link: string;
144
- /**
145
- * Completion item directly leveraged by the editor.
146
- */
147
- completion: CompletionItem;
148
- /**
149
- * Indicates if the documentation for this item should be disabled.
150
- */
151
- disableDocumentation?: boolean;
152
- }
153
- /**
154
- * Represents a constant in the arcade api.
155
- */
156
- interface SdkConstant extends SdkItemBase {
157
- type: "constant";
158
- }
159
- /**
160
- * Represents a function in the arcade api
161
- */
162
- interface SdkFunction extends SdkItemBase {
163
- type: "function";
164
- /**
165
- * Information leveraged by the editor to validate function call.
166
- * Indicates the minimum number of expected parameters and the maximum number of parameters expected.
167
- */
168
- parametersInfo: {
169
- min: number;
170
- max: number;
171
- };
172
- }
173
- /**
174
- * Represents an item in the arcade api.
175
- */
176
- type SdkItem = SdkConstant | SdkFunction | SdkFunction[];
177
-
178
- /**
179
- * Represent items stored in the library
180
- */
181
- type ApiItem = SdkConstant | SdkFunction;
182
- /**
183
- * Represent a category of api items in the api library
184
- */
185
- interface ApiCategory extends SdkCategory {
186
- items: ApiItem[];
187
- }
188
-
189
- /**
190
- * The editor can be extended with custom snippets
191
- */
192
- interface ApiSnippet {
193
- /**
194
- * The label for the snippet. The editor will use it to offer the snippet based on the text typed in the editor.
195
- * It's recommended to keep it short and as close as possible to what the user may be looking for.
196
- * For example: 'polyline'
197
- */
198
- label: string;
199
- /**
200
- * A slightly longer description of what the snippet offers.
201
- */
202
- detail: string;
203
- /**
204
- * A string that should be inserted into the script when selecting
205
- * this snippet.
206
- *
207
- * The `insertText` is subject to interpretation by the editor.
208
- * Use this rules: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#snippet_syntax
209
- */
210
- insertText: string;
211
- }
212
- /**
213
- * Language service api options
214
- */
215
- interface ApiContext {
216
- /**
217
- * The profile (variables, additional api items, bundles, etc.)
218
- */
219
- profile?: ApiProfile;
220
- /**
221
- * The locale for the Api
222
- */
223
- locale?: string;
224
- /**
225
- * Allows to augment the language snippets with a collection of snippets
226
- */
227
- snippets?: ApiSnippet[];
228
- }
229
- /**
230
- * Language service profile
231
- */
232
- interface ApiProfile {
233
- /**
234
- * The wellknown profile id if applicable
235
- */
236
- id?: ProfileId;
237
- /**
238
- * The set of profile variables
239
- */
240
- variables: ApiVariable[];
241
- /**
242
- * The api version to use
243
- */
244
- apiVersion?: string;
245
- /**
246
- * The api bundles to use
247
- */
248
- bundles?: BundleType[];
249
- /**
250
- * A collection of api item names to hide.
251
- */
252
- hiddenApiItems?: string[];
253
- }
254
- /**
255
- * The type for value variable.
256
- */
257
- type ApiValueVariableType = Exclude<SdkVariableType, "dictionary">;
258
- interface ApiVariableBase {
259
- /**
260
- * Name of the variable
261
- */
262
- name: string;
263
- /**
264
- * Optional short description for the variable
265
- */
266
- description?: string;
267
- /**
268
- * Completion item for the variable, leveraged bu the editor
269
- */
270
- completion?: CompletionItem;
271
- }
272
- /**
273
- * Describes a dictionary type (feature, dictionary)
274
- */
275
- interface ApiDictionaryVariable extends ApiVariableBase {
276
- type: "dictionary";
277
- /**
278
- * Dictionary properties
279
- */
280
- properties?: ApiVariable[];
281
- }
282
- /**
283
- * Describes a simple variable type (number, featureSet, etc.)
284
- */
285
- interface ApiValueVariable extends ApiVariableBase {
286
- type: ApiValueVariableType;
287
- }
288
- /**
289
- * The profile variable type
290
- */
291
- type ApiVariable = ApiDictionaryVariable | ApiValueVariable;
292
-
293
- interface ApiVersion {
294
- major: number;
295
- minor?: number;
296
- }
297
- type ApiConstantNamespace = {
298
- type: "namespace";
299
- key: string;
300
- members: SdkConstant[];
301
- completion: CompletionItem;
302
- };
303
- type ApiConstantDefinition = SdkConstant | ApiConstantNamespace;
304
- type ApiFunctionDefinition = {
305
- type: "functionDefinition";
306
- key: string;
307
- overloads: SdkFunction[];
308
- };
309
- /**
310
- * Describes the API properties
311
- */
312
- interface ApiDatabase {
313
- categories: ApiCategory[];
314
- functionDefinitions: Map<string, ApiFunctionDefinition>;
315
- constantDefinitions: Map<string, ApiConstantDefinition>;
316
- }
317
- declare function filterApiLibraryForContext(apiLibraryPromise: Promise<SdkCategory[]>, context: ApiContext): Promise<ApiDatabase>;
318
- /**
319
- * Helper function to test if a variable is a value variable
320
- */
321
- declare function isValueVariable(variable: ApiVariable | null | undefined): variable is ApiValueVariable;
322
- /**
323
- * Helper function to test if a variable is a dictionary variable
324
- */
325
- declare function isDictionaryVariable(variable: ApiVariable | null | undefined): variable is ApiDictionaryVariable;
326
-
327
- /**
328
- * Language service settings
329
- */
330
- interface LanguageServiceSettings {
331
- getApiLibrary: (locale: string) => Promise<ApiCategory[]>;
332
- }
333
- declare class ApiService<TApiContext extends ApiContext = ApiContext> {
334
- private _settings;
335
- private localeToApiLibraryPromiseMap;
336
- constructor(_settings: LanguageServiceSettings);
337
- /**
338
- * Returns the API definitions for the given settings: definitions, constant definitions, and function definitions
339
- */
340
- getApiDatabase(context: TApiContext): Promise<ApiDatabase>;
341
- /**
342
- * Returns the API definitions
343
- */
344
- getApiLibrary(context: TApiContext): Promise<ApiCategory[]>;
345
- }
346
-
347
- 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 ArcadeSdkPredefinedProfile, type BundleType, type LanguageServiceSettings, type ProfileId, type SdkPredefinedProfile, type SqlSdkPredefinedProfile, filterApiLibraryForContext, isDictionaryVariable, isValueVariable };
package/dist/esm/index.js DELETED
@@ -1,3 +0,0 @@
1
- import{CompletionItemKind as f,InsertTextFormat as b,InsertTextMode as C,MarkupKind as x}from"vscode-languageserver-types";async function y(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=d(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:b.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 d(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=d(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 g=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 y(e,i)}async getApiLibrary(i){let{categories:n}=await this.getApiDatabase(i);return n}};export{g as ApiService,y as filterApiLibraryForContext,F as isDictionaryVariable,v as isValueVariable};