Skip to content

Commit

Permalink
feat: Exported Collection and Model for Notes
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Oct 30, 2024
1 parent 97cda76 commit 009d9a8
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/whatsapp/collections/NoteCollection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*!
* Copyright 2024 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 { NoteModel } from '../models';
import { Collection } from './Collection';

/** @whatsapp WAWebNoteCollection
*/
export declare class NoteCollection extends Collection<NoteModel> {
static model: NoteModel;
maybeGetNoteByChatJid(a?: any): any;
hasCachedQueryForChatJid(e?: any): any;
updateCollectionFromDB(a?: any, b?: any): any;
purgeNotesByChatJid(a?: any): any;
}
exportModule(
exports,
{ NoteCollection: ['NoteCollection.constructor'] },
(m) => m.NoteCollection
);
45 changes: 45 additions & 0 deletions src/whatsapp/functions/addOrEditNoteAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*!
* Copyright 2024 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 { NoteModel } from '../models';

/** @whatsapp WAWebNoteAction
*/
export declare function addOrEditNoteAction(
attrs: {
actionType: 'edit' | 'add';
chatJid: string;
content: string;
createdAt: number;
id: string;
noteType: 'unstructured';
},
b: boolean
): Promise<any>;

export declare function retrieveOnlyNoteForChatJid(
jid: string
): Promise<null | NoteModel>;

exportModule(
exports,
{
addOrEditNoteAction: 'addOrEditNoteAction',
retrieveOnlyNoteForChatJid: 'retrieveOnlyNoteForChatJid',
},
(m) => m.addOrEditNoteAction && m.retrieveOnlyNoteForChatJid
);
55 changes: 55 additions & 0 deletions src/whatsapp/models/NoteModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*!
* Copyright 2024 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 { NoteCollection } from '../collections';
import { exportProxyModel } from '../exportModule';
import {
Model,
ModelOptions,
ModelPropertiesContructor,
ModelProxy,
} from './Model';

interface Props {
id?: any;
type?: string;
chatJid: string;
content: string;
createdAt?: number;
modifiedAt?: number;
}

interface Session {
stale?: any;
}

interface Derived {}

export declare interface NoteModel
extends ModelProxy<Props, Session, Derived> {}

/** @whatsapp 86761
*/
export declare class NoteModel extends Model<NoteCollection> {
constructor(
proterties?: ModelPropertiesContructor<NoteModel>,
options?: ModelOptions
);
triggerItemCollectionUpdate(): any;
getCollection(): NoteCollection;
}

exportProxyModel(exports, 'NoteModel');
1 change: 1 addition & 0 deletions src/whatsapp/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export * from './MsgInfoParticipantModel';
export * from './MsgModel';
export * from './MuteModel';
export * from './NetworkStatusModel';
export * from './NoteModel';
export * from './OrderItemModel';
export * from './OrderModel';
export * from './ParticipantModel';
Expand Down
9 changes: 9 additions & 0 deletions src/whatsapp/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export declare const StickerPackStore: collections.StickerPackCollection;
*/
export declare const StickerSearchStore: collections.StickerSearchCollection;
export declare const PinInChatStore: collections.PinInChatCollection;
export declare const NoteStore: collections.NoteCollection;

const storeNames = [
'BlocklistStore',
Expand Down Expand Up @@ -378,3 +379,11 @@ exportModule(
},
(m) => m.QuickReplyCollectionImpl || m.QuickReplyCollection
);

exportModule(
exports,
{
NoteStore: ['NoteCollection'],
},
(m) => m.NoteCollection
);

0 comments on commit 009d9a8

Please sign in to comment.