definy
definy platform features written in definy, such as deploying to Cloudflare Workers · Public
Status: Done · Every branch of the project (change the status there)
definy.cloudflare-workers-runtime-script: String // The ES module (worker.js) uploaded with app.wasm. It runs the Wasm GC module with V8 through its exported runtime functions: when evaluate() returns a function, it passes the HTTP request and turns the returned { status, headers, body } into the response definy.cloudflare-service-runtime-script: String // (en) The ES module (worker.js) of a Cloudflare Worker that runs a definy server (definy.service-io) from app.wasm: evaluate() returns {fetch, scheduled}, and it does what the steps ask with the D1 binding DB, WebCrypto and fetch. A mirror has no seed bundle; definy.ensure-seeded only creates the tables (definy.deploy-service-worker, docs/html-ui.md) definy.cloudflare-service-upload-body: Fn(database_id: String, wasm: List<Number>) -> List<Number> // The multipart body that uploads a definy server Worker: worker.js (definy.cloudflare-service-runtime-script), app.wasm and the D1 binding DB (definy.deploy-service-worker) definy.deploy-service-script: Fn( worker_name: String, database_name: String, database_id: String, cron: String, api_token: Secret, script_url: String, wasm: List<Number> ) -> @wasi.io // (en) Uploads the Worker script of definy.deploy-service-worker with the D1 database database_id, clears the read cache of the runtime (the D1 table host_cache, whose entries depend on the definy code), sets the Cron trigger and enables workers.dev (ja) definy.deploy-service-worker の Worker のスクリプトを D1 のデータベース database_id と一緒にアップロードし, 土台の読み取りのキャッシュ (D1 の表 host_cache。中身は definy のコードで変わる) を消し, Cron を設定して workers.dev を有効にする definy.deploy-service-worker: Fn( worker_name: String, database_name: String, cron: String, api_token: Secret, handler: Code<Record{ fetch: Fn(request: @http.request) -> @definy.service-io, scheduled: Fn(time_ms: Number) -> @definy.service-io }> ) -> @wasi.io // (en) Deploys handler (fetch and scheduled of definy.service-io) as the Cloudflare Worker worker_name with its own D1 database database_name (created when missing) and the Cron trigger cron. The Worker runs with definy.cloudflare-service-runtime-script. api_token needs Workers Scripts Edit and D1 Edit (docs/html-ui.md) (ja) handler (definy.service-io の fetch と scheduled) を, 専用の D1 データベース database_name (無ければ作る) と Cron の cron を持つ Cloudflare Worker worker_name としてデプロイする。Worker は definy.cloudflare-service-runtime-script で動く。api_token には Workers Scripts の編集と D1 の編集の権限が要る (docs/html-ui.md) definy.cloudflare-workers-script-upload-body: Fn(wasm: List<Number>) -> List<Number> // The multipart/form-data body of the Cloudflare Workers script upload API (metadata, worker.js and app.wasm). The boundary is definy-deploy-boundary-5f0c3a definy.json-string-after: Fn(json: String, pattern: String) -> String // The text after the first pattern in json up to the next " ("" if not found) definy.json-string-field: Fn(json: String, key: String) -> String // The first string value of "key" in the JSON text ("" if not found). It accepts both "key":"value" and "key": "value" (pretty-printed JSON such as the Cloudflare API). It does not handle escapes definy.cloudflare-api-token: Secret // A Cloudflare account API token that can edit Workers Scripts (create it in the Cloudflare dashboard under Manage Account > Account API Tokens). The value stays in your browser and is sent only to https://api.cloudflare.com/ definy.deploy-to-cloudflare-workers: Fn( worker_name: String, api_token: Secret, handler: Code<Fn( req: Record{ method: String, url: String, headers: List<Record{name: String, value: String}>, body: Record{ initialState: Number, next: Fn(state: Number) -> Union{#yield(Record{chunk: List<Number>, nextState: Number}), #done} } } ) -> Record{ status: Number, headers: List<Record{name: String, value: String}>, body: Record{ initialState: Number, next: Fn(state: Number) -> Union{#yield(Record{chunk: List<Number>, nextState: Number}), #done} } }> ) -> @wasi.io // (en) Reads the parts the handler code references (wasi.io get_parts), compiles it with definy's own compiler (core.compile-to-wasm) and deploys it to Cloudflare Workers with HTTP requests (wasi.io). api_token is a Cloudflare account API token (for example definy.cloudflare-api-token); the account is read from the token (ja) HTTP リクエストを受け取ってレスポンスを返す関数のコード handler を, 参照しているパーツを読んで (wasi.io の get_parts) definy 製のコンパイラ (core.compile-to-wasm) でコンパイルし, HTTP リクエスト (wasi.io) で Cloudflare Workers にデプロイする. api_token は Cloudflare のアカウント API トークン (definy.cloudflare-api-token など) で, アカウントはトークンから読む definy.worker-request: Type // The HTTP request a worker deployed with definy.deploy-fetch-worker receives definy.worker-response: Type // The HTTP response of a worker deployed with definy.deploy-fetch-worker definy.worker-fetch-request: Type // An HTTP request a worker sends with the fetch step (the body is ignored for GET and HEAD) definy.worker-fetch-response: Type // The response of the fetch step: the status and the body as text (status 0 and the error message for a network error) definy.worker-step: Type // What a worker deployed with definy.deploy-fetch-worker returns: respond, or send an HTTP request (fetch) and continue with the response. The worker.js (definy.cloudflare-workers-runtime-script) runs it definy.deploy-wasm-to-cloudflare-workers: Fn(worker_name: String, api_token: Secret, expression: @core.expression, part_ids: List<String>) -> @wasi.io // Compile the expression (with the parts of part_ids) and deploy it to Cloudflare Workers. The body of definy.deploy-to-cloudflare-workers and definy.deploy-fetch-worker definy.deploy-fetch-worker: Fn( worker_name: String, api_token: Secret, handler: Code<Fn(request: @definy.worker-request) -> @definy.worker-step> ) -> @wasi.io // (en) Deploy a handler that can send HTTP requests (definy.worker-step) to Cloudflare Workers, like definy.deploy-to-cloudflare-workers (ja) HTTP リクエストを送れるハンドラ (definy.worker-step) を, definy.deploy-to-cloudflare-workers と同じく Cloudflare Workers にデプロイする definy.json: Type // A JSON value. The server reads the request body of an RPC into this and writes the response from it (definy.service-io) definy.stored-event: Type // A signed event the server has stored: the event hash, the signed event (Base64), the account, the event type, the time it was received and the time of the event (milliseconds, if known) definy.http-body: Type // The body of an HTTP response of the server: empty, text, JSON (definy.json), bytes in Base64 or bytes (a JSON body is kept as a value so that a handler called inside the server can read it without parsing) definy.service-response: Type // The HTTP response of the server (status, headers and body) definy.service-io: Type // (en) How the server handles a request: a definy.io program that ends with definy.service-outcome (respond with the HTTP response, or serve_asset with the static asset). The tags that ask the host (worker/service_io.ts) to read or write something (the store, the CAS, the request, the signature, HTTP) are in docs/service.md. The host only does what is asked; the handler decides definy.stored-event-json: Fn(event: @definy.stored-event) -> @definy.json // The stored event as the JSON of the API (EventItem) definy.branch-latest-event-hashes: Fn(branches: List<@core.branch-summary>, index: Number) -> List<String> // The latest event hashes of the branches from index definy.branch-items-json: Fn( branches: List<@core.branch-summary>, events: List<Union{#none, #some(@definy.stored-event)}>, index: Number, records: List<@core.branch-status-record>, merges: List<@core.branch-merge> ) -> List<@definy.json> // (en) The branches from index as the JSON of GetProjectBranches (ProjectBranchItem), with their latest events (events, in the same order) and the status of the branches other than main (core.branch-summary-status). Branches whose latest event is not found are left out (ja) index からのブランチを GetProjectBranches の JSON (ProjectBranchItem) にしたもの。最新のイベント (events, 同じ順) と main 以外のブランチの状態 (core.branch-summary-status) を付ける。最新のイベントが見つからないブランチは除く definy.get-project-branches: Fn(request: @definy.json) -> @definy.service-io // The RPC GetProjectBranches: the branches of every project (core.project-branches) with the creator, the number of snapshots, the latest event and the status of the branches other than main (status: in_progress, review or done. core.branch-status-of). The browser knows the branches without reading every event definy.rpc-authorization: Type // The Authorization header of the request (docs/rpc-authorization.md): anonymous if there is none, invalid with the reason if the signature is wrong, account with the account ID if it is right definy.split-account-ids: Fn(text: String, index: Number, current: String, acc: List<String>) -> List<String> // Split a list of account IDs separated by commas, semicolons or spaces (DEFINY_ADMIN_ACCOUNT_IDS) from index, appending to acc. current is the ID being read definy.string-split: Fn(text: String, separator: String, index: Number, current: String, acc: List<String>) -> List<String> // acc followed by text from index split at separator (one character). Empty strings are kept definy.split-words: Fn(text: String, index: Number, current: String, acc: List<String>) -> List<String> // acc followed by the words of text from index separated by spaces definy.string-at: Fn(items: List<String>, index: Number) -> String // The index-th string (empty if there is none) definy.decimal-of: Fn(bytes: List<Number>, index: Number, acc: Number) -> Union{#none, #some(Number)} // The number written in decimal digits by bytes from index after acc. none if there is a byte that is not a digit definy.rpc-authorization-credential: Type // The parts of the Authorization header Definy-Ed25519 <account_id>.<time_seconds>.<signature> (docs/rpc-authorization.md) definy.parse-rpc-authorization: Fn(header: String) -> Union{#none, #some(@definy.rpc-authorization-credential)} // Read the Authorization header (trimmed). none if it is not Definy-Ed25519 <account>.<time>.<sig> definy.rpc-authorization-message: Fn(method: String, path: String, time_seconds: Number, body: String) -> List<Number> // The bytes signed for the Authorization header: definy-rpc-v1, the method in uppercase, the path, the time and the SHA-256 of the body (URL-safe Base64) joined with newlines definy.read-rpc-authorization: Fn(request: @http.request, then: Fn(authorization: @definy.rpc-authorization) -> @definy.service-io) -> @definy.service-io // Verify the Authorization header of the request (docs/rpc-authorization.md): anonymous if there is none, invalid (the reason) if the form, the time (more than 300 seconds off) or the Ed25519 signature is wrong, account (the account ID) if it is right definy.raw-content: Type // A content of the store read by a key (read_raw_content). content_hash is the SHA-256 of the bytes definy.request-json: Type // The request body as JSON (read_request_json): json (an empty body is {}), or invalid with the reason if it is not a JSON object definy.cors-headers: List<@http.field> // The CORS headers of the responses of the server definy.json-response: Fn(status: Number, body: @definy.json) -> @definy.service-io // (en) Respond with JSON and the CORS headers definy.client-ip-version-of: Fn(headers: List<@http.field>) -> String // ipv6 / ipv4 / unknown from CF-Connecting-IP definy.client-ip-version: Fn(headers: List<@http.field>) -> String // Whether the client connected with IPv4 or IPv6, from the headers Cloudflare adds (ipv4 / ipv6 / unknown). Cf-Connecting-IPv6 has the original IPv6 when Pseudo IPv4 rewrote CF-Connecting-IP. The IP address itself is not returned definy.is-worker-first-path: Fn(path: String) -> Boolean // Whether the server handles the path itself (RPC /definy.v1., /virtual/, /healthz) instead of the static assets definy.serve-virtual-wasm: Fn(path: String) -> @definy.service-io // (en) /virtual/wasm/<key>(.wasm): respond with the Wasm of the store. Cached forever only if the key is the content hash of the bytes definy.handle-request: Fn(request: @http.request) -> @definy.service-io // (en) How the server handles an HTTP request (docs/service.md): OPTIONS, /healthz, static assets, /virtual/wasm/ and the RPC (definy.handle-rpc). The server compiles this at build time (wasm/service.wasm) definy.cbor-variant-tag: Fn(entries: List<@cbor.entry>) -> Union{#none, #some(String)} // The tag if the map is a tagged value (only one key that starts with #) definy.cbor-to-value: Fn(cbor: @cbor.item) -> @core.value // CBOR as core.value (docs/cbor.md): a map with only one key that starts with # is a variant, other maps are records. Bytes, tags, null and floats are unit definy.decoded-signed-event: Type // A SignedEvent read by definy.decode-signed-event (the signature is not verified yet). message is the bytes of the inner event that are signed definy.signed-event-decoding: Type // The result of definy.decode-signed-event: decoded, or invalid with the reason definy.decode-inner-event: Fn(signed: @cbor.item, inner: List<Number>) -> @definy.signed-event-decoding // Read the signature of the SignedEvent and the inner event (account_id, time and content) definy.decode-signed-event: Fn(bytes: List<Number>) -> @definy.signed-event-decoding // Read a SignedEvent ({signature, event_binary: tag24(inner event)}. docs/event.md) strictly. Does not verify the signature definy.verify-signed-event: Fn( signed_event_bytes: String, then: Fn(result: @definy.signed-event-verification) -> @definy.service-io ) -> @definy.service-io // (en) Read a SignedEvent (Base64) and verify its Ed25519 signature with account_id (verify_ed25519) and that its time is at most 10 minutes in the future (read_time). The event hash is the SHA-256 of the bytes (hash_contents) (ja) SignedEvent (Base64) を読み, account_id で Ed25519 の署名を確かめ (verify_ed25519), 時刻が 10 分より先でないか確かめる (read_time)。イベントハッシュはバイト列の SHA-256 (hash_contents) definy.sql-value: Type // A value of a SQL parameter or column (SQLite, Cloudflare D1) definy.sql-statement: Type // A SQL statement and its parameters (the ? in order) definy.sql-column: Type // A column of a row of a SQL result definy.sql-row: Type // A row of a SQL result (the columns in the order of SELECT) definy.sql-column-value: Fn(row: @definy.sql-row, name: String, index: Number) -> @definy.sql-value // The value of the column named name from index (null if there is no such column) definy.sql-text: Fn(row: @definy.sql-row, name: String) -> String // The column named name as text (an integer is written in decimal, null is empty) definy.sql-placeholders: Fn(count: Number) -> String // count placeholders separated by commas (?, ?, ?) definy.string-chunks: Fn(items: List<String>, size: Number, start: Number) -> List<List<String>> // items from start split into lists of size items definy.sql-in-statements: Fn(prefix: String, items: List<String>) -> List<@definy.sql-statement> // Statements prefix + (?, ...) with items as the parameters, 50 at a time (D1 limits the parameters of a statement) definy.sql-rows-concat: Fn(results: List<List<@definy.sql-row>>, index: Number) -> List<@definy.sql-row> // The rows of the results from index joined definy.strings-contain: Fn(items: List<String>, value: String, index: Number) -> Boolean // Whether items from index contain value definy.strings-unique: Fn(items: List<String>) -> List<String> // The items without the repeated strings, keeping the first of the same strings in the order of items. Uses a hash index of the items in reverse order (core.list-hash-index-find returns the last in its bucket, which is then the first in items), so it takes O(n log n) instead of O(n^2) definy.sql-missing: Fn(hashes: List<String>, rows: List<@definy.sql-row>) -> List<String> // result followed by the hashes from index that no row has as content_hash definy.stored-event-of-row: Fn(row: @definy.sql-row) -> @definy.stored-event // A row of the events table as definy.stored-event definy.store-read-events: Fn( event_hashes: List<String>, then: Fn(events: List<Union{#none, #some(@definy.stored-event)}>) -> @definy.service-io ) -> @definy.service-io // (en) The events stored with the hashes (in the same order. none if not stored) (SQL) (ja) そのハッシュの保存しているイベント (同じ順. 無ければ none) (SQL) definy.store-read-events-page: Fn( event_type: Union{#none, #some(String)}, limit: Number, offset: Number, then: Fn(events: List<@definy.stored-event>) -> @definy.service-io ) -> @definy.service-io // (en) A page of the stored events, newest first (only of event_type if some, ignoring case and _). limit is 1 to 500 (SQL) (ja) 保存しているイベントの 1 ページ (新しい順. event_type があればその種類だけ. 大文字小文字と _ は区別しない). limit は 1〜500 (SQL) definy.store-read-contents: Fn( content_hashes: List<String>, then: Fn(items: List<Union{#none, #some(@definy.content-item)}>) -> @definy.service-io ) -> @definy.service-io // (en) The contents of the CAS with the hashes (in the same order. none if not stored) (SQL) (ja) そのハッシュの CAS の中身 (同じ順. 無ければ none) (SQL) definy.store-read-missing-content-hashes: Fn(content_hashes: List<String>, then: Fn(missing: List<String>) -> @definy.service-io) -> @definy.service-io // The hashes not in the CAS (without duplicates) (SQL) definy.store-write-event: Fn( signed_event_bytes: String, event_hash: String, account_id: String, event_type: String, time_ms: Number, then: Fn(event_hash: String) -> @definy.service-io ) -> @definy.service-io // (en) Store an event definy checked with the metadata definy read. Nothing happens if it is already stored. created_at_rfc3339 is made from time_ms (SQL) (ja) definy が確かめたイベントを definy が読んだメタデータと一緒に保存する. 既にあれば何もしない. created_at_rfc3339 は time_ms から作る (SQL) definy.store-write-contents: Fn(items: List<@definy.content-item>, then: Fn(stored: List<String>) -> @definy.service-io) -> @definy.service-io // Store the contents in the CAS (the hashes are checked beforehand) and return the hashes. An existing hash is not overwritten (SQL) definy.store-read-raw-content: Fn(key: String, then: Fn(content: Union{#none, #some(@definy.raw-content)}) -> @definy.service-io) -> @definy.service-io // Read a content of the store by the key (a content hash or a name). content_hash is the SHA-256 of the bytes (SQL) definy.seed-event: Type // An event of the seed bundle (public/__definy_seed_bundle.json) with its metadata definy.seed-bundle: Type // The seed bundle the server stores (built from seeds/*.json by npm run build:seeds). fingerprint is seedBundleFingerprint definy.seed-status: Type // Whether this isolate has already seeded the store, and the fingerprint of the seed it expects definy.sql-first-text: Fn(results: List<List<@definy.sql-row>>, name: String) -> String // The column named name of the first row of the results as text (empty if there is no row) definy.sql-run-chunks: Fn( statements: List<@definy.sql-statement>, start: Number, then: Fn(done: Boolean) -> @definy.service-io ) -> @definy.service-io // (en) Run the statements from start, 50 at a time (each 50 in one batch) (ja) start 番目からの文を 50 個ずつ実行する (50 個ずつ 1 つの batch) definy.seed-fingerprint-key: String // The key of cas_contents that records the fingerprint of the seed in the store definy.store-schema-statements: List<@definy.sql-statement> // The SQL that creates the tables and indexes of the store (docs/database.md) definy.store-seed-statements: Fn(bundle: @definy.seed-bundle) -> List<@definy.sql-statement> // The SQL that replaces the seed in the store: delete the events in the time range of the old seed (the first second of 2019-01-31T04:36:01Z) not in the bundle, insert the events and contents, and record the fingerprint last. Other events (also those of accounts in the bundle) are kept (docs/source-in-store.md) definy.mark-seeded: Fn(then: Fn(seeded: Boolean) -> @definy.service-io) -> @definy.service-io // Tell the host that this isolate has seeded the store definy.ensure-seeded: Fn(then: Fn(seeded: Boolean) -> @definy.service-io) -> @definy.service-io // Create the tables if there are none and put the seed in the store if its fingerprint differs (docs/database.md). The host remembers it per isolate (read_seed_status / mark_seeded) definy.seed-store: Fn(status: Number) -> @definy.service-io // (en) Seed the store, then respond with the status and no body. The server compiles this at build time (wasm/seeder.wasm) for WorkerStore.seedD1 definy.definition-cache-entry: Type // A content of the CAS read as a part definition (none if it is not a core.expression in CBOR). The host remembers these per isolate (read_cached_definitions / write_cached_definitions) definy.project-module-ids: Fn(commits: List<@definy.event-snapshot>, project_name: String, index: Number) -> List<String> // The module IDs of the first snapshot of the project from index (none: empty) definy.part-content-hash: Fn(parts: List<@definy.stored-snapshot-part>, part_id: String, index: Number) -> Union{#none, #some(String)} // The content hash of the part with the ID from index definy.some-strings: Fn(items: List<Union{#none, #some(String)}>, index: Number, result: List<String>) -> List<String> // result followed by the strings of the some items from index definy.definition-of-content: Fn(content_bytes: String) -> Union{#none, #some(@core.expression)} // Read a content of the CAS (Base64) as a part definition: CBOR (cbor.read) of a core.expression (core.value-to-expression checks the shape) definy.definition-cache-find: Fn(entries: List<@definy.definition-cache-entry>, content_hash: String, index: Number) -> Union{#none, #some(@definy.definition-cache-entry)} // The entry of the content hash from index definy.definition-lookup: Fn(entries: List<@definy.definition-cache-entry>, content_hash: String) -> Union{#none, #some(@core.expression)} // The definition of the content hash (none if it is not read or not a definition) definy.uncached-hashes: Fn( hashes: List<String>, cached: List<@definy.definition-cache-entry>, index: Number, result: List<String> ) -> List<String> // (en) result followed by the hashes from index that are not cached (ja) result に, index 番目からのハッシュのうち覚えていないものを足したもの definy.definition-entries-of: Fn( items: List<Union{#none, #some(@definy.content-item)}>, index: Number, result: List<@definy.definition-cache-entry> ) -> List<@definy.definition-cache-entry> // (en) result followed by the found contents from index read as part definitions (ja) result に, index 番目からの見つかった中身をパーツの定義の式として読んだものを足したもの definy.read-definitions: Fn( content_hashes: List<String>, then: Fn(definitions: List<@definy.definition-cache-entry>) -> @definy.service-io ) -> @definy.service-io // (en) Read the contents of the CAS as part definitions. Each content is read once per isolate (the host caches it). Contents not in the CAS are left out (ja) CAS の中身をパーツの定義の式として読む。各中身は isolate ごとに 1 回だけ読む (ホストが覚える)。CAS に無い中身は入らない definy.source-part-of: Fn(part: @definy.stored-snapshot-part, definitions: List<@definy.definition-cache-entry>) -> @definy.snapshot-check-source-part // The part with its definition as definy.snapshot-check-source-part definy.read-part-definitions: Fn( part_ids: List<String>, then: Fn(definitions: List<Union{#none, #some(@core.expression)}>) -> @definy.service-io ) -> @definy.service-io // (en) The definitions of the parts (the latest snapshots of the main branches) in the same order. none if there is no such part (ja) パーツ (各 main ブランチの最新のスナップショット) の定義の式 (同じ順. 無ければ none) definy.handle-rpc: Fn(method: String, request: @http.request) -> Union{#none, #some(Fn(request: @definy.json) -> @definy.service-io)} // (en) How the server handles the RPC method (the path after /definy.v1., such as EventService/GetEvent or HttpProxyService/Fetch): a function from the request body. none if there is no such method. definy.handle-request calls this. See docs/service.md definy.json-escape-byte: Fn(value: String, byte: Number, start: Number) -> String // The JSON string escape of one UTF-8 byte of value at start (the byte itself when it needs no escape) definy.json-escape-range: Fn(value: String, bytes: List<Number>, start: Number, end: Number) -> String // The bytes of value from start to end escaped for a JSON string (bytes is core.string-to-bytes of value. Halves the range so the recursion stays shallow) definy.json-string-literal: Fn(value: String) -> String // The JSON string literal of value (with double quotes)
1–100 (of 529) Next 100