Skip to content

Commit dd65cf0

Browse files
committed
rename core mod director fields
1 parent c2450fb commit dd65cf0

32 files changed

+191
-199
lines changed

__test__/setupTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ beforeEach(async () => {
1919
afterEach(() => {
2020
server.resetHandlers();
2121
if (typeof OneSignal !== 'undefined') {
22-
OneSignal._coreDirector?.operationRepo._clear();
22+
OneSignal._coreDirector?._operationRepo._clear();
2323
OneSignal._emitter?.removeAllListeners();
2424
}
2525
});

__test__/support/environment/TestEnvironment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class TestEnvironment {
3232
) {
3333
mockJsonp();
3434
const oneSignal = initOSGlobals(config);
35-
OneSignal._coreDirector.operationRepo.queue = [];
35+
OneSignal._coreDirector._operationRepo.queue = [];
3636

3737
if (config.initOneSignalId) {
3838
updateIdentityModel('onesignal_id', ONESIGNAL_ID);

__test__/support/environment/TestEnvironmentHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const setupSubModelStore = async ({
9595
pushModel.web_p256 = web_p256;
9696
}
9797
await setPushToken(pushModel.token);
98-
OneSignal._coreDirector.subscriptionModelStore.replaceAll(
98+
OneSignal._coreDirector._subscriptionModelStore.replaceAll(
9999
[pushModel],
100100
ModelChangeTags.NO_PROPAGATE,
101101
);

__test__/support/helpers/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export function generateNewSubscription(modelId = '0000000000') {
1818
// Requirement: Test must also call TestEnvironment.initialize();
1919
export async function getCoreModuleDirector(): Promise<CoreModuleDirector> {
2020
const coreModule = new CoreModule();
21-
await coreModule.init();
21+
await coreModule._init();
2222
return new CoreModuleDirector(coreModule);
2323
}

__test__/support/helpers/setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const setupIdentityModel = async (
6464
) => {
6565
const newIdentityModel = new IdentityModel();
6666
newIdentityModel.onesignalId = onesignalID;
67-
OneSignal._coreDirector.identityModelStore.replace(
67+
OneSignal._coreDirector._identityModelStore.replace(
6868
newIdentityModel,
6969
ModelChangeTags.NO_PROPAGATE,
7070
);
@@ -78,7 +78,7 @@ export const setupPropertiesModel = async (
7878
) => {
7979
const newPropertiesModel = new PropertiesModel();
8080
newPropertiesModel.onesignalId = onesignalID;
81-
OneSignal._coreDirector.propertiesModelStore.replace(
81+
OneSignal._coreDirector._propertiesModelStore.replace(
8282
newPropertiesModel,
8383
ModelChangeTags.NO_PROPAGATE,
8484
);
@@ -126,7 +126,7 @@ export const setupSubscriptionModel = async (
126126
const subscriptionModel = new SubscriptionModel();
127127
subscriptionModel.id = id || '';
128128
subscriptionModel.token = token || '';
129-
OneSignal._coreDirector.subscriptionModelStore.replaceAll(
129+
OneSignal._coreDirector._subscriptionModelStore.replaceAll(
130130
[subscriptionModel],
131131
ModelChangeTags.NO_PROPAGATE,
132132
);

__test__/unit/core/coreModuleDirector.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('CoreModuleDirector tests', () => {
1212

1313
describe('getPushSubscriptionModel', () => {
1414
async function getPushSubscriptionModel() {
15-
return (await getCoreModuleDirector()).getPushSubscriptionModel();
15+
return (await getCoreModuleDirector())._getPushSubscriptionModel();
1616
}
1717

1818
test('returns undefined when it find no push records', async () => {

__test__/unit/pushSubscription/nativePermissionChange.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('Notification Types are set correctly on subscription change', () => {
112112
lastKnownPushToken: PUSH_TOKEN,
113113
lastKnownPushId: SUB_ID,
114114
});
115-
OneSignal._coreDirector.addSubscriptionModel(pushModel);
115+
OneSignal._coreDirector._addSubscriptionModel(pushModel);
116116

117117
await checkAndTriggerSubscriptionChanged();
118118
expect(changeListener).not.toHaveBeenCalled();
@@ -130,7 +130,7 @@ describe('Notification Types are set correctly on subscription change', () => {
130130
lastKnownPushToken: PUSH_TOKEN_2,
131131
lastKnownPushId: SUB_ID_3,
132132
});
133-
OneSignal._coreDirector.subscriptionModelStore.add(pushModel);
133+
OneSignal._coreDirector._subscriptionModelStore.add(pushModel);
134134

135135
await checkAndTriggerSubscriptionChanged();
136136
expect(changeListener).toHaveBeenCalledWith({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"path": "./build/releases/OneSignalSDK.page.es6.js",
87-
"limit": "49.98 kB",
87+
"limit": "49.79 kB",
8888
"gzip": true
8989
},
9090
{

src/core/CoreModule.ts

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ import { RefreshUserOperationExecutor } from './executors/RefreshUserOperationEx
77
import { SubscriptionOperationExecutor } from './executors/SubscriptionOperationExecutor';
88
import { UpdateUserOperationExecutor } from './executors/UpdateUserOperationExecutor';
99
import { IdentityModelStoreListener } from './listeners/IdentityModelStoreListener';
10-
import { ModelStoreListener } from './listeners/ModelStoreListener';
1110
import { PropertiesModelStoreListener } from './listeners/PropertiesModelStoreListener';
12-
import { type SingletonModelStoreListener } from './listeners/SingletonModelStoreListener';
1311
import { SubscriptionModelStoreListener } from './listeners/SubscriptionModelStoreListener';
1412
import { OperationModelStore } from './modelRepo/OperationModelStore';
1513
import { RebuildUserService } from './modelRepo/RebuildUserService';
16-
import { type Model } from './models/Model';
1714
import { IdentityModelStore } from './modelStores/IdentityModelStore';
1815
import { PropertiesModelStore } from './modelStores/PropertiesModelStore';
1916
import { SubscriptionModelStore } from './modelStores/SubscriptionModelStore';
@@ -22,105 +19,99 @@ import { OperationRepo } from './operationRepo/OperationRepo';
2219
import type { IOperationExecutor } from './types/operation';
2320

2421
export default class CoreModule {
25-
public operationModelStore: OperationModelStore;
26-
public operationRepo: OperationRepo;
27-
public newRecordsState: NewRecordsState;
28-
public subscriptionModelStore: SubscriptionModelStore;
29-
public identityModelStore: IdentityModelStore;
30-
public propertiesModelStore: PropertiesModelStore;
31-
public customEventController: CustomEventController;
22+
public _operationModelStore: OperationModelStore;
23+
public _operationRepo: OperationRepo;
24+
public _newRecordsState: NewRecordsState;
25+
public _subscriptionModelStore: SubscriptionModelStore;
26+
public _identityModelStore: IdentityModelStore;
27+
public _propertiesModelStore: PropertiesModelStore;
28+
public _customEventController: CustomEventController;
3229

33-
private initPromise: Promise<void>;
30+
private _initPromise: Promise<void>;
3431

35-
private rebuildUserService: RebuildUserService;
36-
private executors?: IOperationExecutor[];
37-
38-
// @ts-expect-error - not exposed but keeps track of listeners
39-
private listeners?: (
40-
| SingletonModelStoreListener<Model>
41-
| ModelStoreListener<Model>
42-
)[];
32+
private _rebuildUserService: RebuildUserService;
33+
private _executors?: IOperationExecutor[];
4334

4435
constructor() {
45-
this.newRecordsState = new NewRecordsState();
46-
this.operationModelStore = new OperationModelStore();
47-
this.identityModelStore = new IdentityModelStore();
48-
this.propertiesModelStore = new PropertiesModelStore();
49-
this.subscriptionModelStore = new SubscriptionModelStore();
50-
this.rebuildUserService = new RebuildUserService(
51-
this.identityModelStore,
52-
this.propertiesModelStore,
53-
this.subscriptionModelStore,
36+
this._newRecordsState = new NewRecordsState();
37+
this._operationModelStore = new OperationModelStore();
38+
this._identityModelStore = new IdentityModelStore();
39+
this._propertiesModelStore = new PropertiesModelStore();
40+
this._subscriptionModelStore = new SubscriptionModelStore();
41+
this._rebuildUserService = new RebuildUserService(
42+
this._identityModelStore,
43+
this._propertiesModelStore,
44+
this._subscriptionModelStore,
5445
);
5546

56-
this.executors = this.initializeExecutors();
57-
this.operationRepo = new OperationRepo(
58-
this.executors,
59-
this.operationModelStore,
60-
this.newRecordsState,
47+
this._executors = this._initializeExecutors();
48+
this._operationRepo = new OperationRepo(
49+
this._executors,
50+
this._operationModelStore,
51+
this._newRecordsState,
6152
);
62-
this.customEventController = new CustomEventController(
63-
this.identityModelStore,
64-
this.operationRepo,
53+
this._customEventController = new CustomEventController(
54+
this._identityModelStore,
55+
this._operationRepo,
6556
);
6657

67-
this.listeners = this.initializeListeners();
68-
this.initPromise = this.operationRepo._start();
58+
this._initializeListeners();
59+
this._initPromise = this._operationRepo._start();
6960
}
7061

71-
public async init() {
62+
public async _init() {
7263
logMethodCall('CoreModule.init');
73-
return this.initPromise;
64+
return this._initPromise;
7465
}
7566

76-
private initializeListeners() {
77-
if (!this.operationRepo) return [];
67+
private _initializeListeners() {
68+
if (!this._operationRepo) return [];
7869
return [
7970
new IdentityModelStoreListener(
80-
this.identityModelStore,
81-
this.operationRepo,
71+
this._identityModelStore,
72+
this._operationRepo,
8273
),
8374
new PropertiesModelStoreListener(
84-
this.propertiesModelStore,
85-
this.operationRepo,
75+
this._propertiesModelStore,
76+
this._operationRepo,
8677
),
8778
new SubscriptionModelStoreListener(
88-
this.subscriptionModelStore,
89-
this.operationRepo,
90-
this.identityModelStore,
79+
this._subscriptionModelStore,
80+
this._operationRepo,
81+
this._identityModelStore,
9182
),
9283
];
9384
}
9485

95-
private initializeExecutors() {
86+
private _initializeExecutors() {
9687
const identityOpExecutor = new IdentityOperationExecutor(
97-
this.identityModelStore,
98-
this.rebuildUserService,
99-
this.newRecordsState,
88+
this._identityModelStore,
89+
this._rebuildUserService,
90+
this._newRecordsState,
10091
);
10192
const loginOpExecutor = new LoginUserOperationExecutor(
10293
identityOpExecutor,
103-
this.identityModelStore,
104-
this.propertiesModelStore,
105-
this.subscriptionModelStore,
94+
this._identityModelStore,
95+
this._propertiesModelStore,
96+
this._subscriptionModelStore,
10697
);
10798
const refreshOpExecutor = new RefreshUserOperationExecutor(
108-
this.identityModelStore,
109-
this.propertiesModelStore,
110-
this.subscriptionModelStore,
111-
this.rebuildUserService,
112-
this.newRecordsState,
99+
this._identityModelStore,
100+
this._propertiesModelStore,
101+
this._subscriptionModelStore,
102+
this._rebuildUserService,
103+
this._newRecordsState,
113104
);
114105
const subscriptionOpExecutor = new SubscriptionOperationExecutor(
115-
this.subscriptionModelStore,
116-
this.rebuildUserService,
117-
this.newRecordsState,
106+
this._subscriptionModelStore,
107+
this._rebuildUserService,
108+
this._newRecordsState,
118109
);
119110
const updateSubOpExecutor = new UpdateUserOperationExecutor(
120-
this.identityModelStore,
121-
this.propertiesModelStore,
122-
this.rebuildUserService,
123-
this.newRecordsState,
111+
this._identityModelStore,
112+
this._propertiesModelStore,
113+
this._rebuildUserService,
114+
this._newRecordsState,
124115
);
125116
const customEventOpExecutor = new CustomEventsOperationExecutor();
126117

0 commit comments

Comments
 (0)