Skip to content

feat: unify initialization process with other sdks#106

Merged
cre8ivejp merged 48 commits into
masterfrom
fix/no-spead-after-defaults-lint
Sep 5, 2025
Merged

feat: unify initialization process with other sdks#106
cre8ivejp merged 48 commits into
masterfrom
fix/no-spead-after-defaults-lint

Conversation

@duyhungtnn
Copy link
Copy Markdown
Collaborator

@duyhungtnn duyhungtnn commented Aug 11, 2025

This pull request introduces

  • A new way to init the BKTClient with BKTConfig
  • Support to set the wrapperSDKVersion and wrapperSourceId for the Node OpenFeature Provider
  • A new custom ESLint rule to prevent a common bug pattern with object spreads,
  • It updates Node.js version requirements, makes minor dependency and workflow improvements that fixed #107

refs: bucketeer-io/javascript-client-sdk#236

@duyhungtnn duyhungtnn changed the title lint: Add custom ESLint rule: no-spread-after-defaults fix: prevent undefined from overriding defaults in defineBKTConfig Aug 11, 2025
@duyhungtnn duyhungtnn requested a review from Copilot August 11, 2025 07:10
@duyhungtnn duyhungtnn marked this pull request as ready for review August 11, 2025 07:10
@duyhungtnn duyhungtnn requested a review from cre8ivejp as a code owner August 11, 2025 07:10

This comment was marked as outdated.

@duyhungtnn duyhungtnn requested a review from Copilot August 11, 2025 10:39

This comment was marked as outdated.

@duyhungtnn
Copy link
Copy Markdown
Collaborator Author

@cre8ivejp please help me to take a look

@duyhungtnn duyhungtnn marked this pull request as draft August 12, 2025 04:20
@duyhungtnn
Copy link
Copy Markdown
Collaborator Author

I will put the changes for refactoring the initialization process in this PR. SO I converted this PR back to a draft

@duyhungtnn duyhungtnn changed the title fix: prevent undefined from overriding defaults in defineBKTConfig refactor: the initialization process Aug 12, 2025
@duyhungtnn duyhungtnn requested a review from Copilot August 19, 2025 03:45

This comment was marked as outdated.

This comment was marked as outdated.

@duyhungtnn duyhungtnn requested a review from Copilot August 26, 2025 05:03

This comment was marked as outdated.

@duyhungtnn duyhungtnn requested a review from Copilot August 26, 2025 15:15

This comment was marked as outdated.

@duyhungtnn duyhungtnn self-assigned this Aug 26, 2025
@duyhungtnn duyhungtnn marked this pull request as ready for review August 26, 2025 15:31
@duyhungtnn duyhungtnn requested a review from Copilot August 26, 2025 15:32

This comment was marked as outdated.

