@contractspec/example.integration-supabase 1.57.0
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/.turbo/turbo-build$colon$bundle.log +42 -0
- package/.turbo/turbo-build.log +40 -0
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/blueprint.d.ts +7 -0
- package/dist/blueprint.d.ts.map +1 -0
- package/dist/blueprint.js +75 -0
- package/dist/blueprint.js.map +1 -0
- package/dist/connection.sample.d.ts +9 -0
- package/dist/connection.sample.d.ts.map +1 -0
- package/dist/connection.sample.js +50 -0
- package/dist/connection.sample.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/integration-supabase.docblock.d.ts +1 -0
- package/dist/docs/integration-supabase.docblock.js +60 -0
- package/dist/docs/integration-supabase.docblock.js.map +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +46 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/runtime.sample.d.ts +16 -0
- package/dist/runtime.sample.d.ts.map +1 -0
- package/dist/runtime.sample.js +43 -0
- package/dist/runtime.sample.js.map +1 -0
- package/dist/tenant.d.ts +7 -0
- package/dist/tenant.d.ts.map +1 -0
- package/dist/tenant.js +40 -0
- package/dist/tenant.js.map +1 -0
- package/package.json +64 -0
- package/src/blueprint.ts +68 -0
- package/src/connection.sample.ts +52 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/integration-supabase.docblock.ts +58 -0
- package/src/example.ts +32 -0
- package/src/index.ts +6 -0
- package/src/runtime.sample.ts +53 -0
- package/src/tenant.ts +41 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +6 -0
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/example.integration-supabase",
|
|
3
|
+
"version": "1.57.0",
|
|
4
|
+
"description": "Integration example - Supabase vector store + Postgres database wiring.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./blueprint": "./dist/blueprint.js",
|
|
10
|
+
"./connection.sample": "./dist/connection.sample.js",
|
|
11
|
+
"./docs": "./dist/docs/index.js",
|
|
12
|
+
"./docs/integration-supabase.docblock": "./dist/docs/integration-supabase.docblock.js",
|
|
13
|
+
"./example": "./dist/example.js",
|
|
14
|
+
"./runtime.sample": "./dist/runtime.sample.js",
|
|
15
|
+
"./tenant": "./dist/tenant.js",
|
|
16
|
+
"./*": "./*"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
20
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
21
|
+
"build": "bun build:types && bun build:bundle",
|
|
22
|
+
"build:bundle": "tsdown",
|
|
23
|
+
"build:types": "tsc --noEmit",
|
|
24
|
+
"dev": "bun build:bundle --watch",
|
|
25
|
+
"clean": "rimraf dist .turbo",
|
|
26
|
+
"lint": "bun lint:fix",
|
|
27
|
+
"lint:fix": "eslint src --fix",
|
|
28
|
+
"lint:check": "eslint src",
|
|
29
|
+
"test": "bun test"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@contractspec/integration.providers-impls": "1.57.0",
|
|
33
|
+
"@contractspec/integration.runtime": "1.57.0",
|
|
34
|
+
"@contractspec/lib.contracts": "1.57.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@contractspec/tool.tsdown": "1.57.0",
|
|
38
|
+
"@contractspec/tool.typescript": "1.57.0",
|
|
39
|
+
"tsdown": "^0.20.3",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": "./dist/index.js",
|
|
46
|
+
"./blueprint": "./dist/blueprint.js",
|
|
47
|
+
"./connection.sample": "./dist/connection.sample.js",
|
|
48
|
+
"./docs": "./dist/docs/index.js",
|
|
49
|
+
"./docs/integration-supabase.docblock": "./dist/docs/integration-supabase.docblock.js",
|
|
50
|
+
"./example": "./dist/example.js",
|
|
51
|
+
"./runtime.sample": "./dist/runtime.sample.js",
|
|
52
|
+
"./tenant": "./dist/tenant.js",
|
|
53
|
+
"./*": "./*"
|
|
54
|
+
},
|
|
55
|
+
"registry": "https://registry.npmjs.org/"
|
|
56
|
+
},
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
61
|
+
"directory": "packages/examples/integration-supabase"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://contractspec.io"
|
|
64
|
+
}
|
package/src/blueprint.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AppBlueprintSpec } from '@contractspec/lib.contracts/app-config/spec';
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum,
|
|
6
|
+
} from '@contractspec/lib.contracts/ownership';
|
|
7
|
+
|
|
8
|
+
export const supabaseKnowledgeBlueprint: AppBlueprintSpec = {
|
|
9
|
+
meta: {
|
|
10
|
+
key: 'knowledge.supabase.dual-store',
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
appId: 'knowledge-assistant',
|
|
13
|
+
title: 'Knowledge Assistant - Supabase Dual Store',
|
|
14
|
+
description:
|
|
15
|
+
'Blueprint that uses Supabase for both vector retrieval and SQL-backed analytics.',
|
|
16
|
+
domain: 'knowledge',
|
|
17
|
+
owners: [OwnersEnum.PlatformCore],
|
|
18
|
+
tags: [
|
|
19
|
+
TagsEnum.Automation,
|
|
20
|
+
'knowledge',
|
|
21
|
+
'supabase',
|
|
22
|
+
'vector-db',
|
|
23
|
+
'database',
|
|
24
|
+
],
|
|
25
|
+
stability: StabilityEnum.Experimental,
|
|
26
|
+
},
|
|
27
|
+
capabilities: {
|
|
28
|
+
enabled: [
|
|
29
|
+
{ key: 'vector-db.search', version: '1.0.0' },
|
|
30
|
+
{ key: 'vector-db.storage', version: '1.0.0' },
|
|
31
|
+
{ key: 'database.sql', version: '1.0.0' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
integrationSlots: [
|
|
35
|
+
{
|
|
36
|
+
slotId: 'primary-vector-db',
|
|
37
|
+
requiredCategory: 'vector-db',
|
|
38
|
+
allowedModes: ['managed', 'byok'],
|
|
39
|
+
requiredCapabilities: [
|
|
40
|
+
{ key: 'vector-db.search', version: '1.0.0' },
|
|
41
|
+
{ key: 'vector-db.storage', version: '1.0.0' },
|
|
42
|
+
],
|
|
43
|
+
required: true,
|
|
44
|
+
description: 'Primary semantic retrieval store for knowledge chunks.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
slotId: 'primary-database',
|
|
48
|
+
requiredCategory: 'database',
|
|
49
|
+
allowedModes: ['managed', 'byok'],
|
|
50
|
+
requiredCapabilities: [{ key: 'database.sql', version: '1.0.0' }],
|
|
51
|
+
required: true,
|
|
52
|
+
description:
|
|
53
|
+
'Primary SQL database for analytics and transactional reads.',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
workflows: {
|
|
57
|
+
ingestKnowledge: {
|
|
58
|
+
key: 'knowledge.ingest.supabase',
|
|
59
|
+
version: '1.0.0',
|
|
60
|
+
},
|
|
61
|
+
refreshMetrics: {
|
|
62
|
+
key: 'knowledge.metrics.supabase',
|
|
63
|
+
version: '1.0.0',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
notes:
|
|
67
|
+
'Bind both slots to Supabase connections when you want shared infra for embeddings and SQL operations.',
|
|
68
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IntegrationConnection } from '@contractspec/lib.contracts/integrations/connection';
|
|
2
|
+
|
|
3
|
+
export const supabaseVectorConnection: IntegrationConnection = {
|
|
4
|
+
meta: {
|
|
5
|
+
id: 'conn-supabase-vector',
|
|
6
|
+
tenantId: 'acme-knowledge',
|
|
7
|
+
integrationKey: 'vectordb.supabase',
|
|
8
|
+
integrationVersion: '1.0.0',
|
|
9
|
+
label: 'Supabase Vector Store',
|
|
10
|
+
environment: 'production',
|
|
11
|
+
createdAt: '2026-02-06T00:00:00.000Z',
|
|
12
|
+
updatedAt: '2026-02-06T00:00:00.000Z',
|
|
13
|
+
},
|
|
14
|
+
ownershipMode: 'managed',
|
|
15
|
+
config: {
|
|
16
|
+
schema: 'public',
|
|
17
|
+
table: 'contractspec_vectors',
|
|
18
|
+
createTableIfMissing: true,
|
|
19
|
+
distanceMetric: 'cosine',
|
|
20
|
+
maxConnections: 5,
|
|
21
|
+
sslMode: 'require',
|
|
22
|
+
},
|
|
23
|
+
secretProvider: 'vault',
|
|
24
|
+
secretRef: 'vault://integrations/acme-knowledge/conn-supabase-vector',
|
|
25
|
+
status: 'connected',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const supabaseDatabaseConnection: IntegrationConnection = {
|
|
29
|
+
meta: {
|
|
30
|
+
id: 'conn-supabase-db',
|
|
31
|
+
tenantId: 'acme-knowledge',
|
|
32
|
+
integrationKey: 'database.supabase',
|
|
33
|
+
integrationVersion: '1.0.0',
|
|
34
|
+
label: 'Supabase Postgres',
|
|
35
|
+
environment: 'production',
|
|
36
|
+
createdAt: '2026-02-06T00:00:00.000Z',
|
|
37
|
+
updatedAt: '2026-02-06T00:00:00.000Z',
|
|
38
|
+
},
|
|
39
|
+
ownershipMode: 'managed',
|
|
40
|
+
config: {
|
|
41
|
+
maxConnections: 10,
|
|
42
|
+
sslMode: 'require',
|
|
43
|
+
},
|
|
44
|
+
secretProvider: 'vault',
|
|
45
|
+
secretRef: 'vault://integrations/acme-knowledge/conn-supabase-db',
|
|
46
|
+
status: 'connected',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const supabaseConnectionSamples: IntegrationConnection[] = [
|
|
50
|
+
supabaseVectorConnection,
|
|
51
|
+
supabaseDatabaseConnection,
|
|
52
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './integration-supabase.docblock';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DocBlock } from '@contractspec/lib.contracts/docs';
|
|
2
|
+
import { registerDocBlocks } from '@contractspec/lib.contracts/docs';
|
|
3
|
+
|
|
4
|
+
const blocks: DocBlock[] = [
|
|
5
|
+
{
|
|
6
|
+
id: 'docs.examples.integration-supabase',
|
|
7
|
+
title: 'Integration Example - Supabase Vector + Postgres',
|
|
8
|
+
summary:
|
|
9
|
+
'Reference example wiring Supabase vector and SQL integrations in one tenant configuration.',
|
|
10
|
+
kind: 'reference',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
route: '/docs/examples/integration-supabase',
|
|
13
|
+
tags: ['supabase', 'vector-db', 'database', 'integration', 'example'],
|
|
14
|
+
body: `## What this example includes
|
|
15
|
+
- A blueprint declaring two required integration slots:
|
|
16
|
+
- \`primary-vector-db\` bound to \`vectordb.supabase\`
|
|
17
|
+
- \`primary-database\` bound to \`database.supabase\`
|
|
18
|
+
- A tenant config binding both slots.
|
|
19
|
+
- Connection samples with clear \`config\` vs \`secretRef\` separation.
|
|
20
|
+
- A runtime sample that upserts/searches vectors and executes SQL queries.
|
|
21
|
+
|
|
22
|
+
## Why this pattern
|
|
23
|
+
- Keeps integration concerns explicit and auditable in app-config.
|
|
24
|
+
- Enables shared Supabase infrastructure for retrieval + analytics.
|
|
25
|
+
- Preserves secret management boundaries (no credentials in config/spec).`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'docs.examples.integration-supabase.usage',
|
|
29
|
+
title: 'Supabase Integration Example - Usage',
|
|
30
|
+
summary:
|
|
31
|
+
'Step-by-step usage of the Supabase dual-store integration example.',
|
|
32
|
+
kind: 'usage',
|
|
33
|
+
visibility: 'public',
|
|
34
|
+
route: '/docs/examples/integration-supabase/usage',
|
|
35
|
+
tags: ['supabase', 'usage'],
|
|
36
|
+
body: `## Usage
|
|
37
|
+
1) Register integration specs from \`createDefaultIntegrationSpecRegistry()\`.
|
|
38
|
+
2) Persist both sample connections from \`connection.sample.ts\`.
|
|
39
|
+
3) Publish the tenant config from \`tenant.ts\` with matching \`connectionId\` values.
|
|
40
|
+
4) Use \`runSupabaseKnowledgeRuntime(...)\` to execute vector and SQL calls through \`IntegrationProviderFactory\`.
|
|
41
|
+
|
|
42
|
+
## Secret payload
|
|
43
|
+
Store the following payload in your secret provider target for each connection:
|
|
44
|
+
|
|
45
|
+
\`\`\`json
|
|
46
|
+
{
|
|
47
|
+
"databaseUrl": "postgresql://postgres.<project-ref>:<password>@aws-0-<region>.pooler.supabase.com:6543/postgres"
|
|
48
|
+
}
|
|
49
|
+
\`\`\`
|
|
50
|
+
|
|
51
|
+
## Guardrails
|
|
52
|
+
- Never place credentials in \`config\` or source control.
|
|
53
|
+
- Keep operational SQL behind explicit workflows/operations.
|
|
54
|
+
- Restrict DB credentials to least-privilege roles whenever possible.`,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
registerDocBlocks(blocks);
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineExample } from '@contractspec/lib.contracts';
|
|
2
|
+
|
|
3
|
+
const example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: 'integration-supabase',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
title: 'Integration - Supabase Vector + Postgres',
|
|
8
|
+
description:
|
|
9
|
+
'Wire AppBlueprint and TenantAppConfig to use Supabase for both vector retrieval and SQL workloads.',
|
|
10
|
+
kind: 'integration',
|
|
11
|
+
visibility: 'public',
|
|
12
|
+
stability: 'experimental',
|
|
13
|
+
owners: ['@platform.core'],
|
|
14
|
+
tags: ['supabase', 'pgvector', 'postgres', 'integration', 'knowledge'],
|
|
15
|
+
},
|
|
16
|
+
docs: {
|
|
17
|
+
rootDocId: 'docs.examples.integration-supabase',
|
|
18
|
+
usageDocId: 'docs.examples.integration-supabase.usage',
|
|
19
|
+
},
|
|
20
|
+
entrypoints: {
|
|
21
|
+
packageName: '@contractspec/example.integration-supabase',
|
|
22
|
+
docs: './docs',
|
|
23
|
+
},
|
|
24
|
+
surfaces: {
|
|
25
|
+
templates: true,
|
|
26
|
+
sandbox: { enabled: true, modes: ['markdown', 'specs'] },
|
|
27
|
+
studio: { enabled: true, installable: true },
|
|
28
|
+
mcp: { enabled: true },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default example;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { VectorSearchResult } from '@contractspec/integration.providers-impls/vector-store';
|
|
2
|
+
import { IntegrationProviderFactory } from '@contractspec/integration.providers-impls/impls/provider-factory';
|
|
3
|
+
import type { IntegrationContext } from '@contractspec/integration.runtime/runtime';
|
|
4
|
+
|
|
5
|
+
export interface SupabaseKnowledgeRuntimeParams {
|
|
6
|
+
vectorContext: IntegrationContext;
|
|
7
|
+
databaseContext: IntegrationContext;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SupabaseKnowledgeRuntimeResult {
|
|
11
|
+
matches: VectorSearchResult[];
|
|
12
|
+
indexedDocumentCount: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function runSupabaseKnowledgeRuntime(
|
|
16
|
+
params: SupabaseKnowledgeRuntimeParams
|
|
17
|
+
): Promise<SupabaseKnowledgeRuntimeResult> {
|
|
18
|
+
const factory = new IntegrationProviderFactory();
|
|
19
|
+
|
|
20
|
+
const vectorStore = await factory.createVectorStoreProvider(
|
|
21
|
+
params.vectorContext
|
|
22
|
+
);
|
|
23
|
+
const database = await factory.createDatabaseProvider(params.databaseContext);
|
|
24
|
+
|
|
25
|
+
await vectorStore.upsert({
|
|
26
|
+
collection: 'knowledge_chunks',
|
|
27
|
+
documents: [
|
|
28
|
+
{
|
|
29
|
+
id: 'chunk-1',
|
|
30
|
+
vector: [0.11, 0.23, 0.45],
|
|
31
|
+
payload: { source: 'faq', locale: 'en' },
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const matches = await vectorStore.search({
|
|
37
|
+
collection: 'knowledge_chunks',
|
|
38
|
+
vector: [0.12, 0.22, 0.44],
|
|
39
|
+
topK: 5,
|
|
40
|
+
filter: { source: 'faq' },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const count = await database.query<{ total: number }>(
|
|
44
|
+
'SELECT COUNT(*)::int AS total FROM knowledge_chunks;'
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
await database.close();
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
matches,
|
|
51
|
+
indexedDocumentCount: count.rows[0]?.total ?? 0,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/src/tenant.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TenantAppConfig } from '@contractspec/lib.contracts/app-config/spec';
|
|
2
|
+
|
|
3
|
+
export const supabaseKnowledgeTenantConfig: TenantAppConfig = {
|
|
4
|
+
meta: {
|
|
5
|
+
id: 'tenant-config-knowledge-supabase',
|
|
6
|
+
tenantId: 'acme-knowledge',
|
|
7
|
+
appId: 'knowledge-assistant',
|
|
8
|
+
blueprintName: 'knowledge.supabase.dual-store',
|
|
9
|
+
blueprintVersion: '1.0.0',
|
|
10
|
+
environment: 'production',
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
status: 'published',
|
|
13
|
+
createdAt: new Date().toISOString(),
|
|
14
|
+
updatedAt: new Date().toISOString(),
|
|
15
|
+
},
|
|
16
|
+
integrations: [
|
|
17
|
+
{
|
|
18
|
+
slotId: 'primary-vector-db',
|
|
19
|
+
connectionId: 'conn-supabase-vector',
|
|
20
|
+
scope: {
|
|
21
|
+
workflows: ['ingestKnowledge'],
|
|
22
|
+
operations: ['knowledge.indexChunks', 'knowledge.semanticSearch'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
slotId: 'primary-database',
|
|
27
|
+
connectionId: 'conn-supabase-db',
|
|
28
|
+
scope: {
|
|
29
|
+
workflows: ['refreshMetrics'],
|
|
30
|
+
operations: ['knowledge.metrics.refresh', 'knowledge.metrics.query'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
knowledge: [],
|
|
35
|
+
locales: {
|
|
36
|
+
defaultLocale: 'en',
|
|
37
|
+
enabledLocales: ['en'],
|
|
38
|
+
},
|
|
39
|
+
notes:
|
|
40
|
+
'Supabase vector + SQL connections bound for production knowledge flows.',
|
|
41
|
+
};
|