Releases: ServiceNow/sdk
SDK 4.1.1
Available on npm at @servicenow/sdk
This is a minor patch release to fix some issues with module dependencies, and address some dependency vulnerabilities
Fixes:
- Support third party modules that are imported using trailing slashes Ex. require('buffer/') which are now supported in glide
- Support for declaring a dependency on libraries that are named the same as node_builtins in order to use those libraries on the platform
- Fix
criticalandhighseverity vulnerabilities in some 3rd party dependencies
SDK 4.1.0
Availalbe on npm at @servicenow/sdk
🚀 New Features
Module Include/Exclude File Patterns
-
Added support for specifying include and exclude file patterns during module builds.
-
Useful for omitting test files or other support files from being treated as module files.
-
New
now.config.jsonproperties:serverModulesIncludePatternsserverModulesExcludePatterns
Default patterns:
// Include defaults
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
"**/*.cts",
"**/*.cjs",
"**/*.mts",
"**/*.mjs",
"**/*.json"
// Exclude defaults
"**/*.test.ts",
"**/*.test.js",
"**/*.d.ts"Apply Templates to Existing Projects
- Running
initinside an existing SDK project now prompts for template selection. - Enables applying UI templates and others to already initialized projects.
Script Include Type Generation for Modules
- The
dependenciescommand now scans modules for scope definitions and fetches script-include types from the instance. - Types are saved under
@types/servicenow. - Detection is based on subpath imports under the
@servicenow/glidenamespace like@servicenow/glide/[scope].
Example:
import { global } from "@servicenow/glide/global";
function test() {
const utils = new global.UtilScript();
const tables = utils.getTables("cmdb_ci_server");
}🐛 Fixes
- Fixed
Listrecords not being deleted on build when fluent code is removed. - Ignored
type-only imports in sys modules during dependency generation. - Fixed
UiActiononClickproperty being cleared on the instance. - Added diagnostics for missing
.htmlfile imports. - Ensured
$meta.installMethodis respected on child records during build. - Fixed
lstaterrors when using certain 3rd-party front-end dependencies (e.g.,@mix/x-charts). - Corrected ATF
Testsys_scopenot being set properly during build. - Fixed radio column choices not being populated during transform.
- Corrected
ClientScriptdiagnostic errors fortype = 'onChange' | 'onLoad'whenfieldis set. - Fixed multiple transform issues with
UiPolicy. - Fixed build failures when fluent content includes XML CDATA escape sequences (
]]>). - Ensured
priorityis captured correctly duringBusinessRuletransform.
SDK 4.0.2
This is a patch release for @ServiceNow/sdk version 4.0.2
- Fix an issue with the front end framework development build system on the ServiceNow IDE
SDK 4.0.1
This is a patch release for @servicenow/sdk version 4.0.1
Changes:
- Fix ATF
Testserialization of record arrays on steps - Fix empty SDK version when using
initon Windows systems - Fix
deployalways reporting success and not checking upgrade history properly - Fix
Tablenot supporting customizing tables viaas anyescape on table name. For example if you wish to add a column to thetasktable you would use theTableAPI and cast the table nameas anyto silent the diagnostic error for thenameproperty. - Moved React dependencies to
devDependenciesin init templates - Fix UI client build failures on Windows
- Fix
$meta.installMethodnot being respected by child records - Fix
ClientScriptfailing build when type is set toonSubmit | onLoadwhenfieldis set
Table({
name: 'task' as any
schema: {
x_mycolumn: new StringColumn({...})
}
})SDK 4.0.0
🔥 4.0.0 is here! 🔥
The latest release of the @servicenow/sdk just dropped on npm, and it’s a big one.
Internally, we’ve completely overhauled our plugin framework to make APIs more reliable, and way faster to ship. Translation? You’ll be seeing more APIs, more often 🚀.
But the real star of the show:
- ⚛️ Front-End app support with front end frameworks like React, Vue, Svelte, SolidJS, and others!
- ⚡️ New Fluent APIs to level up your applications development
- 🛠️ A rock-solid foundation for even bigger things coming soon
Check out the release notes below, kick the tires, and drop your thoughts on the discussion board. We can’t wait to see what you build with 4.0.0 🙌.
New Fluent APIs
Some new Fluent APIs have been added to make working with certain types of tables easier using the SDK.
- ScriptInclude (sys_script_include)
- UiPage (sys_ui_page)
- UiAction (sys_ui_action)
- ScriptAction (sysevent_script_action)
- ServicePortal elements
- SpWidget (sp_widget)
- SPWidgetDependency (sp_dependency)
- SpAngularProvider (sp_angular_provider)
Command changes
There are some minor command changes to now-sdk and they can be viewed using --help option for more information.
-
Added
cleancommand
The clean command will clean out the build output directory, typically dist folder. This is automatically performed as part of the build command, but if you have any other needs to clean out the folder you can use this command. -
Added
packcommand
The pack command will package up the output of a build into an installable archive file. pack is automatically performed as part of the install command. Pack used to be run at the end of build but this was removed since installalso performs pack -
Added
downloadcommand
The download command can be used for downloading complete or incremental metadata from the instance for the application.
Front-end framework support
The SDK now supports building front-end applications with standard frameworks to run on ServiceNow! For this first release, we are natively supporting React out of the box, and we are aiming to support a "bring your own front end" (BYOF) approach. This new feature will let you use a more modern development experience for building UI applications.
To get started building front ends, simply choose a template with included front-end framework support such as now-sdk + fullstack React when running init to get started!
This is just the beginning of the BYOF support we are adding to the SDK and we will be following up soon with more support for providing your own bundler and tooling for other frameworks like Svelte, Vue, etc...
How does it work?
Front-end applications utilize the UiPage Fluent API for bundling and hosting the application and its entry point. The SDK detects importing from an .html page that is being assigned to the html attribute on UiPage Fluent API and bundles your front end into static assets served with your application.
By default, the front-end application code lives in your src/client directory (configurable in now.config.json with the clientDir property). Add all your images, style sheets, fonts, etc. here the same way you would for any typical React application that you're building. The out of the box bundler we have included is Rollup to package up the your front end application.
Example with React:
import { UiPage } from '@servicenow/sdk/core'
import indexPage from '../client/index.html'
UiPage({
$id: Now.ID['sample-frontend'],
endpoint: 'x_sampleapp-uipage-fe.do',
description: 'Sample Front-End Application',
category: 'general',
html: indexPage,
direct: true,
})In the src/client folder create an index.html page like this:
<html>
<head>
<title>Sample Front-End Application</title>
<!-- Initialize globals and Include ServiceNow's required scripts -->
<sdk:now-ux-globals></sdk:now-ux-globals>
<!-- Include your React entry point -->
<script src="./main.tsx" type="module"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>In the src/client/* folder add a main.tsx file with your React code, CSS, and other assets to build your application
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './app'
const rootElement = document.getElementById('root')
if (rootElement) {
ReactDOM.createRoot(rootElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
)
}When you are ready, just build and install then open the UI Page on the instance to view your application!
- React Sample: https://github.com/ServiceNow/sdk-examples/tree/main/react-ui-page-ts-sample
- Svelte Sample: https://github.com/ServiceNow/sdk-examples/tree/main/svelte-ui-page-sample
- Vue Sample: https://github.com/ServiceNow/sdk-examples/tree/main/vue-ui-page-sample
- SolidJS Sample: https://github.com/ServiceNow/sdk-examples/tree/main/solidjs-ui-page-sample
Limitations:
- Only hash routing is currently supported by UI Pages.
- Maximum file size of assets is limited to the
com.glide.attachment.max_sizesystem property - Preloading content linked from HTML isn't supported
(rel="preload") - Relative style sheets linked from HTML aren't supported
(rel="stylesheet"). Import your style sheets into code instead (import "path/to/style-sheet") - Relative
@importin CSS isn't supported - CSS modules aren't supported
- Server-side rendering and React server components aren't supported
API Changes
ListAPI deprecates $id property as it is a coalescing table and uses combination of name, view, sys_domain, element, relationship, and parent properties. The property will not produce build errors but be marked as deprecated.RoleAPI deprecates $id property as it is a coalescing table and uses the name property to generate its key. The property will not produce build errors but will be marked as deprecated.ClientScriptAPI will no longer produce script fields with tagged template literalsscript tag during generation by default. Syntax highlighting for these tags were removed back in 3.0 in favor of Now.include functionality. The tags will not produce build errors, and they do not alter functionality.
//Before
ClientScript({
script: script`gs.info("hello world")`
...
})
//After
ClientScript({
script: `gs.info("hello world")`
...
}) Breaking Changes
- Custom properties have been removed in this version. In versions 3.0 and earlier, you could specify custom properties not included in the type definition on any API. This was helpful for setting custom fields on out-of-box table definitions. However, this feature has been removed in 4.0 to prevent issues caused by allowing arbitrary properties in the API type. This feature would cause AI hallucinations during code generation due to lack of strict type checking on the arbitrary fields that were allowed. We are planning to bring this back soon (4.1+), so if you rely on this in your application please wait or alternatively use the
RecordAPI instead if that's a possibility.
For example, you could specify a field called x_customfield on an API like Role in version 3.0 and prior and that field would be automatically added to the build output.
Role({
$id: Now.ID['my_id'],
name: 'x_myapp_rolename',
x_customfield: 'some value'
}) Documentation
Support and Issues
SDK 3.0.3
📢 We are pleased to announce the release of 3.0.3 of the @servicenow/sdk is available for download on npm!
This is a minor patch release that fixes a bug in the SDK
Fixes
- Table columns that defined
dynamic_value_definitions.calculated_valuefields withstringvalues were creating invalid xml. This did not affect using module imports on thecalculated_valuefield.
Example:
StringColumn({
label: "Label Name",
dynamic_value_definitions: {
type: "calculated_value",
calculated_value: `javascript:global.getNextObjNumberPadded();`,
},
}),SDK 3.0.2
📢 We are pleased to announce the release of 3.0.2 of the @servicenow/sdk is available for download on npm!
This is a patch release that fixes a few bugs in the SDK and adds an option for CI server installs
Add option to specify basic auth credentials through env variables for install command
To inject basic authentication credentials for the install command from a CI server type environment, you can specify the following env variables and the sdk will detect them and default to using them.
SN_SDK_INSTANCE_URL = "https://your-instance-url.com"
SN_SDK_USER = "username" # servicenow user name
SN_SDK_USER_PWD = "passwordvalue" # servicenow user password
SN_SDK_NODE_ENV = "SN_SDK_CI_INSTALL" # needs to be set to enable the featureFixes
- packOutputDir in now.config.json not being respected
- List API should also accept columns other than defined table schema elements
- Choice columns with dropdown: 'dropdown_without_none' are showing as a dropdown WITH none when installed
- Transform generates invalid sys_security_acl_role when the ACL is in metadata directory
- Reinstalling a new fluent app right after installation fails
- ignoreTransformTableList doesn't respect the table configured inside them
- Fixed issue where transform fails when there are no changes to Role
- sys_documentation gets duplication upon transformation
- Wrap the Now.include html content with CDATA tag upon generating the XML
SDK 3.0.1
📢 We are pleased to announce the release of 3.0.1 of the @servicenow/sdk is available for download on npm!
This is a patch release that fixes a few bugs in the SDK
Fixes
- Fix linting errors when trying to import a module from a typescript file using the
.tsextension. Example:import { someFunction } from "../src/server/mymodule.ts"would cause an error from typescript about using ts extensions on imports. - Variables used in
ApplicationMenuwere being erased with literal values during transform - metadata/sys_app xml keeps getting changed on every transform and build even when there are no changes
- Cached third party packages in .now/.output are not refreshed during build
SDK 3.0.0
📢 We are pleased to announce the release of 3.0.0 of the @servicenow/sdk is available for download on npm!
This release includes some major changes to our CLI commands, new features like Now.include for referencing content from other files, dependencies support to enhance scripting development, and many bug fixes!
Command line changes:
The driving reason for the 3.0 version change is to reflect the breaking changes in our CLI commands that have gone through major changes in this version. This is to align with our future development features we have planned out and provide some more consistent naming conventions with the actions being performed on the platform.
initcommand replaces create is new way to create or scaffold new applications with the SDK.
Better support for npx! Usenpx @servicenow/sdk initto get started with creating or converting an application
Removed automatic deploy to instance at end of runinstallcommand replaces deploy for installing the build output of the application to your instancetransformcommand replaces fetch for downloading and transforming metadata from the instance to fluent or updating metadata folder. This command can also be used for transforming individual files and directories into fluent, if you wish to move smaller pieces of an application from metadata to fluent.dependenciescommand is now exposed for downloading table definitions and typescript type definitions to your local projectauthcommand changes to use flags in place of some interactive componentsbuildcommand adds a --frozenKeys which is useful for CI system. When specified the keys.ts file will not be updated and attempts to update it will result in a build error. This is useful if you want to ensure keys files get updated properly by engineers during PR reviews for example.
New Features
Now.include utility function! This can be used for referencing any text content in another file and assigning it to a field on any fluent entity. This is very helpful for moving fields that contain large content or are better modified in a file with the proper extension, such as javascript, html, and css content. If changes are made on the instance, they will be reflected to the include file during transform.
Script include example:
SampleClass.now.ts
Record({
$id: Now.ID["SampleClass"],
table: "sys_script_include",
data: {
name: "SampleClass",
apiName: "x_sample.SampleClass",
access: "public",
caller_access: "caller_tracking",
protection_policy: "read-only",
source: Now.include("./SampleClass.server.js"),
},
});SampleClass.server.js
class SampleClassScriptInclude {
constructor() {}
hello() {
gs.info("Hello World");
}
}
const SampleClass = SampleClassScriptInclude;Sys UI Page sample:
Record({
$id: Now.ID["example_ui_page"],
table: "sys_ui_page",
data: {
processing_script: Now.include("./example_ui_page.server.js"),
html: Now.include("./example_ui_page.html"),
client_script: Now.include("./example_ui_page.client.js"),
},
});dependencies command
The dependencies command also downloads typing information for client and server side development from the instance, similar to what you get in the on instance script editor. These types are saved to the @types/servicenow folder in your project, and can then be imported with tsconfig.json files, to be applied to your js and ts files. We recommend using an extension naming format for this to separate client vs server side files to get proper type information applied to them by typescript. This will give you a rich development environment for things like script includes, server side script, and client scripts when you use GlideRecord or g_form for example.
You can see an example of that here in the samples repo: sdk-examples
Script include types will be automatically scanned for from any .js file in your src/fluent directory. The scanner will look for usages of expressions such as global.JSUtil in the files and download the type information for those.
Other Changes
- Add support for unload and unload.demo custom directories.
- Table API adds support for licensing configuration records.
- Updating lint rules to allow use of fetch and console which are supported in SN Rhino engine
- Record entity detects if new lines exist in field content and uses string literal to preserve them and not write \n
- Fix issue with transitive dependencies not being bundled when multiple versions of the same dependency are referenced for sys modules
- Fix issue with Table entity not syncing choice field changes from instance
- Support remote tables
- Remove script and html tagged template literal syntax highlighting from extension. This was causing issues with code appearing broken due to escape characters interfering with syntax highlight parsing. Recommend using Now.include instead and leverage native file extension capabilities of your editor
- Fix column attributes on transform being deleted
- Wrap html fields with CDATA to fix unescaped characters issue on jelly syntax
- Allow arbitrary fields on any fluent entity. Fluent entities now allow any arbitrary field to be defined that are not part of the built in type to allow setting fields that exist on your instance but not in our type system.