autonomous intelligent information publishing - MVP

P3/grammar.json epoch 1

{
  "version": 1,
  "source_defaults": [
    {
      "entity": "FILES",
      "field": "TRASHED",
      "op": "IS",
      "value": "no",
      "rationale": "Drive hides trashed items by default, so counting them would disagree with what any Drive user sees."
    }
  ],
  "commands": {
    "LIST": {
      "description": "List rows of an entity, filterable and sortable."
    },
    "GET": {
      "description": "Fetch one record by its label field."
    },
    "COUNT": {
      "description": "Count rows, optionally grouped with BY."
    },
    "SUM": {
      "description": "Sum a numeric field, optionally grouped with BY."
    },
    "RESOLVE": {
      "description": "Fuzzy-resolve a name to its canonical value."
    },
    "HELP": {
      "description": "In-band context: HELP, HELP SCHEMA, HELP <ENTITY>."
    }
  },
  "operators": {
    "comparison": [
      "IS",
      "IS_NOT",
      "CONTAINS",
      "GT",
      "GTE",
      "LT",
      "LTE"
    ],
    "logical": [
      "AND",
      "OR"
    ]
  },
  "modifiers": [
    "ORDER BY",
    "LIMIT",
    "OFFSET",
    "BY"
  ],
  "subjects": {
    "COMMENTS": {
      "singular": "COMMENT",
      "table": "comments",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "FILE_ID": {
          "column": "file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "AUTHOR": {
          "column": "author",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "RESOLVED": {
          "column": "resolved",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "QUOTED_TEXT": {
          "column": "quoted_text",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "TEXT": {
          "column": "text",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "CREATED": {
          "column": "created",
          "type": "date",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "ID",
      "resolve_field": "ID",
      "relations": [
        {
          "field": "FILE_ID",
          "references": "FILES"
        }
      ]
    },
    "DRIVES": {
      "singular": "DRIVE",
      "table": "drives",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "NAME": {
          "column": "name",
          "type": "string",
          "enum_values": null,
          "role": "name"
        },
        "DRIVE_KIND": {
          "column": "drive_kind",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "CREATED": {
          "column": "created",
          "type": "date",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "NAME",
      "resolve_field": "NAME",
      "relations": []
    },
    "FILES": {
      "singular": "FILE",
      "table": "files",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "DRIVE_ID": {
          "column": "drive_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "PARENT_ID": {
          "column": "parent_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "PATH": {
          "column": "path",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "NAME": {
          "column": "name",
          "type": "string",
          "enum_values": null,
          "role": "name"
        },
        "DEPTH": {
          "column": "depth",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "IS_FOLDER": {
          "column": "is_folder",
          "type": "string",
          "enum_values": [
            "no",
            "yes"
          ],
          "role": null
        },
        "ITEM_KIND": {
          "column": "item_kind",
          "type": "string",
          "enum_values": [
            "document",
            "folder",
            "image",
            "pdf",
            "spreadsheet"
          ],
          "role": null
        },
        "MIME_TYPE": {
          "column": "mime_type",
          "type": "string",
          "enum_values": [
            "application/pdf",
            "application/vnd.google-apps.document",
            "application/vnd.google-apps.folder",
            "application/vnd.google-apps.spreadsheet",
            "image/png"
          ],
          "role": null
        },
        "SIZE_BYTES": {
          "column": "size_bytes",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "OWNER_EMAIL": {
          "column": "owner_email",
          "type": "string",
          "enum_values": [
            "alice@acme.com",
            "bob@acme.com",
            "carol@acme.com"
          ],
          "role": null
        },
        "CREATED": {
          "column": "created",
          "type": "date",
          "enum_values": null,
          "role": null
        },
        "MODIFIED": {
          "column": "modified",
          "type": "date",
          "enum_values": null,
          "role": null
        },
        "MODIFIED_BY": {
          "column": "modified_by",
          "type": "string",
          "enum_values": [
            "alice@acme.com",
            "bob@acme.com",
            "carol@acme.com",
            "dana@vendor.io"
          ],
          "role": null
        },
        "TRASHED": {
          "column": "trashed",
          "type": "string",
          "enum_values": [
            "no",
            "yes"
          ],
          "role": null
        },
        "STARRED": {
          "column": "starred",
          "type": "string",
          "enum_values": [
            "no",
            "yes"
          ],
          "role": null
        },
        "NAME_IS_UNIQUE": {
          "column": "name_is_unique",
          "type": "string",
          "enum_values": null,
          "role": "name"
        },
        "WORD_COUNT": {
          "column": "word_count",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "SECTION_COUNT": {
          "column": "section_count",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "CONTENT_HASH": {
          "column": "content_hash",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "EXTRACT_STATUS": {
          "column": "extract_status",
          "type": "string",
          "enum_values": [
            "exported_no_size",
            "extracted",
            "not_applicable",
            "unsupported_type"
          ],
          "role": null
        },
        "WEB_VIEW_LINK": {
          "column": "web_view_link",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "LINK_VISIBILITY": {
          "column": "link_visibility",
          "type": "string",
          "enum_values": [
            "anyone_with_link",
            "domain"
          ],
          "role": null
        },
        "SHARED_EXTERNALLY": {
          "column": "shared_externally",
          "type": "string",
          "enum_values": [
            "no",
            "yes"
          ],
          "role": null
        }
      },
      "label_field": "NAME",
      "resolve_field": "NAME",
      "relations": [
        {
          "field": "DRIVE_ID",
          "references": "DRIVES"
        }
      ]
    },
    "LABELS": {
      "singular": "LABEL",
      "table": "labels",
      "fields": {
        "FILE_ID": {
          "column": "file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "LABEL": {
          "column": "label",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "VALUE": {
          "column": "value",
          "type": "string",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "FILE_ID",
      "resolve_field": "FILE_ID",
      "relations": [
        {
          "field": "FILE_ID",
          "references": "FILES"
        }
      ]
    },
    "LINKS": {
      "singular": "LINK",
      "table": "links",
      "fields": {
        "SRC_FILE_ID": {
          "column": "src_file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "DST_FILE_ID": {
          "column": "dst_file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "LINK_TYPE": {
          "column": "link_type",
          "type": "string",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "SRC_FILE_ID",
      "resolve_field": "SRC_FILE_ID",
      "relations": []
    },
    "PERMISSIONS": {
      "singular": "PERMISSION",
      "table": "permissions",
      "fields": {
        "FILE_ID": {
          "column": "file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "PRINCIPAL": {
          "column": "principal",
          "type": "string",
          "enum_values": [
            "acme.com",
            "alice@acme.com",
            "anyone",
            "bob@acme.com",
            "carol@acme.com",
            "dana@vendor.io",
            "eng@acme.com"
          ],
          "role": "name"
        },
        "PRINCIPAL_TYPE": {
          "column": "principal_type",
          "type": "string",
          "enum_values": [
            "anyone",
            "domain",
            "group",
            "user"
          ],
          "role": null
        },
        "ROLE": {
          "column": "role",
          "type": "string",
          "enum_values": [
            "commenter",
            "organizer",
            "owner",
            "reader",
            "writer"
          ],
          "role": null
        },
        "INHERITED": {
          "column": "inherited",
          "type": "string",
          "enum_values": [
            "no",
            "yes"
          ],
          "role": null
        }
      },
      "label_field": "FILE_ID",
      "resolve_field": "FILE_ID",
      "relations": [
        {
          "field": "FILE_ID",
          "references": "FILES"
        },
        {
          "field": "PRINCIPAL",
          "references": "PRINCIPALS"
        }
      ]
    },
    "PRINCIPALS": {
      "singular": "PRINCIPAL",
      "table": "principals",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "PRINCIPAL_TYPE": {
          "column": "principal_type",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "DOMAIN": {
          "column": "domain",
          "type": "string",
          "enum_values": [
            "*",
            "acme.com",
            "vendor.io"
          ],
          "role": null
        }
      },
      "label_field": "ID",
      "resolve_field": "ID",
      "relations": []
    },
    "REVISIONS": {
      "singular": "REVISION",
      "table": "revisions",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "FILE_ID": {
          "column": "file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "REVISION_ID": {
          "column": "revision_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "MODIFIED": {
          "column": "modified",
          "type": "date",
          "enum_values": null,
          "role": null
        },
        "MODIFIED_BY": {
          "column": "modified_by",
          "type": "string",
          "enum_values": [
            "alice@acme.com",
            "bob@acme.com",
            "carol@acme.com"
          ],
          "role": null
        },
        "SIZE_BYTES": {
          "column": "size_bytes",
          "type": "integer",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "ID",
      "resolve_field": "ID",
      "relations": [
        {
          "field": "FILE_ID",
          "references": "FILES"
        }
      ]
    },
    "SECTIONS": {
      "singular": "SECTION",
      "table": "sections",
      "fields": {
        "ID": {
          "column": "id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "FILE_ID": {
          "column": "file_id",
          "type": "string",
          "enum_values": null,
          "role": "id"
        },
        "SECTION_INDEX": {
          "column": "section_index",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "HEADING": {
          "column": "heading",
          "type": "string",
          "enum_values": null,
          "role": null
        },
        "LEVEL": {
          "column": "level",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "CHAR_START": {
          "column": "char_start",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "CHAR_END": {
          "column": "char_end",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "WORD_COUNT": {
          "column": "word_count",
          "type": "integer",
          "enum_values": null,
          "role": null
        },
        "TEXT": {
          "column": "text",
          "type": "string",
          "enum_values": null,
          "role": null
        }
      },
      "label_field": "ID",
      "resolve_field": "ID",
      "relations": [
        {
          "field": "FILE_ID",
          "references": "FILES"
        }
      ]
    }
  },
  "vocabulary": {
    "DOCS": {
      "kind": "entity",
      "target": "FILES"
    }
  },
  "error_hints": {
    "confusable_fields": {
      "ID": [
        "COMMENTS",
        "DRIVES",
        "FILES",
        "PRINCIPALS",
        "REVISIONS",
        "SECTIONS"
      ],
      "FILE_ID": [
        "COMMENTS",
        "LABELS",
        "PERMISSIONS",
        "REVISIONS",
        "SECTIONS"
      ],
      "AUTHOR": [
        "COMMENTS"
      ],
      "RESOLVED": [
        "COMMENTS"
      ],
      "QUOTED_TEXT": [
        "COMMENTS"
      ],
      "TEXT": [
        "COMMENTS",
        "SECTIONS"
      ],
      "CREATED": [
        "COMMENTS",
        "DRIVES",
        "FILES"
      ],
      "NAME": [
        "DRIVES",
        "FILES"
      ],
      "DRIVE_KIND": [
        "DRIVES"
      ],
      "DRIVE_ID": [
        "FILES"
      ],
      "PARENT_ID": [
        "FILES"
      ],
      "PATH": [
        "FILES"
      ],
      "DEPTH": [
        "FILES"
      ],
      "IS_FOLDER": [
        "FILES"
      ],
      "ITEM_KIND": [
        "FILES"
      ],
      "MIME_TYPE": [
        "FILES"
      ],
      "SIZE_BYTES": [
        "FILES",
        "REVISIONS"
      ],
      "OWNER_EMAIL": [
        "FILES"
      ],
      "MODIFIED": [
        "FILES",
        "REVISIONS"
      ],
      "MODIFIED_BY": [
        "FILES",
        "REVISIONS"
      ],
      "TRASHED": [
        "FILES"
      ],
      "STARRED": [
        "FILES"
      ],
      "NAME_IS_UNIQUE": [
        "FILES"
      ],
      "WORD_COUNT": [
        "FILES",
        "SECTIONS"
      ],
      "SECTION_COUNT": [
        "FILES"
      ],
      "CONTENT_HASH": [
        "FILES"
      ],
      "EXTRACT_STATUS": [
        "FILES"
      ],
      "WEB_VIEW_LINK": [
        "FILES"
      ],
      "LINK_VISIBILITY": [
        "FILES"
      ],
      "SHARED_EXTERNALLY": [
        "FILES"
      ],
      "LABEL": [
        "LABELS"
      ],
      "VALUE": [
        "LABELS"
      ],
      "SRC_FILE_ID": [
        "LINKS"
      ],
      "DST_FILE_ID": [
        "LINKS"
      ],
      "LINK_TYPE": [
        "LINKS"
      ],
      "PRINCIPAL": [
        "PERMISSIONS"
      ],
      "PRINCIPAL_TYPE": [
        "PERMISSIONS",
        "PRINCIPALS"
      ],
      "ROLE": [
        "PERMISSIONS"
      ],
      "INHERITED": [
        "PERMISSIONS"
      ],
      "DOMAIN": [
        "PRINCIPALS"
      ],
      "REVISION_ID": [
        "REVISIONS"
      ],
      "SECTION_INDEX": [
        "SECTIONS"
      ],
      "HEADING": [
        "SECTIONS"
      ],
      "LEVEL": [
        "SECTIONS"
      ],
      "CHAR_START": [
        "SECTIONS"
      ],
      "CHAR_END": [
        "SECTIONS"
      ]
    }
  },
  "meta_config": {
    "related": {
      "LIST": [
        "COUNT {SUBJECT}",
        "COUNT {SUBJECT} BY {GROUP}"
      ],
      "GET": [
        "LIST {SUBJECT} LIMIT 10"
      ],
      "COUNT": [
        "SUM {SUBJECT} {NUMERIC} BY {GROUP}",
        "LIST {SUBJECT} LIMIT 10"
      ],
      "SUM": [
        "COUNT {SUBJECT} BY {GROUP}"
      ],
      "RESOLVE": [
        "GET {SUBJECT} \"<canonical name>\""
      ]
    }
  }
}

Back to instance