@gigya-ts/web-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.19 • Public • Published

@gigya-ts/web-sdk

Add type-safety to a Gigya Web SDK project.

See @gigya-ts/gigya if you are using the Gigya REST API instead (even from the browser!).

Installation

Install the @gigya-ts/gigya package from your package manager of choice:

# npm
npm add @gigya-ts/web-sdk
# pnpm
pnpm add @gigya-ts/web-sdk

Usage

0. (Optional) Define your custom Gigya schemas

See adding custom schemas to define your custom schemas (data, preferences, etc.) so that response types from the Web SDK include your custom fields.

1. Extend the global window with the gigya types

Extend the global window with the Gigya Web SDK, including your schemas:

// my-gigya.ts
import { GigyaWebSDK } from '@gigya-ts/web-sdk';

declare global {
    interface Window {
        onGigyaServiceReady?: () => void;

        gigya?: GigyaWebSDK<MyAccountSchema, MyPreferencesSchema, MySubscriptionsSchema>;
    }
}

Once the global window has been extended, you can use the Web SDK as you normally would:

window.onGigyaServiceReady = () => {
    window.gigya?.accounts.getAccountInfo({
        callback: (response) => {
            console.log('gigya.account.getAccountInfo response', response);
        },
    });
};

Readme

Keywords

none

Package Sidebar

Install

npm i @gigya-ts/web-sdk

Weekly Downloads

486

Version

0.1.19

License

none

Unpacked Size

23.3 kB

Total Files

18

Last publish

Collaborators

  • tswymer
  • jevgenijs-jaunslavietis