# com.lopecode.module

> A module version. A record is never rewritten; a new version is a new record whose prev names the one it follows.

- Kind: record
- Record key: tid
- Authority: lopecode.com
- Lexicon: 1
- Published by [larkworthy.bsky.social](https://lexicon.garden/identity/did:plc:j7nm3lrd5h7fm3sfhcv3lhfv), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:j7nm3lrd5h7fm3sfhcv3lhfv/com.lopecode.module)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:j7nm3lrd5h7fm3sfhcv3lhfv/com.lopecode.module/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:j7nm3lrd5h7fm3sfhcv3lhfv/com.lopecode.module/analytics)

## Record (`com.lopecode.module`)

Type: record · key tid

### Properties

- `attachments` (array, required): The files of the module.
  - `items` (ref)
    - Reference: `#fileEntry`
- `createdAt` (string · datetime, required)
- `id` (string, required): The module id, @user/name, e.g. @tomlarkworthy/brain-store.
  - Constraints: maxLength: 200
- `imports` (array, required): Each module the source imports, but the built-ins, pinned to a record.
  - `items` (ref)
    - Reference: `#import`
- `prev` (ref): The version this one follows.
  - Reference: `com.atproto.repo.strongRef`
- `source` (blob, required): The compiled module text, text/javascript. Its CID is v1 raw + sha-256.

## #fileEntry (`com.lopecode.module#fileEntry`)

Type: object

### Properties

- `blob` (blob, required): atproto blob ref: CID (v1 raw + sha-256), mimeType, size.
- `encoding` (string, required): How the file is held, e.g. text or base64.
- `name` (string, required): The file name, as the module's FileAttachment names it.
  - Constraints: maxLength: 1000

## #import (`com.lopecode.module#import`)

Type: object

### Properties

- `id` (string, required): The id of the imported module, @user/name.
  - Constraints: maxLength: 200
- `ref` (ref, required): The com.lopecode.module record of the imported version.
  - Reference: `com.atproto.repo.strongRef`

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "fileEntry": {
      "properties": {
        "blob": {
          "description": "atproto blob ref: CID (v1 raw + sha-256), mimeType, size.",
          "type": "blob"
        },
        "encoding": {
          "description": "How the file is held, e.g. text or base64.",
          "type": "string"
        },
        "name": {
          "description": "The file name, as the module's FileAttachment names it.",
          "maxLength": 1000,
          "type": "string"
        }
      },
      "required": [
        "name",
        "encoding",
        "blob"
      ],
      "type": "object"
    },
    "import": {
      "properties": {
        "id": {
          "description": "The id of the imported module, @user/name.",
          "maxLength": 200,
          "type": "string"
        },
        "ref": {
          "description": "The com.lopecode.module record of the imported version.",
          "ref": "com.atproto.repo.strongRef",
          "type": "ref"
        }
      },
      "required": [
        "id",
        "ref"
      ],
      "type": "object"
    },
    "main": {
      "description": "A module version. A record is never rewritten; a new version is a new record whose prev names the one it follows.",
      "key": "tid",
      "record": {
        "properties": {
          "attachments": {
            "description": "The files of the module.",
            "items": {
              "ref": "#fileEntry",
              "type": "ref"
            },
            "type": "array"
          },
          "createdAt": {
            "format": "datetime",
            "type": "string"
          },
          "id": {
            "description": "The module id, @user/name, e.g. @tomlarkworthy/brain-store.",
            "maxLength": 200,
            "type": "string"
          },
          "imports": {
            "description": "Each module the source imports, but the built-ins, pinned to a record.",
            "items": {
              "ref": "#import",
              "type": "ref"
            },
            "type": "array"
          },
          "prev": {
            "description": "The version this one follows.",
            "ref": "com.atproto.repo.strongRef",
            "type": "ref"
          },
          "source": {
            "description": "The compiled module text, text/javascript. Its CID is v1 raw + sha-256.",
            "type": "blob"
          }
        },
        "required": [
          "id",
          "source",
          "imports",
          "attachments",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    }
  },
  "description": "One version of an Observable module of lopecode: its compiled text, its files, and the versions of the modules it imports.",
  "id": "com.lopecode.module",
  "lexicon": 1
}
```
