Skip to content

Refactor TypeScript declarations #834

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

Merged
merged 9 commits into from
Nov 2, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build

- name: Store assets
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/refactor_type_definitions' || github.ref == 'refs/heads/master') }}
uses: actions/upload-artifact@v3
with:
name: assets
Expand All @@ -69,7 +69,7 @@ jobs:
name: Upload assets
runs-on: ubuntu-20.04
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/refactor_type_definitions' }}
strategy:
matrix:
environment:
Expand Down
7 changes: 2 additions & 5 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
11.0.0 (October XX, 2024)
11.0.0 (November 1, 2024)
- Added support for targeting rules based on large segments for browsers.
- Added `factory.destroy()` method, which invokes the `destroy` method of all clients created by the factory.
- Updated @splitsoftware/splitio-commons package to version 2.0.0 that includes major updates and updated some transitive dependencies for vulnerability fixes.
- Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for EcmaScript Modules build.
- Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for ECMAScript Modules build.
- BREAKING CHANGES:
- Dropped support for NodeJS v6. The SDK now requires NodeJS v14 or above.
- Removed internal ponyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or provide a polyfill.
- Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations. The `integrations` configuration option has been removed from the SDK factory configuration, along with the associated interfaces in the TypeScript definitions.
- Removed the `core.trafficType` configuration option (`SplitIO.IBrowserSettings['core']['trafficType]`) and the `trafficType` parameter from the SDK `client()` method in Browser (`SplitIO.IBrowserSDK['client']`). As a result, traffic types can no longer be bound to SDK clients, and the traffic type must be provided in the `track` method.
- TypeScript definitions:
- Removed an overloaded `client` method in the `SplitIO.ISDK` interface that accepted `key` and `trafficType` parameters. This interface corresponds to the SDK factory instance in NodeJS, which, unlike `SplitIO.IBrowserSDK` for the Browser, does not handle multiple client instances based on keys.
- Updated the `SplitIO.IBrowserSDK` and `SplitIO.IBrowserClient` interfaces to no longer extend the `SplitIO.ISDK` and `SplitIO.IClient` interfaces respectively, as the SDK factory instance in NodeJS or server-side (`SplitIO.ISDK`) has a different API than the SDK client instance in the Browser or client-side (`SplitIO.IBrowserClient`).

10.28.0 (September 6, 2024)
- Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:
Expand Down
21 changes: 11 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio",
"version": "11.0.0-rc.1",
"version": "11.0.0-rc.5",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -38,8 +38,7 @@
"node": ">=14.0.0"
},
"dependencies": {
"@splitsoftware/splitio-commons": "2.0.0-rc.3",
"@types/ioredis": "^4.28.0",
"@splitsoftware/splitio-commons": "2.0.0-rc.6",
"bloom-filters": "^3.0.0",
"ioredis": "^4.28.0",
"js-yaml": "^3.13.1",
Expand Down Expand Up @@ -109,9 +108,7 @@
"test-node-e2e-errorCatching": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/errorCatching/node.spec.js | tap-min",
"test-node-e2e-push": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/push/node.spec.js | tap-min",
"test-node-e2e-redis": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/consumer/node_redis.spec.js | tap-min",
"pretest-ts-decls": "npm run build-esm && npm run build-cjs && npm link",
"test-ts-decls": "./scripts/ts-tests.sh",
"posttest-ts-decls": "npm rm --location=global @splitsoftware/splitio && npm install",
"test-ts-decls": "tsc --build ts-tests",
"test": "npm run test-node && npm run test-browser",
"all": "npm run check && npm run build && npm run test-ts-decls && npm run test",
"publish:rc": "npm run check && npm run build && npm publish --tag canary",
Expand Down
28 changes: 0 additions & 28 deletions scripts/ts-tests.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/settings/defaults/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const packageVersion = '11.0.0-rc.1';
export const packageVersion = '11.0.0-rc.5';
17 changes: 9 additions & 8 deletions ts-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
* @author Nico Zelaya <nicolas.zelaya@split.io>
*/

import { SplitFactory } from '@splitsoftware/splitio';
import { SplitFactory } from '../types/index';
import { SplitFactory as SplitFactoryCS } from '../types/client';
import { SplitFactory as SplitFactorySS } from '../types/server';

let stringPromise: Promise<string>;
let splitNamesPromise: Promise<SplitIO.SplitNames>;
Expand Down Expand Up @@ -166,6 +168,9 @@ browserSettings = {
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
BrowserSDK = SplitFactory(browserSettings);
SDK = SplitFactorySS(nodeSettings);
AsyncSDK = SplitFactorySS(asyncSettings);
BrowserSDK = SplitFactoryCS(browserSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
Expand All @@ -174,15 +179,10 @@ const instantiatedSettingsCore: {
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsMode: ('standalone' | 'consumer' | 'consumer_partial' | 'localhost') = SDK.settings.mode;
const instantiatedSettingsScheduler: { [key: string]: number } = SDK.settings.scheduler;
const instantiatedSettingsStartup: { [key: string]: number } = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
options: Object,
// It can have any of the storages.
type: SplitIO.NodeSyncStorage | SplitIO.NodeAsyncStorage | SplitIO.BrowserStorage
} = SDK.settings.storage;
const instantiatedSettingsStorage = SDK.settings.storage as SplitIO.StorageOptions;
const instantiatedSettingsUrls: { [key: string]: string } = SDK.settings.urls;
const instantiatedSettingsVersion: string = SDK.settings.version;
let instantiatedSettingsFeatures = SDK.settings.features as SplitIO.MockedFeaturesMap;
Expand Down Expand Up @@ -635,6 +635,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = {
debug: true,
sync: {
splitFilters: splitFilters,
impressionsMode: 'DEBUG',
}
};

Expand Down
12 changes: 0 additions & 12 deletions ts-tests/package.json

This file was deleted.

3 changes: 2 additions & 1 deletion ts-tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"compilerOptions": {
"noImplicitAny": true,
"target": "es5",
"module": "commonjs"
"module": "commonjs",
"noEmit": true,
},
"files": [
"index"
Expand Down
3 changes: 2 additions & 1 deletion types/client/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Declaration file for JavaScript Split Software SDK
// Project: http://www.split.io/

/// <reference path="../splitio.d.ts" />
import '@splitsoftware/splitio-commons';

export = JsSdk;

declare module JsSdk {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Project: http://www.split.io/
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>

/// <reference path="./splitio.d.ts" />
import '@splitsoftware/splitio-commons';

export = JsSdk;

Expand Down
3 changes: 2 additions & 1 deletion types/server/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Declaration file for JavaScript Split Software SDK
// Project: http://www.split.io/

/// <reference path="../splitio.d.ts" />
import '@splitsoftware/splitio-commons';

export = JsSdk;

declare module JsSdk {
Expand Down
Loading
Loading