MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / insertConnection

Function insertConnection

packages/core/sdk/src/platform-view.test.ts:86–133  ·  view source on GitHub ↗
(
  db: SqliteTestFumaDb,
  row: {
    readonly rowId: string;
    readonly tenant: string;
    readonly owner: string;
    readonly subject: string;
    readonly integration: string;
    readonly name: string;
    readonly oauthScope?: string | null;
  },
)

Source from the content-addressed store, hash-verified

84 );
85
86const insertConnection = (
87 db: SqliteTestFumaDb,
88 row: {
89 readonly rowId: string;
90 readonly tenant: string;
91 readonly owner: string;
92 readonly subject: string;
93 readonly integration: string;
94 readonly name: string;
95 readonly oauthScope?: string | null;
96 },
97): Effect.Effect<void> =>
98 Effect.promise(async () => {
99 await db.client.execute({
100 sql: `INSERT INTO connection (
101 row_id, tenant, owner, subject, integration, name, template, provider,
102 item_ids, refresh_item_id, oauth_scope, last_health, created_at, updated_at
103 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
104 args: [
105 row.rowId,
106 row.tenant,
107 row.owner,
108 row.subject,
109 row.integration,
110 row.name,
111 "oauth2",
112 "memory",
113 // Deliberately secret-bearing: the assertions below prove these never
114 // leave the storage layer.
115 JSON.stringify({ token: `SECRET-item-${row.rowId}` }),
116 `SECRET-refresh-${row.rowId}`,
117 row.oauthScope ?? null,
118 // A full stored verdict, upstream-derived fields included — that is
119 // what a real health check writes. This layer is entitled to read them
120 // back (see UPSTREAM_HEALTH_FIELDS); the API's projection is what keeps
121 // them off the wire.
122 JSON.stringify({
123 status: "healthy",
124 checkedAt: 1_700_000_000_000,
125 identity: `UPSTREAM-identity-${row.rowId}@provider.test`,
126 detail: `UPSTREAM-detail-${row.rowId}`,
127 responseSample: [{ path: "user.email", value: `UPSTREAM-sample-${row.rowId}` }],
128 }),
129 Date.now(),
130 Date.now(),
131 ],
132 });
133 });
134
135/** A tenant-scoped `integration` row, inserted raw. Needed because
136 * `integrations.remove` short-circuits on an absent slug — without a real row

Callers 1

seedFunction · 0.70

Calls 1

executeMethod · 0.65

Tested by

no test coverage detected