Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sfcc-dts

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sfcc-dts

> High quality Salesforce Commerce Cloud type definitions. A dw-api-types "done right"

  • 1.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
497
decreased by-17.17%
Maintainers
1
Weekly downloads
 
Created
Source

Salesforce Commerce Cloud type definitions

High quality Salesforce Commerce Cloud type definitions. A dw-api-types "done right"

Features

sfcc-dts provides full typeScript definitions for Salesforce Commerce Cloud apis, plus a typescript plugin for resolving requires using "*" cartridge path and a fancy wizard for setting up your project.

The aim of the project is to provide fully working typescript compilation of commerce cloud server side javascript.

Wait, why is this better than the official dw-api from salesforce?

Well, tons of reasons:

  • dw-api definitions are largerly incomplete
  • dw-api definitions are often wrongly defined in terms of static properties/methods
  • dw-api are not documented. sfcc-dts has full documentation for classes, methods, properties, parameters and return types
  • dw-api is not actively updated when new API gets released. Instead, sfcc-dts definitions are automatically generated by parsing the public salesforce documentation, so they can easily be kept up to date

Installation

Using the wizard:

$ npm i -g sfcc-dts

From your sfcc project root directory type:

$ sfcc-dts-setup

The wizard will guide you for adding required dependencies to package.json, setup a working tsconfig.json and configure a customizable dw types entry point for your project.

VSCode setup

Vscode will fully benefit from the typescript configuration from tsconfig.json only when is configured for using the workspace version of typescript.

For enabling it press [cmd]+[shift]+P -> "TypeScript: Select TypeScript version" and select "Use workspace version" with the version pointing to the node_modules/typescript dir in the workspace.

vscode selection of typescript version

If the "TypeScript: Select TypeScript version" option or the expected directory dooesn't show up, just open the node_modules/typescript/bin/tsc file inside vscode and retry, this is usually enough to make vscode detect the available typescript installation.

Type definitions for custom attributes

sfcc-dts can generate definitions for project-specific system object extensions by parsing a system-objecttype-extensions.xml file.

Custom attribute definitions are automatically generated by the sfcc-dts-setup wizard, assuming a system-objecttype-extensions.xml file is available (the default location is sites/site_template/meta/system-objecttype-extensions.xml but the wizard will allow you to choose a different path) and saved to @types/dw/attrs.d.ts.

Definitions can be updated by running sfcc-dts-updateattrs

Usage

If everything goes well you will see autocomplete and validation working in your existing javascript files. Typescript will fully detect:

  • requires using dw/system/Site syntax
  • cartridge requires using */cartridge/somefile or ~/cartridge/somefile
  • fully qualified class names such as dw.system.Site
  • dw globals such as request
vscode example ofworking setup

Todo

Still in the checklist:

  • Find a proper way to define module.superModule augmenting the standard NodeModule definition

License

Released under the MIT license.

Keywords

FAQs

Package last updated on 22 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc