OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Create a data query.
Goal
Define reusable data queries.
Context
Query builder.
Source Definition
import {
defineCommand,
defineQuery,
} from '@lssm-tech/lib.contracts-spec/operations';
import {
CreateQueryInputModel,
ExecuteQueryInputModel,
QueryModel,
QueryResultModel,
} from './query.schema';
export const CreateQueryContract = defineCommand({
meta: {
key: 'analytics.query.create',
version: '1.0.0',
stability: 'stable',
owners: ['@example.analytics-dashboard'],
tags: ['analytics', 'query', 'create'],
description: 'Create a data query.',
goal: 'Define reusable data queries.',
context: 'Query builder.',
},
io: { input: CreateQueryInputModel, output: QueryModel },
policy: { auth: 'user' },
sideEffects: {
emits: [
{
key: 'analytics.query.created',
version: '1.0.0',
stability: 'stable',
owners: ['@example.analytics-dashboard'],
tags: ['analytics', 'query', 'created'],
when: 'Query created',
payload: QueryModel,
},
],
audit: ['analytics.query.created'],
},
acceptance: {
scenarios: [
{
key: 'create-query-happy-path',
given: ['User is authenticated'],
when: ['User submits valid query definition'],
then: ['Query is created', 'QueryCreated event is emitted'],
},
],
examples: [
{
key: 'create-sql-query',
input: {
name: 'Monthly Revenue',
sql: 'SELECT SUM(amount) FROM orders WHERE date >= :startDate',
},
output: { id: 'query-123', name: 'Monthly Revenue', type: 'sql' },
},
],
},
});