@contractspec/lib.metering 1.44.0 → 1.45.0

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.
@@ -664,7 +664,7 @@ const SuccessOutput = defineSchemaModel({
664
664
  const DefineMetricContract = defineCommand({
665
665
  meta: {
666
666
  key: "metric.define",
667
- version: 1,
667
+ version: "1.0.0",
668
668
  stability: "stable",
669
669
  owners: [...OWNERS],
670
670
  tags: [
@@ -694,7 +694,7 @@ const DefineMetricContract = defineCommand({
694
694
  const UpdateMetricContract = defineCommand({
695
695
  meta: {
696
696
  key: "metric.update",
697
- version: 1,
697
+ version: "1.0.0",
698
698
  stability: "stable",
699
699
  owners: [...OWNERS],
700
700
  tags: [
@@ -724,7 +724,7 @@ const UpdateMetricContract = defineCommand({
724
724
  const DeleteMetricContract = defineCommand({
725
725
  meta: {
726
726
  key: "metric.delete",
727
- version: 1,
727
+ version: "1.0.0",
728
728
  stability: "stable",
729
729
  owners: [...OWNERS],
730
730
  tags: [
@@ -754,7 +754,7 @@ const DeleteMetricContract = defineCommand({
754
754
  const GetMetricContract = defineQuery({
755
755
  meta: {
756
756
  key: "metric.get",
757
- version: 1,
757
+ version: "1.0.0",
758
758
  stability: "stable",
759
759
  owners: [...OWNERS],
760
760
  tags: [
@@ -784,7 +784,7 @@ const GetMetricContract = defineQuery({
784
784
  const ListMetricsContract = defineQuery({
785
785
  meta: {
786
786
  key: "metric.list",
787
- version: 1,
787
+ version: "1.0.0",
788
788
  stability: "stable",
789
789
  owners: [...OWNERS],
790
790
  tags: [
@@ -808,7 +808,7 @@ const ListMetricsContract = defineQuery({
808
808
  const RecordUsageContract = defineCommand({
809
809
  meta: {
810
810
  key: "usage.record",
811
- version: 1,
811
+ version: "1.0.0",
812
812
  stability: "stable",
813
813
  owners: [...OWNERS],
814
814
  tags: [
@@ -846,7 +846,7 @@ const RecordUsageContract = defineCommand({
846
846
  const RecordBatchUsageContract = defineCommand({
847
847
  meta: {
848
848
  key: "usage.recordBatch",
849
- version: 1,
849
+ version: "1.0.0",
850
850
  stability: "stable",
851
851
  owners: [...OWNERS],
852
852
  tags: [
@@ -870,7 +870,7 @@ const RecordBatchUsageContract = defineCommand({
870
870
  const GetUsageContract = defineQuery({
871
871
  meta: {
872
872
  key: "usage.get",
873
- version: 1,
873
+ version: "1.0.0",
874
874
  stability: "stable",
875
875
  owners: [...OWNERS],
876
876
  tags: [
@@ -894,7 +894,7 @@ const GetUsageContract = defineQuery({
894
894
  const GetUsageSummaryContract = defineQuery({
895
895
  meta: {
896
896
  key: "usage.getSummary",
897
- version: 1,
897
+ version: "1.0.0",
898
898
  stability: "stable",
899
899
  owners: [...OWNERS],
900
900
  tags: [
@@ -918,7 +918,7 @@ const GetUsageSummaryContract = defineQuery({
918
918
  const CreateThresholdContract = defineCommand({
919
919
  meta: {
920
920
  key: "threshold.create",
921
- version: 1,
921
+ version: "1.0.0",
922
922
  stability: "stable",
923
923
  owners: [...OWNERS],
924
924
  tags: [
@@ -948,7 +948,7 @@ const CreateThresholdContract = defineCommand({
948
948
  const UpdateThresholdContract = defineCommand({
949
949
  meta: {
950
950
  key: "threshold.update",
951
- version: 1,
951
+ version: "1.0.0",
952
952
  stability: "stable",
953
953
  owners: [...OWNERS],
954
954
  tags: [
@@ -978,7 +978,7 @@ const UpdateThresholdContract = defineCommand({
978
978
  const DeleteThresholdContract = defineCommand({
979
979
  meta: {
980
980
  key: "threshold.delete",
981
- version: 1,
981
+ version: "1.0.0",
982
982
  stability: "stable",
983
983
  owners: [...OWNERS],
984
984
  tags: [
@@ -1008,7 +1008,7 @@ const DeleteThresholdContract = defineCommand({
1008
1008
  const ListThresholdsContract = defineQuery({
1009
1009
  meta: {
1010
1010
  key: "threshold.list",
1011
- version: 1,
1011
+ version: "1.0.0",
1012
1012
  stability: "stable",
1013
1013
  owners: [...OWNERS],
1014
1014
  tags: [
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/contracts/index.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineCommand, defineQuery } from '@contractspec/lib.contracts';\n\nconst OWNERS = ['platform.metering'] as const;\n\n// ============ Schema Models ============\n\nexport const MetricDefinitionModel = defineSchemaModel({\n name: 'MetricDefinition',\n description: 'Represents a metric definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n resetPeriod: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const UsageRecordModel = defineSchemaModel({\n name: 'UsageRecord',\n description: 'Represents a usage record',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const UsageSummaryModel = defineSchemaModel({\n name: 'UsageSummary',\n description: 'Represents aggregated usage',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n minQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n maxQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n avgQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n },\n});\n\nexport const UsageThresholdModel = defineSchemaModel({\n name: 'UsageThreshold',\n description: 'Represents a usage threshold',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n// ============ Input/Output Models ============\n\nconst DefineMetricInput = defineSchemaModel({\n name: 'DefineMetricInput',\n description: 'Input for defining a metric',\n fields: {\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n resetPeriod: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\nconst UpdateMetricInput = defineSchemaModel({\n name: 'UpdateMetricInput',\n description: 'Input for updating a metric',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\nconst DeleteMetricInput = defineSchemaModel({\n name: 'DeleteMetricInput',\n description: 'Input for deleting a metric',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst GetMetricInput = defineSchemaModel({\n name: 'GetMetricInput',\n description: 'Input for getting a metric',\n fields: {\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst ListMetricsInput = defineSchemaModel({\n name: 'ListMetricsInput',\n description: 'Input for listing metrics',\n fields: {\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n\nconst ListMetricsOutput = defineSchemaModel({\n name: 'ListMetricsOutput',\n description: 'Output for listing metrics',\n fields: {\n metrics: { type: MetricDefinitionModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst RecordUsageInput = defineSchemaModel({\n name: 'RecordUsageInput',\n description: 'Input for recording usage',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n idempotencyKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n },\n});\n\nconst RecordBatchUsageInput = defineSchemaModel({\n name: 'RecordBatchUsageInput',\n description: 'Input for recording batch usage',\n fields: {\n records: { type: RecordUsageInput, isArray: true, isOptional: false },\n },\n});\n\nconst RecordBatchUsageOutput = defineSchemaModel({\n name: 'RecordBatchUsageOutput',\n description: 'Output for recording batch usage',\n fields: {\n recordedCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n skippedCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n recordIds: { type: ScalarTypeEnum.JSON(), isOptional: false },\n },\n});\n\nconst GetUsageInput = defineSchemaModel({\n name: 'GetUsageInput',\n description: 'Input for getting usage',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n endDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n\nconst GetUsageOutput = defineSchemaModel({\n name: 'GetUsageOutput',\n description: 'Output for getting usage',\n fields: {\n records: { type: UsageRecordModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n },\n});\n\nconst GetUsageSummaryInput = defineSchemaModel({\n name: 'GetUsageSummaryInput',\n description: 'Input for getting usage summary',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n endDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n },\n});\n\nconst GetUsageSummaryOutput = defineSchemaModel({\n name: 'GetUsageSummaryOutput',\n description: 'Output for getting usage summary',\n fields: {\n summaries: { type: UsageSummaryModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst CreateThresholdInput = defineSchemaModel({\n name: 'CreateThresholdInput',\n description: 'Input for creating a threshold',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n notifyEmails: { type: ScalarTypeEnum.JSON(), isOptional: true },\n notifyWebhook: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst UpdateThresholdInput = defineSchemaModel({\n name: 'UpdateThresholdInput',\n description: 'Input for updating a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n notifyEmails: { type: ScalarTypeEnum.JSON(), isOptional: true },\n notifyWebhook: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n },\n});\n\nconst DeleteThresholdInput = defineSchemaModel({\n name: 'DeleteThresholdInput',\n description: 'Input for deleting a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst ListThresholdsInput = defineSchemaModel({\n name: 'ListThresholdsInput',\n description: 'Input for listing thresholds',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n },\n});\n\nconst ListThresholdsOutput = defineSchemaModel({\n name: 'ListThresholdsOutput',\n description: 'Output for listing thresholds',\n fields: {\n thresholds: { type: UsageThresholdModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst SuccessOutput = defineSchemaModel({\n name: 'SuccessOutput',\n description: 'Generic success output',\n fields: {\n success: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n },\n});\n\n// ============ Contracts ============\n\n/**\n * Define a metric.\n */\nexport const DefineMetricContract = defineCommand({\n meta: {\n key: 'metric.define',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'define'],\n description: 'Define a new usage metric.',\n goal: 'Create a new metric for tracking usage.',\n context: 'Called when setting up metering.',\n },\n io: {\n input: DefineMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_KEY_EXISTS: {\n description: 'Metric key already exists',\n http: 409,\n gqlCode: 'METRIC_KEY_EXISTS',\n when: 'A metric with this key already exists',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Update a metric.\n */\nexport const UpdateMetricContract = defineCommand({\n meta: {\n key: 'metric.update',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'update'],\n description: 'Update a metric definition.',\n goal: 'Modify metric configuration.',\n context: 'Called when updating metric settings.',\n },\n io: {\n input: UpdateMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Delete a metric.\n */\nexport const DeleteMetricContract = defineCommand({\n meta: {\n key: 'metric.delete',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'delete'],\n description: 'Delete a metric definition.',\n goal: 'Remove a metric and its data.',\n context: 'Called when removing a metric.',\n },\n io: {\n input: DeleteMetricInput,\n output: SuccessOutput,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get a metric by key.\n */\nexport const GetMetricContract = defineQuery({\n meta: {\n key: 'metric.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'get'],\n description: 'Get a metric by key.',\n goal: 'Retrieve metric definition.',\n context: 'Called to inspect metric details.',\n },\n io: {\n input: GetMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n },\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * List metrics.\n */\nexport const ListMetricsContract = defineQuery({\n meta: {\n key: 'metric.list',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'list'],\n description: 'List all metrics.',\n goal: 'View configured metrics.',\n context: 'Called to browse metrics.',\n },\n io: {\n input: ListMetricsInput,\n output: ListMetricsOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Record usage.\n */\nexport const RecordUsageContract = defineCommand({\n meta: {\n key: 'usage.record',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'record'],\n description: 'Record a usage event.',\n goal: 'Track usage for billing and monitoring.',\n context: 'Called when usage occurs.',\n },\n io: {\n input: RecordUsageInput,\n output: UsageRecordModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n DUPLICATE_RECORD: {\n description: 'Record already exists',\n http: 409,\n gqlCode: 'DUPLICATE_RECORD',\n when: 'Idempotency key already used',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Record batch usage.\n */\nexport const RecordBatchUsageContract = defineCommand({\n meta: {\n key: 'usage.recordBatch',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'batch'],\n description: 'Record multiple usage events.',\n goal: 'Efficiently track bulk usage.',\n context: 'Called for batch processing.',\n },\n io: {\n input: RecordBatchUsageInput,\n output: RecordBatchUsageOutput,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get usage records.\n */\nexport const GetUsageContract = defineQuery({\n meta: {\n key: 'usage.get',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'get'],\n description: 'Get usage records for a subject.',\n goal: 'View detailed usage history.',\n context: 'Called to analyze usage.',\n },\n io: {\n input: GetUsageInput,\n output: GetUsageOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Get usage summary.\n */\nexport const GetUsageSummaryContract = defineQuery({\n meta: {\n key: 'usage.getSummary',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'summary'],\n description: 'Get aggregated usage summary.',\n goal: 'View usage totals for billing.',\n context: 'Called for billing and reporting.',\n },\n io: {\n input: GetUsageSummaryInput,\n output: GetUsageSummaryOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Create a threshold.\n */\nexport const CreateThresholdContract = defineCommand({\n meta: {\n key: 'threshold.create',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'create'],\n description: 'Create a usage threshold.',\n goal: 'Set up usage limits and alerts.',\n context: 'Called when configuring limits.',\n },\n io: {\n input: CreateThresholdInput,\n output: UsageThresholdModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Update a threshold.\n */\nexport const UpdateThresholdContract = defineCommand({\n meta: {\n key: 'threshold.update',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'update'],\n description: 'Update a threshold.',\n goal: 'Modify threshold configuration.',\n context: 'Called when adjusting limits.',\n },\n io: {\n input: UpdateThresholdInput,\n output: UsageThresholdModel,\n errors: {\n THRESHOLD_NOT_FOUND: {\n description: 'Threshold does not exist',\n http: 404,\n gqlCode: 'THRESHOLD_NOT_FOUND',\n when: 'Threshold ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Delete a threshold.\n */\nexport const DeleteThresholdContract = defineCommand({\n meta: {\n key: 'threshold.delete',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'delete'],\n description: 'Delete a threshold.',\n goal: 'Remove a usage threshold.',\n context: 'Called when removing limits.',\n },\n io: {\n input: DeleteThresholdInput,\n output: SuccessOutput,\n errors: {\n THRESHOLD_NOT_FOUND: {\n description: 'Threshold does not exist',\n http: 404,\n gqlCode: 'THRESHOLD_NOT_FOUND',\n when: 'Threshold ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * List thresholds.\n */\nexport const ListThresholdsContract = defineQuery({\n meta: {\n key: 'threshold.list',\n version: 1,\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'list'],\n description: 'List usage thresholds.',\n goal: 'View configured limits.',\n context: 'Called to browse thresholds.',\n },\n io: {\n input: ListThresholdsInput,\n output: ListThresholdsOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n"],"mappings":";;;;AAGA,MAAM,SAAS,CAAC,oBAAoB;AAIpC,MAAa,wBAAwB,kBAAkB;CACrD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,aAAa;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACzE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAA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EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAY;GAAa;GAAS;EACzC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACR,QAAQ,EACN,qBAAqB;GACnB,aAAa;GACb,MAAM;GACN,SAAS;GACT,MAAM;GACP,EACF;EACF;CACD,QAAQ,EACN,MAAM,SACP;CACF,CAAC;;;;AAKF,MAAa,yBAAyB,YAAY;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,WAAW;EACX,QAAQ,CAAC,GAAG,OAAO;EACnB,MAAM;GAAC;GAAY;GAAa;GAAO;EACvC,aAAa;EACb,MAAM;EACN,SAAS;EACV;CACD,IAAI;EACF,OAAO;EACP,QAAQ;EACT;CACD,QAAQ,EACN,MAAM,QACP;CACF,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/contracts/index.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineCommand, defineQuery } from '@contractspec/lib.contracts';\n\nconst OWNERS = ['platform.metering'] as const;\n\n// ============ Schema Models ============\n\nexport const MetricDefinitionModel = defineSchemaModel({\n name: 'MetricDefinition',\n description: 'Represents a metric definition',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n resetPeriod: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const UsageRecordModel = defineSchemaModel({\n name: 'UsageRecord',\n description: 'Represents a usage record',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nexport const UsageSummaryModel = defineSchemaModel({\n name: 'UsageSummary',\n description: 'Represents aggregated usage',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n minQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n maxQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n avgQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n },\n});\n\nexport const UsageThresholdModel = defineSchemaModel({\n name: 'UsageThreshold',\n description: 'Represents a usage threshold',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n// ============ Input/Output Models ============\n\nconst DefineMetricInput = defineSchemaModel({\n name: 'DefineMetricInput',\n description: 'Input for defining a metric',\n fields: {\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n resetPeriod: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\nconst UpdateMetricInput = defineSchemaModel({\n name: 'UpdateMetricInput',\n description: 'Input for updating a metric',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n },\n});\n\nconst DeleteMetricInput = defineSchemaModel({\n name: 'DeleteMetricInput',\n description: 'Input for deleting a metric',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst GetMetricInput = defineSchemaModel({\n name: 'GetMetricInput',\n description: 'Input for getting a metric',\n fields: {\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst ListMetricsInput = defineSchemaModel({\n name: 'ListMetricsInput',\n description: 'Input for listing metrics',\n fields: {\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n category: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n\nconst ListMetricsOutput = defineSchemaModel({\n name: 'ListMetricsOutput',\n description: 'Output for listing metrics',\n fields: {\n metrics: { type: MetricDefinitionModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst RecordUsageInput = defineSchemaModel({\n name: 'RecordUsageInput',\n description: 'Input for recording usage',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n resourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n metadata: { type: ScalarTypeEnum.JSON(), isOptional: true },\n idempotencyKey: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: true,\n },\n },\n});\n\nconst RecordBatchUsageInput = defineSchemaModel({\n name: 'RecordBatchUsageInput',\n description: 'Input for recording batch usage',\n fields: {\n records: { type: RecordUsageInput, isArray: true, isOptional: false },\n },\n});\n\nconst RecordBatchUsageOutput = defineSchemaModel({\n name: 'RecordBatchUsageOutput',\n description: 'Output for recording batch usage',\n fields: {\n recordedCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n skippedCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n recordIds: { type: ScalarTypeEnum.JSON(), isOptional: false },\n },\n});\n\nconst GetUsageInput = defineSchemaModel({\n name: 'GetUsageInput',\n description: 'Input for getting usage',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n endDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },\n },\n});\n\nconst GetUsageOutput = defineSchemaModel({\n name: 'GetUsageOutput',\n description: 'Output for getting usage',\n fields: {\n records: { type: UsageRecordModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n },\n});\n\nconst GetUsageSummaryInput = defineSchemaModel({\n name: 'GetUsageSummaryInput',\n description: 'Input for getting usage summary',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n startDate: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n endDate: { type: ScalarTypeEnum.DateTime(), isOptional: true },\n },\n});\n\nconst GetUsageSummaryOutput = defineSchemaModel({\n name: 'GetUsageSummaryOutput',\n description: 'Output for getting usage summary',\n fields: {\n summaries: { type: UsageSummaryModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst CreateThresholdInput = defineSchemaModel({\n name: 'CreateThresholdInput',\n description: 'Input for creating a threshold',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n notifyEmails: { type: ScalarTypeEnum.JSON(), isOptional: true },\n notifyWebhook: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n },\n});\n\nconst UpdateThresholdInput = defineSchemaModel({\n name: 'UpdateThresholdInput',\n description: 'Input for updating a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n warnThreshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n notifyEmails: { type: ScalarTypeEnum.JSON(), isOptional: true },\n notifyWebhook: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n },\n});\n\nconst DeleteThresholdInput = defineSchemaModel({\n name: 'DeleteThresholdInput',\n description: 'Input for deleting a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n});\n\nconst ListThresholdsInput = defineSchemaModel({\n name: 'ListThresholdsInput',\n description: 'Input for listing thresholds',\n fields: {\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n isActive: { type: ScalarTypeEnum.Boolean(), isOptional: true },\n },\n});\n\nconst ListThresholdsOutput = defineSchemaModel({\n name: 'ListThresholdsOutput',\n description: 'Output for listing thresholds',\n fields: {\n thresholds: { type: UsageThresholdModel, isArray: true, isOptional: false },\n total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n },\n});\n\nconst SuccessOutput = defineSchemaModel({\n name: 'SuccessOutput',\n description: 'Generic success output',\n fields: {\n success: { type: ScalarTypeEnum.Boolean(), isOptional: false },\n },\n});\n\n// ============ Contracts ============\n\n/**\n * Define a metric.\n */\nexport const DefineMetricContract = defineCommand({\n meta: {\n key: 'metric.define',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'define'],\n description: 'Define a new usage metric.',\n goal: 'Create a new metric for tracking usage.',\n context: 'Called when setting up metering.',\n },\n io: {\n input: DefineMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_KEY_EXISTS: {\n description: 'Metric key already exists',\n http: 409,\n gqlCode: 'METRIC_KEY_EXISTS',\n when: 'A metric with this key already exists',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Update a metric.\n */\nexport const UpdateMetricContract = defineCommand({\n meta: {\n key: 'metric.update',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'update'],\n description: 'Update a metric definition.',\n goal: 'Modify metric configuration.',\n context: 'Called when updating metric settings.',\n },\n io: {\n input: UpdateMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Delete a metric.\n */\nexport const DeleteMetricContract = defineCommand({\n meta: {\n key: 'metric.delete',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'delete'],\n description: 'Delete a metric definition.',\n goal: 'Remove a metric and its data.',\n context: 'Called when removing a metric.',\n },\n io: {\n input: DeleteMetricInput,\n output: SuccessOutput,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get a metric by key.\n */\nexport const GetMetricContract = defineQuery({\n meta: {\n key: 'metric.get',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'get'],\n description: 'Get a metric by key.',\n goal: 'Retrieve metric definition.',\n context: 'Called to inspect metric details.',\n },\n io: {\n input: GetMetricInput,\n output: MetricDefinitionModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n },\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * List metrics.\n */\nexport const ListMetricsContract = defineQuery({\n meta: {\n key: 'metric.list',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'metric', 'list'],\n description: 'List all metrics.',\n goal: 'View configured metrics.',\n context: 'Called to browse metrics.',\n },\n io: {\n input: ListMetricsInput,\n output: ListMetricsOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Record usage.\n */\nexport const RecordUsageContract = defineCommand({\n meta: {\n key: 'usage.record',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'record'],\n description: 'Record a usage event.',\n goal: 'Track usage for billing and monitoring.',\n context: 'Called when usage occurs.',\n },\n io: {\n input: RecordUsageInput,\n output: UsageRecordModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n DUPLICATE_RECORD: {\n description: 'Record already exists',\n http: 409,\n gqlCode: 'DUPLICATE_RECORD',\n when: 'Idempotency key already used',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Record batch usage.\n */\nexport const RecordBatchUsageContract = defineCommand({\n meta: {\n key: 'usage.recordBatch',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'batch'],\n description: 'Record multiple usage events.',\n goal: 'Efficiently track bulk usage.',\n context: 'Called for batch processing.',\n },\n io: {\n input: RecordBatchUsageInput,\n output: RecordBatchUsageOutput,\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Get usage records.\n */\nexport const GetUsageContract = defineQuery({\n meta: {\n key: 'usage.get',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'get'],\n description: 'Get usage records for a subject.',\n goal: 'View detailed usage history.',\n context: 'Called to analyze usage.',\n },\n io: {\n input: GetUsageInput,\n output: GetUsageOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Get usage summary.\n */\nexport const GetUsageSummaryContract = defineQuery({\n meta: {\n key: 'usage.getSummary',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'usage', 'summary'],\n description: 'Get aggregated usage summary.',\n goal: 'View usage totals for billing.',\n context: 'Called for billing and reporting.',\n },\n io: {\n input: GetUsageSummaryInput,\n output: GetUsageSummaryOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n\n/**\n * Create a threshold.\n */\nexport const CreateThresholdContract = defineCommand({\n meta: {\n key: 'threshold.create',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'create'],\n description: 'Create a usage threshold.',\n goal: 'Set up usage limits and alerts.',\n context: 'Called when configuring limits.',\n },\n io: {\n input: CreateThresholdInput,\n output: UsageThresholdModel,\n errors: {\n METRIC_NOT_FOUND: {\n description: 'Metric does not exist',\n http: 404,\n gqlCode: 'METRIC_NOT_FOUND',\n when: 'Metric key is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Update a threshold.\n */\nexport const UpdateThresholdContract = defineCommand({\n meta: {\n key: 'threshold.update',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'update'],\n description: 'Update a threshold.',\n goal: 'Modify threshold configuration.',\n context: 'Called when adjusting limits.',\n },\n io: {\n input: UpdateThresholdInput,\n output: UsageThresholdModel,\n errors: {\n THRESHOLD_NOT_FOUND: {\n description: 'Threshold does not exist',\n http: 404,\n gqlCode: 'THRESHOLD_NOT_FOUND',\n when: 'Threshold ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * Delete a threshold.\n */\nexport const DeleteThresholdContract = defineCommand({\n meta: {\n key: 'threshold.delete',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'delete'],\n description: 'Delete a threshold.',\n goal: 'Remove a usage threshold.',\n context: 'Called when removing limits.',\n },\n io: {\n input: DeleteThresholdInput,\n output: SuccessOutput,\n errors: {\n THRESHOLD_NOT_FOUND: {\n description: 'Threshold does not exist',\n http: 404,\n gqlCode: 'THRESHOLD_NOT_FOUND',\n when: 'Threshold ID is invalid',\n },\n },\n },\n policy: {\n auth: 'admin',\n },\n});\n\n/**\n * List thresholds.\n */\nexport const ListThresholdsContract = defineQuery({\n meta: {\n key: 'threshold.list',\n version: '1.0.0',\n stability: 'stable',\n owners: [...OWNERS],\n tags: ['metering', 'threshold', 'list'],\n description: 'List usage thresholds.',\n goal: 'View configured limits.',\n context: 'Called to browse thresholds.',\n },\n io: {\n input: ListThresholdsInput,\n output: ListThresholdsOutput,\n },\n policy: {\n auth: 'user',\n },\n});\n"],"mappings":";;;;AAGA,MAAM,SAAS,CAAC,oBAAoB;AAIpC,MAAa,wBAAwB,kBAAkB;CACrD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,aAAa;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACzE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,iBAAiB;GACf,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,aAAa;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAC1E,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACtE,UAAU;GAAE,MAAM,eAAe,SAAS;GAAE,YAAY;GAAO;EAC/D,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACnE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EACjE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAa,mBAAmB,kBAAkB;CAChD,MAAM;CACN,aAAa;CACb,QAAQ;EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACjE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAA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@ const ThresholdApproachingPayload = defineSchemaModel({
292
292
  const MetricDefinedEvent = defineEvent({
293
293
  meta: {
294
294
  key: "metric.defined",
295
- version: 1,
295
+ version: "1.0.0",
296
296
  description: "A metric has been defined.",
297
297
  stability: "stable",
298
298
  owners: ["@platform.metering"],
@@ -306,7 +306,7 @@ const MetricDefinedEvent = defineEvent({
306
306
  const MetricUpdatedEvent = defineEvent({
307
307
  meta: {
308
308
  key: "metric.updated",
309
- version: 1,
309
+ version: "1.0.0",
310
310
  description: "A metric has been updated.",
311
311
  stability: "stable",
312
312
  owners: ["@platform.metering"],
@@ -320,7 +320,7 @@ const MetricUpdatedEvent = defineEvent({
320
320
  const UsageRecordedEvent = defineEvent({
321
321
  meta: {
322
322
  key: "usage.recorded",
323
- version: 1,
323
+ version: "1.0.0",
324
324
  description: "Usage has been recorded.",
325
325
  stability: "stable",
326
326
  owners: ["@platform.metering"],
@@ -334,7 +334,7 @@ const UsageRecordedEvent = defineEvent({
334
334
  const UsageBatchRecordedEvent = defineEvent({
335
335
  meta: {
336
336
  key: "usage.batch_recorded",
337
- version: 1,
337
+ version: "1.0.0",
338
338
  description: "A batch of usage has been recorded.",
339
339
  stability: "stable",
340
340
  owners: ["@platform.metering"],
@@ -348,7 +348,7 @@ const UsageBatchRecordedEvent = defineEvent({
348
348
  const UsageAggregatedEvent = defineEvent({
349
349
  meta: {
350
350
  key: "usage.aggregated",
351
- version: 1,
351
+ version: "1.0.0",
352
352
  description: "Usage has been aggregated into a summary.",
353
353
  stability: "stable",
354
354
  owners: ["@platform.metering"],
@@ -362,7 +362,7 @@ const UsageAggregatedEvent = defineEvent({
362
362
  const ThresholdCreatedEvent = defineEvent({
363
363
  meta: {
364
364
  key: "threshold.created",
365
- version: 1,
365
+ version: "1.0.0",
366
366
  description: "A usage threshold has been created.",
367
367
  stability: "stable",
368
368
  owners: ["@platform.metering"],
@@ -376,7 +376,7 @@ const ThresholdCreatedEvent = defineEvent({
376
376
  const ThresholdExceededEvent = defineEvent({
377
377
  meta: {
378
378
  key: "threshold.exceeded",
379
- version: 1,
379
+ version: "1.0.0",
380
380
  description: "Usage has exceeded a threshold.",
381
381
  stability: "stable",
382
382
  owners: ["@platform.metering"],
@@ -390,7 +390,7 @@ const ThresholdExceededEvent = defineEvent({
390
390
  const ThresholdApproachingEvent = defineEvent({
391
391
  meta: {
392
392
  key: "threshold.approaching",
393
- version: 1,
393
+ version: "1.0.0",
394
394
  description: "Usage is approaching a threshold.",
395
395
  stability: "stable",
396
396
  owners: ["@platform.metering"],
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineEvent } from '@contractspec/lib.contracts';\n\n// ============ Event Payloads ============\n\nconst MetricDefinedPayload = defineSchemaModel({\n name: 'MetricDefinedEventPayload',\n description: 'Payload when a metric is defined',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst MetricUpdatedPayload = defineSchemaModel({\n name: 'MetricUpdatedEventPayload',\n description: 'Payload when a metric is updated',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n changes: { type: ScalarTypeEnum.JSON(), isOptional: false },\n updatedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageRecordedPayload = defineSchemaModel({\n name: 'UsageRecordedEventPayload',\n description: 'Payload when usage is recorded',\n fields: {\n recordId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageBatchRecordedPayload = defineSchemaModel({\n name: 'UsageBatchRecordedEventPayload',\n description: 'Payload when a batch of usage is recorded',\n fields: {\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n metricKeys: { type: ScalarTypeEnum.JSON(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageAggregatedPayload = defineSchemaModel({\n name: 'UsageAggregatedEventPayload',\n description: 'Payload when usage is aggregated',\n fields: {\n summaryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n aggregatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdCreatedPayload = defineSchemaModel({\n name: 'ThresholdCreatedEventPayload',\n description: 'Payload when a threshold is created',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdExceededPayload = defineSchemaModel({\n name: 'ThresholdExceededEventPayload',\n description: 'Payload when a threshold is exceeded',\n fields: {\n alertId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n actualValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdApproachingPayload = defineSchemaModel({\n name: 'ThresholdApproachingEventPayload',\n description: 'Payload when usage is approaching a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n// ============ Events ============\n\n/**\n * Emitted when a metric is defined.\n */\nexport const MetricDefinedEvent = defineEvent({\n meta: {\n key: 'metric.defined',\n version: 1,\n description: 'A metric has been defined.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricDefinedPayload,\n});\n\n/**\n * Emitted when a metric is updated.\n */\nexport const MetricUpdatedEvent = defineEvent({\n meta: {\n key: 'metric.updated',\n version: 1,\n description: 'A metric has been updated.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricUpdatedPayload,\n});\n\n/**\n * Emitted when usage is recorded.\n */\nexport const UsageRecordedEvent = defineEvent({\n meta: {\n key: 'usage.recorded',\n version: 1,\n description: 'Usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageRecordedPayload,\n});\n\n/**\n * Emitted when a batch of usage is recorded.\n */\nexport const UsageBatchRecordedEvent = defineEvent({\n meta: {\n key: 'usage.batch_recorded',\n version: 1,\n description: 'A batch of usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageBatchRecordedPayload,\n});\n\n/**\n * Emitted when usage is aggregated.\n */\nexport const UsageAggregatedEvent = defineEvent({\n meta: {\n key: 'usage.aggregated',\n version: 1,\n description: 'Usage has been aggregated into a summary.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageAggregatedPayload,\n});\n\n/**\n * Emitted when a threshold is created.\n */\nexport const ThresholdCreatedEvent = defineEvent({\n meta: {\n key: 'threshold.created',\n version: 1,\n description: 'A usage threshold has been created.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdCreatedPayload,\n});\n\n/**\n * Emitted when a threshold is exceeded.\n */\nexport const ThresholdExceededEvent = defineEvent({\n meta: {\n key: 'threshold.exceeded',\n version: 1,\n description: 'Usage has exceeded a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdExceededPayload,\n});\n\n/**\n * Emitted when usage is approaching a threshold.\n */\nexport const ThresholdApproachingEvent = defineEvent({\n meta: {\n key: 'threshold.approaching',\n version: 1,\n description: 'Usage is approaching a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdApproachingPayload,\n});\n\n/**\n * All metering events.\n */\nexport const MeteringEvents = {\n MetricDefinedEvent,\n MetricUpdatedEvent,\n UsageRecordedEvent,\n UsageBatchRecordedEvent,\n UsageAggregatedEvent,\n ThresholdCreatedEvent,\n ThresholdExceededEvent,\n ThresholdApproachingEvent,\n};\n"],"mappings":";;;;AAKA,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,iBAAiB;GACf,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACnE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,Y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AC5C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,QAAQ;EAC5B;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,0BAA0B,YAAY;CACjD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,QAAQ;EAC5B;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,uBAAuB,YAAY;CAC9C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,QAAQ;EAC5B;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,yBAAyB,YAAY;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,4BAA4B,YAAY;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { ScalarTypeEnum, defineSchemaModel } from '@contractspec/lib.schema';\nimport { defineEvent } from '@contractspec/lib.contracts';\n\n// ============ Event Payloads ============\n\nconst MetricDefinedPayload = defineSchemaModel({\n name: 'MetricDefinedEventPayload',\n description: 'Payload when a metric is defined',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n aggregationType: {\n type: ScalarTypeEnum.String_unsecure(),\n isOptional: false,\n },\n orgId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst MetricUpdatedPayload = defineSchemaModel({\n name: 'MetricUpdatedEventPayload',\n description: 'Payload when a metric is updated',\n fields: {\n metricId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n changes: { type: ScalarTypeEnum.JSON(), isOptional: false },\n updatedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageRecordedPayload = defineSchemaModel({\n name: 'UsageRecordedEventPayload',\n description: 'Payload when usage is recorded',\n fields: {\n recordId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n quantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageBatchRecordedPayload = defineSchemaModel({\n name: 'UsageBatchRecordedEventPayload',\n description: 'Payload when a batch of usage is recorded',\n fields: {\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n metricKeys: { type: ScalarTypeEnum.JSON(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst UsageAggregatedPayload = defineSchemaModel({\n name: 'UsageAggregatedEventPayload',\n description: 'Payload when usage is aggregated',\n fields: {\n summaryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n periodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n periodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n totalQuantity: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n recordCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },\n aggregatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdCreatedPayload = defineSchemaModel({\n name: 'ThresholdCreatedEventPayload',\n description: 'Payload when a threshold is created',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdExceededPayload = defineSchemaModel({\n name: 'ThresholdExceededEventPayload',\n description: 'Payload when a threshold is exceeded',\n fields: {\n alertId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n actualValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n action: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\nconst ThresholdApproachingPayload = defineSchemaModel({\n name: 'ThresholdApproachingEventPayload',\n description: 'Payload when usage is approaching a threshold',\n fields: {\n thresholdId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n metricKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n subjectType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n subjectId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },\n threshold: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n currentValue: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },\n percentageUsed: {\n type: ScalarTypeEnum.Float_unsecure(),\n isOptional: false,\n },\n triggeredAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },\n },\n});\n\n// ============ Events ============\n\n/**\n * Emitted when a metric is defined.\n */\nexport const MetricDefinedEvent = defineEvent({\n meta: {\n key: 'metric.defined',\n version: '1.0.0',\n description: 'A metric has been defined.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricDefinedPayload,\n});\n\n/**\n * Emitted when a metric is updated.\n */\nexport const MetricUpdatedEvent = defineEvent({\n meta: {\n key: 'metric.updated',\n version: '1.0.0',\n description: 'A metric has been updated.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'metric'],\n },\n payload: MetricUpdatedPayload,\n});\n\n/**\n * Emitted when usage is recorded.\n */\nexport const UsageRecordedEvent = defineEvent({\n meta: {\n key: 'usage.recorded',\n version: '1.0.0',\n description: 'Usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageRecordedPayload,\n});\n\n/**\n * Emitted when a batch of usage is recorded.\n */\nexport const UsageBatchRecordedEvent = defineEvent({\n meta: {\n key: 'usage.batch_recorded',\n version: '1.0.0',\n description: 'A batch of usage has been recorded.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageBatchRecordedPayload,\n});\n\n/**\n * Emitted when usage is aggregated.\n */\nexport const UsageAggregatedEvent = defineEvent({\n meta: {\n key: 'usage.aggregated',\n version: '1.0.0',\n description: 'Usage has been aggregated into a summary.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage'],\n },\n payload: UsageAggregatedPayload,\n});\n\n/**\n * Emitted when a threshold is created.\n */\nexport const ThresholdCreatedEvent = defineEvent({\n meta: {\n key: 'threshold.created',\n version: '1.0.0',\n description: 'A usage threshold has been created.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdCreatedPayload,\n});\n\n/**\n * Emitted when a threshold is exceeded.\n */\nexport const ThresholdExceededEvent = defineEvent({\n meta: {\n key: 'threshold.exceeded',\n version: '1.0.0',\n description: 'Usage has exceeded a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdExceededPayload,\n});\n\n/**\n * Emitted when usage is approaching a threshold.\n */\nexport const ThresholdApproachingEvent = defineEvent({\n meta: {\n key: 'threshold.approaching',\n version: '1.0.0',\n description: 'Usage is approaching a threshold.',\n stability: 'stable',\n owners: ['@platform.metering'],\n tags: ['metering', 'threshold'],\n },\n payload: ThresholdApproachingPayload,\n});\n\n/**\n * All metering events.\n */\nexport const MeteringEvents = {\n MetricDefinedEvent,\n MetricUpdatedEvent,\n UsageRecordedEvent,\n UsageBatchRecordedEvent,\n UsageAggregatedEvent,\n ThresholdCreatedEvent,\n ThresholdExceededEvent,\n ThresholdApproachingEvent,\n};\n"],"mappings":";;;;AAKA,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,MAAM;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACnE,iBAAiB;GACf,MAAM,eAAe,iBAAiB;GACtC,YAAY;GACb;EACD,OAAO;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACnE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,KAAK;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EAClE,SAAS;GAAE,MAAM,eAAe,MAAM;GAAE,YAAY;GAAO;EAC3D,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAM;EACvE,WAAW;GAAE,MAAM,eAAe,UAAU;GAAE,YAAY;GAAO;EAClE;CACF,CAAC;AAEF,MAAM,uBAAuB,kBAAkB;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ;EACN,UAAU;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACvE,WAAW;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO;EACxE,aAAa;GAAE,MAAM,eA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AAY,QAAQ;EAC5B;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,wBAAwB,YAAY;CAC/C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,yBAAyB,YAAY;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,4BAA4B,YAAY;CACnD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,qBAAqB;EAC9B,MAAM,CAAC,YAAY,YAAY;EAChC;CACD,SAAS;CACV,CAAC;;;;AAKF,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -6,7 +6,7 @@
6
6
  const MeteringFeature = {
7
7
  meta: {
8
8
  key: "metering",
9
- version: 1,
9
+ version: "1.0.0",
10
10
  title: "Usage Metering",
11
11
  description: "Usage metering, metric definitions, and threshold alerting",
12
12
  domain: "platform",
@@ -22,89 +22,89 @@ const MeteringFeature = {
22
22
  operations: [
23
23
  {
24
24
  key: "metric.define",
25
- version: 1
25
+ version: "1.0.0"
26
26
  },
27
27
  {
28
28
  key: "metric.update",
29
- version: 1
29
+ version: "1.0.0"
30
30
  },
31
31
  {
32
32
  key: "metric.delete",
33
- version: 1
33
+ version: "1.0.0"
34
34
  },
35
35
  {
36
36
  key: "metric.get",
37
- version: 1
37
+ version: "1.0.0"
38
38
  },
39
39
  {
40
40
  key: "metric.list",
41
- version: 1
41
+ version: "1.0.0"
42
42
  },
43
43
  {
44
44
  key: "usage.record",
45
- version: 1
45
+ version: "1.0.0"
46
46
  },
47
47
  {
48
48
  key: "usage.recordBatch",
49
- version: 1
49
+ version: "1.0.0"
50
50
  },
51
51
  {
52
52
  key: "usage.get",
53
- version: 1
53
+ version: "1.0.0"
54
54
  },
55
55
  {
56
56
  key: "usage.getSummary",
57
- version: 1
57
+ version: "1.0.0"
58
58
  },
59
59
  {
60
60
  key: "threshold.create",
61
- version: 1
61
+ version: "1.0.0"
62
62
  },
63
63
  {
64
64
  key: "threshold.update",
65
- version: 1
65
+ version: "1.0.0"
66
66
  },
67
67
  {
68
68
  key: "threshold.delete",
69
- version: 1
69
+ version: "1.0.0"
70
70
  },
71
71
  {
72
72
  key: "threshold.list",
73
- version: 1
73
+ version: "1.0.0"
74
74
  }
75
75
  ],
76
76
  events: [
77
77
  {
78
78
  key: "metric.defined",
79
- version: 1
79
+ version: "1.0.0"
80
80
  },
81
81
  {
82
82
  key: "metric.updated",
83
- version: 1
83
+ version: "1.0.0"
84
84
  },
85
85
  {
86
86
  key: "usage.recorded",
87
- version: 1
87
+ version: "1.0.0"
88
88
  },
89
89
  {
90
90
  key: "usage.batch_recorded",
91
- version: 1
91
+ version: "1.0.0"
92
92
  },
93
93
  {
94
94
  key: "usage.aggregated",
95
- version: 1
95
+ version: "1.0.0"
96
96
  },
97
97
  {
98
98
  key: "threshold.created",
99
- version: 1
99
+ version: "1.0.0"
100
100
  },
101
101
  {
102
102
  key: "threshold.exceeded",
103
- version: 1
103
+ version: "1.0.0"
104
104
  },
105
105
  {
106
106
  key: "threshold.approaching",
107
- version: 1
107
+ version: "1.0.0"
108
108
  }
109
109
  ],
110
110
  presentations: [],
@@ -113,10 +113,10 @@ const MeteringFeature = {
113
113
  capabilities: {
114
114
  provides: [{
115
115
  key: "metering",
116
- version: 1
116
+ version: "1.0.0"
117
117
  }, {
118
118
  key: "thresholds",
119
- version: 1
119
+ version: "1.0.0"
120
120
  }],
121
121
  requires: []
122
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"metering.feature.js","names":["MeteringFeature: FeatureModuleSpec"],"sources":["../src/metering.feature.ts"],"sourcesContent":["/**\n * Metering Feature Module Specification\n *\n * Defines the feature module for usage metering and threshold management.\n */\nimport type { FeatureModuleSpec } from '@contractspec/lib.contracts';\n\n/**\n * Metering feature module that bundles metric definitions,\n * usage tracking, and threshold alerting capabilities.\n */\nexport const MeteringFeature: FeatureModuleSpec = {\n meta: {\n key: 'metering',\n version: 1,\n title: 'Usage Metering',\n description: 'Usage metering, metric definitions, and threshold alerting',\n domain: 'platform',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage', 'billing', 'thresholds'],\n stability: 'stable',\n },\n\n // All contract operations included in this feature\n operations: [\n // Metric operations\n { key: 'metric.define', version: 1 },\n { key: 'metric.update', version: 1 },\n { key: 'metric.delete', version: 1 },\n { key: 'metric.get', version: 1 },\n { key: 'metric.list', version: 1 },\n\n // Usage operations\n { key: 'usage.record', version: 1 },\n { key: 'usage.recordBatch', version: 1 },\n { key: 'usage.get', version: 1 },\n { key: 'usage.getSummary', version: 1 },\n\n // Threshold operations\n { key: 'threshold.create', version: 1 },\n { key: 'threshold.update', version: 1 },\n { key: 'threshold.delete', version: 1 },\n { key: 'threshold.list', version: 1 },\n ],\n\n // Events emitted by this feature\n events: [\n // Metric events\n { key: 'metric.defined', version: 1 },\n { key: 'metric.updated', version: 1 },\n\n // Usage events\n { key: 'usage.recorded', version: 1 },\n { key: 'usage.batch_recorded', version: 1 },\n { key: 'usage.aggregated', version: 1 },\n\n // Threshold events\n { key: 'threshold.created', version: 1 },\n { key: 'threshold.exceeded', version: 1 },\n { key: 'threshold.approaching', version: 1 },\n ],\n\n // No presentations for this library feature\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n\n // Capability definitions\n capabilities: {\n provides: [\n { key: 'metering', version: 1 },\n { key: 'thresholds', version: 1 },\n ],\n requires: [],\n },\n};\n"],"mappings":";;;;;AAWA,MAAaA,kBAAqC;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aAAa;EACb,QAAQ;EACR,QAAQ,CAAC,qBAAqB;EAC9B,MAAM;GAAC;GAAY;GAAS;GAAW;GAAa;EACpD,WAAW;EACZ;CAGD,YAAY;EAEV;GAAE,KAAK;GAAiB,SAAS;GAAG;EACpC;GAAE,KAAK;GAAiB,SAAS;GAAG;EACpC;GAAE,KAAK;GAAiB,SAAS;GAAG;EACpC;GAAE,KAAK;GAAc,SAAS;GAAG;EACjC;GAAE,KAAK;GAAe,SAAS;GAAG;EAGlC;GAAE,KAAK;GAAgB,SAAS;GAAG;EACnC;GAAE,KAAK;GAAqB,SAAS;GAAG;EACxC;GAAE,KAAK;GAAa,SAAS;GAAG;EAChC;GAAE,KAAK;GAAoB,SAAS;GAAG;EAGvC;GAAE,KAAK;GAAoB,SAAS;GAAG;EACvC;GAAE,KAAK;GAAoB,SAAS;GAAG;EACvC;GAAE,KAAK;GAAoB,SAAS;GAAG;EACvC;GAAE,KAAK;GAAkB,SAAS;GAAG;EACtC;CAGD,QAAQ;EAEN;GAAE,KAAK;GAAkB,SAAS;GAAG;EACrC;GAAE,KAAK;GAAkB,SAAS;GAAG;EAGrC;GAAE,KAAK;GAAkB,SAAS;GAAG;EACrC;GAAE,KAAK;GAAwB,SAAS;GAAG;EAC3C;GAAE,KAAK;GAAoB,SAAS;GAAG;EAGvC;GAAE,KAAK;GAAqB,SAAS;GAAG;EACxC;GAAE,KAAK;GAAsB,SAAS;GAAG;EACzC;GAAE,KAAK;GAAyB,SAAS;GAAG;EAC7C;CAGD,eAAe,EAAE;CACjB,kBAAkB,EAAE;CACpB,sBAAsB,EAAE;CAGxB,cAAc;EACZ,UAAU,CACR;GAAE,KAAK;GAAY,SAAS;GAAG,EAC/B;GAAE,KAAK;GAAc,SAAS;GAAG,CAClC;EACD,UAAU,EAAE;EACb;CACF"}
1
+ {"version":3,"file":"metering.feature.js","names":["MeteringFeature: FeatureModuleSpec"],"sources":["../src/metering.feature.ts"],"sourcesContent":["/**\n * Metering Feature Module Specification\n *\n * Defines the feature module for usage metering and threshold management.\n */\nimport type { FeatureModuleSpec } from '@contractspec/lib.contracts';\n\n/**\n * Metering feature module that bundles metric definitions,\n * usage tracking, and threshold alerting capabilities.\n */\nexport const MeteringFeature: FeatureModuleSpec = {\n meta: {\n key: 'metering',\n version: '1.0.0',\n title: 'Usage Metering',\n description: 'Usage metering, metric definitions, and threshold alerting',\n domain: 'platform',\n owners: ['@platform.metering'],\n tags: ['metering', 'usage', 'billing', 'thresholds'],\n stability: 'stable',\n },\n\n // All contract operations included in this feature\n operations: [\n // Metric operations\n { key: 'metric.define', version: '1.0.0' },\n { key: 'metric.update', version: '1.0.0' },\n { key: 'metric.delete', version: '1.0.0' },\n { key: 'metric.get', version: '1.0.0' },\n { key: 'metric.list', version: '1.0.0' },\n\n // Usage operations\n { key: 'usage.record', version: '1.0.0' },\n { key: 'usage.recordBatch', version: '1.0.0' },\n { key: 'usage.get', version: '1.0.0' },\n { key: 'usage.getSummary', version: '1.0.0' },\n\n // Threshold operations\n { key: 'threshold.create', version: '1.0.0' },\n { key: 'threshold.update', version: '1.0.0' },\n { key: 'threshold.delete', version: '1.0.0' },\n { key: 'threshold.list', version: '1.0.0' },\n ],\n\n // Events emitted by this feature\n events: [\n // Metric events\n { key: 'metric.defined', version: '1.0.0' },\n { key: 'metric.updated', version: '1.0.0' },\n\n // Usage events\n { key: 'usage.recorded', version: '1.0.0' },\n { key: 'usage.batch_recorded', version: '1.0.0' },\n { key: 'usage.aggregated', version: '1.0.0' },\n\n // Threshold events\n { key: 'threshold.created', version: '1.0.0' },\n { key: 'threshold.exceeded', version: '1.0.0' },\n { key: 'threshold.approaching', version: '1.0.0' },\n ],\n\n // No presentations for this library feature\n presentations: [],\n opToPresentation: [],\n presentationsTargets: [],\n\n // Capability definitions\n capabilities: {\n provides: [\n { key: 'metering', version: '1.0.0' },\n { key: 'thresholds', version: '1.0.0' },\n ],\n requires: [],\n },\n};\n"],"mappings":";;;;;AAWA,MAAaA,kBAAqC;CAChD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;E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45.0",
4
4
  "description": "Usage metering and billing core module for ContractSpec applications",
5
+ "keywords": [
6
+ "contractspec",
7
+ "metering",
8
+ "billing",
9
+ "usage",
10
+ "saas",
11
+ "typescript"
12
+ ],
5
13
  "main": "./dist/index.js",
6
14
  "types": "./dist/index.d.ts",
7
15
  "type": "module",
@@ -18,13 +26,13 @@
18
26
  "lint:check": "eslint src"
19
27
  },
20
28
  "dependencies": {
21
- "@contractspec/lib.schema": "1.44.0",
22
- "@contractspec/lib.contracts": "1.44.0",
29
+ "@contractspec/lib.schema": "1.45.0",
30
+ "@contractspec/lib.contracts": "1.45.0",
23
31
  "zod": "^4.1.13"
24
32
  },
25
33
  "devDependencies": {
26
- "@contractspec/tool.typescript": "1.44.0",
27
- "@contractspec/tool.tsdown": "1.44.0",
34
+ "@contractspec/tool.typescript": "1.45.0",
35
+ "@contractspec/tool.tsdown": "1.45.0",
28
36
  "typescript": "^5.9.3"
29
37
  },
30
38
  "exports": {