pub.techne.draft.query.composeRecords

Up to 12 generic reads in one call. Each step is a pub.techne.draft.query.listRecords call (a list step) or a pub.techne.draft.query.getRecords call (a get step) and answers exactly as that method would for the same caller. A step runs once the steps it binds to have answered (at most 4 at once); the answer does not depend on which finished first. A binding, a string `$<step>.<output>` in a list step's `params` or among a get step's `uris`, stands for that output over the earlier step's records, deduplicated in the order first seen (possibly empty). Outputs: `uri`, `author`, `type`, `space`, `subject`, `references`, and `value.<path>` (string values only). A param may mix literals and bindings and stands for their union. A bound param is a list, so the query uses it with `in` on an indexed role; bind indexed outputs (they never hold a comma) rather than free text. A literal param may not start with `$`. A wrong shape refuses the whole call as InvalidRequest: more than 12 steps, a list step's `limit` over 50000, more than 500 literal `uris`, a `limit` or `cursor` on a `return: false` step. Once running, a step fails alone, its error under its name in `errors`: its method refuses it, a binding fills more than 500 `uris` or 2000 values, the steps read in one page answer more than 3000 records in all, a `return: false` step matches more than 50000, or the paged steps (a `limit` over 500, or `return: false`) read more than 50000 in all. Every step bound to a failed step is `Skipped`, naming the root failure; the others answer, and the call is 200. Budget: a signed-in caller has 20000 rows, refilled at 500 a second. A call is charged up front its declared maximum (a list step's `limit`, else its query's limit or 50, 500 for a `queryUri` or paged step; a get step's URIs, 500 if bound; at most 3000) plus 1000 per `count` step, is given back what it did not read, and is charged afterwards, into debt if need be, for what it read beyond that. A call the budget cannot cover now is RateLimitExceeded. Anonymous callers spend a budget per client IP (one shared budget ten times the size when the IP is unknown). `handles` and `curation` on a list step answer as getRecords does. The body must be application/json, else 415 before it is parsed or charged. A procedure only for its body size: nothing is written, and anyone may call it, signed in or not. Draft tier.

Details · procedure
Kindprocedure
Authorityquery.draft.techne.pub
Commit rev3n3iob7u4ow2u
Indexed
cid bafyreihhtpxapkiofnvt644lc7ok2dktmfkgmiqfqwsevivto3jesknsl4

Checks

Valid
JSONDownload
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Up to 12 generic reads in one call. Each step is a pub.techne.draft.query.listRecords call (a list step) or a pub.techne.draft.query.getRecords call (a get step) and answers exactly as that method would for the same caller. A step runs once the steps it binds to have answered (at most 4 at once); the answer does not depend on which finished first. A binding, a string `$<step>.<output>` in a list step's `params` or among a get step's `uris`, stands for that output over the earlier step's records, deduplicated in the order first seen (possibly empty). Outputs: `uri`, `author`, `type`, `space`, `subject`, `references`, and `value.<path>` (string values only). A param may mix literals and bindings and stands for their union. A bound param is a list, so the query uses it with `in` on an indexed role; bind indexed outputs (they never hold a comma) rather than free text. A literal param may not start with `$`. A wrong shape refuses the whole call as InvalidRequest: more than 12 steps, a list step's `limit` over 50000, more than 500 literal `uris`, a `limit` or `cursor` on a `return: false` step. Once running, a step fails alone, its error under its name in `errors`: its method refuses it, a binding fills more than 500 `uris` or 2000 values, the steps read in one page answer more than 3000 records in all, a `return: false` step matches more than 50000, or the paged steps (a `limit` over 500, or `return: false`) read more than 50000 in all. Every step bound to a failed step is `Skipped`, naming the root failure; the others answer, and the call is 200. Budget: a signed-in caller has 20000 rows, refilled at 500 a second. A call is charged up front its declared maximum (a list step's `limit`, else its query's limit or 50, 500 for a `queryUri` or paged step; a get step's URIs, 500 if bound; at most 3000) plus 1000 per `count` step, is given back what it did not read, and is charged afterwards, into debt if need be, for what it read beyond that. A call the budget cannot cover now is RateLimitExceeded. Anonymous callers spend a budget per client IP (one shared budget ten times the size when the IP is unknown). `handles` and `curation` on a list step answer as getRecords does. The body must be application/json, else 415 before it is parsed or charged. A procedure only for its body size: nothing is written, and anyone may call it, signed in or not. Draft tier.",
      "errors": [
        {
          "description": "HTTP 400. A malformed call, before any step runs (naming the step where there is one): no steps or more than 12, a name repeated or not of the pattern, a step that is neither a list step nor a get step or both, a binding to no earlier step or an unknown output, a list step's `limit` over 500, a get step's literal `uris` over 500, a malformed flag, `params`, `fields` or `envelope` (a name not among its known values). Also HTTP 415, under this name, for a body whose content-type is not application/json, refused before it is parsed or charged. What a step's method refuses is that step's error (`errors`), not the call's.",
          "name": "InvalidRequest"
        },
        {
          "description": "HTTP 429. A call whose charge (at most 15000) is more than what is left of its caller's row budget now: a signed-in caller's 20000 rows, refilled at 500 rows a second; an anonymous caller's the same per client IP, or, without a known client IP, the one budget all such callers share, ten times that size.",
          "name": "RateLimitExceeded"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "steps": {
              "description": "The steps. A binding names only an earlier step. A step runs as soon as the steps it binds to have answered, at most 4 at once, so the steps do not run in this order; the 3000-record cap is counted in this order.",
              "items": {
                "ref": "#step",
                "type": "ref"
              },
              "maxLength": 12,
              "minLength": 1,
              "type": "array"
            }
          },
          "required": [
            "steps"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "errors": {
              "description": "An object keyed by step name, each a #stepError: one for every step that failed or was skipped, returned or not. Absent when every step answered.",
              "type": "unknown"
            },
            "steps": {
              "description": "An object keyed by step name, each a #stepResult: one for every step whose `return` is not false.",
              "type": "unknown"
            }
          },
          "required": [
            "steps"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "record": {
      "description": "One answered record of a step: pub.techne.draft.query.listRecords#record with only `value` required. `uri` is present unless the step's `uri` is false; every other field is present as listRecords#record has it unless the step's `envelope` left it out; `fields` cuts `value`.",
      "properties": {
        "author": {
          "description": "The DID whose repo holds the record.",
          "format": "did",
          "type": "string"
        },
        "cid": {
          "format": "cid",
          "type": "string"
        },
        "collection": {
          "format": "nsid",
          "type": "string"
        },
        "curated": {
          "description": "A public record that is a live curated record: a curator the commons root trusts merged it from its sources, and it is not superseded. Its `pub.techne.draft.provenance` (same author, subject this record) names who it is from. Always answered when the step's `envelope` includes it (or names none): false for every other record.",
          "type": "boolean"
        },
        "held": {
          "description": "The caller's own permissioned record that the reach limit holds back from the people it would reach: a withheld act (a share or a circle add), answered to its author alone (to anyone else it is not found) until the limit admits it. Absent otherwise. A query with `held: true` answers only these.",
          "type": "boolean"
        },
        "matched": {
          "description": "As listRecords#record has it: with a `location` `in` or `covers` condition, the stated locations that matched, at most 8.",
          "items": {
            "ref": "pub.techne.draft.query.listRecords#matchedLocation",
            "type": "ref"
          },
          "maxLength": 8,
          "type": "array"
        },
        "measures": {
          "description": "The numbers the query's operators produced for this record, by name (a `near` distance in metres, a `matches` rank).",
          "type": "unknown"
        },
        "signals": {
          "description": "The server-side signals the query asked for, by name; a signal with no value for this record is absent.",
          "type": "unknown"
        },
        "source": {
          "description": "Whether the record is public (on the firehose) or permissioned.",
          "knownValues": [
            "public",
            "permissioned"
          ],
          "type": "string"
        },
        "space": {
          "description": "The space a permissioned record counts in. Absent for a public record, and for a caller's own record that counts in none.",
          "format": "at-uri",
          "type": "string"
        },
        "time": {
          "description": "The record's indexed time (the `written` role).",
          "format": "datetime",
          "type": "string"
        },
        "uri": {
          "format": "at-uri",
          "type": "string"
        },
        "value": {
          "description": "The record body.",
          "type": "unknown"
        }
      },
      "required": [
        "value"
      ],
      "type": "object"
    },
    "step": {
      "description": "One read. A list step has `query` or `queryUri` (and may have `params`, `limit`, `cursor`, `count`, `handles`, `curation`), as listRecords takes them; a get step has `uris` (and may have `curated`, `handles`, `curation`, `defaults`, `includeBlockedByMe`), as getRecords takes them. Exactly one of the two.",
      "properties": {
        "count": {
          "default": false,
          "description": "List step: also count, as listRecords' `count`.",
          "type": "boolean"
        },
        "curated": {
          "description": "Get step: as getRecords' `curated`.",
          "type": "boolean"
        },
        "curation": {
          "description": "As getRecords' `curation`: in a get step for its URIs, in a list step for the URIs of the records it answered.",
          "type": "boolean"
        },
        "cursor": {
          "description": "List step: the cursor of a previous page of this step, as listRecords' `cursor`. Not allowed on a `return: false` step.",
          "type": "string"
        },
        "defaults": {
          "description": "Get step: as getRecords' `defaults`.",
          "type": "boolean"
        },
        "envelope": {
          "description": "The record fields (#record) each answered record keeps besides `uri` (kept unless `uri` is false) and `value` (always kept): any of cid, author, collection, time, space, source, curated, held, measures, signals, matched and nothing else: the list is closed to these known values, and another name refuses the call as InvalidRequest. Without it every field comes back; `[]` keeps only `value` and, unless `uri` is false, `uri`. A field left out is absent, so a flag left out (`curated`, `held`) reads as false. Bindings read every field, before this selection.",
          "items": {
            "knownValues": [
              "cid",
              "author",
              "collection",
              "time",
              "space",
              "source",
              "curated",
              "held",
              "measures",
              "signals",
              "matched"
            ],
            "type": "string"
          },
          "maxLength": 11,
          "type": "array"
        },
        "fields": {
          "description": "Value paths (`a`, `a.b`, `a[].b`): each answered record's `value` keeps only these. Bindings read the whole value, before this selection. The record's other fields come back as `envelope` says, and its `uri` as `uri` says.",
          "items": {
            "maxLength": 256,
            "type": "string"
          },
          "maxLength": 32,
          "minLength": 1,
          "type": "array"
        },
        "handles": {
          "description": "As getRecords' `handles`: in a get step for its URIs, in a list step for the URIs of the records it answered.",
          "type": "boolean"
        },
        "includeBlockedByMe": {
          "description": "Get step: as getRecords' `includeBlockedByMe`.",
          "type": "boolean"
        },
        "limit": {
          "description": "List step: how many records, as listRecords' `limit`, up to 50000: past 500 (one listRecords page) the server reads listRecords' pages one after another on the same read path and answers them as one, with the `cursor` after the last record answered. Not allowed on a `return: false` step. The steps read past one page read at most 50000 records in all per call; the step whose page crosses that fails (InvalidRequest), and so does any such step that reads a page after it.",
          "maximum": 50000,
          "minimum": 1,
          "type": "integer"
        },
        "name": {
          "description": "The step's name, unique in the call: a letter, then up to 31 letters, digits or `_` (^[A-Za-z][A-Za-z0-9_]{0,31}$). The key of its result and the `<step>` of a binding to it.",
          "maxLength": 32,
          "minLength": 1,
          "type": "string"
        },
        "params": {
          "description": "List step: the query's parameters, an object of strings or lists of strings, as listRecords' `params` (an object here, not JSON in a string). A string `$<step>.<output>` is a binding and becomes a list; a list may mix literal strings and several bindings, and is their deduplicated union.",
          "type": "unknown"
        },
        "query": {
          "description": "List step: an inline pub.techne.draft.query object (not JSON in a string, as listRecords takes it). Give this or `queryUri`.",
          "type": "unknown"
        },
        "queryUri": {
          "description": "List step: a published pub.techne.draft.query record to run. Give this or `query`.",
          "format": "at-uri",
          "type": "string"
        },
        "return": {
          "default": true,
          "description": "False: the step's records only feed later bindings and are not in the output. A list step asked `return: false` is read in full on the server (every record its query matches for the caller, page after page on listRecords' read path), so a later step binds to all of it; it takes no `limit` or `cursor`, and a query that matches more than 50000 records fails the step (InvalidRequest naming the step and the ceiling), never answered in part.",
          "type": "boolean"
        },
        "uri": {
          "default": true,
          "description": "False: each answered record comes back without its `uri`, for a step whose records nobody reads by URI. Bindings read it, before this cut: `$<step>.uri` stands for the step's records' URIs either way. A get step's `resolved`, `curation` and `defaults` still name records by URI, so with `uri: false` they cannot be matched to the records answered.",
          "type": "boolean"
        },
        "uris": {
          "description": "Get step: the URIs to read, as getRecords' `uris`; each entry an AT-URI or a binding, which is replaced by its list. At most 500 after binding.",
          "items": {
            "type": "string"
          },
          "maxLength": 500,
          "minLength": 1,
          "type": "array"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "stepError": {
      "description": "Why a step has no result: what its method refused (as that method would answer it), `Skipped` (424) for a step that binds to a failed one (it may already have run; its answer is dropped), or InvalidRequest (400) for a step past a call limit: its bindings fill a get step's `uris` past 500 or a bound list past 2000 values, or its records would take the call past 3000 answered across the steps read in one page, counted in step order, or it is a list step asked `return: false` whose query matches more than 50000 records, or a page it read took the records read by the call's steps read past one page past 50000; or InternalError (500) for a step read past one page whose pages stop advancing (a cursor that comes back twice).",
      "properties": {
        "error": {
          "description": "The error name the step's method would answer (InvalidRequest, NotFound, ViewRequired and NotCurated for a list step, ...); InvalidRequest for a step past a call limit (#stepError); or `Skipped`: a step it binds to failed.",
          "type": "string"
        },
        "message": {
          "description": "What went wrong, naming the step; for `Skipped`, `step <name>: skipped because <failed step> failed`, naming the step that failed itself (the root of the chain).",
          "type": "string"
        },
        "status": {
          "description": "The HTTP status the step's method would answer alone; 400 for a step past a call limit (a get step's bound `uris` past 500, a bound list past 2000 values, the one-page steps' records past 3000, a `return: false` step matching past 50000, the call's paged reads past 50000); 424 for `Skipped`.",
          "type": "integer"
        }
      },
      "required": [
        "error",
        "message",
        "status"
      ],
      "type": "object"
    },
    "stepResult": {
      "description": "What the step's method answered: a list step's fields are listRecords' output, a get step's are getRecords' output.",
      "properties": {
        "capped": {
          "description": "List step, asked with `count`: as listRecords' `capped`.",
          "type": "boolean"
        },
        "count": {
          "description": "List step, asked with `count`: as listRecords' `count`.",
          "type": "integer"
        },
        "curation": {
          "description": "Asked with `curation`: as getRecords' `curation`.",
          "items": {
            "ref": "pub.techne.draft.query.getRecords#curation",
            "type": "ref"
          },
          "type": "array"
        },
        "cursor": {
          "description": "List step: as listRecords' `cursor`.",
          "type": "string"
        },
        "defaults": {
          "description": "Get step, asked with `defaults`: as getRecords' `defaults`.",
          "items": {
            "ref": "pub.techne.draft.query.getRecords#default",
            "type": "ref"
          },
          "type": "array"
        },
        "handles": {
          "description": "Asked with `handles`: as getRecords' `handles`.",
          "items": {
            "ref": "pub.techne.draft.query.getRecords#handle",
            "type": "ref"
          },
          "type": "array"
        },
        "notServedHere": {
          "description": "List step: as listRecords' `notServedHere` (an empty list with it set means \"not served here\", not \"nothing there\").",
          "ref": "pub.techne.draft.query.listRecords#notServedHere",
          "type": "ref"
        },
        "records": {
          "description": "As the step's method answers them, as #record: `value` always, `uri` unless the step's `uri` is false, every other record field unless the step's `envelope` left it out, and `value` cut to `fields` when given.",
          "items": {
            "ref": "#record",
            "type": "ref"
          },
          "type": "array"
        },
        "resolved": {
          "description": "Get step, asked with `curated`: as getRecords' `resolved`.",
          "items": {
            "ref": "pub.techne.draft.query.getRecords#resolved",
            "type": "ref"
          },
          "type": "array"
        },
        "withheld": {
          "description": "Get step: as getRecords' `withheld`.",
          "items": {
            "format": "at-uri",
            "type": "string"
          },
          "type": "array"
        }
      },
      "required": [
        "records"
      ],
      "type": "object"
    }
  },
  "id": "pub.techne.draft.query.composeRecords",
  "lexicon": 1
}