applescript-node 1.0.1
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 +21 -0
- package/README.md +441 -0
- package/dist/builder-utils.d.ts +19 -0
- package/dist/builder.d.ts +725 -0
- package/dist/compiler.d.ts +15 -0
- package/dist/decompiler.d.ts +6 -0
- package/dist/executor.d.ts +97 -0
- package/dist/expressions.d.ts +252 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +3220 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/languages.d.ts +61 -0
- package/dist/loader.d.ts +24 -0
- package/dist/sdef.d.ts +50 -0
- package/dist/sources/applications.d.ts +102 -0
- package/dist/sources/index.d.ts +29 -0
- package/dist/sources/system.d.ts +178 -0
- package/dist/sources/windows.d.ts +61 -0
- package/dist/types.d.ts +787 -0
- package/dist/validator.d.ts +106 -0
- package/package.json +130 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ApplicationDictionary, Class, Command } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validation severity levels
|
|
4
|
+
*/
|
|
5
|
+
export type ValidationSeverity = 'error' | 'warning' | 'info';
|
|
6
|
+
/**
|
|
7
|
+
* Validation issue found in a script
|
|
8
|
+
*/
|
|
9
|
+
export interface ValidationIssue {
|
|
10
|
+
severity: ValidationSeverity;
|
|
11
|
+
message: string;
|
|
12
|
+
line?: number;
|
|
13
|
+
column?: number;
|
|
14
|
+
code?: string;
|
|
15
|
+
suggestion?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result of script validation
|
|
19
|
+
*/
|
|
20
|
+
export interface ValidationResult {
|
|
21
|
+
valid: boolean;
|
|
22
|
+
issues: ValidationIssue[];
|
|
23
|
+
errors: ValidationIssue[];
|
|
24
|
+
warnings: ValidationIssue[];
|
|
25
|
+
info: ValidationIssue[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for script validation
|
|
29
|
+
*/
|
|
30
|
+
export interface ValidationOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Strictness level for validation
|
|
33
|
+
* - 'strict': Treat warnings as errors
|
|
34
|
+
* - 'normal': Standard validation (default)
|
|
35
|
+
* - 'lenient': Only report errors, skip warnings
|
|
36
|
+
*/
|
|
37
|
+
strictness?: 'strict' | 'normal' | 'lenient';
|
|
38
|
+
/**
|
|
39
|
+
* Whether to provide suggestions for fixes
|
|
40
|
+
*/
|
|
41
|
+
provideSuggestions?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Custom dictionary to validate against (otherwise fetched from appPath)
|
|
44
|
+
*/
|
|
45
|
+
dictionary?: ApplicationDictionary;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Script validator for AppleScript validation against application sdef
|
|
49
|
+
*/
|
|
50
|
+
export declare class ScriptValidator {
|
|
51
|
+
private dictionary;
|
|
52
|
+
private appName;
|
|
53
|
+
constructor(dictionary: ApplicationDictionary, appName: string);
|
|
54
|
+
/**
|
|
55
|
+
* Create a validator for a specific application
|
|
56
|
+
*/
|
|
57
|
+
static forApplication(appPath: string): Promise<ScriptValidator>;
|
|
58
|
+
/**
|
|
59
|
+
* Validate a script string
|
|
60
|
+
*/
|
|
61
|
+
validate(script: string, options?: ValidationOptions): ValidationResult;
|
|
62
|
+
/**
|
|
63
|
+
* Extract tell application blocks from script
|
|
64
|
+
*/
|
|
65
|
+
private extractTellBlocks;
|
|
66
|
+
/**
|
|
67
|
+
* Validate commands in script content
|
|
68
|
+
*/
|
|
69
|
+
private validateCommands;
|
|
70
|
+
/**
|
|
71
|
+
* Validate property access in script content
|
|
72
|
+
*/
|
|
73
|
+
private validateProperties;
|
|
74
|
+
/**
|
|
75
|
+
* Find a read-only property by name across all classes
|
|
76
|
+
*/
|
|
77
|
+
private findReadOnlyProperty;
|
|
78
|
+
/**
|
|
79
|
+
* Suggest a similar command name using string similarity
|
|
80
|
+
*/
|
|
81
|
+
private suggestSimilarCommand;
|
|
82
|
+
/**
|
|
83
|
+
* Calculate Levenshtein distance between two strings
|
|
84
|
+
*/
|
|
85
|
+
private levenshteinDistance;
|
|
86
|
+
/**
|
|
87
|
+
* Validate a command and its parameters
|
|
88
|
+
*/
|
|
89
|
+
validateCommand(commandName: string, parameters?: Record<string, unknown>): ValidationIssue[];
|
|
90
|
+
/**
|
|
91
|
+
* Validate property access on a class
|
|
92
|
+
*/
|
|
93
|
+
validatePropertyAccess(className: string, propertyName: string, accessType: 'read' | 'write'): ValidationIssue[];
|
|
94
|
+
/**
|
|
95
|
+
* Get all available commands in the application
|
|
96
|
+
*/
|
|
97
|
+
getAvailableCommands(): Command[];
|
|
98
|
+
/**
|
|
99
|
+
* Get all available classes in the application
|
|
100
|
+
*/
|
|
101
|
+
getAvailableClasses(): Class[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Quick validation helper function
|
|
105
|
+
*/
|
|
106
|
+
export declare function validateScript(script: string, appPath: string, options?: ValidationOptions): Promise<ValidationResult>;
|
package/package.json
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "applescript-node",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Node.js library for AppleScript integration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"imports": {
|
|
13
|
+
"applescript-node": "./src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
|
17
|
+
"build:js": "tsup",
|
|
18
|
+
"build:types": "rm -f tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
19
|
+
"build:types:staged": "tsc --noEmit --skipLibCheck",
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"lint": "tsc --noEmit && eslint .",
|
|
22
|
+
"format": "prettier --write \"**/*.{ts,js,json}\"",
|
|
23
|
+
"format:fix": "prettier --write \"**/*.{ts,js,json}\" && eslint . --fix",
|
|
24
|
+
"clean": "rm -rf dist",
|
|
25
|
+
"prepublishOnly": "pnpm run build",
|
|
26
|
+
"pretest": "pnpm run lint",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest watch",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"example:basic": "tsx --tsconfig examples/tsconfig.json examples/basic-script.ts",
|
|
31
|
+
"example:builder": "tsx --tsconfig examples/tsconfig.json examples/fluent-builder.ts",
|
|
32
|
+
"example:compile": "tsx --tsconfig examples/tsconfig.json examples/script-compilation.ts",
|
|
33
|
+
"example:languages": "tsx --tsconfig examples/tsconfig.json examples/language-info.ts",
|
|
34
|
+
"example:decompile": "tsx --tsconfig examples/tsconfig.json examples/script-decompilation.ts",
|
|
35
|
+
"example:list-apps": "tsx --tsconfig examples/tsconfig.json examples/list-applications.ts",
|
|
36
|
+
"example:windows": "tsx --tsconfig examples/tsconfig.json examples/window-management.ts",
|
|
37
|
+
"example:messages": "tsx --tsconfig examples/tsconfig.json examples/messages-reader.ts",
|
|
38
|
+
"example:notes": "tsx --tsconfig examples/tsconfig.json examples/notes-automation.ts",
|
|
39
|
+
"example:notes-create": "tsx --tsconfig examples/tsconfig.json examples/notes-creation.ts",
|
|
40
|
+
"example:notes-json": "tsx --tsconfig examples/tsconfig.json examples/notes-latest-json.ts",
|
|
41
|
+
"example:contacts": "tsx --tsconfig examples/tsconfig.json examples/contacts-automation.ts",
|
|
42
|
+
"example:contacts-search": "tsx --tsconfig examples/tsconfig.json examples/contacts-search.ts",
|
|
43
|
+
"example:sdef": "tsx --tsconfig examples/tsconfig.json examples/sdef-introspection.ts",
|
|
44
|
+
"example:validation": "tsx --tsconfig examples/tsconfig.json examples/script-validation.ts",
|
|
45
|
+
"example:sources": "tsx --tsconfig examples/tsconfig.json examples/sources-demo.ts",
|
|
46
|
+
"example:ternary": "tsx --tsconfig examples/tsconfig.json examples/ternary-demo.ts",
|
|
47
|
+
"example:if-exists": "tsx --tsconfig examples/tsconfig.json examples/if-exists-demo.ts",
|
|
48
|
+
"example:first-or-default": "tsx --tsconfig examples/tsconfig.json examples/first-or-default-demo.ts",
|
|
49
|
+
"example:load-edit": "tsx --tsconfig examples/tsconfig.json examples/load-and-edit-script.ts",
|
|
50
|
+
"example:read-contacts": "tsx --tsconfig examples/tsconfig.json examples/read-contacts-list.ts",
|
|
51
|
+
"example:load-edit-save": "tsx --tsconfig examples/tsconfig.json examples/load-edit-save.ts",
|
|
52
|
+
"example:verify-load-save": "tsx --tsconfig examples/tsconfig.json examples/verify-load-save.ts",
|
|
53
|
+
"example:claude-process-gui": "tsx --tsconfig examples/tsconfig.json examples/claude-process-info-gui.ts",
|
|
54
|
+
"example:claude-process-complete": "tsx --tsconfig examples/tsconfig.json examples/claude-process-info-complete.ts",
|
|
55
|
+
"example:ui-explorer": "tsx --tsconfig examples/tsconfig.json examples/ui-explorer.ts",
|
|
56
|
+
"example:outline-explorer": "tsx --tsconfig examples/tsconfig.json examples/outline-explorer.ts",
|
|
57
|
+
"example:element-detail": "tsx --tsconfig examples/tsconfig.json examples/element-detail-explorer.ts",
|
|
58
|
+
"example:inspector-explorer": "tsx --tsconfig examples/tsconfig.json examples/inspector-explorer.ts",
|
|
59
|
+
"example:claude-open-files": "tsx --tsconfig examples/tsconfig.json examples/claude-open-files.ts",
|
|
60
|
+
"example:text-area-debug": "tsx --tsconfig examples/tsconfig.json examples/text-area-debug.ts",
|
|
61
|
+
"example:tab-structure": "tsx --tsconfig examples/tsconfig.json examples/tab-structure-explorer.ts",
|
|
62
|
+
"example:tab-group-content": "tsx --tsconfig examples/tsconfig.json examples/tab-group-content.ts",
|
|
63
|
+
"example:text-area-full": "tsx --tsconfig examples/tsconfig.json examples/text-area-full.ts",
|
|
64
|
+
"examples": "pnpm run example:basic && pnpm run example:languages && pnpm run example:compile && pnpm run example:builder && pnpm run example:decompile && pnpm run example:list-apps && pnpm run example:windows && pnpm run example:sdef && pnpm run example:validation",
|
|
65
|
+
"prepare": "husky",
|
|
66
|
+
"lint-staged": "lint-staged",
|
|
67
|
+
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
68
|
+
"verify": "pnpm run lint && pnpm run test && pnpm run build",
|
|
69
|
+
"docs:dev": "cd docs && pnpm dev",
|
|
70
|
+
"docs:build": "cd docs && pnpm build",
|
|
71
|
+
"docs:serve": "cd docs && pnpm start"
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"src/**/*.{ts,tsx}": [
|
|
75
|
+
"eslint --fix",
|
|
76
|
+
"prettier --write",
|
|
77
|
+
"tsc --noEmit --skipLibCheck",
|
|
78
|
+
"vitest related --run",
|
|
79
|
+
"pnpm run build:types:staged"
|
|
80
|
+
],
|
|
81
|
+
"examples/**/*.{ts,tsx}": [
|
|
82
|
+
"eslint --fix",
|
|
83
|
+
"prettier --write"
|
|
84
|
+
],
|
|
85
|
+
"*.{json,md,yml,yaml}": [
|
|
86
|
+
"prettier --write"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"keywords": [
|
|
90
|
+
"applescript",
|
|
91
|
+
"macos",
|
|
92
|
+
"automation",
|
|
93
|
+
"osascript",
|
|
94
|
+
"typescript"
|
|
95
|
+
],
|
|
96
|
+
"author": "Matthew Herod",
|
|
97
|
+
"license": "MIT",
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=20"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"@biomejs/biome": "2.2.6",
|
|
103
|
+
"@eslint/eslintrc": "3.2.0",
|
|
104
|
+
"@eslint/js": "9.16.0",
|
|
105
|
+
"@types/node": "^22.10.1",
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
107
|
+
"@typescript-eslint/parser": "^8.17.0",
|
|
108
|
+
"@vitest/coverage-v8": "2.1.8",
|
|
109
|
+
"eslint": "^9.16.0",
|
|
110
|
+
"eslint-config-prettier": "^9.1.0",
|
|
111
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
112
|
+
"globals": "15.13.0",
|
|
113
|
+
"husky": "9.1.7",
|
|
114
|
+
"lefthook": "1.13.6",
|
|
115
|
+
"lint-staged": "15.2.10",
|
|
116
|
+
"prettier": "^3.4.2",
|
|
117
|
+
"rollup": "4.28.0",
|
|
118
|
+
"tsup": "^8.3.5",
|
|
119
|
+
"tsx": "^4.7.0",
|
|
120
|
+
"typescript": "^5.7.2",
|
|
121
|
+
"ultracite": "5.6.4",
|
|
122
|
+
"vite": "6.4.1",
|
|
123
|
+
"vitest": "2.1.9"
|
|
124
|
+
},
|
|
125
|
+
"dependencies": {
|
|
126
|
+
"chalk": "5.6.2",
|
|
127
|
+
"cli-table3": "0.6.5",
|
|
128
|
+
"fast-xml-parser": "5.3.4"
|
|
129
|
+
}
|
|
130
|
+
}
|