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.

analytics.query.create

Create a data query.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.analytics-dashboard
  • Tags: analytics, query, create
  • File: packages/examples/analytics-dashboard/src/query/query.operation.ts
  • field.key.label
    analytics.query.create
    field.version.label
    1.0.0
    field.type.label
    operation (command)
    field.title.label
    analytics.query.create
    field.description.label

    Create a data query.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.analytics-dashboard
  • Tags: analytics, query, create
  • File: packages/examples/analytics-dashboard/src/query/query.operation.ts
  • field.tags.label
    analytics,query,create
    field.owners.label
    @example.analytics-dashboard
    field.stability.label
    stable

    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' },
    			},
    		],
    	},
    });