@htilabs/platform-common-models 0.18.0 → 0.19.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.
Files changed (47) hide show
  1. package/dist/cvcs/index.cjs +966 -966
  2. package/dist/cvcs/index.cjs.map +1 -1
  3. package/dist/cvcs/index.d.cts +946 -946
  4. package/dist/cvcs/index.d.ts +946 -946
  5. package/dist/cvcs/index.js +958 -958
  6. package/dist/cvcs/index.js.map +1 -1
  7. package/dist/enums/index.cjs +142 -142
  8. package/dist/enums/index.cjs.map +1 -1
  9. package/dist/enums/index.d.cts +143 -143
  10. package/dist/enums/index.d.ts +143 -143
  11. package/dist/enums/index.js +142 -142
  12. package/dist/enums/index.js.map +1 -1
  13. package/dist/{index-Zu_mOJRn.d.cts → index-CoVr1jIV.d.cts} +1 -1
  14. package/dist/{index-CDoqrfc1.d.ts → index-I-DiX9eQ.d.ts} +1 -1
  15. package/dist/index.cjs +1109 -1109
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +2 -2
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +1101 -1101
  20. package/dist/index.js.map +1 -1
  21. package/dist/models/index.cjs +1 -1
  22. package/dist/models/index.cjs.map +1 -1
  23. package/dist/models/index.d.cts +2 -2
  24. package/dist/models/index.d.ts +2 -2
  25. package/dist/models/index.js +1 -1
  26. package/dist/models/index.js.map +1 -1
  27. package/dist/schemas/index.cjs +1 -1
  28. package/dist/schemas/index.cjs.map +1 -1
  29. package/dist/schemas/index.d.cts +25 -25
  30. package/dist/schemas/index.d.ts +25 -25
  31. package/dist/schemas/index.js +1 -1
  32. package/dist/schemas/index.js.map +1 -1
  33. package/dist/services/index.cjs +1 -1
  34. package/dist/services/index.cjs.map +1 -1
  35. package/dist/services/index.js +1 -1
  36. package/dist/services/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/__tests__/__snapshots__/cvc-sot.snap +1 -1
  39. package/src/__tests__/cvc-sot-snapshot.test.ts +1 -1
  40. package/src/__tests__/cvc-structural.test.ts +2 -2
  41. package/src/cvcs/index.ts +1 -1
  42. package/src/cvcs/{serviceCategories.v1.0.0.json → serviceCategories.v1.2.0.json} +955 -955
  43. package/src/generated/cvc-enums.ts +143 -143
  44. package/src/schemas/cvcRegistry.ts +1 -1
  45. package/src/services/__tests__/cvcRegistryService.test.ts +11 -11
  46. package/dist/{cvcEntry-0BIB9sen.d.cts → cvcEntry-BCj1OWqL.d.cts} +8 -8
  47. package/dist/{cvcEntry-0BIB9sen.d.ts → cvcEntry-BCj1OWqL.d.ts} +8 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/formModel.ts","../../src/schemas/form.ts","../../src/models/sectionModel.ts","../../src/schemas/section.ts","../../src/models/questionModel.ts","../../src/schemas/question.ts","../../src/models/scoringRuleModel.ts","../../src/schemas/scoring-rule.ts","../../src/models/platformFunctionModel.ts","../../src/schemas/platform-function.ts","../../src/constants/platform-auth.ts","../../src/models/platformRoleModel.ts","../../src/schemas/platform-role.ts","../../src/models/cvcRegistryModel.ts","../../src/schemas/cvcRegistry.ts","../../src/models/cvcEntryModel.ts","../../src/schemas/cvcEntry.ts","../../src/models/index.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — Form Model\n *\n * Factory for creating Form model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildFormSchema, type Form } from \"../schemas/form.js\";\n\nexport type FormDoc = HydratedDocument<Form>;\n\n/**\n * Build the Form schema.\n * @returns Mongoose Schema for Form\n */\nexport { buildFormSchema as buildSchema };\n\n/**\n * Compile the Form model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildFormSchema() if not provided)\n * @returns Mongoose Model for Form\n */\nexport function compileModel(\n connection: Connection,\n schema = buildFormSchema(),\n): Model<Form> {\n return connection.model<Form>(\"Form\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Form Schema\n *\n * Versioned form definitions for screening, intake, and assessment forms.\n * Forms contain ordered references to sections with display metadata.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Form Section Reference Sub-Schema ───────────────────────────────────────\n\nexport const formSectionRefSchema = new Schema(\n {\n sectionId: { type: String, required: true },\n sectionVersion: { type: String, required: true },\n index: { type: Number, required: true },\n isStep: { type: Boolean, default: false },\n wizardStep: { type: Number },\n label: { type: String },\n presetsType: { type: String },\n },\n { _id: false },\n);\n\nexport type FormSectionRef = InferRawDocType<typeof formSectionRefSchema>;\n\n// ─── Form Schema ─────────────────────────────────────────────────────────────\n\nexport const formSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Form info\n name: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n },\n formType: {\n type: String,\n index: true,\n },\n appScope: {\n type: [String],\n enum: [\"thread\", \"pave\", \"both\"],\n default: [],\n },\n\n // Ordered sections\n sections: {\n type: [formSectionRefSchema],\n default: [],\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n};\n\nexport const formSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"forms\",\n};\n\n/**\n * Build the Form schema.\n * @returns Mongoose Schema for Form\n */\nexport function buildFormSchema(): Schema {\n const schema = new Schema(formSchemaDefinition, formSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _formSchema = buildFormSchema();\n\nexport type Form = InferRawDocType<typeof _formSchema>;\n","/**\n * @htilabs/platform-common-models — Section Model\n *\n * Factory for creating Section model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildSectionSchema, type Section } from \"../schemas/section.js\";\n\nexport type SectionDoc = HydratedDocument<Section>;\n\n/**\n * Build the Section schema.\n * @returns Mongoose Schema for Section\n */\nexport { buildSectionSchema as buildSchema };\n\n/**\n * Compile the Section model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildSectionSchema() if not provided)\n * @returns Mongoose Model for Section\n */\nexport function compileModel(\n connection: Connection,\n schema = buildSectionSchema(),\n): Model<Section> {\n return connection.model<Section>(\"Section\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Section Schema\n *\n * Logical grouping of questions within a form.\n * Sections contain ordered references to questions with display metadata.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Section Question Reference Sub-Schema ───────────────────────────────────\n\nexport const sectionQuestionRefSchema = new Schema(\n {\n questionId: { type: String, required: true },\n questionVersion: { type: String, required: true },\n index: { type: Number, required: true },\n },\n { _id: false },\n);\n\nexport type SectionQuestionRef = InferRawDocType<\n typeof sectionQuestionRefSchema\n>;\n\n// ─── Guidance Sub-Schema ─────────────────────────────────────────────────────\n\nexport const guidanceSchema = new Schema(\n {\n type: {\n type: String,\n required: true,\n enum: [\"tip\", \"warning\", \"prompt\"],\n },\n text: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type Guidance = InferRawDocType<typeof guidanceSchema>;\n\n// ─── Section Schema ──────────────────────────────────────────────────────────\n\nexport const sectionSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Section info\n name: {\n type: String,\n required: true,\n },\n directions: {\n type: String,\n },\n\n // Typed guidance items\n guidance: {\n type: [guidanceSchema],\n default: [],\n },\n\n // Ordered question refs\n questions: {\n type: [sectionQuestionRefSchema],\n default: [],\n },\n\n // Template visibility\n templateScope: {\n type: [String],\n default: undefined,\n },\n collapsible: {\n type: Boolean,\n default: false,\n },\n defaultCollapsed: {\n type: Boolean,\n default: false,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n\n // PAVE-aligned optional fields\n rephrasing: {\n type: String,\n },\n script: {\n type: String,\n },\n};\n\nexport const sectionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"sections\",\n};\n\n/**\n * Build the Section schema.\n * @returns Mongoose Schema for Section\n */\nexport function buildSectionSchema(): Schema {\n const schema = new Schema(sectionSchemaDefinition, sectionSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _sectionSchema = buildSectionSchema();\n\nexport type Section = InferRawDocType<typeof _sectionSchema>;\n","/**\n * @htilabs/platform-common-models — Question Model\n *\n * Factory for creating Question model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildQuestionSchema, type Question } from \"../schemas/question.js\";\n\nexport type QuestionDoc = HydratedDocument<Question>;\n\n/**\n * Build the Question schema.\n * @returns Mongoose Schema for Question\n */\nexport { buildQuestionSchema as buildSchema };\n\n/**\n * Compile the Question model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildQuestionSchema() if not provided)\n * @returns Mongoose Model for Question\n */\nexport function compileModel(\n connection: Connection,\n schema = buildQuestionSchema(),\n): Model<Question> {\n return connection.model<Question>(\"Question\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Question Schema\n *\n * Individual form fields with validation, choices, visibility rules, and scoring.\n * Questions support static and dynamic choices, conditional visibility, and IC code mapping.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Choice Sub-Schema ───────────────────────────────────────────────────────\n\nexport const choiceSchema = new Schema(\n {\n val: { type: Schema.Types.Mixed, required: true },\n text: { type: String, required: true },\n tip: { type: String },\n trigger: { type: [String] },\n },\n { _id: false },\n);\n\nexport type Choice = InferRawDocType<typeof choiceSchema>;\n\n// ─── Visibility Rule Sub-Schema ──────────────────────────────────────────────\n\nexport const visibilityRuleSchema = new Schema(\n {\n dependsOn: { type: String, required: true },\n condition: {\n type: String,\n required: true,\n enum: [\"equals\", \"not_equals\", \"any_of\", \"in_range\"],\n },\n values: { type: [Schema.Types.Mixed], required: true },\n source: {\n type: String,\n enum: [\"form\", \"session\"],\n default: \"form\",\n },\n },\n { _id: false },\n);\n\nexport type VisibilityRule = InferRawDocType<typeof visibilityRuleSchema>;\n\n// ─── Layout Sub-Schema ───────────────────────────────────────────────────────\n\nexport const layoutSchema = new Schema(\n {\n columns: { type: Number, default: 1, min: 1, max: 4 },\n collapsible: { type: Boolean, default: false },\n groupKey: { type: String },\n },\n { _id: false },\n);\n\nexport type Layout = InferRawDocType<typeof layoutSchema>;\n\n// ─── Question Schema ─────────────────────────────────────────────────────────\n\nexport const questionSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Question definition\n index: {\n type: Number,\n required: true,\n },\n text: {\n type: String,\n required: true,\n },\n format: {\n type: String,\n required: true,\n },\n sectionId: {\n type: String,\n required: true,\n },\n required: {\n type: Boolean,\n default: false,\n },\n allowMultiple: {\n type: Boolean,\n default: false,\n },\n\n // Nesting\n isNested: {\n type: Boolean,\n default: false,\n },\n nested: {\n type: [String],\n default: [],\n },\n\n // Trigger logic\n isTriggered: {\n type: Boolean,\n default: false,\n },\n triggersWhenAnswered: {\n type: [String],\n default: [],\n },\n\n // Display\n header: { type: String },\n directions: { type: String },\n tip: { type: String },\n\n // Dynamic choices\n hasDynamicChoices: {\n type: Boolean,\n default: false,\n },\n dynamicChoiceSet: { type: String },\n group: { type: String },\n\n // Static choices\n choices: {\n type: [choiceSchema],\n default: [],\n },\n\n // UI rendering hints\n componentProps: {\n type: Schema.Types.Mixed,\n },\n\n // Autofill\n autofillRules: {\n type: Schema.Types.Mixed,\n default: [],\n },\n\n // Classification\n formType: {\n type: [String],\n enum: [\"screening\", \"intake\", \"assessment\", \"demographics\"],\n default: [],\n },\n icCode: {\n type: String,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n\n // Entity mapping (dual-write bridge)\n targetEntity: {\n type: String,\n enum: [\n \"caseSession\",\n \"protectedPerson\",\n \"perpetratorPerson\",\n \"personnelPerson\",\n \"caseRecord\",\n \"serviceInstance\",\n ],\n },\n targetField: {\n type: String,\n },\n\n // Conditional visibility\n visibilityRule: {\n type: visibilityRuleSchema,\n },\n\n // Layout hints\n layout: {\n type: layoutSchema,\n },\n microcopy: {\n type: String,\n },\n sensitivity: {\n type: String,\n enum: [\"standard\", \"sensitive\", \"highly_sensitive\"],\n },\n\n // Scoring group\n scoringGroup: {\n type: String,\n },\n\n // PAVE-aligned optional fields\n groups: {\n type: [String],\n default: undefined,\n },\n rephrasingSelector: {\n type: Schema.Types.Mixed,\n },\n textSelector: {\n type: Schema.Types.Mixed,\n },\n tipSelector: {\n type: Schema.Types.Mixed,\n },\n sortChoices: {\n type: Boolean,\n },\n isAllRequired: {\n type: Boolean,\n },\n itemLabel: {\n type: String,\n },\n prompts: {\n type: [String],\n default: undefined,\n },\n rephrasing: {\n type: String,\n },\n dynamicChoiceTrigger: {\n type: String,\n },\n};\n\nexport const questionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"questions\",\n};\n\n/**\n * Build the Question schema.\n * @returns Mongoose Schema for Question\n */\nexport function buildQuestionSchema(): Schema {\n const schema = new Schema(questionSchemaDefinition, questionSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n // Lookup by section + order\n schema.index({ sectionId: 1, index: 1 });\n\n // IC code lookup (sparse — many questions won't have an IC code)\n schema.index({ icCode: 1 }, { sparse: true });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _questionSchema = buildQuestionSchema();\n\nexport type Question = InferRawDocType<typeof _questionSchema>;\n","/**\n * @htilabs/platform-common-models — ScoringRule Model\n *\n * Factory for creating ScoringRule model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildScoringRuleSchema,\n type ScoringRule,\n} from \"../schemas/scoring-rule.js\";\n\nexport type ScoringRuleDoc = HydratedDocument<ScoringRule>;\n\n/**\n * Build the ScoringRule schema.\n * @returns Mongoose Schema for ScoringRule\n */\nexport { buildScoringRuleSchema as buildSchema };\n\n/**\n * Compile the ScoringRule model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildScoringRuleSchema() if not provided)\n * @returns Mongoose Model for ScoringRule\n */\nexport function compileModel(\n connection: Connection,\n schema = buildScoringRuleSchema(),\n): Model<ScoringRule> {\n return connection.model<ScoringRule>(\"ScoringRule\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Scoring Rule Schema\n *\n * Evaluation rules for screening and assessment instruments.\n * Defines conditions to evaluate, score thresholds, and risk level recommendations.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Scoring Condition Sub-Schema ────────────────────────────────────────────\n\nexport const scoringConditionSchema = new Schema(\n {\n questionKey: { type: String, required: true },\n operator: {\n type: String,\n required: true,\n enum: [\"eq\", \"ne\", \"in\", \"not_in\", \"gt\", \"gte\", \"lt\", \"lte\"],\n },\n value: { type: Schema.Types.Mixed, required: true },\n weight: { type: Number, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringCondition = InferRawDocType<typeof scoringConditionSchema>;\n\n// ─── Scoring Threshold Sub-Schema ────────────────────────────────────────────\n\nexport const scoringThresholdSchema = new Schema(\n {\n minScore: { type: Number, required: true },\n maxScore: { type: Number, required: true },\n riskLevel: { type: String, required: true },\n label: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringThreshold = InferRawDocType<typeof scoringThresholdSchema>;\n\n// ─── Scoring Recommendation Sub-Schema ───────────────────────────────────────\n\nexport const scoringRecommendationSchema = new Schema(\n {\n riskLevel: { type: String, required: true },\n action: { type: String, required: true },\n description: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringRecommendation = InferRawDocType<\n typeof scoringRecommendationSchema\n>;\n\n// ─── Scoring Rule Schema ─────────────────────────────────────────────────────\n\nexport const scoringRuleSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Reference to Form (cross-db string, not ObjectId)\n formId: {\n type: String,\n required: true,\n },\n formVersion: {\n type: String,\n required: true,\n },\n\n // Rule info\n name: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n appScope: {\n type: [String],\n enum: [\"thread\", \"pave\", \"both\"],\n default: [],\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n effectiveDate: {\n type: Date,\n },\n deprecatedDate: {\n type: Date,\n },\n replacedBy: {\n type: String,\n },\n\n // Scoring logic\n conditions: {\n type: [scoringConditionSchema],\n default: [],\n },\n thresholds: {\n type: [scoringThresholdSchema],\n default: [],\n },\n recommendations: {\n type: [scoringRecommendationSchema],\n default: [],\n },\n};\n\nexport const scoringRuleSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"scoringrules\",\n};\n\n/**\n * Build the ScoringRule schema.\n * @returns Mongoose Schema for ScoringRule\n */\nexport function buildScoringRuleSchema(): Schema {\n const schema = new Schema(\n scoringRuleSchemaDefinition,\n scoringRuleSchemaOptions,\n );\n\n // Compound unique: one rule name per form version\n schema.index(\n { formId: 1, formVersion: 1, version: 1, name: 1 },\n { unique: true },\n );\n\n // Lookup active rules for a form\n schema.index({ formId: 1, formVersion: 1, status: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _scoringRuleSchema = buildScoringRuleSchema();\n\nexport type ScoringRule = InferRawDocType<typeof _scoringRuleSchema>;\n","/**\n * @htilabs/platform-common-models — PlatformFunction Model\n *\n * Factory for creating PlatformFunction model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildPlatformFunctionSchema,\n type PlatformFunction,\n} from \"../schemas/platform-function.js\";\n\nexport type PlatformFunctionDoc = HydratedDocument<PlatformFunction>;\n\n/**\n * Build the PlatformFunction schema.\n * @returns Mongoose Schema for PlatformFunction\n */\nexport { buildPlatformFunctionSchema as buildSchema };\n\n/**\n * Compile the PlatformFunction model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildPlatformFunctionSchema() if not provided)\n * @returns Mongoose Model for PlatformFunction\n */\nexport function compileModel(\n connection: Connection,\n schema = buildPlatformFunctionSchema(),\n): Model<PlatformFunction> {\n return connection.model<PlatformFunction>(\"PlatformFunction\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Platform Function Schema\n *\n * Mongoose schema for the `platformFunctions` collection.\n * Each document represents a discrete action that can be performed\n * within the platform, with tool scope and admin/user relevance flags.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\nimport {\n PLATFORM_TOOL_VALUES,\n FUNCTION_STATUS_VALUES,\n} from \"../constants/platform-auth.js\";\n\n// ─── Schema Definition ──────────────────────────────────────────────\n\nexport const platformFunctionSchemaDefinition = {\n code: {\n type: String,\n required: true,\n },\n label: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n default: \"\",\n },\n category: {\n type: String,\n default: \"\",\n },\n tools: {\n type: [String],\n enum: [...PLATFORM_TOOL_VALUES],\n default: [],\n },\n isAdminRelevant: {\n type: Boolean,\n default: false,\n },\n isUserRelevant: {\n type: Boolean,\n default: false,\n },\n isHtiOnly: {\n type: Boolean,\n default: false,\n },\n status: {\n type: String,\n enum: [...FUNCTION_STATUS_VALUES],\n default: \"Not started\",\n },\n sortOrder: {\n type: Number,\n default: 0,\n },\n};\n\nexport const platformFunctionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"platformFunctions\",\n};\n\n// ─── Schema Builder ─────────────────────────────────────────────────\n\n/**\n * Build the PlatformFunction schema.\n * @returns Mongoose Schema for PlatformFunction\n */\nexport function buildPlatformFunctionSchema(): Schema {\n const schema = new Schema(\n platformFunctionSchemaDefinition,\n platformFunctionSchemaOptions,\n );\n\n // Unique index on function code\n schema.index({ code: 1 }, { unique: true });\n\n // Lookup indexes\n schema.index({ tools: 1 });\n schema.index({ category: 1 });\n schema.index({ sortOrder: 1 });\n\n return schema;\n}\n\n// ─── Type Inference ─────────────────────────────────────────────────\n\nconst _platformFunctionSchema = buildPlatformFunctionSchema();\nexport type PlatformFunction = InferRawDocType<typeof _platformFunctionSchema>;\n","/**\n * @htilabs/platform-common-models — Platform Authorization Constants\n *\n * Enums and labels for the platform role/function permission model.\n * Includes permission states, share view levels, tool codes, role levels,\n * and function implementation statuses.\n *\n * Source: PLATFORM_AUTH_SPEC.md Sections 5 + 6\n */\n\n// ─── Permission State (4-state role→function mapping) ──────────────\n\nexport const PERMISSION_STATE = {\n /** Role can always perform this function (mandatory, cannot disable). */\n ALWAYS: \"ALWAYS\",\n /** Default On — user can opt off. */\n PREF_YES: \"PREF_YES\",\n /** Default Off — user can opt in. */\n PREF_NO: \"PREF_NO\",\n /** Role is explicitly barred from this function. */\n NEVER: \"NEVER\",\n} as const;\n\nexport type PermissionStateValue =\n (typeof PERMISSION_STATE)[keyof typeof PERMISSION_STATE];\n\nexport const PERMISSION_STATE_VALUES = [\n PERMISSION_STATE.ALWAYS,\n PERMISSION_STATE.PREF_YES,\n PERMISSION_STATE.PREF_NO,\n PERMISSION_STATE.NEVER,\n] as const;\n\nexport const PERMISSION_STATE_LABELS: Record<PermissionStateValue, string> = {\n [PERMISSION_STATE.ALWAYS]: \"Always\",\n [PERMISSION_STATE.PREF_YES]: \"Default On\",\n [PERMISSION_STATE.PREF_NO]: \"Default Off\",\n [PERMISSION_STATE.NEVER]: \"Never\",\n};\n\n/** UI display metadata for permission states (colors, icons). */\nexport const PERMISSION_STATE_DISPLAY: Record<\n PermissionStateValue,\n { label: string; color: string; bgColor: string; icon: string }\n> = {\n [PERMISSION_STATE.ALWAYS]: {\n label: \"Always\",\n color: \"#2e7d32\",\n bgColor: \"#e8f5e9\",\n icon: \"\\u{1F512}\",\n },\n [PERMISSION_STATE.PREF_YES]: {\n label: \"Default On\",\n color: \"#1565c0\",\n bgColor: \"#e3f2fd\",\n icon: \"\\u{1F513}\",\n },\n [PERMISSION_STATE.PREF_NO]: {\n label: \"Default Off\",\n color: \"#e65100\",\n bgColor: \"#fff3e0\",\n icon: \"\\u{1F513}\",\n },\n [PERMISSION_STATE.NEVER]: {\n label: \"Never\",\n color: \"#c62828\",\n bgColor: \"#ffebee\",\n icon: \"\\u{1F512}\",\n },\n};\n\n// ─── Share View (data visibility for shared records) ───────────────\n\nexport const SHARE_VIEW = {\n /** System metadata only (partial access). */\n SYS_INFO: \"sys_info\",\n /** Full case/record content. */\n ALL: \"all\",\n /** No data access. */\n NONE: \"none\",\n} as const;\n\nexport type ShareViewValue = (typeof SHARE_VIEW)[keyof typeof SHARE_VIEW];\n\nexport const SHARE_VIEW_VALUES = [\n SHARE_VIEW.SYS_INFO,\n SHARE_VIEW.ALL,\n SHARE_VIEW.NONE,\n] as const;\n\nexport const SHARE_VIEW_LABELS: Record<ShareViewValue, string> = {\n [SHARE_VIEW.SYS_INFO]: \"System Info Only\",\n [SHARE_VIEW.ALL]: \"Full Content\",\n [SHARE_VIEW.NONE]: \"No Data Access\",\n};\n\n// ─── Platform Tool Codes ───────────────────────────────────────────\n\nexport const PLATFORM_TOOL = {\n PAVE: \"PAVE\",\n ECHO: \"ECHO\",\n LEADS: \"LEADS\",\n THREAD: \"THREAD\",\n TRAIL: \"TRAIL\",\n PLATFORM: \"PLATFORM\",\n} as const;\n\nexport type PlatformToolValue =\n (typeof PLATFORM_TOOL)[keyof typeof PLATFORM_TOOL];\n\nexport const PLATFORM_TOOL_VALUES = [\n PLATFORM_TOOL.PAVE,\n PLATFORM_TOOL.ECHO,\n PLATFORM_TOOL.LEADS,\n PLATFORM_TOOL.THREAD,\n PLATFORM_TOOL.TRAIL,\n PLATFORM_TOOL.PLATFORM,\n] as const;\n\nexport const PLATFORM_TOOL_LABELS: Record<PlatformToolValue, string> = {\n [PLATFORM_TOOL.PAVE]: \"PAVE\",\n [PLATFORM_TOOL.ECHO]: \"Echo\",\n [PLATFORM_TOOL.LEADS]: \"LEADS\",\n [PLATFORM_TOOL.THREAD]: \"Thread\",\n [PLATFORM_TOOL.TRAIL]: \"Trail\",\n [PLATFORM_TOOL.PLATFORM]: \"Platform\",\n};\n\n// ─── Role Level (hierarchy tiers) ──────────────────────────────────\n\nexport const ROLE_LEVEL = {\n /** User-facing roles (staff, volunteers, practitioners). */\n OPERATIONAL: \"operational\",\n /** Agency-level admin roles. */\n AGENCY: \"agency\",\n /** Team-level admin roles. */\n TEAM: \"team\",\n /** HTI-wide platform admin. */\n PLATFORM: \"platform\",\n /** External governance/oversight roles. */\n OVERSIGHT: \"oversight\",\n} as const;\n\nexport type RoleLevelValue = (typeof ROLE_LEVEL)[keyof typeof ROLE_LEVEL];\n\nexport const ROLE_LEVEL_VALUES = [\n ROLE_LEVEL.OPERATIONAL,\n ROLE_LEVEL.AGENCY,\n ROLE_LEVEL.TEAM,\n ROLE_LEVEL.PLATFORM,\n ROLE_LEVEL.OVERSIGHT,\n] as const;\n\nexport const ROLE_LEVEL_LABELS: Record<RoleLevelValue, string> = {\n [ROLE_LEVEL.OPERATIONAL]: \"Operational\",\n [ROLE_LEVEL.AGENCY]: \"Agency\",\n [ROLE_LEVEL.TEAM]: \"Team\",\n [ROLE_LEVEL.PLATFORM]: \"Platform\",\n [ROLE_LEVEL.OVERSIGHT]: \"Oversight\",\n};\n\n// ─── Function Implementation Status ────────────────────────────────\n\nexport const FUNCTION_STATUS = {\n NOT_STARTED: \"Not started\",\n DEFINED_NEW: \"Defined; new function\",\n DEFINED_EXISTING: \"Defined; existing PAVE function\",\n FUNCTIONAL: \"Functional on all apps\",\n FUTURE: \"Future function (not v1)\",\n} as const;\n\nexport type FunctionStatusValue =\n (typeof FUNCTION_STATUS)[keyof typeof FUNCTION_STATUS];\n\nexport const FUNCTION_STATUS_VALUES = [\n FUNCTION_STATUS.NOT_STARTED,\n FUNCTION_STATUS.DEFINED_NEW,\n FUNCTION_STATUS.DEFINED_EXISTING,\n FUNCTION_STATUS.FUNCTIONAL,\n FUNCTION_STATUS.FUTURE,\n] as const;\n\nexport const FUNCTION_STATUS_LABELS: Record<FunctionStatusValue, string> = {\n [FUNCTION_STATUS.NOT_STARTED]: \"Not Started\",\n [FUNCTION_STATUS.DEFINED_NEW]: \"Defined (New)\",\n [FUNCTION_STATUS.DEFINED_EXISTING]: \"Defined (Existing PAVE)\",\n [FUNCTION_STATUS.FUNCTIONAL]: \"Functional\",\n [FUNCTION_STATUS.FUTURE]: \"Future (Not v1)\",\n};\n","/**\n * @htilabs/platform-common-models — PlatformRole Model\n *\n * Factory for creating PlatformRole model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildPlatformRoleSchema,\n type PlatformRole,\n} from \"../schemas/platform-role.js\";\n\nexport type PlatformRoleDoc = HydratedDocument<PlatformRole>;\n\n/**\n * Build the PlatformRole schema.\n * @returns Mongoose Schema for PlatformRole\n */\nexport { buildPlatformRoleSchema as buildSchema };\n\n/**\n * Compile the PlatformRole model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildPlatformRoleSchema() if not provided)\n * @returns Mongoose Model for PlatformRole\n */\nexport function compileModel(\n connection: Connection,\n schema = buildPlatformRoleSchema(),\n): Model<PlatformRole> {\n return connection.model<PlatformRole>(\"PlatformRole\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Platform Role Schema\n *\n * Mongoose schema for the `platformRoles` collection.\n * Each document represents a role that bundles function permissions,\n * tool scope, and share visibility settings.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\nimport {\n PLATFORM_TOOL_VALUES,\n ROLE_LEVEL_VALUES,\n SHARE_VIEW_VALUES,\n} from \"../constants/platform-auth.js\";\n\n// ─── Schema Definition ──────────────────────────────────────────────\n\nexport const platformRoleSchemaDefinition = {\n code: {\n type: String,\n required: true,\n },\n label: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n default: \"\",\n },\n level: {\n type: String,\n enum: [...ROLE_LEVEL_VALUES],\n required: true,\n },\n tools: {\n type: [String],\n enum: [...PLATFORM_TOOL_VALUES],\n default: [],\n },\n shareView: {\n type: String,\n enum: [...SHARE_VIEW_VALUES, null],\n default: null,\n },\n trainingRequirements: {\n type: String,\n default: null,\n },\n isHtiOnly: {\n type: Boolean,\n default: false,\n },\n /** Dynamic map of functionCode → PermissionStateValue. */\n functions: {\n type: Schema.Types.Mixed,\n default: {},\n },\n sortOrder: {\n type: Number,\n default: 0,\n },\n};\n\nexport const platformRoleSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"platformRoles\",\n};\n\n// ─── Schema Builder ─────────────────────────────────────────────────\n\n/**\n * Build the PlatformRole schema.\n * @returns Mongoose Schema for PlatformRole\n */\nexport function buildPlatformRoleSchema(): Schema {\n const schema = new Schema(\n platformRoleSchemaDefinition,\n platformRoleSchemaOptions,\n );\n\n // Unique index on role code\n schema.index({ code: 1 }, { unique: true });\n\n // Lookup indexes\n schema.index({ level: 1 });\n schema.index({ tools: 1 });\n schema.index({ isHtiOnly: 1 });\n\n return schema;\n}\n\n// ─── Type Inference ─────────────────────────────────────────────────\n\nconst _platformRoleSchema = buildPlatformRoleSchema();\nexport type PlatformRole = InferRawDocType<typeof _platformRoleSchema>;\n","/**\n * @htilabs/platform-common-models — CvcRegistry Model\n *\n * Factory for creating the CvcRegistry model bound to a specific connection.\n * Mirrors the buildSchema/compileModel pattern used by the other platform\n * models in this package (see `formModel.ts`, `questionModel.ts`).\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildCvcRegistrySchema,\n type CvcRegistry,\n} from \"../schemas/cvcRegistry.js\";\n\nexport type CvcRegistryDoc = HydratedDocument<CvcRegistry>;\n\n/**\n * Build the CvcRegistry schema.\n * @returns Mongoose Schema for CvcRegistry\n */\nexport { buildCvcRegistrySchema as buildSchema };\n\n/**\n * Compile the CvcRegistry model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildCvcRegistrySchema() if not provided)\n * @returns Mongoose Model for CvcRegistry\n */\nexport function compileModel(\n connection: Connection,\n schema = buildCvcRegistrySchema(),\n): Model<CvcRegistry> {\n return connection.models?.CvcRegistry as Model<CvcRegistry>\n ?? connection.model<CvcRegistry>(\"CvcRegistry\", schema);\n}\n","/**\n * @htilabs/platform-common-models — CVC Registry Schema\n *\n * A CVC Registry is a configuration bundle that pins specific versions of\n * each Controlled Vocabulary (CVC) domain for a given application/agency\n * scope. Consumers resolve \"which entries should I use right now?\" by\n * looking up the active registry for their scope, then loading the pinned\n * versions from `cvc_entries`.\n *\n * Locked spec reference:\n * §9.1 — Generalized CVC data layer in platform-common-models\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * Scope hierarchy (most specific wins at lookup time):\n * 1. (application, agencyId) — agency-specific override for an app\n * 2. (application, null) — app-wide default\n * 3. (null, null) — platform-wide default\n *\n * Lifecycle: a registry begins in `draft`, transitions to `active` (at most\n * one active per scope), and is eventually `deprecated` when superseded.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── CVC Registry Schema ─────────────────────────────────────────────────────\n\nexport const cvcRegistrySchemaDefinition = {\n // Versioning — semantic version of this registry bundle\n version: {\n type: String,\n required: true,\n match: /^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$/,\n },\n\n // Human-readable name (e.g. \"PAVE production registry\")\n name: {\n type: String,\n required: true,\n },\n\n // Scope keys. `null` widens scope: a null `application` means platform-wide;\n // a null `agencyId` means all agencies within `application`.\n application: {\n type: String,\n default: null,\n },\n agencyId: {\n type: Schema.Types.ObjectId,\n default: null,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n dateActivated: {\n type: Date,\n },\n dateDeactivated: {\n type: Date,\n },\n\n // Pinned domain versions: { service_categories: \"1.0.0\", ... }\n // Stored as a Map<string, string> so individual domains can be added or\n // bumped without re-validating the whole document shape.\n cvcVersions: {\n type: Map,\n of: String,\n required: true,\n default: () => new Map(),\n },\n\n // Selective inclusion/exclusion lists. Both contain CVC entry codes\n // (positional 7-segment, format v2: e.g. \"022-002-000-000-000-000-000\").\n // The runtime applies excludes after includes when resolving the effective\n // set.\n excludedEntries: {\n type: [String],\n default: [],\n },\n includedEntries: {\n type: [String],\n default: [],\n },\n\n // Inheritance pointer — when set, this registry inherits cvcVersions /\n // include / exclude lists from its base before applying its own overrides.\n // Indexed below so a base-version bump can find every dependent registry.\n basedOn: {\n type: Schema.Types.ObjectId,\n default: null,\n },\n};\n\nexport const cvcRegistrySchemaOptions = {\n timestamps: true,\n collection: \"cvc_registries\",\n};\n\n/**\n * Build the CvcRegistry schema with its full set of indexes.\n *\n * Indexes:\n * 1. `{ application, agencyId, version }` unique — primary identity. Two\n * registries in the same scope cannot share a version number.\n * 2. `{ application, agencyId, status }` partial — at most one `active`\n * registry per scope (enforced by the `status: \"active\"` partial filter).\n * 3. `{ basedOn }` — fast lookup of dependent registries when a base\n * registry is bumped or deprecated.\n *\n * @returns Mongoose Schema for CvcRegistry\n */\nexport function buildCvcRegistrySchema(): Schema {\n const schema = new Schema(\n cvcRegistrySchemaDefinition,\n cvcRegistrySchemaOptions,\n );\n\n // Primary identity: one (application, agencyId, version) tuple per registry\n schema.index(\n { application: 1, agencyId: 1, version: 1 },\n { unique: true },\n );\n\n // At most one `active` registry per scope. The partial filter ensures the\n // uniqueness constraint only applies to active rows; draft and deprecated\n // rows are unindexed by this index.\n schema.index(\n { application: 1, agencyId: 1, status: 1 },\n {\n unique: true,\n partialFilterExpression: { status: \"active\" },\n },\n );\n\n // Reverse-lookup for inheritance: \"what registries inherit from me?\"\n schema.index({ basedOn: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _cvcRegistrySchema = buildCvcRegistrySchema();\n\nexport type CvcRegistry = InferRawDocType<typeof _cvcRegistrySchema>;\n","/**\n * @htilabs/platform-common-models — CvcEntry Model\n *\n * Factory for creating the CvcEntry model bound to a specific connection.\n * Mirrors the buildSchema/compileModel pattern used by the other platform\n * models in this package (see `formModel.ts`, `questionModel.ts`).\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildCvcEntrySchema, type CvcEntry } from \"../schemas/cvcEntry.js\";\n\nexport type CvcEntryDoc = HydratedDocument<CvcEntry>;\n\n/**\n * Build the CvcEntry schema.\n * @returns Mongoose Schema for CvcEntry\n */\nexport { buildCvcEntrySchema as buildSchema };\n\n/**\n * Compile the CvcEntry model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildCvcEntrySchema() if not provided)\n * @returns Mongoose Model for CvcEntry\n */\nexport function compileModel(\n connection: Connection,\n schema = buildCvcEntrySchema(),\n): Model<CvcEntry> {\n return connection.models?.CvcEntry as Model<CvcEntry>\n ?? connection.model<CvcEntry>(\"CvcEntry\", schema);\n}\n","/**\n * @htilabs/platform-common-models — CVC Entry Schema\n *\n * Persistent storage for individual Controlled Vocabulary (CVC) entries.\n * Every entry is keyed by `(domain, version, code)` so that multiple\n * versions of a domain can coexist in the same collection — registries\n * pin which (domain, version) tuples are active for a given scope.\n *\n * Locked spec reference:\n * §9.1.2 — `cvc_entries` collection shape\n * §3 — Positional 7-segment code format\n * §3.2 — Stable machine key format\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * The Zod equivalents in `validation/cvc.ts` enforce the same shapes at the\n * application boundary; the Mongoose constraints below are the persistence\n * layer's defense in depth so that bad inserts fail loudly even if a caller\n * skipped Zod validation.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Shared validators ───────────────────────────────────────────────────────\n\n/**\n * Positional 7-segment CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (format v2,\n * 3-digit segments with a Notion-aligned domain prefix). Mirrors\n * `CvcCodeSchema` in `validation/cvc.ts`. See locked spec §3.\n */\nconst CVC_CODE_PATTERN = /^\\d{3}(-\\d{3}){6}$/;\n\n/**\n * Stable machine key for a CVC entry. Mirrors `CvcKeySchema` in\n * `validation/cvc.ts`. See locked spec §3.2.\n */\nconst CVC_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;\n\n// ─── CVC Entry Schema ────────────────────────────────────────────────────────\n\nexport const cvcEntrySchemaDefinition = {\n // Compound identity: (domain, version, code) uniquely identifies an entry.\n // `domain` is the SOT family (e.g. \"service_categories\"); `version` is the\n // semantic version of the SOT JSON file the entry was loaded from.\n domain: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n code: {\n type: String,\n required: true,\n match: CVC_CODE_PATTERN,\n },\n\n // Stable machine key for cross-CVC references (e.g. `relevantMechanisms`\n // in service_categories points at service_mechanisms entries by `key`).\n key: {\n type: String,\n required: true,\n match: CVC_KEY_PATTERN,\n },\n\n // Display fields\n title: {\n type: String,\n required: true,\n },\n\n // `selectable` distinguishes leaf entries (selectable) from structural\n // grouping rows (not selectable). Required because the seed CLI must\n // populate it explicitly — there is no sane default.\n selectable: {\n type: Boolean,\n required: true,\n },\n\n // Tree structure. `parentCode` is `null` for root rows; `childCodes` is\n // empty for leaves. We give `parentCode` a `default: null` (rather than\n // marking it required) because Mongoose's `required` validator rejects\n // `null` outright — the default ensures the field is always present on\n // disk while still allowing the documented `string | null` shape. The\n // `match` validator is skipped by Mongoose when the value is null.\n parentCode: {\n type: String,\n default: null,\n match: CVC_CODE_PATTERN,\n },\n childCodes: {\n type: [String],\n required: true,\n default: [],\n },\n\n // Long-form definition. Same `default: null` treatment as `parentCode`\n // above — every row reaches disk with `definition` set to either a\n // string or an explicit null.\n definition: {\n type: String,\n default: null,\n },\n\n // Domain-specific extension bag. Used for fields that only apply to a\n // particular CVC family — e.g. `relevantMechanisms` on service_categories\n // entries (a cross-CVC reference into service_mechanisms by key).\n meta: {\n type: Schema.Types.Mixed,\n },\n};\n\nexport const cvcEntrySchemaOptions = {\n timestamps: true,\n collection: \"cvc_entities\",\n // `parentCode` defaults to null but Mongoose strips required-with-default\n // null assignments unless we keep minimize off.\n minimize: false,\n};\n\n/**\n * Build the CvcEntry schema with its full set of indexes.\n *\n * Indexes:\n * 1. `{ domain, version, code }` unique — primary identity. The seed CLI\n * uses this for upsert keys.\n * 2. `{ domain, version, key }` unique — secondary lookup target for\n * cross-CVC references like `relevantMechanisms`.\n * 3. `{ domain, version, parentCode }` non-unique — supports tree walks\n * (\"give me the children of this code at this version\").\n *\n * @returns Mongoose Schema for CvcEntry\n */\nexport function buildCvcEntrySchema(): Schema {\n const schema = new Schema(cvcEntrySchemaDefinition, cvcEntrySchemaOptions);\n\n // Primary identity\n schema.index(\n { domain: 1, version: 1, code: 1 },\n { unique: true },\n );\n\n // Secondary lookup for cross-CVC references by stable key\n schema.index(\n { domain: 1, version: 1, key: 1 },\n { unique: true },\n );\n\n // Tree walks\n schema.index({ domain: 1, version: 1, parentCode: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _cvcEntrySchema = buildCvcEntrySchema();\n\nexport type CvcEntry = InferRawDocType<typeof _cvcEntrySchema>;\n","/**\n * @htilabs/platform-common-models — Models\n *\n * Mongoose model factories for platform models.\n * Each model exports buildSchema() and compileModel(connection) functions.\n *\n * Usage:\n * ```typescript\n * import { createPlatformModels } from '@htilabs/platform-common-models/models';\n * import mongoose from 'mongoose';\n *\n * const platformDb = mongoose.createConnection(PLATFORM_DB_URI);\n * const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);\n * ```\n */\n\nimport type { Connection, Model } from \"mongoose\";\n\n// Individual model factories\nimport * as formModel from \"./formModel.js\";\nimport * as sectionModel from \"./sectionModel.js\";\nimport * as questionModel from \"./questionModel.js\";\nimport * as scoringRuleModel from \"./scoringRuleModel.js\";\nimport * as platformFunctionModel from \"./platformFunctionModel.js\";\nimport * as platformRoleModel from \"./platformRoleModel.js\";\nimport * as cvcRegistryModel from \"./cvcRegistryModel.js\";\nimport * as cvcEntryModel from \"./cvcEntryModel.js\";\n\n// Re-export individual model factories\nexport {\n formModel,\n sectionModel,\n questionModel,\n scoringRuleModel,\n platformFunctionModel,\n platformRoleModel,\n cvcRegistryModel,\n cvcEntryModel,\n};\n\n// Re-export types\nexport type { FormDoc } from \"./formModel.js\";\nexport type { SectionDoc } from \"./sectionModel.js\";\nexport type { QuestionDoc } from \"./questionModel.js\";\nexport type { ScoringRuleDoc } from \"./scoringRuleModel.js\";\nexport type { PlatformFunctionDoc } from \"./platformFunctionModel.js\";\nexport type { PlatformRoleDoc } from \"./platformRoleModel.js\";\nexport type { CvcRegistryDoc } from \"./cvcRegistryModel.js\";\nexport type { CvcEntryDoc } from \"./cvcEntryModel.js\";\n\n// Re-export schema types\nexport type { Form } from \"../schemas/form.js\";\nexport type { Section } from \"../schemas/section.js\";\nexport type { Question } from \"../schemas/question.js\";\nexport type { ScoringRule } from \"../schemas/scoring-rule.js\";\nexport type { PlatformFunction } from \"../schemas/platform-function.js\";\nexport type { PlatformRole } from \"../schemas/platform-role.js\";\nexport type { CvcRegistry } from \"../schemas/cvcRegistry.js\";\nexport type { CvcEntry } from \"../schemas/cvcEntry.js\";\n\n/**\n * Platform models interface returned by createPlatformModels.\n */\nexport interface PlatformModels {\n FormModel: Model<import(\"../schemas/form.js\").Form>;\n SectionModel: Model<import(\"../schemas/section.js\").Section>;\n QuestionModel: Model<import(\"../schemas/question.js\").Question>;\n ScoringRuleModel: Model<import(\"../schemas/scoring-rule.js\").ScoringRule>;\n PlatformFunctionModel: Model<import(\"../schemas/platform-function.js\").PlatformFunction>;\n PlatformRoleModel: Model<import(\"../schemas/platform-role.js\").PlatformRole>;\n}\n\n/**\n * Create all platform models bound to a single connection.\n * Convenience function for apps that need all form-related models.\n *\n * @param connection - Mongoose connection to bind all models to\n * @returns Object with all compiled models\n *\n * @example\n * ```typescript\n * const platformDb = mongoose.createConnection(PLATFORM_DB_URI);\n * const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);\n *\n * const forms = await FormModel.find({ status: 'active' });\n * ```\n */\nexport function createPlatformModels(connection: Connection): PlatformModels {\n return {\n FormModel: formModel.compileModel(connection),\n SectionModel: sectionModel.compileModel(connection),\n QuestionModel: questionModel.compileModel(connection),\n ScoringRuleModel: scoringRuleModel.compileModel(connection),\n PlatformFunctionModel: platformFunctionModel.compileModel(connection),\n PlatformRoleModel: platformRoleModel.compileModel(connection),\n };\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,SAAS,cAAc;AAKhB,IAAM,uBAAuB,IAAI;AAAA,EACtC;AAAA,IACE,WAAW,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC1C,gBAAgB,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC/C,OAAO,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACtC,QAAQ,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IACxC,YAAY,EAAE,MAAM,OAAO;AAAA,IAC3B,OAAO,EAAE,MAAM,OAAO;AAAA,IACtB,aAAa,EAAE,MAAM,OAAO;AAAA,EAC9B;AAAA,EACA,EAAE,KAAK,MAAM;AACf;AAMO,IAAM,uBAAuB;AAAA,EAClC,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA;AAAA,EAGA,aAAa;AAAA,IACX,MAAM,OAAO,MAAM;AAAA,IACnB,UAAU;AAAA,IACV,OAAO;AAAA,EACT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AA,IAC5C,cAA2BC,cAAa,UAAU;AAAA,IAClD,eAA6BA,cAAa,UAAU;AAAA,IACpD,kBAAmCA,cAAa,UAAU;AAAA,IAC1D,uBAA6CA,cAAa,UAAU;AAAA,IACpE,mBAAqCA,cAAa,UAAU;AAAA,EAC9D;AACF;","names":["compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","Schema","compileModel","compileModel","Schema","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel"]}
