Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsdoc Lint: fix types in modules userId #12196

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/userId/eids.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {deepClone, isFn, isStr} from '../../src/utils.js';
/*
* @typedef {import('../modules/userId/index.js').SubmoduleContainer} SubmoduleContainer

/**
* @typedef {import('./index.js').SubmodulePriorityMap} SubmodulePriorityMap
*/

export const EID_CONFIG = new Map();
Expand Down
72 changes: 29 additions & 43 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,47 @@
*/

/**
* @interface Submodule
* @typedef Submodule
* @property {string} name - used to link submodule with config
* @property {decode} decode
* @property {getId} getId
* @property {Object} eids
* @property {number} [gvlid] - vendor ID
* @property {extendId} [extendId]
* @property {function} [domainOverride] - use a predefined domain override for cookies or provide your own
* @property {function(): string} [findRootDomain] - returns the root domain
*/

/**
* @function
* @summary performs action to obtain id and return a value in the callback's response argument.
* If IdResponse#id is defined, then it will be written to the current active storage.
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#getId
* Performs action to obtain id and return a value in the callback's response argument.
* If IdResponse#id is defined, then it will be written to the current active storage.
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @callback getId
* @param {SubmoduleConfig} config
* @param {ConsentData|undefined} consentData
* @param {(Object|undefined)} cacheIdObj
* @return {(IdResponse|undefined)} A response object that contains id and/or callback.
* @param {Object|undefined} cacheIdObj
* @returns {IdResponse|undefined} A response object that contains id and/or callback.
*/

/**
* @function
* @summary Similar to Submodule#getId, this optional method returns response to for id that exists already.
* If IdResponse#id is defined, then it will be written to the current active storage even if it exists already.
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @name Submodule#extendId
* Similar to `getId`, this optional method returns response to for id that exists already.
* If IdResponse#id is defined, then it will be written to the current active storage even if it exists already.
* If IdResponse#callback is defined, then it'll called at the end of auction.
* It's permissible to return neither, one, or both fields.
* @callback extendId
* @param {SubmoduleConfig} config
* @param {ConsentData|undefined} consentData
* @param {Object} storedId - existing id, if any
* @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback.
* @returns {IdResponse|function(callback:function)} A response object that contains id and/or callback.
*/

/**
* @function
* @summary decode a stored value for passing to bid requests
* @name Submodule#decode
* Decode a stored value for passing to bid requests
* @callback decode
* @param {Object|string} value
* @param {SubmoduleConfig|undefined} config
* @return {(Object|undefined)}
*/

/**
* @property
* @summary used to link submodule with config
* @name Submodule#name
* @type {string}
*/

/**
* @property
* @summary use a predefined domain override for cookies or provide your own
* @name Submodule#domainOverride
* @type {(undefined|function)}
*/

/**
* @function
* @summary Returns the root domain
* @name Submodule#findRootDomain
* @returns {string}
* @returns {Object|undefined}
*/

/**
Expand All @@ -69,6 +53,7 @@
* @property {(SubmoduleStorage|undefined)} storage - browser storage config
* @property {(SubmoduleParams|undefined)} params - params config for use by the submodule.getId function
* @property {(Object|undefined)} value - if not empty, this value is added to bid requests for access in adapters
* @property {string[]} [enabledStorageTypes]
*/

/**
Expand Down Expand Up @@ -111,6 +96,7 @@
* @property {(Object|undefined)} idObj - cache decoded id value (this is copied to every adUnit bid)
* @property {(function|undefined)} callback - holds reference to submodule.getId() result if it returned a function. Will be set to undefined after callback executes
* @property {StorageManager} storageMgr
* @property {string[]} [enabledStorageTypes]
*/

/**
Expand All @@ -122,8 +108,8 @@

/**
* @typedef {Object} IdResponse
* @property {(Object|undefined)} id - id data
* @property {(function|undefined)} callback - function that will return an id
* @property {Object} [id] - id data
* @property {function} [callback] - function that will return an id
*/

/**
Expand Down
17 changes: 7 additions & 10 deletions modules/yandexIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

// @ts-check

/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
* @typedef {import('../modules/userId/index.js').SubmoduleConfig} SubmoduleConfig
*/

import { MODULE_TYPE_UID } from '../src/activities/modules.js';
import { submodule } from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';
Expand All @@ -26,11 +31,8 @@ export const PREBID_STORAGE = getStorageManager({
bidderCode: undefined
});

/** @type {Submodule} */
export const yandexIdSubmodule = {
/**
* Used to link submodule with config.
* @type {string}
*/
name: BIDDER_CODE,
/**
* Decodes the stored id value for passing to bid requests.
Expand All @@ -41,11 +43,6 @@ export const yandexIdSubmodule = {

return { [YANDEX_ID_KEY]: value };
},
/**
* @param {import('./userId/index.js').SubmoduleConfig} submoduleConfig
* @param {unknown} [_consentData]
* @param {string} [storedId] Id that was saved by the core previously.
*/
getId(submoduleConfig, _consentData, storedId) {
if (checkConfigHasErrorsAndReport(submoduleConfig)) {
return;
Expand All @@ -70,7 +67,7 @@ export const yandexIdSubmodule = {
};

/**
* @param {import('./userId/index.js').SubmoduleConfig} submoduleConfig
* @param {SubmoduleConfig} submoduleConfig
* @returns {boolean} `true` - when there are errors, `false` - otherwise.
*/
function checkConfigHasErrorsAndReport(submoduleConfig) {
Expand Down