servicenow-fluent-development by danielmadsendk/nowdev-ai-toolbox
npx skills add https://github.com/danielmadsendk/nowdev-ai-toolbox --skill servicenow-fluent-development使用 ServiceNow SDK 编写 ServiceNow Fluent (.now.ts) 元数据和 TypeScript/JavaScript 模块的专家知识。
.now.ts 文件)now-sdk 进行构建/同步/安装now-sdk dependencies 在 @types/servicenow 中获取类型定义Now.include() 引用外部脚本;SDK 对象来自 @servicenow/sdk/coreUiPage 实现全栈 React 应用,客户端代码位于 src/client/广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
@servicenow/sdk/automation 支持流程/工作流自动化@types/servicenow/schema/(防止安装时出现重复项)parent.$id, table.name) — 引用时切勿使用 Now.ID[...]// 正确
export const menu = ApplicationMenu({ $id: Now.ID['menu'], title: 'App' })
export const module = Record({ table: 'sys_app_module', data: { application: menu.$id } })
export const table = Table({ name: 'x_app_table', schema: {...} })
export const rule = BusinessRule({ table: table.name })
// 错误 — 创建了一个新的 ID 引用,而不是指向常量
data: { application: Now.ID['menu'] }
| 链接类型 | 必填字段 | 备注 |
|---|---|---|
| 全部 | title, application, active, link_type, order, hint | 基础字段 |
| 列表 / 新建 | + name (= 目标表名) | name: 'x_app_mytable' |
| 直接 | + query (= UI 页面端点) | query: 'x_app_page.do', 无 name |
// TypeScript 模块导入(服务器端)— 编译为 .js
import { fn } from '../server/module.js'
BusinessRule({ script: fn })
// 用于 ServiceNow JavaScript 的 Now.include() — 启用双向同步
ClientScript({ script: Now.include('./script.client.js') })
// 内联 ServiceNow JavaScript(非 TypeScript)
ClientScript({ script: `function onLoad() { g_form.addInfoMessage('Hi'); }` })
// script 标记模板字面量
RestApi({ routes: [{ script: script`(function(req,res){ res.setBody({ok:true}) })(request,response)` }] })
同步指令: @fluent-ignore, @fluent-disable-sync, @fluent-disable-sync-for-file — 谨慎使用,并附上解释原因的注释。
src/fluent/ui-pages/page.now.ts → UiPage({ html: htmlEntry, endpoint: 'x_app.do' })
src/fluent/script-includes/*.now.ts → ScriptInclude with clientCallable: true
src/fluent/script-includes/*.server.js → Class.create() with client-callable methods
src/client/index.html → <sdk:now-ux-globals>, <script src="./main.tsx" type="module">
src/client/main.tsx → ReactDOM.createRoot(root).render(<App />)
src/client/app.tsx → State, CRUD handlers, components
src/client/services/Service.ts → GlideAjax or REST service layer
src/client/components/*.tsx → UI components
src/client/global.d.ts → declare global { Window.g_ck, GlideAjax }
第三方 npm 库(组件套件、图标、图表等)受支持 — 通过 npm 安装,在客户端代码中正常导入,Rollup 会自动打包它们。完整设置指南(包括 CSS 导入、上下文提供程序和构建警告抑制)请参阅 references/third-party-libraries.md。
| 需求 | GlideAjax | REST API |
|---|---|---|
| 仅限内部 ServiceNow 应用 | 推荐 | 过度复杂 |
| 外部系统集成 | 无法实现 | 必需 |
| 移动应用 / 非 React 客户端 | 无法实现 | 必需 |
| 设置更简单 | 代码更少 | 更多样板代码 |
| ServiceNow 原生安全性 | 内置 | 手动配置 |
| OpenAPI 文档 | 有限 | 支持 |
默认: 对于内部 ServiceNow 应用,使用 GlideAjax。完整实现示例请参阅 references/client-server-patterns.md。
src/fluent/tables/*.now.ts 中创建表src/fluent/script-includes/*.now.ts 中创建 ScriptInclude(对于 GlideAjax 使用 clientCallable: true)src/fluent/ui-pages/*.now.ts 中创建 UiPage<sdk:now-ux-globals> 的 src/client/index.htmlsrc/client/main.tsx(React 引导程序)和 src/client/app.tsx(状态、处理程序)src/client/services/*.ts 中创建服务层(GlideAjax 或 REST)src/client/components/*.tsx 中创建组件link_type: 'DIRECT')now-sdk build && now-sdk install --auth <alias>x_[供应商]_[应用]_[名称],字段使用 snake_case,导出的常量使用 PascalCasegs.hasRole();验证所有输入abortAction;get() 后使用 isValidRecord();使用 gs.error() 进行日志记录GlideRecord<'表名'> 泛型;运行 now-sdk dependencies 获取模式文件需要特定主题的详细指导时,请加载这些文件:
now-sdk dependencies、tsconfig 设置、#now: 导入别名、trustedModules、构建行为、验证清单package.json 布局、Rollup 预构建脚本、CSS 导入、上下文提供程序、TypeScript 声明、构建警告抑制以及完整清单每周安装数
1
代码库
GitHub 星标数
3
首次出现
1 天前
安全审计
已安装于
amp1
cline1
opencode1
cursor1
kimi-cli1
codex1
Expert knowledge for authoring ServiceNow Fluent (.now.ts) metadata and TypeScript/JavaScript modules using the ServiceNow SDK.
.now.ts files)now-sdk for build/sync/install@types/servicenow via now-sdk dependenciesNow.include() references external scripts; SDK objects from @servicenow/sdk/coreUiPage with client code in src/client/@servicenow/sdk/automation@types/servicenow/schema/ (prevents duplicates on install)parent.$id, table.name) — never Now.ID[...] for references// CORRECT
export const menu = ApplicationMenu({ $id: Now.ID['menu'], title: 'App' })
export const module = Record({ table: 'sys_app_module', data: { application: menu.$id } })
export const table = Table({ name: 'x_app_table', schema: {...} })
export const rule = BusinessRule({ table: table.name })
// WRONG — creates a new ID reference instead of pointing to the constant
data: { application: Now.ID['menu'] }
| Link Type | Required Fields | Notes |
|---|---|---|
| ALL | title, application, active, link_type, order, hint | Base fields |
| LIST / NEW | + name (= target table name) | name: 'x_app_mytable' |
// TypeScript module import (server-side) — compiled to .js
import { fn } from '../server/module.js'
BusinessRule({ script: fn })
// Now.include() for ServiceNow JavaScript — enables two-way sync
ClientScript({ script: Now.include('./script.client.js') })
// Inline ServiceNow JavaScript (NOT TypeScript)
ClientScript({ script: `function onLoad() { g_form.addInfoMessage('Hi'); }` })
// script tagged template literal
RestApi({ routes: [{ script: script`(function(req,res){ res.setBody({ok:true}) })(request,response)` }] })
Sync directives: @fluent-ignore, @fluent-disable-sync, @fluent-disable-sync-for-file — use sparingly with a comment explaining why.
src/fluent/ui-pages/page.now.ts → UiPage({ html: htmlEntry, endpoint: 'x_app.do' })
src/fluent/script-includes/*.now.ts → ScriptInclude with clientCallable: true
src/fluent/script-includes/*.server.js → Class.create() with client-callable methods
src/client/index.html → <sdk:now-ux-globals>, <script src="./main.tsx" type="module">
src/client/main.tsx → ReactDOM.createRoot(root).render(<App />)
src/client/app.tsx → State, CRUD handlers, components
src/client/services/Service.ts → GlideAjax or REST service layer
src/client/components/*.tsx → UI components
src/client/global.d.ts → declare global { Window.g_ck, GlideAjax }
Third-party npm libraries (component kits, icons, charts, etc.) are supported — install via npm, import normally in client code, and Rollup bundles them automatically. See references/third-party-libraries.md for the full setup guide including CSS imports, context providers, and build-warning suppression.
| Requirement | GlideAjax | REST API |
|---|---|---|
| Internal ServiceNow app only | Recommended | Overkill |
| External system integration | Cannot | Required |
| Mobile app / non-React client | Cannot | Required |
| Simpler setup | Less code | More boilerplate |
| ServiceNow native security | Built-in | Manual |
| OpenAPI documentation | Limited | Supported |
Default: Use GlideAjax for internal ServiceNow apps. See references/client-server-patterns.md for full implementation examples.
src/fluent/tables/*.now.tssrc/fluent/script-includes/*.now.ts (with clientCallable: true for GlideAjax)src/fluent/ui-pages/*.now.tssrc/client/index.html with <sdk:now-ux-globals>src/client/main.tsx (React bootstrap) and src/client/app.tsx (state, handlers)src/client/services/*.ts (GlideAjax or REST)x_[vendor]_[app]_[name] for tables, snake_case fields, PascalCase exported constantsgs.hasRole() in script-based ACLs; validate all inputabortAction for validation failures; isValidRecord() after get(); gs.error() for loggingGlideRecord<'tablename'> generics in server modules; run for schema filesLoad these files when you need detailed guidance on specific topics:
now-sdk dependencies, tsconfig setup, #now: import alias, trustedModules, build behaviour, verification checklistWeekly Installs
1
Repository
GitHub Stars
3
First Seen
1 day ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
amp1
cline1
opencode1
cursor1
kimi-cli1
codex1
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
79,900 周安装
| DIRECT | + query (= UI page endpoint) | query: 'x_app_page.do', no name |
src/client/components/*.tsxlink_type: 'DIRECT')now-sdk build && now-sdk install --auth <alias>now-sdk dependenciespackage.json layout, Rollup prebuild script, CSS imports, context providers, TypeScript declarations, build-warning suppression, and a full checklist