@duyhungtnn duyhungtnn marked this pull request as draft September 3, 2025 03:27
@duyhungtnn duyhungtnn force-pushed the fix/no-spead-after-defaults-lint branch 2 times, most recently from 8636734 to a8342d6 Compare September 3, 2025 14:12
Introduces a custom ESLint rule to disallow spreading objects after default properties in object literals, preventing accidental override of defaults with undefined values. Includes rule implementation, documentation, tests, and integration into the ESLint config.
Replaced object spread config merging with explicit property assignment in defineBKTConfig for improved clarity and type safety. Updated initialize to use defineBKTConfig. Added a Makefile target and workflow step for running a custom ESLint rule test.
Corrected 'reafactor' to 'refactor' in the comment about future deprecation and refactoring of the initialize function.
Introduces the sdkVersion parameter to feature flag and segment user cache processors, as well as to event creation and registration logic. Updates all relevant tests and internal calls to ensure sdkVersion is consistently passed and handled throughout the codebase. This change improves traceability and compatibility for SDK versioning in event and cache operations.
Updated event test files to use nodeSDKVersion instead of version when checking the sdkVersion property. This ensures consistency with the updated import from the version module.
Added the sdkVersion parameter to relevant test cases and updated interface property formatting in config and internalConfig for consistency. Also added TODO comments for missing tests in metricsEvent functions and removed an unnecessary blank line in sourceId.
Corrects the call to createInternalSdkErrorMetricsEvent in toErrorMetricsEvent to include sdkVersion as an argument. Also removes an unused convertMS function and a TODO comment.
Replaces the createBasicConfig helper with a baseConfig constant and updates test cases to use more explicit type casting and object spreading. This improves readability, reduces indirection, and ensures better type safety in test setup.
Added logger warnings when config values are invalid and default values are used in config.ts. Improved code formatting and consistency in both config.ts and internalConfig.ts, including semicolon usage and export statements. No functional changes to logic except for added logging.
Fixed minor formatting issues in sourceId type and function definitions, and corrected a comment typo in config.ts. No functional changes were made.
Introduces a type-check step to the pull request workflow using the Makefile. Updates ESLint config to include additional test directories and removes 'symbol-observable' from test TypeScript config types.
Refactored BKTConfig and related code to replace the 'pollingInterval' property with 'cachePollingInterval' for clarity. Updated all usages, validation logic, and tests to reflect the new property name. Also added 'skipLibCheck' to TypeScript configs for improved build performance.
Both feature flag and segment users cache processors now execute cache update immediately upon start, in addition to scheduled polling. Unit tests have been updated to reflect the new polling and event emission behavior.
Introduces a 'test-single' Makefile target to run individual test files. Updates README with instructions for running all tests and single tests using the new Makefile commands.
Updated cachePollingInterval from 1000/3000ms to 15000ms in all local evaluation test files to reduce polling frequency. This change may help decrease load on the API and improve test stability.
Refactored the pull request workflow to separate linting and custom ESLint rule tests. Updated various dependencies in package.json to newer versions for improved stability and compatibility.
Replaces version tags with commit SHAs for actions/checkout, actions/setup-node, and actions/cache to improve security and reliability. Also updates step names for clarity in the workflow.
@duyhungtnn duyhungtnn force-pushed the fix/no-spead-after-defaults-lint branch from 05f5303 to d268fbb Compare September 3, 2025 16:11
Updated the import path for FEATURE_FLAG_REQUESTED_AT in polling.ts and update.ts test files to reference the correct location. This resolves incorrect import errors due to a previous path typo.
@duyhungtnn duyhungtnn requested a review from Copilot September 3, 2025 17:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a comprehensive refactoring of the SDK initialization process to improve modularity and support for wrapper SDKs like OpenFeature. It includes a new configuration approach, better source ID management, and enhanced type safety while maintaining backward compatibility.

Key changes:

  • Introduces new BKTConfig interface and defineBKTConfig function for improved configuration management
  • Adds support for wrapper SDK source ID and version tracking for better telemetry
  • Refactors internal initialization to use InternalConfig with proper validation

Reviewed Changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/config.ts Introduces new BKTConfig interface and defineBKTConfig function
src/internalConfig.ts New internal configuration management with validation
src/index.ts Adds new initializeBKTClient function and maintains backward compatibility
src/objects/sourceId.ts Converts enum to const object with helper functions
src/objects/version.ts Renames version export to nodeSDKVersion
Multiple event files Updates event creation to accept sourceId and sdkVersion parameters
Comments suppressed due to low confidence (1)

src/objects/status.ts:1

  • [nitpick] Property shorthand can be used here. These can be simplified to sourceId, and sdkVersion, since the property names match the variable names.
import { ApiId, NodeApiIds } from './apiId';

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread tsconfig.test.json
Comment thread tsconfig.test.json Outdated
Comment thread src/objects/metricsEvent.ts
Comment thread src/objects/goalEvent.ts
Comment thread src/objects/goalEvent.ts
Comment thread src/objects/evaluationEvent.ts
Comment thread src/objects/evaluationEvent.ts
Comment thread src/objects/evaluationEvent.ts
Comment thread src/config.ts
Comment thread src/config.ts Outdated
Deleted 'skipLibCheck' and 'pretty' options from tsconfig.json and tsconfig.test.json to simplify configuration and remove unnecessary settings.
Corrected the comment from 'cachPollingInterval' to 'cachePollingInterval' for clarity in the config validation logic.
@duyhungtnn duyhungtnn marked this pull request as ready for review September 4, 2025 03:53
@cre8ivejp cre8ivejp changed the title refactor: the initialization process feat: new initialization process Sep 5, 2025
@cre8ivejp cre8ivejp changed the title feat: new initialization process feat: unify initialization process with other sdks Sep 5, 2025
Copy link
Copy Markdown
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
Thank you!

@cre8ivejp cre8ivejp merged commit b431026 into master Sep 5, 2025
8 checks passed
@cre8ivejp cre8ivejp deleted the fix/no-spead-after-defaults-lint branch September 5, 2025 03:43
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.

3 participants