@enfocussw/switch-scripting-context 25.11.0-beta.10

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,40 @@
1
+ # Switch Scripting (Node.js)
2
+ Enfocus Switch workflow automation scripts written in TypeScript/Node.js.
3
+
4
+ ## Execution environment
5
+ - Entry points are top-level `async` functions with specific names — **not exported** — executed in a `node:vm.Script()` context.
6
+ - ESM is supported: if ES modules are present the script is bundled with ESBuild before running.
7
+ - Type declarations are in `node_modules/@types/switch-scripting/index.d.ts` and must be followed precisely.
8
+
9
+ ## API reference
10
+ Detailed API docs are in `docs/switch-api/`:
11
+
12
+ | File | Contents | Load when |
13
+ |---|---|---|
14
+ | `switch-api/api-entry-points.md` | All entry point signatures, constraints, and when each is called | Scaffolding a new script or adding an entry point |
15
+ | `switch-api/api-switch.md` | `Switch` (`s`) — global data, webhooks, abort, server utilities | Using global data, webhooks, abort, or server settings |
16
+ | `switch-api/api-flow-element.md` | `FlowElement` — properties, connections, job creation, logging | Reading properties, creating jobs, logging, connections |
17
+ | `switch-api/api-job.md` | `Job` — routing, file access, child jobs, private data, datasets | Processing/routing jobs, file access, private data, datasets |
18
+ | `switch-api/api-connection.md` | `Connection` — type, properties, file count | Routing to specific connections or reading connection properties |
19
+ | `switch-api/api-http.md` | `HttpRequest` / `HttpResponse` + webhook pattern | Handling incoming HTTP webhooks |
20
+ | `switch-api/api-enums.md` | All enums with string values (`LogLevel`, `AccessLevel`, `DatasetModel`, `Scope`, `Priority`, `Connection.Level`, etc.) | Looking up enum values |
21
+ | `switch-api/api-document-classes.md` | `PdfDocument`, `PdfPage`, `ImageDocument`, `XmlDocument`, `XmpDocument` — read-only file introspection | Inspecting PDF, image, XML, or XMP file contents |
22
+ | `switch-api/api-script-structure.md` | Script folder/package files, manifest format, App vs Script, execution modes | Setting up a new script project or converting to an App |
23
+ | `switch-api/api-tooling.md` | SwitchScriptTool commands, script folder vs package, build and deployment | Creating, building, packaging, or deploying a script |
24
+ | `switch-api/api-debugging.md` | Enabling debug mode in Switch Designer, debuggable entry points, VS Code attach | Debugging a script |
25
+ | `switch-api/api-vscode.md` | Type declarations, tsconfig for TypeScript 6, ESLint rules | Setting up VS Code or fixing type errors |
26
+ | `switch-api/api-script-declaration.md` | XML declaration reference: properties, connections, execution config — agents may edit this file directly | Understanding, adding, or editing script properties/connections/execution config |
27
+ | `switch-api/api-property-editors.md` | Property editor types, string return values, literal editors, dropdowns | Defining property editors in XML or reading property values in code |
28
+ | `switch-api/api-job-patterns.md` | File access semantics, temp cleanup, routing rules, child jobs, executor limits | Processing jobs, creating child jobs, working with datasets, routing to multiple connections |
29
+ | `switch-api/api-execution-environment.md` | Process/concurrency model, state persistence across job invocations, unhandled-rejection behavior, npm/native module constraints | Relying on module-level state across jobs, handling errors/rejections, or using third-party npm packages |
30
+ | `switch-api/api-logging.md` | Log level semantics, logging practice, `console.log` limitation, common gotchas | Adding or reviewing `job.log()`/`flowElement.log()`/`job.fail()`/`failProcess()` calls |
31
+ | `switch-api/api-logs-and-dataroot.md` | Locating the Application Data Root, querying `ServerLogs.db3` directly | Diagnosing or validating a script from its actual log output rather than by reading the code |
32
+
33
+ ## Key rules
34
+ - Always consult the API reference files above before writing or modifying script code.
35
+ - Do not `export` entry point functions.
36
+ - Every `jobArrived` invocation must end with exactly one `job.sendTo*()` or `job.fail()` call — either in the same invocation or deferred to `timerFired` via job information stored in global data.
37
+ - Use `AccessLevel.ReadOnly` for `job.get()` unless the file content will be modified.
38
+ - Use VS Code snippets (`.vscode/switch.code-snippets`, prefix `switch…`) to scaffold entry points.
39
+ - After calling `createJob()`, `createChild()`, or `createDataset()` with a file path, the script must delete the source file/folder after routing — Switch does not auto-remove it.
40
+ - The XML declaration (`<ScriptID>.xml`) can be edited directly — read `switch-api/api-script-declaration.md` first and follow its rules exactly (no schema validates this format, so mistakes fail silently). Never change an existing script's `Name`. Bump `Version` on every declaration edit. Leave `manifest.xml` edits (package type, declaration filename, program files) to the user unless explicitly asked.
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@enfocussw/switch-scripting-context",
3
+ "version": "25.11.0-beta.10",
4
+ "description": "AI coding assistant context for Enfocus Switch scripting (Node.js/TypeScript)",
5
+ "keywords": [
6
+ "switch",
7
+ "enfocus",
8
+ "switch-scripting",
9
+ "ai-context",
10
+ "claude",
11
+ "copilot",
12
+ "cursor",
13
+ "codex",
14
+ "gemini",
15
+ "windsurf",
16
+ "zed",
17
+ "cline"
18
+ ],
19
+ "main": "dist/init.js",
20
+ "bin": {
21
+ "switch-scripting-context": "bin/cli.js"
22
+ },
23
+ "files": [
24
+ "bin/",
25
+ "dist/",
26
+ "!dist/*.test.js",
27
+ "docs/",
28
+ "!docs/superpowers",
29
+ "!docs/temp",
30
+ "CHANGELOG.md"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "build:test": "tsc src/init.test.ts --outDir dist --target ES2020 --module commonjs --lib ES2020 --types node --strict --esModuleInterop --skipLibCheck",
35
+ "test": "npm run build && npm run build:test && node dist/init.test.js",
36
+ "prepack": "npm run build",
37
+ "postpack": "node -e \"const fs=require('fs');const version=process.env.npm_package_version;const scoped=process.env.npm_package_name.replace(/^@/,'').replace('/','-')+'-'+version+'.tgz';const unscoped=process.env.npm_package_name.replace(/^@[^/]+\\//,'')+'-'+version+'.tgz';if(scoped!==unscoped&&fs.existsSync(scoped))fs.renameSync(scoped,unscoped);\""
38
+ },
39
+ "author": "Sam Wallace",
40
+ "license": "ISC",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/samw_pacol/enf-switch-scripting-context.git"
44
+ },
45
+ "publishConfig": {
46
+ "registry": "https://registry.npmjs.org/",
47
+ "access": "public"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^20.0.0",
51
+ "typescript": "^5.0.0"
52
+ },
53
+ "homepage": "https://github.com/samw_pacol/enf-switch-scripting-context#readme",
54
+ "bugs": {
55
+ "url": "https://github.com/samw_pacol/enf-switch-scripting-context/issues"
56
+ },
57
+ "engines": {
58
+ "node": ">=18"
59
+ }
60
+ }