1
+ {"version":3,"sources":["../../src/models/formModel.ts","../../src/schemas/form.ts","../../src/models/sectionModel.ts","../../src/schemas/section.ts","../../src/models/questionModel.ts","../../src/schemas/question.ts","../../src/models/scoringRuleModel.ts","../../src/schemas/scoring-rule.ts","../../src/models/platformFunctionModel.ts","../../src/schemas/platform-function.ts","../../src/constants/platform-auth.ts","../../src/models/platformRoleModel.ts","../../src/schemas/platform-role.ts","../../src/models/cvcRegistryModel.ts","../../src/schemas/cvcRegistry.ts","../../src/models/cvcEntryModel.ts","../../src/schemas/cvcEntry.ts","../../src/models/index.ts"],"sourcesContent":["/**\n * @htilabs/platform-common-models — Form Model\n *\n * Factory for creating Form model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildFormSchema, type Form } from \"../schemas/form.js\";\n\nexport type FormDoc = HydratedDocument<Form>;\n\n/**\n * Build the Form schema.\n * @returns Mongoose Schema for Form\n */\nexport { buildFormSchema as buildSchema };\n\n/**\n * Compile the Form model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildFormSchema() if not provided)\n * @returns Mongoose Model for Form\n */\nexport function compileModel(\n connection: Connection,\n schema = buildFormSchema(),\n): Model<Form> {\n return connection.model<Form>(\"Form\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Form Schema\n *\n * Versioned form definitions for screening, intake, and assessment forms.\n * Forms contain ordered references to sections with display metadata.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Form Section Reference Sub-Schema ───────────────────────────────────────\n\nexport const formSectionRefSchema = new Schema(\n {\n sectionId: { type: String, required: true },\n sectionVersion: { type: String, required: true },\n index: { type: Number, required: true },\n isStep: { type: Boolean, default: false },\n wizardStep: { type: Number },\n label: { type: String },\n presetsType: { type: String },\n },\n { _id: false },\n);\n\nexport type FormSectionRef = InferRawDocType<typeof formSectionRefSchema>;\n\n// ─── Form Schema ─────────────────────────────────────────────────────────────\n\nexport const formSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Form info\n name: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n },\n formType: {\n type: String,\n index: true,\n },\n appScope: {\n type: [String],\n enum: [\"thread\", \"pave\", \"both\"],\n default: [],\n },\n\n // Ordered sections\n sections: {\n type: [formSectionRefSchema],\n default: [],\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n};\n\nexport const formSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"forms\",\n};\n\n/**\n * Build the Form schema.\n * @returns Mongoose Schema for Form\n */\nexport function buildFormSchema(): Schema {\n const schema = new Schema(formSchemaDefinition, formSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _formSchema = buildFormSchema();\n\nexport type Form = InferRawDocType<typeof _formSchema>;\n","/**\n * @htilabs/platform-common-models — Section Model\n *\n * Factory for creating Section model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildSectionSchema, type Section } from \"../schemas/section.js\";\n\nexport type SectionDoc = HydratedDocument<Section>;\n\n/**\n * Build the Section schema.\n * @returns Mongoose Schema for Section\n */\nexport { buildSectionSchema as buildSchema };\n\n/**\n * Compile the Section model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildSectionSchema() if not provided)\n * @returns Mongoose Model for Section\n */\nexport function compileModel(\n connection: Connection,\n schema = buildSectionSchema(),\n): Model<Section> {\n return connection.model<Section>(\"Section\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Section Schema\n *\n * Logical grouping of questions within a form.\n * Sections contain ordered references to questions with display metadata.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Section Question Reference Sub-Schema ───────────────────────────────────\n\nexport const sectionQuestionRefSchema = new Schema(\n {\n questionId: { type: String, required: true },\n questionVersion: { type: String, required: true },\n index: { type: Number, required: true },\n },\n { _id: false },\n);\n\nexport type SectionQuestionRef = InferRawDocType<\n typeof sectionQuestionRefSchema\n>;\n\n// ─── Guidance Sub-Schema ─────────────────────────────────────────────────────\n\nexport const guidanceSchema = new Schema(\n {\n type: {\n type: String,\n required: true,\n enum: [\"tip\", \"warning\", \"prompt\"],\n },\n text: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type Guidance = InferRawDocType<typeof guidanceSchema>;\n\n// ─── Section Schema ──────────────────────────────────────────────────────────\n\nexport const sectionSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Section info\n name: {\n type: String,\n required: true,\n },\n directions: {\n type: String,\n },\n\n // Typed guidance items\n guidance: {\n type: [guidanceSchema],\n default: [],\n },\n\n // Ordered question refs\n questions: {\n type: [sectionQuestionRefSchema],\n default: [],\n },\n\n // Template visibility\n templateScope: {\n type: [String],\n default: undefined,\n },\n collapsible: {\n type: Boolean,\n default: false,\n },\n defaultCollapsed: {\n type: Boolean,\n default: false,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n\n // PAVE-aligned optional fields\n rephrasing: {\n type: String,\n },\n script: {\n type: String,\n },\n};\n\nexport const sectionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"sections\",\n};\n\n/**\n * Build the Section schema.\n * @returns Mongoose Schema for Section\n */\nexport function buildSectionSchema(): Schema {\n const schema = new Schema(sectionSchemaDefinition, sectionSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _sectionSchema = buildSectionSchema();\n\nexport type Section = InferRawDocType<typeof _sectionSchema>;\n","/**\n * @htilabs/platform-common-models — Question Model\n *\n * Factory for creating Question model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildQuestionSchema, type Question } from \"../schemas/question.js\";\n\nexport type QuestionDoc = HydratedDocument<Question>;\n\n/**\n * Build the Question schema.\n * @returns Mongoose Schema for Question\n */\nexport { buildQuestionSchema as buildSchema };\n\n/**\n * Compile the Question model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildQuestionSchema() if not provided)\n * @returns Mongoose Model for Question\n */\nexport function compileModel(\n connection: Connection,\n schema = buildQuestionSchema(),\n): Model<Question> {\n return connection.model<Question>(\"Question\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Question Schema\n *\n * Individual form fields with validation, choices, visibility rules, and scoring.\n * Questions support static and dynamic choices, conditional visibility, and IC code mapping.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Choice Sub-Schema ───────────────────────────────────────────────────────\n\nexport const choiceSchema = new Schema(\n {\n val: { type: Schema.Types.Mixed, required: true },\n text: { type: String, required: true },\n tip: { type: String },\n trigger: { type: [String] },\n },\n { _id: false },\n);\n\nexport type Choice = InferRawDocType<typeof choiceSchema>;\n\n// ─── Visibility Rule Sub-Schema ──────────────────────────────────────────────\n\nexport const visibilityRuleSchema = new Schema(\n {\n dependsOn: { type: String, required: true },\n condition: {\n type: String,\n required: true,\n enum: [\"equals\", \"not_equals\", \"any_of\", \"in_range\"],\n },\n values: { type: [Schema.Types.Mixed], required: true },\n source: {\n type: String,\n enum: [\"form\", \"session\"],\n default: \"form\",\n },\n },\n { _id: false },\n);\n\nexport type VisibilityRule = InferRawDocType<typeof visibilityRuleSchema>;\n\n// ─── Layout Sub-Schema ───────────────────────────────────────────────────────\n\nexport const layoutSchema = new Schema(\n {\n columns: { type: Number, default: 1, min: 1, max: 4 },\n collapsible: { type: Boolean, default: false },\n groupKey: { type: String },\n },\n { _id: false },\n);\n\nexport type Layout = InferRawDocType<typeof layoutSchema>;\n\n// ─── Question Schema ─────────────────────────────────────────────────────────\n\nexport const questionSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Versioning\n key: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n\n // Question definition\n index: {\n type: Number,\n required: true,\n },\n text: {\n type: String,\n required: true,\n },\n format: {\n type: String,\n required: true,\n },\n sectionId: {\n type: String,\n required: true,\n },\n required: {\n type: Boolean,\n default: false,\n },\n allowMultiple: {\n type: Boolean,\n default: false,\n },\n\n // Nesting\n isNested: {\n type: Boolean,\n default: false,\n },\n nested: {\n type: [String],\n default: [],\n },\n\n // Trigger logic\n isTriggered: {\n type: Boolean,\n default: false,\n },\n triggersWhenAnswered: {\n type: [String],\n default: [],\n },\n\n // Display\n header: { type: String },\n directions: { type: String },\n tip: { type: String },\n\n // Dynamic choices\n hasDynamicChoices: {\n type: Boolean,\n default: false,\n },\n dynamicChoiceSet: { type: String },\n group: { type: String },\n\n // Static choices\n choices: {\n type: [choiceSchema],\n default: [],\n },\n\n // UI rendering hints\n componentProps: {\n type: Schema.Types.Mixed,\n },\n\n // Autofill\n autofillRules: {\n type: Schema.Types.Mixed,\n default: [],\n },\n\n // Classification\n formType: {\n type: [String],\n enum: [\"screening\", \"intake\", \"assessment\", \"demographics\"],\n default: [],\n },\n icCode: {\n type: String,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n supersedes: {\n type: String,\n },\n\n // Entity mapping (dual-write bridge)\n targetEntity: {\n type: String,\n enum: [\n \"caseSession\",\n \"protectedPerson\",\n \"perpetratorPerson\",\n \"personnelPerson\",\n \"caseRecord\",\n \"serviceInstance\",\n ],\n },\n targetField: {\n type: String,\n },\n\n // Conditional visibility\n visibilityRule: {\n type: visibilityRuleSchema,\n },\n\n // Layout hints\n layout: {\n type: layoutSchema,\n },\n microcopy: {\n type: String,\n },\n sensitivity: {\n type: String,\n enum: [\"standard\", \"sensitive\", \"highly_sensitive\"],\n },\n\n // Scoring group\n scoringGroup: {\n type: String,\n },\n\n // PAVE-aligned optional fields\n groups: {\n type: [String],\n default: undefined,\n },\n rephrasingSelector: {\n type: Schema.Types.Mixed,\n },\n textSelector: {\n type: Schema.Types.Mixed,\n },\n tipSelector: {\n type: Schema.Types.Mixed,\n },\n sortChoices: {\n type: Boolean,\n },\n isAllRequired: {\n type: Boolean,\n },\n itemLabel: {\n type: String,\n },\n prompts: {\n type: [String],\n default: undefined,\n },\n rephrasing: {\n type: String,\n },\n dynamicChoiceTrigger: {\n type: String,\n },\n};\n\nexport const questionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"questions\",\n};\n\n/**\n * Build the Question schema.\n * @returns Mongoose Schema for Question\n */\nexport function buildQuestionSchema(): Schema {\n const schema = new Schema(questionSchemaDefinition, questionSchemaOptions);\n\n // Compound unique: only one version of a given key\n schema.index({ key: 1, version: 1 }, { unique: true });\n\n // Partial unique: only one \"active\" document per key\n schema.index(\n { key: 1 },\n { unique: true, partialFilterExpression: { status: \"active\" } },\n );\n\n // Lookup by section + order\n schema.index({ sectionId: 1, index: 1 });\n\n // IC code lookup (sparse — many questions won't have an IC code)\n schema.index({ icCode: 1 }, { sparse: true });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _questionSchema = buildQuestionSchema();\n\nexport type Question = InferRawDocType<typeof _questionSchema>;\n","/**\n * @htilabs/platform-common-models — ScoringRule Model\n *\n * Factory for creating ScoringRule model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildScoringRuleSchema,\n type ScoringRule,\n} from \"../schemas/scoring-rule.js\";\n\nexport type ScoringRuleDoc = HydratedDocument<ScoringRule>;\n\n/**\n * Build the ScoringRule schema.\n * @returns Mongoose Schema for ScoringRule\n */\nexport { buildScoringRuleSchema as buildSchema };\n\n/**\n * Compile the ScoringRule model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildScoringRuleSchema() if not provided)\n * @returns Mongoose Model for ScoringRule\n */\nexport function compileModel(\n connection: Connection,\n schema = buildScoringRuleSchema(),\n): Model<ScoringRule> {\n return connection.model<ScoringRule>(\"ScoringRule\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Scoring Rule Schema\n *\n * Evaluation rules for screening and assessment instruments.\n * Defines conditions to evaluate, score thresholds, and risk level recommendations.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Scoring Condition Sub-Schema ────────────────────────────────────────────\n\nexport const scoringConditionSchema = new Schema(\n {\n questionKey: { type: String, required: true },\n operator: {\n type: String,\n required: true,\n enum: [\"eq\", \"ne\", \"in\", \"not_in\", \"gt\", \"gte\", \"lt\", \"lte\"],\n },\n value: { type: Schema.Types.Mixed, required: true },\n weight: { type: Number, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringCondition = InferRawDocType<typeof scoringConditionSchema>;\n\n// ─── Scoring Threshold Sub-Schema ────────────────────────────────────────────\n\nexport const scoringThresholdSchema = new Schema(\n {\n minScore: { type: Number, required: true },\n maxScore: { type: Number, required: true },\n riskLevel: { type: String, required: true },\n label: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringThreshold = InferRawDocType<typeof scoringThresholdSchema>;\n\n// ─── Scoring Recommendation Sub-Schema ───────────────────────────────────────\n\nexport const scoringRecommendationSchema = new Schema(\n {\n riskLevel: { type: String, required: true },\n action: { type: String, required: true },\n description: { type: String, required: true },\n },\n { _id: false },\n);\n\nexport type ScoringRecommendation = InferRawDocType<\n typeof scoringRecommendationSchema\n>;\n\n// ─── Scoring Rule Schema ─────────────────────────────────────────────────────\n\nexport const scoringRuleSchemaDefinition = {\n _schemaVersion: {\n type: Number,\n required: true,\n default: 1,\n },\n\n // Audit fields\n createdUser: {\n type: Schema.Types.ObjectId,\n required: true,\n index: true,\n },\n updatedUser: {\n type: Schema.Types.ObjectId,\n index: true,\n },\n\n // Reference to Form (cross-db string, not ObjectId)\n formId: {\n type: String,\n required: true,\n },\n formVersion: {\n type: String,\n required: true,\n },\n\n // Rule info\n name: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n appScope: {\n type: [String],\n enum: [\"thread\", \"pave\", \"both\"],\n default: [],\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n effectiveDate: {\n type: Date,\n },\n deprecatedDate: {\n type: Date,\n },\n replacedBy: {\n type: String,\n },\n\n // Scoring logic\n conditions: {\n type: [scoringConditionSchema],\n default: [],\n },\n thresholds: {\n type: [scoringThresholdSchema],\n default: [],\n },\n recommendations: {\n type: [scoringRecommendationSchema],\n default: [],\n },\n};\n\nexport const scoringRuleSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"scoringrules\",\n};\n\n/**\n * Build the ScoringRule schema.\n * @returns Mongoose Schema for ScoringRule\n */\nexport function buildScoringRuleSchema(): Schema {\n const schema = new Schema(\n scoringRuleSchemaDefinition,\n scoringRuleSchemaOptions,\n );\n\n // Compound unique: one rule name per form version\n schema.index(\n { formId: 1, formVersion: 1, version: 1, name: 1 },\n { unique: true },\n );\n\n // Lookup active rules for a form\n schema.index({ formId: 1, formVersion: 1, status: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _scoringRuleSchema = buildScoringRuleSchema();\n\nexport type ScoringRule = InferRawDocType<typeof _scoringRuleSchema>;\n","/**\n * @htilabs/platform-common-models — PlatformFunction Model\n *\n * Factory for creating PlatformFunction model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildPlatformFunctionSchema,\n type PlatformFunction,\n} from \"../schemas/platform-function.js\";\n\nexport type PlatformFunctionDoc = HydratedDocument<PlatformFunction>;\n\n/**\n * Build the PlatformFunction schema.\n * @returns Mongoose Schema for PlatformFunction\n */\nexport { buildPlatformFunctionSchema as buildSchema };\n\n/**\n * Compile the PlatformFunction model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildPlatformFunctionSchema() if not provided)\n * @returns Mongoose Model for PlatformFunction\n */\nexport function compileModel(\n connection: Connection,\n schema = buildPlatformFunctionSchema(),\n): Model<PlatformFunction> {\n return connection.model<PlatformFunction>(\"PlatformFunction\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Platform Function Schema\n *\n * Mongoose schema for the `platformFunctions` collection.\n * Each document represents a discrete action that can be performed\n * within the platform, with tool scope and admin/user relevance flags.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\nimport {\n PLATFORM_TOOL_VALUES,\n FUNCTION_STATUS_VALUES,\n} from \"../constants/platform-auth.js\";\n\n// ─── Schema Definition ──────────────────────────────────────────────\n\nexport const platformFunctionSchemaDefinition = {\n code: {\n type: String,\n required: true,\n },\n label: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n default: \"\",\n },\n category: {\n type: String,\n default: \"\",\n },\n tools: {\n type: [String],\n enum: [...PLATFORM_TOOL_VALUES],\n default: [],\n },\n isAdminRelevant: {\n type: Boolean,\n default: false,\n },\n isUserRelevant: {\n type: Boolean,\n default: false,\n },\n isHtiOnly: {\n type: Boolean,\n default: false,\n },\n status: {\n type: String,\n enum: [...FUNCTION_STATUS_VALUES],\n default: \"Not started\",\n },\n sortOrder: {\n type: Number,\n default: 0,\n },\n};\n\nexport const platformFunctionSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"platformFunctions\",\n};\n\n// ─── Schema Builder ─────────────────────────────────────────────────\n\n/**\n * Build the PlatformFunction schema.\n * @returns Mongoose Schema for PlatformFunction\n */\nexport function buildPlatformFunctionSchema(): Schema {\n const schema = new Schema(\n platformFunctionSchemaDefinition,\n platformFunctionSchemaOptions,\n );\n\n // Unique index on function code\n schema.index({ code: 1 }, { unique: true });\n\n // Lookup indexes\n schema.index({ tools: 1 });\n schema.index({ category: 1 });\n schema.index({ sortOrder: 1 });\n\n return schema;\n}\n\n// ─── Type Inference ─────────────────────────────────────────────────\n\nconst _platformFunctionSchema = buildPlatformFunctionSchema();\nexport type PlatformFunction = InferRawDocType<typeof _platformFunctionSchema>;\n","/**\n * @htilabs/platform-common-models — Platform Authorization Constants\n *\n * Enums and labels for the platform role/function permission model.\n * Includes permission states, share view levels, tool codes, role levels,\n * and function implementation statuses.\n *\n * Source: PLATFORM_AUTH_SPEC.md Sections 5 + 6\n */\n\n// ─── Permission State (4-state role→function mapping) ──────────────\n\nexport const PERMISSION_STATE = {\n /** Role can always perform this function (mandatory, cannot disable). */\n ALWAYS: \"ALWAYS\",\n /** Default On — user can opt off. */\n PREF_YES: \"PREF_YES\",\n /** Default Off — user can opt in. */\n PREF_NO: \"PREF_NO\",\n /** Role is explicitly barred from this function. */\n NEVER: \"NEVER\",\n} as const;\n\nexport type PermissionStateValue =\n (typeof PERMISSION_STATE)[keyof typeof PERMISSION_STATE];\n\nexport const PERMISSION_STATE_VALUES = [\n PERMISSION_STATE.ALWAYS,\n PERMISSION_STATE.PREF_YES,\n PERMISSION_STATE.PREF_NO,\n PERMISSION_STATE.NEVER,\n] as const;\n\nexport const PERMISSION_STATE_LABELS: Record<PermissionStateValue, string> = {\n [PERMISSION_STATE.ALWAYS]: \"Always\",\n [PERMISSION_STATE.PREF_YES]: \"Default On\",\n [PERMISSION_STATE.PREF_NO]: \"Default Off\",\n [PERMISSION_STATE.NEVER]: \"Never\",\n};\n\n/** UI display metadata for permission states (colors, icons). */\nexport const PERMISSION_STATE_DISPLAY: Record<\n PermissionStateValue,\n { label: string; color: string; bgColor: string; icon: string }\n> = {\n [PERMISSION_STATE.ALWAYS]: {\n label: \"Always\",\n color: \"#2e7d32\",\n bgColor: \"#e8f5e9\",\n icon: \"\\u{1F512}\",\n },\n [PERMISSION_STATE.PREF_YES]: {\n label: \"Default On\",\n color: \"#1565c0\",\n bgColor: \"#e3f2fd\",\n icon: \"\\u{1F513}\",\n },\n [PERMISSION_STATE.PREF_NO]: {\n label: \"Default Off\",\n color: \"#e65100\",\n bgColor: \"#fff3e0\",\n icon: \"\\u{1F513}\",\n },\n [PERMISSION_STATE.NEVER]: {\n label: \"Never\",\n color: \"#c62828\",\n bgColor: \"#ffebee\",\n icon: \"\\u{1F512}\",\n },\n};\n\n// ─── Share View (data visibility for shared records) ───────────────\n\nexport const SHARE_VIEW = {\n /** System metadata only (partial access). */\n SYS_INFO: \"sys_info\",\n /** Full case/record content. */\n ALL: \"all\",\n /** No data access. */\n NONE: \"none\",\n} as const;\n\nexport type ShareViewValue = (typeof SHARE_VIEW)[keyof typeof SHARE_VIEW];\n\nexport const SHARE_VIEW_VALUES = [\n SHARE_VIEW.SYS_INFO,\n SHARE_VIEW.ALL,\n SHARE_VIEW.NONE,\n] as const;\n\nexport const SHARE_VIEW_LABELS: Record<ShareViewValue, string> = {\n [SHARE_VIEW.SYS_INFO]: \"System Info Only\",\n [SHARE_VIEW.ALL]: \"Full Content\",\n [SHARE_VIEW.NONE]: \"No Data Access\",\n};\n\n// ─── Platform Tool Codes ───────────────────────────────────────────\n\nexport const PLATFORM_TOOL = {\n PAVE: \"PAVE\",\n ECHO: \"ECHO\",\n LEADS: \"LEADS\",\n THREAD: \"THREAD\",\n TRAIL: \"TRAIL\",\n PLATFORM: \"PLATFORM\",\n} as const;\n\nexport type PlatformToolValue =\n (typeof PLATFORM_TOOL)[keyof typeof PLATFORM_TOOL];\n\nexport const PLATFORM_TOOL_VALUES = [\n PLATFORM_TOOL.PAVE,\n PLATFORM_TOOL.ECHO,\n PLATFORM_TOOL.LEADS,\n PLATFORM_TOOL.THREAD,\n PLATFORM_TOOL.TRAIL,\n PLATFORM_TOOL.PLATFORM,\n] as const;\n\nexport const PLATFORM_TOOL_LABELS: Record<PlatformToolValue, string> = {\n [PLATFORM_TOOL.PAVE]: \"PAVE\",\n [PLATFORM_TOOL.ECHO]: \"Echo\",\n [PLATFORM_TOOL.LEADS]: \"LEADS\",\n [PLATFORM_TOOL.THREAD]: \"Thread\",\n [PLATFORM_TOOL.TRAIL]: \"Trail\",\n [PLATFORM_TOOL.PLATFORM]: \"Platform\",\n};\n\n// ─── Role Level (hierarchy tiers) ──────────────────────────────────\n\nexport const ROLE_LEVEL = {\n /** User-facing roles (staff, volunteers, practitioners). */\n OPERATIONAL: \"operational\",\n /** Agency-level admin roles. */\n AGENCY: \"agency\",\n /** Team-level admin roles. */\n TEAM: \"team\",\n /** HTI-wide platform admin. */\n PLATFORM: \"platform\",\n /** External governance/oversight roles. */\n OVERSIGHT: \"oversight\",\n} as const;\n\nexport type RoleLevelValue = (typeof ROLE_LEVEL)[keyof typeof ROLE_LEVEL];\n\nexport const ROLE_LEVEL_VALUES = [\n ROLE_LEVEL.OPERATIONAL,\n ROLE_LEVEL.AGENCY,\n ROLE_LEVEL.TEAM,\n ROLE_LEVEL.PLATFORM,\n ROLE_LEVEL.OVERSIGHT,\n] as const;\n\nexport const ROLE_LEVEL_LABELS: Record<RoleLevelValue, string> = {\n [ROLE_LEVEL.OPERATIONAL]: \"Operational\",\n [ROLE_LEVEL.AGENCY]: \"Agency\",\n [ROLE_LEVEL.TEAM]: \"Team\",\n [ROLE_LEVEL.PLATFORM]: \"Platform\",\n [ROLE_LEVEL.OVERSIGHT]: \"Oversight\",\n};\n\n// ─── Function Implementation Status ────────────────────────────────\n\nexport const FUNCTION_STATUS = {\n NOT_STARTED: \"Not started\",\n DEFINED_NEW: \"Defined; new function\",\n DEFINED_EXISTING: \"Defined; existing PAVE function\",\n FUNCTIONAL: \"Functional on all apps\",\n FUTURE: \"Future function (not v1)\",\n} as const;\n\nexport type FunctionStatusValue =\n (typeof FUNCTION_STATUS)[keyof typeof FUNCTION_STATUS];\n\nexport const FUNCTION_STATUS_VALUES = [\n FUNCTION_STATUS.NOT_STARTED,\n FUNCTION_STATUS.DEFINED_NEW,\n FUNCTION_STATUS.DEFINED_EXISTING,\n FUNCTION_STATUS.FUNCTIONAL,\n FUNCTION_STATUS.FUTURE,\n] as const;\n\nexport const FUNCTION_STATUS_LABELS: Record<FunctionStatusValue, string> = {\n [FUNCTION_STATUS.NOT_STARTED]: \"Not Started\",\n [FUNCTION_STATUS.DEFINED_NEW]: \"Defined (New)\",\n [FUNCTION_STATUS.DEFINED_EXISTING]: \"Defined (Existing PAVE)\",\n [FUNCTION_STATUS.FUNCTIONAL]: \"Functional\",\n [FUNCTION_STATUS.FUTURE]: \"Future (Not v1)\",\n};\n","/**\n * @htilabs/platform-common-models — PlatformRole Model\n *\n * Factory for creating PlatformRole model bound to a specific connection.\n * Follows the platform-common-services pattern with buildSchema/compileModel.\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildPlatformRoleSchema,\n type PlatformRole,\n} from \"../schemas/platform-role.js\";\n\nexport type PlatformRoleDoc = HydratedDocument<PlatformRole>;\n\n/**\n * Build the PlatformRole schema.\n * @returns Mongoose Schema for PlatformRole\n */\nexport { buildPlatformRoleSchema as buildSchema };\n\n/**\n * Compile the PlatformRole model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildPlatformRoleSchema() if not provided)\n * @returns Mongoose Model for PlatformRole\n */\nexport function compileModel(\n connection: Connection,\n schema = buildPlatformRoleSchema(),\n): Model<PlatformRole> {\n return connection.model<PlatformRole>(\"PlatformRole\", schema);\n}\n","/**\n * @htilabs/platform-common-models — Platform Role Schema\n *\n * Mongoose schema for the `platformRoles` collection.\n * Each document represents a role that bundles function permissions,\n * tool scope, and share visibility settings.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\nimport {\n PLATFORM_TOOL_VALUES,\n ROLE_LEVEL_VALUES,\n SHARE_VIEW_VALUES,\n} from \"../constants/platform-auth.js\";\n\n// ─── Schema Definition ──────────────────────────────────────────────\n\nexport const platformRoleSchemaDefinition = {\n code: {\n type: String,\n required: true,\n },\n label: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n default: \"\",\n },\n level: {\n type: String,\n enum: [...ROLE_LEVEL_VALUES],\n required: true,\n },\n tools: {\n type: [String],\n enum: [...PLATFORM_TOOL_VALUES],\n default: [],\n },\n shareView: {\n type: String,\n enum: [...SHARE_VIEW_VALUES, null],\n default: null,\n },\n trainingRequirements: {\n type: String,\n default: null,\n },\n isHtiOnly: {\n type: Boolean,\n default: false,\n },\n /** Dynamic map of functionCode → PermissionStateValue. */\n functions: {\n type: Schema.Types.Mixed,\n default: {},\n },\n sortOrder: {\n type: Number,\n default: 0,\n },\n};\n\nexport const platformRoleSchemaOptions = {\n timestamps: {\n createdAt: \"createdTime\",\n updatedAt: \"updatedTime\",\n },\n collection: \"platformRoles\",\n};\n\n// ─── Schema Builder ─────────────────────────────────────────────────\n\n/**\n * Build the PlatformRole schema.\n * @returns Mongoose Schema for PlatformRole\n */\nexport function buildPlatformRoleSchema(): Schema {\n const schema = new Schema(\n platformRoleSchemaDefinition,\n platformRoleSchemaOptions,\n );\n\n // Unique index on role code\n schema.index({ code: 1 }, { unique: true });\n\n // Lookup indexes\n schema.index({ level: 1 });\n schema.index({ tools: 1 });\n schema.index({ isHtiOnly: 1 });\n\n return schema;\n}\n\n// ─── Type Inference ─────────────────────────────────────────────────\n\nconst _platformRoleSchema = buildPlatformRoleSchema();\nexport type PlatformRole = InferRawDocType<typeof _platformRoleSchema>;\n","/**\n * @htilabs/platform-common-models — CvcRegistry Model\n *\n * Factory for creating the CvcRegistry model bound to a specific connection.\n * Mirrors the buildSchema/compileModel pattern used by the other platform\n * models in this package (see `formModel.ts`, `questionModel.ts`).\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport {\n buildCvcRegistrySchema,\n type CvcRegistry,\n} from \"../schemas/cvcRegistry.js\";\n\nexport type CvcRegistryDoc = HydratedDocument<CvcRegistry>;\n\n/**\n * Build the CvcRegistry schema.\n * @returns Mongoose Schema for CvcRegistry\n */\nexport { buildCvcRegistrySchema as buildSchema };\n\n/**\n * Compile the CvcRegistry model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildCvcRegistrySchema() if not provided)\n * @returns Mongoose Model for CvcRegistry\n */\nexport function compileModel(\n connection: Connection,\n schema = buildCvcRegistrySchema(),\n): Model<CvcRegistry> {\n return connection.models?.CvcRegistry as Model<CvcRegistry>\n ?? connection.model<CvcRegistry>(\"CvcRegistry\", schema);\n}\n","/**\n * @htilabs/platform-common-models — CVC Registry Schema\n *\n * A CVC Registry is a configuration bundle that pins specific versions of\n * each Controlled Vocabulary (CVC) domain for a given application/agency\n * scope. Consumers resolve \"which entries should I use right now?\" by\n * looking up the active registry for their scope, then loading the pinned\n * versions from `cvc_entries`.\n *\n * Locked spec reference:\n * §9.1 — Generalized CVC data layer in platform-common-models\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * Scope hierarchy (most specific wins at lookup time):\n * 1. (application, agencyId) — agency-specific override for an app\n * 2. (application, null) — app-wide default\n * 3. (null, null) — platform-wide default\n *\n * Lifecycle: a registry begins in `draft`, transitions to `active` (at most\n * one active per scope), and is eventually `deprecated` when superseded.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── CVC Registry Schema ─────────────────────────────────────────────────────\n\nexport const cvcRegistrySchemaDefinition = {\n // Versioning — semantic version of this registry bundle\n version: {\n type: String,\n required: true,\n match: /^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$/,\n },\n\n // Human-readable name (e.g. \"PAVE production registry\")\n name: {\n type: String,\n required: true,\n },\n\n // Scope keys. `null` widens scope: a null `application` means platform-wide;\n // a null `agencyId` means all agencies within `application`.\n application: {\n type: String,\n default: null,\n },\n agencyId: {\n type: Schema.Types.ObjectId,\n default: null,\n },\n\n // Lifecycle\n status: {\n type: String,\n required: true,\n enum: [\"draft\", \"active\", \"deprecated\"],\n default: \"draft\",\n index: true,\n },\n dateActivated: {\n type: Date,\n },\n dateDeactivated: {\n type: Date,\n },\n\n // Pinned domain versions: { service_categories: \"1.2.0\", ... }\n // Stored as a Map<string, string> so individual domains can be added or\n // bumped without re-validating the whole document shape.\n cvcVersions: {\n type: Map,\n of: String,\n required: true,\n default: () => new Map(),\n },\n\n // Selective inclusion/exclusion lists. Both contain CVC entry codes\n // (positional 7-segment, format v2: e.g. \"022-002-000-000-000-000-000\").\n // The runtime applies excludes after includes when resolving the effective\n // set.\n excludedEntries: {\n type: [String],\n default: [],\n },\n includedEntries: {\n type: [String],\n default: [],\n },\n\n // Inheritance pointer — when set, this registry inherits cvcVersions /\n // include / exclude lists from its base before applying its own overrides.\n // Indexed below so a base-version bump can find every dependent registry.\n basedOn: {\n type: Schema.Types.ObjectId,\n default: null,\n },\n};\n\nexport const cvcRegistrySchemaOptions = {\n timestamps: true,\n collection: \"cvc_registries\",\n};\n\n/**\n * Build the CvcRegistry schema with its full set of indexes.\n *\n * Indexes:\n * 1. `{ application, agencyId, version }` unique — primary identity. Two\n * registries in the same scope cannot share a version number.\n * 2. `{ application, agencyId, status }` partial — at most one `active`\n * registry per scope (enforced by the `status: \"active\"` partial filter).\n * 3. `{ basedOn }` — fast lookup of dependent registries when a base\n * registry is bumped or deprecated.\n *\n * @returns Mongoose Schema for CvcRegistry\n */\nexport function buildCvcRegistrySchema(): Schema {\n const schema = new Schema(\n cvcRegistrySchemaDefinition,\n cvcRegistrySchemaOptions,\n );\n\n // Primary identity: one (application, agencyId, version) tuple per registry\n schema.index(\n { application: 1, agencyId: 1, version: 1 },\n { unique: true },\n );\n\n // At most one `active` registry per scope. The partial filter ensures the\n // uniqueness constraint only applies to active rows; draft and deprecated\n // rows are unindexed by this index.\n schema.index(\n { application: 1, agencyId: 1, status: 1 },\n {\n unique: true,\n partialFilterExpression: { status: \"active\" },\n },\n );\n\n // Reverse-lookup for inheritance: \"what registries inherit from me?\"\n schema.index({ basedOn: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _cvcRegistrySchema = buildCvcRegistrySchema();\n\nexport type CvcRegistry = InferRawDocType<typeof _cvcRegistrySchema>;\n","/**\n * @htilabs/platform-common-models — CvcEntry Model\n *\n * Factory for creating the CvcEntry model bound to a specific connection.\n * Mirrors the buildSchema/compileModel pattern used by the other platform\n * models in this package (see `formModel.ts`, `questionModel.ts`).\n */\n\nimport type { Connection, Model, HydratedDocument } from \"mongoose\";\nimport { buildCvcEntrySchema, type CvcEntry } from \"../schemas/cvcEntry.js\";\n\nexport type CvcEntryDoc = HydratedDocument<CvcEntry>;\n\n/**\n * Build the CvcEntry schema.\n * @returns Mongoose Schema for CvcEntry\n */\nexport { buildCvcEntrySchema as buildSchema };\n\n/**\n * Compile the CvcEntry model on a specific connection.\n * @param connection - Mongoose connection to bind the model to\n * @param schema - Optional pre-built schema (uses buildCvcEntrySchema() if not provided)\n * @returns Mongoose Model for CvcEntry\n */\nexport function compileModel(\n connection: Connection,\n schema = buildCvcEntrySchema(),\n): Model<CvcEntry> {\n return connection.models?.CvcEntry as Model<CvcEntry>\n ?? connection.model<CvcEntry>(\"CvcEntry\", schema);\n}\n","/**\n * @htilabs/platform-common-models — CVC Entry Schema\n *\n * Persistent storage for individual Controlled Vocabulary (CVC) entries.\n * Every entry is keyed by `(domain, version, code)` so that multiple\n * versions of a domain can coexist in the same collection — registries\n * pin which (domain, version) tuples are active for a given scope.\n *\n * Locked spec reference:\n * §9.1.2 — `cvc_entries` collection shape\n * §3 — Positional 7-segment code format\n * §3.2 — Stable machine key format\n * /gt/docs/data/cvcs/CVC Implementation Spec 2780449faf8045258c67daab0f1c5569.md\n *\n * The Zod equivalents in `validation/cvc.ts` enforce the same shapes at the\n * application boundary; the Mongoose constraints below are the persistence\n * layer's defense in depth so that bad inserts fail loudly even if a caller\n * skipped Zod validation.\n */\n\nimport { Schema } from \"mongoose\";\nimport type { InferRawDocType } from \"mongoose\";\n\n// ─── Shared validators ───────────────────────────────────────────────────────\n\n/**\n * Positional 7-segment CVC code: `XXX-XXX-XXX-XXX-XXX-XXX-XXX` (format v2,\n * 3-digit segments with a Notion-aligned domain prefix). Mirrors\n * `CvcCodeSchema` in `validation/cvc.ts`. See locked spec §3.\n */\nconst CVC_CODE_PATTERN = /^\\d{3}(-\\d{3}){6}$/;\n\n/**\n * Stable machine key for a CVC entry. Mirrors `CvcKeySchema` in\n * `validation/cvc.ts`. See locked spec §3.2.\n */\nconst CVC_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;\n\n// ─── CVC Entry Schema ────────────────────────────────────────────────────────\n\nexport const cvcEntrySchemaDefinition = {\n // Compound identity: (domain, version, code) uniquely identifies an entry.\n // `domain` is the SOT family (e.g. \"service_categories\"); `version` is the\n // semantic version of the SOT JSON file the entry was loaded from.\n domain: {\n type: String,\n required: true,\n },\n version: {\n type: String,\n required: true,\n },\n code: {\n type: String,\n required: true,\n match: CVC_CODE_PATTERN,\n },\n\n // Stable machine key for cross-CVC references (e.g. `relevantMechanisms`\n // in service_categories points at service_mechanisms entries by `key`).\n key: {\n type: String,\n required: true,\n match: CVC_KEY_PATTERN,\n },\n\n // Display fields\n title: {\n type: String,\n required: true,\n },\n\n // `selectable` distinguishes leaf entries (selectable) from structural\n // grouping rows (not selectable). Required because the seed CLI must\n // populate it explicitly — there is no sane default.\n selectable: {\n type: Boolean,\n required: true,\n },\n\n // Tree structure. `parentCode` is `null` for root rows; `childCodes` is\n // empty for leaves. We give `parentCode` a `default: null` (rather than\n // marking it required) because Mongoose's `required` validator rejects\n // `null` outright — the default ensures the field is always present on\n // disk while still allowing the documented `string | null` shape. The\n // `match` validator is skipped by Mongoose when the value is null.\n parentCode: {\n type: String,\n default: null,\n match: CVC_CODE_PATTERN,\n },\n childCodes: {\n type: [String],\n required: true,\n default: [],\n },\n\n // Long-form definition. Same `default: null` treatment as `parentCode`\n // above — every row reaches disk with `definition` set to either a\n // string or an explicit null.\n definition: {\n type: String,\n default: null,\n },\n\n // Domain-specific extension bag. Used for fields that only apply to a\n // particular CVC family — e.g. `relevantMechanisms` on service_categories\n // entries (a cross-CVC reference into service_mechanisms by key).\n meta: {\n type: Schema.Types.Mixed,\n },\n};\n\nexport const cvcEntrySchemaOptions = {\n timestamps: true,\n collection: \"cvc_entities\",\n // `parentCode` defaults to null but Mongoose strips required-with-default\n // null assignments unless we keep minimize off.\n minimize: false,\n};\n\n/**\n * Build the CvcEntry schema with its full set of indexes.\n *\n * Indexes:\n * 1. `{ domain, version, code }` unique — primary identity. The seed CLI\n * uses this for upsert keys.\n * 2. `{ domain, version, key }` unique — secondary lookup target for\n * cross-CVC references like `relevantMechanisms`.\n * 3. `{ domain, version, parentCode }` non-unique — supports tree walks\n * (\"give me the children of this code at this version\").\n *\n * @returns Mongoose Schema for CvcEntry\n */\nexport function buildCvcEntrySchema(): Schema {\n const schema = new Schema(cvcEntrySchemaDefinition, cvcEntrySchemaOptions);\n\n // Primary identity\n schema.index(\n { domain: 1, version: 1, code: 1 },\n { unique: true },\n );\n\n // Secondary lookup for cross-CVC references by stable key\n schema.index(\n { domain: 1, version: 1, key: 1 },\n { unique: true },\n );\n\n // Tree walks\n schema.index({ domain: 1, version: 1, parentCode: 1 });\n\n return schema;\n}\n\n// Pre-built schema for type inference\nconst _cvcEntrySchema = buildCvcEntrySchema();\n\nexport type CvcEntry = InferRawDocType<typeof _cvcEntrySchema>;\n","/**\n * @htilabs/platform-common-models — Models\n *\n * Mongoose model factories for platform models.\n * Each model exports buildSchema() and compileModel(connection) functions.\n *\n * Usage:\n * ```typescript\n * import { createPlatformModels } from '@htilabs/platform-common-models/models';\n * import mongoose from 'mongoose';\n *\n * const platformDb = mongoose.createConnection(PLATFORM_DB_URI);\n * const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);\n * ```\n */\n\nimport type { Connection, Model } from \"mongoose\";\n\n// Individual model factories\nimport * as formModel from \"./formModel.js\";\nimport * as sectionModel from \"./sectionModel.js\";\nimport * as questionModel from \"./questionModel.js\";\nimport * as scoringRuleModel from \"./scoringRuleModel.js\";\nimport * as platformFunctionModel from \"./platformFunctionModel.js\";\nimport * as platformRoleModel from \"./platformRoleModel.js\";\nimport * as cvcRegistryModel from \"./cvcRegistryModel.js\";\nimport * as cvcEntryModel from \"./cvcEntryModel.js\";\n\n// Re-export individual model factories\nexport {\n formModel,\n sectionModel,\n questionModel,\n scoringRuleModel,\n platformFunctionModel,\n platformRoleModel,\n cvcRegistryModel,\n cvcEntryModel,\n};\n\n// Re-export types\nexport type { FormDoc } from \"./formModel.js\";\nexport type { SectionDoc } from \"./sectionModel.js\";\nexport type { QuestionDoc } from \"./questionModel.js\";\nexport type { ScoringRuleDoc } from \"./scoringRuleModel.js\";\nexport type { PlatformFunctionDoc } from \"./platformFunctionModel.js\";\nexport type { PlatformRoleDoc } from \"./platformRoleModel.js\";\nexport type { CvcRegistryDoc } from \"./cvcRegistryModel.js\";\nexport type { CvcEntryDoc } from \"./cvcEntryModel.js\";\n\n// Re-export schema types\nexport type { Form } from \"../schemas/form.js\";\nexport type { Section } from \"../schemas/section.js\";\nexport type { Question } from \"../schemas/question.js\";\nexport type { ScoringRule } from \"../schemas/scoring-rule.js\";\nexport type { PlatformFunction } from \"../schemas/platform-function.js\";\nexport type { PlatformRole } from \"../schemas/platform-role.js\";\nexport type { CvcRegistry } from \"../schemas/cvcRegistry.js\";\nexport type { CvcEntry } from \"../schemas/cvcEntry.js\";\n\n/**\n * Platform models interface returned by createPlatformModels.\n */\nexport interface PlatformModels {\n FormModel: Model<import(\"../schemas/form.js\").Form>;\n SectionModel: Model<import(\"../schemas/section.js\").Section>;\n QuestionModel: Model<import(\"../schemas/question.js\").Question>;\n ScoringRuleModel: Model<import(\"../schemas/scoring-rule.js\").ScoringRule>;\n PlatformFunctionModel: Model<import(\"../schemas/platform-function.js\").PlatformFunction>;\n PlatformRoleModel: Model<import(\"../schemas/platform-role.js\").PlatformRole>;\n}\n\n/**\n * Create all platform models bound to a single connection.\n * Convenience function for apps that need all form-related models.\n *\n * @param connection - Mongoose connection to bind all models to\n * @returns Object with all compiled models\n *\n * @example\n * ```typescript\n * const platformDb = mongoose.createConnection(PLATFORM_DB_URI);\n * const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);\n *\n * const forms = await FormModel.find({ status: 'active' });\n * ```\n */\nexport function createPlatformModels(connection: Connection): PlatformModels {\n return {\n FormModel: formModel.compileModel(connection),\n SectionModel: sectionModel.compileModel(connection),\n QuestionModel: questionModel.compileModel(connection),\n ScoringRuleModel: scoringRuleModel.compileModel(connection),\n PlatformFunctionModel: platformFunctionModel.compileModel(connection),\n PlatformRoleModel: platformRoleModel.compileModel(connection),\n };\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,SAAS,cAAc;AAKhB,IAAM,uBAAuB,IAAI;AAAA,EACtC;AAAA,IACE,WAAW,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC1C,gBAAgB,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC/C,OAAO,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACtC,QAAQ,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IACxC,YAAY,EAAE,MAAM,OAAO;AAAA,IAC3B,OAAO,EAAE,MAAM,OAAO;AAAA,IACtB,aAAa,EAAE,MAAM,OAAO;AAAA,EAC9B;AAAA,EACA,EAAE,KAAK,MAAM;AACf;AAMO,IAAM,uBAAuB;AAAA,EAClC,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA;AAAA,EAGA,aAAa;AAAA,IACX,MAAM,OAAO,MAAM;AAAA,IACnB,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AAAA,IACX,MAAM,OAAO,MAAM;AAAA,IACnB,OAA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;AAAA,IACpD,kBAAmCA,cAAa,UAAU;AAAA,IAC1D,uBAA6CA,cAAa,UAAU;AAAA,IACpE,mBAAqCA,cAAa,UAAU;AAAA,EAC9D;AACF;","names":["compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","Schema","compileModel","compileModel","Schema","Schema","compileModel","compileModel","Schema","compileModel","compileModel","Schema","compileModel","compileModel"]}
@@ -4770,7 +4770,7 @@ var cvcRegistrySchemaDefinition = {
4770
4770
  dateDeactivated: {
4771
4771
  type: Date
4772
4772
  },
4773
- // Pinned domain versions: { service_categories: "1.0.0", ... }
4773
+ // Pinned domain versions: { service_categories: "1.2.0", ... }
4774
4774
  // Stored as a Map<string, string> so individual domains can be added or
4775
4775
  // bumped without re-validating the whole document shape.
4776
4776
  cvcVersions: {