
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
sfcc-ocapi-documents
Advanced tools
TypeScript types based on the official OCAPI documentation
using npm:
npm install sfcc-ocapi-documents
using yarn:
yarn add sfcc-ocapi-documents
import OCAPI from 'sfcc-ocapi-documents'
const basket: OCAPI.Basket
import OCAPI from 'sfcc-ocapi-documents/20.10'
const basket: OCAPI.Basket = {...}
import OCAPI, {Util} from 'sfcc-ocapi-documents/20.10'
const basket: Util.Response<OCAPI.Basket> = {...}
latestprevious20.220.320.420.820.920.1021.221.621.8 // latest
import OCAPI from 'sfcc-ocapi-documents'
// equivalent to above
import OCAPI from 'sfcc-ocapi-documents/latest'
// specific version
import OCAPI from 'sfcc-ocapi-documents/21.2'
To add custom properties to the documents you can create a OCAPI.d.ts (example). If the keys of the interface are not prefixed with c_ - they will be automatically prefixed
declare namespace OCAPI {
namespace Custom {
interface ProductItem {
customAttribute: boolean
c_otherCustomAttribute: boolean
}
}
}
Dash separated numbers
import { Util } from 'sfcc-ocapi-documents'
const date: Util.Date = '2020-10-10';
the ISO 8601 standard: "2012-03-19T07:22:59Z".
import { Util } from 'sfcc-ocapi-documents'
export const dateTime: Util.DateTime = "2012-03-19T07:22:59Z";
Lowercase day of the week
import { Util } from 'sfcc-ocapi-documents'
const day: Util.DayOfWeek = "friday";
import { Util } from 'sfcc-ocapi-documents'
const time: Util.LocalTime = "23:59:59";
Placeholder indicating the value may be localized
import { Util } from 'sfcc-ocapi-documents'
const str: Util.Localized<string> = "супер кул";
Object indicating time interval
import { Util } from 'sfcc-ocapi-documents'
const timeOfDay: Util.TimeOfDay = {
time_from: "11:59:59",
time_to: "23:59:59"
};
Ensures the keys of the given object are prefixed with c_
import { Util } from 'sfcc-ocapi-documents'
type CustomData = {
c_attr1: "value 1",
attr2: boolean
}
const obj: Util.WithCustom<CustomData> = {
c_attr1: "value 1",
c_attr2: true
}
If given an object ensures it has optional _type property with string value and all of it's nested objects
import { Util } from 'sfcc-ocapi-documents'
type Data = {
prop1: string
prop2: {
nestedProp: boolean
},
prop3: {
nestedProp: boolean
}
}
const typedData: Util.Typed<Data> = {
_type: "data",
prop1: "val",
prop2: {
_type: "nested",
nestedProp: true
},
prop3: {
nestedProp: false
}
}
Adds _v: string, _resource_state?: string; and _flash?: Typed<Flash>[]; to the given object and ensures the rest of the properties are Typed
PRs are welcome for adding missing interfaces or versions
FAQs
SFCC Shop API documents
The npm package sfcc-ocapi-documents receives a total of 18 weekly downloads. As such, sfcc-ocapi-documents popularity was classified as not popular.
We found that sfcc-ocapi-documents demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.