@grapadigital/shared-schemas 1.0.177 → 1.0.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -4
- package/dist/schemas/action.schema.d.ts +1 -1
- package/dist/schemas/action.schema.js +3 -7
- package/dist/schemas/campaign.schema.js +1 -0
- package/dist/schemas/commission.schema.d.ts +13 -2
- package/dist/schemas/commission.schema.js +7 -3
- package/dist/schemas/content.schema.d.ts +2 -0
- package/dist/schemas/content.schema.js +8 -0
- package/dist/schemas/payment.schema.d.ts +1 -1
- package/dist/schemas/payment.schema.js +2 -1
- package/dist/schemas/tag.schema.d.ts +44 -0
- package/dist/schemas/tag.schema.js +38 -0
- package/package.json +1 -1
- package/src/index.ts +1 -4
- package/src/schemas/action.schema.ts +3 -7
- package/src/schemas/campaign.schema.ts +3 -0
- package/src/schemas/commission.schema.ts +7 -4
- package/src/schemas/content.schema.ts +6 -0
- package/src/schemas/payment.schema.ts +3 -2
- package/src/schemas/tag.schema.ts +26 -0
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,6 @@ export * from './schemas/notifications.schema';
|
|
|
21
21
|
export * from './schemas/organization.schema';
|
|
22
22
|
export * from './schemas/user.schema';
|
|
23
23
|
export * from './schemas/group.schema';
|
|
24
|
+
export * from './schemas/tag.schema';
|
|
24
25
|
export * from './schemas/trigger.schema';
|
|
25
26
|
export { Note, NoteSchema, NoteMention, NoteMentionSchema } from './schemas/note.schema';
|
package/dist/index.js
CHANGED
|
@@ -38,11 +38,8 @@ __exportStar(require("./schemas/notifications.schema"), exports);
|
|
|
38
38
|
__exportStar(require("./schemas/organization.schema"), exports);
|
|
39
39
|
__exportStar(require("./schemas/user.schema"), exports);
|
|
40
40
|
__exportStar(require("./schemas/group.schema"), exports);
|
|
41
|
+
__exportStar(require("./schemas/tag.schema"), exports);
|
|
41
42
|
__exportStar(require("./schemas/trigger.schema"), exports);
|
|
42
|
-
// Exportação explícita: `influencer.schema.ts` já exporta seu próprio `Note`/`NoteSchema`
|
|
43
|
-
// (domínio de anotações do Influencer, sem `mentioneds`, não tocado por esta mudança). A
|
|
44
|
-
// exportação nomeada abaixo tem precedência sobre a ambiguidade do `export *` e faz o `Note`
|
|
45
|
-
// deste arquivo (usado por Sale/Invoice/Payment/Action) ser o resolvido na raiz do pacote.
|
|
46
43
|
var note_schema_1 = require("./schemas/note.schema");
|
|
47
44
|
Object.defineProperty(exports, "Note", { enumerable: true, get: function () { return note_schema_1.Note; } });
|
|
48
45
|
Object.defineProperty(exports, "NoteSchema", { enumerable: true, get: function () { return note_schema_1.NoteSchema; } });
|
|
@@ -60,7 +60,7 @@ export declare const ResponsiblesSchema: MongooseSchema<Responsibles, import("mo
|
|
|
60
60
|
}>;
|
|
61
61
|
export declare const ACTION_BUSINESS_UNIT_VALUES: readonly ["service", "comercial", "squad_a", "squad_b"];
|
|
62
62
|
export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
|
|
63
|
-
export declare const ACTION_STATUS_VALUES: readonly ["config", "
|
|
63
|
+
export declare const ACTION_STATUS_VALUES: readonly ["config", "inProgress", "finished", "archived", "cancelled"];
|
|
64
64
|
export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
|
|
65
65
|
export declare class Action {
|
|
66
66
|
_id?: Types.ObjectId;
|
|
@@ -66,15 +66,10 @@ exports.ACTION_BUSINESS_UNIT_VALUES = [
|
|
|
66
66
|
];
|
|
67
67
|
exports.ACTION_STATUS_VALUES = [
|
|
68
68
|
'config',
|
|
69
|
-
'
|
|
70
|
-
'production',
|
|
71
|
-
'posting',
|
|
72
|
-
'analytics',
|
|
69
|
+
'inProgress',
|
|
73
70
|
'finished',
|
|
74
|
-
'
|
|
71
|
+
'archived',
|
|
75
72
|
'cancelled',
|
|
76
|
-
'inProgress',
|
|
77
|
-
'archived', // legado — mantido por compatibilidade
|
|
78
73
|
];
|
|
79
74
|
let Action = class Action {
|
|
80
75
|
};
|
|
@@ -299,4 +294,5 @@ exports.ActionSchema.index({ organization: 1, sale: 1 });
|
|
|
299
294
|
exports.ActionSchema.index({ sale: 1 });
|
|
300
295
|
exports.ActionSchema.index({ organization: 1, startDate: 1, endDate: 1 });
|
|
301
296
|
exports.ActionSchema.index({ 'responsibles.service.email': 1 });
|
|
297
|
+
exports.ActionSchema.index({ campaign: 1 });
|
|
302
298
|
exports.ActionModel = (0, mongoose_2.model)('Action', exports.ActionSchema);
|
|
@@ -51,4 +51,5 @@ Campaign = __decorate([
|
|
|
51
51
|
], Campaign);
|
|
52
52
|
exports.Campaign = Campaign;
|
|
53
53
|
exports.CampaignSchema = mongoose_1.SchemaFactory.createForClass(Campaign);
|
|
54
|
+
exports.CampaignSchema.index({ client: 1 });
|
|
54
55
|
exports.CampaignModel = (0, mongoose_2.model)('Campaign', exports.CampaignSchema);
|
|
@@ -34,14 +34,25 @@ export declare class Commission {
|
|
|
34
34
|
role: 'origination' | 'commercial' | 'planning' | 'curation';
|
|
35
35
|
value: number;
|
|
36
36
|
percentage: number;
|
|
37
|
-
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
|
|
37
|
+
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed' | 'reproved';
|
|
38
38
|
type: 'collaborator' | 'agency' | 'bonus';
|
|
39
39
|
sale: Types.ObjectId | Sale;
|
|
40
40
|
paidAt?: Date;
|
|
41
41
|
approvedAt?: Date;
|
|
42
42
|
readyAt?: Date;
|
|
43
43
|
paymentDate?: Date;
|
|
44
|
-
approvedBy?:
|
|
44
|
+
approvedBy?: {
|
|
45
|
+
_id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
email: string;
|
|
48
|
+
username: string;
|
|
49
|
+
};
|
|
50
|
+
reprovedBy?: {
|
|
51
|
+
_id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
username: string;
|
|
55
|
+
};
|
|
45
56
|
description?: string;
|
|
46
57
|
createdAt?: Date;
|
|
47
58
|
updatedAt?: Date;
|
|
@@ -50,7 +50,7 @@ __decorate([
|
|
|
50
50
|
__decorate([
|
|
51
51
|
(0, mongoose_1.Prop)({
|
|
52
52
|
type: String,
|
|
53
|
-
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
|
|
53
|
+
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed', 'reproved'],
|
|
54
54
|
default: 'pending',
|
|
55
55
|
required: true,
|
|
56
56
|
}),
|
|
@@ -85,9 +85,13 @@ __decorate([
|
|
|
85
85
|
__metadata("design:type", Date)
|
|
86
86
|
], Commission.prototype, "paymentDate", void 0);
|
|
87
87
|
__decorate([
|
|
88
|
-
(0, mongoose_1.Prop)({ type:
|
|
89
|
-
__metadata("design:type",
|
|
88
|
+
(0, mongoose_1.Prop)({ type: Object, required: false }),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
90
|
], Commission.prototype, "approvedBy", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, mongoose_1.Prop)({ type: Object, required: false }),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], Commission.prototype, "reprovedBy", void 0);
|
|
91
95
|
__decorate([
|
|
92
96
|
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
93
97
|
__metadata("design:type", String)
|
|
@@ -149,6 +149,8 @@ export declare class Content {
|
|
|
149
149
|
sentimentAnalysis?: SentimentAnalysis | null;
|
|
150
150
|
thumbnailUrl?: string;
|
|
151
151
|
mediaUrl?: string;
|
|
152
|
+
isEdited?: boolean;
|
|
153
|
+
editedAt?: Date;
|
|
152
154
|
}
|
|
153
155
|
export declare const ContentSchema: MongooseSchema<Content, import("mongoose").Model<Content, any, any, any, import("mongoose").Document<unknown, any, Content, any, {}> & Content & Required<{
|
|
154
156
|
_id: Types.ObjectId;
|
|
@@ -295,6 +295,14 @@ __decorate([
|
|
|
295
295
|
(0, mongoose_1.Prop)({ type: String, required: false }),
|
|
296
296
|
__metadata("design:type", String)
|
|
297
297
|
], Content.prototype, "mediaUrl", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
(0, mongoose_1.Prop)({ type: Boolean, required: false, default: false }),
|
|
300
|
+
__metadata("design:type", Boolean)
|
|
301
|
+
], Content.prototype, "isEdited", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
(0, mongoose_1.Prop)({ type: Date, required: false }),
|
|
304
|
+
__metadata("design:type", Date)
|
|
305
|
+
], Content.prototype, "editedAt", void 0);
|
|
298
306
|
Content = __decorate([
|
|
299
307
|
(0, mongoose_1.Schema)({ timestamps: true })
|
|
300
308
|
], Content);
|
|
@@ -130,7 +130,7 @@ __decorate([
|
|
|
130
130
|
__metadata("design:type", Number)
|
|
131
131
|
], Pending.prototype, "installmentNumber", void 0);
|
|
132
132
|
__decorate([
|
|
133
|
-
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Sale' }),
|
|
133
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.ObjectId, ref: 'Sale', required: false }),
|
|
134
134
|
__metadata("design:type", Object)
|
|
135
135
|
], Pending.prototype, "sale", void 0);
|
|
136
136
|
__decorate([
|
|
@@ -341,6 +341,7 @@ Payment = __decorate([
|
|
|
341
341
|
exports.Payment = Payment;
|
|
342
342
|
exports.PaymentSchema = mongoose_1.SchemaFactory.createForClass(Payment);
|
|
343
343
|
exports.PaymentSchema.index({ 'pending.sale': 1 });
|
|
344
|
+
exports.PaymentSchema.index({ 'pending.sale': 1, 'pending.installmentNumber': 1 });
|
|
344
345
|
exports.PaymentSchema.index({ 'pending.influencer': 1 });
|
|
345
346
|
exports.PaymentSchema.index({ 'pending.recruitment': 1 });
|
|
346
347
|
exports.PaymentSchema.index({ 'pending.action': 1 });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/session" />
|
|
19
|
+
/// <reference types="mongoose/types/types" />
|
|
20
|
+
/// <reference types="mongoose/types/utility" />
|
|
21
|
+
/// <reference types="mongoose/types/validation" />
|
|
22
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import { HydratedDocument, Types } from 'mongoose';
|
|
27
|
+
export type TagDocument = HydratedDocument<Tag>;
|
|
28
|
+
export declare class Tag {
|
|
29
|
+
organization: Types.ObjectId;
|
|
30
|
+
module: string;
|
|
31
|
+
name: string;
|
|
32
|
+
color?: string;
|
|
33
|
+
createdAt?: Date;
|
|
34
|
+
updatedAt?: Date;
|
|
35
|
+
}
|
|
36
|
+
export declare const TagSchema: import("mongoose").Schema<Tag, import("mongoose").Model<Tag, any, any, any, import("mongoose").Document<unknown, any, Tag, any, {}> & Tag & {
|
|
37
|
+
_id: Types.ObjectId;
|
|
38
|
+
} & {
|
|
39
|
+
__v: number;
|
|
40
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Tag, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Tag>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Tag> & {
|
|
41
|
+
_id: Types.ObjectId;
|
|
42
|
+
} & {
|
|
43
|
+
__v: number;
|
|
44
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TagSchema = exports.Tag = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const mongoose_2 = require("mongoose");
|
|
15
|
+
let Tag = class Tag {
|
|
16
|
+
};
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'Organization', required: true, index: true }),
|
|
19
|
+
__metadata("design:type", mongoose_2.Types.ObjectId)
|
|
20
|
+
], Tag.prototype, "organization", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, mongoose_1.Prop)({ required: true, enum: ['sales', 'invoices', 'payments', 'actions'], index: true }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], Tag.prototype, "module", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, mongoose_1.Prop)({ required: true, trim: true }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], Tag.prototype, "name", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, mongoose_1.Prop)({ required: false }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Tag.prototype, "color", void 0);
|
|
33
|
+
Tag = __decorate([
|
|
34
|
+
(0, mongoose_1.Schema)({ timestamps: true, collection: 'tag' })
|
|
35
|
+
], Tag);
|
|
36
|
+
exports.Tag = Tag;
|
|
37
|
+
exports.TagSchema = mongoose_1.SchemaFactory.createForClass(Tag);
|
|
38
|
+
exports.TagSchema.index({ organization: 1, module: 1, name: 1 }, { unique: true });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,9 +21,6 @@ export * from './schemas/notifications.schema';
|
|
|
21
21
|
export * from './schemas/organization.schema';
|
|
22
22
|
export * from './schemas/user.schema';
|
|
23
23
|
export * from './schemas/group.schema';
|
|
24
|
+
export * from './schemas/tag.schema';
|
|
24
25
|
export * from './schemas/trigger.schema';
|
|
25
|
-
// Exportação explícita: `influencer.schema.ts` já exporta seu próprio `Note`/`NoteSchema`
|
|
26
|
-
// (domínio de anotações do Influencer, sem `mentioneds`, não tocado por esta mudança). A
|
|
27
|
-
// exportação nomeada abaixo tem precedência sobre a ambiguidade do `export *` e faz o `Note`
|
|
28
|
-
// deste arquivo (usado por Sale/Invoice/Payment/Action) ser o resolvido na raiz do pacote.
|
|
29
26
|
export { Note, NoteSchema, NoteMention, NoteMentionSchema } from './schemas/note.schema';
|
|
@@ -57,15 +57,10 @@ export type ActionBusinessUnit = (typeof ACTION_BUSINESS_UNIT_VALUES)[number];
|
|
|
57
57
|
|
|
58
58
|
export const ACTION_STATUS_VALUES = [
|
|
59
59
|
'config',
|
|
60
|
-
'
|
|
61
|
-
'production',
|
|
62
|
-
'posting',
|
|
63
|
-
'analytics',
|
|
60
|
+
'inProgress',
|
|
64
61
|
'finished',
|
|
65
|
-
'
|
|
62
|
+
'archived',
|
|
66
63
|
'cancelled',
|
|
67
|
-
'inProgress', // legado — mantido por compatibilidade
|
|
68
|
-
'archived', // legado — mantido por compatibilidade
|
|
69
64
|
] as const;
|
|
70
65
|
export type ActionStatus = (typeof ACTION_STATUS_VALUES)[number];
|
|
71
66
|
|
|
@@ -251,5 +246,6 @@ ActionSchema.index({ organization: 1, sale: 1 });
|
|
|
251
246
|
ActionSchema.index({ sale: 1 });
|
|
252
247
|
ActionSchema.index({ organization: 1, startDate: 1, endDate: 1 });
|
|
253
248
|
ActionSchema.index({ 'responsibles.service.email': 1 });
|
|
249
|
+
ActionSchema.index({ campaign: 1 });
|
|
254
250
|
|
|
255
251
|
export const ActionModel = MongooseModel('Action', ActionSchema);
|
|
@@ -41,11 +41,11 @@ export class Commission {
|
|
|
41
41
|
|
|
42
42
|
@Prop({
|
|
43
43
|
type: String,
|
|
44
|
-
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed'],
|
|
44
|
+
enum: ['pending', 'approved', 'ready', 'paid', 'cancelled', 'disputed', 'reproved'],
|
|
45
45
|
default: 'pending',
|
|
46
46
|
required: true,
|
|
47
47
|
})
|
|
48
|
-
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed';
|
|
48
|
+
status: 'pending' | 'approved' | 'ready' | 'paid' | 'cancelled' | 'disputed' | 'reproved';
|
|
49
49
|
|
|
50
50
|
@Prop({
|
|
51
51
|
type: String,
|
|
@@ -69,8 +69,11 @@ export class Commission {
|
|
|
69
69
|
@Prop({ type: Date, required: false })
|
|
70
70
|
paymentDate?: Date;
|
|
71
71
|
|
|
72
|
-
@Prop({ type:
|
|
73
|
-
approvedBy?: string;
|
|
72
|
+
@Prop({ type: Object, required: false })
|
|
73
|
+
approvedBy?: { _id: string; name: string; email: string; username: string };
|
|
74
|
+
|
|
75
|
+
@Prop({ type: Object, required: false })
|
|
76
|
+
reprovedBy?: { _id: string; name: string; email: string; username: string };
|
|
74
77
|
|
|
75
78
|
@Prop({ type: String, required: false })
|
|
76
79
|
description?: string;
|
|
@@ -225,6 +225,12 @@ export class Content {
|
|
|
225
225
|
|
|
226
226
|
@Prop({ type: String, required: false })
|
|
227
227
|
mediaUrl?: string;
|
|
228
|
+
|
|
229
|
+
@Prop({ type: Boolean, required: false, default: false })
|
|
230
|
+
isEdited?: boolean;
|
|
231
|
+
|
|
232
|
+
@Prop({ type: Date, required: false })
|
|
233
|
+
editedAt?: Date;
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
export const ContentSchema = SchemaFactory.createForClass(Content);
|
|
@@ -124,8 +124,8 @@ export class Pending {
|
|
|
124
124
|
|
|
125
125
|
@Prop() installmentNumber: number;
|
|
126
126
|
|
|
127
|
-
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale' })
|
|
128
|
-
sale
|
|
127
|
+
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Sale', required: false })
|
|
128
|
+
sale?: Types.ObjectId | Sale;
|
|
129
129
|
|
|
130
130
|
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Action' })
|
|
131
131
|
action?: Types.ObjectId | Action;
|
|
@@ -261,6 +261,7 @@ export class Payment {
|
|
|
261
261
|
export const PaymentSchema = SchemaFactory.createForClass(Payment);
|
|
262
262
|
|
|
263
263
|
PaymentSchema.index({ 'pending.sale': 1 });
|
|
264
|
+
PaymentSchema.index({ 'pending.sale': 1, 'pending.installmentNumber': 1 });
|
|
264
265
|
PaymentSchema.index({ 'pending.influencer': 1 });
|
|
265
266
|
PaymentSchema.index({ 'pending.recruitment': 1 });
|
|
266
267
|
PaymentSchema.index({ 'pending.action': 1 });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
2
|
+
import { HydratedDocument, Types } from 'mongoose';
|
|
3
|
+
|
|
4
|
+
export type TagDocument = HydratedDocument<Tag>;
|
|
5
|
+
|
|
6
|
+
@Schema({ timestamps: true, collection: 'tag' })
|
|
7
|
+
export class Tag {
|
|
8
|
+
@Prop({ type: Types.ObjectId, ref: 'Organization', required: true, index: true })
|
|
9
|
+
organization: Types.ObjectId;
|
|
10
|
+
|
|
11
|
+
@Prop({ required: true, enum: ['sales', 'invoices', 'payments', 'actions'], index: true })
|
|
12
|
+
module: string;
|
|
13
|
+
|
|
14
|
+
@Prop({ required: true, trim: true })
|
|
15
|
+
name: string;
|
|
16
|
+
|
|
17
|
+
@Prop({ required: false })
|
|
18
|
+
color?: string;
|
|
19
|
+
|
|
20
|
+
createdAt?: Date;
|
|
21
|
+
updatedAt?: Date;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const TagSchema = SchemaFactory.createForClass(Tag);
|
|
25
|
+
|
|
26
|
+
TagSchema.index({ organization: 1, module: 1, name: 1 }, { unique: true });
|