Skip to content

refactor: migrate helpers module to TS#1273

Open
jaissica12 wants to merge 3 commits into
developmentfrom
refactor/SDKE-1111-migrate-helpers-to-TS
Open

refactor: migrate helpers module to TS#1273
jaissica12 wants to merge 3 commits into
developmentfrom
refactor/SDKE-1111-migrate-helpers-to-TS

Conversation

@jaissica12
Copy link
Copy Markdown
Contributor

Background

  • Continuing the effort to migrate remaining JavaScript modules to TypeScript for improved type safety and developer experience across the SDK codebase.

What Has Changed

  • Converted src/helpers.js to src/helpers.ts with full type annotations on all methods, parameters, and return types
  • Converted test/src/tests-helpers.js to test/src/tests-helpers.ts with necessary type adjustments
  • Updated src/sdkRuntimeModels.ts with expanded SDKHelpersApi interface definitions to support the conversion
  • Updated src/consent.ts with import path adjustment for the renamed module
  • Replaced var declarations with const/let to satisfy SonarCloud linting rules
  • Replaced const self = this pattern with arrow functions using lexical this to resolve SonarCloud violation

Screenshots/Video

  • {Include any screenshots or video demonstrating the new feature or fix, if applicable}

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • {Any additional information or context relevant to this PR}

Reference Issue (For employees only. Ignore if you are an outside contributor)

@jaissica12 jaissica12 requested a review from a team as a code owner May 26, 2026 12:07
@cursor
Copy link
Copy Markdown

cursor Bot commented May 26, 2026

PR Summary

Low Risk
Mostly typing and module rename; the only behavioral tweak is a narrow fix in identity callback previous-user resolution when MPIDs collide.

Overview
Migrates the helpers module from JavaScript to TypeScript and aligns runtime types with the typed implementation.

src/helpers.ts replaces helpers.js with explicit types on the Helpers constructor (SDKHelpersApi / IMParticleWebSDKInstance), typed helper methods, const/let instead of var, and arrow functions on several methods so this no longer uses a self alias. getPreviousUser in invokeCallback now returns the next user from the stack when the most recent user matches the current MPID (return users.shift() || null) instead of only reassigning a local variable.

src/sdkRuntimeModels.ts expands SDKHelpersApi (e.g. filterUserIdentities, decoded, parseStringOrNumber, inArray), changes generateHash to return number, relaxes SDKProduct required fields and allows Attributes to be null, and stops omitting identityCallback from SDKInitConfig’s MPConfiguration omit list.

src/consent.ts widens IConsentRulesValues.consentPurpose to string | number for hashed consent rule keys.

test/src/tests-helpers.ts is the TypeScript test port with sandbox typing and casts where the public SDK types are incomplete.

Reviewed by Cursor Bugbot for commit 354bfb4. Bugbot is set up for automated code reviews on this repo. Configure here.

@jaissica12 jaissica12 changed the base branch from master to development May 26, 2026 12:07
@jaissica12 jaissica12 changed the title Refactor/sdke 1111 migrate helpers to ts refactor: migrate helpers module to ts May 26, 2026
@sonarqubecloud
Copy link
Copy Markdown

@jaissica12 jaissica12 changed the title refactor: migrate helpers module to ts refactor: migrate helpers module to TS May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant