@polymorphism-tech/morph-spec 11.2.0 → 11.3.1
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/README.md +3 -2
- package/bin/morph-spec.js +7 -7
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +1 -1
- package/framework/MORPH.md +2 -2
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +19 -11
- package/framework/evals/review-checklist.md +26 -2
- package/framework/hooks/README.md +3 -2
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
- package/framework/mcp/registry.json +15 -15
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/mcp-standards.md +10 -0
- package/framework/schemas/config.schema.json +7 -0
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +4 -3
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +8 -4
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/agent-archetypes.md +1 -1
- package/framework/standards/ai-agents/middleware-patterns.md +0 -2
- package/framework/standards/ai-agents/prompt-sources.md +2 -2
- package/framework/standards/ai-agents/providers/model-registry.md +9 -12
- package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
- package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
- package/framework/standards/integration/mcp/mcp-tools.md +124 -266
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +0 -206
- package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
- package/framework/templates/context/design-system.md +1 -1
- package/framework/templates/docs/plan.md +1 -1
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +2 -4
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +9 -3
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +23 -191
- package/src/commands/project/doctor.js +6 -16
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +15 -133
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +1 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +52 -66
- package/src/commands/scaffold/scaffold.js +28 -7
- package/src/lib/ai/ai-project-scan.js +1 -4
- package/src/lib/ai/code-audit.js +1 -6
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +45 -47
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +2 -7
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +2 -1
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +14 -5
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +42 -21
- package/src/lib/installers/stack-sync.js +12 -12
- package/src/lib/installers/stack-tooling.js +4 -3
- package/src/lib/json-file.js +9 -0
- package/src/lib/plan/artifact-vocabulary.js +1 -1
- package/src/lib/plan/checks.js +3 -2
- package/src/lib/plan/media.js +3 -3
- package/src/lib/plan/plan-parser.js +5 -10
- package/src/lib/review-reports.js +5 -4
- package/src/lib/stack/stack-scan.js +1 -1
- package/src/lib/standards/verified-against.js +1 -1
- package/src/lib/tests-audit/audit.js +1 -1
- package/src/lib/text.js +5 -0
- package/src/scripts/setup-infra.js +22 -33
- package/src/utils/agents-installer.js +13 -30
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +2 -2
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +55 -20
- package/src/utils/skills-installer.js +18 -78
- package/framework/templates/IDE-SNIPPETS.md +0 -262
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
- package/framework/templates/code/dotnet/contracts/README.md +0 -74
- package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
- package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
- package/framework/templates/code/typescript/contracts.ts +0 -140
- package/framework/templates/examples/design-system-examples.md +0 -354
- package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
- package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
- package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
- package/framework/templates/integrations/asaas-client.cs +0 -332
- package/framework/templates/integrations/asaas-webhook.cs +0 -290
- package/framework/templates/integrations/neon-auth-config.cs +0 -170
- package/framework/templates/ui/design-system.css +0 -226
- package/src/lib/detectors/index.js +0 -153
- package/src/lib/installers/templates-reconcile.js +0 -26
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Contracts - {{titleCase FEATURE_NAME}}
|
|
2
|
-
|
|
3
|
-
> Estrutura de contracts para features complexas
|
|
4
|
-
|
|
5
|
-
## Estrutura
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
contracts/
|
|
9
|
-
├── README.md # Este arquivo (índice)
|
|
10
|
-
├── Entities/ # Entidades de domínio
|
|
11
|
-
│ └── I{{pascalCase FEATURE_NAME}}Entity.cs
|
|
12
|
-
├── Commands/ # Commands (CQRS)
|
|
13
|
-
│ └── I{{pascalCase FEATURE_NAME}}Commands.cs
|
|
14
|
-
├── Queries/ # Queries (CQRS)
|
|
15
|
-
│ └── I{{pascalCase FEATURE_NAME}}Queries.cs
|
|
16
|
-
├── DTOs/ # Data Transfer Objects
|
|
17
|
-
│ └── {{pascalCase FEATURE_NAME}}Dto.cs
|
|
18
|
-
├── Events/ # Domain Events
|
|
19
|
-
│ └── {{pascalCase FEATURE_NAME}}Events.cs
|
|
20
|
-
└── Services/ # Service Interfaces
|
|
21
|
-
└── I{{pascalCase FEATURE_NAME}}Service.cs
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Quando usar pasta vs arquivo único
|
|
25
|
-
|
|
26
|
-
| Cenário | Usar |
|
|
27
|
-
|---------|------|
|
|
28
|
-
| < 5 interfaces/DTOs | `contracts.cs` (arquivo único) |
|
|
29
|
-
| 5-15 interfaces/DTOs | `contracts/` (pasta organizada) |
|
|
30
|
-
| > 15 interfaces/DTOs | `contracts/` + subpastas por domínio |
|
|
31
|
-
|
|
32
|
-
## Convenções
|
|
33
|
-
|
|
34
|
-
1. **Prefixo `I`** para interfaces: `IOrderService`, `IPaymentGateway`
|
|
35
|
-
2. **Sufixo `Dto`** para DTOs: `OrderDto`, `OrderCreateDto`
|
|
36
|
-
3. **Sufixo `Command`** para commands: `CreateOrderCommand`
|
|
37
|
-
4. **Sufixo `Query`** para queries: `GetOrderByIdQuery`
|
|
38
|
-
5. **Sufixo `Event`** para eventos: `OrderCreatedEvent`
|
|
39
|
-
|
|
40
|
-
## Índice de Contracts
|
|
41
|
-
|
|
42
|
-
### Entidades
|
|
43
|
-
|
|
44
|
-
| Interface | Descrição | Arquivo |
|
|
45
|
-
|-----------|-----------|---------|
|
|
46
|
-
| _A ser preenchido_ | | |
|
|
47
|
-
|
|
48
|
-
### Commands
|
|
49
|
-
|
|
50
|
-
| Command | Handler | Descrição |
|
|
51
|
-
|---------|---------|-----------|
|
|
52
|
-
| _A ser preenchido_ | | |
|
|
53
|
-
|
|
54
|
-
### Queries
|
|
55
|
-
|
|
56
|
-
| Query | Handler | Descrição |
|
|
57
|
-
|-------|---------|-----------|
|
|
58
|
-
| _A ser preenchido_ | | |
|
|
59
|
-
|
|
60
|
-
### DTOs
|
|
61
|
-
|
|
62
|
-
| DTO | Usado em | Descrição |
|
|
63
|
-
|-----|----------|-----------|
|
|
64
|
-
| _A ser preenchido_ | | |
|
|
65
|
-
|
|
66
|
-
### Services
|
|
67
|
-
|
|
68
|
-
| Interface | Implementação | Descrição |
|
|
69
|
-
|-----------|---------------|-----------|
|
|
70
|
-
| _A ser preenchido_ | | |
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
_Gerado por MORPH-SPEC Framework_
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
using System.ComponentModel.DataAnnotations.Schema;
|
|
2
|
-
using Microsoft.EntityFrameworkCore;
|
|
3
|
-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
4
|
-
using Pgvector;
|
|
5
|
-
|
|
6
|
-
#nullable disable
|
|
7
|
-
|
|
8
|
-
namespace {{NAMESPACE}}.Domain.Entities;
|
|
9
|
-
|
|
10
|
-
public class {{pascalCase FEATURE_NAME}}
|
|
11
|
-
{
|
|
12
|
-
public Guid Id { get; set; }
|
|
13
|
-
public string Title { get; set; } = string.Empty;
|
|
14
|
-
public string Content { get; set; } = string.Empty;
|
|
15
|
-
public string? Metadata { get; set; }
|
|
16
|
-
|
|
17
|
-
// 1536 é a dimensão do text-embedding-3-small; troca junto com o modelo, aqui e na configuração
|
|
18
|
-
[Column(TypeName = "vector(1536)")]
|
|
19
|
-
public Vector? Embedding { get; set; }
|
|
20
|
-
|
|
21
|
-
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
|
22
|
-
public DateTimeOffset? UpdatedAt { get; set; }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
namespace {{NAMESPACE}}.Infrastructure.Data.Configurations;
|
|
26
|
-
|
|
27
|
-
// Exige UseVector() no AddNpgsql e HasPostgresExtension("vector") no OnModelCreating
|
|
28
|
-
public class {{pascalCase FEATURE_NAME}}Configuration : IEntityTypeConfiguration<{{pascalCase FEATURE_NAME}}>
|
|
29
|
-
{
|
|
30
|
-
public void Configure(EntityTypeBuilder<{{pascalCase FEATURE_NAME}}> builder)
|
|
31
|
-
{
|
|
32
|
-
builder.ToTable("{{snakeCase FEATURE_NAME}}s");
|
|
33
|
-
builder.HasKey(e => e.Id);
|
|
34
|
-
builder.Property(e => e.Id).HasDefaultValueSql("gen_random_uuid()");
|
|
35
|
-
builder.Property(e => e.Title).IsRequired().HasMaxLength(200);
|
|
36
|
-
builder.Property(e => e.Content).IsRequired();
|
|
37
|
-
builder.Property(e => e.Metadata).HasColumnType("jsonb");
|
|
38
|
-
builder.Property(e => e.Embedding).HasColumnType("vector(1536)");
|
|
39
|
-
builder.Property(e => e.CreatedAt).HasDefaultValueSql("now()");
|
|
40
|
-
|
|
41
|
-
builder.HasIndex(e => e.Embedding)
|
|
42
|
-
.HasMethod("hnsw")
|
|
43
|
-
.HasOperators("vector_cosine_ops")
|
|
44
|
-
.HasStorageParameter("m", 16)
|
|
45
|
-
.HasStorageParameter("ef_construction", 64);
|
|
46
|
-
|
|
47
|
-
builder.HasIndex(e => e.Title);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
-- TEMPLATE: pgvector-embeddings-migration.sql
|
|
2
|
-
-- PURPOSE: Creates the kb_embeddings table for custom RAG — chunk storage with pgvector.
|
|
3
|
-
-- READS STANDARD: ai-agents-rag-custom-pgvector
|
|
4
|
-
-- PLACEHOLDERS:
|
|
5
|
-
-- {{SCHEMA}} — target schema (default: public)
|
|
6
|
-
-- LAST-VERIFIED: 2026-05-19
|
|
7
|
-
--
|
|
8
|
-
-- PREREQUISITES:
|
|
9
|
-
-- - pgvector extension enabled in Neon (see infrastructure-neon-pgvector).
|
|
10
|
-
-- - NpgsqlDataSourceBuilder.UseVector() called in the project's DB setup.
|
|
11
|
-
--
|
|
12
|
-
-- DIMENSION NOTE:
|
|
13
|
-
-- embedding vector(1536) matches text-embedding-3-small (default 1536 dimensions).
|
|
14
|
-
-- If the project uses a different embedding model, adjust the dimension to match.
|
|
15
|
-
-- NEVER mix embedding models on a single column — vectors live in different spaces.
|
|
16
|
-
|
|
17
|
-
-- ============================================================
|
|
18
|
-
-- 1. EXTENSION
|
|
19
|
-
-- ============================================================
|
|
20
|
-
|
|
21
|
-
CREATE EXTENSION IF NOT EXISTS vector;
|
|
22
|
-
|
|
23
|
-
-- ============================================================
|
|
24
|
-
-- 2. TABLE
|
|
25
|
-
-- ============================================================
|
|
26
|
-
|
|
27
|
-
CREATE TABLE {{SCHEMA}}.kb_embeddings (
|
|
28
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
29
|
-
tenant_id uuid NOT NULL,
|
|
30
|
-
source text NOT NULL, -- document identifier or source URL
|
|
31
|
-
chunk_index int NOT NULL, -- position of this chunk within the source document
|
|
32
|
-
content text NOT NULL, -- chunk text returned to the agent as context
|
|
33
|
-
embedding vector(1536) NOT NULL, -- vector dimension must match embedding model
|
|
34
|
-
metadata jsonb NOT NULL DEFAULT '{}',
|
|
35
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
COMMENT ON TABLE {{SCHEMA}}.kb_embeddings IS 'RAG knowledge base — chunk text and pgvector embeddings for semantic search.';
|
|
39
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.tenant_id IS 'Tenant partition. Every query MUST filter on this column. Never query across tenants.';
|
|
40
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.source IS 'Document identifier or URL. Used for citation and re-indexing detection.';
|
|
41
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.chunk_index IS 'Zero-based position of this chunk within the source document.';
|
|
42
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.content IS 'Chunk text returned to the agent. Plain text, no markup.';
|
|
43
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.embedding IS 'Float vector. Dimension MUST match the embedding model declared in model-registry.json.';
|
|
44
|
-
COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.metadata IS 'Arbitrary JSON metadata (section headers, page numbers, doc type, etc.). Used for filtering.';
|
|
45
|
-
|
|
46
|
-
-- ============================================================
|
|
47
|
-
-- 3. INDEXES
|
|
48
|
-
-- ============================================================
|
|
49
|
-
|
|
50
|
-
-- HNSW index for cosine similarity — production-grade recall, no training data required.
|
|
51
|
-
-- vector_cosine_ops: use <=> operator (cosine distance, ascending = most similar first).
|
|
52
|
-
-- m=16, ef_construction=64 are pgvector defaults. Tune per infrastructure-neon-pgvector §HNSW Parameters.
|
|
53
|
-
CREATE INDEX ix_kb_embeddings_hnsw
|
|
54
|
-
ON {{SCHEMA}}.kb_embeddings
|
|
55
|
-
USING hnsw (embedding vector_cosine_ops)
|
|
56
|
-
WITH (m = 16, ef_construction = 64);
|
|
57
|
-
|
|
58
|
-
-- Index for the mandatory tenant_id filter (applied in every search query).
|
|
59
|
-
CREATE INDEX ix_kb_embeddings_tenant
|
|
60
|
-
ON {{SCHEMA}}.kb_embeddings (tenant_id);
|
|
61
|
-
|
|
62
|
-
-- Composite index for source-level operations (re-indexing, deletion by document).
|
|
63
|
-
CREATE INDEX ix_kb_embeddings_source
|
|
64
|
-
ON {{SCHEMA}}.kb_embeddings (tenant_id, source);
|
|
65
|
-
|
|
66
|
-
-- ============================================================
|
|
67
|
-
-- 4. ROW-LEVEL SECURITY (multi-tenant)
|
|
68
|
-
-- ============================================================
|
|
69
|
-
|
|
70
|
-
-- RLS enforces tenant isolation at the database level as a second line of defence.
|
|
71
|
-
-- The application already filters on tenant_id in every query; RLS is the backstop.
|
|
72
|
-
--
|
|
73
|
-
-- See templates/code/sql/postgresql-rls-policy.sql for the policy pattern that
|
|
74
|
-
-- binds app.current_tenant_id (a session-level setting) to the RLS policy.
|
|
75
|
-
--
|
|
76
|
-
-- Uncomment and adapt once RLS is wired in the project:
|
|
77
|
-
--
|
|
78
|
-
-- ALTER TABLE {{SCHEMA}}.kb_embeddings ENABLE ROW LEVEL SECURITY;
|
|
79
|
-
--
|
|
80
|
-
-- CREATE POLICY kb_embeddings_tenant_isolation
|
|
81
|
-
-- ON {{SCHEMA}}.kb_embeddings
|
|
82
|
-
-- USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
|
|
83
|
-
|
|
84
|
-
-- ============================================================
|
|
85
|
-
-- ROLLBACK
|
|
86
|
-
-- ============================================================
|
|
87
|
-
|
|
88
|
-
-- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_hnsw;
|
|
89
|
-
-- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_tenant;
|
|
90
|
-
-- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_source;
|
|
91
|
-
-- DROP TABLE IF EXISTS {{SCHEMA}}.kb_embeddings CASCADE;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
-- Migration: {{FEATURE_NAME_HUMAN}}
|
|
2
|
-
-- Created: {{DATE}}
|
|
3
|
-
-- Description: {{DESCRIPTION}}
|
|
4
|
-
|
|
5
|
-
-- Enable necessary extensions
|
|
6
|
-
create extension if not exists "uuid-ossp";
|
|
7
|
-
|
|
8
|
-
-- ========================================
|
|
9
|
-
-- Create Tables
|
|
10
|
-
-- ========================================
|
|
11
|
-
|
|
12
|
-
create table if not exists public.{{TABLE_NAME}} (
|
|
13
|
-
-- Primary key
|
|
14
|
-
id uuid primary key default gen_random_uuid(),
|
|
15
|
-
|
|
16
|
-
-- Columns
|
|
17
|
-
name text not null,
|
|
18
|
-
description text,
|
|
19
|
-
is_active boolean default true not null,
|
|
20
|
-
|
|
21
|
-
-- Foreign keys (example)
|
|
22
|
-
-- user_id text not null,
|
|
23
|
-
|
|
24
|
-
-- Timestamps
|
|
25
|
-
created_at timestamptz default now() not null,
|
|
26
|
-
updated_at timestamptz default now() not null
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
-- ========================================
|
|
30
|
-
-- Create Indexes
|
|
31
|
-
-- ========================================
|
|
32
|
-
|
|
33
|
-
-- Index on frequently queried columns
|
|
34
|
-
create index if not exists idx_{{TABLE_NAME}}_name
|
|
35
|
-
on public.{{TABLE_NAME}} (name);
|
|
36
|
-
|
|
37
|
-
-- Index on foreign keys (if any)
|
|
38
|
-
-- create index if not exists idx_{{TABLE_NAME}}_user_id
|
|
39
|
-
-- on public.{{TABLE_NAME}} (user_id);
|
|
40
|
-
|
|
41
|
-
-- Composite index for common queries
|
|
42
|
-
-- create index if not exists idx_{{TABLE_NAME}}_user_created
|
|
43
|
-
-- on public.{{TABLE_NAME}} (user_id, created_at desc);
|
|
44
|
-
|
|
45
|
-
-- ========================================
|
|
46
|
-
-- Create Triggers
|
|
47
|
-
-- ========================================
|
|
48
|
-
|
|
49
|
-
-- Auto-update timestamp trigger
|
|
50
|
-
create or replace function public.handle_updated_at()
|
|
51
|
-
returns trigger as $$
|
|
52
|
-
begin
|
|
53
|
-
new.updated_at = now();
|
|
54
|
-
return new;
|
|
55
|
-
end;
|
|
56
|
-
$$ language plpgsql;
|
|
57
|
-
|
|
58
|
-
create trigger {{TABLE_NAME}}_updated_at
|
|
59
|
-
before update on public.{{TABLE_NAME}}
|
|
60
|
-
for each row execute function public.handle_updated_at();
|
|
61
|
-
|
|
62
|
-
-- ========================================
|
|
63
|
-
-- Enable Row Level Security (RLS)
|
|
64
|
-
-- ========================================
|
|
65
|
-
|
|
66
|
-
alter table public.{{TABLE_NAME}} enable row level security;
|
|
67
|
-
|
|
68
|
-
-- Policy: Users can view all records (example)
|
|
69
|
-
create policy "{{TABLE_NAME}}_select_policy"
|
|
70
|
-
on public.{{TABLE_NAME}} for select
|
|
71
|
-
using (true);
|
|
72
|
-
|
|
73
|
-
-- Policy: Users can only insert their own records (Neon Auth + pg_session_jwt)
|
|
74
|
-
-- create policy "{{TABLE_NAME}}_insert_policy"
|
|
75
|
-
-- on public.{{TABLE_NAME}} for insert to authenticated
|
|
76
|
-
-- with check (auth.user_id() = user_id);
|
|
77
|
-
|
|
78
|
-
-- Policy: Users can only update their own records (Neon Auth + pg_session_jwt)
|
|
79
|
-
-- create policy "{{TABLE_NAME}}_update_policy"
|
|
80
|
-
-- on public.{{TABLE_NAME}} for update to authenticated
|
|
81
|
-
-- using (auth.user_id() = user_id)
|
|
82
|
-
-- with check (auth.user_id() = user_id);
|
|
83
|
-
|
|
84
|
-
-- Policy: Users can only delete their own records (Neon Auth + pg_session_jwt)
|
|
85
|
-
-- create policy "{{TABLE_NAME}}_delete_policy"
|
|
86
|
-
-- on public.{{TABLE_NAME}} for delete to authenticated
|
|
87
|
-
-- using (auth.user_id() = user_id);
|
|
88
|
-
|
|
89
|
-
-- Policy: Admins have full access (Neon Auth + pg_session_jwt)
|
|
90
|
-
-- create policy "{{TABLE_NAME}}_admin_policy"
|
|
91
|
-
-- on public.{{TABLE_NAME}} for all
|
|
92
|
-
-- using (auth.jwt()->>'role' = 'admin');
|
|
93
|
-
|
|
94
|
-
-- ========================================
|
|
95
|
-
-- Seed Data (Optional)
|
|
96
|
-
-- ========================================
|
|
97
|
-
|
|
98
|
-
-- insert into public.{{TABLE_NAME}} (name, description) values
|
|
99
|
-
-- ('Example 1', 'First example record'),
|
|
100
|
-
-- ('Example 2', 'Second example record');
|
|
101
|
-
|
|
102
|
-
-- ========================================
|
|
103
|
-
-- Rollback Instructions
|
|
104
|
-
-- ========================================
|
|
105
|
-
|
|
106
|
-
-- Uncomment to rollback this migration:
|
|
107
|
-
-- drop table if exists public.{{TABLE_NAME}} cascade;
|
|
108
|
-
-- drop function if exists public.handle_updated_at() cascade;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// {{titleCase FEATURE_NAME}} contracts, generated {{DATE}}
|
|
2
|
-
|
|
3
|
-
export interface NeonConfig {
|
|
4
|
-
connectionString: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ApiClientConfig {
|
|
8
|
-
baseUrl: string;
|
|
9
|
-
getAccessToken: () => Promise<string | null>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ApiError {
|
|
13
|
-
message: string;
|
|
14
|
-
code: string;
|
|
15
|
-
statusCode: number;
|
|
16
|
-
details?: Record<string, string[]>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type ApiResult<T> =
|
|
20
|
-
| { success: true; data: T }
|
|
21
|
-
| { success: false; error: ApiError };
|
|
22
|
-
|
|
23
|
-
export interface PaginationQuery {
|
|
24
|
-
page?: number;
|
|
25
|
-
pageSize?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface PagedResult<T> {
|
|
29
|
-
items: T[];
|
|
30
|
-
totalCount: number;
|
|
31
|
-
page: number;
|
|
32
|
-
pageSize: number;
|
|
33
|
-
totalPages: number;
|
|
34
|
-
hasNext: boolean;
|
|
35
|
-
hasPrevious: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type Tables<T extends keyof Database["public"]["Tables"]> =
|
|
39
|
-
Database["public"]["Tables"][T]["Row"];
|
|
40
|
-
|
|
41
|
-
export type Insertable<T extends keyof Database["public"]["Tables"]> =
|
|
42
|
-
Database["public"]["Tables"][T]["Insert"];
|
|
43
|
-
|
|
44
|
-
export type Updatable<T extends keyof Database["public"]["Tables"]> =
|
|
45
|
-
Database["public"]["Tables"][T]["Update"];
|
|
46
|
-
|
|
47
|
-
// Placeholder: replace with the types your ORM (Drizzle or Prisma) generates from the Neon schema.
|
|
48
|
-
export interface Database {
|
|
49
|
-
public: {
|
|
50
|
-
Tables: {
|
|
51
|
-
{{FEATURE_NAME}}: {
|
|
52
|
-
Row: {
|
|
53
|
-
id: string;
|
|
54
|
-
name: string;
|
|
55
|
-
user_id: string;
|
|
56
|
-
status: {{pascalCase FEATURE_NAME}}Status;
|
|
57
|
-
created_at: string;
|
|
58
|
-
updated_at: string | null;
|
|
59
|
-
};
|
|
60
|
-
Insert: {
|
|
61
|
-
id?: string;
|
|
62
|
-
name: string;
|
|
63
|
-
user_id?: string;
|
|
64
|
-
status?: {{pascalCase FEATURE_NAME}}Status;
|
|
65
|
-
created_at?: string;
|
|
66
|
-
updated_at?: string | null;
|
|
67
|
-
};
|
|
68
|
-
Update: {
|
|
69
|
-
id?: string;
|
|
70
|
-
name?: string;
|
|
71
|
-
user_id?: string;
|
|
72
|
-
status?: {{pascalCase FEATURE_NAME}}Status;
|
|
73
|
-
created_at?: string;
|
|
74
|
-
updated_at?: string | null;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
Views: Record<string, never>;
|
|
79
|
-
Functions: Record<string, never>;
|
|
80
|
-
Enums: {
|
|
81
|
-
{{FEATURE_NAME}}_status: {{pascalCase FEATURE_NAME}}Status;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export type {{pascalCase FEATURE_NAME}}Status =
|
|
87
|
-
| "draft"
|
|
88
|
-
| "active"
|
|
89
|
-
| "completed"
|
|
90
|
-
| "archived"
|
|
91
|
-
| "failed"
|
|
92
|
-
| "cancelled";
|
|
93
|
-
|
|
94
|
-
export interface {{pascalCase FEATURE_NAME}} {
|
|
95
|
-
id: string;
|
|
96
|
-
name: string;
|
|
97
|
-
userId: string;
|
|
98
|
-
status: {{pascalCase FEATURE_NAME}}Status;
|
|
99
|
-
createdAt: string;
|
|
100
|
-
updatedAt: string | null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface Create{{pascalCase FEATURE_NAME}}Input {
|
|
104
|
-
name: string;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface Update{{pascalCase FEATURE_NAME}}Input {
|
|
108
|
-
name?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface StorageUpload {
|
|
112
|
-
bucket: string;
|
|
113
|
-
path: string;
|
|
114
|
-
file: File;
|
|
115
|
-
contentType?: string;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface StorageFile {
|
|
119
|
-
id: string;
|
|
120
|
-
name: string;
|
|
121
|
-
bucket: string;
|
|
122
|
-
path: string;
|
|
123
|
-
publicUrl: string;
|
|
124
|
-
size: number;
|
|
125
|
-
contentType: string;
|
|
126
|
-
createdAt: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface AuthUser {
|
|
130
|
-
id: string;
|
|
131
|
-
email: string;
|
|
132
|
-
displayName: string | null;
|
|
133
|
-
avatarUrl: string | null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface AuthSession {
|
|
137
|
-
user: AuthUser;
|
|
138
|
-
accessToken: string;
|
|
139
|
-
expiresAt: number;
|
|
140
|
-
}
|