@knime/scripting-editor 0.0.116 → 0.0.118

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.
@@ -1,32 +1,33 @@
1
- import { l as r } from "./log-BmIREpQ5.js";
2
- function c(i) {
3
- return new Promise((n) => setTimeout(n, i));
1
+ import { l as i } from "./log-BmIREpQ5.js";
2
+ function l(r) {
3
+ return new Promise((s) => setTimeout(s, r));
4
4
  }
5
- const l = 100, a = 2e3, g = (i, ...n) => {
6
- typeof consola > "u" ? console.error(i, ...n) : consola.error(i, ...n);
7
- }, u = (i) => {
8
- let n = 498;
5
+ const a = 100, c = 2e3, u = (r, ...s) => {
6
+ typeof consola > "u" ? console.error(r, ...s) : consola.error(r, ...s);
7
+ }, g = (r) => {
8
+ let s = 498;
9
9
  const t = /* @__PURE__ */ new Map(), o = {
10
10
  suggestCode: async () => {
11
- await c(a);
11
+ await l(c);
12
12
  const e = t.get("codeSuggestion");
13
13
  return typeof e < "u" && e({
14
14
  status: "SUCCESS",
15
- code: JSON.stringify({
15
+ error: null,
16
+ response: {
16
17
  code: "// THIS IS A FAKE AI SUGGESTION",
17
- interactionId: "mock-interaction-id",
18
- usage: {
18
+ updatedUsage: {
19
+ type: "LIMITED",
19
20
  limit: 500,
20
- used: n++
21
+ used: ++s
21
22
  }
22
- })
23
+ }
23
24
  }), {};
24
25
  },
25
26
  abortSuggestCodeRequest: () => Promise.resolve()
26
27
  };
27
28
  return {
28
- async sendToService(e, s) {
29
- return r(`Called scriptingService.sendToService("${e}")`, s), await c(l), i.sendToServiceMockResponses && e in i.sendToServiceMockResponses ? i.sendToServiceMockResponses[e](...s ?? []) : e in o ? o[e](...s ?? []) : (g(
29
+ async sendToService(e, n) {
30
+ return i(`Called scriptingService.sendToService("${e}")`, n), await l(a), r.sendToServiceMockResponses && e in r.sendToServiceMockResponses ? r.sendToServiceMockResponses[e](...n ?? []) : e in o ? o[e](...n ?? []) : (u(
30
31
  `${e} not implemented in sendToServiceMockResponses.
31
32
  Returning undefined.`
32
33
  ), Promise.resolve());
@@ -36,40 +37,46 @@ const l = 100, a = 2e3, g = (i, ...n) => {
36
37
  },
37
38
  // Settings and dialog window
38
39
  isCallKnimeUiApiAvailable() {
39
- return r("Called scriptingService.isCallKnimeUiApiAvailable"), Promise.resolve(!1);
40
+ return i("Called scriptingService.isCallKnimeUiApiAvailable"), Promise.resolve(!1);
40
41
  },
41
42
  isKaiEnabled() {
42
- return r("Called scriptingService.isKaiEnabled"), Promise.resolve(!0);
43
+ return i("Called scriptingService.isKaiEnabled"), Promise.resolve(!0);
43
44
  },
44
45
  isLoggedIntoHub() {
45
- return r("Called scriptingService.isLoggedIntoHub"), Promise.resolve(!0);
46
+ return i("Called scriptingService.isLoggedIntoHub"), Promise.resolve(!0);
46
47
  },
47
48
  // Event handler
48
- registerEventHandler(e, s) {
49
- r("Called scriptingService.registerEventHandler", e), t.set(e, s);
49
+ registerEventHandler(e, n) {
50
+ i("Called scriptingService.registerEventHandler", e), t.set(e, n);
50
51
  },
51
52
  // Language server
52
53
  connectToLanguageServer() {
53
- return r("Called scriptingService.connectToLanguageServer"), Promise.reject(new Error("No language server in mock"));
54
+ return i("Called scriptingService.connectToLanguageServer"), Promise.reject(new Error("No language server in mock"));
54
55
  },
55
56
  getAiDisclaimer() {
56
- return r("Called scriptingService.getAiDisclaimer"), Promise.resolve(
57
+ return i("Called scriptingService.getAiDisclaimer"), Promise.resolve(
57
58
  "This is a fake AI disclaimer. Enjoy the AI. It does nothing!"
58
59
  );
59
60
  },
60
61
  getAiUsage() {
61
- return r("Called scriptingService.getAiUsage"), Promise.resolve({
62
- limit: 500,
63
- used: n
64
- });
62
+ return i("Called scriptingService.getAiUsage"), Promise.resolve(
63
+ r.unlicensedKaiUser ? {
64
+ type: "UNLICENSED",
65
+ message: "You need a KNIME Hub team license to use AI features. Please contact your team administrator or upgrade your plan."
66
+ } : {
67
+ type: "LIMITED",
68
+ limit: 500,
69
+ used: s
70
+ }
71
+ );
65
72
  },
66
73
  sendAlert(e) {
67
- r("Called scriptingService.sendAlert", e);
74
+ i("Called scriptingService.sendAlert", e);
68
75
  },
69
76
  // Console handling
70
77
  eventHandlers: t
71
78
  };
72
79
  };
73
80
  export {
74
- u as createScriptingServiceMock
81
+ g as createScriptingServiceMock
75
82
  };
@@ -1,3 +1,4 @@
1
+ import { UsageData } from '../../scripting-service';
1
2
  /**
2
3
  * Content for the popup that contains the prompt for the KAi, as well as holding the components
3
4
  * that show the diff and disclaimer.
@@ -12,3 +13,16 @@ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import
12
13
  abortButton: any;
13
14
  }, HTMLDivElement>;
14
15
  export default _default;
16
+ type CodeRequestResponse = {
17
+ code: string;
18
+ updatedUsage: UsageData;
19
+ };
20
+ export type CodeSuggestion = {
21
+ response: null;
22
+ status: "ERROR" | "CANCELLED";
23
+ error: string;
24
+ } | {
25
+ response: CodeRequestResponse;
26
+ status: "SUCCESS";
27
+ error: null;
28
+ };
@@ -1,6 +1,7 @@
1
1
  import { ScriptingServiceType } from './scripting-service';
2
2
  export type ScriptingServiceMockOptions = {
3
3
  sendToServiceMockResponses?: Record<string, (...options: any) => Promise<any>>;
4
+ unlicensedKaiUser?: boolean;
4
5
  };
5
6
  export declare const createScriptingServiceMock: (opt: ScriptingServiceMockOptions) => ScriptingServiceType & {
6
7
  eventHandlers: Map<string, (args: any) => void>;
@@ -2,10 +2,28 @@ import { AlertParams, AlertingService, JsonDataService } from '@knime/ui-extensi
2
2
  import { PortConfig } from './initial-data-service';
3
3
  import { MonacoLSPConnection } from './lsp/connection';
4
4
  import { PublicAPI } from './types/public-api';
5
- export type UsageData = {
6
- limit: number | null;
5
+ type UnknownUsageData = {
6
+ type: "UNKNOWN";
7
+ };
8
+ type LimitedUsageData = {
9
+ type: "LIMITED";
10
+ limit: number;
7
11
  used: number;
8
12
  };
13
+ type UnlimitedUsageData = {
14
+ type: "UNLIMITED";
15
+ };
16
+ type UnlicensedUsageData = {
17
+ type: "UNLICENSED";
18
+ message: string;
19
+ };
20
+ /**
21
+ * Usage data for K-AI interactions.
22
+ *
23
+ * This type must match the JSON serialization of the Java type
24
+ * `org.knime.core.webui.node.dialog.scripting.kai.CodeKaiHandler.KaiUsage`.
25
+ */
26
+ export type UsageData = UnknownUsageData | LimitedUsageData | UnlimitedUsageData | UnlicensedUsageData;
9
27
  export declare class ScriptingService {
10
28
  private readonly jsonDataService;
11
29
  private readonly alertingService;
@@ -32,8 +50,9 @@ export declare class ScriptingService {
32
50
  isKaiEnabled(): Promise<boolean>;
33
51
  isLoggedIntoHub(): Promise<boolean>;
34
52
  getAiDisclaimer(): Promise<string>;
35
- getAiUsage(): Promise<UsageData | null>;
53
+ getAiUsage(): Promise<UsageData>;
36
54
  sendAlert(alert: AlertParams): void;
37
55
  }
38
56
  /** Type representing the public API of ScriptingService */
39
57
  export type ScriptingServiceType = PublicAPI<ScriptingService>;
58
+ export {};
@@ -20,9 +20,25 @@ export declare const activeEditorStore: import('vue').ShallowRef<UseCodeEditorRe
20
20
  export declare const setActiveEditorStoreForAi: (store: UseCodeEditorReturn | undefined) => void;
21
21
  export declare const currentInputOutputItems: Ref<InputOutputModel[]>;
22
22
  export declare const usageData: Ref<{
23
- limit: number | null;
23
+ type: "UNKNOWN";
24
+ } | {
25
+ type: "LIMITED";
26
+ limit: number;
24
27
  used: number;
25
- } | null, UsageData | {
26
- limit: number | null;
28
+ } | {
29
+ type: "UNLIMITED";
30
+ } | {
31
+ type: "UNLICENSED";
32
+ message: string;
33
+ }, UsageData | {
34
+ type: "UNKNOWN";
35
+ } | {
36
+ type: "LIMITED";
37
+ limit: number;
27
38
  used: number;
28
- } | null>;
39
+ } | {
40
+ type: "UNLIMITED";
41
+ } | {
42
+ type: "UNLICENSED";
43
+ message: string;
44
+ }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knime/scripting-editor",
3
3
  "type": "module",
4
- "version": "0.0.116",
4
+ "version": "0.0.118",
5
5
  "description": "Shared Scripting Editor components for KNIME",
6
6
  "repository": {
7
7
  "type": "git",
@@ -10,27 +10,9 @@
10
10
  },
11
11
  "author": "KNIME AG, Zurich, Switzerland",
12
12
  "license": "See the file license.txt",
13
- "scripts": {
14
- "build": "run-p type-check build-only",
15
- "build-only": "vite build",
16
- "build-watch": "vite build --minify=false --watch",
17
- "demo": "vite --config vite.demo.config.ts",
18
- "test:unit": "vitest",
19
- "type-check": "vue-tsc -p tsconfig.vitest.json",
20
- "format": "prettier --cache --write .",
21
- "format:check": "prettier --cache --check .",
22
- "lint": "run-p 'lint:* -- --fix'",
23
- "lint:js": "eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts",
24
- "lint:css": "stylelint --cache '**/*.{css,vue}'",
25
- "ci:lint-format": "run-p ci:lint:* format:check -c",
26
- "ci:lint:js": "npm run lint:js && npm run lint:js -- -f json -o test-results/eslint.json",
27
- "ci:lint:css": "npm run lint:css -- -f json -o test-results/stylelint.json",
28
- "coverage": "vitest run --coverage",
29
- "postinstall": "license-check -c"
30
- },
31
13
  "dependencies": {
32
- "@knime/kds-components": "catalog:",
33
- "@knime/kds-styles": "catalog:",
14
+ "@knime/kds-components": "0.4.0",
15
+ "@knime/kds-styles": "0.4.0",
34
16
  "@knime/styles": "1.15.0",
35
17
  "@knime/ui-extension-renderer": "2.4.0",
36
18
  "@knime/utils": "1.8.0",
@@ -75,14 +57,14 @@
75
57
  "vite-plugin-dts": "4.5.4",
76
58
  "vite-svg-loader": "5.1.0",
77
59
  "vitest": "2.1.9",
78
- "vue": "catalog:",
60
+ "vue": "3.5.18",
79
61
  "vue-tsc": "3.0.4"
80
62
  },
81
63
  "peerDependencies": {
82
64
  "@knime/components": "1.43.0",
83
65
  "@knime/ui-extension-service": "2.6.0",
84
66
  "monaco-editor": "0.45.x",
85
- "vue": "catalog:"
67
+ "vue": "3.5.18"
86
68
  },
87
69
  "files": [
88
70
  "dist"
@@ -99,5 +81,23 @@
99
81
  },
100
82
  "engines": {
101
83
  "node": "24.x"
84
+ },
85
+ "scripts": {
86
+ "build": "run-p type-check build-only",
87
+ "build-only": "vite build",
88
+ "build-watch": "vite build --minify=false --watch",
89
+ "demo": "vite --config vite.demo.config.ts",
90
+ "test:unit": "vitest",
91
+ "type-check": "vue-tsc -p tsconfig.vitest.json",
92
+ "format": "prettier --cache --write .",
93
+ "format:check": "prettier --cache --check .",
94
+ "lint": "run-p 'lint:* -- --fix'",
95
+ "lint:js": "eslint . --cache --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts",
96
+ "lint:css": "stylelint --cache '**/*.{css,vue}'",
97
+ "ci:lint-format": "run-p ci:lint:* format:check -c",
98
+ "ci:lint:js": "npm run lint:js && npm run lint:js -- -f json -o test-results/eslint.json",
99
+ "ci:lint:css": "npm run lint:css -- -f json -o test-results/stylelint.json",
100
+ "coverage": "vitest run --coverage",
101
+ "postinstall": "license-check -c"
102
102
  }
103
- }
103
+ }