@htilabs/platform-common-models 0.1.0-beta.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.
- package/dist/constants/index.cjs +1379 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +528 -0
- package/dist/constants/index.d.ts +528 -0
- package/dist/constants/index.js +1252 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.cjs +2138 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1986 -0
- package/dist/index.js.map +1 -0
- package/dist/models/index.cjs +661 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.cts +204 -0
- package/dist/models/index.d.ts +204 -0
- package/dist/models/index.js +636 -0
- package/dist/models/index.js.map +1 -0
- package/dist/schemas/index.cjs +1405 -0
- package/dist/schemas/index.cjs.map +1 -0
- package/dist/schemas/index.d.cts +312 -0
- package/dist/schemas/index.d.ts +312 -0
- package/dist/schemas/index.js +1353 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/scoring-rule-BOkG46I3.d.cts +1179 -0
- package/dist/scoring-rule-BOkG46I3.d.ts +1179 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +81 -0
- package/src/constants/ic.ts +1630 -0
- package/src/constants/index.ts +11 -0
- package/src/index.ts +30 -0
- package/src/models/formModel.ts +30 -0
- package/src/models/index.ts +72 -0
- package/src/models/questionModel.ts +30 -0
- package/src/models/scoringRuleModel.ts +33 -0
- package/src/models/sectionModel.ts +30 -0
- package/src/schemas/common.ts +118 -0
- package/src/schemas/form.ts +125 -0
- package/src/schemas/index.ts +70 -0
- package/src/schemas/question.ts +297 -0
- package/src/schemas/scoring-rule.ts +169 -0
- package/src/schemas/section.ts +158 -0
- package/src/types/index.ts +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/models/index.ts","../../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"],"sourcesContent":["/**\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\";\n\n// Re-export individual model factories\nexport { formModel, sectionModel, questionModel, scoringRuleModel };\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\";\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\";\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}\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 };\n}\n","/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,sBAAuB;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;AAA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AqB,YAAwC;AAC3E,SAAO;AAAA,IACL,WAAqB,aAAa,UAAU;AAAA,IAC5C,cAA2BC,cAAa,UAAU;AAAA,IAClD,eAA6BA,cAAa,UAAU;AAAA,IACpD,kBAAmCA,cAAa,UAAU;AAAA,EAC5D;AACF;","names":["compileModel","import_mongoose","compileModel","compileModel","import_mongoose","compileModel","compileModel","import_mongoose","compileModel","compileModel"]}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { F as Form, g as buildFormSchema, e as Section, j as buildSectionSchema, Q as Question, h as buildQuestionSchema, c as ScoringRule, i as buildScoringRuleSchema } from '../scoring-rule-BOkG46I3.cjs';
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import { HydratedDocument, Connection, Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
type FormDoc = HydratedDocument<Form>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compile the Form model on a specific connection.
|
|
9
|
+
* @param connection - Mongoose connection to bind the model to
|
|
10
|
+
* @param schema - Optional pre-built schema (uses buildFormSchema() if not provided)
|
|
11
|
+
* @returns Mongoose Model for Form
|
|
12
|
+
*/
|
|
13
|
+
declare function compileModel$3(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
14
|
+
[x: number]: unknown;
|
|
15
|
+
[x: symbol]: unknown;
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
}, mongoose.Document<unknown, {}, {
|
|
18
|
+
[x: number]: unknown;
|
|
19
|
+
[x: symbol]: unknown;
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
}, {
|
|
22
|
+
id: string;
|
|
23
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
24
|
+
[x: number]: unknown;
|
|
25
|
+
[x: symbol]: unknown;
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
} & Required<{
|
|
28
|
+
_id: unknown;
|
|
29
|
+
}> & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}, "id"> & {
|
|
32
|
+
id: string;
|
|
33
|
+
}, unknown, {
|
|
34
|
+
[x: number]: {};
|
|
35
|
+
[x: symbol]: {};
|
|
36
|
+
[x: string]: {};
|
|
37
|
+
} & Required<{
|
|
38
|
+
_id: unknown;
|
|
39
|
+
}> & {
|
|
40
|
+
__v: number;
|
|
41
|
+
}>): Model<Form>;
|
|
42
|
+
|
|
43
|
+
type formModel_FormDoc = FormDoc;
|
|
44
|
+
declare namespace formModel {
|
|
45
|
+
export { type formModel_FormDoc as FormDoc, buildFormSchema as buildSchema, compileModel$3 as compileModel };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type SectionDoc = HydratedDocument<Section>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Compile the Section model on a specific connection.
|
|
52
|
+
* @param connection - Mongoose connection to bind the model to
|
|
53
|
+
* @param schema - Optional pre-built schema (uses buildSectionSchema() if not provided)
|
|
54
|
+
* @returns Mongoose Model for Section
|
|
55
|
+
*/
|
|
56
|
+
declare function compileModel$2(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
57
|
+
[x: number]: unknown;
|
|
58
|
+
[x: symbol]: unknown;
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
}, mongoose.Document<unknown, {}, {
|
|
61
|
+
[x: number]: unknown;
|
|
62
|
+
[x: symbol]: unknown;
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
}, {
|
|
65
|
+
id: string;
|
|
66
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
67
|
+
[x: number]: unknown;
|
|
68
|
+
[x: symbol]: unknown;
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
} & Required<{
|
|
71
|
+
_id: unknown;
|
|
72
|
+
}> & {
|
|
73
|
+
__v: number;
|
|
74
|
+
}, "id"> & {
|
|
75
|
+
id: string;
|
|
76
|
+
}, unknown, {
|
|
77
|
+
[x: number]: {};
|
|
78
|
+
[x: symbol]: {};
|
|
79
|
+
[x: string]: {};
|
|
80
|
+
} & Required<{
|
|
81
|
+
_id: unknown;
|
|
82
|
+
}> & {
|
|
83
|
+
__v: number;
|
|
84
|
+
}>): Model<Section>;
|
|
85
|
+
|
|
86
|
+
type sectionModel_SectionDoc = SectionDoc;
|
|
87
|
+
declare namespace sectionModel {
|
|
88
|
+
export { type sectionModel_SectionDoc as SectionDoc, buildSectionSchema as buildSchema, compileModel$2 as compileModel };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type QuestionDoc = HydratedDocument<Question>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Compile the Question model on a specific connection.
|
|
95
|
+
* @param connection - Mongoose connection to bind the model to
|
|
96
|
+
* @param schema - Optional pre-built schema (uses buildQuestionSchema() if not provided)
|
|
97
|
+
* @returns Mongoose Model for Question
|
|
98
|
+
*/
|
|
99
|
+
declare function compileModel$1(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
100
|
+
[x: number]: unknown;
|
|
101
|
+
[x: symbol]: unknown;
|
|
102
|
+
[x: string]: unknown;
|
|
103
|
+
}, mongoose.Document<unknown, {}, {
|
|
104
|
+
[x: number]: unknown;
|
|
105
|
+
[x: symbol]: unknown;
|
|
106
|
+
[x: string]: unknown;
|
|
107
|
+
}, {
|
|
108
|
+
id: string;
|
|
109
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
110
|
+
[x: number]: unknown;
|
|
111
|
+
[x: symbol]: unknown;
|
|
112
|
+
[x: string]: unknown;
|
|
113
|
+
} & Required<{
|
|
114
|
+
_id: unknown;
|
|
115
|
+
}> & {
|
|
116
|
+
__v: number;
|
|
117
|
+
}, "id"> & {
|
|
118
|
+
id: string;
|
|
119
|
+
}, unknown, {
|
|
120
|
+
[x: number]: {};
|
|
121
|
+
[x: symbol]: {};
|
|
122
|
+
[x: string]: {};
|
|
123
|
+
} & Required<{
|
|
124
|
+
_id: unknown;
|
|
125
|
+
}> & {
|
|
126
|
+
__v: number;
|
|
127
|
+
}>): Model<Question>;
|
|
128
|
+
|
|
129
|
+
type questionModel_QuestionDoc = QuestionDoc;
|
|
130
|
+
declare namespace questionModel {
|
|
131
|
+
export { type questionModel_QuestionDoc as QuestionDoc, buildQuestionSchema as buildSchema, compileModel$1 as compileModel };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type ScoringRuleDoc = HydratedDocument<ScoringRule>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Compile the ScoringRule model on a specific connection.
|
|
138
|
+
* @param connection - Mongoose connection to bind the model to
|
|
139
|
+
* @param schema - Optional pre-built schema (uses buildScoringRuleSchema() if not provided)
|
|
140
|
+
* @returns Mongoose Model for ScoringRule
|
|
141
|
+
*/
|
|
142
|
+
declare function compileModel(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
143
|
+
[x: number]: unknown;
|
|
144
|
+
[x: symbol]: unknown;
|
|
145
|
+
[x: string]: unknown;
|
|
146
|
+
}, mongoose.Document<unknown, {}, {
|
|
147
|
+
[x: number]: unknown;
|
|
148
|
+
[x: symbol]: unknown;
|
|
149
|
+
[x: string]: unknown;
|
|
150
|
+
}, {
|
|
151
|
+
id: string;
|
|
152
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
153
|
+
[x: number]: unknown;
|
|
154
|
+
[x: symbol]: unknown;
|
|
155
|
+
[x: string]: unknown;
|
|
156
|
+
} & Required<{
|
|
157
|
+
_id: unknown;
|
|
158
|
+
}> & {
|
|
159
|
+
__v: number;
|
|
160
|
+
}, "id"> & {
|
|
161
|
+
id: string;
|
|
162
|
+
}, unknown, {
|
|
163
|
+
[x: number]: {};
|
|
164
|
+
[x: symbol]: {};
|
|
165
|
+
[x: string]: {};
|
|
166
|
+
} & Required<{
|
|
167
|
+
_id: unknown;
|
|
168
|
+
}> & {
|
|
169
|
+
__v: number;
|
|
170
|
+
}>): Model<ScoringRule>;
|
|
171
|
+
|
|
172
|
+
type scoringRuleModel_ScoringRuleDoc = ScoringRuleDoc;
|
|
173
|
+
declare const scoringRuleModel_compileModel: typeof compileModel;
|
|
174
|
+
declare namespace scoringRuleModel {
|
|
175
|
+
export { type scoringRuleModel_ScoringRuleDoc as ScoringRuleDoc, buildScoringRuleSchema as buildSchema, scoringRuleModel_compileModel as compileModel };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Platform models interface returned by createPlatformModels.
|
|
180
|
+
*/
|
|
181
|
+
interface PlatformModels {
|
|
182
|
+
FormModel: Model<Form>;
|
|
183
|
+
SectionModel: Model<Section>;
|
|
184
|
+
QuestionModel: Model<Question>;
|
|
185
|
+
ScoringRuleModel: Model<ScoringRule>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create all platform models bound to a single connection.
|
|
189
|
+
* Convenience function for apps that need all form-related models.
|
|
190
|
+
*
|
|
191
|
+
* @param connection - Mongoose connection to bind all models to
|
|
192
|
+
* @returns Object with all compiled models
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const platformDb = mongoose.createConnection(PLATFORM_DB_URI);
|
|
197
|
+
* const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);
|
|
198
|
+
*
|
|
199
|
+
* const forms = await FormModel.find({ status: 'active' });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare function createPlatformModels(connection: Connection): PlatformModels;
|
|
203
|
+
|
|
204
|
+
export { Form, type FormDoc, type PlatformModels, Question, type QuestionDoc, ScoringRule, type ScoringRuleDoc, Section, type SectionDoc, createPlatformModels, formModel, questionModel, scoringRuleModel, sectionModel };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { F as Form, g as buildFormSchema, e as Section, j as buildSectionSchema, Q as Question, h as buildQuestionSchema, c as ScoringRule, i as buildScoringRuleSchema } from '../scoring-rule-BOkG46I3.js';
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import { HydratedDocument, Connection, Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
type FormDoc = HydratedDocument<Form>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Compile the Form model on a specific connection.
|
|
9
|
+
* @param connection - Mongoose connection to bind the model to
|
|
10
|
+
* @param schema - Optional pre-built schema (uses buildFormSchema() if not provided)
|
|
11
|
+
* @returns Mongoose Model for Form
|
|
12
|
+
*/
|
|
13
|
+
declare function compileModel$3(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
14
|
+
[x: number]: unknown;
|
|
15
|
+
[x: symbol]: unknown;
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
}, mongoose.Document<unknown, {}, {
|
|
18
|
+
[x: number]: unknown;
|
|
19
|
+
[x: symbol]: unknown;
|
|
20
|
+
[x: string]: unknown;
|
|
21
|
+
}, {
|
|
22
|
+
id: string;
|
|
23
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
24
|
+
[x: number]: unknown;
|
|
25
|
+
[x: symbol]: unknown;
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
} & Required<{
|
|
28
|
+
_id: unknown;
|
|
29
|
+
}> & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}, "id"> & {
|
|
32
|
+
id: string;
|
|
33
|
+
}, unknown, {
|
|
34
|
+
[x: number]: {};
|
|
35
|
+
[x: symbol]: {};
|
|
36
|
+
[x: string]: {};
|
|
37
|
+
} & Required<{
|
|
38
|
+
_id: unknown;
|
|
39
|
+
}> & {
|
|
40
|
+
__v: number;
|
|
41
|
+
}>): Model<Form>;
|
|
42
|
+
|
|
43
|
+
type formModel_FormDoc = FormDoc;
|
|
44
|
+
declare namespace formModel {
|
|
45
|
+
export { type formModel_FormDoc as FormDoc, buildFormSchema as buildSchema, compileModel$3 as compileModel };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type SectionDoc = HydratedDocument<Section>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Compile the Section model on a specific connection.
|
|
52
|
+
* @param connection - Mongoose connection to bind the model to
|
|
53
|
+
* @param schema - Optional pre-built schema (uses buildSectionSchema() if not provided)
|
|
54
|
+
* @returns Mongoose Model for Section
|
|
55
|
+
*/
|
|
56
|
+
declare function compileModel$2(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
57
|
+
[x: number]: unknown;
|
|
58
|
+
[x: symbol]: unknown;
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
}, mongoose.Document<unknown, {}, {
|
|
61
|
+
[x: number]: unknown;
|
|
62
|
+
[x: symbol]: unknown;
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
}, {
|
|
65
|
+
id: string;
|
|
66
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
67
|
+
[x: number]: unknown;
|
|
68
|
+
[x: symbol]: unknown;
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
} & Required<{
|
|
71
|
+
_id: unknown;
|
|
72
|
+
}> & {
|
|
73
|
+
__v: number;
|
|
74
|
+
}, "id"> & {
|
|
75
|
+
id: string;
|
|
76
|
+
}, unknown, {
|
|
77
|
+
[x: number]: {};
|
|
78
|
+
[x: symbol]: {};
|
|
79
|
+
[x: string]: {};
|
|
80
|
+
} & Required<{
|
|
81
|
+
_id: unknown;
|
|
82
|
+
}> & {
|
|
83
|
+
__v: number;
|
|
84
|
+
}>): Model<Section>;
|
|
85
|
+
|
|
86
|
+
type sectionModel_SectionDoc = SectionDoc;
|
|
87
|
+
declare namespace sectionModel {
|
|
88
|
+
export { type sectionModel_SectionDoc as SectionDoc, buildSectionSchema as buildSchema, compileModel$2 as compileModel };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type QuestionDoc = HydratedDocument<Question>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Compile the Question model on a specific connection.
|
|
95
|
+
* @param connection - Mongoose connection to bind the model to
|
|
96
|
+
* @param schema - Optional pre-built schema (uses buildQuestionSchema() if not provided)
|
|
97
|
+
* @returns Mongoose Model for Question
|
|
98
|
+
*/
|
|
99
|
+
declare function compileModel$1(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
100
|
+
[x: number]: unknown;
|
|
101
|
+
[x: symbol]: unknown;
|
|
102
|
+
[x: string]: unknown;
|
|
103
|
+
}, mongoose.Document<unknown, {}, {
|
|
104
|
+
[x: number]: unknown;
|
|
105
|
+
[x: symbol]: unknown;
|
|
106
|
+
[x: string]: unknown;
|
|
107
|
+
}, {
|
|
108
|
+
id: string;
|
|
109
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
110
|
+
[x: number]: unknown;
|
|
111
|
+
[x: symbol]: unknown;
|
|
112
|
+
[x: string]: unknown;
|
|
113
|
+
} & Required<{
|
|
114
|
+
_id: unknown;
|
|
115
|
+
}> & {
|
|
116
|
+
__v: number;
|
|
117
|
+
}, "id"> & {
|
|
118
|
+
id: string;
|
|
119
|
+
}, unknown, {
|
|
120
|
+
[x: number]: {};
|
|
121
|
+
[x: symbol]: {};
|
|
122
|
+
[x: string]: {};
|
|
123
|
+
} & Required<{
|
|
124
|
+
_id: unknown;
|
|
125
|
+
}> & {
|
|
126
|
+
__v: number;
|
|
127
|
+
}>): Model<Question>;
|
|
128
|
+
|
|
129
|
+
type questionModel_QuestionDoc = QuestionDoc;
|
|
130
|
+
declare namespace questionModel {
|
|
131
|
+
export { type questionModel_QuestionDoc as QuestionDoc, buildQuestionSchema as buildSchema, compileModel$1 as compileModel };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type ScoringRuleDoc = HydratedDocument<ScoringRule>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Compile the ScoringRule model on a specific connection.
|
|
138
|
+
* @param connection - Mongoose connection to bind the model to
|
|
139
|
+
* @param schema - Optional pre-built schema (uses buildScoringRuleSchema() if not provided)
|
|
140
|
+
* @returns Mongoose Model for ScoringRule
|
|
141
|
+
*/
|
|
142
|
+
declare function compileModel(connection: Connection, schema?: mongoose.Schema<any, Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
143
|
+
[x: number]: unknown;
|
|
144
|
+
[x: symbol]: unknown;
|
|
145
|
+
[x: string]: unknown;
|
|
146
|
+
}, mongoose.Document<unknown, {}, {
|
|
147
|
+
[x: number]: unknown;
|
|
148
|
+
[x: symbol]: unknown;
|
|
149
|
+
[x: string]: unknown;
|
|
150
|
+
}, {
|
|
151
|
+
id: string;
|
|
152
|
+
}, mongoose.DefaultSchemaOptions> & Omit<{
|
|
153
|
+
[x: number]: unknown;
|
|
154
|
+
[x: symbol]: unknown;
|
|
155
|
+
[x: string]: unknown;
|
|
156
|
+
} & Required<{
|
|
157
|
+
_id: unknown;
|
|
158
|
+
}> & {
|
|
159
|
+
__v: number;
|
|
160
|
+
}, "id"> & {
|
|
161
|
+
id: string;
|
|
162
|
+
}, unknown, {
|
|
163
|
+
[x: number]: {};
|
|
164
|
+
[x: symbol]: {};
|
|
165
|
+
[x: string]: {};
|
|
166
|
+
} & Required<{
|
|
167
|
+
_id: unknown;
|
|
168
|
+
}> & {
|
|
169
|
+
__v: number;
|
|
170
|
+
}>): Model<ScoringRule>;
|
|
171
|
+
|
|
172
|
+
type scoringRuleModel_ScoringRuleDoc = ScoringRuleDoc;
|
|
173
|
+
declare const scoringRuleModel_compileModel: typeof compileModel;
|
|
174
|
+
declare namespace scoringRuleModel {
|
|
175
|
+
export { type scoringRuleModel_ScoringRuleDoc as ScoringRuleDoc, buildScoringRuleSchema as buildSchema, scoringRuleModel_compileModel as compileModel };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Platform models interface returned by createPlatformModels.
|
|
180
|
+
*/
|
|
181
|
+
interface PlatformModels {
|
|
182
|
+
FormModel: Model<Form>;
|
|
183
|
+
SectionModel: Model<Section>;
|
|
184
|
+
QuestionModel: Model<Question>;
|
|
185
|
+
ScoringRuleModel: Model<ScoringRule>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create all platform models bound to a single connection.
|
|
189
|
+
* Convenience function for apps that need all form-related models.
|
|
190
|
+
*
|
|
191
|
+
* @param connection - Mongoose connection to bind all models to
|
|
192
|
+
* @returns Object with all compiled models
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const platformDb = mongoose.createConnection(PLATFORM_DB_URI);
|
|
197
|
+
* const { FormModel, SectionModel, QuestionModel, ScoringRuleModel } = createPlatformModels(platformDb);
|
|
198
|
+
*
|
|
199
|
+
* const forms = await FormModel.find({ status: 'active' });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare function createPlatformModels(connection: Connection): PlatformModels;
|
|
203
|
+
|
|
204
|
+
export { Form, type FormDoc, type PlatformModels, Question, type QuestionDoc, ScoringRule, type ScoringRuleDoc, Section, type SectionDoc, createPlatformModels, formModel, questionModel, scoringRuleModel, sectionModel };
|