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.

usage.record

Record a usage event.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: platform.metering
  • Tags: metering, usage, record
  • File: packages/libs/metering/src/contracts/index.ts
  • field.key.label
    usage.record
    field.version.label
    1.0.0
    field.type.label
    operation (command)
    field.title.label
    usage.record
    field.description.label

    Record a usage event.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: platform.metering
  • Tags: metering, usage, record
  • File: packages/libs/metering/src/contracts/index.ts
  • field.tags.label
    metering,usage,record
    field.owners.label
    platform.metering
    field.stability.label
    stable

    Record a usage event.

    Goal

    Track usage for billing and monitoring.

    Context

    Called when usage occurs.

    Source Definition

    import { defineCommand, defineQuery } from '@lssm-tech/lib.contracts-spec';
    import { defineSchemaModel, ScalarTypeEnum } from '@lssm-tech/lib.schema';
    
    export const RecordUsageContract = defineCommand({
    	meta: {
    		key: 'usage.record',
    		version: '1.0.0',
    		stability: 'stable',
    		owners: ['platform.metering'],
    		tags: ['metering', 'usage', 'record'],
    		description: 'Record a usage event.',
    		goal: 'Track usage for billing and monitoring.',
    		context: 'Called when usage occurs.',
    	},
    	io: {
    		input: RecordUsageInput,
    		output: UsageRecordModel,
    		errors: {
    			METRIC_NOT_FOUND: {
    				description: 'Metric does not exist',
    				http: 404,
    				gqlCode: 'METRIC_NOT_FOUND',
    				when: 'Metric key is invalid',
    			},
    			DUPLICATE_RECORD: {
    				description: 'Record already exists',
    				http: 409,
    				gqlCode: 'DUPLICATE_RECORD',
    				when: 'Idempotency key already used',
    			},
    		},
    	},
    	policy: {
    		auth: 'admin',
    	},
    });