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

0.0.13 • Public • Published

@gigya-ts/web-sdk

Type definitions for interacting with the Gigya / SAP Customer Data Cloud Web SDK.

See @gigya-ts/gigya if you are working with the REST API instead.

Installation

# npm
npm install @gigya-ts/web-sdk

Usage

Define your own schema types. They will be used to type the data used when interacting with the Web SDK.

import { GigyaPreference } from '@gigya-ts/web-sdk';

// Data Schema
type MyDataSchema = {
    myCustomString: string;
    myCustomObject: {
        myCustomNumber: number;
    };
};

// Preferences Schema
type MyPreferencesSchema = {
    terms: {
        myTerms: GigyaPreference;
    };
    myCustomPreference: GigyaPreference;
};

// Subscriptions Schema
type MySubscriptionsSchema = {};

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

// gigya.d.ts (or any other name)
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

215

Version

0.0.13

License

none

Unpacked Size

16.1 kB

Total Files

14

Last publish

Collaborators

  • tswymer