All files / src/platform/marketplace/schemas marketplace.schema.ts

0% Statements 0/21
0% Branches 0/4
100% Functions 0/0
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                                           
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'marketplace_apps' })
export class MarketplaceApp extends Document {
  @Prop({ required: true, unique: true, index: true })
  appKey: string; // e.g. 'jira_sync', 'slack_alerts'
 
  @Prop({ required: true })
  name: string;
 
  @Prop({ required: true })
  description: string;
 
  @Prop({ type: [String], default: [] })
  requiredScopes: string[];
 
  @Prop({ default: true })
  isActive: boolean;
 
  createdAt: Date;
  updatedAt: Date;
}
export const MarketplaceAppSchema =
  SchemaFactory.createForClass(MarketplaceApp);
 
@Schema({ timestamps: true, collection: 'marketplace_installations' })
export class MarketplaceInstallation extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, index: true })
  appKey: string;
 
  @Prop({ required: true, enum: ['installed', 'uninstalled', 'suspended'] })
  status: string;
 
  @Prop({ type: Object, default: {} })
  settings: Record<string, any>;
 
  @Prop({ default: null })
  installedBy: string;
 
  createdAt: Date;
  updatedAt: Date;
}
export const MarketplaceInstallationSchema = SchemaFactory.createForClass(
  MarketplaceInstallation,
);
MarketplaceInstallationSchema.index(
  { tenantId: 1, appKey: 1 },
  { unique: true },
);