File size: 1,452 Bytes
46252cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Column, CreateDateColumn, Entity, Index, PrimaryColumn, UpdateDateColumn } from 'typeorm';
import { jsonColumnType } from '../../../common/utils/column-types';

// One configured instance of an adapter plugin (e.g. one Chatwoot account). instanceId is namespaced
// under pluginId; NOT a separate worker. Secret is host-minted and masked-on-read.
@Entity('plugin_instances')
@Index('UQ_plugin_instances_plugin_instance', ['pluginId', 'instanceId'], { unique: true })
export class PluginInstance {
  @PrimaryColumn()
  id: string; // `${pluginId}:${instanceId}`

  @Column()
  pluginId: string;

  @Column()
  instanceId: string;

  @Column({ type: 'varchar', nullable: true })
  sessionScope: string | null; // resolved session id this instance acts on; null = inherit manifest.sessions

  @Column()
  secret: string; // host-minted ingress HMAC secret; stored plaintext, masked to '***' on API reads
  // (via PluginInstanceService.maskedView + the provisioning controller's reveal flag), exposed
  // in full only on mint and regenerate-secret. Note: instance `config` is NOT secret-redacted.

  @Column({ type: 'varchar', nullable: true })
  verifyToken: string | null; // optional provider challenge token

  @Column({ type: jsonColumnType(), nullable: true })
  config: Record<string, unknown> | null;

  @Column({ default: true })
  enabled: boolean;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}