Skip to content

Commit 8d92ba9

Browse files
Merge pull request #834 from splitio/refactor_type_definitions
Refactor TypeScript declarations
2 parents a625171 + 4c9b7af commit 8d92ba9

File tree

13 files changed

+35
-1742
lines changed

13 files changed

+35
-1742
lines changed

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build
5959

6060
- name: Store assets
61-
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
61+
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/refactor_type_definitions' || github.ref == 'refs/heads/master') }}
6262
uses: actions/upload-artifact@v3
6363
with:
6464
name: assets
@@ -69,7 +69,7 @@ jobs:
6969
name: Upload assets
7070
runs-on: ubuntu-20.04
7171
needs: build
72-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
72+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/refactor_type_definitions' }}
7373
strategy:
7474
matrix:
7575
environment:

CHANGES.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
11.0.0 (October XX, 2024)
1+
11.0.0 (November 1, 2024)
22
- Added support for targeting rules based on large segments for browsers.
33
- Added `factory.destroy()` method, which invokes the `destroy` method of all clients created by the factory.
44
- Updated @splitsoftware/splitio-commons package to version 2.0.0 that includes major updates and updated some transitive dependencies for vulnerability fixes.
5-
- Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for EcmaScript Modules build.
5+
- Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for ECMAScript Modules build.
66
- BREAKING CHANGES:
77
- Dropped support for NodeJS v6. The SDK now requires NodeJS v14 or above.
88
- 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.
99
- 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.
1010
- 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.
11-
- TypeScript definitions:
12-
- 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.
13-
- 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`).
1411

1512
10.28.0 (September 6, 2024)
1613
- Updated @splitsoftware/splitio-commons package to version 1.17.0 that includes minor updates:

package-lock.json

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio",
3-
"version": "11.0.0-rc.1",
3+
"version": "11.0.0-rc.5",
44
"description": "Split SDK",
55
"files": [
66
"README.md",
@@ -38,8 +38,7 @@
3838
"node": ">=14.0.0"
3939
},
4040
"dependencies": {
41-
"@splitsoftware/splitio-commons": "2.0.0-rc.3",
42-
"@types/ioredis": "^4.28.0",
41+
"@splitsoftware/splitio-commons": "2.0.0-rc.6",
4342
"bloom-filters": "^3.0.0",
4443
"ioredis": "^4.28.0",
4544
"js-yaml": "^3.13.1",
@@ -109,9 +108,7 @@
109108
"test-node-e2e-errorCatching": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/errorCatching/node.spec.js | tap-min",
110109
"test-node-e2e-push": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/push/node.spec.js | tap-min",
111110
"test-node-e2e-redis": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/consumer/node_redis.spec.js | tap-min",
112-
"pretest-ts-decls": "npm run build-esm && npm run build-cjs && npm link",
113-
"test-ts-decls": "./scripts/ts-tests.sh",
114-
"posttest-ts-decls": "npm rm --location=global @splitsoftware/splitio && npm install",
111+
"test-ts-decls": "tsc --build ts-tests",
115112
"test": "npm run test-node && npm run test-browser",
116113
"all": "npm run check && npm run build && npm run test-ts-decls && npm run test",
117114
"publish:rc": "npm run check && npm run build && npm publish --tag canary",

scripts/ts-tests.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/settings/defaults/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const packageVersion = '11.0.0-rc.1';
1+
export const packageVersion = '11.0.0-rc.5';

ts-tests/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
* @author Nico Zelaya <nicolas.zelaya@split.io>
1212
*/
1313

14-
import { SplitFactory } from '@splitsoftware/splitio';
14+
import { SplitFactory } from '../types/index';
15+
import { SplitFactory as SplitFactoryCS } from '../types/client';
16+
import { SplitFactory as SplitFactorySS } from '../types/server';
1517

1618
let stringPromise: Promise<string>;
1719
let splitNamesPromise: Promise<SplitIO.SplitNames>;
@@ -166,6 +168,9 @@ browserSettings = {
166168
SDK = SplitFactory(nodeSettings);
167169
AsyncSDK = SplitFactory(asyncSettings);
168170
BrowserSDK = SplitFactory(browserSettings);
171+
SDK = SplitFactorySS(nodeSettings);
172+
AsyncSDK = SplitFactorySS(asyncSettings);
173+
BrowserSDK = SplitFactoryCS(browserSettings);
169174

170175
// The settings values the SDK expose.
171176
const instantiatedSettingsCore: {
@@ -174,15 +179,10 @@ const instantiatedSettingsCore: {
174179
labelsEnabled: boolean,
175180
IPAddressesEnabled: boolean
176181
} = SDK.settings.core;
177-
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
182+
const instantiatedSettingsMode: ('standalone' | 'consumer' | 'consumer_partial' | 'localhost') = SDK.settings.mode;
178183
const instantiatedSettingsScheduler: { [key: string]: number } = SDK.settings.scheduler;
179184
const instantiatedSettingsStartup: { [key: string]: number } = SDK.settings.startup;
180-
const instantiatedSettingsStorage: {
181-
prefix: string,
182-
options: Object,
183-
// It can have any of the storages.
184-
type: SplitIO.NodeSyncStorage | SplitIO.NodeAsyncStorage | SplitIO.BrowserStorage
185-
} = SDK.settings.storage;
185+
const instantiatedSettingsStorage = SDK.settings.storage as SplitIO.StorageOptions;
186186
const instantiatedSettingsUrls: { [key: string]: string } = SDK.settings.urls;
187187
const instantiatedSettingsVersion: string = SDK.settings.version;
188188
let instantiatedSettingsFeatures = SDK.settings.features as SplitIO.MockedFeaturesMap;
@@ -635,6 +635,7 @@ let fullAsyncSettings: SplitIO.INodeAsyncSettings = {
635635
debug: true,
636636
sync: {
637637
splitFilters: splitFilters,
638+
impressionsMode: 'DEBUG',
638639
}
639640
};
640641

ts-tests/package.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

ts-tests/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"noImplicitAny": true,
44
"target": "es5",
5-
"module": "commonjs"
5+
"module": "commonjs",
6+
"noEmit": true,
67
},
78
"files": [
89
"index"

types/client/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Declaration file for JavaScript Split Software SDK
22
// Project: http://www.split.io/
33

4-
/// <reference path="../splitio.d.ts" />
4+
import '@splitsoftware/splitio-commons';
5+
56
export = JsSdk;
67

78
declare module JsSdk {

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Project: http://www.split.io/
33
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
44

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

77
export = JsSdk;
88

types/server/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Declaration file for JavaScript Split Software SDK
22
// Project: http://www.split.io/
33

4-
/// <reference path="../splitio.d.ts" />
4+
import '@splitsoftware/splitio-commons';
5+
56
export = JsSdk;
67

78
declare module JsSdk {

0 commit comments

Comments
 (0)