Skip to content

Commit

Permalink
feat: Extracted Stream module
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Feb 28, 2022
1 parent 5d6e082 commit 0d8f076
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/whatsapp/misc/Stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { exportModule } from '../exportModule';
import { StreamModel } from '../models';

/** @whatsapp 8080 */
export declare const Stream: StreamModel;

exportModule(
exports,
{ Stream: (m) => (m.default ? m.default : m.Stream) },
(m) => m.Stream || m.StreamInfo
);
1 change: 1 addition & 0 deletions src/whatsapp/misc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export * from './MsgKey';
export * from './MsgLoadState';
export * from './OpaqueData';
export * from './Socket';
export * from './Stream';
export * from './UserPrefs';
export * from './VCard';
export * from './Wap';
Expand Down
83 changes: 83 additions & 0 deletions src/whatsapp/models/StreamModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*!
* Copyright 2021 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { exportModule } from '../exportModule';
import {
Model,
ModelOptions,
ModelPropertiesContructor,
ModelProxy,
} from './Model';

interface Props {}

interface Session {
info?: any;
mode?: any;
obscurity?: any;
needsUpdate?: any;
clientExpired?: any;
hardExpired?: any;
lastSyncStart?: any;
needsManualDownload?: any;
couldForce?: any;
uiActive?: any;
available?: any;
unavailableShiftTimer?: any;
unavailableLogoutTimer?: any;
unobscureShiftTimer?: any;
timeoutEvent?: any;
resumeCount?: any;
phoneAuthed?: any;
}

interface Derived {
displayInfo?: any;
}

/** @whatsapp 8080 */
export declare interface StreamModel
extends ModelProxy<Props, Session, Derived> {}

/** @whatsapp 8080 */
export declare class StreamModel extends Model {
constructor(
proterties?: ModelPropertiesContructor<StreamModel>,
options?: ModelOptions
);
markAvailable(): void;
markUnavailable(e?: any): void;
onSelfUpdate(): void;
onSocketUpdate(): void;
unobscure(): void;
onPhoneAuthedUpdate(): void;
onAvailableUpdate(): void;
sendAvailability(e?: any): void;
updateCouldForce(): void;
updateHardExpire(): void;
logPageResume(): void;
updateWamLog(): void;
logModeChange(): void;
}

exportModule(
exports,
{
StreamModel: (m) =>
m.default ? m.default.constructor : m.Stream.constructor,
},
(m) => m.Stream || m.StreamInfo
);
1 change: 1 addition & 0 deletions src/whatsapp/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export * from './StatusModel';
export * from './StatusV3Model';
export * from './StickerModel';
export * from './StickerPackModel';
export * from './StreamModel';
export * from './TemplateButtonModel';
export * from './UnreadMentionModel';
export * from './WebCallModel';

0 comments on commit 0d8f076

Please sign in to comment.