소스 정보
- 저장소
- dilgerma/nebulit-code-generators
- 최근 소스 활동
- 2026년 2월 18일 10:49
- 감지된 SKILL.md 언어
- 영어
- 스타
- 22
- 포크
- 9
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/dilgerma/nebulit-code-generators --skill state-view-slice명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | state-view-slice |
| description | builds a state-view slice from an event model |
State View Slices are read model projections that build table-based views from events. They consume events and project them into queryable database tables using PostgreSQL.
If the processors-array in the slice json is not empty. Treat this as an AUTOMATION Slice. Load the skill for automation slice.
restaurant_id column (snake_case)restaurantId in their metadata (camelCase)locationId or location_id - these are outdated and forbiddenWhen creating a state-view slice, you MUST create the following files:
Every projection file follows this pattern:
import {postgreSQLRawSQLProjection} from '@event-driven-io/emmett-postgresql';
import {sql} from '@event-driven-io/dumbo';
import knex, {Knex} from 'knex';
import {EventType} from '../../events/EventType';
Define TypeScript types for the read model:
export type {Name}ReadModelItem = {
field1?: type,
field2?: type,
// fields from projection
}
export type {Name}ReadModel = {
data: {Name}ReadModelItem[],
}
export const tableName = 'table_name';
export const getKnexInstance = (connectionString: string): Knex => {
return knex({
client: 'pg',
connection: connectionString,
});
};
export const {Name}Projection = postgreSQLRawSQLProjection<EventType>({
canHandle: ["Event1", "Event2"], // events this projection handles
evolve: (event, context) => {
const {type, data} = event;
const db = getKnexInstance(context.connection.connectionString);
switch (type) {
case "Event1":
return sql(db(tableName)
.withSchema('public')
.insert({
field1: data.field1,
field2: data.field2,
})
.onConflict('id_field') // upsert on conflict
.merge({field1: data.field1, field2: data.field2})
.toQuery());
case "Event2":
return sql(db(tableName)
.withSchema()
.(, data.)
.({
: data.,
})
.());
:
[];
}
}
});
export const findEventstore = async () => {
return getPostgreSQLEventStore(postgresUrl, {
schema: {
autoMigration: "CreateOrUpdate"
},
projections: projections.inline([
<register projection here>
]),
});
}
Use this pattern for events that create or update records:
return sql(db(tableName)
.withSchema('public')
.insert({ /* fields */ })
.onConflict('id_field')
.merge({ /* fields to update */ })
.toQuery());
Use this for events that only update existing records:
return sql(db(tableName)
.withSchema('public')
.where('id_field', data.id)
.update({ /* fields */ })
.toQuery());
Use this for events that remove records:
return sql(db(tableName)
.withSchema('public')
.where('id_field', data.id)
.delete()
.toQuery());
Every projection MUST have tests using PostgreSQLProjectionSpec with Testcontainers:
import {before, after, describe, it} from "node:test";
import {PostgreSQLProjectionAssert, PostgreSQLProjectionSpec} from "@event-driven-io/emmett-postgresql";
import {{Name}Projection} from "./{Name}Projection";
import {PostgreSqlContainer, StartedPostgreSqlContainer} from "@testcontainers/postgresql";
import {EventType} from "../../events/EventType"
import knex, {Knex} from 'knex';
import assert from 'assert';
import {runFlywayMigrations} from "../../common/testHelpers";
describe('{Name} Specification', () => {
let postgres: StartedPostgreSqlContainer;
let connectionString: string;
let db: Knex;
let given: PostgreSQLProjectionSpec<EventType>
before(async () => {
postgres = ().();
connectionString = postgres.();
db = ({
: ,
: connectionString,
});
(connectionString);
given = .({
: {},
connectionString,
});
});
( () => {
db?.();
postgres?.();
});
(, () => {
: = ({: connStr}) => {
queryDb = ({
: ,
: connStr,
});
{
result = ()
.()
.();
assert.(result., );
} {
queryDb.();
}
};
([{
: ,
: { },
: {: }
}])
.([])
.(assertReadModel);
});
});
Every read model exposes a GET endpoint to fetch data:
import {Request, Response, Router} from 'express';
import {{Name}ReadModel, tableName} from "./{Name}Projection";
import {WebApiSetup} from "@event-driven-io/emmett-expressjs";
import createClient from "../../supabase/api";
import {readmodel} from "../../core/readmodel";
import {requireUser} from "../../supabase/requireUser";
export const api =
(
// external dependencies
): WebApiSetup =>
(router: Router): void => {
router.get('/api/query/{name}-collection', async (req: Request, res: Response) => {
try {
const principal = await requireUser(req, res, true);
if (principal.error) {
return;
}
const userId = principal..;
id = req..?.();
supabase = ()
: = {};
query.;
: {} | {}[] | =
id ? (tableName, supabase).<{}>(, id) :
(tableName, supabase).<{}>(query)
sanitized = .(
.(data || [],
value === ? value.() : value
)
);
res.().(sanitized);
} (err) {
.(err);
res.().({: , : });
}
});
};
Make sure to annotate it with OpenAPI annotations in the comments, so it´s picked up by the open-api ui.
Each read model requires a migration file in supabase/migrations/:
Naming Convention: V{N}__{tablename}.sql
V{N} - Version number (sequential: V1, V2, V3, etc.){tablename} - Lowercase table name matching the projection's tableNameExample: V8__locations.sql
-- Create {tablename} table
CREATE TABLE IF NOT EXISTS "public"."{tablename}"
(
id_field TEXT PRIMARY KEY,
field1 TEXT,
field2 INTEGER,
field3 TEXT,
restaurant_id uuid NOT NULL
);
IF NOT EXISTS for idempotencyonConflict()restaurant_id uuid NOT NULL column (required for multi-tenancy)supabase/migrations/ directorysrc/slices/{SliceName}/
├── {SliceName}Projection.ts # Projection logic
├── {SliceName}.test.ts # Tests
└── routes.ts # Query endpoint
supabase/migrations/
└── V{N}__{tablename}.sql # Database schema
in each slice folder, generate a file .slice.json
{
"id" : "<slice id>",
"slice": "<slice title>",
"context": "<contextx>",
"link": "https://miro.com/app/board/<board-id>=/?moveToWidget=<slice id>"
}
templates/Locations/ for simple single-event projection exampletemplates/Tables/ for multi-event projection with updatestemplates/V8__locations.sql for migration exampletemplates/V2__tables.sql for migration exampleto build the UI prompt, list the following facts:
to build the UI - use this table "<schema>.<table_name>"
Payload example:
<payload example as JSON>
this is the table definition:
<table definition as SQL DDL>