Testing TypeScript - missing exported IdentificationEngine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2024 11:20 AM - edited ‎10-31-2024 11:24 AM
While we test using typescript and transpiling, we can use, import, mock, test GlideRecord in our script_include code
import { GlideRecord } from '@servicenow/glide';
We dont see scoped IdentificationEngine exported in types, only global IdentificationEngineScriptableApi
Is this on purpose, are we missing something?
If I would be to run this in backgroundScript, I would need to do something like:
const stringResult = sn_cmdb.IdentificationEngine.createOrUpdateCI(verifiedDiscoverySource, stringifiedPayload);
Thanks, Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 11:00 AM
Servicenow will probably not provide types for every (niche) module out there. What you can do is create your own d.ts file for this function.
this is what we've done even before the servicenow SDK existed.
I still wonder though how the API doc is generated. If they do it automatically they may have the json or types already available. So we don't have to do it manually or reverse it from their api doc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2024 11:17 AM
We do not have type definitions for every available modules yet, but will be updating types with new versions
In the meantime, as @paki suggested, you can add custom declarations to your project
// custom_definitions.d.ts
declare module '@servicenow/glide/sn_cmdb' {
class IdentificationEngine {
static createOrUpdateCI(String source, String input): any
}
}
// Then in the js file which is serialized in my app package:
import { gs } from '@servicenow/glide'
import { IdentificationEngine } from '@servicenow/glide/sn_cmdb'
const result = IdentificationEngine.createOrUpdateCI('ServiceNow', input);
Hope that helps.
-- Venkat