diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 86739af..2bcc3cf 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -42,14 +42,14 @@ jobs: run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build - name: Configure AWS credentials (development) - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/data_loader' }} uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: arn:aws:iam::079419646996:role/public-assets aws-region: us-east-1 - name: Upload to S3 (development) - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/data_loader' }} run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS env: BUCKET: split-public-stage diff --git a/package-lock.json b/package-lock.json index 5c7c4b8..793fe90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "0.6.1-rc.1", + "version": "0.6.1-rc.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2184,9 +2184,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "1.4.2-rc.1", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.4.2-rc.1.tgz", - "integrity": "sha512-SuX2Fjt48TEHizOoAYw+cuL85kgJKUnMV1wxF5u+LUooeLrpP3GcKA6OkiHCwZSbbxhpp529mJTsyzeJpFqDYw==", + "version": "1.4.2-rc.2", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.4.2-rc.2.tgz", + "integrity": "sha512-9ePLuOB0jO0cAREd/UQ38GvkEieQF7c8Kk2MYN+LwvUNct17sjPHuCBWkmpQlLjFyiyKelpT6U6TgSO7hWX2Pg==", "requires": { "tslib": "^2.3.1" } diff --git a/package.json b/package.json index d7f6d49..c88061b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "0.6.1-rc.1", + "version": "0.6.1-rc.2", "description": "Split SDK for Javascript on Browser", "main": "cjs/index.js", "module": "esm/index.js", @@ -61,7 +61,7 @@ "bugs": "https://github.com/splitio/javascript-browser-client/issues", "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { - "@splitsoftware/splitio-commons": "1.4.2-rc.1", + "@splitsoftware/splitio-commons": "1.4.2-rc.2", "@types/google.analytics": "0.0.40" }, "devDependencies": { diff --git a/src/full/index.ts b/src/full/index.ts index 42991c3..35317b8 100644 --- a/src/full/index.ts +++ b/src/full/index.ts @@ -7,3 +7,4 @@ export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/Wa export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger'; export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable'; +export { DataLoaderFactory } from '@splitsoftware/splitio-commons/src/storages/dataLoader'; diff --git a/src/full/umd.ts b/src/full/umd.ts index 23cc82b..9a49634 100644 --- a/src/full/umd.ts +++ b/src/full/umd.ts @@ -1,5 +1,5 @@ // @ts-nocheck -import { SplitFactory, InLocalStorage, GoogleAnalyticsToSplit, SplitToGoogleAnalytics, ErrorLogger, WarnLogger, InfoLogger, DebugLogger } from './index'; +import { SplitFactory, InLocalStorage, GoogleAnalyticsToSplit, SplitToGoogleAnalytics, ErrorLogger, WarnLogger, InfoLogger, DebugLogger, DataLoaderFactory } from './index'; // Include all pluggable modules as properties to expose at the global `splitio` object SplitFactory.SplitFactory = SplitFactory; @@ -10,6 +10,7 @@ SplitFactory.ErrorLogger = ErrorLogger; SplitFactory.WarnLogger = WarnLogger; SplitFactory.InfoLogger = InfoLogger; SplitFactory.DebugLogger = DebugLogger; +SplitFactory.DataLoaderFactory = DataLoaderFactory; // eslint-disable-next-line import/no-default-export export default SplitFactory; diff --git a/src/index.ts b/src/index.ts index 9bbdafb..4d67dba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,3 +24,4 @@ export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/In export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; export { LocalhostFromObject } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject'; export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable'; +export { DataLoaderFactory } from '@splitsoftware/splitio-commons/src/storages/dataLoader'; diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index 6beaaaf..f2ad118 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/ import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; -const packageVersion = '0.6.1-rc.1'; +const packageVersion = '0.6.1-rc.2'; /** * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item. diff --git a/types/full/index.d.ts b/types/full/index.d.ts index 151fcfa..2180e73 100644 --- a/types/full/index.d.ts +++ b/types/full/index.d.ts @@ -74,4 +74,9 @@ declare module JsSdk { * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging} */ export function ErrorLogger(): SplitIO.ILogger; + + /** + * @TODO + */ + export function DataLoaderFactory(preloadedData: SplitIO.PreloadedData): SplitIO.DataLoader; } diff --git a/types/index.d.ts b/types/index.d.ts index 35e41e5..7e4b174 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -82,4 +82,9 @@ declare module JsSdk { * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode} */ export function LocalhostFromObject(): SplitIO.LocalhostFactory; + + /** + * @TODO + */ + export function DataLoaderFactory(preloadedData: SplitIO.PreloadedData): SplitIO.DataLoader; } diff --git a/types/splitio.d.ts b/types/splitio.d.ts index bde87bf..f0a4989 100644 --- a/types/splitio.d.ts +++ b/types/splitio.d.ts @@ -73,6 +73,7 @@ interface ISettings { eventsFirstPushWindow: number }, readonly storage?: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory, + readonly dataLoader?: SplitIO.DataLoader, readonly urls: { events: string, sdk: string, @@ -93,6 +94,7 @@ interface ISettings { impressionsMode: SplitIO.ImpressionsMode, localhostMode?: SplitIO.LocalhostFactory, enabled?: boolean + onlySubmitters?: boolean }, readonly userConsent: SplitIO.ConsentStatus } @@ -244,15 +246,23 @@ interface ISharedSettings { */ localhostMode?: SplitIO.LocalhostFactory /** - * Controls the SDK continuous synchronization flags. - * - * When `true` a running SDK will process rollout plan updates performed on the UI (default). + * Controls the SDK continuous synchronization flags. + * + * When `true` a running SDK will process rollout plan updates performed on the UI (default). * When false it'll just fetch all data upon init - * + * * @property {boolean} enabled * @default true */ enabled?: boolean + /* + * @TODO + * + * False by default. + * If true and standalone mode, it will DISABLE splits and segments synchronization (i.e., polling and streaming). + * In consumer and partial consumer mode, it has no effect + */ + onlySubmitters?: boolean } } /** @@ -543,6 +553,10 @@ declare namespace SplitIO { */ prefix?: string } + /** + * @TODO + */ + type DataLoader = (storage: StorageSync, key?: string) => void /** * Storage for asynchronous (consumer) SDK. * Its interface details are not part of the public API. @@ -799,6 +813,42 @@ declare namespace SplitIO { * @typedef {string} ImpressionsMode */ type ImpressionsMode = 'OPTIMIZED' | 'DEBUG'; + /** + * Defines the format of Split data to preload on the factory storage (cache). + */ + interface PreloadedData { + /** + * Timestamp of the last moment the data was synchronized with Split servers. + * If this value is older than 10 days ago (expiration time policy), the data is not used to update the storage content. + * @TODO configurable expiration time policy? + */ + lastUpdated: number, + /** + * Change number of the preloaded data. + * If this value is older than the current changeNumber at the storage, the data is not used to update the storage content. + */ + since: number, + /** + * Map of splits to their serialized definitions. + */ + splitsData: { + [splitName: string]: string + }, + /** + * Optional map of user keys to their list of segments. + * @TODO remove when releasing first version + */ + mySegmentsData?: { + [key: string]: string[] + }, + /** + * Optional map of segments to their serialized definitions. + * This property is ignored if `mySegmentsData` was provided. + */ + segmentsData?: { + [segmentName: string]: string + }, + } /** * User consent status. * @typedef {string} ConsentStatus @@ -904,6 +954,10 @@ declare namespace SplitIO { * @property {Object} storage */ storage?: StorageSyncFactory, + /** + * @TODO + */ + dataLoader?: DataLoader, /** * SDK Startup settings for the Browser. * @property {Object} startup