(db: DrizzleDb, tenant: string, tag: string)
| 49 | // Insert one row into every tenant table, plus an org- and a user-scoped blob, |
| 50 | // all owned by `tenant`. `tag` keeps unique indexes from colliding across orgs. |
| 51 | const seedTenant = async (db: DrizzleDb, tenant: string, tag: string) => { |
| 52 | const now = new Date(); |
| 53 | await db.insert(integration).values({ |
| 54 | slug: `int-${tag}`, |
| 55 | plugin_id: "p", |
| 56 | created_at: now, |
| 57 | updated_at: now, |
| 58 | tenant, |
| 59 | }); |
| 60 | await db.insert(connection).values({ |
| 61 | integration: "int", |
| 62 | name: `conn-${tag}`, |
| 63 | template: "t", |
| 64 | provider: "pr", |
| 65 | item_ids: [], |
| 66 | created_at: now, |
| 67 | updated_at: now, |
| 68 | tenant, |
| 69 | owner: "o", |
| 70 | subject: "s", |
| 71 | }); |
| 72 | await db.insert(oauth_client).values({ |
| 73 | slug: `oc-${tag}`, |
| 74 | authorization_url: "u", |
| 75 | token_url: "u", |
| 76 | grant: "g", |
| 77 | client_id: "c", |
| 78 | created_at: now, |
| 79 | tenant, |
| 80 | owner: "o", |
| 81 | subject: "s", |
| 82 | }); |
| 83 | await db.insert(oauth_session).values({ |
| 84 | state: `state-${tag}`, |
| 85 | client_slug: "cs", |
| 86 | integration: "int", |
| 87 | name: "n", |
| 88 | template: "t", |
| 89 | redirect_url: "r", |
| 90 | payload: {}, |
| 91 | expires_at: 0n, |
| 92 | created_at: now, |
| 93 | tenant, |
| 94 | owner: "o", |
| 95 | subject: "s", |
| 96 | }); |
| 97 | await db.insert(tool).values({ |
| 98 | integration: "int", |
| 99 | connection: "conn", |
| 100 | plugin_id: "p", |
| 101 | name: `tool-${tag}`, |
| 102 | description: "d", |
| 103 | created_at: now, |
| 104 | updated_at: now, |
| 105 | tenant, |
| 106 | owner: "o", |
| 107 | subject: "s", |
| 108 | }); |
no test coverage detected