Skip to content

Code

Menu: Development → Code
Deep link: /_Admin/development/code?SiteId={siteGuid}

Manage site KScript / TypeScript code resources: API, CodeBlock, event handlers, page scripts, etc. Types come from the admin Code/CodeType API; tabs and list filter by type. Script logic and APIs: KScript API (e.g. k.site.codes).

Permissions

List and edit: code (view / edit / delete). API tab Settings (Swagger doc toggle) requires code·edit. Row Version requires site·log.

How to Open

  1. In Edit Menu, enable Development → Code.
  2. Open Development → Code in the left sidebar.
Code list overview

Breadcrumb Code; right Search filters by name or URL keyword (debounced). With folder hierarchy, search auto expands all to hit children.

Code header: breadcrumb and search

Type tabs

Tabquery nameDescription
Allall (default)All types; Create is a dropdown to pick a specific type
Each code typee.g. api, codeblock, eventThat type only; Create is a single button labeled "Create {type}"

Switching tabs updates URL name and clears current multi-select.

Code type tabs

Toolbar

ControlPermissionDescription
Createcode·editAll tab: dropdown picks type then edit code; type tab: create that type directly
Searchcode·editOnline package search (All, CodeBlock, etc. tabs)
SwaggerAPI tab only, when docs enabled in API settings; opens /_Admin/swagger in new tab
Settingscode·editAPI tab only; opens API settings dialog
Expand all / Collapse allWhen list has folder hierarchy from URL paths
Code toolbar: create and search

Create type dropdown

On All tab, click Create and choose type from dropdown (same options as type tabs).

Create code type dropdown

List table

Tree table: items with url paths show as folder rows (expand/collapse); leaves are concrete code entries.

ColumnDescription
NameClick to edit; row checkbox for batch delete
Code typeType label (e.g. API, CodeBlock)
Script typeClassic / Module (hidden for some types, e.g. embedded PageScript, CodeBlock)
Referenced byReference relationships
PreviewAccess path url, click to preview
Last modifiedSave time
VersionVersion history

Supports multi-select Delete.

Code list table

API settings dialog

On API tab, toolbar Settings:

ItemDescription
Enable Swagger documentationWrites codeOpenApiSettings.enable; when on, shows Swagger button
AuthenticationNone / Cookie / Header
Token nameWhen not None (default jwt_token)

Confirm button label is Start (saves site config).

API Swagger settings dialog

Edit code

Path: /_Admin/development/code/edit?SiteId=... (new with type={CodeType}; edit with id)

Code edit: TypeScript editor

Header form

Fields vary slightly by code type:

FieldDescription
Code nameRequired on create, unique (1–50 chars); cannot rename after save; rename may sync default url to /{name}
URLRequired for API type, interface route
Event typeEvent type: pick event name from category dropdown (optional on create, locked after save)
Script typeClassic / Module (hidden for embedded PageScript, CodeBlock, etc.)
FormatFormat editor content
Code edit header form

Code editor

  • Language: TypeScript, supports KScript.
  • API, CodeBlock, etc. support code references after save.
  • Save / Save and return; unsaved leave prompts.

Encrypted code

If code is encrypted (isDecrypted), editor shows This code is encrypted and cannot be edited; footer only has Return.

DocDescription
Development overviewDevelopment menu index
Code logCode runtime logs
Code searchSite-wide code search
KScript APIScript APIs