{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "baselineRange": {
      "properties": {
        "from": {
          "minimum": 0,
          "type": "integer"
        },
        "to": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "from",
        "to"
      ],
      "type": "object"
    },
    "itemSegment": {
      "description": "One chapter segment of a 'problem-by-problem' plan's item spec. Item identity is the (segment, number) pair, so numbering may restart per segment.",
      "properties": {
        "end": {
          "description": "Last item number in this segment (inclusive)",
          "minimum": 0,
          "type": "integer"
        },
        "excluded": {
          "description": "Item numbers excluded from generation",
          "items": {
            "minimum": 0,
            "type": "integer"
          },
          "maxLength": 100000,
          "type": "array"
        },
        "label": {
          "description": "Segment label, e.g. a chapter name. May be empty.",
          "maxLength": 300,
          "type": "string"
        },
        "start": {
          "description": "First item number in this segment",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "label",
        "start",
        "end"
      ],
      "type": "object"
    },
    "itemSpec": {
      "description": "Problem specification of a 'problem-by-problem' plan: unit label plus chapter segments.",
      "properties": {
        "segments": {
          "items": {
            "ref": "#itemSegment",
            "type": "ref"
          },
          "maxLength": 200,
          "minLength": 1,
          "type": "array"
        },
        "unit": {
          "description": "Item unit label, e.g. '問' or 'ページ'",
          "maxLength": 60,
          "type": "string"
        }
      },
      "required": [
        "unit",
        "segments"
      ],
      "type": "object"
    },
    "main": {
      "description": "A study plan with goals, scheduling, and progress tracking. rkey is the client's localId (see the `localId` property below), written via putRecord — this makes a retried push idempotent (a network-timeout retry overwrites the same rkey instead of creating a duplicate) rather than requiring the client to track which pushes already succeeded.",
      "key": "any",
      "record": {
        "properties": {
          "accent": {
            "description": "Accent color (hex code)",
            "maxLength": 7,
            "type": "string"
          },
          "ankiDeckId": {
            "description": "Dedicated flashcard deck id for a 'problem-by-problem' plan. Absent for standard plans; legacy clients drop it on rewrite and current clients restore it from the local copy.",
            "maxLength": 100,
            "type": "string"
          },
          "baselineDoneUnits": {
            "minimum": 0,
            "type": "integer"
          },
          "baselineRanges": {
            "items": {
              "ref": "#baselineRange",
              "type": "ref"
            },
            "maxLength": 1000,
            "type": "array"
          },
          "createdAt": {
            "description": "Plan creation date (YYYY-MM-DD)",
            "type": "string"
          },
          "currentRound": {
            "description": "Current round number",
            "minimum": 1,
            "type": "integer"
          },
          "dailyQuota": {
            "description": "Daily study quota (units per day)",
            "minimum": 1,
            "type": "integer"
          },
          "deadline": {
            "description": "Target completion date (YYYY-MM-DD)",
            "type": "string"
          },
          "difficulty": {
            "description": "Difficulty level",
            "knownValues": [
              "easy",
              "normal",
              "hard"
            ],
            "type": "string"
          },
          "doneUnits": {
            "description": "Units already completed",
            "minimum": 0,
            "type": "integer"
          },
          "dynamicDeadline": {
            "description": "Auto-calculated deadline date (YYYY-MM-DD), based on pace",
            "type": "string"
          },
          "expectedMinPerUnit": {
            "description": "Expected minutes required per unit",
            "type": "integer"
          },
          "expectedSecPerUnit": {
            "description": "Expected seconds per unit; optional for legacy records. expectedMinPerUnit remains the rounded minutes projection (minimum 1).",
            "minimum": 1,
            "type": "integer"
          },
          "generateReviewTasks": {
            "description": "Whether review tasks are auto-generated for this plan (default: true). Only written when explicitly false.",
            "type": "boolean"
          },
          "isbn": {
            "description": "ISBN of the tracked book. The cover image itself is never stored here; it is resolved on-device from this ISBN.",
            "maxLength": 20,
            "type": "string"
          },
          "isbnRemoved": {
            "type": "boolean"
          },
          "itemSpec": {
            "description": "Problem specification for a 'problem-by-problem' plan (generation source of truth). Absent for standard plans.",
            "ref": "#itemSpec",
            "type": "ref"
          },
          "localId": {
            "description": "Matches local StudyPlan.id and equals this record's own rkey (see the record-level description above).",
            "maxLength": 100,
            "type": "string"
          },
          "materialId": {
            "description": "Associated material ID if any",
            "maxLength": 100,
            "type": "string"
          },
          "maxDailyReviewUnits": {
            "minimum": 1,
            "type": "integer"
          },
          "maxDailyReviewUnitsRemoved": {
            "description": "復習上限を明示的に解除した印。旧版端末のフィールド省略と区別する。",
            "type": "boolean"
          },
          "pdsRkey": {
            "description": "Canonical migrated TID rkey. It points to a create-only copy while the legacy source record remains readable.",
            "format": "tid",
            "type": "string"
          },
          "problemTaskSkipDates": {
            "description": "Dates (YYYY-MM-DD) on which the synthesized daily task of a 'problem-by-problem' plan was skipped. Absent for standard plans; legacy clients drop it on rewrite and current clients restore it from the local copy.",
            "items": {
              "type": "string"
            },
            "maxLength": 400,
            "type": "array"
          },
          "recordOnly": {
            "description": "Whether this plan is a pure logging material without generated tasks",
            "type": "boolean"
          },
          "reviewCount": {
            "maximum": 5,
            "minimum": 1,
            "type": "integer"
          },
          "reviewIntervalDays": {
            "minimum": 1,
            "type": "integer"
          },
          "reviewLoadBalancing": {
            "description": "Use review-aware daily study allocation. Absent for legacy plans.",
            "type": "boolean"
          },
          "short": {
            "description": "Short title or abbreviation",
            "maxLength": 150,
            "type": "string"
          },
          "sortOrder": {
            "type": "integer"
          },
          "startUnit": {
            "description": "Starting unit number; zero is allowed for a not-yet-started plan",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "description": "Current plan status",
            "knownValues": [
              "active",
              "paused",
              "completed"
            ],
            "type": "string"
          },
          "studyDayWeights": {
            "items": {
              "minimum": 0,
              "type": "integer"
            },
            "maxLength": 7,
            "minLength": 7,
            "type": "array"
          },
          "studyDays": {
            "description": "Days of week to study (0=Sunday, 6=Saturday)",
            "items": {
              "maximum": 6,
              "minimum": 0,
              "type": "integer"
            },
            "maxLength": 7,
            "type": "array"
          },
          "studyIntervalDays": {
            "minimum": 1,
            "type": "integer"
          },
          "subjectId": {
            "description": "Associated subject ID if any",
            "maxLength": 100,
            "type": "string"
          },
          "subjectIdRemoved": {
            "description": "科目の明示的な解除印。フィールド欠落の旧版レコードと区別する。",
            "type": "boolean"
          },
          "subjectName": {
            "description": "Subject name snapshot",
            "maxLength": 300,
            "type": "string"
          },
          "targetRounds": {
            "description": "Target number of review rounds",
            "minimum": 1,
            "type": "integer"
          },
          "thumbnail": {
            "accept": [
              "image/*"
            ],
            "maxSize": 1000000,
            "type": "blob"
          },
          "title": {
            "description": "Plan title",
            "maxLength": 600,
            "type": "string"
          },
          "totalUnits": {
            "description": "Total number of units to complete",
            "minimum": 1,
            "type": "integer"
          },
          "unit": {
            "description": "Unit name (e.g., '章', 'pages')",
            "maxLength": 60,
            "type": "string"
          },
          "updatedAt": {
            "description": "Last update timestamp",
            "format": "datetime",
            "type": "string"
          }
        },
        "required": [
          "localId",
          "title",
          "short",
          "unit",
          "totalUnits",
          "doneUnits",
          "createdAt",
          "targetRounds",
          "currentRound",
          "dailyQuota",
          "expectedMinPerUnit",
          "difficulty",
          "studyDays",
          "status",
          "accent",
          "updatedAt"
        ],
        "type": "object"
      },
      "type": "record"
    }
  },
  "id": "app.studynext.plan",
  "lexicon": 1
}
