
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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> = {...}
latest
previous
20.2
20.3
20.4
20.8
20.9
20.10
21.2
21.6
21.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 30 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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.