npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@edraj/tsdmart

v5.0.3

Published

A TypeScript implementation of the Dmart that depends on axios.

Readme

Dmart

A TypeScript implementation of the Dmart that depends on axios.

Setup

make sure you define axiosDmartInstance with your axios instance before importing the Dmart class.

APIs

  • setAxiosInstance(axiosInstance: AxiosInstance) - Sets the axios instance to be used by the Dmart class.
  • getAxiosInstance() -> AxiosInstance - Gets the axios instance used by the Dmart class.
  • getBaseUrl() -> string - Gets the base URL of the Dmart instance.
  • setBaseUrl(baseUrl: string) - Sets the base URL of the Dmart instance.
  • getHeaders() - Gets the headers used by the Dmart instance.
  • setHeaders(headers: Record<string, string>) - Sets the headers used by the Dmart instance.
  • getToken() -> string | null - Gets the token used by the Dmart instance.
  • setToken(token: string) - Sets the token used by the Dmart instance.
  • login(shortname: string, password: string) -> Promise<LoginResponse> - Performs a login action (shortname).
  • loginBy(credentials: dict, password: string) -> Promise<LoginResponse> - Performs a login action but altering the default identifier that you can customise.
  • logout() -> Promise<ApiResponse> - Performs a logout action.
  • otpRequest(request: SendOTPRequest, acceptLanguage: string | null = null) -> Promise<ApiResponse> - Requests an OTP (One Time Password) for login.
  • otpRequestLogin(request: SendOTPRequest, acceptLanguage: string | null = null) -> Promise<ApiResponse> - Requests an OTP for login and returns a login response.
  • passwordResetRequest(request: PasswordResetRequest) -> Promise<ApiResponse> - Requests a password reset.
  • confirmOtp(request: ConfirmOTPRequest) -> Promise<ApiResponse> - Confirms the OTP (One Time Password) for login or password reset.
  • userReset(shortname: string) -> Promise<ApiResponse> - Resets the user password by sending an OTP to the user's email.
  • validatePassword(password: string) -> Promise<ApiResponse> - Validates the password.
  • createUser(request: ActionRequestRecord) -> Promise<ActionResponse> - Creates a new user.
  • updateUser(request: ActionRequestRecord) -> Promise<ActionResponse> - Updates an existing user.
  • checkExisting(prop: string, value: string) -> Promise<ResponseEntry> - Checks if a user exists.
  • getProfile() -> Promise<ProfileResponse> - Gets the profile of the current user.
  • query(query: QueryRequest) -> Promise<ApiQueryResponse | null> - Performs a query action.
  • csv(query: any) -> Promise<ApiQueryResponse> - Query the entries as csv file.
  • space(action: ActionRequest) -> Promise<ActionResponse> - Performs actions on spaces.
  • request(action: ActionRequest) -> Promise<ActionResponse> - Performs a request action.
  • retrieveEntry(request: RetrieveEntryRequest, scope: string = "managed") -> Promise<ResponseEntry | null> - Performs a retrieve action.
  • uploadWithPayload(request: UploadWithPayloadRequest, scope: string = "managed") -> Promise<ApiResponse> - Uploads a file with a payload.
  • fetchDataAsset(request: FetchDataAssetRequest) -> Promise<any> - Fetches a data asset.
  • getSpaces() -> Promise<ApiResponse | null> - Gets the spaces (user query).
  • getChildren(request: GetChildrenRequest) -> Promise<ApiResponse | null> - Gets the children of a space (user query).
  • getAttachmentUrl(request: GetAttachmentURLRequest, scope: string = "managed") -> string - Constructs the URL of an attachment.
  • getSpaceHealth(space_name: string) -> Promise<ApiQueryResponse & { attributes: { folders_report: Object } }> - Gets the health check of a space.
  • getPayload(request: GetPayloadRequest, scope: string = "managed") -> Promise<any> - Gets the payload of a resource.
  • progressTicket(request: ProgressTicketRequest) -> Promise<ApiQueryResponse & { attributes: { folders_report: Object } }> - Performs a progress ticket action.
  • submit(request: SubmitRequest) -> Promise<any> - Submits a record (log/feedback) to Dmart.
  • getManifest() -> Promise<any> - Gets the manifest of the current instance.
  • getSettings() -> Promise<any> - Gets the settings of the current instance.

Usage

  • Initialize the Dmart instance:
export const dmartAxios = axios.create({
    baseURL: backendURL,
    withCredentials: true,
});
Dmart.setAxiosInstance(dmartAxios);

Manage user

  • Create user
const createUserRequest: ActionRequest = {
    space_name: 'users',
    request_type: RequestType.create,
    records: [
        {
            resource_type: ResourceType.user,
            shortname: 'john_doe', // auto: for auto-generated shortname
            attributes: {
                password: 'my-password',
                is_active: true,
                // email, msisdn, displayname are optional
                email: '[email protected]',
                msisdn: '1234567890',
                password: 'securePassword123',
                displayname: {en: 'John Doe'},
                // roles is optional
                roles: ['store_manager'],
                // is_msisdn_verified, is_email_verified are optional
                is_msisdn_verified: true,
                is_email_verified: true,
                // is force_password_change is optional
                is_force_password_change: false,
                // payload is optional
                payload: {
                    content_type: 'json',
                    body: {
                        additional_info: 'This is some additional information about the user.'
                    }
                }
            }
        }
    ]
};

const response = await Dmart.createUser(createUserRequest.records[0]);
  • Login with credentials
const response = await Dmart.login('john_doe', 'securePassword123');

loginBy({email: '[email protected]'}, 'securePassword123');

loginBy({msisdn: '1234567890'}, 'securePassword123');
  • Get user profile
const profileResponse = await Dmart.getProfile();
  • Update user
const updateUserRequest: ActionRequest = {
    space_name: 'users',
    request_type: RequestType.update,
    records: [
        {
            resource_type: ResourceType.user,
            shortname: 'john_doe',
            attributes: {
                payload: {
                    content_type: 'json',
                    body: {
                        'rotation': 'bi-weekly'
                    }
                }
            }
        }
    ]
};

const response = await Dmart.updateUser(updateUserRequest.records[0]);

Managing entries

  • Create entry
const createRequest: ActionRequest = {
    space_name: 'test_space',
    request_type: RequestType.create,
    records: [
        {
            resource_type: ResourceType.content,
            subpath: '/dummies',
            shortname: 'dummy_001',
            attributes: {
                payload: {
                    content_type: 'json',
                    body: {
                        title: 'Test Dummy Entry',
                        description: 'This is a test dummy entry',
                        status: 'active'
                    }
                }
            }
        }
    ]
};
const response = await Dmart.request(createRequest);
  • Update entry
const updateRequest: ActionRequest = {
    space_name: 'test_space',
    request_type: RequestType.update,
    records: [
        {
            resource_type: ResourceType.content,
            subpath: '/dummies',
            shortname: 'dummy_001',
            attributes: {
                payload: {
                    content_type: 'json',
                    body: {
                        status: 'unactive'
                    }
                }
            }
        }
    ]
};
const response = await Dmart.request(createRequest);
  • Delete entry
const deleteRequest: ActionRequest = {
    space_name: 'test_space',
    request_type: RequestType.delete,
    records: [
        {
            resource_type: ResourceType.content,
            subpath: '/dummies',
            shortname: 'dummy_001',
            attributes: {}
        }
    ]
};
const response = await Dmart.request(createRequest);