Skip to content

Commit 7181921

Browse files
committed
refactor: keep existing type ownership
1 parent 2c200a3 commit 7181921

6 files changed

Lines changed: 94 additions & 112 deletions

File tree

src/configAPIClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { DataPlanConfig } from './publicSdkTypes';
2-
import {
1+
import type {
32
BooleanStringLowerCase,
3+
DataPlanConfig,
44
DataPlanResult,
55
SDKEventCustomFlags,
66
SDKInitConfig,

src/identity-user-interfaces.ts

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import type {
22
AllUserAttributes,
3-
IdentityCallback,
4-
IdentityResultBody,
53
MPID,
64
User,
75
} from './publicSdkTypes';
8-
import { SDKIdentityTypeEnum } from './identity.interfaces';
6+
import type { SDKIdentityTypeEnum } from './identity.interfaces';
97
import { MessageType } from './types';
10-
import { BaseEvent, SDKProduct } from './sdkRuntimeModels';
11-
12-
export type {
13-
IdentityCallback,
14-
IdentityModifyResultBody,
15-
IdentityResult,
16-
IdentityResultBody,
17-
} from './publicSdkTypes';
8+
import type { BaseEvent, SDKProduct } from './sdkRuntimeModels';
189

1910
// Cart is Deprecated and private to mParticle user in @mparticle/web-sdk
2011
// but we need to expose it here for type safety in some of our tests
@@ -37,6 +28,45 @@ interface ICart {
3728
getCartProducts: () => SDKProduct[];
3829
}
3930

31+
export interface IdentityResultBody {
32+
context: string | null;
33+
is_ephemeral: boolean;
34+
is_logged_in: boolean;
35+
matched_identities: Record<string, unknown>;
36+
mpid?: MPID;
37+
}
38+
39+
export interface IdentityModifyResultBody {
40+
change_results?: {
41+
identity_type: SDKIdentityTypeEnum;
42+
modified_mpid: MPID;
43+
};
44+
}
45+
46+
export type IdentityHTTPCode =
47+
| -1 // noHttpCoverage
48+
| -2 // activeIdentityRequest
49+
| -3 // activeSession
50+
| -4 // validationIssue
51+
| -5 // nativeIdentityRequest
52+
| -6 // loggingDisabledOrMissingAPIKey
53+
| 200
54+
| 202
55+
| 400
56+
| 429;
57+
58+
export interface IdentityResult {
59+
httpCode: IdentityHTTPCode;
60+
getPreviousUser(): User;
61+
getUser(): User;
62+
body: IdentityResultBody | IdentityModifyResultBody;
63+
}
64+
65+
// https://go.mparticle.com/work/SQDSDKS-6460
66+
export interface IdentityCallback {
67+
(result: IdentityResult): void;
68+
}
69+
4070
// https://go.mparticle.com/work/SQDSDKS-5033
4171
// https://go.mparticle.com/work/SQDSDKS-6354
4272
export interface IMParticleUser extends User {

src/public-types.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,8 @@ export type {
4646
Cart,
4747
CCPAConsentState,
4848
ConsentState,
49-
DataPlanConfig,
50-
DataPlanResult,
51-
Dictionary,
5249
GDPRConsentState,
5350
IdentityApiData,
54-
IdentityCallback,
55-
IdentityHTTPCode,
56-
IdentityModifyResultBody,
57-
IdentityResult,
58-
IdentityResultBody,
5951
IdentifyRequest,
6052
Impression,
6153
LauncherOptions,
@@ -102,6 +94,8 @@ export type {
10294
export type {
10395
SDKInitConfig,
10496
BaseEvent,
97+
DataPlanConfig,
98+
DataPlanResult,
10599
LogLevelType,
106100
MParticleWebSDKInstance,
107101
MParticleWebSDKManager,
@@ -110,6 +104,11 @@ export type {
110104

111105
// User & Identity
112106
export type {
107+
IdentityCallback,
108+
IdentityHTTPCode,
109+
IdentityModifyResultBody,
110+
IdentityResult,
111+
IdentityResultBody,
113112
IMParticleUser,
114113
ISDKUserIdentity,
115114
ISDKUserAttributes,
@@ -159,4 +158,4 @@ export type {
159158
} from './consent';
160159

161160
// Utilities
162-
export type { valueof } from './utils';
161+
export type { Dictionary, valueof } from './utils';

src/publicSdkTypes.ts

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Batch } from '@mparticle/event-models';
2-
3-
export type Dictionary<V = any> = Record<string, V>;
2+
import type { IdentityCallback } from './identity-user-interfaces';
3+
import type { DataPlanConfig } from './sdkRuntimeModels';
4+
import type { Dictionary } from './utils';
45

56
export type MPID = string;
67

@@ -30,44 +31,6 @@ export interface Logger {
3031
verbose?: (message: string) => void;
3132
}
3233

33-
export interface DataPlanResult {
34-
dtpn?: {
35-
vers: DataPlanVersion;
36-
blok: {
37-
ev: boolean;
38-
ea: boolean;
39-
ua: boolean;
40-
id: boolean;
41-
};
42-
};
43-
error_message?: string;
44-
}
45-
46-
export interface DataPlanVersion {
47-
version?: number;
48-
data_plan_id?: string;
49-
last_modified_on?: string;
50-
version_document?: Dictionary;
51-
}
52-
53-
export interface DataPlanConfig {
54-
planId?: string;
55-
planVersion?: number;
56-
document?: DataPlanResult;
57-
}
58-
59-
export interface KitBlockerOptions {
60-
dataPlanVersion: DataPlanVersion;
61-
blockUserAttributes: boolean;
62-
blockEventAttributes: boolean;
63-
blockEvents: boolean;
64-
blockUserIdentities: boolean;
65-
}
66-
67-
export interface KitBlockerDataPlan {
68-
document: DataPlanResult;
69-
}
70-
7134
export type MPForwarder = Dictionary;
7235

7336
export type OnUserAlias = (previousUser: User, newUser: User) => void;
@@ -223,44 +186,6 @@ export interface User {
223186
getUserAudiences?(callback?: IdentityCallback): void;
224187
}
225188

226-
export interface IdentityResultBody {
227-
context: string | null;
228-
is_ephemeral: boolean;
229-
is_logged_in: boolean;
230-
matched_identities: Record<string, unknown>;
231-
mpid?: MPID;
232-
}
233-
234-
export interface IdentityModifyResultBody {
235-
change_results?: {
236-
identity_type: string;
237-
modified_mpid: MPID;
238-
};
239-
}
240-
241-
export type IdentityHTTPCode =
242-
| -1 // noHttpCoverage
243-
| -2 // activeIdentityRequest
244-
| -3 // activeSession
245-
| -4 // validationIssue
246-
| -5 // nativeIdentityRequest
247-
| -6 // loggingDisabledOrMissingAPIKey
248-
| 200
249-
| 202
250-
| 400
251-
| 429;
252-
253-
export interface IdentityResult {
254-
httpCode: IdentityHTTPCode;
255-
getPreviousUser(): User;
256-
getUser(): User;
257-
body: IdentityResultBody | IdentityModifyResultBody;
258-
}
259-
260-
export interface IdentityCallback {
261-
(result: IdentityResult): void;
262-
}
263-
264189
export type AliasRequestScope = 'device' | 'mpid';
265190

266191
export interface UserAliasRequest {

src/sdkRuntimeModels.ts

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import * as EventsApi from '@mparticle/event-models';
22
import {
3-
DataPlanConfig,
4-
KitBlockerDataPlan,
5-
KitBlockerOptions,
63
MPConfiguration,
74
MPID,
85
SDKEventAttrs,
@@ -17,7 +14,7 @@ import {
1714
} from './store';
1815
import Validators from './validators';
1916
import { AttributeValue, Dictionary, Environment, valueof } from './utils';
20-
import { IKitConfigs } from './configAPIClient';
17+
import type { IKitConfigs } from './configAPIClient';
2118
import { SDKConsentApi, SDKConsentState } from './consent';
2219
import MPSideloadedKit from './sideloadedKit';
2320
import { ISessionManager } from './sessionManager';
@@ -55,13 +52,6 @@ import RoktManager, { IRoktLauncherOptions } from './roktManager';
5552
import { IConsoleLogger } from './logger';
5653
import { ErrorCodes, IErrorReportingService, ILoggingService } from './reporting/types';
5754

58-
export type {
59-
DataPlanConfig,
60-
DataPlanResult,
61-
KitBlockerDataPlan,
62-
KitBlockerOptions,
63-
} from './publicSdkTypes';
64-
6555
// Internal SDK custom flags are normalized before upload and may temporarily
6656
// contain arrays or other values supported by the legacy public API.
6757
export type SDKEventCustomFlags = Dictionary<any>;
@@ -373,6 +363,44 @@ export interface SDKInitConfig
373363
logger?: IConsoleLogger;
374364
}
375365

366+
export interface DataPlanVersion {
367+
version?: number;
368+
data_plan_id?: string;
369+
last_modified_on?: string;
370+
version_document?: Dictionary;
371+
}
372+
373+
export interface DataPlanConfig {
374+
planId?: string;
375+
planVersion?: number;
376+
document?: DataPlanResult;
377+
}
378+
379+
export interface KitBlockerOptions {
380+
dataPlanVersion: DataPlanVersion;
381+
blockUserAttributes: boolean;
382+
blockEventAttributes: boolean;
383+
blockEvents: boolean;
384+
blockUserIdentities: boolean;
385+
}
386+
387+
export interface KitBlockerDataPlan {
388+
document: DataPlanResult;
389+
}
390+
391+
export interface DataPlanResult {
392+
dtpn?: {
393+
vers: DataPlanVersion;
394+
blok: {
395+
ev: boolean;
396+
ea: boolean;
397+
ua: boolean;
398+
id: boolean;
399+
};
400+
};
401+
error_message?: string;
402+
}
403+
376404
export interface SDKHelpersApi {
377405
canLog?(): boolean;
378406
createMainStorageName?(workspaceToken: string): string;

src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Batch, Context } from '@mparticle/event-models';
22
import {
3-
DataPlanConfig,
43
IdentityApiData,
54
MPID,
65
SDKEventCustomFlags,
@@ -10,6 +9,7 @@ import {
109
import { IKitConfigs } from './configAPIClient';
1110
import Constants from './constants';
1211
import {
12+
DataPlanConfig,
1313
DataPlanResult,
1414
KitBlockerOptions,
1515
LogLevelType,

0 commit comments

Comments
 (0)