diff --git a/.npmrc b/.npmrc index ae643592e..e69de29bb 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +0,0 @@ -//registry.npmjs.org/:_authToken=${NPM_TOKEN} diff --git a/README.md b/README.md index b5885778b..a0f985944 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# The NodeJS driver for EdgeDB +# The official Node.js client library for EdgeDB [![Build Status](https://github.com/edgedb/edgedb-js/workflows/Tests/badge.svg?event=push&branch=master)](https://github.com/edgedb/edgedb-js/actions) [![NPM](https://img.shields.io/npm/v/edgedb)](https://www.npmjs.com/package/edgedb) [![Join GitHub discussions](https://img.shields.io/badge/join-github%20discussions-green)](https://github.com/edgedb/edgedb/discussions) @@ -54,9 +54,13 @@ A local installation of EdgeDB is required to run tests. Download EdgeDB from [here](https://www.edgedb.com/download) or [build it manually](https://www.edgedb.com/docs/reference/dev). -We use TypeScript, yarn, prettier, and tslint to develop edgedb-js. -To run the test suite, run `yarn test`. To lint or format the code, run -`yarn lint` / `yarn format`. +```bash +$ git clone git@github.com:edgedb/edgedb-js.git +$ cd edgedb-js +$ yarn # install dependencies +$ yarn build # compile TypeScript +$ yarn tests # run tests +``` ## License diff --git a/docs/api/connection.rst b/docs/api/connection.rst deleted file mode 100644 index 1befcb0f9..000000000 --- a/docs/api/connection.rst +++ /dev/null @@ -1,422 +0,0 @@ -.. _edgedb-js-api-reference: - -=== -API -=== - -.. _edgedb-js-api-client: - - -Client -====== - -.. js:function:: createClient( \ - options: string | ConnectOptions | null \ - ): Client - - Creates a new :js:class:`Client` instance. - - :param options: - This is an optional parameter. When it is not specified the client - will connect to the current EdgeDB Project instance. - - If this parameter is a string it can represent either a - DSN or an instance name: - - * when the string does not start with ``edgedb://`` it is a - :ref:`name of an instance `; - - * otherwise it specifies a single string in the connection URI format: - ``edgedb://user:password@host:port/database?option=value``. - - See the :ref:`Connection Parameters ` - docs for full details. - - Alternatively the parameter can be a ``ConnectOptions`` config; - see the documentation of valid options below. - - :param string options.dsn: - Specifies the DSN of the instance. - - :param string options.credentialsFile: - Path to a file containing credentials. - - :param string options.host: - Database host address as either an IP address or a domain name. - - :param number options.port: - Port number to connect to at the server host. - - :param string options.user: - The name of the database role used for authentication. - - :param string options.database: - The name of the database to connect to. - - :param string options.password: - Password to be used for authentication, if the server requires one. - - :param string options.tlsCAFile: - Path to a file containing the root certificate of the server. - - :param boolean options.tlsSecurity: - Determines whether certificate and hostname verification is enabled. - Valid values are ``'strict'`` (certificate will be fully validated), - ``'no_host_verification'`` (certificate will be validated, but - hostname may not match), ``'insecure'`` (certificate not validated, - self-signed certificates will be trusted), or ``'default'`` (acts as - ``strict`` by default, or ``no_host_verification`` if ``tlsCAFile`` - is set). - - The above connection options can also be specified by their corresponding - environment variable. If none of ``dsn``, ``credentialsFile``, ``host`` or - ``port`` are explicitly specified, the client will connect to your - linked project instance, if it exists. For full details, see the - :ref:`Connection Parameters ` docs. - - - :param number options.timeout: - Connection timeout in milliseconds. - - :param number options.waitUntilAvailable: - If first connection fails, the number of milliseconds to keep retrying - to connect (Defaults to 30 seconds). Useful if your development - instance and app are started together, to allow the server time to - be ready. - - :param number options.concurrency: - The maximum number of connection the ``Client`` will create in it's - connection pool. If not specified the concurrency will be controlled - by the server. This is recommended as it allows the server to better - manage the number of client connections based on it's own available - resources. - - :returns: - Returns an instance of :js:class:`Client`. - - Example: - - .. code-block:: js - - // Use the Node.js assert library to test results. - const assert = require("assert"); - const edgedb = require("edgedb"); - - async function main() { - const client = edgedb.createClient(); - - const data = await client.querySingle("select 1 + 1"); - - // The result is a number 2. - assert(typeof data === "number"); - assert(data === 2); - } - - main(); - - -.. js:class:: Client - - A ``Client`` allows you to run queries on an EdgeDB instance. - - Since opening connections is an expensive operation, ``Client`` also - maintains a internal pool of connections to the instance, allowing - connections to be automatically reused, and you to run multiple queries - on the client simultaneously, enhancing the performance of - database interactions. - - :js:class:`Client` is not meant to be instantiated directly; - :js:func:`createClient` should be used instead. - - - .. _edgedb-js-api-async-optargs: - - .. note:: - - Some methods take query arguments as an *args* parameter. The type of - the *args* parameter depends on the query: - - * If the query uses positional query arguments, the *args* parameter - must be an ``array`` of values of the types specified by each query - argument's type cast. - * If the query uses named query arguments, the *args* parameter must - be an ``object`` with property names and values corresponding to - the query argument names and type casts. - - If a query argument is defined as ``optional``, the key/value can be - either omitted from the *args* object or be a ``null`` value. - - .. js:method:: execute(query: string): Promise - - Execute an EdgeQL command (or commands). - - :param query: Query text. - - This commands takes no arguments. - - Example: - - .. code-block:: js - - await client.execute(` - CREATE TYPE MyType { - CREATE PROPERTY a -> int64 - }; - - for x in {100, 200, 300} - union (insert MyType { a := x }); - `) - - .. js:method:: query(query: string, args?: QueryArgs): Promise - - Run a query and return the results as an array. This method **always** - returns an array. - - This method takes :ref:`optional query arguments - `. - - .. js:method:: querySingle( \ - query: string, \ - args?: QueryArgs \ - ): Promise - - Run an optional singleton-returning query and return the result. - - This method takes :ref:`optional query arguments - `. - - The *query* must return no more than one element. If the query returns - more than one element, a ``ResultCardinalityMismatchError`` error is - thrown. - - .. js:method:: queryRequiredSingle( \ - query: string, \ - args?: QueryArgs \ - ): Promise - - Run a singleton-returning query and return the result. - - This method takes :ref:`optional query arguments - `. - - The *query* must return exactly one element. If the query returns - more than one element, a ``ResultCardinalityMismatchError`` error is - thrown. If the query returns an empty set, a ``NoDataError`` error is - thrown. - - .. js:method:: queryJSON(query: string, args?: QueryArgs): Promise - - Run a query and return the results as JSON. - - This method takes :ref:`optional query arguments - `. - - .. note:: - - Caution is advised when reading ``decimal`` or ``bigint`` - values using this method. The JSON specification does not - have a limit on significant digits, so a ``decimal`` or a - ``bigint`` number can be losslessly represented in JSON. - However, JSON decoders in JavaScript will often read all - such numbers as ``number`` values, which may result in - precision loss. If such loss is unacceptable, then - consider casting the value into ``str`` and decoding it on - the client side into a more appropriate type, such as - BigInt_. - - .. js:method:: querySingleJSON( \ - query: string, \ - args?: QueryArgs \ - ): Promise - - Run an optional singleton-returning query and return its element - in JSON. - - This method takes :ref:`optional query arguments - `. - - The *query* must return at most one element. If the query returns - more than one element, an ``ResultCardinalityMismatchError`` error - is thrown. - - .. note:: - - Caution is advised when reading ``decimal`` or ``bigint`` - values using this method. The JSON specification does not - have a limit on significant digits, so a ``decimal`` or a - ``bigint`` number can be losslessly represented in JSON. - However, JSON decoders in JavaScript will often read all - such numbers as ``number`` values, which may result in - precision loss. If such loss is unacceptable, then - consider casting the value into ``str`` and decoding it on - the client side into a more appropriate type, such as - BigInt_. - - .. js:method:: queryRequiredSingleJSON( \ - query: string, \ - args?: QueryArgs \ - ): Promise - - Run a singleton-returning query and return its element in JSON. - - This method takes :ref:`optional query arguments - `. - - The *query* must return exactly one element. If the query returns - more than one element, a ``ResultCardinalityMismatchError`` error - is thrown. If the query returns an empty set, a ``NoDataError`` error - is thrown. - - .. note:: - - Caution is advised when reading ``decimal`` or ``bigint`` - values using this method. The JSON specification does not - have a limit on significant digits, so a ``decimal`` or a - ``bigint`` number can be losslessly represented in JSON. - However, JSON decoders in JavaScript will often read all - such numbers as ``number`` values, which may result in - precision loss. If such loss is unacceptable, then - consider casting the value into ``str`` and decoding it on - the client side into a more appropriate type, such as - BigInt_. - - .. js:method:: transaction( \ - action: (tx: Transaction) => Promise \ - ): Promise - - Execute a retryable transaction. The ``Transaction`` object passed to - the action function has the same ``execute`` and ``query*`` methods - as ``Client``. - - This is the preferred method of initiating and running a database - transaction in a robust fashion. The ``transaction()`` method - will attempt to re-execute the transaction body if a transient error - occurs, such as a network error or a transaction serialization error. - The number of times ``transaction()`` will attempt to execute the - transaction, and the backoff timeout between retries can be - configured with :js:meth:`Client.withRetryOptions`. - - See :ref:`edgedb-js-api-transaction` for more details. - - Example: - - .. code-block:: js - - await client.transaction(async tx => { - const value = await tx.querySingle("select Counter.value") - await tx.execute( - `update Counter set { value := $value }`, - {value: value + 1}, - ) - }); - - Note that we are executing queries on the ``tx`` object rather - than on the original ``client``. - - .. js:method:: ensureConnected(): Promise - - If the client does not yet have any open connections in its pool, - attempts to open a connection, else returns immediately. - - Since the client lazily creates new connections as needed (up to the - configured ``concurrency`` limit), the first connection attempt will - only occur when the first query is run a client. ``ensureConnected`` - can be useful to catch any errors resulting from connection - mis-configuration by triggering the first connection attempt - explicitly. - - Example: - - .. code-block:: js - - import {createClient} from 'edgedb'; - - async function getClient() { - try { - return await createClient('custom_instance').ensureConnected(); - } catch (err) { - // handle connection error - } - } - - function main() { - const client = await getClient(); - - await client.query('select ...'); - } - - .. js:method:: withRetryOptions(opts: { \ - attempts?: number \ - backoff?: (attempt: number) => number \ - }): Client - - Returns a new ``Client`` instance with the specified retry attempts - number and backoff time function (the time that retrying methods will - wait between retry attempts, in milliseconds), where options not given - are inherited from the current client instance. - - The default number of attempts is ``3``. The default backoff - function returns a random time between 100 and 200ms multiplied by - ``2 ^ attempt number``. - - .. note:: - - The new client instance will share the same connection pool as the - client it's created from, so calling the ``ensureConnected``, - ``close`` and ``terminate`` methods will affect all clients - sharing the pool. - - Example: - - .. code-block:: js - - import {createClient} from 'edgedb'; - - function main() { - const client = createClient(); - - // By default transactions will retry if they fail - await client.transaction(async tx => { - // ... - }); - - const nonRetryingClient = client.withRetryOptions({ - attempts: 1 - }); - - // This transaction will not retry - await nonRetryingClient.transaction(async tx => { - // ... - }); - } - - .. js:method:: close(): Promise - - Close the client's open connections gracefully. When a client is - closed, all its underlying connections are awaited to complete their - pending operations, then closed. A warning is produced if the pool - takes more than 60 seconds to close. - - .. note:: - - Clients will not prevent Node.js from exiting once all of it's - open connections are idle and Node.js has no further tasks it is - awaiting on, so it is not necessary to explicitly call ``close()`` - if it is more convenient for your application. - - (This does not apply to Deno, since Deno is missing the - required API's to ``unref`` idle connections) - - .. js:method:: isClosed(): boolean - - Returns true if ``close()`` has been called on the client. - - .. js:method:: terminate(): void - - Terminate all connections in the client, closing all connections non - gracefully. If the client is already closed, return without doing - anything. - - -.. _BigInt: - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt diff --git a/docs/delete.rst b/docs/delete.rst new file mode 100644 index 000000000..c4055a0eb --- /dev/null +++ b/docs/delete.rst @@ -0,0 +1,18 @@ +.. _edgedb-js-delete: + +Delete +------ + +Delete objects with ``e.delete``. + +.. code-block:: typescript + + e.delete(e.Movie, movie => ({ + filter: .., + order_by: ..., + offset: ..., + limit: ... + })); + +The only supported keys are ``filter``, ``order_by``, ``offset``, and +``limit``. diff --git a/docs/driver.rst b/docs/driver.rst new file mode 100644 index 000000000..98eb18a3b --- /dev/null +++ b/docs/driver.rst @@ -0,0 +1,349 @@ +.. _edgedb-js-examples: + + +Driver +====== + +The driver implements the core functionality required to establish a +connection to your database and execute queries. + +.. _edgedb-js-create-client: + +Creating clients +---------------- + +A *client* represents a connection to your database and provides methods for +executing queries. + +.. note:: + + In actuality, the client maintains an *pool* of connections under the hood. + When your server is under load, queries will be run in parallel across many + connections, instead of being bottlenecked by a single connection. + +To create a client: + +.. code-block:: js + + const edgedb = require("edgedb"); + + const client = edgedb.createClient(); + + +If you're using TypeScript or have ES modules enabled, you can use +``import`` syntax instead: + +.. code-block:: js + + impoart * as edgedb from "edgedb"; + + const client = edgedb.createClient(); + + +Configuring the connection +-------------------------- + +Notice we didn't pass any arguments into ``createClient``. That's intentional; +we recommend using EdgeDB projects or environment variables to configure your +database connections. See the :ref:`Client Library Connection +` docs for details on configuring connections. + +Running queries +--------------- + +To execute a basic query: + +.. code-block:: js + + const edgedb = require("edgedb"); + + const client = edgedb.createClient(); + + async function main() { + const result = await client.query(`select 2 + 2;`); + console.log(result); // [4] + } + + +.. _edgedb-js-typescript: + +In TypeScript, you can supply a type hint to receive a strongly typed result. + +.. code-block:: js + + const result = await client.query(`select 2 + 2;`); + // number[] + + +Type conversion +--------------- + +The driver converts EdgeDB types into a corresponding JavaScript data +structure. Some EdgeDB types like ``duration`` don't have a corresponding type +in the JavaScript type system, so we've implemented classes like +:js:class:`Duration` to represent them. + +.. list-table:: + + * - **EdgeDB type** + - **JavaScript type** + * - Sets + - ``Array`` + * - Arrays + - ``Array`` + * - Tuples ``tuple`` + - ``Array`` + * - Named tuples ``tuple`` + - ``object`` + * - Enums + - ``string`` + * - ``Object`` + - ``object`` + * - ``str`` + - ``string`` + * - ``bool`` + - ``boolean`` + * - ``float32`` ``float64`` ``int16`` ``int32`` ``int64`` + - ``number`` + * - ``json`` + - ``string`` + * - ``uuid`` + - ``string`` + * - ``bigint`` + - ``BigInt`` + * - ``decimal`` + - N/A (not supported) + * - ``bytes`` + - ``Buffer`` + * - ``datetime`` + - ``Date`` + * - ``duration`` + - :js:class:`Duration` + * - ``cal::local_date`` + - :js:class:`LocalDate` + * - ``cal::local_time`` + - :js:class:`LocalTime` + * - ``cal::local_datetime`` + - :js:class:`LocalDateTime` + * - ``cfg::memory`` + - :js:class:`ConfigMemory` + + +To learn more about the driver's built-in type classes, refer to the reference +documentation. + +- :js:class:`LocalDate` +- :js:class:`LocalTime` +- :js:class:`LocalDateTime` +- :js:class:`Duration` +- :js:class:`ConfigMemory` + + +.. .. note:: + +.. **A message for query builder users** + +.. Everything below this point isn't necessary/applicable for query builder users. Continue to the :ref:`Query Builder ` docs. + + +Enforcing cardinality +--------------------- + +There are additional methods for running queries that have an *expected +cardinality*. This is a useful way to tell the driver how many elements you +expect the query to return. + +``.query`` method +^^^^^^^^^^^^^^^^^ + +The ``query`` method places no constraints on cardinality. It returns an +array, no matter what. + +.. code-block:: js + + await client.query(`select 2 + 2;`); // [4] + await client.query(`select {};`); // [] + await client.query(`select {1, 2, 3};`); // [1, 2, 3] + +``.querySingle`` method +^^^^^^^^^^^^^^^^^^^^^^^ + +Use ``querySingle`` if you expect your query to return *zero or one* elements. +Unlike ``query``, it either returns a single element or ``null``. Note that if +you're selecting an array, tuple, or + +.. code-block:: js + + await client.querySingle(`select 2 + 2;`); // [4] + await client.querySingle(`select {};`); // null + await client.querySingle(`select {1, 2, 3};`); // Error + +``.queryRequiredSingle`` method +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Use ``queryRequiredSingle`` for queries that return *exactly one* element. + +.. code-block:: js + + await client.queryRequiredSingle(`select 2 + 2;`); // 4 + await client.queryRequiredSingle(`select {};`); // Error + await client.queryRequiredSingle(`select {1, 2, 3};`); // Error + +The TypeScript signatures of these methods reflects their behavior. + +.. code-block:: typescript + + await client.querySingle(`select 2 + 2;`); + // number | null + + await client.queryRequiredSingle(`select 2 + 2;`); + // number + + +JSON results +------------ + +There are dedicated methods for running queries and retrieving results as a +serialized JSON string. This serialization happens inside the database. + +.. code-block:: js + + await client.query(`select {1, 2, 3};`); + // "[1, 2, 3]" + + await client.querySingle(`select {};`); + // "null" + + await client.queryRequiredSingle(`select 3.14;`); + // "3.14" + +Non-returning queries +--------------------- + +To execute a query without retrieving a result, use the ``.execute`` method. +This is especially useful for mutations, where there's often no need for the +query to return a value. + +.. code-block:: js + + await client.execute(`insert Movie { + title := "Avengers: Endgame" + };`); + +Parameters +---------- + +If your query contains parameters (e.g. ``$foo``), you can pass in values as +the second argument. This is true for all ``query*`` methods and ``execute``. + +.. code-block:: js + + const INSERT_MOVIE = `insert Movie { + title := $title + }` + const result = await client.querySingle(INSERT_MOVIE, { + title: "Iron Man" + }); + console.log(result); + // {id: "047c5893..."} + +Remember that :ref:`parameters ` can only be *scalars* or +*arrays of scalars*. + +Checking connection status +-------------------------- + +The client maintains a dynamically sized *pool* of connections under the hood. +These connections are initialized *lazily*, so no connection will be +established until the first time you execute a query. + +If you want to explicitly ensure that the client is connected without running +a query, use the ``.ensureConnected()`` method. + +.. code-block:: js + + const edgedb = require("edgedb"); + + const client = edgedb.createClient(); + + async function main() { + await client.ensureConnected(); + } + +.. _edgedb-js-api-transaction: + +Transactions +------------ + +The most robust way to execute transactional code is to use +the ``transaction()`` API: + +.. code-block:: js + + await client.transaction(tx => { + await tx.execute("insert User {name := 'Don'}"); + }); + +Note that we execute queries on the ``tx`` object in the above +example, rather than on the original ``client`` object. + +The ``transaction()`` API guarantees that: + +1. Transactions are executed atomically; +2. If a transaction fails due to retryable error (like + a network failure or a concurrent update error), the transaction + would be retried; +3. If any other, non-retryable error occurs, the transaction is rolled + back and the ``transaction()`` block throws. + +The key implication of retrying transactions is that the entire +nested code block can be re-run, including any non-querying +JavaScript code. Here is an example: + +.. code-block:: js + + const email = "timmy@edgedb.com" + + await client.transaction(async tx => { + await tx.execute( + `insert User { email := $email }`, + { email }, + ) + + await sendWelcomeEmail(email); + + await tx.execute( + `insert LoginHistory { + user := (select User filter .email = $email), + timestamp := datetime_current() + }`, + { email }, + ) + }) + +In the above example, the welcome email may be sent multiple times if the +transaction block is retried. Generally, the code inside the transaction block +shouldn't have side effects or run for a significant amount of time. + +.. note:: + + Transactions allocate expensive server resources and having + too many concurrently running long-running transactions will + negatively impact the performance of the DB server. + +.. note:: + + * RFC1004_ + * :js:meth:`Client.transaction\` + + .. _RFC1004: https://github.com/edgedb/rfcs/blob/master/text/1004-transactions-api.rst + + +Next up +------- + +If you're a TypeScript user and want autocompletion and type inference, head +over to the :ref:`Query Builder docs `. If you're using plain +JavaScript that likes writing queries with composable code-first syntax, you +should check out the query builder too! If you're content writing queries as +strings, the vanilla driver API will meet your needs. diff --git a/docs/expressions.rst b/docs/expressions.rst new file mode 100644 index 000000000..b2b1c64fa --- /dev/null +++ b/docs/expressions.rst @@ -0,0 +1,106 @@ +.. _edgedb-js-execution: + +Expressions +----------- + + +The query builder is exact what it sounds like: a way to declare EdgeQL +queries with code. By convention, it's imported from the directory where it was +generated as a single, default import called ``e``. + +.. code-block:: typescript + + import e from "./dbschema/edgeql-js"; + +The ``e`` variable provides everything you need to build any EdgeQL query. All +EdgeQL commands, standard library functions, and types are available as +properties on ``e``. + +.. code-block:: typescript + + import e from "./dbschema/edgeql-js"; + + // commands + e.select; + e.insert; + e.update; + e.delete; + + // types + e.str; + e.bool; + e.int64; + e.duration; + e.cal.local_date; + + // functions + e.str_upper; + e.len; + e.count; + e.math.stddev; + +These building blocks are used to define *expressions*. Everything you create +using the query builder is an expression. Expressions have a few things in +common. + +**Expressions produce EdgeQL.** Below is a number of expressions and the +EdgeQL they produce. (The actual EdgeQL the create may look slightly +different, but it's equivalent.) You can extract an EdgeQL representation of +any expression calling the ``.toEdgeQL()`` method. + +.. code-block:: typescript + + e.str("Hello world!").toEdgeQL(); + // "Hello world" + + e.set(1, 2, 3).toEdgeQL(); + // {1, 2, 3} + + e.count(e.Movie).toEdgeQL(); + // count(Movie) + + e.insert(e.Movie, { title: "Iron Man "}).toEdgeQL(); + // insert Movie { title := "Iron Man" } + + e.select(e.Movie, () => ({ id: true, title: true })).toEdgeQL(); + // select Movie { id, title } + + +**Expressions are runnable.** Expressions can be executed with the ``.run`` +method. + +.. code-block:: typescript + + import * as edgedb from "edgedb"; + + const client = edgedb.createClient(); + const myQuery = e.str("Hello world") + const result = await myQuery.run(client) + // => "Hello world" + +Note that the ``.run`` method accepts an instance of :js:class:`Client` (or +``Transaction``) as it's first argument. See :ref:`Creating a Client +` for details on creating clients. The second +argument is for passing :ref:`$parameters `, more on +that later. + +.. code-block:: typescript + + .run(client: Client | Transaction, params: Params): Promise + + +**Expressions have a type and a cardinality**. Just like sets in EdgeQL, all +expressions are associated with a type and a cardinality. The query builder is +extremely good at *inferring* these. You can see the values of these with the +special ``__element__`` and ``__cardinality__`` properties. + +.. code-block:: typescript + + const q1 = e.str("Hello"); + q1.__element__: // e.str + q1.__cardinality__: // "One" + + const q2 = e.Movie; + q2.__element__: // e.Movie + q2.__cardinality__: // "Many" + diff --git a/docs/for.rst b/docs/for.rst new file mode 100644 index 000000000..74b85e7a6 --- /dev/null +++ b/docs/for.rst @@ -0,0 +1,15 @@ +.. _edgedb-js-for: + + +For loops +--------- + +.. code-block:: typescript + + e.for(e.set("1", "2", "3"), number => { + // do stuff + }); + + e.for(e.Movie, movie => { + // do stuff + }); diff --git a/docs/funcops.rst b/docs/funcops.rst new file mode 100644 index 000000000..8692d2331 --- /dev/null +++ b/docs/funcops.rst @@ -0,0 +1,145 @@ +.. _edgedb-js-funcops: + +Functions and operators +----------------------- + +Function syntax +^^^^^^^^^^^^^^^ + +All built-in standard library functions are reflected as functions in ``e``. + +.. code-block:: typescript + + e.str_upper(e.str("hello")); + // str_upper("hello") + + e.plus(e.int64(2), e.int64(2)); + // 2 + 2 + + const nums = e.set(e.int64(3), e.int64(5), e.int64(7)) + e.in(e.int64(4), nums); + // 4 in {3, 5, 7} + + e.math.mean(nums); + // math::mean({3, 5, 7}) + + + +Operator syntax +^^^^^^^^^^^^^^^ + +By comparison, operators do *not* each have a corresponding function on the +``e`` object. Instead, use the ``e.op`` function. + +**Unary operators** + +Unary operators operate on a single argument: ``OPERATOR ``. + +.. code-block:: typescript + + e.op('not', e.bool(true)); // not true + e.op('exists', e.set('hi')); // exists {'hi'} + +**Binary operators** + +Unary operators operate on two arguments: `` OPERATOR ``. + +.. code-block:: typescript + + e.op(e.str('Hello '), '++', e.str('World!')); + // 'Hello ' ++ 'World!' + + +**Ternary operators** + +Unary operators operate on three arguments: `` OPERATOR OPERATOR +``. Currently there's only one ternary operator: the ``if else`` +construct. + +.. code-block:: typescript + + e.op(e.str('😄'), 'if', e.bool(true), 'else', e.str('😢')); + // 😄 if true else 😢 + +**Operator reference** + +.. list-table:: + + * - Prefix operators + - ``"exists"`` ``"distinct"`` ``"not"`` + * - Infix operators + - ``"="`` ``"?="`` ``"!="`` ``"?!="`` ``">="`` ``">"`` ``"<="`` ``"<"`` + ``"or"`` ``"and"`` ``"+"`` ``"-"`` ``"*"`` ``"/"`` ``"//"`` ``"%"`` + ``"^"`` ``"in"`` ``"not in"`` ``"union"`` ``"??"`` ``"++"`` ``"like"`` + ``"ilike"`` ``"not like"`` ``"not ilike"`` + * - Ternary operators + - ``"if"/"else"`` + +.. * - ``=`` +.. - ``e.eq`` +.. * - ``?=`` +.. - ``e.coal_eq`` +.. * - ``!=`` +.. - ``e.neq`` +.. * - ``?!=`` +.. - ``e.coal_neq`` +.. * - ``>=`` +.. - ``e.gte`` +.. * - ``>`` +.. - ``e.gt`` +.. * - ``<=`` +.. - ``e.lte`` +.. * - ``<`` +.. - ``e.lt`` +.. * - ``OR`` +.. - ``e.or`` +.. * - ``AND`` +.. - ``e.and`` +.. * - ``NOT`` +.. - ``e.not`` +.. * - ``+`` +.. - ``e.plus`` +.. * - ``-`` +.. - ``e.minus`` +.. * - ``*`` +.. - ``e.mult`` +.. * - ``/`` +.. - ``e.div`` +.. * - ``//`` +.. - ``e.floordiv`` +.. * - ``%`` +.. - ``e.mod`` +.. * - ``^`` +.. - ``e.pow`` +.. * - ``IN`` +.. - ``e.in`` +.. * - ``NOT IN`` +.. - ``e.not_in`` +.. * - ``EXISTS`` +.. - ``e.exists`` +.. * - ``DISTINCT`` +.. - ``e.distinct`` +.. * - ``UNION`` +.. - ``e.union`` +.. * - ``??`` +.. - ``e.coalesce`` +.. * - ``IF`` +.. - ``e.if_else`` +.. * - ``++`` +.. - ``e.concat`` +.. * - ``[i]`` +.. - ``e.index`` +.. * - ``[i:j:k]`` +.. - ``e.slice`` +.. * - ``[key]`` +.. - ``e.destructure`` (JSON element access) +.. * - ``++`` +.. - ``e.concatenate`` +.. * - ``LIKE`` +.. - ``e.like`` +.. * - ``ILIKE`` +.. - ``e.ilike`` +.. * - ``NOT LIKE`` +.. - ``e.not_like`` +.. * - ``NOT ILIKE`` +.. - ``e.not_ilike`` diff --git a/docs/generation.rst b/docs/generation.rst new file mode 100644 index 000000000..1e8b36365 --- /dev/null +++ b/docs/generation.rst @@ -0,0 +1,174 @@ +.. _edgedb-js-generation: + +Generation +========== + +The query builder is *auto-generated* from your database schema. + +Minimum requirements +^^^^^^^^^^^^^^^^^^^^ + +It's possible to use the query builder with or without TypeScript. Some +requirements apply to TypeScript users only. + +- Node.js 10+. Run ``node --version`` to see your current version. TypeScript + users should also install Node.js typing: ``npm install @types/node`` +- TypeScript 4.4+ +- Make sure the following ``compilerOptions`` exist in your ``tsconfig.json``: + + .. code-block:: javascript + + // tsconfig.json + { + // ... + "compilerOptions": { + // ... + "strict": true, + "downlevelIteration": true, + } + } + +Initialize a project +^^^^^^^^^^^^^^^^^^^^ + +Set up an :ref:`EdgeDB project ` for your +application. Follow the :ref:`Quickstart ` for detailed +instructions on installing the CLI, initializing a project, writing a basic +schema, and executing your first migration. + +Install the JavaScript client library +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Install the ``edgedb`` package from NPM. + +.. code-block:: bash + + $ npm install edgedb # npm users + $ yarn add edgedb # yarn users + +Generate the query builder +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Generate the query builder with the following command. + +.. code-block:: bash + + $ npx edgeql-js # npm users + $ yarn edgeql-js # yarn users + +You'll see something like this. + +.. code-block:: bash + + $ npx edgeql-js + Detected tsconfig.json, generating TypeScript files. + To override this, use the --target flag. + Run `npx edgeql-js --help` for details. + Generating query builder into ./dbschema/edgeql-js + Connecting to EdgeDB instance... + Introspecting database schema... + Generation successful! + +The ``npx edgeql-js`` establishes a connection to your database, introspects +the current schema, and generates a bunch of files. By default, these files +are written to the ``./dbschema/edgeql-js`` directory, as defined relative to +your project root. The project root is identified by scanning up the file +system for a ``package.json``. + + +.. note:: + + **Connection issue?** + + This command must be able to connect to a running EdgeDB instance. If you're + using ``edgedb project init``, this is automatically handled for you. + Otherwise, you'll need to explicitly pass connection information, just like + any other CLI command. See :ref:`Client Libraries > Connection + ` for guidance. + +Version control +^^^^^^^^^^^^^^^ + +The first time you run the command, you'll be prompted to add the generated +files to your ``.gitignore``. Confirm this prompt, and a line will be +automatically added to your ``.gitignore`` to exclude the generated files from +Git. + +.. code-block:: bash + + $ npx edgeql-js + ... + Checking the generated query builder into version control + is NOT RECOMMENDED. Would you like to update .gitignore to ignore + the query builder directory? The following line will be added: + + dbschema/edgeql-js + + [y/n] (leave blank for "y") + + +Importing +^^^^^^^^^ + +Once the query builder is generated, it's ready to use! Just import it and +start building queries. Below is a full "Hello world" example. + +.. code-block:: typescript + + import * as edgedb from "edgedb"; + import e from "./dbschema/edgeql-js"; + + const client = edgedb.createClient(); + + async function run(){ + // declare a simple query + const myQuery = e.str("Hello world!"); + + // execute the expression + const result = await myQuery.run(client); + + // print the result + console.log(result); // "Hello world!" + } + +Configuring ``npx edgeql-js`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The generation command is configurable in a number of ways. + +``--output-dir `` + Sets the output directory for the generated files. + +``--target `` + What type of files to generate. + + .. list-table:: + + * - ``ts`` + - Generate TypeScript + * - ``cjs`` + - Generate JavaScript with CommonJS (``require/module.exports``) syntax + * - ``esm`` + - Generate JavaScript with ES Module (``import/export``) syntax + + The default is determined according the the following simple algorithm: + + 1. Check for a ``tsconfig.json`` in the project root. If it exists, use + ``--target ts``. + 2. Otherwise. check if ``package.json`` includes ``"type": "module"``. If + so, use ``--target esm``. + 3. Otherwise, use ``--target cjs``. + + +``--force-overwrite`` + To avoid accidental changes, you'll be prompted to confirm whenever the + ``--target`` has changed from the previous run. To avoid this prompt, pass + ``--force-overwrite``. + +``-h/--help`` + Prints full documentation. + +The generator also supports all the :ref:`connection flags +` supported by the EdgeDB CLI. These aren't +necessary when using a project or environment variables to configure a +connection. diff --git a/docs/index.rst b/docs/index.rst index cd666ea5a..e814bcca3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,43 +1,169 @@ .. _edgedb-js-intro: -======================== -EdgeDB JavaScript Driver -======================== +=========================== +EdgeDB TypeScript/JS Client +=========================== -**edgedb-js** is the official EdgeDB driver for JavaScript written in TypeScript. +.. toctree:: + :maxdepth: 3 + :hidden: -.. rubric:: Contents + driver + generation + expressions + literals + types + funcops + parameters + objects + select + insert + update + delete + with + for + reference -* :ref:`edgedb-js-installation` +This is the official EdgeDB client library for JavaScript and TypeScript. It's +the easiest way to connect to your database and execute queries from a Node.js +or Deno backend. - edgedb-js is installable via ``$ npm install edgedb``. Read - the section for more information on how to install the library. +.. _edgedb-js-installation: -* :ref:`edgedb-js-examples` +**Installation** - High-level examples on how to use the edgedb-js client, - as well as on how to work with transactions. +To get started, install the ``edgedb`` module from NPM. -* :ref:`edgedb-js-typescript` +.. code-block:: bash - An overview of how to use this library in a TypeScript environment, - including how to execute strongly typed queries. + # using npm + $ npm install edgedb + # using Yarn + $ npm install edgedb -* :ref:`edgedb-js-api-reference` +There are two components of this library: the *driver* and the *query builder*. - APIs reference. +The driver +========== -* :ref:`edgedb-js-datatypes` +The driver implements the core functionality required to establish a +connection to your database and execute queries. If you prefer writing queries +as strings, the driver API is all you need. - EdgeDB JavaScript types documentation. +.. code-block:: javascript + const edgedb = require("edgedb"); -.. toctree:: - :maxdepth: 3 - :hidden: + const client = edgedb.createClient(); + const query = `select "Hello world!";`; + + async function run(){ + const result = await client.query(query) + console.log(result); // "Hello world!" + } + +If you're not using TypeScript, you can skip straight to :ref:`the Driver docs +`. + + +.. _edgedb-js-qb: + +The query builder +================= + +The EdgeDB query builder provides a **code-first** way to write +**fully-typed** EdgeQL queries with TypeScript. We recommend it for TypeScript +users—it's awesome. + +.. code-block:: typescript + + import edgedb from "edgedb"; + import e from "./dbschema/edgeql-js"; // auto-generated code + + const client = edgedb.createClient(); + + async function run(){ + const query = e.str("Hello world!"); + const result = await query.run(client) + console.log(result); // "Hello world!" + } + +As you can see, you still use the ``edgedb`` module to instantiate a client, +but you use the auto-generated query builder to write and execute your queries. + +Why use the query builder? +-------------------------- + +*Type inference!* If you're using TypeScript, the result type of *all +queries* is automatically inferred for you. For the first time, you don't +need an ORM to write strongly typed queries. + +.. code-block:: typescript + + const client = edgedb.createClient(); + + const q1 = await e.str("Hello world!").run(client); + // number + + const q2 = await e.set(1, 2, 3).run(client); + // number[] + + const q3 = e.select(e.Movie, () => ({ + id: true, + name: true + })); + // {id:string; name: string}[] + + +*Auto-completion!* You can write queries full autocompletion on EdgeQL +keywords, standard library functions, and link/property names. + +*Type checking!* In the vast majority of cases, the query builder won't let +you construct invalid queries. This eliminates an entire class of bugs and +helps you write valid queries the first time. + + +Is it an ORM? +------------- + +Nope. There's no "object-relational mapping" happening here—that's all handled +by EdgeDB itself. + +The query builder itself is a comparatively thin wrapper over EdgeQL. We've +designed the API such that the TypeScript representation of a query is +structurally similar to the equivalent EdgeQL. + +.. code-block:: edgeql + + select Movie { + id, + title, + uppercase_title := str_upper(.title) + } + filter .title = "Iron Man" + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + id: true, + title: true, + uppercase_title := e.str_upper(movie.title), + filter: e.op(movie.title, '=', 'Iron Man') + }); + +More importantly, it gives you access to the **full power** of EdgeQL! The +query builder can represent EdgeQL queries of arbitrary complexity. + +By comparison, SQL-based ORMs are limited in what they can represent. Things +like computed properties, SQL's large standard library of functions, +aggregations, transactions, and subqueries are rarely possible. But even for +the simple stuff, we think the query builder API is more readable, compact, +and intuitive than any ORM on the market. + +How do I get started? +--------------------- - installation - usage - typescript - api/connection - api/types +The query builder not an alternative to the driver; the driver API is still +needed to initialize a database client. We recommend reading the :ref:`Driver +docs ` first, then continuing on to the :ref:`Query +builder ` docs. diff --git a/docs/insert.rst b/docs/insert.rst new file mode 100644 index 000000000..a8e258743 --- /dev/null +++ b/docs/insert.rst @@ -0,0 +1,82 @@ +.. _edgedb-js-insert: + +Insert +------ + +Insert new data with ``e.insert``: + +.. cast: e.select(e.Person, person => ({ +.. filter: e.op(person.name, 'in', e.set("Tom Holland", "Zendaya")), +.. })), + +.. code-block:: typescript + + const runtime = new edgedb.Duration(0,0,0,0,2,28); + e.insert(e.Movie, { + title: e.str("Spider-Man: No Way Home"), + runtime: e.duration(runtime), + }); + +For convenience, the second argument ``e.insert`` function can also accept +plain JS data. + +.. code-block:: typescript + + const runtime = new edgedb.Duration(0,0,0,0,2,28); + e.insert(e.Movie, { + title: "Spider-Man: No Way Home", + runtime: runtime, + }); + + +Handling conflicts +^^^^^^^^^^^^^^^^^^ + +In EdgeQL, "upsert" functionality is achieved by handling **conflicts** on +``insert`` statements with the ``unless conflict`` clause. In the query +builder, this is possible with the ``.unlessConflict`` method (available only +on ``insert`` expressions). + +In the simplest case, adding ``.unlessConflict`` (no arguments) will prevent +EdgeDB from throwing an error if the insertion would violate an exclusivity +contstraint. Instead, the query would return the pre-existing object. + +.. code-block:: typescript + + const runtime = new edgedb.Duration(0,0,0,0,2,28); + e.insert(e.Movie, { + title: "Spider-Man: No Way Home", + runtime: runtime + }).unlessConflict(); + + +To specify an ``on`` clause: + +.. code-block:: typescript + + const runtime = new edgedb.Duration(0,0,0,0,2,28); + e.insert(e.Movie, { + title: "Spider-Man: No Way Home", + runtime: runtime + }).unlessConflict(movie => ({ + on: movie.title, // can be any expression + })); + + +To specify an ``on...else`` clause: + +.. code-block:: typescript + + const runtime = new edgedb.Duration(0,0,0,0,2,28); + e.insert(e.Movie, { + title: "Spider-Man: Homecoming", + runtime: runtime + }).unlessConflict(movie => ({ + on: movie.title, + else: e.update(movie, () => ({ + set: { + runtime: runtime + } + })), + })); + diff --git a/docs/installation.rst b/docs/installation.rst deleted file mode 100644 index 601ee93bf..000000000 --- a/docs/installation.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. _edgedb-js-installation: - - -Installation -============ - -To install EdgeDB driver with **npm** use: - -.. code-block:: bash - - $ npm install edgedb - -To install EdgeDB driver with **yarn** use: - -.. code-block:: bash - - $ yarn add edgedb - - -Building from source --------------------- - -If you want to build the EdgeDB driver from a Git checkout you will need: - -* Node.js 10 or above. -* TypeScript compiler. -* yarn package manger. - -Once the above requirements are satisfied, run the following command -in the root of the source checkout: - -.. code-block:: bash - - $ yarn - - -Running tests -------------- - -The testsuite requires a working local installation of the EdgeDB server. -To execute the testsuite run: - -.. code-block:: bash - - $ yarn test diff --git a/docs/literals.rst b/docs/literals.rst new file mode 100644 index 000000000..a18d959e5 --- /dev/null +++ b/docs/literals.rst @@ -0,0 +1,358 @@ +.. _edgedb-js-literals: + + +Literals +-------- + +The query builder provides a set of "helper functions" that convert JavaScript +literals into *expressions* that can be used in queries. For the most part, +these helper functions correspond to the *name* of the type. + + + +Primitives +^^^^^^^^^^ + +Primitive literal expressions are created using constructor functions that +correspond to EdgeDB datatypes. Each expression below is accompanied by the +EdgeQL it produces. + +.. code-block:: typescript + + e.str("asdf") // "asdf" + e.int64(123) // 1234 + e.float64(123.456) // 123.456 + e.bool(true) // true + e.bigint(12345n) // 12345n + e.decimal("1234.1234n") // 1234.1234n + e.uuid("599236a4...") // "599236a4..." + + e.bytes(Buffer.from('binary data')); + // b'binary data' + +Strings +^^^^^^^ + +String expressions have some special functionality: they support indexing and +slicing, as in EdgeQL. + +.. code-block:: typescript + + const myString = e.str("hello world"); + + myString[5]; // "hello world"[5] + myString['2:5']; // "hello world"[0:5] + myString[':5']; // "hello world"[:5] + myString['2:']; // "hello world"[:5] + +There are also equivalent ``.index`` and ``.slice`` methods that can accept +integer expressions as arguments. + +.. code-block:: typescript + + const myString = e.str("hello world"); + const start = e.int64(2); + const end = e.int64(5); + + myString.index(start); // "hello world"[2] + myString.slice(start, end); // "hello world"[2:5] + myString.slice(null, end); // "hello world"[:5] + myString.slice(start, null); // "hello world"[2:] + +Enums +^^^^^ + +All enum types are represented as functions. + +.. code-block:: typescript + + e.Colors('green'); + // Colors.green; + + e.sys.VersionStage('beta'); + // sys::VersionStage.beta + +Dates and times +^^^^^^^^^^^^^^^ + +To create an instance of ``datetime``, pass a JavaScript ``Date`` object into +``e.datetime``: + +.. code-block:: typescript + + e.datetime(new Date('1999-01-01'))) + // '1999-01-01T00:00:00.000Z' + +EdgeDB's other temporal datatypes don't have equivalents in the JavaScript +type system: ``duration``, ``cal::local_date``, ``cal::local_time``, and +``cal::local_datetime``. + +To resolve this, each of these datatypes can be represented with an instance +of a corresponding class, as defined in ``edgedb`` module. The driver uses +these classes to represent these values in query results; they are documented +on the :ref:`Driver ` page. + +.. list-table:: + + * - ``e.duration`` + - :js:class:`Duration` + * - ``e.cal.local_date`` + - :js:class:`LocalDate` + * - ``e.cal.local_time`` + - :js:class:`LocalTime` + * - ``e.cal.local_datetime`` + - :js:class:`LocalDateTime` + +The code below demonstrates how to declare each kind of temporal literal, +along with the equivalent EdgeQL. + +.. code-block:: typescript + + import * as edgedb from "edgedb"; + + const myDuration = new edgedb.Duration(0, 0, 0, 0, 1, 2, 3); + e.duration(myDuration); + + const myLocalDate = new edgedb.LocalDate(1776, 07, 04); + e.cal.local_date(myLocalDate); + + const myLocalTime = new edgedb.LocalTime(13, 15, 0); + e.cal.local_time(myLocalTime); + + const myLocalDateTime = new edgedb.LocalDateTime(1776, 07, 04, 13, 15, 0); + e.cal.local_datetime(myLocalDateTime); + + +You can also declare these literals by casting an appropriately formatted +``str`` expression, as in EdgeQL. Casting :ref:`is documented +` in more detail later in the docs. + +.. code-block:: typescript + + e.cast(e.duration, e.str('5 minutes')); + // '5 minutes' + + e.cast(e.cal.local_datetime, e.str('1999-03-31T15:17:00')); + // '1999-03-31T15:17:00' + + e.cast(e.cal.local_date, e.str('1999-03-31')); + // '1999-03-31' + + e.cast(e.cal.local_time, e.str('15:17:00')); + // '15:17:00' + + +JSON +^^^^ + +JSON literals are created with the ``e.json`` function. You can pass in any +data structure of EdgeDB-encodable data. + +.. note:: + + What does "EdgeDB-encodable" mean? It means any JavaScript data structure + with an equivalent in EdgeDB: strings, number, booleans, arrays, objects, + ``bigint``s, ``Buffer``s, ``Date``s, and instances of EdgeDB's built-in + classes: ``Duration``, ``LocalDate`` ``LocalTime``, and ``LocalDateTime``. + +.. code-block:: typescript + + e.json({ name: "Billie" }) + // to_json('{"name": "Billie"}') + + const data = e.json({ + name: "Billie", + numbers: [1,2,3], + nested: { foo: "bar"}, + duration: new edgedb.Duration(1, 3, 3) + }) + +JSON expressions support indexing, as in EdgeQL. The returned expression also +has a ``json`` type. + +.. code-block:: typescript + + const myJSON = e.json({ numbers: [0,1,2] }); + // to_json('{"numbers":[0,1,2]}') + + myJSON.numbers[0]; + // to_json('{"numbers":[0,1,2]}')['numbers'][0] + +.. Keep in mind that JSON expressions are represented as strings when returned from a query. + +.. .. code-block:: typescript + +.. await e.json({ +.. name: "Billie", +.. numbers: [1,2,3] +.. }).run(client) +.. // => '{"name": "Billie", "numbers": [1, 2, 3]}'; + +Arrays +^^^^^^ + +Declare array expressions by passing an array of expressions into ``e.array``. + +.. code-block:: typescript + + e.array([e.str("a"), e.str("b"), e.str("b")]); + // ["a", "b", "c"] + +EdgeQL semantics are enforced by TypeScript, so arrays can't contain elements +with incompatible types. + +.. code-block:: typescript + + e.array([e.int64(5), e.str("foo")]); + // TypeError! + +For convenence, the ``e.array`` can also accept arrays of plain JavaScript +data as well. + +.. code-block:: typescript + + e.array(['a', 'b', 'c']); + // ['a', 'b', 'c'] + + // you can intermixing expressions and plain data + e.array([1, 2, e.int64(3)]); + // [1, 2, 3] + +Array expressions also support indexing and slicing operations. + +.. code-block:: typescript + + const myArray = e.array(['a', 'b', 'c', 'd', 'e']); + // ['a', 'b', 'c', 'd', 'e'] + + myArray[1]; + // ['a', 'b', 'c', 'd', 'e'][1] + + myArray['1:3']; + // ['a', 'b', 'c', 'd', 'e'][1:3] + +There are also equivalent ``.index`` and ``.slice`` methods that can accept +other expressions as arguments. + +.. code-block:: typescript + + const start = e.int64(1); + const end = e.int64(3); + + myArray.index(start); + // ['a', 'b', 'c', 'd', 'e'][1] + + myArray.slice(start, end); + // ['a', 'b', 'c', 'd', 'e'][1:3] + +Tuples +^^^^^^ + +Declare tuples with ``e.tuple``. Pass in an array to declare a "regular" +(unnamed) tuple; pass in an object to declare a named tuple. + +.. code-block:: typescript + + e.tuple([e.str("Peter Parker"), e.int64(18)]); + // ("Peter Parker", 18) + + e.tuple({ + name: e.str("Peter Parker"), + age: e.int64(18) + }); + // (name := "Peter Parker", age := 18) + +Tuple expressions support indexing. + +.. code-block:: typescript + + // Unnamed tuples + const spidey = e.tuple([ + e.str("Peter Parker"), + e.int64(18) + ]); + spidey[0]; // => ("Peter Parker", 18)[0] + spidey.index(0); // => ("Peter Parker", 18)[0] + spidey.index(e.int64(0)); // => ("Peter Parker", 18)[0] + + // Named tuples + const spidey = e.tuple({ + name: e.str("Peter Parker"), + age: e.int64(18) + }); + spidey.name; + // (name := "Peter Parker", age := 18).name + +Set literals +^^^^^^^^^^^^ + +Declare sets with ``e.set``. + +.. code-block:: typescript + + e.set(e.str("asdf"), e.str("qwer")); + // {'asdf', 'qwer'} + +As in EdgeQL, sets can't contain elements with incompatible types. These +semantics are enforced by TypeScript. + +.. code-block:: typescript + + e.set(e.int64(1234), e.str(1234)); + // TypeError + +Empty sets +^^^^^^^^^^ + +To declare an empty set, cast an empty set to the desired type. As in EdgeQL, +empty sets are not allowed without a cast. + +.. code-block:: typescript + + e.cast(e.int64, e.set()); + // {} + + +.. Modules +.. ------- + +.. All *types*, *functions*, and *commands* are available on the ``e`` object, properly namespaced by module. + +.. .. code-block:: typescript + +.. // commands +.. e.select; +.. e.insert; +.. e.update; +.. e.delete; + +.. // types +.. e.std.str; +.. e.std.int64; +.. e.std.bool; +.. e.cal.local_datetime; +.. e.default.User; // user-defined object type +.. e.my_module.Foo; // object type in user-defined module + +.. // functions +.. e.std.len; +.. e.std.str_upper; +.. e.math.floor; +.. e.sys.get_version; + +.. For convenience, the contents of the ``std`` and ``default`` modules are also exposed at the top-level of ``e``. + +.. .. code-block:: typescript + +.. e.str; +.. e.int64; +.. e.bool; +.. e.len; +.. e.str_upper; +.. e.User; + +.. .. note:: + +.. If there are any name conflicts (e.g. a user-defined module called ``len``), +.. ``e.len`` will point to the user-defined module; in that scenario, you must +.. explicitly use ``e.std.len`` to access the built-in ``len`` function. diff --git a/docs/objects.rst b/docs/objects.rst new file mode 100644 index 000000000..370d3e5ca --- /dev/null +++ b/docs/objects.rst @@ -0,0 +1,127 @@ +.. _edgedb-js-objects: + + +Objects and paths +================= + +All queries on this page assume the following schema. + +.. code-block:: sdl + + module default { + type Account { + required property username -> str { + constraint exclusive; + }; + multi link watchlist -> Media; + } + + type Person { + required property name -> str; + } + + abstract type Media { + required property title -> str; + multi link cast -> Person { + property character_name -> str; + }; + } + + type Movie extending Media { + property runtime -> duration; + } + + type TVShow extending Media { + property number_of_seasons -> int64; + } + } + +Object types +^^^^^^^^^^^^ + +All object types in your schema are reflected into the query builder, properly +namespaced by module. + +.. code-block:: typescript + + e.default.Person; + e.default.Movie; + e.default.TVShow; + e.my_module.SomeType; + +For convenience, the contents of the ``default`` module are also available at +the top-level of ``e``. + +.. code-block:: typescript + + e.Person; + e.Movie; + e.TVShow; + +.. As in EdgeQL, type names like ``Movie`` serve two purposes. + +.. - They can be used to represent the set of all Movie objects: ``select Movie``. +.. - They can be used to represent the Movie *type* in operations like type intersections: ``select Media[is Movie]`` + +Paths +^^^^^ + +EdgeQL-style *paths* are supported on object type references. + +.. code-block:: typescript + + e.Person.name; // Person.name + e.Movie.title; // Movie.title + e.TVShow.cast.name; // Movie.cast.name + +Paths can be constructed from any object expression, not just the root types. + +.. code-block:: typescript + + e.select(e.Person).name; + // (select Person).name + + e.op(e.Movie, 'union', e.TVShow).cast; + // (Movie union TVShow).cast + + const ironMan = e.insert(e.Movie, { + title: "Iron Man" + }); + ironMan.title; + // (insert Movie { title := "Iron Man" }).title + + +Type intersections +^^^^^^^^^^^^^^^^^^ + +Use the type intersection operator to narrow the type of a set of objects. For +instance, to represent the elements of an Account's watchlist that are of type +``TVShow``: + +.. code-block:: typescript + + e.Person.acted_in.is(e.TVShow); + // Person.acted_in[is TVShow] + + +Backlinks +^^^^^^^^^ + +All possible backlinks are auto-generated and can be auto-completed by +TypeScript. They behave just like forward links. However, because they contain +special characters, you must use bracket syntax instead of simple dot notation. + +.. code-block:: typescript + + e.Person[" + e.op(params.name) + ); + /* with name := $name + select name; + */ + + +The first argument is an object defining the parameter names and their +corresponding types. The second argument is a closure that returns an +expression; use the ``params`` argument to construct the rest of your query. + +Passing parameter data +^^^^^^^^^^^^^^^^^^^^^^ + +To executing a query with parameters, pass the parameter data as the second +argument to ``.run()``; this argument is *fully typed*! + +.. code-block:: typescript + + await helloQuery.run(client, { name: "Harry Styles" }) + // => "Yer a wizard, Harry Styles" + + await query.run(client, { name: 16 }) + // => TypeError: number is not assignable to string + +Top-level usage +^^^^^^^^^^^^^^^ + +Note that the expression being ``run`` must be the one declared with +``e.params``; in other words, you can only use ``e.params`` at the *top level* +of your query, not as an expression inside a larger query. + +.. code-block:: typescript + + const wrappedQuery = e.select(helloQuery); + + await e.select(helloQuery).run(client, {name: "Harry Styles"}); + // TypeError + + +Parameter types +^^^^^^^^^^^^^^^ +In EdgeQL, parameters can only be primitives or arrays of primitives. That's +not true with the query builder! Parameter types can be arbitrarily complex. +Under the hood, the query builder serializes the parameters to JSON and +deserializes them on the server. + +.. code-block:: typescript + + const complexParams = e.params( + { + title: e.str, + runtime: e.duration, + cast: e.array( + e.tuple({ + name: e.str, + character_name: e.str, + }) + ), + }, + params => e.insert(e.Movie, { + // ... + }) + ); + + await insertMovie.run(client, { + title: "Dune", + runtime: new edgedb.Duration(0, 0, 0, 0, 2, 35), + cast: [ + {name: "Timmy", character_name: "Paul"}, + {name: "JMo", character_name: "Idaho"}, + ] + }) + diff --git a/docs/api/types.rst b/docs/reference.rst similarity index 54% rename from docs/api/types.rst rename to docs/reference.rst index dbff10014..942b51d75 100644 --- a/docs/api/types.rst +++ b/docs/reference.rst @@ -1,10 +1,428 @@ +.. _edgedb-js-api-reference: + +######### +Reference +######### + +.. _edgedb-js-api-client: + +Client +====== + +.. js:function:: createClient( \ + options: string | ConnectOptions | null \ + ): Client + + Creates a new :js:class:`Client` instance. + + :param options: + This is an optional parameter. When it is not specified the client + will connect to the current EdgeDB Project instance. + + If this parameter is a string it can represent either a + DSN or an instance name: + + * when the string does not start with ``edgedb://`` it is a + :ref:`name of an instance `; + + * otherwise it specifies a single string in the connection URI format: + ``edgedb://user:password@host:port/database?option=value``. + + See the :ref:`Connection Parameters ` + docs for full details. + + Alternatively the parameter can be a ``ConnectOptions`` config; + see the documentation of valid options below. + + :param string options.dsn: + Specifies the DSN of the instance. + + :param string options.credentialsFile: + Path to a file containing credentials. + + :param string options.host: + Database host address as either an IP address or a domain name. + + :param number options.port: + Port number to connect to at the server host. + + :param string options.user: + The name of the database role used for authentication. + + :param string options.database: + The name of the database to connect to. + + :param string options.password: + Password to be used for authentication, if the server requires one. + + :param string options.tlsCAFile: + Path to a file containing the root certificate of the server. + + :param boolean options.tlsSecurity: + Determines whether certificate and hostname verification is enabled. + Valid values are ``'strict'`` (certificate will be fully validated), + ``'no_host_verification'`` (certificate will be validated, but + hostname may not match), ``'insecure'`` (certificate not validated, + self-signed certificates will be trusted), or ``'default'`` (acts as + ``strict`` by default, or ``no_host_verification`` if ``tlsCAFile`` + is set). + + The above connection options can also be specified by their corresponding + environment variable. If none of ``dsn``, ``credentialsFile``, ``host`` or + ``port`` are explicitly specified, the client will connect to your + linked project instance, if it exists. For full details, see the + :ref:`Connection Parameters ` docs. + + + :param number options.timeout: + Connection timeout in milliseconds. + + :param number options.waitUntilAvailable: + If first connection fails, the number of milliseconds to keep retrying + to connect (Defaults to 30 seconds). Useful if your development + instance and app are started together, to allow the server time to + be ready. + + :param number options.concurrency: + The maximum number of connection the ``Client`` will create in it's + connection pool. If not specified the concurrency will be controlled + by the server. This is recommended as it allows the server to better + manage the number of client connections based on it's own available + resources. + + :returns: + Returns an instance of :js:class:`Client`. + + Example: + + .. code-block:: js + + // Use the Node.js assert library to test results. + const assert = require("assert"); + const edgedb = require("edgedb"); + + async function main() { + const client = edgedb.createClient(); + + const data = await client.querySingle("select 1 + 1"); + + // The result is a number 2. + assert(typeof data === "number"); + assert(data === 2); + } + + main(); + + +.. js:class:: Client + + A ``Client`` allows you to run queries on an EdgeDB instance. + + Since opening connections is an expensive operation, ``Client`` also + maintains a internal pool of connections to the instance, allowing + connections to be automatically reused, and you to run multiple queries + on the client simultaneously, enhancing the performance of + database interactions. + + :js:class:`Client` is not meant to be instantiated directly; + :js:func:`createClient` should be used instead. + + + .. _edgedb-js-api-async-optargs: + + .. note:: + + Some methods take query arguments as an *args* parameter. The type of + the *args* parameter depends on the query: + + * If the query uses positional query arguments, the *args* parameter + must be an ``array`` of values of the types specified by each query + argument's type cast. + * If the query uses named query arguments, the *args* parameter must + be an ``object`` with property names and values corresponding to + the query argument names and type casts. + + If a query argument is defined as ``optional``, the key/value can be + either omitted from the *args* object or be a ``null`` value. + + .. js:method:: execute(query: string): Promise + + Execute an EdgeQL command (or commands). + + :param query: Query text. + + This commands takes no arguments. + + Example: + + .. code-block:: js + + await client.execute(` + CREATE TYPE MyType { + CREATE PROPERTY a -> int64 + }; + + for x in {100, 200, 300} + union (insert MyType { a := x }); + `) + + .. js:method:: query(query: string, args?: QueryArgs): Promise + + Run a query and return the results as an array. This method **always** + returns an array. + + This method takes :ref:`optional query arguments + `. + + .. js:method:: querySingle( \ + query: string, \ + args?: QueryArgs \ + ): Promise + + Run an optional singleton-returning query and return the result. + + This method takes :ref:`optional query arguments + `. + + The *query* must return no more than one element. If the query returns + more than one element, a ``ResultCardinalityMismatchError`` error is + thrown. + + .. js:method:: queryRequiredSingle( \ + query: string, \ + args?: QueryArgs \ + ): Promise + + Run a singleton-returning query and return the result. + + This method takes :ref:`optional query arguments + `. + + The *query* must return exactly one element. If the query returns + more than one element, a ``ResultCardinalityMismatchError`` error is + thrown. If the query returns an empty set, a ``NoDataError`` error is + thrown. + + .. js:method:: queryJSON(query: string, args?: QueryArgs): Promise + + Run a query and return the results as JSON. + + This method takes :ref:`optional query arguments + `. + + .. note:: + + Caution is advised when reading ``decimal`` or ``bigint`` + values using this method. The JSON specification does not + have a limit on significant digits, so a ``decimal`` or a + ``bigint`` number can be losslessly represented in JSON. + However, JSON decoders in JavaScript will often read all + such numbers as ``number`` values, which may result in + precision loss. If such loss is unacceptable, then + consider casting the value into ``str`` and decoding it on + the client side into a more appropriate type, such as + BigInt_. + + .. js:method:: querySingleJSON( \ + query: string, \ + args?: QueryArgs \ + ): Promise + + Run an optional singleton-returning query and return its element + in JSON. + + This method takes :ref:`optional query arguments + `. + + The *query* must return at most one element. If the query returns + more than one element, an ``ResultCardinalityMismatchError`` error + is thrown. + + .. note:: + + Caution is advised when reading ``decimal`` or ``bigint`` + values using this method. The JSON specification does not + have a limit on significant digits, so a ``decimal`` or a + ``bigint`` number can be losslessly represented in JSON. + However, JSON decoders in JavaScript will often read all + such numbers as ``number`` values, which may result in + precision loss. If such loss is unacceptable, then + consider casting the value into ``str`` and decoding it on + the client side into a more appropriate type, such as + BigInt_. + + .. js:method:: queryRequiredSingleJSON( \ + query: string, \ + args?: QueryArgs \ + ): Promise + + Run a singleton-returning query and return its element in JSON. + + This method takes :ref:`optional query arguments + `. + + The *query* must return exactly one element. If the query returns + more than one element, a ``ResultCardinalityMismatchError`` error + is thrown. If the query returns an empty set, a ``NoDataError`` error + is thrown. + + .. note:: + + Caution is advised when reading ``decimal`` or ``bigint`` + values using this method. The JSON specification does not + have a limit on significant digits, so a ``decimal`` or a + ``bigint`` number can be losslessly represented in JSON. + However, JSON decoders in JavaScript will often read all + such numbers as ``number`` values, which may result in + precision loss. If such loss is unacceptable, then + consider casting the value into ``str`` and decoding it on + the client side into a more appropriate type, such as + BigInt_. + + .. js:method:: transaction( \ + action: (tx: Transaction) => Promise \ + ): Promise + + Execute a retryable transaction. The ``Transaction`` object passed to + the action function has the same ``execute`` and ``query*`` methods + as ``Client``. + + This is the preferred method of initiating and running a database + transaction in a robust fashion. The ``transaction()`` method + will attempt to re-execute the transaction body if a transient error + occurs, such as a network error or a transaction serialization error. + The number of times ``transaction()`` will attempt to execute the + transaction, and the backoff timeout between retries can be + configured with :js:meth:`Client.withRetryOptions`. + + See :ref:`edgedb-js-api-transaction` for more details. + + Example: + + .. code-block:: js + + await client.transaction(async tx => { + const value = await tx.querySingle("select Counter.value") + await tx.execute( + `update Counter set { value := $value }`, + {value: value + 1}, + ) + }); + + Note that we are executing queries on the ``tx`` object rather + than on the original ``client``. + + .. js:method:: ensureConnected(): Promise + + If the client does not yet have any open connections in its pool, + attempts to open a connection, else returns immediately. + + Since the client lazily creates new connections as needed (up to the + configured ``concurrency`` limit), the first connection attempt will + only occur when the first query is run a client. ``ensureConnected`` + can be useful to catch any errors resulting from connection + mis-configuration by triggering the first connection attempt + explicitly. + + Example: + + .. code-block:: js + + import {createClient} from 'edgedb'; + + async function getClient() { + try { + return await createClient('custom_instance').ensureConnected(); + } catch (err) { + // handle connection error + } + } + + function main() { + const client = await getClient(); + + await client.query('select ...'); + } + + .. js:method:: withRetryOptions(opts: { \ + attempts?: number \ + backoff?: (attempt: number) => number \ + }): Client + + Returns a new ``Client`` instance with the specified retry attempts + number and backoff time function (the time that retrying methods will + wait between retry attempts, in milliseconds), where options not given + are inherited from the current client instance. + + The default number of attempts is ``3``. The default backoff + function returns a random time between 100 and 200ms multiplied by + ``2 ^ attempt number``. + + .. note:: + + The new client instance will share the same connection pool as the + client it's created from, so calling the ``ensureConnected``, + ``close`` and ``terminate`` methods will affect all clients + sharing the pool. + + Example: + + .. code-block:: js + + import {createClient} from 'edgedb'; + + function main() { + const client = createClient(); + + // By default transactions will retry if they fail + await client.transaction(async tx => { + // ... + }); + + const nonRetryingClient = client.withRetryOptions({ + attempts: 1 + }); + + // This transaction will not retry + await nonRetryingClient.transaction(async tx => { + // ... + }); + } + + .. js:method:: close(): Promise + + Close the client's open connections gracefully. When a client is + closed, all its underlying connections are awaited to complete their + pending operations, then closed. A warning is produced if the pool + takes more than 60 seconds to close. + + .. note:: + + Clients will not prevent Node.js from exiting once all of it's + open connections are idle and Node.js has no further tasks it is + awaiting on, so it is not necessary to explicitly call ``close()`` + if it is more convenient for your application. + + (This does not apply to Deno, since Deno is missing the + required API's to ``unref`` idle connections) + + .. js:method:: isClosed(): boolean + + Returns true if ``close()`` has been called on the client. + + .. js:method:: terminate(): void + + Terminate all connections in the client, closing all connections non + gracefully. If the client is already closed, return without doing + anything. + + .. _edgedb-js-datatypes: -========= -Datatypes -========= +Type conversion +=============== -edgedb-js automatically converts EdgeDB types to the corresponding JavaScript +The driver automatically converts EdgeDB types to the corresponding JavaScript types and vice versa. The table below shows the correspondence between EdgeDB and JavaScript types. diff --git a/docs/select.rst b/docs/select.rst new file mode 100644 index 000000000..580d90c48 --- /dev/null +++ b/docs/select.rst @@ -0,0 +1,378 @@ +.. _edgedb-js-select: + +Select +------ + +The full power of the EdgeQL ``select`` statement is available as a top-level +``e.select`` function. All queries on this page assume the Netflix schema +described on the :ref:`Objects page `. + +Selecting scalars +^^^^^^^^^^^^^^^^^ + +Any scalar expression be passed into ``e.select``, though it's often +unnecessary, since expressions are ``run``able without being wrapped by +``e.select``. + +.. code-block:: typescript + + e.select(e.str('Hello world')); + // select 1234; + + e.select(a.op(e.int64(2), '+', e.int64(2))); + // select 2 + 2; + +Selecting free objects +^^^^^^^^^^^^^^^^^^^^^^ + +Select a free object by passing an object into ``e.select`` + +.. code-block:: typescript + + e.select({ + name: e.str("Name"), + number: e.int64(1234), + movies: e.Movie, + }); + /* select { + name := "Name", + number := 1234, + movies := Movie + } */ + +Selecting objects +^^^^^^^^^^^^^^^^^ + +As in EdgeQL, selecting an set of objects without a shape will return their +``id`` property only. This is reflected in the TypeScript type of the result. + +.. code-block:: typescript + + const query = e.select(e.Movie); + // select Movie; + + const result = await query.run(client); + // {id:string}[] + +Shapes +^^^^^^ + +To specify a shape, pass a function as the second argument. This function +should return an object that specifies which properties to include in the +result. This roughly corresponds to a *shape* in EdgeQL. + +.. code-block:: typescript + + const query = e.select(e.Movie, ()=>({ + id: true, + title: true, + runtime: true, + })); + /* + select Movie { + id, + title, + runtime + } + */ + +Note that the type of the query result is properly inferred from the shape. +This is true for all queries on this page. + +.. code-block:: typescript + + const result = await query.run(client); + /* { + id: string; + title: string; + runtime: Duration | undefined; + }[] */ + +As you can see, the type of ``runtime`` is ``Duration | undefined`` since it's +an optional property, whereas ``id`` and ``title`` are required. + + +Passing a ``boolean`` value (as opposed to a ``true`` literal), which will +make the property optional. Passing ``false`` will exclude that property. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + id: true, + title: Math.random() > 0.5, + runtime: false, + })); + + const result = await query.run(client); + // {id: string; title: string | undefined; runtime: never}[] + +Nesting shapes + +As in EdgeQL, shapes can be nested to fetch deeply related objects. + +.. code-block:: typescript + + const query = e.select(e.Movie, () => ({ + id: true, + title: true, + cast: { + name: true + } + })); + + const result = await query.run(client); + /* { + id: string; + title: string; + cast: { name: string }[] + }[] */ + + +Why closures? +^^^^^^^^^^^^^ + +In EdgeQL, a ``select`` statement introduces a new *scope*; within the clauses +of a select statement, you can refer to fields of the *elements being +selected* using leading dot notation. + +.. code-block:: edgeql + + select Movie { id, title } + filter .title = "The Avengers"; + +Here, ``.title`` is shorthand for the ``title`` property of the selected +``Movie`` elements. All properties/links on the ``Movie`` type can be +referenced using this shorthand anywhere in the ``select`` expression. In +other words, the ``select`` expression is *scoped* to the ``Movie`` type. + +To represent this scoping in the query builder, we use function scoping. This +is a powerful pattern that makes it painless to represent filters, ordering, +computed fields, and other expressions. Let's see it in action. + + +Filtering +^^^^^^^^^ + +To add a filtering clause, just include a ``filter`` key in the returned +params object. This should correspond to a boolean expression. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + id: true, + title: true, + filter: e.op(movie.title, 'ilike', "The Matrix%") + })); + /* + select Movie { + id, + title + } filter .title ilike "The Matrix%" + */ + +Since ``filter`` is a reserved keyword in EdgeQL, there is minimal danger of +conflicting with a property or link named ``filter``. All shapes can contain +filter clauses, even nested ones. + +### Nested filtering + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + title: true, + cast: actor => ({ + name: true, + filter: e.op(actor.name.slice(0, 1), '=', 'A'), + }), + filter: e.op(movie.title, '=', 'Iron Man'), + })); + + +Ordering +^^^^^^^^ + +As with ``filter``, you can pass a value with the special ``order_by`` key. To +simply order by a property: + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + order_by: movie.title, + })); + +The ``order`` key can correspond to an arbitrary expression. + +.. code-block:: typescript + + // order by length of title + e.select(e.Movie, movie => ({ + order_by: e.len(movie.title), + })); + /* + select Movie + order by len(.title) + */ + + // order by number of cast members + e.select(e.Movie, movie => ({ + order_by: e.count(movie.cast), + })); + /* + select Movie + order by count(.cast) + */ + +You can customize the sort direction and empty-handling behavior by passing an +object into ``order_by``. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + order_by: { + expression: movie.title, + direction: e.DESC, + empty: e.EMPTY_FIRST, + }, + })); + /* + select Movie + order by .title desc empty first + */ + +.. list-table:: + + * - Order direction + - ``e.DESC`` ``e.ASC`` + * - Empty handling + - ``e.EMPTY_FIRST`` ``e.EMPTY_LAST`` + +Pass an array of objects to do multiple ordering. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + title: true, + order_by: [ + { + expression: movie.title, + direction: e.DESC, + }, + { + expression: e.count(movie.cast), + direction: e.ASC, + empty: e.EMPTY_LAST, + }, + ], + })); + + +Pagination +^^^^^^^^^^ + +Use ``offset`` and ``limit`` to paginate queries. You can pass an expression +with an integer type or a plain JS number. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + offset: 50, + limit: e.int64(10), + })); + /* + select Movie + offset 50 + limit 10 + */ + +Computeds +^^^^^^^^^ + +To add a computed field, just add it to the returned shape alongside the other +elements. All reflected functions are typesafe, so the output type + +.. code-block:: typescript + + const query = e.select(e.Movie, movie => ({ + title: true, + uppercase_title: e.str_upper(movie.title), + title_length: e.len(movie.title), + })); + + const result = await query.run(client); + /* => + [ + { + title:"Iron Man", + uppercase_title: "IRON MAN", + title_length: 8 + }, + ... + ] + */ + // {name: string; uppercase_title: string, title_length: number}[] + + +Computables can "override" an actual link/property as long as the type +signatures agree. + +.. code-block:: typescript + + e.select(e.Movie, movie => ({ + title: e.str_upper(movie.title), // this works + runtime: e.int64(55), // TypeError + + // you can override links too + cast: e.Person, + })); + + +Polymorphism +^^^^^^^^^^^^ + +EdgeQL supports polymorphic queries using the ``[is type]`` prefix. + +.. code-block:: edgeql + + select Content { + title, + [is Movie].runtime, + [is TVShow].num_episodes + } + +In the query builder, this is represented with the ``e.is`` function. + +.. code-block:: typescript + + e.select(e.Content, content => ({ + title: true, + ...e.is(e.Movie, { runtime: true }), + ...e.is(e.TVShow, { num_episodes: true }), + })); + + const result = await query.run(client); + /* { + title: string; + runtime: Duration | null; + num_episodes: number | null; + }[] */ + +The ``runtime`` and ``num_episodes`` properties are nullable to reflect the +fact that they will only occur in certain objects. + + +Detached +^^^^^^^^ + +.. code-block:: typescript + + const query = e.select(e.Person, (outer) => ({ + name: true, + castmates: e.select(detachedPerson, (inner) => ({ + name: true, + filter: e.op( + e.op(outer.acted_in, 'in', inner.acted_in), + 'and', + e.op(outer, '!=', inner) // don't include self + ), + })), + })); diff --git a/docs/types.rst b/docs/types.rst new file mode 100644 index 000000000..a4660f1aa --- /dev/null +++ b/docs/types.rst @@ -0,0 +1,122 @@ +.. _edgedb-js-types-and-casting: + + +Types +----- + +The properties of ``e`` that corresond to types—``e.str``, ``e.int64``, etc— +serve a dual purpose. + +- They can be used as functions to instantiate literals: ``e.str("hi")``. +- They are also used to represent the *type itself* for certain type + operations like *casting* and *declaring parameters*. + +Reflected types +^^^^^^^^^^^^^^^ + +The entire type system of EdgeDB is reflected in the ``e`` object, including +scalar types, object types, and enums. + +.. code-block:: typescript + + e.str; + e.bool; + e.int16; + e.int32; + e.int64; + e.float32; + e.float64; + e.bigin; + e.decimal; + e.datetime; + e.duration; + e.bytes; + e.json; + e.cal.local_datetime; + e.cal.local_date; + e.cal.local_time; + e.cal.relative_duration; + + e.Movie; // user-defined object type + e.Genre; // user-defined enum + + +Collection types +^^^^^^^^^^^^^^^^ + +Construct array and tuple types. + +.. code-block:: typescript + + e.array(e.bool); + // array + + e.tuple([e.str, e.int64]); + // tuple + + e.tuple({ + name: e.str, + age: e.int64 + }); + // tuple + + +.. _ref_qb_casting: + +Casting +^^^^^^^ + +These types can be used to *cast* one expression to another type. + +.. code-block:: typescript + + e.cast(e.json, e.int64('123')); + // '123' + + e.cast(e.duration, e.str('127 hours')); + // '127 hours' + + +Custom literals +^^^^^^^^^^^^^^^ + +You can use ``e.literal`` to create literals corresponding to collection +types like tuples, arrays, and primitives. The first argument expects a type, +the second expects a *value* of that type. + +.. code-block:: typescript + + e.literal(e.str, "sup"); + // equivalent to: e.str("sup") + + e.literal(e.array(e.int16), [1, 2, 3]); + // >[1, 2, 3] + + e.literal(e.tuple([e.str, e.int64]), ['baz', 9000]); + // >("Goku", 9000) + + e.literal( + e.tuple({name: e.str, power_level: e.int64}), + {name: 'Goku', power_level: 9000} + ); + // >("asdf", false) + +Parameters +^^^^^^^^^^ + +Types are also necessary for declaring *query parameters*. + +Pass strongly-typed parameters into your query with ``e.params``. + +.. code-block:: typescript + + const query = e.params({name: e.str}, params => + e.op(e.str("Yer a wizard, "), "++", params.name) + ); + + await query.run(client, {name: "Harry"}); + // => "Yer a wizard, Harry" + + +The full documentation on using parameters is :ref:`here +`. diff --git a/docs/typescript.rst b/docs/typescript.rst deleted file mode 100644 index 971d96b5e..000000000 --- a/docs/typescript.rst +++ /dev/null @@ -1,41 +0,0 @@ -.. _edgedb-js-typescript: - - -TypeScript -=========== - -The ``query`` and ``querySingle`` methods are generic. Pass a type annotation -to these methods to retrieve a strongly typed result. - -.. code-block:: ts - - import * as edgedb from "edgedb"; - - interface User { - id: string; - name: string; - dob: edgedb.LocalDate; - } - - async function main() { - - const client = edgedb.createClient(); - - // Select several Users - let userSet = await client.query( - `select User {id, name, dob} filter .name ilike 'B%';` - ); - - userSet[0].name; // "Bob" - - - // Select a single user - const bob = await client.querySingle( - `select User {id, name, dob} filter .name = 'Bob' limit 1;` - ); - - bob.dob; // edgedb.LocalDate - - } - -A TypeScript-native query builder for EdgeQL is currently under development. diff --git a/docs/update.rst b/docs/update.rst new file mode 100644 index 000000000..944c4d1a7 --- /dev/null +++ b/docs/update.rst @@ -0,0 +1,104 @@ +.. _edgedb-js-update: + +Update +------ + +Update objects with the ``e.update`` function. + +.. code-block:: typescript + + e.update(e.Movie, movie => ({ + filter: e.op(movie.title, '=', e.str("Avengers 4")), + set: { + title: "Avengers: Endgame" + } + })) + + +The parameter object supports the full set of clauses for filtering, ordering, +and pagination. + +.. code-block:: typescript + + e.update(e.Movie, movie => ({ + filter: ..., + order_by: ..., + offset: ..., + limit: ..., + set: { + // ... + } + })) + + +You can reference the current value of the object's properties. + +.. code-block:: typescript + + e.update(e.Movie, movie => ({ + filter: e.op(movie.title[0], '=', ' '), + set: { + title: e.str_trim(movie.title) + } + })) + + +Updating links +^^^^^^^^^^^^^^ + +EdgeQL supports some convenient syntax for appending to, subtracting from, and +overwriting links. + +.. code-block:: edgeql + + update Movie set { + # overwrite + cast := Person, + + # add to link + cast += Person, + + # subtract from link + cast -= Person + } + +In the query builder this is represented with the following syntax. + +**Overwrite a link** + +.. code-block:: typescript + + const castMembers = e.select(e.Person, ...); + e.update(e.Movie, movie => ({ + filter: e.op(movie.title, '=', 'The Eternals'), + set: { + cast: castMembers, + } + })) + +**Add to a link** + +.. code-block:: typescript + + const castMembers = e.select(e.Person, ...); + e.update(e.Movie, movie => ({ + filter: e.op(movie.title, '=', 'The Eternals'), + set: { + cast: { "+=": castMembers }, + } + })) + + +**Subtract from a link** + +.. code-block:: typescript + + const castMembers = e.select(e.Person, ...); + e.update(e.Movie, movie => ({ + filter: e.op(movie.title, '=', 'The Eternals'), + set: { + characters: { "-=": castMembers }, + } + })) + + diff --git a/docs/usage.rst b/docs/usage.rst deleted file mode 100644 index 29c5e82a9..000000000 --- a/docs/usage.rst +++ /dev/null @@ -1,167 +0,0 @@ -.. _edgedb-js-examples: - - -Basic Usage -=========== - - -Connection ----------- - -The client library must be able to establish a connection to a running EdgeDB -instance to execute queries. Refer to the :ref:`Client Library Connection -` docs for details on configuring connections. - -Creating a Client ------------------ - -The interaction with the database normally starts with a call to -``createClient()``, which returns a new ``Client`` object. The client will -maintains a pool of connections to your EdgeDB instance and provides methods -to run queries. - -.. code-block:: js - - const edgedb = require("edgedb"); - - async function main() { - // If you're running in an EdgeDB project directory, there's no need - // to provide any connection config to 'createClient', edgedb-js will - // find your database instance automatically - const client = edgedb.createClient(); - - // The 'Client' creates connections lazily as they are needed, so until - // you run a query no connection will be made. If you want to explicitly - // ensure that the client is connected, use the 'ensureConnected' method: - // await client.ensureConnected(); - - // Create a User object type. - await client.execute(` - CREATE TYPE User { - CREATE REQUIRED PROPERTY name -> str; - CREATE PROPERTY dob -> cal::local_date; - } - `); - - // Insert a new User object. - await client.query( - `insert User { - name := $name, - dob := $dob - }`, - { - name: "Bob", - dob: new edgedb.LocalDate(1984, 3, 1) - } - ); - - // Select User objects. - const userBob = await client.querySingle( - `select User {name, dob} - filter .name = $name`, - { name: "Bob" } - ); - console.log(userBob); - // { name: 'Bob', dob: edgedb.LocalDate(1984, 3, 1) } - - // Try running multiple queries at once - const results = await Promise.all([ - client.query(`select User`), - client.querySingle(`select 1 + 2`), - ]); - console.log(results); - // [ - // [{ name: 'Bob', dob: edgedb.LocalDate(1984, 3, 1) }], - // 3 - // ] - - client.close(); - } - - main(); - -TypeScript ---------------- - -For details on usage with TypeScript, go to :ref:`edgedb-js-typescript`. - - -Type Conversion ---------------- - -``edgedb`` automatically converts EdgeDB types to the corresponding -JavaScript types and vice versa. See :ref:`edgedb-js-datatypes` for details. - - -.. _edgedb-js-api-transaction: - -Transactions ------------- - -The most robust way to execute transactional code is to use -the ``transaction()`` API: - -.. code-block:: js - - await client.transaction(tx => { - await tx.execute("insert User {name := 'Don'}"); - }); - -Note that we execute queries on the ``tx`` object in the above -example, rather than on the original ``client`` object. - -The ``transaction()`` API guarantees that: - -1. Transactions are executed atomically; -2. If a transaction is failed for any of the number of transient errors (i.e. - a network failure or a concurrent update error), the transaction - would be retried; -3. If any other, non-retryable exception occurs, the transaction is rolled - back, and the exception is propagated, immediately aborting the - ``transaction()`` block. - -The key implication of retrying transactions is that the entire -nested code block can be re-run, including any non-querying -JavaScript code. Here is an example: - -.. code-block:: js - - client.transaction(tx => { - const user = await tx.querySingle( - `select User { email } filter .login = $login`, - {login}, - ) - const query = await fetch( - 'https://service.local/email_info', { - body: JSON.stringify({email: user.email}) - headers: { 'Content-Type': 'application/json' }, - }, - ) - const data = await query.json() - await tx.querySingle(` - update User filter .login = $login - set { email_info := $data} - `, { - login, - data, - }) - }) - -In the above example, the execution of the HTTP request would be retried -too. The core of the issue is that whenever transaction is interrupted -user might have the email changed (as the result of concurrent -transaction), so we have to redo all the work done. - -Generally it's recommended to not execute any long running -code within the transaction unless absolutely necessary. - -Transactions allocate expensive server resources and having -too many concurrently running long-running transactions will -negatively impact the performance of the DB server. - -See also: - -* RFC1004_ -* :js:meth:`Client.transaction\` - -.. _RFC1004: https://github.com/edgedb/rfcs/blob/master/text/1004-transactions-api.rst diff --git a/docs/with.rst b/docs/with.rst new file mode 100644 index 000000000..3b2f8f7d7 --- /dev/null +++ b/docs/with.rst @@ -0,0 +1,65 @@ +.. _edgedb-js-with: + +With blocks +----------- + +:edb-alt-title: With blocks + +During the query rendering step, the number of occurrences of each expression +are tracked. All expressions that are referenced more than once and are not +explicitly defined in a ``WITH`` block (with ``e.with``), are extracted into +the nearest ``WITH`` block that encloses all usages of the expression. + +.. code-block:: typescript + + const a = e.set(e.int64(1), e.int64(2), e.int64(3)); + const b = e.alias(a); + + e.select(e.plus(a, b)).toEdgeQL(); + // WITH + // a := {1, 2, 3}, + // b := a + // SELECT a + b + +This hold for expressions of arbitrary complexity. + +.. code-block:: typescript + + const newActor = e.insert(e.Person, { + name: "Colin Farrell" + }); + + const newMovie = e.insert(e.Movie, { + title: "The Batman", + cast: newActor + }); + + const query = e.select(newMovie, ()=>({ + id: true, + title: true, + cast: { name: true } + })); + + +To embed ``WITH`` statements inside queries, you can short-circuit this logic +with a "dependency list". It's an error to pass an expr to multiple +``e.with``s, and an error to use an expr passed to ``e.with`` outside of that +WITH block in the query. + + +.. code-block:: typescript + + const newActor = e.insert(e.Person, { + name: "Colin Farrell" + }); + + e.insert(e.Movie, { + cast: e.with([newActor], // list "dependencies"; + e.select(newActor, ()=>({ + id: true, + title: true, + })) + ) + }) + + diff --git a/edgedb-generate/index.js b/edgedb-generate/index.js new file mode 100755 index 000000000..5212b9ebd --- /dev/null +++ b/edgedb-generate/index.js @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +console.log( + `Failure: must install edgedb module. + +To generate the EdgeDB query builder, you must have +the \`edgedb\` package installed as a dependency in +your local project: + +With npm: npm install edgedb +With yarn: yarn add edgedb + +Then run \`yarn edgeql-js\` again.` +); diff --git a/edgedb-generate/package.json b/edgedb-generate/package.json new file mode 100644 index 000000000..9cc809c13 --- /dev/null +++ b/edgedb-generate/package.json @@ -0,0 +1,24 @@ +{ + "name": "edgeql-js", + "version": "1.0.0", + "description": "Issues warning when npx edgeql-js is executed without locally installed package.", + "homepage": "https://edgedb.com/docs", + "author": "EdgeDB ", + "engines": { + "node": ">= 10.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/edgedb/edgedb-js.git" + }, + "main": "index.js", + "license": "Apache-2.0", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "edgeql-js": "./index.js" + }, + "bin": { + "edgeql-js": "./index.js" + }, + "keywords": [] +} diff --git a/edgedb-generate/yarn.lock b/edgedb-generate/yarn.lock new file mode 100644 index 000000000..4c29cbb27 --- /dev/null +++ b/edgedb-generate/yarn.lock @@ -0,0 +1,13 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 4 + +"edgedb-generate@workspace:.": + version: 0.0.0-use.local + resolution: "edgedb-generate@workspace:." + bin: + edgedb-generate: ./index.js + languageName: unknown + linkType: soft diff --git a/package.json b/package.json index baa7226d8..cabf09704 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "edgedb", - "description": "A JavaScript binding for EdgeDB", + "description": "The official Node.js client library for EdgeDB", "homepage": "https://edgedb.com/docs", "author": "EdgeDB ", "engines": { @@ -10,7 +10,7 @@ "type": "git", "url": "https://github.com/edgedb/edgedb-js.git" }, - "version": "0.18.0", + "version": "0.19.0-alpha.5", "main": "./dist/index.node.js", "types": "./dist/index.node.d.ts", "license": "Apache-2.0", @@ -21,7 +21,7 @@ "./dist/index.node.js": "./dist/index.browser.js" }, "bin": { - "edgedb-generate": "./dist/reflection/cli.js" + "edgeql-js": "./dist/reflection/cli.js" }, "devDependencies": { "@types/jest": "^24.0.11", @@ -39,9 +39,10 @@ "typescript": "^4.5.2" }, "scripts": { - "build": "yarn build:cjs && yarn build:esm", - "build:esm": "tsc --project tsconfig.build-esm.json && ./tools/copySyntaxToDist.sh", + "build": "yarn build:cjs && yarn build:esm && yarn copy:syntax", + "build:esm": "tsc --project tsconfig.build-esm.json", "build:cjs": "tsc --project tsconfig.build.json", + "copy:syntax": "./tools/copySyntaxToDist.sh", "test": "jest --detectOpenHandles", "test:all": "yarn test && yarn test:qb", "test:qb": "cd qb && yarn test", @@ -49,8 +50,7 @@ "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", "gen-errors": "edb gen-errors-json --client | node tools/gen_errors.js", "compileForDeno": "deno run --unstable --allow-env --allow-read --allow-write tools/compileForDeno.ts", - "build:dev": "nodemon -e ts -w ./src -w ./qb -x 'yarn tsc --project tsconfig.build.json --incremental'", - "dev": "yarn generate && echo \"Compiling TypeScript...\" && yarn build --incremental", - "dev:watch": "nodemon -e ts -w ./src -x 'yarn generate && echo \"Compiling TypeScript...\" && yarn build --incremental'" + "dev": "yarn tsc --project tsconfig.build.json --incremental && yarn copy:syntax && cd qb && yarn generate", + "dev:watch": "nodemon -e ts -w ./src -x 'yarn dev'" } } diff --git a/qb/.gitignore b/qb/.gitignore index e7ef0f83e..3d138f12c 100644 --- a/qb/.gitignore +++ b/qb/.gitignore @@ -1 +1,3 @@ -dbschema/edgeql +dbschema/edgeql-js +trace +trace/* diff --git a/qb/README.md b/qb/README.md index ede16860b..b384ea79f 100644 --- a/qb/README.md +++ b/qb/README.md @@ -25,7 +25,7 @@ The files inside `qb` import from the _built_ files in `edgedb-js/src`. So run ` $ yarn build ``` -The run `yarn generate` anywhere inside `edgedb-js` or `edgedb-js/qb`. Files are generated into `qb/dbschema/edgeql`. +The run `yarn generate` anywhere inside `edgedb-js` or `edgedb-js/qb`. Files are generated into `qb/dbschema/edgeql-js`. ``` yarn generate @@ -58,12 +58,12 @@ yarn test - `src/syntax`: All top-level syntactic structures are declared in this directory: literals, `set`, `cast`, `select`, etc. The contents of this directory are copied into the generated query builder. For all code inside `src/syntax`: - To import something from `src/reflection`, use the `"reflection"` path alias. - To import something from the generated code, use the `"@reflection/*"` alias. - - This is important, becauase these imports are rewritten with a simple find/replace when the `syntax` files are copied over into `qb/dbschema/edgeql`. See `generate.ts` for details. + - This is important, becauase these imports are rewritten with a simple find/replace when the `syntax` files are copied over into `qb/dbschema/edgeql-js`. See `generate.ts` for details. - `qb`: A directory added to make query builder development easier. It is an EdgeDB project containing a sample schema. - `qb/run.ts`: The script that generates the query builder. Delegates to generate.ts. - `qb/generate.ts`: The script that generates the query builder. - `qb/tests`: Directory containing QB tests. - - `qb/dbschema/edgeql`: The query builder is generated into this directory. This path is hard-coded in `run.ts`. - - `qb/dbschema/edgeql/modules/{MODULE_NAME}`: The contents of each module is generated into an appropriately named file. - - `qb/dbschema/edgeql/syntax`: Modified versions of the files in `src/syntax/*` are generated into this File - - `qb/dbschema/edgeql/__spec__.ts`: A "dehydrated" representation of all types in the database, including all metadata and inheritance info. These types are "hydrated" by the `makeType` function in `src/reflection/hydrate.ts`, which produces a statically typed + - `qb/dbschema/edgeql-js`: The query builder is generated into this directory. This path is hard-coded in `run.ts`. + - `qb/dbschema/edgeql-js/modules/{MODULE_NAME}`: The contents of each module is generated into an appropriately named file. + - `qb/dbschema/edgeql-js/syntax`: Modified versions of the files in `src/syntax/*` are generated into this File + - `qb/dbschema/edgeql-js/__spec__.ts`: A "dehydrated" representation of all types in the database, including all metadata and inheritance info. These types are "hydrated" by the `makeType` function in `src/reflection/hydrate.ts`, which produces a statically typed diff --git a/qb/RFC.md b/qb/RFC.md index e7b2972fd..03b80f9c9 100644 --- a/qb/RFC.md +++ b/qb/RFC.md @@ -257,7 +257,7 @@ Movie.characters; ```ts // Movie.characters[IS Hero] -Movie.characters.$is(e.Hero); +Movie.characters.is(e.Hero); ``` ### Backward links @@ -265,13 +265,13 @@ Movie.characters.$is(e.Hero); Provide backlinks that behave just like forward links: ```ts -Hero[">`. ```ts e.cast(e.int16, e.int32(1255)); // 1255; -e.cast(e.UUID, e.str("ab1bcd81...")); // 'ab1bcd81...'; +e.cast(e.uuid, e.str("ab1bcd81...")); // 'ab1bcd81...'; ``` ## Functions @@ -435,7 +435,7 @@ Simple: ```ts e.select(e.Hero, hero => ({ - order: hero.name, + order_by: hero.name, })); ``` @@ -443,7 +443,7 @@ Advanced: ```ts e.select(e.Hero, hero => ({ - order: { + order_by: { expression: hero.name, direction: e.DESC, empty: e.EMPTY_FIRST, @@ -456,7 +456,7 @@ Multiple ordering ```ts e.select(e.Hero, hero => ({ name: true, - order: [ + order_by: [ { expression: hero.name, direction: e.DESC, @@ -485,7 +485,7 @@ e.select(e.Hero, hero => ({ ```ts // select Movie { characters[IS Hero]: { id }} e.select(e.Movie, movie => ({ - characters: movie.characters.$is(e.Hero), + characters: movie.characters.is(e.Hero), })); ``` @@ -494,7 +494,7 @@ To specify shape, use subqueries: ```ts e.select(e.Movie, movie => ({ id: true, - characters: e.select(movie.characters.$is(e.default.Hero), hero => ({ + characters: e.select(movie.characters.is(e.default.Hero), hero => ({ id: true, secret_identity: true, })), @@ -551,7 +551,7 @@ e.insert(e.Movie, { // update method e.select(e.Movie, movie => ({ filter: e.eq(movie.title, e.str("Avengers 4")), - // order: ..., + // order_by: ..., // offset: ..., })).update({ // set @@ -574,7 +574,7 @@ e.select(e.Movie, movie => ({ ```ts e.select(e.Hero, hero => ({ filter: e.eq(hero.name, "Captain America"), - order: ..., + order_by: ..., offset: ..., limit: ... })) diff --git a/qb/dbschema/default.esdl b/qb/dbschema/default.esdl index 9b1373034..77fb90d5b 100644 --- a/qb/dbschema/default.esdl +++ b/qb/dbschema/default.esdl @@ -25,6 +25,9 @@ module default { property genre -> Genre; property rating -> float64; required property title -> str; + required property release_year -> int16 { + default := datetime_get(datetime_current(), 'year'); + } multi link characters extending movie_character -> Person; link profile -> Profile { constraint exclusive; diff --git a/qb/dbschema/edgeql-js/__spec__.ts b/qb/dbschema/edgeql-js/__spec__.ts new file mode 100644 index 000000000..eae87bef8 --- /dev/null +++ b/qb/dbschema/edgeql-js/__spec__.ts @@ -0,0 +1,124 @@ +import { $ } from "edgedb"; +const spec: $.introspect.Types = new $.StrictMap(); + +spec.set("00000000-0000-0000-0000-000000000002", {"id":"00000000-0000-0000-0000-000000000002","name":"anytuple","is_abstract":false,"kind":"unknown","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("00000000-0000-0000-0000-000000000001", {"id":"00000000-0000-0000-0000-000000000001","name":"anytype","is_abstract":false,"kind":"unknown","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("5d31584b-3a5f-533d-3d64-fab0fdab61b3", {"id":"5d31584b-3a5f-533d-3d64-fab0fdab61b3","name":"array","is_abstract":true,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-000000000001","tuple_elements":[]} as any); +spec.set("076e1d6f-f104-88b2-0632-d53171d9c827", {"id":"076e1d6f-f104-88b2-0632-d53171d9c827","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-00000000010c","tuple_elements":[]} as any); +spec.set("44a76fab-349d-00e9-396b-1000d7e967da", {"id":"44a76fab-349d-00e9-396b-1000d7e967da","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-00000000010b","tuple_elements":[]} as any); +spec.set("82ea7b30-73d3-c79c-86fb-b253f194f53e", {"id":"82ea7b30-73d3-c79c-86fb-b253f194f53e","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-00000000010d","tuple_elements":[]} as any); +spec.set("63acbf06-4c0c-67ac-c508-50a5ef4f4b16", {"id":"63acbf06-4c0c-67ac-c508-50a5ef4f4b16","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-000000000111","tuple_elements":[]} as any); +spec.set("41307a65-72fc-d40d-7423-a117edf9fc74", {"id":"41307a65-72fc-d40d-7423-a117edf9fc74","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"615b6350-5222-11ec-b957-d34fe8655f0e","tuple_elements":[]} as any); +spec.set("732817b7-131f-fac8-c0a3-58a31b5ac1d3", {"id":"732817b7-131f-fac8-c0a3-58a31b5ac1d3","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-000000000103","tuple_elements":[]} as any); +spec.set("59e264aa-8124-adf5-92fd-c1e96f826bc9", {"id":"59e264aa-8124-adf5-92fd-c1e96f826bc9","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-00000000010f","tuple_elements":[]} as any); +spec.set("05f91774-15ea-9001-038e-092c1cad80af", {"id":"05f91774-15ea-9001-038e-092c1cad80af","name":"array","is_abstract":false,"kind":"array","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":"00000000-0000-0000-0000-000000000101","tuple_elements":[]} as any); +spec.set("73795da2-77f8-11ec-a0fb-95758a2ed256", {"id":"73795da2-77f8-11ec-a0fb-95758a2ed256","name":"std::anyscalar","is_abstract":true,"kind":"scalar","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("00000000-0000-0000-0000-00000000010c", {"id":"00000000-0000-0000-0000-00000000010c","name":"cal::local_date","is_abstract":false,"kind":"scalar","enum_values":null,"material_id":null,"bases":[{"id":"73795da2-77f8-11ec-a0fb-95758a2ed256"}],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("00000000-0000-0000-0000-00000000010b", {"id":"00000000-0000-0000-0000-00000000010b","name":"cal::local_datetime","is_abstract":false,"kind":"scalar","enum_values":null,"material_id":null,"bases":[{"id":"73795da2-77f8-11ec-a0fb-95758a2ed256"}],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("00000000-0000-0000-0000-00000000010d", {"id":"00000000-0000-0000-0000-00000000010d","name":"cal::local_time","is_abstract":false,"kind":"scalar","enum_values":null,"material_id":null,"bases":[{"id":"73795da2-77f8-11ec-a0fb-95758a2ed256"}],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("00000000-0000-0000-0000-000000000111", {"id":"00000000-0000-0000-0000-000000000111","name":"cal::relative_duration","is_abstract":false,"kind":"scalar","enum_values":null,"material_id":null,"bases":[{"id":"73795da2-77f8-11ec-a0fb-95758a2ed256"}],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("7afe0046-77f8-11ec-8427-71ef12be3838", {"id":"7afe0046-77f8-11ec-8427-71ef12be3838","name":"std::BaseObject","is_abstract":true,"kind":"object","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[{"real_cardinality":"One","name":"__type__","target_id":"7bb628f6-77f8-11ec-95a9-9f0f2ea7cd4f","kind":"link","is_exclusive":false,"is_writable":false,"has_default":false,"pointers":[]},{"real_cardinality":"One","name":"id","target_id":"00000000-0000-0000-0000-000000000100","kind":"property","is_exclusive":true,"is_writable":false,"has_default":true,"pointers":[]}],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("83272b4e-77f8-11ec-80dc-0ff25edd967a", {"id":"83272b4e-77f8-11ec-80dc-0ff25edd967a","name":"cfg::ConfigObject","is_abstract":true,"kind":"object","enum_values":null,"material_id":null,"bases":[{"id":"7afe0046-77f8-11ec-8427-71ef12be3838"}],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("8394cadc-77f8-11ec-aa13-e30ef0102e6e", {"id":"8394cadc-77f8-11ec-aa13-e30ef0102e6e","name":"cfg::AbstractConfig","is_abstract":true,"kind":"object","enum_values":null,"material_id":null,"bases":[{"id":"83272b4e-77f8-11ec-80dc-0ff25edd967a"}],"union_of":[],"intersection_of":[],"pointers":[{"real_cardinality":"Many","name":"auth","target_id":"83713496-77f8-11ec-8191-9de83f09506d","kind":"link","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"One","name":"session_idle_timeout","target_id":"00000000-0000-0000-0000-00000000010e","kind":"property","is_exclusive":false,"is_writable":true,"has_default":true,"pointers":[]},{"real_cardinality":"One","name":"session_idle_transaction_timeout","target_id":"00000000-0000-0000-0000-00000000010e","kind":"property","is_exclusive":false,"is_writable":true,"has_default":true,"pointers":[]},{"real_cardinality":"One","name":"query_execution_timeout","target_id":"00000000-0000-0000-0000-00000000010e","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"One","name":"listen_port","target_id":"00000000-0000-0000-0000-000000000103","kind":"property","is_exclusive":false,"is_writable":true,"has_default":true,"pointers":[]},{"real_cardinality":"Many","name":"listen_addresses","target_id":"00000000-0000-0000-0000-000000000101","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"AtMostOne","name":"allow_dml_in_functions","target_id":"00000000-0000-0000-0000-000000000109","kind":"property","is_exclusive":false,"is_writable":true,"has_default":true,"pointers":[]},{"real_cardinality":"AtMostOne","name":"shared_buffers","target_id":"00000000-0000-0000-0000-000000000130","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"AtMostOne","name":"query_work_mem","target_id":"00000000-0000-0000-0000-000000000130","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"AtMostOne","name":"effective_cache_size","target_id":"00000000-0000-0000-0000-000000000130","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"AtMostOne","name":"effective_io_concurrency","target_id":"00000000-0000-0000-0000-000000000105","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"AtMostOne","name":"default_statistics_target","target_id":"00000000-0000-0000-0000-000000000105","kind":"property","is_exclusive":false,"is_writable":true,"has_default":false,"pointers":[]}],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[]} as any); +spec.set("83713496-77f8-11ec-8191-9de83f09506d", {"id":"83713496-77f8-11ec-8191-9de83f09506d","name":"cfg::Auth","is_abstract":false,"kind":"object","enum_values":null,"material_id":null,"bases":[{"id":"83272b4e-77f8-11ec-80dc-0ff25edd967a"}],"union_of":[],"intersection_of":[],"pointers":[{"real_cardinality":"AtMostOne","name":"method","target_id":"8337a26c-77f8-11ec-826c-bd887570c3cf","kind":"link","is_exclusive":true,"is_writable":true,"has_default":false,"pointers":[]},{"real_cardinality":"One","name":"priority","target_id":"00000000-0000-0000-0000-000000000105","kind":"property","is_exclusive":true,"is_writable":false,"has_default":false,"pointers":[]},{"real_cardinality":"Many","name":"user","target_id":"00000000-0000-0000-0000-000000000101","kind":"property","is_exclusive":false,"is_writable":false,"has_default":true,"pointers":[]},{"real_cardinality":"AtMostOne","name":"comment","target_id":"00000000-0000-0000-0000-000000000101","kind":"property","is_exclusive":false,"is_writable":false,"has_default":false,"pointers":[]}],"backlinks":[{"real_cardinality":"Many","name":">","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000105","name":"major"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"minor"},{"target_id":"00000000-0000-0000-0000-000000000101","name":"stage"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"stage_no"},{"target_id":"05f91774-15ea-9001-038e-092c1cad80af","name":"local"}]} as any); +spec.set("66656800-544e-31af-103b-0bd99605f056", {"id":"66656800-544e-31af-103b-0bd99605f056","name":"tuple>","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000105","name":"major"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"minor"},{"target_id":"822250e8-77f8-11ec-892c-13df3f9f35ff","name":"stage"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"stage_no"},{"target_id":"05f91774-15ea-9001-038e-092c1cad80af","name":"local"}]} as any); +spec.set("9c27acd9-0932-6050-c7b0-c7410e2e0a85", {"id":"9c27acd9-0932-6050-c7b0-c7410e2e0a85","name":"tuple","is_abstract":true,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000105","name":"0"},{"target_id":"00000000-0000-0000-0000-000000000001","name":"1"}]} as any); +spec.set("b6dce0a9-a33c-8f05-943f-f7187bfabdce", {"id":"b6dce0a9-a33c-8f05-943f-f7187bfabdce","name":"tuple","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000105","name":"0"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"1"}]} as any); +spec.set("338fc9bb-51be-b55d-b2f7-abe53ff0567f", {"id":"338fc9bb-51be-b55d-b2f7-abe53ff0567f","name":"tuple","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000101","name":"0"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"1"}]} as any); +spec.set("79d8ede8-30f1-a805-fbc3-503ece3c9205", {"id":"79d8ede8-30f1-a805-fbc3-503ece3c9205","name":"tuple","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000101","name":"0"},{"target_id":"00000000-0000-0000-0000-00000000010f","name":"1"}]} as any); +spec.set("10386947-4d9a-9752-f24f-0d79556fe2f7", {"id":"10386947-4d9a-9752-f24f-0d79556fe2f7","name":"tuple","is_abstract":false,"kind":"tuple","enum_values":null,"material_id":null,"bases":[],"union_of":[],"intersection_of":[],"pointers":[],"backlinks":[],"backlink_stubs":[],"array_element_id":null,"tuple_elements":[{"target_id":"00000000-0000-0000-0000-000000000101","name":"x"},{"target_id":"00000000-0000-0000-0000-000000000105","name":"y"}]} as any); +spec.set("00000000-0000-0000-0000-0000000001ff", {"id":"00000000-0000-0000-0000-0000000001ff","name":"std::number","is_abstract":false,"kind":"scalar","enum_values":null,"material_id":null,"bases":[]} as any); + + +export { spec }; diff --git a/qb/dbschema/edgeql-js/castMaps.ts b/qb/dbschema/edgeql-js/castMaps.ts new file mode 100644 index 000000000..81c9b739e --- /dev/null +++ b/qb/dbschema/edgeql-js/castMaps.ts @@ -0,0 +1,465 @@ +import * as edgedb from "edgedb"; +import { $ } from "edgedb"; +import { $getType } from "./syntax/literal"; +import * as _std from "./modules/std"; +import * as _default from "./modules/default"; +import * as _cfg from "./modules/cfg"; +import * as _cal from "./modules/cal"; +export type scalarAssignableBy = + T extends _std.$number ? _std.$number : + T extends _std.$uuid ? _std.$uuid : + T extends _std.$json ? _std.$json : + T extends _std.$int64 ? _std.$int64 : + T extends _std.$int32 ? _std.$int32 : + T extends _std.$int16 ? _std.$int16 : + T extends _std.$float64 ? _std.$float64 : + T extends _std.$float32 ? _std.$float32 : + T extends _std.$duration ? _std.$duration : + T extends _std.$decimal ? _std.$decimalλIAssignableBy : + T extends _std.$datetime ? _std.$datetime : + T extends _std.$bytes ? _std.$bytes : + T extends _std.$bool ? _std.$bool : + T extends _std.$bigint ? _std.$bigint : + T extends _default.$_616dff56522211ec8244db8a94893b78 ? _default.$_616dff56522211ec8244db8a94893b78 : + T extends _default.$_61681488522211ecbf9a1dea2d8e6375 ? _default.$_61681488522211ecbf9a1dea2d8e6375 : + T extends _default.$_6167fbd8522211ecb676ffcb3cdf24e0 ? _default.$_6167fbd8522211ecb676ffcb3cdf24e0 : + T extends _std.$str ? _std.$str : + T extends _cfg.$memory ? _cfg.$memory : + T extends _cal.$relative_duration ? _cal.$relative_duration : + T extends _cal.$local_time ? _cal.$local_time : + T extends _cal.$local_datetime ? _cal.$local_datetime : + T extends _cal.$local_date ? _cal.$local_date : + never + +export type scalarCastableFrom = + T extends _std.$number ? _std.$number : + T extends _std.$uuid ? _std.$uuid : + T extends _std.$json ? _std.$json : + T extends _std.$int64 ? _std.$int64 : + T extends _std.$int32 ? _std.$int32 : + T extends _std.$int16 ? _std.$int16 : + T extends _std.$float64 ? _std.$float64 : + T extends _std.$float32 ? _std.$float32 : + T extends _std.$duration ? _std.$duration : + T extends _std.$decimal ? _std.$decimalλICastableTo : + T extends _std.$datetime ? _std.$datetime : + T extends _std.$bytes ? _std.$bytes : + T extends _std.$bool ? _std.$bool : + T extends _std.$bigint ? _std.$bigint : + T extends _default.$_616dff56522211ec8244db8a94893b78 ? _default.$_616dff56522211ec8244db8a94893b78 : + T extends _default.$_61681488522211ecbf9a1dea2d8e6375 ? _default.$_61681488522211ecbf9a1dea2d8e6375 : + T extends _default.$_6167fbd8522211ecb676ffcb3cdf24e0 ? _default.$_6167fbd8522211ecb676ffcb3cdf24e0 : + T extends _std.$str ? _std.$str : + T extends _cfg.$memory ? _cfg.$memory : + T extends _cal.$relative_duration ? _cal.$relative_duration : + T extends _cal.$local_time ? _cal.$local_time : + T extends _cal.$local_datetime ? _cal.$local_datetime : + T extends _cal.$local_date ? _cal.$local_date : + never + +type getSharedParentScalar = + A extends _std.$number ? + B extends _std.$number ? + B + : + never + : + A extends _std.$uuid ? + B extends _std.$uuid ? + B + : + never + : + A extends _std.$json ? + B extends _std.$json ? + B + : + never + : + A extends _std.$int64 ? + B extends _std.$int64 ? + B + : + never + : + A extends _std.$int32 ? + B extends _std.$int32 ? + B + : + never + : + A extends _std.$int16 ? + B extends _std.$int16 ? + B + : + never + : + A extends _std.$float64 ? + B extends _std.$float64 ? + B + : + never + : + A extends _std.$float32 ? + B extends _std.$float32 ? + B + : + never + : + A extends _std.$duration ? + B extends _std.$duration ? + B + : + never + : + A extends _std.$decimal ? + B extends _std.$decimal ? + B + : + B extends _std.$bigint ? + A + : + never + : + A extends _std.$datetime ? + B extends _std.$datetime ? + B + : + never + : + A extends _std.$bytes ? + B extends _std.$bytes ? + B + : + never + : + A extends _std.$bool ? + B extends _std.$bool ? + B + : + never + : + A extends _std.$bigint ? + B extends _std.$decimal ? + B + : + B extends _std.$bigint ? + B + : + never + : + A extends _default.$_616dff56522211ec8244db8a94893b78 ? + B extends _default.$_616dff56522211ec8244db8a94893b78 ? + B + : + never + : + A extends _default.$_61681488522211ecbf9a1dea2d8e6375 ? + B extends _default.$_61681488522211ecbf9a1dea2d8e6375 ? + B + : + never + : + A extends _default.$_6167fbd8522211ecb676ffcb3cdf24e0 ? + B extends _default.$_6167fbd8522211ecb676ffcb3cdf24e0 ? + B + : + never + : + A extends _std.$str ? + B extends _std.$str ? + B + : + never + : + A extends _cfg.$memory ? + B extends _cfg.$memory ? + B + : + never + : + A extends _cal.$relative_duration ? + B extends _cal.$relative_duration ? + B + : + never + : + A extends _cal.$local_time ? + B extends _cal.$local_time ? + B + : + never + : + A extends _cal.$local_datetime ? + B extends _cal.$local_datetime ? + B + : + never + : + A extends _cal.$local_date ? + B extends _cal.$local_date ? + B + : + never + : +never + +function getSharedParentScalar(a: A, b: B): A | B { + a = (a as any).__casttype__ ?? a; + b = (b as any).__casttype__ ?? b; + if (a.__name__ === "std::number") { + if(b.__name__ === "std::number") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::uuid") { + if(b.__name__ === "std::uuid") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::json") { + if(b.__name__ === "std::json") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::int64") { + if(b.__name__ === "std::int64") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::int32") { + if(b.__name__ === "std::int32") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::int16") { + if(b.__name__ === "std::int16") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::float64") { + if(b.__name__ === "std::float64") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::float32") { + if(b.__name__ === "std::float32") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::duration") { + if(b.__name__ === "std::duration") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::decimal") { + if(b.__name__ === "std::decimal") { + return b; + } + if(b.__name__ === "std::bigint") { + return a; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::datetime") { + if(b.__name__ === "std::datetime") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::bytes") { + if(b.__name__ === "std::bytes") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::bool") { + if(b.__name__ === "std::bool") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::bigint") { + if(b.__name__ === "std::decimal") { + return b; + } + if(b.__name__ === "std::bigint") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "default::🚀🚀🚀") { + if(b.__name__ === "default::🚀🚀🚀") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "default::مرحبا") { + if(b.__name__ === "default::مرحبا") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "default::你好") { + if(b.__name__ === "default::你好") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "std::str") { + if(b.__name__ === "std::str") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "cfg::memory") { + if(b.__name__ === "cfg::memory") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "cal::relative_duration") { + if(b.__name__ === "cal::relative_duration") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "cal::local_time") { + if(b.__name__ === "cal::local_time") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "cal::local_datetime") { + if(b.__name__ === "cal::local_datetime") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + if (a.__name__ === "cal::local_date") { + if(b.__name__ === "cal::local_date") { + return b; + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); + } + throw new Error(`Types are not castable: ${a.__name__}, ${b.__name__}`); +} + +const implicitCastMap = new Map>([ + ["std::bigint", new Set(["std::decimal"])], +]); +function isImplicitlyCastableTo(from: string, to: string): boolean { + const _a = implicitCastMap.get(from), + _b = _a != null ? _a.has(to) : null; + return _b != null ? _b : false; +}; + +export type scalarLiterals = + | number + | string + | boolean + | bigint + | Buffer + | Date + | edgedb.Duration + | edgedb.LocalDateTime + | edgedb.LocalDate + | edgedb.LocalTime + | edgedb.RelativeDuration + | edgedb.ConfigMemory; + +type getTsType = T extends $.ScalarType + ? T extends _std.$decimal | _std.$json | _std.$uuid + ? never + : T["__tstype__"] + : never; +export type orScalarLiteral = + | T + | ($.BaseTypeSet extends T ? scalarLiterals : getTsType); + +export type scalarWithConstType< + T extends $.ScalarType, + TsConstType +> = $.ScalarType< + T["__name__"], + T["__tstype__"], + T["__castable__"], + TsConstType +>; +export type literalToScalarType = + T extends number ? scalarWithConstType<_std.$number, T> : + T extends string ? scalarWithConstType<_std.$str, T> : + T extends boolean ? scalarWithConstType<_std.$bool, T> : + T extends bigint ? scalarWithConstType<_std.$bigint, T> : + T extends Buffer ? scalarWithConstType<_std.$bytes, T> : + T extends Date ? scalarWithConstType<_std.$datetime, T> : + T extends edgedb.Duration ? scalarWithConstType<_std.$duration, T> : + T extends edgedb.LocalDateTime ? scalarWithConstType<_cal.$local_datetime, T> : + T extends edgedb.LocalDate ? scalarWithConstType<_cal.$local_date, T> : + T extends edgedb.LocalTime ? scalarWithConstType<_cal.$local_time, T> : + T extends edgedb.RelativeDuration ? scalarWithConstType<_cal.$relative_duration, T> : + T extends edgedb.ConfigMemory ? scalarWithConstType<_cfg.$memory, T> : + $.BaseType; + +type literalToTypeSet = T extends $.TypeSet + ? T + : $.$expr_Literal>; + +export type mapLiteralToTypeSet = { + [k in keyof T]: literalToTypeSet; +}; + +function literalToTypeSet(type: any): $.TypeSet { + if (type?.__element__) { + return type; + } + if (typeof type === "number") { + return $getType("00000000-0000-0000-0000-0000000001ff")(type); + } + if (typeof type === "string") { + return $getType("00000000-0000-0000-0000-000000000101")(type); + } + if (typeof type === "boolean") { + return $getType("00000000-0000-0000-0000-000000000109")(type); + } + if (typeof type === "bigint") { + return $getType("00000000-0000-0000-0000-000000000110")(type); + } + if (type instanceof Buffer) { + return $getType("00000000-0000-0000-0000-000000000102")(type); + } + if (type instanceof Date) { + return $getType("00000000-0000-0000-0000-00000000010a")(type); + } + if (type instanceof edgedb.Duration) { + return $getType("00000000-0000-0000-0000-00000000010e")(type); + } + if (type instanceof edgedb.LocalDateTime) { + return $getType("00000000-0000-0000-0000-00000000010b")(type); + } + if (type instanceof edgedb.LocalDate) { + return $getType("00000000-0000-0000-0000-00000000010c")(type); + } + if (type instanceof edgedb.LocalTime) { + return $getType("00000000-0000-0000-0000-00000000010d")(type); + } + if (type instanceof edgedb.RelativeDuration) { + return $getType("00000000-0000-0000-0000-000000000111")(type); + } + if (type instanceof edgedb.ConfigMemory) { + return $getType("00000000-0000-0000-0000-000000000130")(type); + } + throw new Error(`Cannot convert literal '${type}' into scalar type`); +} + + +export { getSharedParentScalar, isImplicitlyCastableTo, literalToTypeSet }; diff --git a/qb/dbschema/edgeql-js/config.json b/qb/dbschema/edgeql-js/config.json new file mode 100644 index 000000000..9c7ed2522 --- /dev/null +++ b/qb/dbschema/edgeql-js/config.json @@ -0,0 +1,2 @@ +// EdgeDB query builder. To update, run `npx edgeql-js` +{"target":"ts"} diff --git a/qb/dbschema/edgeql-js/imports.ts b/qb/dbschema/edgeql-js/imports.ts new file mode 100644 index 000000000..c7755fc2f --- /dev/null +++ b/qb/dbschema/edgeql-js/imports.ts @@ -0,0 +1,4 @@ +export * as edgedb from "edgedb"; +export { spec } from "./__spec__"; +export * as syntax from "./syntax/syntax"; +export * as castMaps from "./castMaps"; diff --git a/qb/dbschema/edgeql-js/index.ts b/qb/dbschema/edgeql-js/index.ts new file mode 100644 index 000000000..03cf25b06 --- /dev/null +++ b/qb/dbschema/edgeql-js/index.ts @@ -0,0 +1,49 @@ +export * from "./castMaps"; +export * from "./syntax/syntax"; +export { createClient } from "edgedb"; +export { Cardinality } from "edgedb/dist/reflection"; +import { $ } from "edgedb"; +import * as $syntax from "./syntax/syntax"; +import * as $op from "./operators"; +import _std from "./modules/std"; +import _cal from "./modules/cal"; +import _cfg from "./modules/cfg"; +import _default from "./modules/default"; +import _schema from "./modules/schema"; +import _sys from "./modules/sys"; +import _math from "./modules/math"; +import __7 from "./modules/_7"; + +const ExportDefault: typeof _std & + typeof _default & + $.util.OmitDollarPrefixed & + typeof $op & { + "std": typeof _std; + "cal": typeof _cal; + "cfg": typeof _cfg; + "default": typeof _default; + "schema": typeof _schema; + "sys": typeof _sys; + "math": typeof _math; + "💯💯💯": typeof __7; +} = { + ..._std, + ..._default, + ...$.util.omitDollarPrefixed($syntax), + ...$op, + "std": _std, + "cal": _cal, + "cfg": _cfg, + "default": _default, + "schema": _schema, + "sys": _sys, + "math": _math, + "💯💯💯": __7, +}; +export type Set< + Type extends $.BaseType, + Cardinality extends $.Cardinality = $.Cardinality.Many +> = $.TypeSet; + + +export default ExportDefault; diff --git a/qb/dbschema/edgeql-js/modules/_7.ts b/qb/dbschema/edgeql-js/modules/_7.ts new file mode 100644 index 000000000..10ed564ca --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/_7.ts @@ -0,0 +1,39 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _default from "./default"; +type _617906a8522211ec9ee61f9c66f184eaλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_default.$_616dff56522211ec8244db8a94893b78>>, +> = $.$expr_Function< + "💯💯💯::🚀🙀🚀", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_default.$_616dff56522211ec8244db8a94893b78, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +function _617906a8522211ec9ee61f9c66f184ea< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_default.$_616dff56522211ec8244db8a94893b78>>, +>( + _0: P1, +): _617906a8522211ec9ee61f9c66f184eaλFuncExpr; +function _617906a8522211ec9ee61f9c66f184ea(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('💯💯💯::🚀🙀🚀', args, _.spec, [ + {args: [{typeId: "616dff56-5222-11ec-8244-db8a94893b78", optional: false, setoftype: false, variadic: false}], returnTypeId: "616dff56-5222-11ec-8244-db8a94893b78"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "💯💯💯::🚀🙀🚀", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +type __defaultExports = { + "🚀🙀🚀": typeof _617906a8522211ec9ee61f9c66f184ea +}; +const __defaultExports: __defaultExports = { + "🚀🙀🚀": _617906a8522211ec9ee61f9c66f184ea +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/cal.ts b/qb/dbschema/edgeql-js/modules/cal.ts new file mode 100644 index 000000000..d95410620 --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/cal.ts @@ -0,0 +1,393 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _std from "./std"; +export type $local_date = $.ScalarType<"cal::local_date", _.edgedb.LocalDate, true>; +const local_date: $.scalarTypeWithConstructor<$local_date, never> = $.makeType<$.scalarTypeWithConstructor<$local_date, never>>(_.spec, "00000000-0000-0000-0000-00000000010c", _.syntax.literal); + +export type $local_datetime = $.ScalarType<"cal::local_datetime", _.edgedb.LocalDateTime, true>; +const local_datetime: $.scalarTypeWithConstructor<$local_datetime, never> = $.makeType<$.scalarTypeWithConstructor<$local_datetime, never>>(_.spec, "00000000-0000-0000-0000-00000000010b", _.syntax.literal); + +export type $local_time = $.ScalarType<"cal::local_time", _.edgedb.LocalTime, true>; +const local_time: $.scalarTypeWithConstructor<$local_time, never> = $.makeType<$.scalarTypeWithConstructor<$local_time, never>>(_.spec, "00000000-0000-0000-0000-00000000010d", _.syntax.literal); + +export type $relative_duration = $.ScalarType<"cal::relative_duration", _.edgedb.RelativeDuration, true>; +const relative_duration: $.scalarTypeWithConstructor<$relative_duration, never> = $.makeType<$.scalarTypeWithConstructor<$relative_duration, never>>(_.spec, "00000000-0000-0000-0000-000000000111", _.syntax.literal); + +type to_local_datetimeλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +> = $.$expr_Function< + "cal::to_local_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_local_datetimeλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +> = $.$expr_Function< + "cal::to_local_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type to_local_datetimeλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P4 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P5 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P6 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "cal::to_local_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3, P4, P5, P6]>, + {}, + $.TypeSet<$local_datetime, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Create a `cal::local_datetime` value. + */ +function to_local_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_local_datetimeλFuncExpr; +/** + * Create a `cal::local_datetime` value. + */ +function to_local_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + dt: P1, + zone: P2, +): to_local_datetimeλFuncExpr2; +/** + * Create a `cal::local_datetime` value. + */ +function to_local_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P4 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P5 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P6 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + year: P1, + month: P2, + day: P3, + hour: P4, + min: P5, + sec: P6, +): to_local_datetimeλFuncExpr3; +function to_local_datetime(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::to_local_datetime', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::to_local_datetime", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_local_dateλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +> = $.$expr_Function< + "cal::to_local_date", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_local_dateλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +> = $.$expr_Function< + "cal::to_local_date", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type to_local_dateλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "cal::to_local_date", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$local_date, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Create a `cal::local_date` value. + */ +function to_local_date< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_local_dateλFuncExpr; +/** + * Create a `cal::local_date` value. + */ +function to_local_date< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + dt: P1, + zone: P2, +): to_local_dateλFuncExpr2; +/** + * Create a `cal::local_date` value. + */ +function to_local_date< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + year: P1, + month: P2, + day: P3, +): to_local_dateλFuncExpr3; +function to_local_date(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::to_local_date', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::to_local_date", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_local_timeλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +> = $.$expr_Function< + "cal::to_local_time", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_local_timeλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +> = $.$expr_Function< + "cal::to_local_time", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type to_local_timeλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "cal::to_local_time", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$local_time, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Create a `cal::local_time` value. + */ +function to_local_time< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_local_timeλFuncExpr; +/** + * Create a `cal::local_time` value. + */ +function to_local_time< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + dt: P1, + zone: P2, +): to_local_timeλFuncExpr2; +/** + * Create a `cal::local_time` value. + */ +function to_local_time< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + hour: P1, + min: P2, + sec: P3, +): to_local_timeλFuncExpr3; +function to_local_time(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::to_local_time', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::to_local_time", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type time_getλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +> = $.$expr_Function< + "cal::time_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Extract a specific element of input time by name. + */ +function time_get< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + dt: P1, + el: P2, +): time_getλFuncExpr; +function time_get(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::time_get', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::time_get", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type date_getλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +> = $.$expr_Function< + "cal::date_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Extract a specific element of input date by name. + */ +function date_get< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + dt: P1, + el: P2, +): date_getλFuncExpr; +function date_get(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::date_get', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::date_get", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_relative_durationλFuncExpr< + NamedArgs extends { + "years"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "months"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "days"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "hours"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "minutes"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "seconds"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "microseconds"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + }, +> = $.$expr_Function< + "cal::to_relative_duration", + [], + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<$relative_duration, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `cal::relative_duration` value. + */ +function to_relative_duration< + NamedArgs extends { + "years"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "months"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "days"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "hours"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "minutes"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "seconds"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + "microseconds"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + }, +>( + namedArgs: NamedArgs, +): to_relative_durationλFuncExpr; +function to_relative_duration(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cal::to_relative_duration', args, _.spec, [ + {args: [], namedArgs: {"years": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "months": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "days": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "hours": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "minutes": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "seconds": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "microseconds": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-000000000111"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cal::to_relative_duration", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +export { local_date, local_datetime, local_time, relative_duration }; + +type __defaultExports = { + "local_date": typeof local_date; + "local_datetime": typeof local_datetime; + "local_time": typeof local_time; + "relative_duration": typeof relative_duration; + "to_local_datetime": typeof to_local_datetime; + "to_local_date": typeof to_local_date; + "to_local_time": typeof to_local_time; + "time_get": typeof time_get; + "date_get": typeof date_get; + "to_relative_duration": typeof to_relative_duration +}; +const __defaultExports: __defaultExports = { + "local_date": local_date, + "local_datetime": local_datetime, + "local_time": local_time, + "relative_duration": relative_duration, + "to_local_datetime": to_local_datetime, + "to_local_date": to_local_date, + "to_local_time": to_local_time, + "time_get": time_get, + "date_get": date_get, + "to_relative_duration": to_relative_duration +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/cfg.ts b/qb/dbschema/edgeql-js/modules/cfg.ts new file mode 100644 index 000000000..934550e98 --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/cfg.ts @@ -0,0 +1,156 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _std from "./std"; +export type $memory = $.ScalarType<"cfg::memory", _.edgedb.ConfigMemory, true>; +const memory: $.scalarTypeWithConstructor<$memory, never> = $.makeType<$.scalarTypeWithConstructor<$memory, never>>(_.spec, "00000000-0000-0000-0000-000000000130", _.syntax.literal); + +export type $ConfigObjectλShape = $.typeutil.flatten<_std.$BaseObjectλShape & { +}>; +type $ConfigObject = $.ObjectType<"cfg::ConfigObject", $ConfigObjectλShape, null>; +const $ConfigObject = $.makeType<$ConfigObject>(_.spec, "83272b4e-77f8-11ec-80dc-0ff25edd967a", _.syntax.literal); + +const ConfigObject: $.$expr_PathNode<$.TypeSet<$ConfigObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ConfigObject, $.Cardinality.Many), null, true); + +export type $AbstractConfigλShape = $.typeutil.flatten<$ConfigObjectλShape & { + "auth": $.LinkDesc<$Auth, $.Cardinality.Many, {}, false, true, false>; + "session_idle_timeout": $.PropertyDesc<_std.$duration, $.Cardinality.One, false, true, true>; + "session_idle_transaction_timeout": $.PropertyDesc<_std.$duration, $.Cardinality.One, false, true, true>; + "query_execution_timeout": $.PropertyDesc<_std.$duration, $.Cardinality.One, false, true, false>; + "listen_port": $.PropertyDesc<_std.$int16, $.Cardinality.One, false, true, true>; + "listen_addresses": $.PropertyDesc<_std.$str, $.Cardinality.Many, false, true, false>; + "allow_dml_in_functions": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, true>; + "shared_buffers": $.PropertyDesc<$memory, $.Cardinality.AtMostOne, false, true, false>; + "query_work_mem": $.PropertyDesc<$memory, $.Cardinality.AtMostOne, false, true, false>; + "effective_cache_size": $.PropertyDesc<$memory, $.Cardinality.AtMostOne, false, true, false>; + "effective_io_concurrency": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne, false, true, false>; + "default_statistics_target": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $AbstractConfig = $.ObjectType<"cfg::AbstractConfig", $AbstractConfigλShape, null>; +const $AbstractConfig = $.makeType<$AbstractConfig>(_.spec, "8394cadc-77f8-11ec-aa13-e30ef0102e6e", _.syntax.literal); + +const AbstractConfig: $.$expr_PathNode<$.TypeSet<$AbstractConfig, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($AbstractConfig, $.Cardinality.Many), null, true); + +export type $AuthλShape = $.typeutil.flatten<$ConfigObjectλShape & { + "method": $.LinkDesc<$AuthMethod, $.Cardinality.AtMostOne, {}, true, true, false>; + "priority": $.PropertyDesc<_std.$int64, $.Cardinality.One, true, false, false>; + "user": $.PropertyDesc<_std.$str, $.Cardinality.Many, false, false, true>; + "comment": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, false, false>; + "; + "; + "; + "; + "; +}>; +type $Auth = $.ObjectType<"cfg::Auth", $AuthλShape, null>; +const $Auth = $.makeType<$Auth>(_.spec, "83713496-77f8-11ec-8191-9de83f09506d", _.syntax.literal); + +const Auth: $.$expr_PathNode<$.TypeSet<$Auth, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Auth, $.Cardinality.Many), null, true); + +export type $AuthMethodλShape = $.typeutil.flatten<$ConfigObjectλShape & { + "; + "; +}>; +type $AuthMethod = $.ObjectType<"cfg::AuthMethod", $AuthMethodλShape, null>; +const $AuthMethod = $.makeType<$AuthMethod>(_.spec, "8337a26c-77f8-11ec-826c-bd887570c3cf", _.syntax.literal); + +const AuthMethod: $.$expr_PathNode<$.TypeSet<$AuthMethod, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($AuthMethod, $.Cardinality.Many), null, true); + +export type $ConfigλShape = $.typeutil.flatten<$AbstractConfigλShape & { +}>; +type $Config = $.ObjectType<"cfg::Config", $ConfigλShape, null>; +const $Config = $.makeType<$Config>(_.spec, "83c9ec94-77f8-11ec-b8e8-0d574811cf5e", _.syntax.literal); + +const Config: $.$expr_PathNode<$.TypeSet<$Config, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Config, $.Cardinality.Many), null, true); + +export type $DatabaseConfigλShape = $.typeutil.flatten<$AbstractConfigλShape & { +}>; +type $DatabaseConfig = $.ObjectType<"cfg::DatabaseConfig", $DatabaseConfigλShape, null>; +const $DatabaseConfig = $.makeType<$DatabaseConfig>(_.spec, "84417372-77f8-11ec-acaf-ff579f1de337", _.syntax.literal); + +const DatabaseConfig: $.$expr_PathNode<$.TypeSet<$DatabaseConfig, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($DatabaseConfig, $.Cardinality.Many), null, true); + +export type $InstanceConfigλShape = $.typeutil.flatten<$AbstractConfigλShape & { +}>; +type $InstanceConfig = $.ObjectType<"cfg::InstanceConfig", $InstanceConfigλShape, null>; +const $InstanceConfig = $.makeType<$InstanceConfig>(_.spec, "8404c792-77f8-11ec-92d0-fd1a01621f3b", _.syntax.literal); + +const InstanceConfig: $.$expr_PathNode<$.TypeSet<$InstanceConfig, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($InstanceConfig, $.Cardinality.Many), null, true); + +export type $SCRAMλShape = $.typeutil.flatten<$AuthMethodλShape & { +}>; +type $SCRAM = $.ObjectType<"cfg::SCRAM", $SCRAMλShape, null>; +const $SCRAM = $.makeType<$SCRAM>(_.spec, "835de7c4-77f8-11ec-884c-af730517f2c3", _.syntax.literal); + +const SCRAM: $.$expr_PathNode<$.TypeSet<$SCRAM, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($SCRAM, $.Cardinality.Many), null, true); + +export type $TrustλShape = $.typeutil.flatten<$AuthMethodλShape & { +}>; +type $Trust = $.ObjectType<"cfg::Trust", $TrustλShape, null>; +const $Trust = $.makeType<$Trust>(_.spec, "8349589a-77f8-11ec-bdff-815e36b507f6", _.syntax.literal); + +const Trust: $.$expr_PathNode<$.TypeSet<$Trust, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Trust, $.Cardinality.Many), null, true); + +type get_config_jsonλFuncExpr< + NamedArgs extends { + "sources"?: $.TypeSet<$.ArrayType<_std.$str>>, + "max_source"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + }, +> = $.$expr_Function< + "cfg::get_config_json", + [], + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<_std.$json, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +function get_config_json< + NamedArgs extends { + "sources"?: $.TypeSet<$.ArrayType<_std.$str>>, + "max_source"?: _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + }, +>( + namedArgs: NamedArgs, +): get_config_jsonλFuncExpr; +function get_config_json(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('cfg::get_config_json', args, _.spec, [ + {args: [], namedArgs: {"sources": {typeId: "05f91774-15ea-9001-038e-092c1cad80af", optional: true, setoftype: false, variadic: false}, "max_source": {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-00000000010f"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "cfg::get_config_json", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +export { memory, $ConfigObject, ConfigObject, $AbstractConfig, AbstractConfig, $Auth, Auth, $AuthMethod, AuthMethod, $Config, Config, $DatabaseConfig, DatabaseConfig, $InstanceConfig, InstanceConfig, $SCRAM, SCRAM, $Trust, Trust }; + +type __defaultExports = { + "memory": typeof memory; + "ConfigObject": typeof ConfigObject; + "AbstractConfig": typeof AbstractConfig; + "Auth": typeof Auth; + "AuthMethod": typeof AuthMethod; + "Config": typeof Config; + "DatabaseConfig": typeof DatabaseConfig; + "InstanceConfig": typeof InstanceConfig; + "SCRAM": typeof SCRAM; + "Trust": typeof Trust; + "get_config_json": typeof get_config_json +}; +const __defaultExports: __defaultExports = { + "memory": memory, + "ConfigObject": ConfigObject, + "AbstractConfig": AbstractConfig, + "Auth": Auth, + "AuthMethod": AuthMethod, + "Config": Config, + "DatabaseConfig": DatabaseConfig, + "InstanceConfig": InstanceConfig, + "SCRAM": SCRAM, + "Trust": Trust, + "get_config_json": get_config_json +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/default.ts b/qb/dbschema/edgeql-js/modules/default.ts new file mode 100644 index 000000000..7f0fb9b9b --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/default.ts @@ -0,0 +1,245 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _std from "./std"; +import * as _cal from "./cal"; +enum $GenreλEnum { + Horror = "Horror", + Action = "Action", + RomCom = "RomCom", +} +export type $Genre = typeof $GenreλEnum & $.EnumType<"default::Genre", $GenreλEnum, `${$GenreλEnum}`>; +const Genre: $Genre = $.makeType<$Genre>(_.spec, "615b6350-5222-11ec-b957-d34fe8655f0e", _.syntax.literal); + +export type $_6167fbd8522211ecb676ffcb3cdf24e0 = $.ScalarType<"default::你好", string, true>; +const _6167fbd8522211ecb676ffcb3cdf24e0: $.scalarTypeWithConstructor<$_6167fbd8522211ecb676ffcb3cdf24e0, never> = $.makeType<$.scalarTypeWithConstructor<$_6167fbd8522211ecb676ffcb3cdf24e0, never>>(_.spec, "6167fbd8-5222-11ec-b676-ffcb3cdf24e0", _.syntax.literal); + +export type $_61681488522211ecbf9a1dea2d8e6375 = $.ScalarType<"default::مرحبا", string, true>; +const _61681488522211ecbf9a1dea2d8e6375: $.scalarTypeWithConstructor<$_61681488522211ecbf9a1dea2d8e6375, never> = $.makeType<$.scalarTypeWithConstructor<$_61681488522211ecbf9a1dea2d8e6375, never>>(_.spec, "61681488-5222-11ec-bf9a-1dea2d8e6375", _.syntax.literal); + +export type $_616dff56522211ec8244db8a94893b78 = $.ScalarType<"default::🚀🚀🚀", string, true>; +const _616dff56522211ec8244db8a94893b78: $.scalarTypeWithConstructor<$_616dff56522211ec8244db8a94893b78, never> = $.makeType<$.scalarTypeWithConstructor<$_616dff56522211ec8244db8a94893b78, never>>(_.spec, "616dff56-5222-11ec-8244-db8a94893b78", _.syntax.literal); + +export type $AλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "s p A m 🤞": $.LinkDesc<$SpaM_6175fb8e522211eca4592d0a8657e1b8, $.Cardinality.One, {}, false, true, false>; + "<Ł💯[is Łukasz]": $.LinkDesc<$ukasz_61706188522211ec8089a1208956222f, $.Cardinality.Many, {}, false, false, false>; + "<Ł💯": $.LinkDesc<$.ObjectType, $.Cardinality.Many, {}, false, false, false>; +}>; +type $A = $.ObjectType<"default::A", $AλShape, null>; +const $A = $.makeType<$A>(_.spec, "6165e924-5222-11ec-a61b-717fdd8f6589", _.syntax.literal); + +const A: $.$expr_PathNode<$.TypeSet<$A, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($A, $.Cardinality.Many), null, true); + +export type $HasNameλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "name": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $HasName = $.ObjectType<"default::HasName", $HasNameλShape, null>; +const $HasName = $.makeType<$HasName>(_.spec, "615ccd9e-5222-11ec-9b0d-41e1bdaa68e8", _.syntax.literal); + +const HasName: $.$expr_PathNode<$.TypeSet<$HasName, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($HasName, $.Cardinality.Many), null, true); + +export type $HasAgeλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "age": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $HasAge = $.ObjectType<"default::HasAge", $HasAgeλShape, null>; +const $HasAge = $.makeType<$HasAge>(_.spec, "615b748a-5222-11ec-bbaf-d3e5e609d9a3", _.syntax.literal); + +const HasAge: $.$expr_PathNode<$.TypeSet<$HasAge, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($HasAge, $.Cardinality.Many), null, true); + +export type $BagλShape = $.typeutil.flatten<$HasNameλShape & $HasAgeλShape & { + "enumArr": $.PropertyDesc<$.ArrayType<$Genre>, $.Cardinality.AtMostOne, false, true, false>; + "bigintField": $.PropertyDesc<_std.$bigint, $.Cardinality.AtMostOne, false, true, false>; + "boolField": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "datetimeField": $.PropertyDesc<_std.$datetime, $.Cardinality.AtMostOne, false, true, false>; + "decimalField": $.PropertyDesc<_std.$decimal, $.Cardinality.AtMostOne, false, true, false>; + "durationField": $.PropertyDesc<_std.$duration, $.Cardinality.AtMostOne, false, true, false>; + "float32Field": $.PropertyDesc<_std.$float32, $.Cardinality.AtMostOne, false, true, false>; + "float64Field": $.PropertyDesc<_std.$float64, $.Cardinality.AtMostOne, false, true, false>; + "genre": $.PropertyDesc<$Genre, $.Cardinality.AtMostOne, false, true, false>; + "int16Field": $.PropertyDesc<_std.$int16, $.Cardinality.AtMostOne, false, true, false>; + "int32Field": $.PropertyDesc<_std.$int32, $.Cardinality.AtMostOne, false, true, false>; + "int64Field": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne, false, true, false>; + "localDateField": $.PropertyDesc<_cal.$local_date, $.Cardinality.AtMostOne, false, true, false>; + "localDateTimeField": $.PropertyDesc<_cal.$local_datetime, $.Cardinality.AtMostOne, false, true, false>; + "localTimeField": $.PropertyDesc<_cal.$local_time, $.Cardinality.AtMostOne, false, true, false>; + "namedTuple": $.PropertyDesc<$.NamedTupleType<{x: _std.$str, y: _std.$int64}>, $.Cardinality.AtMostOne, false, true, false>; + "secret_identity": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "stringMultiArr": $.PropertyDesc<$.ArrayType<_std.$str>, $.Cardinality.Many, false, true, false>; + "stringsArr": $.PropertyDesc<$.ArrayType<_std.$str>, $.Cardinality.AtMostOne, false, true, false>; + "stringsMulti": $.PropertyDesc<_std.$str, $.Cardinality.AtLeastOne, false, true, false>; + "unnamedTuple": $.PropertyDesc<$.TupleType<[_std.$str, _std.$int64]>, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $Bag = $.ObjectType<"default::Bag", $BagλShape, null>; +const $Bag = $.makeType<$Bag>(_.spec, "615e3e86-5222-11ec-85e1-c536e21415ce", _.syntax.literal); + +const Bag: $.$expr_PathNode<$.TypeSet<$Bag, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Bag, $.Cardinality.Many), null, true); + +export type $PersonλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "name": $.PropertyDesc<_std.$str, $.Cardinality.One, true, true, false>; + "; + "; +}>; +type $Person = $.ObjectType<"default::Person", $PersonλShape, null>; +const $Person = $.makeType<$Person>(_.spec, "61797b60-5222-11ec-b72f-83e2a66aca2c", _.syntax.literal); + +const Person: $.$expr_PathNode<$.TypeSet<$Person, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Person, $.Cardinality.Many), null, true); + +export type $HeroλShape = $.typeutil.flatten<$PersonλShape & { + "villains": $.LinkDesc<$Villain, $.Cardinality.Many, {}, false, false, false>; + "number_of_movies": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne, false, true, false>; + "secret_identity": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; +}>; +type $Hero = $.ObjectType<"default::Hero", $HeroλShape, null>; +const $Hero = $.makeType<$Hero>(_.spec, "6182b464-5222-11ec-a001-ad2669f69225", _.syntax.literal); + +const Hero: $.$expr_PathNode<$.TypeSet<$Hero, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Hero, $.Cardinality.Many), null, true); + +export type $MovieλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "characters": $.LinkDesc<$Person, $.Cardinality.Many, { + "@character_name": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne>; + }, false, true, false>; + "profile": $.LinkDesc<$Profile, $.Cardinality.AtMostOne, {}, true, true, false>; + "genre": $.PropertyDesc<$Genre, $.Cardinality.AtMostOne, false, true, false>; + "rating": $.PropertyDesc<_std.$float64, $.Cardinality.AtMostOne, false, true, false>; + "title": $.PropertyDesc<_std.$str, $.Cardinality.One, false, true, false>; + "release_year": $.PropertyDesc<_std.$int16, $.Cardinality.One, false, true, true>; +}>; +type $Movie = $.ObjectType<"default::Movie", $MovieλShape, null>; +const $Movie = $.makeType<$Movie>(_.spec, "617cee44-5222-11ec-9d8f-79a472544ad6", _.syntax.literal); + +const Movie: $.$expr_PathNode<$.TypeSet<$Movie, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Movie, $.Cardinality.Many), null, true); + +export type $MovieShapeλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { +}>; +type $MovieShape = $.ObjectType<"default::MovieShape", $MovieShapeλShape, null>; +const $MovieShape = $.makeType<$MovieShape>(_.spec, "618a1f1a-5222-11ec-b4de-97d6e10e4aa8", _.syntax.literal); + +const MovieShape: $.$expr_PathNode<$.TypeSet<$MovieShape, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($MovieShape, $.Cardinality.Many), null, true); + +export type $ProfileλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "plot_summary": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; +}>; +type $Profile = $.ObjectType<"default::Profile", $ProfileλShape, null>; +const $Profile = $.makeType<$Profile>(_.spec, "617b95b2-5222-11ec-82c5-7d669cab4fa5", _.syntax.literal); + +const Profile: $.$expr_PathNode<$.TypeSet<$Profile, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Profile, $.Cardinality.Many), null, true); + +export type $SpaM_6175fb8e522211eca4592d0a8657e1b8λShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "🚀": $.PropertyDesc<_std.$int32, $.Cardinality.One, false, true, false>; + "c100": $.PropertyDesc<_std.$int64, $.Cardinality.One, false, false, false>; + "; + "; +}>; +type $SpaM_6175fb8e522211eca4592d0a8657e1b8 = $.ObjectType<"default::S p a M", $SpaM_6175fb8e522211eca4592d0a8657e1b8λShape, null>; +const $SpaM_6175fb8e522211eca4592d0a8657e1b8 = $.makeType<$SpaM_6175fb8e522211eca4592d0a8657e1b8>(_.spec, "6175fb8e-5222-11ec-a459-2d0a8657e1b8", _.syntax.literal); + +const SpaM_6175fb8e522211eca4592d0a8657e1b8: $.$expr_PathNode<$.TypeSet<$SpaM_6175fb8e522211eca4592d0a8657e1b8, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($SpaM_6175fb8e522211eca4592d0a8657e1b8, $.Cardinality.Many), null, true); + +export type $SimpleλShape = $.typeutil.flatten<$HasNameλShape & $HasAgeλShape & { +}>; +type $Simple = $.ObjectType<"default::Simple", $SimpleλShape, null>; +const $Simple = $.makeType<$Simple>(_.spec, "61804788-5222-11ec-a3ea-9da16efe9179", _.syntax.literal); + +const Simple: $.$expr_PathNode<$.TypeSet<$Simple, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Simple, $.Cardinality.Many), null, true); + +export type $VillainλShape = $.typeutil.flatten<$PersonλShape & { + "nemesis": $.LinkDesc<$Hero, $.Cardinality.AtMostOne, {}, false, true, false>; + "; + "; +}>; +type $Villain = $.ObjectType<"default::Villain", $VillainλShape, null>; +const $Villain = $.makeType<$Villain>(_.spec, "6184ecde-5222-11ec-871e-0d407b48fbc9", _.syntax.literal); + +const Villain: $.$expr_PathNode<$.TypeSet<$Villain, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Villain, $.Cardinality.Many), null, true); + +export type $ukasz_61706188522211ec8089a1208956222fλShape = $.typeutil.flatten<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818λShape & { + "Ł💯": $.LinkDesc<$A, $.Cardinality.AtMostOne, { + "@🙀مرحبا🙀": $.PropertyDesc<$_61681488522211ecbf9a1dea2d8e6375, $.Cardinality.AtMostOne>; + "@🙀🚀🚀🚀🙀": $.PropertyDesc<$_616dff56522211ec8244db8a94893b78, $.Cardinality.AtMostOne>; + }, false, true, false>; + "Ł🤞": $.PropertyDesc<$_616dff56522211ec8244db8a94893b78, $.Cardinality.One, false, true, true>; +}>; +type $ukasz_61706188522211ec8089a1208956222f = $.ObjectType<"default::Łukasz", $ukasz_61706188522211ec8089a1208956222fλShape, null>; +const $ukasz_61706188522211ec8089a1208956222f = $.makeType<$ukasz_61706188522211ec8089a1208956222f>(_.spec, "61706188-5222-11ec-8089-a1208956222f", _.syntax.literal); + +const ukasz_61706188522211ec8089a1208956222f: $.$expr_PathNode<$.TypeSet<$ukasz_61706188522211ec8089a1208956222f, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ukasz_61706188522211ec8089a1208956222f, $.Cardinality.Many), null, true); + +type _615b3d30522211ecb80125f264b11669λFuncExpr< + NamedArgs extends { + "🙀": _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + }, +> = $.$expr_Function< + "default::💯", + [], + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +function _615b3d30522211ecb80125f264b11669< + NamedArgs extends { + "🙀": _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + }, +>( + namedArgs: NamedArgs, +): _615b3d30522211ecb80125f264b11669λFuncExpr; +function _615b3d30522211ecb80125f264b11669(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('default::💯', args, _.spec, [ + {args: [], namedArgs: {"🙀": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "default::💯", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +export { $GenreλEnum, Genre, _6167fbd8522211ecb676ffcb3cdf24e0, _61681488522211ecbf9a1dea2d8e6375, _616dff56522211ec8244db8a94893b78, $A, A, $HasName, HasName, $HasAge, HasAge, $Bag, Bag, $Person, Person, $Hero, Hero, $Movie, Movie, $MovieShape, MovieShape, $Profile, Profile, $SpaM_6175fb8e522211eca4592d0a8657e1b8, SpaM_6175fb8e522211eca4592d0a8657e1b8, $Simple, Simple, $Villain, Villain, $ukasz_61706188522211ec8089a1208956222f, ukasz_61706188522211ec8089a1208956222f }; + +type __defaultExports = { + "Genre": typeof Genre; + "你好": typeof _6167fbd8522211ecb676ffcb3cdf24e0; + "مرحبا": typeof _61681488522211ecbf9a1dea2d8e6375; + "🚀🚀🚀": typeof _616dff56522211ec8244db8a94893b78; + "A": typeof A; + "HasName": typeof HasName; + "HasAge": typeof HasAge; + "Bag": typeof Bag; + "Person": typeof Person; + "Hero": typeof Hero; + "Movie": typeof Movie; + "MovieShape": typeof MovieShape; + "Profile": typeof Profile; + "S p a M": typeof SpaM_6175fb8e522211eca4592d0a8657e1b8; + "Simple": typeof Simple; + "Villain": typeof Villain; + "Łukasz": typeof ukasz_61706188522211ec8089a1208956222f; + "💯": typeof _615b3d30522211ecb80125f264b11669 +}; +const __defaultExports: __defaultExports = { + "Genre": Genre, + "你好": _6167fbd8522211ecb676ffcb3cdf24e0, + "مرحبا": _61681488522211ecbf9a1dea2d8e6375, + "🚀🚀🚀": _616dff56522211ec8244db8a94893b78, + "A": A, + "HasName": HasName, + "HasAge": HasAge, + "Bag": Bag, + "Person": Person, + "Hero": Hero, + "Movie": Movie, + "MovieShape": MovieShape, + "Profile": Profile, + "S p a M": SpaM_6175fb8e522211eca4592d0a8657e1b8, + "Simple": Simple, + "Villain": Villain, + "Łukasz": ukasz_61706188522211ec8089a1208956222f, + "💯": _615b3d30522211ecb80125f264b11669 +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/math.ts b/qb/dbschema/edgeql-js/modules/math.ts new file mode 100644 index 000000000..093bb7c80 --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/math.ts @@ -0,0 +1,556 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _std from "./std"; +type var_8211da5677f811ecb687d38660b3af37λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::var", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, $.cardinalityUtil.overrideLowerBound<$.Cardinality.One, 'Zero'>> +>; +type var_8211da5677f811ecb687d38660b3af37λFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::var", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, $.cardinalityUtil.overrideLowerBound<$.Cardinality.One, 'Zero'>> +>; +/** + * Return the sample variance of the input set. + */ +function var_8211da5677f811ecb687d38660b3af37< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + vals: P1, +): var_8211da5677f811ecb687d38660b3af37λFuncExpr; +/** + * Return the sample variance of the input set. + */ +function var_8211da5677f811ecb687d38660b3af37< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + vals: P1, +): var_8211da5677f811ecb687d38660b3af37λFuncExpr2; +function var_8211da5677f811ecb687d38660b3af37(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::var', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff", returnTypemod: "OptionalType"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108", returnTypemod: "OptionalType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::var", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type absλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyreal>>, +> = $.$expr_Function< + "math::abs", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$anyreal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return the absolute value of the input *x*. + */ +function abs< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyreal>>, +>( + x: P1, +): absλFuncExpr; +function abs(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::abs', args, _.spec, [ + {args: [{typeId: "737f608a-77f8-11ec-b80e-79da670d9616", optional: false, setoftype: false, variadic: false}], returnTypeId: "737f608a-77f8-11ec-b80e-79da670d9616"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::abs", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type ceilλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::ceil", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type ceilλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +> = $.$expr_Function< + "math::ceil", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$bigint, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type ceilλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::ceil", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Round up to the nearest integer. + */ +function ceil< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + x: P1, +): ceilλFuncExpr; +/** + * Round up to the nearest integer. + */ +function ceil< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + x: P1, +): ceilλFuncExpr2; +/** + * Round up to the nearest integer. + */ +function ceil< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + x: P1, +): ceilλFuncExpr3; +function ceil(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::ceil', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::ceil", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type floorλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::floor", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type floorλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +> = $.$expr_Function< + "math::floor", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$bigint, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type floorλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::floor", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Round down to the nearest integer. + */ +function floor< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + x: P1, +): floorλFuncExpr; +/** + * Round down to the nearest integer. + */ +function floor< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + x: P1, +): floorλFuncExpr2; +/** + * Round down to the nearest integer. + */ +function floor< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + x: P1, +): floorλFuncExpr3; +function floor(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::floor', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::floor", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type lnλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::ln", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type lnλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::ln", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return the natural logarithm of the input value. + */ +function ln< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + x: P1, +): lnλFuncExpr; +/** + * Return the natural logarithm of the input value. + */ +function ln< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + x: P1, +): lnλFuncExpr2; +function ln(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::ln', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::ln", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type lgλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::lg", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type lgλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::lg", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return the base 10 logarithm of the input value. + */ +function lg< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + x: P1, +): lgλFuncExpr; +/** + * Return the base 10 logarithm of the input value. + */ +function lg< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + x: P1, +): lgλFuncExpr2; +function lg(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::lg', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::lg", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type logλFuncExpr< + NamedArgs extends { + "base": _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::log", + _.castMaps.mapLiteralToTypeSet<[P1]>, + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Return the logarithm of the input value in the specified *base*. + */ +function log< + NamedArgs extends { + "base": _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + namedArgs: NamedArgs, + x: P1, +): logλFuncExpr; +function log(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::log', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], namedArgs: {"base": {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::log", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type meanλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::mean", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, $.Cardinality.One> +>; +type meanλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::mean", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, $.Cardinality.One> +>; +/** + * Return the arithmetic mean of the input set. + */ +function mean< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + vals: P1, +): meanλFuncExpr; +/** + * Return the arithmetic mean of the input set. + */ +function mean< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + vals: P1, +): meanλFuncExpr2; +function mean(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::mean', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::mean", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type stddevλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::stddev", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, $.Cardinality.One> +>; +type stddevλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::stddev", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, $.Cardinality.One> +>; +/** + * Return the sample standard deviation of the input set. + */ +function stddev< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + vals: P1, +): stddevλFuncExpr; +/** + * Return the sample standard deviation of the input set. + */ +function stddev< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + vals: P1, +): stddevλFuncExpr2; +function stddev(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::stddev', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::stddev", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type stddev_popλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::stddev_pop", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, $.Cardinality.One> +>; +type stddev_popλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::stddev_pop", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, $.Cardinality.One> +>; +/** + * Return the population standard deviation of the input set. + */ +function stddev_pop< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + vals: P1, +): stddev_popλFuncExpr; +/** + * Return the population standard deviation of the input set. + */ +function stddev_pop< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + vals: P1, +): stddev_popλFuncExpr2; +function stddev_pop(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::stddev_pop', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::stddev_pop", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type var_popλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +> = $.$expr_Function< + "math::var_pop", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$number, $.cardinalityUtil.overrideLowerBound<$.Cardinality.One, 'Zero'>> +>; +type var_popλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +> = $.$expr_Function< + "math::var_pop", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_std.$decimal, $.cardinalityUtil.overrideLowerBound<$.Cardinality.One, 'Zero'>> +>; +/** + * Return the population variance of the input set. + */ +function var_pop< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + vals: P1, +): var_popλFuncExpr; +/** + * Return the population variance of the input set. + */ +function var_pop< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + vals: P1, +): var_popλFuncExpr2; +function var_pop(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('math::var_pop', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff", returnTypemod: "OptionalType"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108", returnTypemod: "OptionalType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "math::var_pop", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +type __defaultExports = { + "var": typeof var_8211da5677f811ecb687d38660b3af37; + "abs": typeof abs; + "ceil": typeof ceil; + "floor": typeof floor; + "ln": typeof ln; + "lg": typeof lg; + "log": typeof log; + "mean": typeof mean; + "stddev": typeof stddev; + "stddev_pop": typeof stddev_pop; + "var_pop": typeof var_pop +}; +const __defaultExports: __defaultExports = { + "var": var_8211da5677f811ecb687d38660b3af37, + "abs": abs, + "ceil": ceil, + "floor": floor, + "ln": ln, + "lg": lg, + "log": log, + "mean": mean, + "stddev": stddev, + "stddev_pop": stddev_pop, + "var_pop": var_pop +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/schema.ts b/qb/dbschema/edgeql-js/modules/schema.ts new file mode 100644 index 000000000..de8682560 --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/schema.ts @@ -0,0 +1,627 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _std from "./std"; +import * as _sys from "./sys"; +import * as _cfg from "./cfg"; +import * as _default from "./default"; +enum $CardinalityλEnum { + One = "One", + Many = "Many", +} +export type $Cardinality = typeof $CardinalityλEnum & $.EnumType<"schema::Cardinality", $CardinalityλEnum, `${$CardinalityλEnum}`>; +const Cardinality: $Cardinality = $.makeType<$Cardinality>(_.spec, "7b9029da-77f8-11ec-a0a7-a3a953e21652", _.syntax.literal); + +enum $OperatorKindλEnum { + Infix = "Infix", + Postfix = "Postfix", + Prefix = "Prefix", + Ternary = "Ternary", +} +export type $OperatorKind = typeof $OperatorKindλEnum & $.EnumType<"schema::OperatorKind", $OperatorKindλEnum, `${$OperatorKindλEnum}`>; +const OperatorKind: $OperatorKind = $.makeType<$OperatorKind>(_.spec, "7b91b6a6-77f8-11ec-baae-016c19539d96", _.syntax.literal); + +enum $ParameterKindλEnum { + VariadicParam = "VariadicParam", + NamedOnlyParam = "NamedOnlyParam", + PositionalParam = "PositionalParam", +} +export type $ParameterKind = typeof $ParameterKindλEnum & $.EnumType<"schema::ParameterKind", $ParameterKindλEnum, `${$ParameterKindλEnum}`>; +const ParameterKind: $ParameterKind = $.makeType<$ParameterKind>(_.spec, "7b934368-77f8-11ec-b6a9-bf4220ff9cbd", _.syntax.literal); + +enum $TargetDeleteActionλEnum { + Restrict = "Restrict", + DeleteSource = "DeleteSource", + Allow = "Allow", + DeferredRestrict = "DeferredRestrict", +} +export type $TargetDeleteAction = typeof $TargetDeleteActionλEnum & $.EnumType<"schema::TargetDeleteAction", $TargetDeleteActionλEnum, `${$TargetDeleteActionλEnum}`>; +const TargetDeleteAction: $TargetDeleteAction = $.makeType<$TargetDeleteAction>(_.spec, "7b90f37e-77f8-11ec-8694-8da98d62d603", _.syntax.literal); + +enum $TypeModifierλEnum { + SetOfType = "SetOfType", + OptionalType = "OptionalType", + SingletonType = "SingletonType", +} +export type $TypeModifier = typeof $TypeModifierλEnum & $.EnumType<"schema::TypeModifier", $TypeModifierλEnum, `${$TypeModifierλEnum}`>; +const TypeModifier: $TypeModifier = $.makeType<$TypeModifier>(_.spec, "7b940d16-77f8-11ec-ac0e-e339563110bf", _.syntax.literal); + +enum $VolatilityλEnum { + Immutable = "Immutable", + Stable = "Stable", + Volatile = "Volatile", +} +export type $Volatility = typeof $VolatilityλEnum & $.EnumType<"schema::Volatility", $VolatilityλEnum, `${$VolatilityλEnum}`>; +const Volatility: $Volatility = $.makeType<$Volatility>(_.spec, "7b927dd4-77f8-11ec-b539-f19bc8001a05", _.syntax.literal); + +export type $Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape = $.typeutil.flatten<_std.$BaseObjectλShape & { + "name": $.PropertyDesc<_std.$str, $.Cardinality.One, false, true, false>; + "internal": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, true, true>; + "builtin": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, true, true>; + "computed_fields": $.PropertyDesc<$.ArrayType<_std.$str>, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $Object_7b94fcee77f811ec849f6d5e34ea4a1b = $.ObjectType<"schema::Object", $Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape, null>; +const $Object_7b94fcee77f811ec849f6d5e34ea4a1b = $.makeType<$Object_7b94fcee77f811ec849f6d5e34ea4a1b>(_.spec, "7b94fcee-77f8-11ec-849f-6d5e34ea4a1b", _.syntax.literal); + +const Object_7b94fcee77f811ec849f6d5e34ea4a1b: $.$expr_PathNode<$.TypeSet<$Object_7b94fcee77f811ec849f6d5e34ea4a1b, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Object_7b94fcee77f811ec849f6d5e34ea4a1b, $.Cardinality.Many), null, true); + +export type $AnnotationSubjectλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "annotations": $.LinkDesc<$Annotation, $.Cardinality.Many, { + "@value": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne>; + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, false, true, false>; +}>; +type $AnnotationSubject = $.ObjectType<"schema::AnnotationSubject", $AnnotationSubjectλShape, null>; +const $AnnotationSubject = $.makeType<$AnnotationSubject>(_.spec, "7d01dfc0-77f8-11ec-985b-e7feddfe1f41", _.syntax.literal); + +const AnnotationSubject: $.$expr_PathNode<$.TypeSet<$AnnotationSubject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($AnnotationSubject, $.Cardinality.Many), null, true); + +export type $AliasλShape = $.typeutil.flatten<$AnnotationSubjectλShape & { + "type": $.LinkDesc<$Type, $.Cardinality.One, {}, false, true, false>; + "expr": $.PropertyDesc<_std.$str, $.Cardinality.One, false, true, false>; +}>; +type $Alias = $.ObjectType<"schema::Alias", $AliasλShape, null>; +const $Alias = $.makeType<$Alias>(_.spec, "7edb69e2-77f8-11ec-96d5-4d1b396adb0c", _.syntax.literal); + +const Alias: $.$expr_PathNode<$.TypeSet<$Alias, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Alias, $.Cardinality.Many), null, true); + +export type $SubclassableObjectλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "abstract": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, true>; + "is_abstract": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, false, true>; + "final": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "is_final": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; +}>; +type $SubclassableObject = $.ObjectType<"schema::SubclassableObject", $SubclassableObjectλShape, null>; +const $SubclassableObject = $.makeType<$SubclassableObject>(_.spec, "7ba1836a-77f8-11ec-a024-0d98629985bc", _.syntax.literal); + +const SubclassableObject: $.$expr_PathNode<$.TypeSet<$SubclassableObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($SubclassableObject, $.Cardinality.Many), null, true); + +export type $InheritingObjectλShape = $.typeutil.flatten<$SubclassableObjectλShape & { + "bases": $.LinkDesc<$InheritingObject, $.Cardinality.Many, { + "@index": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne>; + }, false, true, false>; + "ancestors": $.LinkDesc<$InheritingObject, $.Cardinality.Many, { + "@index": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne>; + }, false, true, false>; + "inherited_fields": $.PropertyDesc<$.ArrayType<_std.$str>, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; +}>; +type $InheritingObject = $.ObjectType<"schema::InheritingObject", $InheritingObjectλShape, null>; +const $InheritingObject = $.makeType<$InheritingObject>(_.spec, "7d1dd0e0-77f8-11ec-a6e6-05d8ba0ee9ba", _.syntax.literal); + +const InheritingObject: $.$expr_PathNode<$.TypeSet<$InheritingObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($InheritingObject, $.Cardinality.Many), null, true); + +export type $AnnotationλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & $InheritingObjectλShape & { + "inheritable": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; + "; +}>; +type $Annotation = $.ObjectType<"schema::Annotation", $AnnotationλShape, null>; +const $Annotation = $.makeType<$Annotation>(_.spec, "7ced5ee2-77f8-11ec-99a7-c1048bed8c6f", _.syntax.literal); + +const Annotation: $.$expr_PathNode<$.TypeSet<$Annotation, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Annotation, $.Cardinality.Many), null, true); + +export type $TypeλShape = $.typeutil.flatten<$SubclassableObjectλShape & $AnnotationSubjectλShape & { + "expr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "from_alias": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "is_from_alias": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "<__type__[is std::BaseObject]": $.LinkDesc<$.ObjectType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is std::Object]": $.LinkDesc<_std.$Object_7b057b6477f811ec8deb1f5fc25e7818, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is std::FreeObject]": $.LinkDesc<_std.$FreeObject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Object]": $.LinkDesc<$Object_7b94fcee77f811ec849f6d5e34ea4a1b, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::SubclassableObject]": $.LinkDesc<$SubclassableObject, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::TupleElement]": $.LinkDesc<$TupleElement, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::Delta]": $.LinkDesc<$Delta, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::AnnotationSubject]": $.LinkDesc<$AnnotationSubject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::InheritingObject]": $.LinkDesc<$InheritingObject, $.Cardinality.Many, {}, false, false, false>; + "; + "; + "<__type__[is schema::VolatilitySubject]": $.LinkDesc<$VolatilitySubject, $.Cardinality.Many, {}, false, false, false>; + "; + "; + "; + "; + "<__type__[is sys::SystemObject]": $.LinkDesc<_sys.$SystemObject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::ConfigObject]": $.LinkDesc<_cfg.$ConfigObject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::AuthMethod]": $.LinkDesc<_cfg.$AuthMethod, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::Trust]": $.LinkDesc<_cfg.$Trust, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::SCRAM]": $.LinkDesc<_cfg.$SCRAM, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::Auth]": $.LinkDesc<_cfg.$Auth, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::AbstractConfig]": $.LinkDesc<_cfg.$AbstractConfig, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::Config]": $.LinkDesc<_cfg.$Config, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::InstanceConfig]": $.LinkDesc<_cfg.$InstanceConfig, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is cfg::DatabaseConfig]": $.LinkDesc<_cfg.$DatabaseConfig, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Annotation]": $.LinkDesc<$Annotation, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Type]": $.LinkDesc<$Type, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::PrimitiveType]": $.LinkDesc<$PrimitiveType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::CollectionType]": $.LinkDesc<$CollectionType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Array]": $.LinkDesc<$Array, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Tuple]": $.LinkDesc<$Tuple, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Parameter]": $.LinkDesc<$Parameter, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::CallableObject]": $.LinkDesc<$CallableObject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Function]": $.LinkDesc<$Function, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::Operator]": $.LinkDesc<$Operator, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::Cast]": $.LinkDesc<$Cast, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Migration]": $.LinkDesc<$Migration, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Module]": $.LinkDesc<$Module, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Constraint]": $.LinkDesc<$Constraint, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::ConsistencySubject]": $.LinkDesc<$ConsistencySubject, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::ScalarType]": $.LinkDesc<$ScalarType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::PseudoType]": $.LinkDesc<$PseudoType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Index]": $.LinkDesc<$Index, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Alias]": $.LinkDesc<$Alias, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Pointer]": $.LinkDesc<$Pointer, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Property]": $.LinkDesc<$Property, $.Cardinality.Many, {}, false, false, false>; + "; + "<__type__[is schema::Source]": $.LinkDesc<$Source, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Link]": $.LinkDesc<$Link, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::ObjectType]": $.LinkDesc<$ObjectType, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is sys::Role]": $.LinkDesc<_sys.$Role, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is sys::ExtensionPackage]": $.LinkDesc<_sys.$ExtensionPackage, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is schema::Extension]": $.LinkDesc<$Extension, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is sys::Database]": $.LinkDesc<_sys.$Database, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is HasAge]": $.LinkDesc<_default.$HasAge, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is HasName]": $.LinkDesc<_default.$HasName, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Bag]": $.LinkDesc<_default.$Bag, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is A]": $.LinkDesc<_default.$A, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Łukasz]": $.LinkDesc<_default.$ukasz_61706188522211ec8089a1208956222f, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is S p a M]": $.LinkDesc<_default.$SpaM_6175fb8e522211eca4592d0a8657e1b8, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Person]": $.LinkDesc<_default.$Person, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Profile]": $.LinkDesc<_default.$Profile, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Movie]": $.LinkDesc<_default.$Movie, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Simple]": $.LinkDesc<_default.$Simple, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Hero]": $.LinkDesc<_default.$Hero, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is Villain]": $.LinkDesc<_default.$Villain, $.Cardinality.Many, {}, false, false, false>; + "<__type__[is MovieShape]": $.LinkDesc<_default.$MovieShape, $.Cardinality.Many, {}, false, false, false>; + "<__type__": $.LinkDesc<$.ObjectType, $.Cardinality.Many, {}, false, false, false>; + "; + "; + "; + "; + "; + "; +}>; +type $Type = $.ObjectType<"schema::Type", $TypeλShape, null>; +const $Type = $.makeType<$Type>(_.spec, "7bb628f6-77f8-11ec-95a9-9f0f2ea7cd4f", _.syntax.literal); + +const Type: $.$expr_PathNode<$.TypeSet<$Type, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Type, $.Cardinality.Many), null, true); + +export type $PrimitiveTypeλShape = $.typeutil.flatten<$TypeλShape & { +}>; +type $PrimitiveType = $.ObjectType<"schema::PrimitiveType", $PrimitiveTypeλShape, null>; +const $PrimitiveType = $.makeType<$PrimitiveType>(_.spec, "7c245484-77f8-11ec-a96d-0ded46185429", _.syntax.literal); + +const PrimitiveType: $.$expr_PathNode<$.TypeSet<$PrimitiveType, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($PrimitiveType, $.Cardinality.Many), null, true); + +export type $CollectionTypeλShape = $.typeutil.flatten<$PrimitiveTypeλShape & { +}>; +type $CollectionType = $.ObjectType<"schema::CollectionType", $CollectionTypeλShape, null>; +const $CollectionType = $.makeType<$CollectionType>(_.spec, "7c454c66-77f8-11ec-95f8-efac6ba28b6f", _.syntax.literal); + +const CollectionType: $.$expr_PathNode<$.TypeSet<$CollectionType, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($CollectionType, $.Cardinality.Many), null, true); + +export type $ArrayλShape = $.typeutil.flatten<$CollectionTypeλShape & { + "element_type": $.LinkDesc<$Type, $.Cardinality.One, {}, false, true, false>; + "dimensions": $.PropertyDesc<$.ArrayType<_std.$int16>, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $Array = $.ObjectType<"schema::Array", $ArrayλShape, null>; +const $Array = $.makeType<$Array>(_.spec, "7c671a76-77f8-11ec-a73d-bbc1b14ad2a2", _.syntax.literal); + +const Array: $.$expr_PathNode<$.TypeSet<$Array, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Array, $.Cardinality.Many), null, true); + +export type $CallableObjectλShape = $.typeutil.flatten<$AnnotationSubjectλShape & { + "params": $.LinkDesc<$Parameter, $.Cardinality.Many, { + "@index": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne>; + }, false, true, false>; + "return_type": $.LinkDesc<$Type, $.Cardinality.AtMostOne, {}, false, true, false>; + "return_typemod": $.PropertyDesc<$TypeModifier, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $CallableObject = $.ObjectType<"schema::CallableObject", $CallableObjectλShape, null>; +const $CallableObject = $.makeType<$CallableObject>(_.spec, "7d62a80a-77f8-11ec-80b9-872e01758f9c", _.syntax.literal); + +const CallableObject: $.$expr_PathNode<$.TypeSet<$CallableObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($CallableObject, $.Cardinality.Many), null, true); + +export type $VolatilitySubjectλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "volatility": $.PropertyDesc<$Volatility, $.Cardinality.AtMostOne, false, true, true>; +}>; +type $VolatilitySubject = $.ObjectType<"schema::VolatilitySubject", $VolatilitySubjectλShape, null>; +const $VolatilitySubject = $.makeType<$VolatilitySubject>(_.spec, "7d8c1078-77f8-11ec-a724-19a1ff37ea10", _.syntax.literal); + +const VolatilitySubject: $.$expr_PathNode<$.TypeSet<$VolatilitySubject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($VolatilitySubject, $.Cardinality.Many), null, true); + +export type $CastλShape = $.typeutil.flatten<$AnnotationSubjectλShape & $VolatilitySubjectλShape & { + "from_type": $.LinkDesc<$Type, $.Cardinality.AtMostOne, {}, false, true, false>; + "to_type": $.LinkDesc<$Type, $.Cardinality.AtMostOne, {}, false, true, false>; + "allow_implicit": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "allow_assignment": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $Cast = $.ObjectType<"schema::Cast", $CastλShape, null>; +const $Cast = $.makeType<$Cast>(_.spec, "813ebc34-77f8-11ec-9f70-dde20a1e8c77", _.syntax.literal); + +const Cast: $.$expr_PathNode<$.TypeSet<$Cast, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Cast, $.Cardinality.Many), null, true); + +export type $ConsistencySubjectλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & $InheritingObjectλShape & $AnnotationSubjectλShape & { + "constraints": $.LinkDesc<$Constraint, $.Cardinality.Many, { + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, true, true, false>; + "; + "; +}>; +type $ConsistencySubject = $.ObjectType<"schema::ConsistencySubject", $ConsistencySubjectλShape, null>; +const $ConsistencySubject = $.makeType<$ConsistencySubject>(_.spec, "7de906e8-77f8-11ec-b1b2-818121b0ef75", _.syntax.literal); + +const ConsistencySubject: $.$expr_PathNode<$.TypeSet<$ConsistencySubject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ConsistencySubject, $.Cardinality.Many), null, true); + +export type $ConstraintλShape = $.typeutil.flatten<$CallableObjectλShape & $InheritingObjectλShape & { + "subject": $.LinkDesc<$ConsistencySubject, $.Cardinality.AtMostOne, {}, false, true, false>; + "params": $.LinkDesc<$Parameter, $.Cardinality.Many, { + "@value": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne>; + "@index": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne>; + }, false, true, false>; + "expr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "subjectexpr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "finalexpr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "errmessage": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "delegated": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; + "; + "; + "; +}>; +type $Constraint = $.ObjectType<"schema::Constraint", $ConstraintλShape, null>; +const $Constraint = $.makeType<$Constraint>(_.spec, "7da33e6a-77f8-11ec-b787-4d75fdfc5e29", _.syntax.literal); + +const Constraint: $.$expr_PathNode<$.TypeSet<$Constraint, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Constraint, $.Cardinality.Many), null, true); + +export type $DeltaλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "parents": $.LinkDesc<$Delta, $.Cardinality.Many, {}, false, true, false>; + "; + "; +}>; +type $Delta = $.ObjectType<"schema::Delta", $DeltaλShape, null>; +const $Delta = $.makeType<$Delta>(_.spec, "7cd5e41a-77f8-11ec-bc5f-a5ac8a33e048", _.syntax.literal); + +const Delta: $.$expr_PathNode<$.TypeSet<$Delta, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Delta, $.Cardinality.Many), null, true); + +export type $ExtensionλShape = $.typeutil.flatten<$AnnotationSubjectλShape & $Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "package": $.LinkDesc<_sys.$ExtensionPackage, $.Cardinality.One, {}, true, true, false>; +}>; +type $Extension = $.ObjectType<"schema::Extension", $ExtensionλShape, null>; +const $Extension = $.makeType<$Extension>(_.spec, "81a0744c-77f8-11ec-b262-3b7c22c628a5", _.syntax.literal); + +const Extension: $.$expr_PathNode<$.TypeSet<$Extension, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Extension, $.Cardinality.Many), null, true); + +export type $FunctionλShape = $.typeutil.flatten<$CallableObjectλShape & $VolatilitySubjectλShape & { + "preserves_optionality": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, true>; +}>; +type $Function = $.ObjectType<"schema::Function", $FunctionλShape, null>; +const $Function = $.makeType<$Function>(_.spec, "80cd8690-77f8-11ec-9332-ad5a65218d54", _.syntax.literal); + +const Function: $.$expr_PathNode<$.TypeSet<$Function, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Function, $.Cardinality.Many), null, true); + +export type $IndexλShape = $.typeutil.flatten<$AnnotationSubjectλShape & { + "expr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; +}>; +type $Index = $.ObjectType<"schema::Index", $IndexλShape, null>; +const $Index = $.makeType<$Index>(_.spec, "7e120480-77f8-11ec-8bc9-897d953184bc", _.syntax.literal); + +const Index: $.$expr_PathNode<$.TypeSet<$Index, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Index, $.Cardinality.Many), null, true); + +export type $PointerλShape = $.typeutil.flatten<$InheritingObjectλShape & $ConsistencySubjectλShape & $AnnotationSubjectλShape & { + "source": $.LinkDesc<$Source, $.Cardinality.AtMostOne, {}, false, true, false>; + "target": $.LinkDesc<$Type, $.Cardinality.AtMostOne, {}, false, true, false>; + "cardinality": $.PropertyDesc<$Cardinality, $.Cardinality.AtMostOne, false, true, false>; + "required": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "readonly": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, false>; + "default": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "expr": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; +}>; +type $Pointer = $.ObjectType<"schema::Pointer", $PointerλShape, null>; +const $Pointer = $.makeType<$Pointer>(_.spec, "7e502666-77f8-11ec-a401-bb4c2251e6fb", _.syntax.literal); + +const Pointer: $.$expr_PathNode<$.TypeSet<$Pointer, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Pointer, $.Cardinality.Many), null, true); + +export type $SourceλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "pointers": $.LinkDesc<$Pointer, $.Cardinality.Many, { + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, true, true, false>; + "indexes": $.LinkDesc<$Index, $.Cardinality.Many, {}, true, true, false>; + "; + "; + "; + "; +}>; +type $Source = $.ObjectType<"schema::Source", $SourceλShape, null>; +const $Source = $.makeType<$Source>(_.spec, "7e3234b2-77f8-11ec-889b-2b123b0e40cb", _.syntax.literal); + +const Source: $.$expr_PathNode<$.TypeSet<$Source, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Source, $.Cardinality.Many), null, true); + +export type $LinkλShape = $.typeutil.flatten<$PointerλShape & $SourceλShape & { + "target": $.LinkDesc<$ObjectType, $.Cardinality.AtMostOne, {}, false, true, false>; + "properties": $.LinkDesc<$Property, $.Cardinality.Many, { + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, false, false, false>; + "on_target_delete": $.PropertyDesc<$TargetDeleteAction, $.Cardinality.AtMostOne, false, true, false>; + "; + "; +}>; +type $Link = $.ObjectType<"schema::Link", $LinkλShape, null>; +const $Link = $.makeType<$Link>(_.spec, "7fc9d0e6-77f8-11ec-b7f3-4da3547db4bb", _.syntax.literal); + +const Link: $.$expr_PathNode<$.TypeSet<$Link, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Link, $.Cardinality.Many), null, true); + +export type $MigrationλShape = $.typeutil.flatten<$AnnotationSubjectλShape & $Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "parents": $.LinkDesc<$Migration, $.Cardinality.Many, {}, false, true, false>; + "script": $.PropertyDesc<_std.$str, $.Cardinality.One, false, true, false>; + "message": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; +}>; +type $Migration = $.ObjectType<"schema::Migration", $MigrationλShape, null>; +const $Migration = $.makeType<$Migration>(_.spec, "8174af06-77f8-11ec-913f-d99151cf21b3", _.syntax.literal); + +const Migration: $.$expr_PathNode<$.TypeSet<$Migration, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Migration, $.Cardinality.Many), null, true); + +export type $ModuleλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & $AnnotationSubjectλShape & { +}>; +type $Module = $.ObjectType<"schema::Module", $ModuleλShape, null>; +const $Module = $.makeType<$Module>(_.spec, "7c12572a-77f8-11ec-9370-a72093efa849", _.syntax.literal); + +const Module: $.$expr_PathNode<$.TypeSet<$Module, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Module, $.Cardinality.Many), null, true); + +export type $ObjectTypeλShape = $.typeutil.flatten<$InheritingObjectλShape & $ConsistencySubjectλShape & $AnnotationSubjectλShape & $TypeλShape & $SourceλShape & { + "union_of": $.LinkDesc<$ObjectType, $.Cardinality.Many, {}, false, true, false>; + "intersection_of": $.LinkDesc<$ObjectType, $.Cardinality.Many, {}, false, true, false>; + "links": $.LinkDesc<$Link, $.Cardinality.Many, { + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, false, false, false>; + "properties": $.LinkDesc<$Property, $.Cardinality.Many, { + "@is_owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + "@owned": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne>; + }, false, false, false>; + "compound_type": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "is_compound_type": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "; + "; + "; + "; + "; + "; +}>; +type $ObjectType = $.ObjectType<"schema::ObjectType", $ObjectTypeλShape, null>; +const $ObjectType = $.makeType<$ObjectType>(_.spec, "7f5736d0-77f8-11ec-976d-c7a42f8512a6", _.syntax.literal); + +const ObjectType: $.$expr_PathNode<$.TypeSet<$ObjectType, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ObjectType, $.Cardinality.Many), null, true); + +export type $OperatorλShape = $.typeutil.flatten<$CallableObjectλShape & $VolatilitySubjectλShape & { + "operator_kind": $.PropertyDesc<$OperatorKind, $.Cardinality.AtMostOne, false, true, false>; + "is_abstract": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, false, true>; + "abstract": $.PropertyDesc<_std.$bool, $.Cardinality.AtMostOne, false, true, true>; +}>; +type $Operator = $.ObjectType<"schema::Operator", $OperatorλShape, null>; +const $Operator = $.makeType<$Operator>(_.spec, "8103419a-77f8-11ec-8aed-cf1fd4159b8d", _.syntax.literal); + +const Operator: $.$expr_PathNode<$.TypeSet<$Operator, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Operator, $.Cardinality.Many), null, true); + +export type $ParameterλShape = $.typeutil.flatten<$Object_7b94fcee77f811ec849f6d5e34ea4a1bλShape & { + "type": $.LinkDesc<$Type, $.Cardinality.One, {}, false, true, false>; + "typemod": $.PropertyDesc<$TypeModifier, $.Cardinality.One, false, true, false>; + "kind": $.PropertyDesc<$ParameterKind, $.Cardinality.One, false, true, false>; + "num": $.PropertyDesc<_std.$int64, $.Cardinality.One, false, true, false>; + "default": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; + "; + "; + "; +}>; +type $Parameter = $.ObjectType<"schema::Parameter", $ParameterλShape, null>; +const $Parameter = $.makeType<$Parameter>(_.spec, "7d4524e2-77f8-11ec-879e-839d73fadd17", _.syntax.literal); + +const Parameter: $.$expr_PathNode<$.TypeSet<$Parameter, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Parameter, $.Cardinality.Many), null, true); + +export type $PropertyλShape = $.typeutil.flatten<$PointerλShape & { + "; + "; + "; +}>; +type $Property = $.ObjectType<"schema::Property", $PropertyλShape, null>; +const $Property = $.makeType<$Property>(_.spec, "8030c738-77f8-11ec-b34d-3d7f323a040f", _.syntax.literal); + +const Property: $.$expr_PathNode<$.TypeSet<$Property, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Property, $.Cardinality.Many), null, true); + +export type $PseudoTypeλShape = $.typeutil.flatten<$InheritingObjectλShape & $TypeλShape & { +}>; +type $PseudoType = $.ObjectType<"schema::PseudoType", $PseudoTypeλShape, null>; +const $PseudoType = $.makeType<$PseudoType>(_.spec, "7bcb25da-77f8-11ec-8769-916f2785870e", _.syntax.literal); + +const PseudoType: $.$expr_PathNode<$.TypeSet<$PseudoType, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($PseudoType, $.Cardinality.Many), null, true); + +export type $ScalarTypeλShape = $.typeutil.flatten<$InheritingObjectλShape & $ConsistencySubjectλShape & $AnnotationSubjectλShape & $PrimitiveTypeλShape & { + "default": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "enum_values": $.PropertyDesc<$.ArrayType<_std.$str>, $.Cardinality.AtMostOne, false, true, false>; +}>; +type $ScalarType = $.ObjectType<"schema::ScalarType", $ScalarTypeλShape, null>; +const $ScalarType = $.makeType<$ScalarType>(_.spec, "7f025b2e-77f8-11ec-be4f-f1dd71625fc0", _.syntax.literal); + +const ScalarType: $.$expr_PathNode<$.TypeSet<$ScalarType, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ScalarType, $.Cardinality.Many), null, true); + +export type $TupleλShape = $.typeutil.flatten<$CollectionTypeλShape & { + "element_types": $.LinkDesc<$TupleElement, $.Cardinality.Many, { + "@index": $.PropertyDesc<_std.$int64, $.Cardinality.AtMostOne>; + }, true, true, false>; +}>; +type $Tuple = $.ObjectType<"schema::Tuple", $TupleλShape, null>; +const $Tuple = $.makeType<$Tuple>(_.spec, "7ca4cfe2-77f8-11ec-929a-a3223be82948", _.syntax.literal); + +const Tuple: $.$expr_PathNode<$.TypeSet<$Tuple, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Tuple, $.Cardinality.Many), null, true); + +export type $TupleElementλShape = $.typeutil.flatten<_std.$BaseObjectλShape & { + "type": $.LinkDesc<$Type, $.Cardinality.One, {}, false, true, false>; + "name": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "; + "; +}>; +type $TupleElement = $.ObjectType<"schema::TupleElement", $TupleElementλShape, null>; +const $TupleElement = $.makeType<$TupleElement>(_.spec, "7c91fffc-77f8-11ec-bce6-2d39e0d9a395", _.syntax.literal); + +const TupleElement: $.$expr_PathNode<$.TypeSet<$TupleElement, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($TupleElement, $.Cardinality.Many), null, true); + + + +export { $CardinalityλEnum, Cardinality, $OperatorKindλEnum, OperatorKind, $ParameterKindλEnum, ParameterKind, $TargetDeleteActionλEnum, TargetDeleteAction, $TypeModifierλEnum, TypeModifier, $VolatilityλEnum, Volatility, $Object_7b94fcee77f811ec849f6d5e34ea4a1b, Object_7b94fcee77f811ec849f6d5e34ea4a1b, $AnnotationSubject, AnnotationSubject, $Alias, Alias, $SubclassableObject, SubclassableObject, $InheritingObject, InheritingObject, $Annotation, Annotation, $Type, Type, $PrimitiveType, PrimitiveType, $CollectionType, CollectionType, $Array, Array, $CallableObject, CallableObject, $VolatilitySubject, VolatilitySubject, $Cast, Cast, $ConsistencySubject, ConsistencySubject, $Constraint, Constraint, $Delta, Delta, $Extension, Extension, $Function, Function, $Index, Index, $Pointer, Pointer, $Source, Source, $Link, Link, $Migration, Migration, $Module, Module, $ObjectType, ObjectType, $Operator, Operator, $Parameter, Parameter, $Property, Property, $PseudoType, PseudoType, $ScalarType, ScalarType, $Tuple, Tuple, $TupleElement, TupleElement }; + +type __defaultExports = { + "Cardinality": typeof Cardinality; + "OperatorKind": typeof OperatorKind; + "ParameterKind": typeof ParameterKind; + "TargetDeleteAction": typeof TargetDeleteAction; + "TypeModifier": typeof TypeModifier; + "Volatility": typeof Volatility; + "Object": typeof Object_7b94fcee77f811ec849f6d5e34ea4a1b; + "AnnotationSubject": typeof AnnotationSubject; + "Alias": typeof Alias; + "SubclassableObject": typeof SubclassableObject; + "InheritingObject": typeof InheritingObject; + "Annotation": typeof Annotation; + "Type": typeof Type; + "PrimitiveType": typeof PrimitiveType; + "CollectionType": typeof CollectionType; + "Array": typeof Array; + "CallableObject": typeof CallableObject; + "VolatilitySubject": typeof VolatilitySubject; + "Cast": typeof Cast; + "ConsistencySubject": typeof ConsistencySubject; + "Constraint": typeof Constraint; + "Delta": typeof Delta; + "Extension": typeof Extension; + "Function": typeof Function; + "Index": typeof Index; + "Pointer": typeof Pointer; + "Source": typeof Source; + "Link": typeof Link; + "Migration": typeof Migration; + "Module": typeof Module; + "ObjectType": typeof ObjectType; + "Operator": typeof Operator; + "Parameter": typeof Parameter; + "Property": typeof Property; + "PseudoType": typeof PseudoType; + "ScalarType": typeof ScalarType; + "Tuple": typeof Tuple; + "TupleElement": typeof TupleElement +}; +const __defaultExports: __defaultExports = { + "Cardinality": Cardinality, + "OperatorKind": OperatorKind, + "ParameterKind": ParameterKind, + "TargetDeleteAction": TargetDeleteAction, + "TypeModifier": TypeModifier, + "Volatility": Volatility, + "Object": Object_7b94fcee77f811ec849f6d5e34ea4a1b, + "AnnotationSubject": AnnotationSubject, + "Alias": Alias, + "SubclassableObject": SubclassableObject, + "InheritingObject": InheritingObject, + "Annotation": Annotation, + "Type": Type, + "PrimitiveType": PrimitiveType, + "CollectionType": CollectionType, + "Array": Array, + "CallableObject": CallableObject, + "VolatilitySubject": VolatilitySubject, + "Cast": Cast, + "ConsistencySubject": ConsistencySubject, + "Constraint": Constraint, + "Delta": Delta, + "Extension": Extension, + "Function": Function, + "Index": Index, + "Pointer": Pointer, + "Source": Source, + "Link": Link, + "Migration": Migration, + "Module": Module, + "ObjectType": ObjectType, + "Operator": Operator, + "Parameter": Parameter, + "Property": Property, + "PseudoType": PseudoType, + "ScalarType": ScalarType, + "Tuple": Tuple, + "TupleElement": TupleElement +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/std.ts b/qb/dbschema/edgeql-js/modules/std.ts new file mode 100644 index 000000000..855ec731f --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/std.ts @@ -0,0 +1,3521 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _cal from "./cal"; +import * as _cfg from "./cfg"; +import * as _schema from "./schema"; +type $anyscalar = $uuid | $str | $bytes | $bool | $datetime | _cal.$local_datetime | _cal.$local_date | _cal.$local_time | $duration | $json | _cal.$relative_duration | _cfg.$memory | $anyreal | $.EnumType; +const $anyscalar: $anyscalar = $.makeType<$anyscalar>(_.spec, "73795da2-77f8-11ec-a0fb-95758a2ed256", _.syntax.literal); + +export type $str = $.ScalarType<"std::str", string, true>; +const str: $.scalarTypeWithConstructor<$str, never> = $.makeType<$.scalarTypeWithConstructor<$str, never>>(_.spec, "00000000-0000-0000-0000-000000000101", _.syntax.literal); + +type $anyreal = $anyint | $anyfloat | $anynumeric; +const $anyreal: $anyreal = $.makeType<$anyreal>(_.spec, "737f608a-77f8-11ec-b80e-79da670d9616", _.syntax.literal); + +type $anyfloat = $number; +const $anyfloat: $anyfloat = $.makeType<$anyfloat>(_.spec, "73833b92-77f8-11ec-ba18-a953df212644", _.syntax.literal); + +type $anyint = $number | $bigint; +const $anyint: $anyint = $.makeType<$anyint>(_.spec, "73802e5c-77f8-11ec-bb71-d5cd789ef564", _.syntax.literal); + +type $anynumeric = $decimal | $bigint; +const $anynumeric: $anynumeric = $.makeType<$anynumeric>(_.spec, "738575f6-77f8-11ec-8118-c31d6ebbaa16", _.syntax.literal); + +export type $bigint = $.ScalarType<"std::bigint", bigint, true>; +const bigint: $.scalarTypeWithConstructor<$bigint, never> = $.makeType<$.scalarTypeWithConstructor<$bigint, never>>(_.spec, "00000000-0000-0000-0000-000000000110", _.syntax.literal); + +export type $bool = $.ScalarType<"std::bool", boolean, true>; +const bool: $.scalarTypeWithConstructor<$bool, never> = $.makeType<$.scalarTypeWithConstructor<$bool, never>>(_.spec, "00000000-0000-0000-0000-000000000109", _.syntax.literal); + +export type $bytes = $.ScalarType<"std::bytes", Buffer, true>; +const bytes: $.scalarTypeWithConstructor<$bytes, never> = $.makeType<$.scalarTypeWithConstructor<$bytes, never>>(_.spec, "00000000-0000-0000-0000-000000000102", _.syntax.literal); + +export type $datetime = $.ScalarType<"std::datetime", Date, true>; +const datetime: $.scalarTypeWithConstructor<$datetime, never> = $.makeType<$.scalarTypeWithConstructor<$datetime, never>>(_.spec, "00000000-0000-0000-0000-00000000010a", _.syntax.literal); + +export type $decimal = $.ScalarType<"std::decimal", unknown, true>; +const decimal: $.scalarTypeWithConstructor<$decimal, never> = $.makeType<$.scalarTypeWithConstructor<$decimal, never>>(_.spec, "00000000-0000-0000-0000-000000000108", _.syntax.literal); +export type $decimalλICastableTo = $decimal | $bigint; +export type $decimalλIAssignableBy = $decimal | $bigint; + +export type $duration = $.ScalarType<"std::duration", _.edgedb.Duration, true>; +const duration: $.scalarTypeWithConstructor<$duration, never> = $.makeType<$.scalarTypeWithConstructor<$duration, never>>(_.spec, "00000000-0000-0000-0000-00000000010e", _.syntax.literal); + +export type $float32 = $.ScalarType<"std::number", number, true>; +const float32: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-000000000106", _.syntax.literal); + +export type $float64 = $.ScalarType<"std::number", number, true>; +const float64: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-000000000107", _.syntax.literal); + +export type $int16 = $.ScalarType<"std::number", number, true>; +const int16: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-000000000103", _.syntax.literal); + +export type $int32 = $.ScalarType<"std::number", number, true>; +const int32: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-000000000104", _.syntax.literal); + +export type $int64 = $.ScalarType<"std::number", number, true>; +const int64: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-000000000105", _.syntax.literal); + +export type $json = $.ScalarType<"std::json", string, true>; +const json: $.scalarTypeWithConstructor<$json, any> = $.makeType<$.scalarTypeWithConstructor<$json, any>>(_.spec, "00000000-0000-0000-0000-00000000010f", _.syntax.literal); + +interface $sequence extends $int64 {} +const $sequence: $sequence = $.makeType<$sequence>(_.spec, "7387c356-77f8-11ec-a2f8-3ffa01fdc573", _.syntax.literal); + +export type $uuid = $.ScalarType<"std::uuid", string, true>; +const uuid: $.scalarTypeWithConstructor<$uuid, never> = $.makeType<$.scalarTypeWithConstructor<$uuid, never>>(_.spec, "00000000-0000-0000-0000-000000000100", _.syntax.literal); + +export type $number = $.ScalarType<"std::number", number, true>; +const number: $.scalarTypeWithConstructor<$number, string> = $.makeType<$.scalarTypeWithConstructor<$number, string>>(_.spec, "00000000-0000-0000-0000-0000000001ff", _.syntax.literal); + +export type $BaseObjectλShape = $.typeutil.flatten<{ + "__type__": $.LinkDesc<_schema.$Type, $.Cardinality.One, {}, false, false, false>; + "id": $.PropertyDesc<$uuid, $.Cardinality.One, true, false, true>; +}>; +type $BaseObject = $.ObjectType<"std::BaseObject", $BaseObjectλShape, null>; +const $BaseObject = $.makeType<$BaseObject>(_.spec, "7afe0046-77f8-11ec-8427-71ef12be3838", _.syntax.literal); + +const BaseObject: $.$expr_PathNode<$.TypeSet<$BaseObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($BaseObject, $.Cardinality.Many), null, true); + +export type $Object_7b057b6477f811ec8deb1f5fc25e7818λShape = $.typeutil.flatten<$BaseObjectλShape & { +}>; +type $Object_7b057b6477f811ec8deb1f5fc25e7818 = $.ObjectType<"std::Object", $Object_7b057b6477f811ec8deb1f5fc25e7818λShape, null>; +const $Object_7b057b6477f811ec8deb1f5fc25e7818 = $.makeType<$Object_7b057b6477f811ec8deb1f5fc25e7818>(_.spec, "7b057b64-77f8-11ec-8deb-1f5fc25e7818", _.syntax.literal); + +const Object_7b057b6477f811ec8deb1f5fc25e7818: $.$expr_PathNode<$.TypeSet<$Object_7b057b6477f811ec8deb1f5fc25e7818, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Object_7b057b6477f811ec8deb1f5fc25e7818, $.Cardinality.Many), null, true); + +export type $FreeObjectλShape = $.typeutil.flatten<$BaseObjectλShape & { +}>; +type $FreeObject = $.ObjectType<"std::FreeObject", $FreeObjectλShape, null>; +const $FreeObject = $.makeType<$FreeObject>(_.spec, "7b0d993e-77f8-11ec-ab20-7985420ab019", _.syntax.literal); + +const FreeObject: $.$expr_PathNode<$.TypeSet<$FreeObject, $.Cardinality.One>, null, true> = _.syntax.$PathNode($.$toSet($FreeObject, $.Cardinality.One), null, true); + +type assert_singleλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::assert_single", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +/** + * Check that the input set contains at most one element, raise + CardinalityViolationError otherwise. + */ +function assert_single< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + input: P1, +): assert_singleλFuncExpr; +function assert_single(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::assert_single', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "OptionalType", preservesOptionality: true}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::assert_single", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type assert_existsλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::assert_exists", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.cardinalityUtil.overrideLowerBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +/** + * Check that the input set contains at least one element, raise + CardinalityViolationError otherwise. + */ +function assert_exists< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + input: P1, +): assert_existsλFuncExpr; +function assert_exists(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::assert_exists', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::assert_exists", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type assert_distinctλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::assert_distinct", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.Cardinality.Many> +>; +/** + * Check that the input set is a proper set, i.e. all elements + are unique + */ +function assert_distinct< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + input: P1, +): assert_distinctλFuncExpr; +function assert_distinct(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::assert_distinct', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType", preservesOptionality: true}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::assert_distinct", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type lenλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::len", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type lenλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +> = $.$expr_Function< + "std::len", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type lenλFuncExpr3< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, +> = $.$expr_Function< + "std::len", + [P1], + {}, + $.TypeSet<$number, P1["__cardinality__"]> +>; +/** + * A polymorphic function to calculate a "length" of its first argument. + */ +function len< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + str: P1, +): lenλFuncExpr; +/** + * A polymorphic function to calculate a "length" of its first argument. + */ +function len< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +>( + bytes: P1, +): lenλFuncExpr2; +/** + * A polymorphic function to calculate a "length" of its first argument. + */ +function len< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, +>( + array: P1, +): lenλFuncExpr3; +function len(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::len', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::len", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type sumλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, +> = $.$expr_Function< + "std::sum", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$bigint, $.Cardinality.One> +>; +type sumλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::sum", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$number, $.Cardinality.One> +>; +type sumλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +> = $.$expr_Function< + "std::sum", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$decimal, $.Cardinality.One> +>; +/** + * Return the sum of the set of numbers. + */ +function sum< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, +>( + s: P1, +): sumλFuncExpr; +/** + * Return the sum of the set of numbers. + */ +function sum< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + s: P1, +): sumλFuncExpr2; +/** + * Return the sum of the set of numbers. + */ +function sum< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +>( + s: P1, +): sumλFuncExpr3; +function sum(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::sum', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::sum", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type countλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::count", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$number, $.Cardinality.One> +>; +/** + * Return the number of elements in a set. + */ +function count< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + s: P1, +): countλFuncExpr; +function count(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::count', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::count", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type randomλFuncExpr = $.$expr_Function< + "std::random", + [], + {}, + $.TypeSet<$number, $.Cardinality.One> +>; +/** + * Return a pseudo-random number in the range `0.0 <= x < 1.0` + */ +function random(): randomλFuncExpr; +function random(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::random', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::random", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type minλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$anyreal>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$anyreal, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.EnumType, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr4< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr5< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$duration, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr6< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr7< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr8< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type minλFuncExpr9< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_datetime>>, +> = $.$expr_Function< + "std::min", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_datetime>, $.cardinalityUtil.overrideUpperBound> +>; +type minλFuncExpr10< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_date>>, +> = $.$expr_Function< + "std::min", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_date>, $.cardinalityUtil.overrideUpperBound> +>; +type minλFuncExpr11< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_time>>, +> = $.$expr_Function< + "std::min", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_time>, $.cardinalityUtil.overrideUpperBound> +>; +type minλFuncExpr12< + P1 extends $.TypeSet<$.ArrayType<_cal.$relative_duration>>, +> = $.$expr_Function< + "std::min", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$relative_duration>, $.cardinalityUtil.overrideUpperBound> +>; +type minλFuncExpr13< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::min", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$anyreal>>, +>( + vals: P1, +): minλFuncExpr; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + vals: P1, +): minλFuncExpr2; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + vals: P1, +): minλFuncExpr3; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, +>( + vals: P1, +): minλFuncExpr4; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +>( + vals: P1, +): minλFuncExpr5; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + vals: P1, +): minλFuncExpr6; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + vals: P1, +): minλFuncExpr7; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + vals: P1, +): minλFuncExpr8; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_datetime>>, +>( + vals: P1, +): minλFuncExpr9; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_date>>, +>( + vals: P1, +): minλFuncExpr10; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_time>>, +>( + vals: P1, +): minλFuncExpr11; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends $.TypeSet<$.ArrayType<_cal.$relative_duration>>, +>( + vals: P1, +): minλFuncExpr12; +/** + * Return the smallest value of the input set. + */ +function min< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + vals: P1, +): minλFuncExpr13; +function min(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::min', args, _.spec, [ + {args: [{typeId: "737f608a-77f8-11ec-b80e-79da670d9616", optional: false, setoftype: true, variadic: false}], returnTypeId: "737f608a-77f8-11ec-b80e-79da670d9616", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: true, variadic: false}], returnTypeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "44a76fab-349d-00e9-396b-1000d7e967da", optional: false, setoftype: true, variadic: false}], returnTypeId: "44a76fab-349d-00e9-396b-1000d7e967da", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "076e1d6f-f104-88b2-0632-d53171d9c827", optional: false, setoftype: true, variadic: false}], returnTypeId: "076e1d6f-f104-88b2-0632-d53171d9c827", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "82ea7b30-73d3-c79c-86fb-b253f194f53e", optional: false, setoftype: true, variadic: false}], returnTypeId: "82ea7b30-73d3-c79c-86fb-b253f194f53e", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "63acbf06-4c0c-67ac-c508-50a5ef4f4b16", optional: false, setoftype: true, variadic: false}], returnTypeId: "63acbf06-4c0c-67ac-c508-50a5ef4f4b16", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "OptionalType", preservesOptionality: true}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::min", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type maxλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$anyreal>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$anyreal, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.EnumType, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr4< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr5< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$duration, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr6< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr7< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr8< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +type maxλFuncExpr9< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_datetime>>, +> = $.$expr_Function< + "std::max", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_datetime>, $.cardinalityUtil.overrideUpperBound> +>; +type maxλFuncExpr10< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_date>>, +> = $.$expr_Function< + "std::max", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_date>, $.cardinalityUtil.overrideUpperBound> +>; +type maxλFuncExpr11< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_time>>, +> = $.$expr_Function< + "std::max", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$local_time>, $.cardinalityUtil.overrideUpperBound> +>; +type maxλFuncExpr12< + P1 extends $.TypeSet<$.ArrayType<_cal.$relative_duration>>, +> = $.$expr_Function< + "std::max", + [P1], + {}, + $.TypeSet<$.ArrayType<_cal.$relative_duration>, $.cardinalityUtil.overrideUpperBound> +>; +type maxλFuncExpr13< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::max", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.cardinalityUtil.overrideUpperBound<_.castMaps.literalToTypeSet["__cardinality__"], "One">> +>; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$anyreal>>, +>( + vals: P1, +): maxλFuncExpr; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + vals: P1, +): maxλFuncExpr2; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + vals: P1, +): maxλFuncExpr3; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, +>( + vals: P1, +): maxλFuncExpr4; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +>( + vals: P1, +): maxλFuncExpr5; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + vals: P1, +): maxλFuncExpr6; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + vals: P1, +): maxλFuncExpr7; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + vals: P1, +): maxλFuncExpr8; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_datetime>>, +>( + vals: P1, +): maxλFuncExpr9; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_date>>, +>( + vals: P1, +): maxλFuncExpr10; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends $.TypeSet<$.ArrayType<_cal.$local_time>>, +>( + vals: P1, +): maxλFuncExpr11; +/** + * Return the smallest value of the input set. + */ +function max< + P1 extends $.TypeSet<$.ArrayType<_cal.$relative_duration>>, +>( + vals: P1, +): maxλFuncExpr12; +/** + * Return the greatest value of the input set. + */ +function max< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + vals: P1, +): maxλFuncExpr13; +function max(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::max', args, _.spec, [ + {args: [{typeId: "737f608a-77f8-11ec-b80e-79da670d9616", optional: false, setoftype: true, variadic: false}], returnTypeId: "737f608a-77f8-11ec-b80e-79da670d9616", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: true, variadic: false}], returnTypeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "44a76fab-349d-00e9-396b-1000d7e967da", optional: false, setoftype: true, variadic: false}], returnTypeId: "44a76fab-349d-00e9-396b-1000d7e967da", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "076e1d6f-f104-88b2-0632-d53171d9c827", optional: false, setoftype: true, variadic: false}], returnTypeId: "076e1d6f-f104-88b2-0632-d53171d9c827", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "82ea7b30-73d3-c79c-86fb-b253f194f53e", optional: false, setoftype: true, variadic: false}], returnTypeId: "82ea7b30-73d3-c79c-86fb-b253f194f53e", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "63acbf06-4c0c-67ac-c508-50a5ef4f4b16", optional: false, setoftype: true, variadic: false}], returnTypeId: "63acbf06-4c0c-67ac-c508-50a5ef4f4b16", returnTypemod: "OptionalType", preservesOptionality: true}, + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "OptionalType", preservesOptionality: true}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::max", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type allλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bool>>, +> = $.$expr_Function< + "std::all", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$bool, $.Cardinality.One> +>; +/** + * Generalized boolean `AND` applied to the set of *values*. + */ +function all< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bool>>, +>( + vals: P1, +): allλFuncExpr; +function all(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::all', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::all", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type anyλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bool>>, +> = $.$expr_Function< + "std::any", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$bool, $.Cardinality.One> +>; +/** + * Generalized boolean `OR` applied to the set of *values*. + */ +function any< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bool>>, +>( + vals: P1, +): anyλFuncExpr; +function any(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::any', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::any", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type enumerateλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +> = $.$expr_Function< + "std::enumerate", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.TupleType<[$int64, $.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>]>, $.Cardinality.Many> +>; +/** + * Return a set of tuples of the form `(index, element)`. + */ +function enumerate< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + vals: P1, +): enumerateλFuncExpr; +function enumerate(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::enumerate', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "9c27acd9-0932-6050-c7b0-c7410e2e0a85", returnTypemod: "SetOfType", preservesOptionality: true}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::enumerate", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type roundλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::round", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type roundλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, +> = $.$expr_Function< + "std::round", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$bigint, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type roundλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +> = $.$expr_Function< + "std::round", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type roundλFuncExpr4< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::round", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Round to the nearest value. + */ +function round< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + val: P1, +): roundλFuncExpr; +/** + * Round to the nearest value. + */ +function round< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, +>( + val: P1, +): roundλFuncExpr2; +/** + * Round to the nearest value. + */ +function round< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +>( + val: P1, +): roundλFuncExpr3; +/** + * Round to the nearest value. + */ +function round< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + val: P1, + d: P2, +): roundλFuncExpr4; +function round(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::round', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::round", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type containsλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::contains", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type containsλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +> = $.$expr_Function< + "std::contains", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type containsλFuncExpr3< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends $.TypeSet<$decimalλICastableTo>, +> = $.$expr_Function< + "std::contains", + [P1, P2], + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities> +>; +type containsλFuncExpr4< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ObjectType>, +> = $.$expr_Function< + "std::contains", + [P1, P2], + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities> +>; +type containsλFuncExpr5< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.AnyTupleType>, +> = $.$expr_Function< + "std::contains", + [P1, P2], + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities> +>; +type containsλFuncExpr6< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, +> = $.$expr_Function< + "std::contains", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities["__cardinality__"]>> +>; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr2; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends $.TypeSet<$decimalλICastableTo>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr3; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ObjectType>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr4; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr5; +/** + * A polymorphic function to test if a sequence contains a certain element. + */ +function contains< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, +>( + haystack: P1, + needle: P2, +): containsλFuncExpr6; +function contains(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::contains', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::contains", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type findλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type findλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type findλFuncExpr3< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends $.TypeSet<$decimalλICastableTo>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type findλFuncExpr4< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ObjectType>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type findλFuncExpr5< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.AnyTupleType>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type findλFuncExpr6< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +> = $.$expr_Function< + "std::find", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + haystack: P1, + needle: P2, +): findλFuncExpr; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, +>( + haystack: P1, + needle: P2, +): findλFuncExpr2; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends $.TypeSet<$decimalλICastableTo>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +>( + haystack: P1, + needle: P2, + from_pos?: P3, +): findλFuncExpr3; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ObjectType>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +>( + haystack: P1, + needle: P2, + from_pos?: P3, +): findλFuncExpr4; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.AnyTupleType>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +>( + haystack: P1, + needle: P2, + from_pos?: P3, +): findλFuncExpr5; +/** + * A polymorphic function to find index of an element in a sequence. + */ +function find< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>> | undefined, +>( + haystack: P1, + needle: P2, + from_pos?: P3, +): findλFuncExpr6; +function find(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::find', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::find", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type array_aggλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.NonArrayType>>, +> = $.$expr_Function< + "std::array_agg", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType<_.castMaps.literalToTypeSet["__element__"]>>, $.Cardinality.One> +>; +/** + * Return the array made from all of the input set elements. + */ +function array_agg< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.NonArrayType>>, +>( + s: P1, +): array_aggλFuncExpr; +function array_agg(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::array_agg', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::array_agg", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type array_unpackλFuncExpr< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, +> = $.$expr_Function< + "std::array_unpack", + [P1], + {}, + $.TypeSet<$.getPrimitiveNonArrayBaseType, $.Cardinality.Many> +>; +/** + * Return array elements as a set. + */ +function array_unpack< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, +>( + array: P1, +): array_unpackλFuncExpr; +function array_unpack(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::array_unpack', args, _.spec, [ + {args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::array_unpack", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type array_getλFuncExpr< + NamedArgs extends { + "default"?: $.TypeSet<$decimalλICastableTo>, + }, + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + NamedArgs, + $.TypeSet<_.syntax.getSharedParentPrimitive, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality>, 'Zero'>> +>; +type array_getλFuncExpr2< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet["__cardinality__"]>, 'Zero'>> +>; +type array_getλFuncExpr3< + NamedArgs extends { + "default"?: $.TypeSet<$.ObjectType>, + }, + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + NamedArgs, + $.TypeSet<_.syntax.mergeObjectTypes, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality>, 'Zero'>> +>; +type array_getλFuncExpr4< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet["__cardinality__"]>, 'Zero'>> +>; +type array_getλFuncExpr5< + NamedArgs extends { + "default"?: $.TypeSet<$.AnyTupleType>, + }, + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + NamedArgs, + $.TypeSet<_.syntax.getSharedParentPrimitive, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality>, 'Zero'>> +>; +type array_getλFuncExpr6< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet["__cardinality__"]>, 'Zero'>> +>; +type array_getλFuncExpr7< + NamedArgs extends { + "default"?: _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, + }, + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<$.getPrimitiveNonArrayBaseType, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, 'Zero'>> +>; +type array_getλFuncExpr8< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::array_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$.getPrimitiveNonArrayBaseType, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities["__cardinality__"]>, 'Zero'>> +>; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + NamedArgs extends { + "default"?: $.TypeSet<$decimalλICastableTo>, + }, + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + namedArgs: NamedArgs, + array: P1, + idx: P2, +): array_getλFuncExpr; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + P1 extends $.TypeSet<$.ArrayType<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + array: P1, + idx: P2, +): array_getλFuncExpr2; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + NamedArgs extends { + "default"?: $.TypeSet<$.ObjectType>, + }, + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + namedArgs: NamedArgs, + array: P1, + idx: P2, +): array_getλFuncExpr3; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + array: P1, + idx: P2, +): array_getλFuncExpr4; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + NamedArgs extends { + "default"?: $.TypeSet<$.AnyTupleType>, + }, + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + namedArgs: NamedArgs, + array: P1, + idx: P2, +): array_getλFuncExpr5; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + array: P1, + idx: P2, +): array_getλFuncExpr6; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + NamedArgs extends { + "default"?: _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveNonArrayBaseType>>, + }, + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + namedArgs: NamedArgs, + array: P1, + idx: P2, +): array_getλFuncExpr7; +/** + * Return the element of *array* at the specified *index*. + */ +function array_get< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + array: P1, + idx: P2, +): array_getλFuncExpr8; +function array_get(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::array_get', args, _.spec, [ + {args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], namedArgs: {"default": {typeId: "00000000-0000-0000-0000-000000000001", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "OptionalType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::array_get", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type array_joinλFuncExpr< + P1 extends $.TypeSet<$.ArrayType<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::array_join", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities["__cardinality__"]>> +>; +/** + * Render an array to a string. + */ +function array_join< + P1 extends $.TypeSet<$.ArrayType<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + array: P1, + delimiter: P2, +): array_joinλFuncExpr; +function array_join(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::array_join', args, _.spec, [ + {args: [{typeId: "05f91774-15ea-9001-038e-092c1cad80af", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::array_join", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type bytes_get_bitλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::bytes_get_bit", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Get the *nth* bit of the *bytes* value. + */ +function bytes_get_bit< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + bytes: P1, + num: P2, +): bytes_get_bitλFuncExpr; +function bytes_get_bit(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::bytes_get_bit', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::bytes_get_bit", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type datetime_currentλFuncExpr = $.$expr_Function< + "std::datetime_current", + [], + {}, + $.TypeSet<$datetime, $.Cardinality.One> +>; +/** + * Return the current server date and time. + */ +function datetime_current(): datetime_currentλFuncExpr; +function datetime_current(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::datetime_current', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::datetime_current", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type datetime_of_transactionλFuncExpr = $.$expr_Function< + "std::datetime_of_transaction", + [], + {}, + $.TypeSet<$datetime, $.Cardinality.One> +>; +/** + * Return the date and time of the start of the current transaction. + */ +function datetime_of_transaction(): datetime_of_transactionλFuncExpr; +function datetime_of_transaction(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::datetime_of_transaction', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::datetime_of_transaction", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type datetime_of_statementλFuncExpr = $.$expr_Function< + "std::datetime_of_statement", + [], + {}, + $.TypeSet<$datetime, $.Cardinality.One> +>; +/** + * Return the date and time of the start of the current statement. + */ +function datetime_of_statement(): datetime_of_statementλFuncExpr; +function datetime_of_statement(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::datetime_of_statement', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::datetime_of_statement", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type datetime_getλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::datetime_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type datetime_getλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::datetime_get", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Extract a specific element of input datetime by name. + */ +function datetime_get< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + dt: P1, + el: P2, +): datetime_getλFuncExpr; +/** + * Extract a specific element of input datetime by name. + */ +function datetime_get< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + dt: P1, + el: P2, +): datetime_getλFuncExpr2; +function datetime_get(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::datetime_get', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::datetime_get", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type datetime_truncateλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::datetime_truncate", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Truncate the input datetime to a particular precision. + */ +function datetime_truncate< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + dt: P1, + unit: P2, +): datetime_truncateλFuncExpr; +function datetime_truncate(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::datetime_truncate', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::datetime_truncate", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type duration_truncateλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::duration_truncate", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Truncate the input duration to a particular precision. + */ +function duration_truncate< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + dt: P1, + unit: P2, +): duration_truncateλFuncExpr; +function duration_truncate(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::duration_truncate', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::duration_truncate", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type duration_to_secondsλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +> = $.$expr_Function< + "std::duration_to_seconds", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return duration as total number of seconds in interval. + */ +function duration_to_seconds< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, +>( + dur: P1, +): duration_to_secondsλFuncExpr; +function duration_to_seconds(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::duration_to_seconds', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::duration_to_seconds", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type json_typeofλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +> = $.$expr_Function< + "std::json_typeof", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return the type of the outermost JSON value as a string. + */ +function json_typeof< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +>( + json: P1, +): json_typeofλFuncExpr; +function json_typeof(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::json_typeof', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::json_typeof", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type json_array_unpackλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +> = $.$expr_Function< + "std::json_array_unpack", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$json, $.Cardinality.Many> +>; +/** + * Return elements of JSON array as a set of `json`. + */ +function json_array_unpack< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +>( + array: P1, +): json_array_unpackλFuncExpr; +function json_array_unpack(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::json_array_unpack', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010f", returnTypemod: "SetOfType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::json_array_unpack", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type json_object_unpackλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +> = $.$expr_Function< + "std::json_object_unpack", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$.TupleType<[$str, $json]>, $.Cardinality.Many> +>; +/** + * Return set of key/value tuples that make up the JSON object. + */ +function json_object_unpack< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, +>( + obj: P1, +): json_object_unpackλFuncExpr; +function json_object_unpack(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::json_object_unpack', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "79d8ede8-30f1-a805-fbc3-503ece3c9205", returnTypemod: "SetOfType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::json_object_unpack", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type json_getλFuncExpr< + NamedArgs extends { + "default"?: _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends [_.castMaps.orScalarLiteral<$.TypeSet<$str>>, ..._.castMaps.orScalarLiteral<$.TypeSet<$str>>[]], +> = $.$expr_Function< + "std::json_get", + _.castMaps.mapLiteralToTypeSet<[P1, ...P2]>, + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<$json, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.multiplyCardinalitiesVariadic<$.cardinalityUtil.paramArrayCardinality<_.castMaps.mapLiteralToTypeSet>>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, 'Zero'>> +>; +type json_getλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends [_.castMaps.orScalarLiteral<$.TypeSet<$str>>, ..._.castMaps.orScalarLiteral<$.TypeSet<$str>>[]], +> = $.$expr_Function< + "std::json_get", + _.castMaps.mapLiteralToTypeSet<[P1, ...P2]>, + {}, + $.TypeSet<$json, $.cardinalityUtil.overrideLowerBound<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.multiplyCardinalitiesVariadic<$.cardinalityUtil.paramArrayCardinality<_.castMaps.mapLiteralToTypeSet>>>, 'Zero'>> +>; +/** + * Return the JSON value at the end of the specified path or an empty set. + */ +function json_get< + NamedArgs extends { + "default"?: _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends [_.castMaps.orScalarLiteral<$.TypeSet<$str>>, ..._.castMaps.orScalarLiteral<$.TypeSet<$str>>[]], +>( + namedArgs: NamedArgs, + json: P1, + ...path: P2 +): json_getλFuncExpr; +/** + * Return the JSON value at the end of the specified path or an empty set. + */ +function json_get< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends [_.castMaps.orScalarLiteral<$.TypeSet<$str>>, ..._.castMaps.orScalarLiteral<$.TypeSet<$str>>[]], +>( + json: P1, + ...path: P2 +): json_getλFuncExpr2; +function json_get(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::json_get', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: true}], namedArgs: {"default": {typeId: "00000000-0000-0000-0000-00000000010f", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-00000000010f", returnTypemod: "OptionalType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::json_get", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type re_matchλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::re_match", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$.ArrayType<$str>, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Find the first regular expression match in a string. + */ +function re_match< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + pattern: P1, + str: P2, +): re_matchλFuncExpr; +function re_match(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::re_match', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "05f91774-15ea-9001-038e-092c1cad80af"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::re_match", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type re_match_allλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::re_match_all", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$.ArrayType<$str>, $.Cardinality.Many> +>; +/** + * Find all regular expression matches in a string. + */ +function re_match_all< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + pattern: P1, + str: P2, +): re_match_allλFuncExpr; +function re_match_all(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::re_match_all', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "05f91774-15ea-9001-038e-092c1cad80af", returnTypemod: "SetOfType"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::re_match_all", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type re_testλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::re_test", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Test if a regular expression has a match in a string. + */ +function re_test< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + pattern: P1, + str: P2, +): re_testλFuncExpr; +function re_test(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::re_test', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::re_test", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type re_replaceλFuncExpr< + NamedArgs extends { + "flags"?: _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::re_replace", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type re_replaceλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::re_replace", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Replace matching substrings in a given string. + */ +function re_replace< + NamedArgs extends { + "flags"?: _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + }, + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + namedArgs: NamedArgs, + pattern: P1, + sub: P2, + str: P3, +): re_replaceλFuncExpr; +/** + * Replace matching substrings in a given string. + */ +function re_replace< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + pattern: P1, + sub: P2, + str: P3, +): re_replaceλFuncExpr2; +function re_replace(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::re_replace', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], namedArgs: {"flags": {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::re_replace", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_repeatλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::str_repeat", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Repeat the input *string* *n* times. + */ +function str_repeat< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + s: P1, + n: P2, +): str_repeatλFuncExpr; +function str_repeat(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_repeat', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_repeat", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_lowerλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::str_lower", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return a lowercase copy of the input *string*. + */ +function str_lower< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + s: P1, +): str_lowerλFuncExpr; +function str_lower(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_lower', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_lower", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_upperλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::str_upper", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return an uppercase copy of the input *string*. + */ +function str_upper< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + s: P1, +): str_upperλFuncExpr; +function str_upper(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_upper', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_upper", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_titleλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::str_title", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$str, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return a titlecase copy of the input *string*. + */ +function str_title< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + s: P1, +): str_titleλFuncExpr; +function str_title(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_title', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_title", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_pad_startλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_pad_start", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string padded at the start to the length *n*. + */ +function str_pad_start< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + n: P2, + fill?: P3, +): str_pad_startλFuncExpr; +function str_pad_start(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_pad_start', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_pad_start", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_lpadλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_lpad", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string left-padded to the length *n*. + */ +function str_lpad< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + n: P2, + fill?: P3, +): str_lpadλFuncExpr; +function str_lpad(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_lpad', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_lpad", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_pad_endλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_pad_end", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string padded at the end to the length *n*. + */ +function str_pad_end< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + n: P2, + fill?: P3, +): str_pad_endλFuncExpr; +function str_pad_end(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_pad_end', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_pad_end", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_rpadλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_rpad", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string right-padded to the length *n*. + */ +function str_rpad< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + n: P2, + fill?: P3, +): str_rpadλFuncExpr; +function str_rpad(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_rpad', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_rpad", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_trim_startλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_trim_start", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string with all *trim* characters removed from its start. + */ +function str_trim_start< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + tr?: P2, +): str_trim_startλFuncExpr; +function str_trim_start(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_trim_start', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_trim_start", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_ltrimλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_ltrim", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string with all leftmost *trim* characters removed. + */ +function str_ltrim< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + tr?: P2, +): str_ltrimλFuncExpr; +function str_ltrim(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_ltrim', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_ltrim", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_trim_endλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_trim_end", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string with all *trim* characters removed from its end. + */ +function str_trim_end< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + tr?: P2, +): str_trim_endλFuncExpr; +function str_trim_end(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_trim_end', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_trim_end", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_rtrimλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_rtrim", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string with all rightmost *trim* characters removed. + */ +function str_rtrim< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + tr?: P2, +): str_rtrimλFuncExpr; +function str_rtrim(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_rtrim', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_rtrim", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_trimλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::str_trim", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return the input string with *trim* characters removed from both ends. + */ +function str_trim< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + tr?: P2, +): str_trimλFuncExpr; +function str_trim(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_trim', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_trim", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type str_splitλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::str_split", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$.ArrayType<$str>, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** + * Split string into array elements using the supplied delimiter. + */ +function str_split< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + s: P1, + delimiter: P2, +): str_splitλFuncExpr; +function str_split(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::str_split', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "05f91774-15ea-9001-038e-092c1cad80af"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::str_split", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type uuid_generate_v1mcλFuncExpr = $.$expr_Function< + "std::uuid_generate_v1mc", + [], + {}, + $.TypeSet<$uuid, $.Cardinality.One> +>; +/** + * Return a version 1 UUID. + */ +function uuid_generate_v1mc(): uuid_generate_v1mcλFuncExpr; +function uuid_generate_v1mc(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::uuid_generate_v1mc', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-000000000100"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::uuid_generate_v1mc", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_strλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr4< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr5< + P1 extends $.TypeSet<$.ArrayType<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities["__cardinality__"]>> +>; +type to_strλFuncExpr6< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr7< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr8< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr9< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr10< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_strλFuncExpr11< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_str", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + dt: P1, + fmt?: P2, +): to_strλFuncExpr; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + td: P1, + fmt?: P2, +): to_strλFuncExpr2; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + i: P1, + fmt?: P2, +): to_strλFuncExpr3; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + d: P1, + fmt?: P2, +): to_strλFuncExpr4; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends $.TypeSet<$.ArrayType<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + array: P1, + delimiter: P2, +): to_strλFuncExpr5; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + json: P1, + fmt?: P2, +): to_strλFuncExpr6; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + dt: P1, + fmt?: P2, +): to_strλFuncExpr7; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + d: P1, + fmt?: P2, +): to_strλFuncExpr8; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + nt: P1, + fmt?: P2, +): to_strλFuncExpr9; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + rd: P1, + fmt?: P2, +): to_strλFuncExpr10; +/** + * Return string representation of the input value. + */ +function to_str< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + d: P1, + fmt?: P2, +): to_strλFuncExpr11; +function to_str(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_str', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "05f91774-15ea-9001-038e-092c1cad80af", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_str", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_jsonλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::to_json", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$json, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Return JSON value represented by the input *string*. + */ +function to_json< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + str: P1, +): to_jsonλFuncExpr; +function to_json(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_json', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010f"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_json", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_datetimeλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::to_datetime", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$datetime, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +type to_datetimeλFuncExpr2< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +type to_datetimeλFuncExpr3< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::to_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type to_datetimeλFuncExpr4< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P4 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P5 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P6 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P7 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +> = $.$expr_Function< + "std::to_datetime", + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3, P4, P5, P6, P7]>, + {}, + $.TypeSet<$datetime, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +type to_datetimeλFuncExpr5< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +> = $.$expr_Function< + "std::to_datetime", + _.castMaps.mapLiteralToTypeSet<[P1]>, + {}, + $.TypeSet<$datetime, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** + * Create a `datetime` value. + */ +function to_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + epochseconds: P1, +): to_datetimeλFuncExpr; +/** + * Create a `datetime` value. + */ +function to_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_datetimeλFuncExpr2; +/** + * Create a `datetime` value. + */ +function to_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + local: P1, + zone: P2, +): to_datetimeλFuncExpr3; +/** + * Create a `datetime` value. + */ +function to_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P4 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P5 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P6 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + P7 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, +>( + year: P1, + month: P2, + day: P3, + hour: P4, + min: P5, + sec: P6, + timezone: P7, +): to_datetimeλFuncExpr4; +/** + * Create a `datetime` value. + */ +function to_datetime< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$decimalλICastableTo>>, +>( + epochseconds: P1, +): to_datetimeλFuncExpr5; +function to_datetime(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_datetime', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_datetime", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_durationλFuncExpr< + NamedArgs extends { + "hours"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "minutes"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "seconds"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "microseconds"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + }, +> = $.$expr_Function< + "std::to_duration", + [], + _.castMaps.mapLiteralToTypeSet, + $.TypeSet<$duration, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `duration` value. + */ +function to_duration< + NamedArgs extends { + "hours"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "minutes"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "seconds"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + "microseconds"?: _.castMaps.orScalarLiteral<$.TypeSet<$number>>, + }, +>( + namedArgs: NamedArgs, +): to_durationλFuncExpr; +function to_duration(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_duration', args, _.spec, [ + {args: [], namedArgs: {"hours": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "minutes": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "seconds": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, "microseconds": {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}}, returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_duration", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_bigintλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_bigint", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `bigint` value. + */ +function to_bigint< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_bigintλFuncExpr; +function to_bigint(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_bigint', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_bigint", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_decimalλFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_decimal", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `decimal` value. + */ +function to_decimal< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_decimalλFuncExpr; +function to_decimal(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_decimal', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_decimal", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_int64λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_int64", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `int64` value. + */ +function to_int64< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_int64λFuncExpr; +function to_int64(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_int64', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_int64", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_int32λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_int32", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `int32` value. + */ +function to_int32< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_int32λFuncExpr; +function to_int32(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_int32', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_int32", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_int16λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_int16", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `int16` value. + */ +function to_int16< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_int16λFuncExpr; +function to_int16(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_int16', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_int16", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_float64λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_float64", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `float64` value. + */ +function to_float64< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_float64λFuncExpr; +function to_float64(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_float64', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_float64", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type to_float32λFuncExpr< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +> = $.$expr_Function< + "std::to_float32", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** + * Create a `float32` value. + */ +function to_float32< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$str>> | undefined, +>( + s: P1, + fmt?: P2, +): to_float32λFuncExpr; +function to_float32(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::to_float32', args, _.spec, [ + {args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::to_float32", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type sequence_resetλFuncExpr< + P1 extends $.TypeSet<_schema.$ScalarType>, +> = $.$expr_Function< + "std::sequence_reset", + [P1], + {}, + $.TypeSet<$number, P1["__cardinality__"]> +>; +type sequence_resetλFuncExpr2< + P1 extends $.TypeSet<_schema.$ScalarType>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +> = $.$expr_Function< + "std::sequence_reset", + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + {}, + $.TypeSet<$number, $.cardinalityUtil.multiplyCardinalities["__cardinality__"]>> +>; +function sequence_reset< + P1 extends $.TypeSet<_schema.$ScalarType>, +>( + seq: P1, +): sequence_resetλFuncExpr; +function sequence_reset< + P1 extends $.TypeSet<_schema.$ScalarType>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$number>>, +>( + seq: P1, + value: P2, +): sequence_resetλFuncExpr2; +function sequence_reset(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::sequence_reset', args, _.spec, [ + {args: [{typeId: "7f025b2e-77f8-11ec-be4f-f1dd71625fc0", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {args: [{typeId: "7f025b2e-77f8-11ec-be4f-f1dd71625fc0", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::sequence_reset", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type sequence_nextλFuncExpr< + P1 extends $.TypeSet<_schema.$ScalarType>, +> = $.$expr_Function< + "std::sequence_next", + [P1], + {}, + $.TypeSet<$number, P1["__cardinality__"]> +>; +function sequence_next< + P1 extends $.TypeSet<_schema.$ScalarType>, +>( + seq: P1, +): sequence_nextλFuncExpr; +function sequence_next(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('std::sequence_next', args, _.spec, [ + {args: [{typeId: "7f025b2e-77f8-11ec-be4f-f1dd71625fc0", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "std::sequence_next", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +export { $anyscalar, str, $anyreal, $anyfloat, $anyint, $anynumeric, bigint, bool, bytes, datetime, decimal, duration, float32, float64, int16, int32, int64, json, $sequence, uuid, number, $BaseObject, BaseObject, $Object_7b057b6477f811ec8deb1f5fc25e7818, Object_7b057b6477f811ec8deb1f5fc25e7818, $FreeObject, FreeObject }; + +type __defaultExports = { + "str": typeof str; + "bigint": typeof bigint; + "bool": typeof bool; + "bytes": typeof bytes; + "datetime": typeof datetime; + "decimal": typeof decimal; + "duration": typeof duration; + "float32": typeof float32; + "float64": typeof float64; + "int16": typeof int16; + "int32": typeof int32; + "int64": typeof int64; + "json": typeof json; + "uuid": typeof uuid; + "BaseObject": typeof BaseObject; + "Object": typeof Object_7b057b6477f811ec8deb1f5fc25e7818; + "FreeObject": typeof FreeObject; + "assert_single": typeof assert_single; + "assert_exists": typeof assert_exists; + "assert_distinct": typeof assert_distinct; + "len": typeof len; + "sum": typeof sum; + "count": typeof count; + "random": typeof random; + "min": typeof min; + "max": typeof max; + "all": typeof all; + "any": typeof any; + "enumerate": typeof enumerate; + "round": typeof round; + "contains": typeof contains; + "find": typeof find; + "array_agg": typeof array_agg; + "array_unpack": typeof array_unpack; + "array_get": typeof array_get; + "array_join": typeof array_join; + "bytes_get_bit": typeof bytes_get_bit; + "datetime_current": typeof datetime_current; + "datetime_of_transaction": typeof datetime_of_transaction; + "datetime_of_statement": typeof datetime_of_statement; + "datetime_get": typeof datetime_get; + "datetime_truncate": typeof datetime_truncate; + "duration_truncate": typeof duration_truncate; + "duration_to_seconds": typeof duration_to_seconds; + "json_typeof": typeof json_typeof; + "json_array_unpack": typeof json_array_unpack; + "json_object_unpack": typeof json_object_unpack; + "json_get": typeof json_get; + "re_match": typeof re_match; + "re_match_all": typeof re_match_all; + "re_test": typeof re_test; + "re_replace": typeof re_replace; + "str_repeat": typeof str_repeat; + "str_lower": typeof str_lower; + "str_upper": typeof str_upper; + "str_title": typeof str_title; + "str_pad_start": typeof str_pad_start; + "str_lpad": typeof str_lpad; + "str_pad_end": typeof str_pad_end; + "str_rpad": typeof str_rpad; + "str_trim_start": typeof str_trim_start; + "str_ltrim": typeof str_ltrim; + "str_trim_end": typeof str_trim_end; + "str_rtrim": typeof str_rtrim; + "str_trim": typeof str_trim; + "str_split": typeof str_split; + "uuid_generate_v1mc": typeof uuid_generate_v1mc; + "to_str": typeof to_str; + "to_json": typeof to_json; + "to_datetime": typeof to_datetime; + "to_duration": typeof to_duration; + "to_bigint": typeof to_bigint; + "to_decimal": typeof to_decimal; + "to_int64": typeof to_int64; + "to_int32": typeof to_int32; + "to_int16": typeof to_int16; + "to_float64": typeof to_float64; + "to_float32": typeof to_float32; + "sequence_reset": typeof sequence_reset; + "sequence_next": typeof sequence_next +}; +const __defaultExports: __defaultExports = { + "str": str, + "bigint": bigint, + "bool": bool, + "bytes": bytes, + "datetime": datetime, + "decimal": decimal, + "duration": duration, + "float32": float32, + "float64": float64, + "int16": int16, + "int32": int32, + "int64": int64, + "json": json, + "uuid": uuid, + "BaseObject": BaseObject, + "Object": Object_7b057b6477f811ec8deb1f5fc25e7818, + "FreeObject": FreeObject, + "assert_single": assert_single, + "assert_exists": assert_exists, + "assert_distinct": assert_distinct, + "len": len, + "sum": sum, + "count": count, + "random": random, + "min": min, + "max": max, + "all": all, + "any": any, + "enumerate": enumerate, + "round": round, + "contains": contains, + "find": find, + "array_agg": array_agg, + "array_unpack": array_unpack, + "array_get": array_get, + "array_join": array_join, + "bytes_get_bit": bytes_get_bit, + "datetime_current": datetime_current, + "datetime_of_transaction": datetime_of_transaction, + "datetime_of_statement": datetime_of_statement, + "datetime_get": datetime_get, + "datetime_truncate": datetime_truncate, + "duration_truncate": duration_truncate, + "duration_to_seconds": duration_to_seconds, + "json_typeof": json_typeof, + "json_array_unpack": json_array_unpack, + "json_object_unpack": json_object_unpack, + "json_get": json_get, + "re_match": re_match, + "re_match_all": re_match_all, + "re_test": re_test, + "re_replace": re_replace, + "str_repeat": str_repeat, + "str_lower": str_lower, + "str_upper": str_upper, + "str_title": str_title, + "str_pad_start": str_pad_start, + "str_lpad": str_lpad, + "str_pad_end": str_pad_end, + "str_rpad": str_rpad, + "str_trim_start": str_trim_start, + "str_ltrim": str_ltrim, + "str_trim_end": str_trim_end, + "str_rtrim": str_rtrim, + "str_trim": str_trim, + "str_split": str_split, + "uuid_generate_v1mc": uuid_generate_v1mc, + "to_str": to_str, + "to_json": to_json, + "to_datetime": to_datetime, + "to_duration": to_duration, + "to_bigint": to_bigint, + "to_decimal": to_decimal, + "to_int64": to_int64, + "to_int32": to_int32, + "to_int16": to_int16, + "to_float64": to_float64, + "to_float32": to_float32, + "sequence_reset": sequence_reset, + "sequence_next": sequence_next +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/modules/sys.ts b/qb/dbschema/edgeql-js/modules/sys.ts new file mode 100644 index 000000000..4692d560e --- /dev/null +++ b/qb/dbschema/edgeql-js/modules/sys.ts @@ -0,0 +1,186 @@ +import { $ } from "edgedb"; +import * as _ from "../imports"; +import * as _schema from "./schema"; +import * as _std from "./std"; +enum $TransactionIsolationλEnum { + RepeatableRead = "RepeatableRead", + Serializable = "Serializable", +} +export type $TransactionIsolation = typeof $TransactionIsolationλEnum & $.EnumType<"sys::TransactionIsolation", $TransactionIsolationλEnum, `${$TransactionIsolationλEnum}`>; +const TransactionIsolation: $TransactionIsolation = $.makeType<$TransactionIsolation>(_.spec, "82217b5a-77f8-11ec-a994-df90e972d7e9", _.syntax.literal); + +enum $VersionStageλEnum { + dev = "dev", + alpha = "alpha", + beta = "beta", + rc = "rc", + final = "final", +} +export type $VersionStage = typeof $VersionStageλEnum & $.EnumType<"sys::VersionStage", $VersionStageλEnum, `${$VersionStageλEnum}`>; +const VersionStage: $VersionStage = $.makeType<$VersionStage>(_.spec, "822250e8-77f8-11ec-892c-13df3f9f35ff", _.syntax.literal); + +export type $SystemObjectλShape = $.typeutil.flatten<_schema.$AnnotationSubjectλShape & { +}>; +type $SystemObject = $.ObjectType<"sys::SystemObject", $SystemObjectλShape, null>; +const $SystemObject = $.makeType<$SystemObject>(_.spec, "8223284c-77f8-11ec-af70-d734339fe825", _.syntax.literal); + +const SystemObject: $.$expr_PathNode<$.TypeSet<$SystemObject, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($SystemObject, $.Cardinality.Many), null, true); + +export type $DatabaseλShape = $.typeutil.flatten<$SystemObjectλShape & _schema.$AnnotationSubjectλShape & { + "name": $.PropertyDesc<_std.$str, $.Cardinality.One, true, true, false>; +}>; +type $Database = $.ObjectType<"sys::Database", $DatabaseλShape, null>; +const $Database = $.makeType<$Database>(_.spec, "824aae8a-77f8-11ec-aa7f-738eab5af57a", _.syntax.literal); + +const Database: $.$expr_PathNode<$.TypeSet<$Database, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Database, $.Cardinality.Many), null, true); + +export type $ExtensionPackageλShape = $.typeutil.flatten<$SystemObjectλShape & _schema.$AnnotationSubjectλShape & { + "script": $.PropertyDesc<_std.$str, $.Cardinality.One, false, true, false>; + "version": $.PropertyDesc<$.NamedTupleType<{major: _std.$int64, minor: _std.$int64, stage: $VersionStage, stage_no: _std.$int64, local: $.ArrayType<_std.$str>}>, $.Cardinality.One, false, true, false>; + "; + "; +}>; +type $ExtensionPackage = $.ObjectType<"sys::ExtensionPackage", $ExtensionPackageλShape, null>; +const $ExtensionPackage = $.makeType<$ExtensionPackage>(_.spec, "8277116e-77f8-11ec-9478-65dc78e5fa28", _.syntax.literal); + +const ExtensionPackage: $.$expr_PathNode<$.TypeSet<$ExtensionPackage, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($ExtensionPackage, $.Cardinality.Many), null, true); + +export type $RoleλShape = $.typeutil.flatten<$SystemObjectλShape & _schema.$InheritingObjectλShape & _schema.$AnnotationSubjectλShape & { + "member_of": $.LinkDesc<$Role, $.Cardinality.Many, {}, false, true, false>; + "superuser": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, true, false>; + "password": $.PropertyDesc<_std.$str, $.Cardinality.AtMostOne, false, true, false>; + "name": $.PropertyDesc<_std.$str, $.Cardinality.One, true, true, false>; + "is_superuser": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false>; + "; + "; +}>; +type $Role = $.ObjectType<"sys::Role", $RoleλShape, null>; +const $Role = $.makeType<$Role>(_.spec, "82b0b5b8-77f8-11ec-bd29-65c89aa3c892", _.syntax.literal); + +const Role: $.$expr_PathNode<$.TypeSet<$Role, $.Cardinality.Many>, null, true> = _.syntax.$PathNode($.$toSet($Role, $.Cardinality.Many), null, true); + +type get_versionλFuncExpr = $.$expr_Function< + "sys::get_version", + [], + {}, + $.TypeSet<$.NamedTupleType<{major: _std.$int64, minor: _std.$int64, stage: $VersionStage, stage_no: _std.$int64, local: $.ArrayType<_std.$str>}>, $.Cardinality.One> +>; +/** + * Return the server version as a tuple. + */ +function get_version(): get_versionλFuncExpr; +function get_version(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('sys::get_version', args, _.spec, [ + {args: [], returnTypeId: "66656800-544e-31af-103b-0bd99605f056"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "sys::get_version", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type get_version_as_strλFuncExpr = $.$expr_Function< + "sys::get_version_as_str", + [], + {}, + $.TypeSet<_std.$str, $.Cardinality.One> +>; +/** + * Return the server version as a string. + */ +function get_version_as_str(): get_version_as_strλFuncExpr; +function get_version_as_str(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('sys::get_version_as_str', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "sys::get_version_as_str", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type get_transaction_isolationλFuncExpr = $.$expr_Function< + "sys::get_transaction_isolation", + [], + {}, + $.TypeSet<$TransactionIsolation, $.Cardinality.One> +>; +/** + * Return the isolation level of the current transaction. + */ +function get_transaction_isolation(): get_transaction_isolationλFuncExpr; +function get_transaction_isolation(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('sys::get_transaction_isolation', args, _.spec, [ + {args: [], returnTypeId: "82217b5a-77f8-11ec-a994-df90e972d7e9"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "sys::get_transaction_isolation", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + +type get_current_databaseλFuncExpr = $.$expr_Function< + "sys::get_current_database", + [], + {}, + $.TypeSet<_std.$str, $.Cardinality.One> +>; +/** + * Return the name of the current database as a string. + */ +function get_current_database(): get_current_databaseλFuncExpr; +function get_current_database(...args: any[]) { + const {returnType, cardinality, args: positionalArgs, namedArgs} = _.syntax.$resolveOverload('sys::get_current_database', args, _.spec, [ + {args: [], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + ]); + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Function, + __element__: returnType, + __cardinality__: cardinality, + __name__: "sys::get_current_database", + __args__: positionalArgs, + __namedargs__: namedArgs, + }) as any; +}; + + + +export { $TransactionIsolationλEnum, TransactionIsolation, $VersionStageλEnum, VersionStage, $SystemObject, SystemObject, $Database, Database, $ExtensionPackage, ExtensionPackage, $Role, Role }; + +type __defaultExports = { + "TransactionIsolation": typeof TransactionIsolation; + "VersionStage": typeof VersionStage; + "SystemObject": typeof SystemObject; + "Database": typeof Database; + "ExtensionPackage": typeof ExtensionPackage; + "Role": typeof Role; + "get_version": typeof get_version; + "get_version_as_str": typeof get_version_as_str; + "get_transaction_isolation": typeof get_transaction_isolation; + "get_current_database": typeof get_current_database +}; +const __defaultExports: __defaultExports = { + "TransactionIsolation": TransactionIsolation, + "VersionStage": VersionStage, + "SystemObject": SystemObject, + "Database": Database, + "ExtensionPackage": ExtensionPackage, + "Role": Role, + "get_version": get_version, + "get_version_as_str": get_version_as_str, + "get_transaction_isolation": get_transaction_isolation, + "get_current_database": get_current_database +}; +export default __defaultExports; diff --git a/qb/dbschema/edgeql-js/operators.ts b/qb/dbschema/edgeql-js/operators.ts new file mode 100644 index 000000000..6fd7fdf7c --- /dev/null +++ b/qb/dbschema/edgeql-js/operators.ts @@ -0,0 +1,4218 @@ +import { $ } from "edgedb"; +import * as _ from "./imports"; +import * as _std from "./modules/std"; +import * as _cfg from "./modules/cfg"; +import * as _cal from "./modules/cal"; + +const overloadDefs: { + [opKind in 'Infix' | 'Prefix' | 'Postfix' | 'Ternary']: { + [opSymbol: string]: any[] + } +} = { + Infix: { + "=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "?=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: true, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: true, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: true, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}, {typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "!=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "?!=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: true, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: true, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: true, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}, {typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: true, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + ">=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + ">": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "<=": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "<": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000002", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}, {typeId: "73888fe8-77f8-11ec-9a80-4de755fc7ccd", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000100", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}, {typeId: "7afe0046-77f8-11ec-8427-71ef12be3838", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000130", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "73802e5c-77f8-11ec-bb71-d5cd789ef564", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "or": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "and": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "+": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000111"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000111"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "-": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010a", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010a"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010b", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010b"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010c", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010c"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010d", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010d"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000111"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000111"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "*": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "/": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "//": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "%": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "^": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "in": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "not in": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "union": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ], + "??": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: true, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ], + "++": [ + {kind: "Infix", args: [{typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}, {typeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3", optional: false, setoftype: false, variadic: false}], returnTypeId: "5d31584b-3a5f-533d-3d64-fab0fdab61b3"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000102", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000102"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000101"}, + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-00000000010f", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010f"}, + ], + "like": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "ilike": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "not like": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "not ilike": [ + {kind: "Infix", args: [{typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000101", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + }, + Postfix: { + }, + Prefix: { + "not": [ + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "+": [ + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "-": [ + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-0000000001ff", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-0000000001ff"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000110", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000110"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-00000000010e", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-00000000010e"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000111", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000111"}, + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000108", optional: false, setoftype: false, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000108"}, + ], + "exists": [ + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000109"}, + ], + "distinct": [ + {kind: "Prefix", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ], + }, + Ternary: { + "if_else": [ + {kind: "Ternary", args: [{typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000109", optional: false, setoftype: false, variadic: false}, {typeId: "00000000-0000-0000-0000-000000000001", optional: false, setoftype: true, variadic: false}], returnTypeId: "00000000-0000-0000-0000-000000000001", returnTypemod: "SetOfType"}, + ], + }, +}; + +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "=", r: P2 +): $.$expr_Operator< + "=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for equality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "?=", r: P2 +): $.$expr_Operator< + "?=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "!=", r: P2 +): $.$expr_Operator< + "!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality, $.cardinalityUtil.optionalParamCardinality>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Compare two (potentially empty) values for inequality. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "?!=", r: P2 +): $.$expr_Operator< + "?!=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>, $.cardinalityUtil.optionalParamCardinality<_.castMaps.literalToTypeSet>>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">=", r: P2 +): $.$expr_Operator< + ">=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Greater than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: ">", r: P2 +): $.$expr_Operator< + ">", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than or equal. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<=", r: P2 +): $.$expr_Operator< + "<=", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.EnumType>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$uuid>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cfg.$memory>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$anyint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Less than. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "<", r: P2 +): $.$expr_Operator< + "<", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Logical disjunction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + a: P1, op: "or", b: P2 +): $.$expr_Operator< + "or", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Logical conjunction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + a: P1, op: "and", b: P2 +): $.$expr_Operator< + "and", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Logical negation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, +>( + op: "not", v: P1 +): $.$expr_Operator< + "not", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$bool, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + op: "+", l: P1 +): $.$expr_Operator< + "+", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + op: "+", l: P1 +): $.$expr_Operator< + "+", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$bigint, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$relative_duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$relative_duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + op: "+", l: P1 +): $.$expr_Operator< + "+", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic addition. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "+", r: P2 +): $.$expr_Operator< + "+", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + op: "-", l: P1 +): $.$expr_Operator< + "-", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$number, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + op: "-", l: P1 +): $.$expr_Operator< + "-", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$bigint, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + op: "-", v: P1 +): $.$expr_Operator< + "-", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$duration, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + op: "-", v: P1 +): $.$expr_Operator< + "-", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_cal.$relative_duration, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_datetime>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_datetime, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_date>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_date, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$local_time>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$local_time, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$relative_duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Time interval and date/time subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$duration>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_cal.$relative_duration>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_cal.$relative_duration, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + op: "-", l: P1 +): $.$expr_Operator< + "-", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$decimal, _.castMaps.literalToTypeSet["__cardinality__"]> +>; +/** +* Arithmetic subtraction. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "-", r: P2 +): $.$expr_Operator< + "-", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic multiplication. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "*", r: P2 +): $.$expr_Operator< + "*", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic multiplication. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + l: P1, op: "*", r: P2 +): $.$expr_Operator< + "*", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic multiplication. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "*", r: P2 +): $.$expr_Operator< + "*", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic division. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + l: P1, op: "/", r: P2 +): $.$expr_Operator< + "/", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Arithmetic division. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + l: P1, op: "/", r: P2 +): $.$expr_Operator< + "/", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Floor division. Result is rounded down to the nearest integer +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + n: P1, op: "//", d: P2 +): $.$expr_Operator< + "//", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Floor division. Result is rounded down to the nearest integer +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + n: P1, op: "//", d: P2 +): $.$expr_Operator< + "//", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Floor division. Result is rounded down to the nearest integer +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + n: P1, op: "//", d: P2 +): $.$expr_Operator< + "//", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Remainder from division (modulo). +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + n: P1, op: "%", d: P2 +): $.$expr_Operator< + "%", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Remainder from division (modulo). +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + n: P1, op: "%", d: P2 +): $.$expr_Operator< + "%", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bigint, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Remainder from division (modulo). +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + n: P1, op: "%", d: P2 +): $.$expr_Operator< + "%", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Power operation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$number>>, +>( + n: P1, op: "^", p: P2 +): $.$expr_Operator< + "^", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$number, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Power operation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bigint>>, +>( + n: P1, op: "^", p: P2 +): $.$expr_Operator< + "^", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Power operation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$decimalλICastableTo>>, +>( + n: P1, op: "^", p: P2 +): $.$expr_Operator< + "^", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$decimal, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<_std.$decimalλICastableTo>, + P2 extends $.TypeSet<_std.$decimalλICastableTo>, +>( + e: P1, op: "in", s: P2 +): $.$expr_Operator< + "in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + e: P1, op: "in", s: P2 +): $.$expr_Operator< + "in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + e: P1, op: "in", s: P2 +): $.$expr_Operator< + "in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + e: P1, op: "in", s: P2 +): $.$expr_Operator< + "in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>>>, +>( + e: P1, op: "in", s: P2 +): $.$expr_Operator< + "in", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.Cardinality.One>> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<_std.$decimalλICastableTo>, + P2 extends $.TypeSet<_std.$decimalλICastableTo>, +>( + e: P1, op: "not in", s: P2 +): $.$expr_Operator< + "not in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + e: P1, op: "not in", s: P2 +): $.$expr_Operator< + "not in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + e: P1, op: "not in", s: P2 +): $.$expr_Operator< + "not in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + e: P1, op: "not in", s: P2 +): $.$expr_Operator< + "not in", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Test the membership of an element in a set. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>>>, +>( + e: P1, op: "not in", s: P2 +): $.$expr_Operator< + "not in", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], $.Cardinality.One>> +>; +/** +* Test whether a set is not empty. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + op: "exists", s: P1 +): $.$expr_Operator< + "exists", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<_std.$bool, $.Cardinality.One> +>; +/** +* Return a set without repeating any elements. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, +>( + op: "distinct", s: P1 +): $.$expr_Operator< + "distinct", + $.OperatorKind.Prefix, + _.castMaps.mapLiteralToTypeSet<[P1]>, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.Cardinality.Many> +>; +/** +* Merge two sets. +*/ +function op< + P1 extends $.TypeSet<_std.$decimalλICastableTo>, + P2 extends $.TypeSet<_std.$decimalλICastableTo>, +>( + s1: P1, op: "union", s2: P2 +): $.$expr_Operator< + "union", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Merge two sets. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + s1: P1, op: "union", s2: P2 +): $.$expr_Operator< + "union", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Merge two sets. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + s1: P1, op: "union", s2: P2 +): $.$expr_Operator< + "union", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.mergeObjectTypes, $.Cardinality.Many> +>; +/** +* Merge two sets. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + s1: P1, op: "union", s2: P2 +): $.$expr_Operator< + "union", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Merge two sets. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>>>, +>( + s1: P1, op: "union", s2: P2 +): $.$expr_Operator< + "union", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.Cardinality.Many> +>; +/** +* Coalesce. +*/ +function op< + P1 extends $.TypeSet<_std.$decimalλICastableTo>, + P2 extends $.TypeSet<_std.$decimalλICastableTo>, +>( + l: P1, op: "??", r: P2 +): $.$expr_Operator< + "??", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Coalesce. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "??", r: P2 +): $.$expr_Operator< + "??", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Coalesce. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends $.TypeSet<$.ObjectType>, +>( + l: P1, op: "??", r: P2 +): $.$expr_Operator< + "??", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.mergeObjectTypes, $.Cardinality.Many> +>; +/** +* Coalesce. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends $.TypeSet<$.AnyTupleType>, +>( + l: P1, op: "??", r: P2 +): $.$expr_Operator< + "??", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<_.syntax.getSharedParentPrimitive, $.Cardinality.Many> +>; +/** +* Coalesce. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>>>, +>( + l: P1, op: "??", r: P2 +): $.$expr_Operator< + "??", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.Cardinality.Many> +>; +/** +* Conditionally provide one or the other result. +*/ +function op< + P1 extends $.TypeSet<_std.$decimalλICastableTo>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P3 extends $.TypeSet<_std.$decimalλICastableTo>, +>( + if_true: P1, op: "if", condition: P2, op2: "else", if_false: P3 +): $.$expr_Operator< + "if_else", + $.OperatorKind.Ternary, + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + $.TypeSet<_.syntax.getSharedParentPrimitive, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.orCardinalities, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Conditionally provide one or the other result. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P3 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + if_true: P1, op: "if", condition: P2, op2: "else", if_false: P3 +): $.$expr_Operator< + "if_else", + $.OperatorKind.Ternary, + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + $.TypeSet<_.syntax.getSharedParentPrimitive, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.orCardinalities, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Conditionally provide one or the other result. +*/ +function op< + P1 extends $.TypeSet<$.ObjectType>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P3 extends $.TypeSet<$.ObjectType>, +>( + if_true: P1, op: "if", condition: P2, op2: "else", if_false: P3 +): $.$expr_Operator< + "if_else", + $.OperatorKind.Ternary, + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + $.TypeSet<_.syntax.mergeObjectTypes, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.orCardinalities, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Conditionally provide one or the other result. +*/ +function op< + P1 extends $.TypeSet<$.AnyTupleType>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P3 extends $.TypeSet<$.AnyTupleType>, +>( + if_true: P1, op: "if", condition: P2, op2: "else", if_false: P3 +): $.$expr_Operator< + "if_else", + $.OperatorKind.Ternary, + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + $.TypeSet<_.syntax.getSharedParentPrimitive, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.orCardinalities, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Conditionally provide one or the other result. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<$.BaseType>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bool>>, + P3 extends _.castMaps.orScalarLiteral<$.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>>>, +>( + if_true: P1, op: "if", condition: P2, op2: "else", if_false: P3 +): $.$expr_Operator< + "if_else", + $.OperatorKind.Ternary, + _.castMaps.mapLiteralToTypeSet<[P1, P2, P3]>, + $.TypeSet<$.getPrimitiveBaseType<_.castMaps.literalToTypeSet["__element__"]>, $.cardinalityUtil.multiplyCardinalities<$.cardinalityUtil.orCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>, _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Array concatenation. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, + P2 extends $.TypeSet<$.ArrayType<_std.$decimalλICastableTo>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<$.ArrayType<_.syntax.getSharedParentPrimitive>, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Array concatenation. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.ObjectType>>, + P2 extends $.TypeSet<$.ArrayType<$.ObjectType>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<$.ArrayType<_.syntax.mergeObjectTypes>, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Array concatenation. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, + P2 extends $.TypeSet<$.ArrayType<$.AnyTupleType>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<$.ArrayType<_.syntax.getSharedParentPrimitive>, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Array concatenation. +*/ +function op< + P1 extends $.TypeSet<$.ArrayType<$.NonArrayType>>, + P2 extends $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + [P1, P2], + $.TypeSet<$.ArrayType<$.getPrimitiveNonArrayBaseType>, $.cardinalityUtil.multiplyCardinalities> +>; +/** +* Bytes concatenation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$bytes>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bytes, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* String concatenation. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$str, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Concatenate two JSON values into a new JSON value. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$json>>, +>( + l: P1, op: "++", r: P2 +): $.$expr_Operator< + "++", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$json, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Case-sensitive simple string matching. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + string: P1, op: "like", pattern: P2 +): $.$expr_Operator< + "like", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Case-insensitive simple string matching. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + string: P1, op: "ilike", pattern: P2 +): $.$expr_Operator< + "ilike", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Case-sensitive simple string matching. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + string: P1, op: "not like", pattern: P2 +): $.$expr_Operator< + "not like", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +/** +* Case-insensitive simple string matching. +*/ +function op< + P1 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, + P2 extends _.castMaps.orScalarLiteral<$.TypeSet<_std.$str>>, +>( + string: P1, op: "not ilike", pattern: P2 +): $.$expr_Operator< + "not ilike", + $.OperatorKind.Infix, + _.castMaps.mapLiteralToTypeSet<[P1, P2]>, + $.TypeSet<_std.$bool, $.cardinalityUtil.multiplyCardinalities<_.castMaps.literalToTypeSet["__cardinality__"], _.castMaps.literalToTypeSet["__cardinality__"]>> +>; +function op(...args: any[]) { + let op: string = ""; + let params: any[] = []; + let defs: any[] | null = null; + if (args.length === 2) { + if (typeof args[0] === "string" && overloadDefs.Prefix[args[0]]) { + op = args[0]; + params = [args[1]]; + defs = overloadDefs.Prefix[op]; + } else if (typeof args[1] === "string" && overloadDefs.Postfix[args[1]]) { + op = args[1]; + params = [args[0]]; + defs = overloadDefs.Postfix[op]; + } + } else if (args.length === 3) { + if (typeof args[1] === "string") { + op = args[1]; + params = [args[0], args[2]]; + defs = overloadDefs.Infix[op]; + } + } else if (args.length === 5) { + if (typeof args[1] === "string" && typeof args[3] === "string") { + op = `${args[1]}_${args[3]}`; + params = [args[0], args[2], args[4]]; + defs = overloadDefs.Ternary[op]; + } + } + + if (!defs) { + throw new Error(`No operator exists with signature: ${args.map(arg => `${arg}`).join(", ")}`); + } + + const {kind, returnType, cardinality, args: resolvedArgs} = _.syntax.$resolveOverload(op, params, _.spec, defs); + + return _.syntax.$expressionify({ + __kind__: $.ExpressionKind.Operator, + __element__: returnType, + __cardinality__: cardinality, + __name__: op, + __opkind__: kind, + __args__: resolvedArgs, + }) as any; +}; + + +export { op }; diff --git a/qb/dbschema/edgeql-js/syntax/cast.ts b/qb/dbschema/edgeql-js/syntax/cast.ts new file mode 100644 index 000000000..845b1bd0c --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/cast.ts @@ -0,0 +1,38 @@ +import { + Expression, + ExpressionKind, + BaseType, + CastableNonArrayType, + CastableArrayType, + unwrapCastableType, + TypeSet, + Cardinality, +} from "edgedb/dist/reflection"; +import {$expressionify} from "./path"; + +export function cast( + target: Target, + arg: null +): $expr_Cast>; +export function cast< + Target extends CastableNonArrayType | CastableArrayType, + Expr extends TypeSet +>(target: Target, expr: Expr): $expr_Cast; +export function cast(target: BaseType, expr: any) { + return $expressionify({ + __element__: target, + __cardinality__: expr === null ? Cardinality.Empty : expr.__cardinality__, + __expr__: expr, + __kind__: ExpressionKind.Cast, + }) as any; +} + +export type $expr_Cast< + Target extends BaseType = BaseType, + Expr extends TypeSet = TypeSet +> = Expression<{ + __element__: unwrapCastableType; + __cardinality__: Expr["__cardinality__"]; + __kind__: ExpressionKind.Cast; + __expr__: Expr | null; +}>; diff --git a/qb/dbschema/edgeql-js/syntax/casting.ts b/qb/dbschema/edgeql-js/syntax/casting.ts new file mode 100644 index 000000000..781ecb3c9 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/casting.ts @@ -0,0 +1,121 @@ +import { + ArrayType, + BaseType, + BaseTypeTuple, + cardinalityUtil, + LinkDesc, + NamedTupleType, + ObjectType, + PropertyDesc, + ScalarType, + TupleType, + TypeSet, + typeutil, +} from "edgedb/dist/reflection"; +import { + scalarCastableFrom, + scalarAssignableBy, + orScalarLiteral, +} from "../castMaps"; + +export type anonymizeObject = ObjectType< + string, + T["__pointers__"], + any +>; + +//////////////// +// ASSIGNABLE +//////////////// + +type assignableTuple = { + [k in keyof Items]: Items[k] extends BaseType + ? assignableBy + : never; +} extends infer NewItems + ? NewItems extends BaseTypeTuple + ? NewItems + : never + : never; + +export type assignableBy = T extends ScalarType + ? scalarAssignableBy + : T extends ObjectType + ? anonymizeObject + : T extends ArrayType + ? ArrayType> + : T extends TupleType + ? TupleType> + : T extends NamedTupleType + ? NamedTupleType<{ + [k in keyof T["__shape__"]]: assignableBy; + }> + : never; + +export type pointerToAssignmentExpression< + Pointer extends PropertyDesc | LinkDesc +> = [Pointer] extends [PropertyDesc] + ? typeutil.flatten< + orScalarLiteral< + TypeSet< + assignableBy, + cardinalityUtil.assignable + > + > + > + : [Pointer] extends [LinkDesc] + ? TypeSet< + ObjectType< + // anonymize the object type + string, + Pointer["target"]["__pointers__"] + >, + cardinalityUtil.assignable + > + : never; + +//////////////// +// CASTABLES +//////////////// + +type castableTuple = { + [k in keyof Items]: Items[k] extends BaseType + ? castableFrom + : never; +} extends infer NewItems + ? NewItems extends BaseTypeTuple + ? NewItems + : never + : never; + +export type castableFrom = T extends ScalarType + ? scalarCastableFrom + : T extends ObjectType + ? anonymizeObject + : T extends ArrayType + ? ArrayType> + : T extends TupleType + ? TupleType> + : T extends NamedTupleType + ? NamedTupleType<{ + [k in keyof T["__shape__"]]: castableFrom; + }> + : never; + +export type pointerToCastableExpression< + Pointer extends PropertyDesc | LinkDesc +> = [Pointer] extends [PropertyDesc] + ? { + __element__: castableFrom; + __cardinality__: cardinalityUtil.assignable; + } + : [Pointer] extends [LinkDesc] + ? TypeSet< + ObjectType< + // anonymize the object type + string, + Pointer["target"]["__pointers__"] + >, + cardinalityUtil.assignable + > + : never; diff --git a/qb/dbschema/edgeql-js/syntax/collections.ts b/qb/dbschema/edgeql-js/syntax/collections.ts new file mode 100644 index 000000000..b40d9a86a --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/collections.ts @@ -0,0 +1,309 @@ +import { + $expr_Array, + $expr_NamedTuple, + $expr_Tuple, + $expr_TuplePath, + ArrayType, + BaseType, + Cardinality, + cardinalityUtil, + CastableNonArrayType, + ExpressionKind, + ExpressionRoot, + getPrimitiveBaseType, + NamedTupleLiteralShape, + NamedTupleShape, + NamedTupleType, + NonArrayType, + TupleType, + TypeKind, + TypeSet, + typeutil, +} from "edgedb/dist/reflection"; +import {$expressionify} from "./path"; +import {getCardsFromExprs} from "./set"; +import { + literalToScalarType, + literalToTypeSet, + mapLiteralToTypeSet, + orScalarLiteral, + scalarLiterals, +} from "../castMaps"; + +const indexSliceRegx = /^(-?\d+)(?:(:)(-?\d+)?)?|:(-?\d+)$/; + +const arrayLikeProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + const match = typeof prop === "string" ? prop.match(indexSliceRegx) : null; + if (match) { + const start = match[1]; + const end = match[3] ?? match[4]; + const isIndex = start && !match[2]; + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: + target.__element__.__kind__ === TypeKind.array && isIndex + ? (target.__element__ as ArrayType).__element__ + : target.__element__, + __cardinality__: target.__cardinality__, + __name__: "[]", + __opkind__: "Infix", + __args__: [ + proxy, + isIndex + ? literalToTypeSet(Number(start)) + : [ + start && literalToTypeSet(Number(start)), + end && literalToTypeSet(Number(end)), + ], + ], + }) as any; + } + return (target as any)[prop]; + }, +}; + +function arrayLikeIndex(this: ExpressionRoot, index: any) { + const indexTypeSet = literalToTypeSet(index); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: + this.__element__.__kind__ === TypeKind.array + ? (this.__element__ as ArrayType).__element__ + : this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + indexTypeSet.__cardinality__ + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, indexTypeSet], + }) as any; +} + +function arrayLikeSlice(this: ExpressionRoot, start: any, end: any) { + const startTypeSet = start && literalToTypeSet(start); + const endTypeSet = end && literalToTypeSet(end); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + startTypeSet?.__cardinality__ ?? Cardinality.One + ), + endTypeSet?.__cardinality__ ?? Cardinality.One + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, [startTypeSet, endTypeSet]], + }) as any; +} + +export function $arrayLikeIndexify(_expr: ExpressionRoot) { + if ( + _expr.__element__.__kind__ === TypeKind.array || + (_expr.__element__.__kind__ === TypeKind.scalar && + (_expr.__element__.__name__ === "std::str" || + _expr.__element__.__name__ === "std::bytes")) + ) { + const expr = new Proxy(_expr, arrayLikeProxyHandlers) as any; + + expr.index = arrayLikeIndex.bind(expr); + expr.slice = arrayLikeSlice.bind(expr); + + return expr; + } + + return _expr; +} + +// ARRAY +export function array( + element: Element +): ArrayType; +export function array< + Expr extends TypeSet | scalarLiterals, + Exprs extends orScalarLiteral< + TypeSet< + Expr extends TypeSet + ? getPrimitiveBaseType + : getPrimitiveBaseType> + > + >[] +>( + arg: [Expr, ...Exprs] +): $expr_Array< + ArrayType< + Expr extends TypeSet + ? getPrimitiveBaseType + : getPrimitiveBaseType> + >, + cardinalityUtil.multiplyCardinalitiesVariadic< + getCardsFromExprs> + > +>; +export function array(arg: any) { + if (Array.isArray(arg)) { + const items = arg.map(a => literalToTypeSet(a)); + return $expressionify({ + __kind__: ExpressionKind.Array, + __cardinality__: cardinalityUtil.multiplyCardinalitiesVariadic( + items.map(item => item.__cardinality__) as any + ), + __element__: { + __kind__: TypeKind.array, + __name__: `array<${items[0].__element__.__name__}>`, + __element__: items[0].__element__, + } as any, + __items__: items, + }); + } + if (arg.__kind__) { + return { + __kind__: TypeKind.array, + __name__: `array<${arg.__name__}>`, + __element__: arg, + } as any; + } + + throw new Error("Invalid array input."); +} + +// TUPLE + +const tupleProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + const type = target.__element__; + const items = + type.__kind__ === TypeKind.tuple + ? (type as TupleType).__items__ + : type.__kind__ === TypeKind.namedtuple + ? (type as NamedTupleType).__shape__ + : null; + return items?.hasOwnProperty(prop) + ? tuplePath(proxy, (items as any)[prop], prop as any) + : (target as any)[prop]; + }, +}; + +export function $tuplePathify(expr: ExpressionRoot) { + if ( + expr.__element__.__kind__ !== TypeKind.tuple && + expr.__element__.__kind__ !== TypeKind.namedtuple + ) { + return expr; + } + + return new Proxy(expr, tupleProxyHandlers); +} + +function tuplePath( + parent: $expr_Tuple | $expr_TuplePath, + itemType: BaseType, + index: string +): $expr_TuplePath { + return $expressionify({ + __kind__: ExpressionKind.TuplePath, + __element__: itemType, + __cardinality__: parent.__cardinality__, + __parent__: parent, + __index__: index, + }) as any; +} + +function makeTupleType(name: string, items: BaseType[]) { + return { + __kind__: TypeKind.tuple, + __name__: name, + __items__: items, + } as any; +} + +const typeKinds = new Set(Object.values(TypeKind)); + +export function tuple>( + items: Items +): TupleType; +export function tuple< + Item extends TypeSet | scalarLiterals, + Items extends typeutil.tupleOf +>( + items: Items +): $expr_Tuple< + Items extends typeutil.tupleOf ? mapLiteralToTypeSet : never +>; +export function tuple( + shape: Shape +): NamedTupleType; +export function tuple( + shape: Shape +): $expr_NamedTuple>; +export function tuple(input: any) { + if (Array.isArray(input)) { + // is tuple + if (input.every(item => typeKinds.has(item.__kind__))) { + const typeItems = input as BaseType[]; + const typeName = `tuple<${typeItems + .map(item => item.__name__) + .join(", ")}>`; + return makeTupleType(typeName, typeItems); + } + + const items = input.map(item => literalToTypeSet(item)); + const name = `tuple<${items + .map(item => item.__element__.__name__) + .join(", ")}>`; + return $expressionify({ + __kind__: ExpressionKind.Tuple, + __element__: makeTupleType( + name, + items.map(item => item.__element__) + ), + __cardinality__: cardinalityUtil.multiplyCardinalitiesVariadic( + items.map(i => i.__cardinality__) as any + ), + __items__: items, + }) as any; + } else { + // is named tuple + if (Object.values(input).every((el: any) => typeKinds.has(el.__kind__))) { + const typeName = `tuple<${Object.entries(input) + .map(([key, val]: [string, any]) => `${key}: ${val.__name__}`) + .join(", ")}>`; + return { + __kind__: TypeKind.namedtuple, + __name__: typeName, + __shape__: input, + } as any; + } + + const exprShape: NamedTupleLiteralShape = {}; + const typeShape: NamedTupleShape = {}; + for (const [key, val] of Object.entries(input)) { + exprShape[key] = literalToTypeSet(val); + typeShape[key] = exprShape[key].__element__; + } + const name = `tuple<${Object.entries(exprShape) + .map(([key, val]) => `${key}: ${val.__element__.__name__}`) + .join(", ")}>`; + return $expressionify({ + __kind__: ExpressionKind.NamedTuple, + __element__: { + __kind__: TypeKind.namedtuple, + __name__: name, + __shape__: typeShape, + } as any, + __cardinality__: cardinalityUtil.multiplyCardinalitiesVariadic( + Object.values(exprShape).map(val => val.__cardinality__) as any + ), + __shape__: exprShape, + }) as any; + } +} + +export type { + ArrayType as $Array, + NamedTupleType as $NamedTuple, + TupleType as $Tuple, +} from "edgedb/dist/reflection"; diff --git a/qb/dbschema/edgeql-js/syntax/detached.ts b/qb/dbschema/edgeql-js/syntax/detached.ts new file mode 100644 index 000000000..e0a7d2757 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/detached.ts @@ -0,0 +1,20 @@ +import {Expression, ExpressionKind, TypeSet} from "edgedb/dist/reflection"; +import {$expressionify} from "./path"; + +export function detached( + expr: Expr +): $expr_Detached { + return $expressionify({ + __element__: expr.__element__, + __cardinality__: expr.__cardinality__, + __expr__: expr, + __kind__: ExpressionKind.Detached, + }) as any; +} + +export type $expr_Detached = Expression<{ + __element__: Expr["__element__"]; + __cardinality__: Expr["__cardinality__"]; + __kind__: ExpressionKind.Detached; + __expr__: Expr; +}>; diff --git a/qb/dbschema/edgeql-js/syntax/for.ts b/qb/dbschema/edgeql-js/syntax/for.ts new file mode 100644 index 000000000..9499fc991 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/for.ts @@ -0,0 +1,57 @@ +import { + Expression, + BaseType, + BaseTypeSet, + Cardinality, + ExpressionKind, + cardinalityUtil, +} from "edgedb/dist/reflection"; +import {$expressionify} from "./path"; + +export type $expr_For< + IterSet extends BaseTypeSet = BaseTypeSet, + Expr extends Expression = Expression +> = Expression<{ + __element__: Expr["__element__"]; + __cardinality__: cardinalityUtil.multiplyCardinalities< + IterSet["__cardinality__"], + Expr["__cardinality__"] + >; + __kind__: ExpressionKind.For; + __iterSet__: IterSet; + __forVar__: $expr_ForVar; + __expr__: Expr; +}>; + +export type $expr_ForVar = Expression<{ + __element__: Type; + __cardinality__: Cardinality.One; + __kind__: ExpressionKind.ForVar; +}>; + +function _for( + set: IteratorSet, + expr: (variable: $expr_ForVar) => Expr +): $expr_For { + const forVar = $expressionify({ + __kind__: ExpressionKind.ForVar, + __element__: set.__element__, + __cardinality__: Cardinality.One, + }) as $expr_ForVar; + + const returnExpr = expr(forVar); + + return $expressionify({ + __kind__: ExpressionKind.For, + __element__: returnExpr.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + set.__cardinality__, + returnExpr.__cardinality__ + ), + __iterSet__: set, + __expr__: returnExpr, + __forVar__: forVar, + }) as any; +} + +export {_for as for}; diff --git a/qb/dbschema/edgeql-js/syntax/funcops.ts b/qb/dbschema/edgeql-js/syntax/funcops.ts new file mode 100644 index 000000000..68c1cdcca --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/funcops.ts @@ -0,0 +1,323 @@ +import { + BaseType, + BaseTypeSet, + Cardinality, + introspect, + makeType, + TypeKind, + ArrayType, + cardinalityUtil, + ObjectType, + TypeSet, +} from "edgedb/dist/reflection"; +import {cast} from "./cast"; +import {isImplicitlyCastableTo, literalToTypeSet} from "../castMaps"; +import {literal} from "./literal"; + +interface OverloadFuncArgDef { + typeId: string; + optional?: boolean; + setoftype?: boolean; + variadic?: boolean; +} + +interface OverloadFuncDef { + kind?: string; + args: OverloadFuncArgDef[]; + namedArgs?: {[key: string]: OverloadFuncArgDef}; + returnTypeId: string; + returnTypemod?: "SetOfType" | "OptionalType"; + preservesOptionality?: boolean; +} + +function mapLiteralToTypeSet(literals: any[]): TypeSet[]; +function mapLiteralToTypeSet(literals: {[key: string]: any}): { + [key: string]: TypeSet; +}; +function mapLiteralToTypeSet(literals: any[] | {[key: string]: any}) { + if (Array.isArray(literals)) { + return literals.map(lit => (lit != null ? literalToTypeSet(lit) : lit)); + } + const obj: {[key: string]: TypeSet} = {}; + for (const key of Object.keys(literals)) { + obj[key] = + literals[key] != null ? literalToTypeSet(literals[key]) : literals[key]; + } + return obj; +} + +export function $resolveOverload( + funcName: string, + args: any[], + typeSpec: introspect.Types, + funcDefs: OverloadFuncDef[] +) { + const [positionalArgs, namedArgs] = + typeof args[0] === "object" && typeof args[0].__kind__ === "undefined" + ? [ + mapLiteralToTypeSet(args.slice(1)), + mapLiteralToTypeSet(args[0] as object), + ] + : [mapLiteralToTypeSet(args), undefined]; + + for (const def of funcDefs) { + const resolvedOverload = _tryOverload( + funcName, + positionalArgs, + namedArgs, + typeSpec, + def + ); + if (resolvedOverload !== null) { + return resolvedOverload; + } + } + throw new Error( + `No function overload found for ${ + funcName.includes("::") + ? `'e.${funcName.split("::")[1]}()'` + : `operator '${funcName}'` + } with args: ${args.map(arg => `${arg}`).join(", ")}` + ); +} + +function _tryOverload( + funcName: string, + args: (BaseTypeSet | undefined)[], + namedArgs: {[key: string]: BaseTypeSet} | undefined, + typeSpec: introspect.Types, + funcDef: OverloadFuncDef +): { + kind?: string; + returnType: BaseType; + cardinality: Cardinality; + args: BaseTypeSet[]; + namedArgs: {[key: string]: BaseTypeSet}; +} | null { + if ( + (funcDef.namedArgs === undefined && namedArgs !== undefined) || + (namedArgs === undefined && + funcDef.namedArgs && + Object.values(funcDef.namedArgs).some(arg => !arg.optional)) + ) { + return null; + } + + const lastParamVariadic = funcDef.args[funcDef.args.length - 1]?.variadic; + if (!lastParamVariadic && args.length > funcDef.args.length) { + return null; + } + + const paramCardinalities: [Cardinality, ...Cardinality[]] = [ + Cardinality.One, + ]; + + if (namedArgs) { + for (const [key, value] of Object.entries(namedArgs)) { + const argDef = funcDef.namedArgs?.[key]; + if ( + !argDef || + !compareType(typeSpec, argDef.typeId, value.__element__).match + ) { + return null; + } + + paramCardinalities.push( + argDef.setoftype + ? funcDef.preservesOptionality + ? cardinalityUtil.overrideUpperBound(value.__cardinality__, "One") + : Cardinality.One + : argDef.optional + ? cardinalityUtil.overrideLowerBound(value.__cardinality__, "One") + : value.__cardinality__ + ); + } + } + + const positionalArgs: BaseTypeSet[] = []; + + let returnAnytype: BaseType | undefined; + + for (let i = 0; i < funcDef.args.length; i++) { + const argDef = funcDef.args[i]; + const arg = args[i]; + + if (arg === undefined) { + if (!argDef.optional) { + return null; + } + + if (i < args.length) { + // arg is explicitly undefined, inject empty set + const argType = makeType(typeSpec, argDef.typeId, literal); + positionalArgs.push(cast(argType, null)); + } + } else { + const {match, anytype} = compareType( + typeSpec, + argDef.typeId, + arg.__element__ + ); + + if (!match) { + return null; + } + if (!returnAnytype && anytype) { + returnAnytype = anytype; + } + + positionalArgs.push( + ...(argDef.variadic ? (args.slice(i) as BaseTypeSet[]) : [arg]) + ); + if (argDef.setoftype) { + paramCardinalities.push( + funcDef.preservesOptionality + ? cardinalityUtil.overrideUpperBound(arg.__cardinality__, "One") + : Cardinality.One + ); + } else { + const card = argDef.variadic + ? cardinalityUtil.multiplyCardinalitiesVariadic( + (args.slice(i) as BaseTypeSet[]).map( + el => el.__cardinality__ + ) as [Cardinality, ...Cardinality[]] + ) + : arg.__cardinality__; + + paramCardinalities.push( + argDef.optional + ? cardinalityUtil.overrideLowerBound(card, "One") + : card + ); + } + } + } + + let cardinality: Cardinality; + if (funcName === "if_else") { + cardinality = cardinalityUtil.multiplyCardinalities( + cardinalityUtil.orCardinalities( + positionalArgs[0].__cardinality__, + positionalArgs[2].__cardinality__ + ), + positionalArgs[1].__cardinality__ + ); + } else if (funcName === "std::assert_exists") { + cardinality = cardinalityUtil.overrideLowerBound( + positionalArgs[0].__cardinality__, + "One" + ); + } else { + cardinality = + funcDef.returnTypemod === "SetOfType" + ? Cardinality.Many + : cardinalityUtil.multiplyCardinalitiesVariadic(paramCardinalities); + + if ( + funcDef.returnTypemod === "OptionalType" && + !funcDef.preservesOptionality + ) { + cardinality = cardinalityUtil.overrideLowerBound(cardinality, "Zero"); + } + } + + return { + kind: funcDef.kind, + returnType: makeType( + typeSpec, + funcDef.returnTypeId, + literal, + returnAnytype + ), + cardinality, + args: positionalArgs, + namedArgs: namedArgs ?? {}, + }; +} + +function compareType( + typeSpec: introspect.Types, + typeId: string, + arg: BaseType +): {match: boolean; anytype?: BaseType} { + const type = typeSpec.get(typeId); + + if (type.name === "anytype") { + return {match: true, anytype: arg}; + } + + if (type.kind === "scalar") { + arg = (arg as any).__casttype__ ?? arg; + return { + match: + arg.__kind__ === TypeKind.scalar && + (arg.__name__ === type.name || + isImplicitlyCastableTo(arg.__name__, type.name)), + }; + } + if (type.kind === "array") { + if (arg.__kind__ === TypeKind.array) { + return compareType( + typeSpec, + type.array_element_id, + (arg as any as ArrayType).__element__ as BaseType + ); + } + } + if (type.kind === "object") { + if (arg.__kind__ !== TypeKind.object) return {match: false}; + + const objectArg = arg as ObjectType; + let match = true; + + // shape comparison + for (const ptr of type.pointers) { + if (objectArg.__pointers__[ptr.name]) { + const argPtr = objectArg.__pointers__[ptr.name]; + const ptrTarget = typeSpec.get(ptr.target_id); + if ( + ptrTarget.name !== argPtr.target.__name__ || + ptr.real_cardinality !== argPtr.cardinality + ) { + match = false; + } + } + } + + return { + match, + }; + } + if (type.kind === "tuple") { + const items = + arg.__kind__ === TypeKind.tuple + ? (arg as any).__items__ + : arg.__kind__ === TypeKind.namedtuple + ? (arg as any).__shape__ + : null; + if (items) { + const keys = Object.keys(items); + + if (keys.length === type.tuple_elements.length) { + let anytype: BaseType | undefined; + for (let i = 0; i < keys.length; i++) { + if (keys[i] !== type.tuple_elements[i].name) { + return {match: false}; + } + const {match: m, anytype: a} = compareType( + typeSpec, + type.tuple_elements[i].target_id, + (items as any)[keys[i]] + ); + if (!m) { + return {match: false}; + } + if (a) anytype = a; + } + return {match: true, anytype}; + } + } + } + + return {match: false}; +} diff --git a/qb/dbschema/edgeql-js/syntax/insert.ts b/qb/dbschema/edgeql-js/syntax/insert.ts new file mode 100644 index 000000000..d7b47b3c6 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/insert.ts @@ -0,0 +1,190 @@ +import { + Cardinality, + Expression, + ExpressionKind, + LinkDesc, + ObjectTypeSet, + ObjectTypePointers, + PropertyDesc, + stripBacklinks, + stripNonWritables, + typeutil, + $scopify, + stripSet, + TypeSet, + ScalarType, + scalarTypeWithConstructor, +} from "edgedb/dist/reflection"; +import type {pointerToAssignmentExpression} from "./casting"; +import {$expressionify, $getScopedExpr} from "./path"; +import {cast} from "./cast"; +import {$expr_PathNode} from "edgedb/dist/reflection/path"; + +export type pointerIsOptional = + T["cardinality"] extends + | Cardinality.Many + | Cardinality.Empty + | Cardinality.AtMostOne + ? true + : false; + +export type InsertShape = typeutil.stripNever< + stripNonWritables> +> extends infer Shape + ? Shape extends ObjectTypePointers + ? typeutil.addQuestionMarks<{ + [k in keyof Shape]: + | pointerToAssignmentExpression + | (pointerIsOptional extends true + ? undefined | null + : never) + | (Shape[k]["hasDefault"] extends true ? undefined : never); + }> + : never + : never; + +interface UnlessConflict { + on: TypeSet | null; + else?: TypeSet; +} + +type InsertBaseExpression = { + __kind__: ExpressionKind.Insert; + __element__: Root["__element__"]; + __cardinality__: Cardinality.One; + __expr__: stripSet; + __shape__: any; +}; +export type $expr_Insert< + Root extends $expr_PathNode = $expr_PathNode + // Conflict = UnlessConflict | null + // Shape extends InsertShape = any +> = Expression<{ + __kind__: ExpressionKind.Insert; + __element__: Root["__element__"]; + __cardinality__: Cardinality.One; + __expr__: Root; + __shape__: InsertShape; + + unlessConflict(): $expr_InsertUnlessConflict< + Expression<{ + __kind__: ExpressionKind.Insert; + __element__: Root["__element__"]; + __cardinality__: Cardinality.One; + __expr__: Root; + __shape__: InsertShape; + }>, + {on: null} + >; + unlessConflict( + conflictGetter: (scope: $scopify) => Conflict + ): $expr_InsertUnlessConflict< + Expression<{ + __kind__: ExpressionKind.Insert; + __element__: Root["__element__"]; + __cardinality__: Cardinality.One; + __expr__: Root; + __shape__: InsertShape; + }>, + Conflict + >; +}>; + +export type $expr_InsertUnlessConflict< + Root extends InsertBaseExpression = InsertBaseExpression, + Conflict extends UnlessConflict = UnlessConflict +> = Expression<{ + __kind__: ExpressionKind.InsertUnlessConflict; + __element__: Root["__element__"]; + __cardinality__: Cardinality.One; + __expr__: Root; + __conflict__: Conflict; +}>; + +function unlessConflict( + this: $expr_Insert, + conflictGetter?: (scope: TypeSet) => UnlessConflict +) { + const expr: any = { + __kind__: ExpressionKind.InsertUnlessConflict, + __element__: this.__element__, + __cardinality__: Cardinality.One, + __expr__: this, + // __conflict__: Conflict; + }; + + if (!conflictGetter) { + expr.__conflict__ = {on: null}; + return $expressionify(expr); + } else { + const scopedExpr = $getScopedExpr(this.__expr__); + expr.__conflict__ = conflictGetter(scopedExpr); + return $expressionify(expr); + } +} + +export function $insertify( + expr: Omit<$expr_Insert, "unlessConflict"> +): $expr_Insert { + (expr as any).unlessConflict = unlessConflict.bind(expr as any); + return expr as any; +} + +export function $normaliseInsertShape( + root: ObjectTypeSet, + shape: {[key: string]: any}, + isUpdate: boolean = false +): {[key: string]: TypeSet | {"+=": TypeSet} | {"-=": TypeSet}} { + const newShape: { + [key: string]: TypeSet | {"+=": TypeSet} | {"-=": TypeSet}; + } = {}; + for (const [key, _val] of Object.entries(shape)) { + let val = _val; + let setModify: string | null = null; + if (isUpdate && _val != null && typeof _val === "object") { + const valKeys = Object.keys(_val); + if ( + valKeys.length === 1 && + (valKeys[0] === "+=" || valKeys[0] === "-=") + ) { + val = _val[valKeys[0]]; + setModify = valKeys[0]; + } + } + if (val?.__kind__ || val === undefined) { + newShape[key] = _val; + } else { + const pointer = root.__element__.__pointers__[key]; + if (!pointer || (pointer.__kind__ !== "property" && val !== null)) { + throw new Error( + `Could not find property pointer for ${ + isUpdate ? "update" : "insert" + } shape key: '${key}'` + ); + } + const wrappedVal = + val === null + ? cast(pointer.target, null) + : (pointer.target as scalarTypeWithConstructor)(val); + newShape[key] = setModify + ? ({[setModify]: wrappedVal} as any) + : wrappedVal; + } + } + return newShape; +} + +export function insert( + root: Root, + shape: InsertShape +): $expr_Insert { + const expr: any = { + __kind__: ExpressionKind.Insert, + __element__: root.__element__, + __cardinality__: Cardinality.One, + __expr__: root, + __shape__: $normaliseInsertShape(root, shape), + }; + (expr as any).unlessConflict = unlessConflict.bind(expr); + return $expressionify($insertify(expr)) as any; +} diff --git a/qb/dbschema/edgeql-js/syntax/literal.ts b/qb/dbschema/edgeql-js/syntax/literal.ts new file mode 100644 index 000000000..3f687f382 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/literal.ts @@ -0,0 +1,38 @@ +import { + Cardinality, + ExpressionKind, + BaseType, + BaseTypeToTsType, + unwrapCastableType, + makeType, + ScalarType, +} from "edgedb/dist/reflection"; +import {$expr_Literal} from "edgedb/dist/reflection/literal"; +import {$expressionify} from "./path"; +import {spec} from "../__spec__"; + +export function literal( + type: T, + value: BaseTypeToTsType> +): $expr_Literal> { + return $expressionify({ + __element__: type, + __cardinality__: Cardinality.One, + __kind__: ExpressionKind.Literal, + __value__: value, + }) as any; +} + +const nameMapping = new Map([ + ["std::number", "00000000-0000-0000-0000-0000000001ff"], +]); + +export function $getType(id: string): (val: any) => $expr_Literal { + return makeType(spec, id, literal) as any; +} + +export function $getTypeByName( + name: string +): (val: any) => $expr_Literal { + return makeType(spec, nameMapping.get(name)!, literal) as any; +} diff --git a/qb/dbschema/edgeql-js/syntax/params.ts b/qb/dbschema/edgeql-js/syntax/params.ts new file mode 100644 index 000000000..d419f534f --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/params.ts @@ -0,0 +1,224 @@ +import type {Executor} from "edgedb"; +import { + Expression, + ExpressionKind, + ParamType, + Cardinality, + setToTsType, + TypeSet, + unwrapCastableType, + TypeKind, + BaseTypeToTsType, +} from "edgedb/dist/reflection"; +import {$expressionify} from "./path"; + +export type $expr_OptionalParam = { + __kind__: ExpressionKind.OptionalParam; + __type__: Type; +}; + +export function optional( + type: Type +): $expr_OptionalParam { + return { + __kind__: ExpressionKind.OptionalParam, + __type__: type, + }; +} + +export type QueryableWithParamsExpression< + Set extends TypeSet = TypeSet, + Params extends { + [key: string]: ParamType | $expr_OptionalParam; + } = {} +> = Expression & { + run( + cxn: Executor, + args: paramsToParamArgs + ): Promise>; +}; + +export type $expr_WithParams< + Params extends { + [key: string]: ParamType | $expr_OptionalParam; + } = {}, + Expr extends Expression = Expression +> = QueryableWithParamsExpression< + { + __kind__: ExpressionKind.WithParams; + __element__: Expr["__element__"]; + __cardinality__: Expr["__cardinality__"]; + __expr__: Expr; + __params__: $expr_Param[]; + }, + Params +>; + +type paramsToParamArgs< + Params extends { + [key: string]: ParamType | $expr_OptionalParam; + } +> = { + [key in keyof Params as Params[key] extends ParamType + ? key + : never]: Params[key] extends ParamType + ? BaseTypeToTsType + : never; +} & { + [key in keyof Params as Params[key] extends $expr_OptionalParam + ? key + : never]?: Params[key] extends $expr_OptionalParam + ? BaseTypeToTsType | null + : never; +}; + +export type $expr_Param< + Name extends string | number | symbol = string, + Type extends ParamType = ParamType, + Optional extends boolean = boolean +> = Expression<{ + __kind__: ExpressionKind.Param; + __element__: unwrapCastableType; + __cardinality__: Optional extends true + ? Cardinality.AtMostOne + : Cardinality.One; + __name__: Name; + __isComplex__: boolean; +}>; + +type paramsToParamExprs< + Params extends { + [key: string]: ParamType | $expr_OptionalParam; + } +> = { + [key in keyof Params]: Params[key] extends $expr_OptionalParam + ? $expr_Param + : Params[key] extends ParamType + ? $expr_Param + : never; +}; + +const complexParamKinds = new Set([TypeKind.tuple, TypeKind.namedtuple]); + +export function params< + Params extends { + [key: string]: ParamType | $expr_OptionalParam; + } = {}, + Expr extends Expression = Expression +>( + paramsDef: Params, + expr: (params: paramsToParamExprs) => Expr +): $expr_WithParams { + const paramExprs: {[key: string]: $expr_Param} = {}; + for (const [key, param] of Object.entries(paramsDef)) { + const paramType = + param.__kind__ === ExpressionKind.OptionalParam ? param.__type__ : param; + const isComplex = + complexParamKinds.has(paramType.__kind__) || + (paramType.__kind__ === TypeKind.array && + complexParamKinds.has(paramType.__element__.__kind__)); + paramExprs[key] = $expressionify({ + __kind__: ExpressionKind.Param, + __element__: paramType, + __cardinality__: + param.__kind__ === ExpressionKind.OptionalParam + ? Cardinality.AtMostOne + : Cardinality.One, + __name__: key, + __isComplex__: isComplex, + }) as any; + } + + const returnExpr = expr(paramExprs as any); + + return $expressionify({ + __kind__: ExpressionKind.WithParams, + __element__: returnExpr.__element__, + __cardinality__: returnExpr.__cardinality__, + __expr__: returnExpr, + __params__: Object.values(paramExprs), + }) as any; +} + +function jsonStringify(type: ParamType, val: any): string { + if (type.__kind__ === TypeKind.array) { + if (Array.isArray(val)) { + return `[${val + .map(item => jsonStringify(type.__element__, item)) + .join()}]`; + } + throw new Error(`Param with array type is not an array`); + } + if (type.__kind__ === TypeKind.tuple) { + if (!Array.isArray(val)) { + throw new Error(`Param with tuple type is not an array`); + } + if (val.length !== type.__items__.length) { + throw new Error( + `Param with tuple type has incorrect number of items. Got ${val.length} expected ${type.__items__.length}` + ); + } + return `[${val + .map((item, i) => jsonStringify(type.__items__[i], item)) + .join()}]`; + } + if (type.__kind__ === TypeKind.namedtuple) { + if (typeof val !== "object") { + throw new Error(`Param with named tuple type is not an object`); + } + if (Object.keys(val).length !== Object.keys(type.__shape__).length) { + throw new Error( + `Param with named tuple type has incorrect number of items. Got ${ + Object.keys(val).length + } expected ${Object.keys(type.__shape__).length}` + ); + } + return `{${Object.entries(val) + .map(([key, item]) => { + if (!type.__shape__[key]) { + throw new Error( + `Unexpected key in named tuple param: ${key}, expected keys: ${Object.keys( + type.__shape__ + ).join()}` + ); + } + return `"${key}": ${jsonStringify(type.__shape__[key], item)}`; + }) + .join()}}`; + } + if ( + type.__kind__ === TypeKind.scalar + // || type.__kind__ === TypeKind.castonlyscalar + ) { + switch (type.__name__) { + case "std::bigint": + return val.toString(); + case "std::json": + return val; + case "std::bytes": + return `"${val.toString("base64")}"`; + case "cfg::memory": + return `"${val.toString()}"`; + default: + return JSON.stringify(val); + } + } + throw new Error(`Invalid param type: ${(type as any).__kind__}`); +} + +export function jsonifyComplexParams(expr: any, _args: any) { + if (_args && expr.__kind__ === ExpressionKind.WithParams) { + const args = {..._args}; + for (const param of (expr as $expr_WithParams).__params__) { + if (param.__isComplex__) { + args[param.__name__] = jsonStringify( + param.__element__ as any, + args[param.__name__] + ); + } + } + + return args; + } + return _args; +} diff --git a/qb/dbschema/edgeql-js/syntax/path.ts b/qb/dbschema/edgeql-js/syntax/path.ts new file mode 100644 index 000000000..45bb1cfb2 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/path.ts @@ -0,0 +1,244 @@ +import { + cardinalityUtil, + ObjectTypeSet, + TypeSet, + Expression, + ExpressionKind, + TypeKind, + LinkDesc, + PropertyDesc, + Cardinality, +} from "edgedb/dist/reflection"; +import { + PathParent, + $expr_PathLeaf, + $expr_PathNode, + $pathify, + ExpressionRoot, +} from "edgedb/dist/reflection/path"; +import {$arrayLikeIndexify, $tuplePathify} from "./collections"; +import {literalToTypeSet} from "../castMaps"; +import {$toEdgeQL} from "./toEdgeQL"; +import {$queryFunc} from "./query"; + +function PathLeaf< + Root extends TypeSet, + Parent extends PathParent, + Exclusive extends boolean = boolean +>( + root: Root, + parent: Parent, + exclusive: Exclusive, + scopeRoot: TypeSet | null = null +): $expr_PathLeaf { + return $expressionify({ + __kind__: ExpressionKind.PathLeaf, + __element__: root.__element__, + __cardinality__: root.__cardinality__, + __parent__: parent, + __exclusive__: exclusive, + __scopeRoot__: scopeRoot, + }) as any; +} + +function PathNode< + Root extends ObjectTypeSet, + Parent extends PathParent | null, + Exclusive extends boolean = boolean +>( + root: Root, + parent: Parent, + exclusive: Exclusive, + scopeRoot: TypeSet | null = null +): $expr_PathNode { + return $expressionify({ + __kind__: ExpressionKind.PathNode, + __element__: root.__element__, + __cardinality__: root.__cardinality__, + __parent__: parent, + __exclusive__: exclusive, + __scopeRoot__: scopeRoot, + }) as any; +} + +const _pathCache = Symbol(); +const _pointers = Symbol(); + +const pathifyProxyHandlers: ProxyHandler = { + get(target: any, prop: string | symbol, proxy: any) { + const ptr = target[_pointers][prop as any] as LinkDesc | PropertyDesc; + if (ptr) { + return ( + target[_pathCache][prop] ?? + (target[_pathCache][prop] = ( + (ptr.__kind__ === "property" ? PathLeaf : PathNode) as any + )( + { + __element__: ptr.target, + __cardinality__: cardinalityUtil.multiplyCardinalities( + target.__cardinality__, + ptr.cardinality + ), + }, + { + linkName: prop, + type: proxy, + }, + ptr.exclusive ?? false, + target.__scopeRoot__ ?? (scopeRoots.has(proxy) ? proxy : null) + )) + ); + } + return target[prop]; + }, +}; + +function _$pathify( + _root: Root +): $pathify { + if (_root.__element__.__kind__ !== TypeKind.object) { + return _root as any; + } + + const root: $expr_PathNode = _root as any; + + let pointers = { + ...root.__element__.__pointers__, + }; + + if (root.__parent__) { + const {type, linkName} = root.__parent__; + const parentPointer = type.__element__.__pointers__[linkName]; + if (parentPointer?.__kind__ === "link") { + pointers = {...pointers, ...parentPointer.properties}; + } + } + + for (const [key, val] of Object.entries(root.__element__.__shape__)) { + if ((val as any)?.__element__ && !pointers[key]) { + pointers[key] = { + __kind__: "property", + target: (val as any).__element__, + cardinality: (val as any).__cardinality__, + exclusive: false, + writable: false, + hasDefault: false, + }; + } + } + + (root as any)[_pointers] = pointers; + (root as any)[_pathCache] = {}; + + return new Proxy(root, pathifyProxyHandlers); +} + +function isFunc(this: any, expr: ObjectTypeSet) { + return $expressionify({ + __kind__: ExpressionKind.TypeIntersection, + __cardinality__: this.__cardinality__, + __element__: { + ...expr.__element__, + __shape__: {id: true}, + } as any, + __expr__: this, + }); +} + +function assert_single(expr: Expression) { + return $expressionify({ + __kind__: ExpressionKind.Function, + __element__: expr.__element__, + __cardinality__: cardinalityUtil.overrideUpperBound( + expr.__cardinality__, + "One" + ), + __name__: "std::assert_single", + __args__: [expr], + __namedargs__: {}, + }) as any; +} + +const jsonDestructureProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + if ( + typeof prop === "string" && + prop !== "run" && + (target as any)[prop] === undefined + ) { + const parsedProp = Number.isInteger(Number(prop)) ? Number(prop) : prop; + return jsonDestructure.call(proxy, parsedProp); + } + return (target as any)[prop]; + }, +}; + +function jsonDestructure(this: ExpressionRoot, path: any) { + const pathTypeSet = literalToTypeSet(path); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + pathTypeSet.__cardinality__ + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, pathTypeSet], + }) as any; +} + +export function $jsonDestructure(_expr: ExpressionRoot) { + if ( + _expr.__element__.__kind__ === TypeKind.scalar && + _expr.__element__.__name__ === "std::json" + ) { + const expr = new Proxy(_expr, jsonDestructureProxyHandlers) as any; + + expr.destructure = jsonDestructure.bind(expr); + + return expr; + } + + return _expr; +} + +export function $expressionify( + _expr: T +): Expression { + const expr: Expression = _$pathify( + $jsonDestructure($arrayLikeIndexify($tuplePathify(_expr))) + ) as any; + + expr.run = $queryFunc.bind(expr) as any; + expr.is = isFunc.bind(expr) as any; + expr.toEdgeQL = $toEdgeQL.bind(expr); + expr.assert_single = () => assert_single(expr) as any; + + return Object.freeze(expr) as any; +} + +const scopedExprCache = new WeakMap(); +const scopeRoots = new WeakSet(); + +export function $getScopedExpr( + expr: T, + existingScopes?: Set +): Expression { + let scopedExpr = scopedExprCache.get(expr); + if (!scopedExpr || existingScopes?.has(scopedExpr)) { + const uncached = !scopedExpr; + scopedExpr = $expressionify({ + ...expr, + __cardinality__: Cardinality.One, + }); + scopeRoots.add(scopedExpr); + if (uncached) { + scopedExprCache.set(expr, scopedExpr); + } + } + existingScopes?.add(scopedExpr); + return scopedExpr as any; +} + +export {_$pathify as $pathify, PathLeaf as $PathLeaf, PathNode as $PathNode}; diff --git a/qb/dbschema/edgeql-js/syntax/query.ts b/qb/dbschema/edgeql-js/syntax/query.ts new file mode 100644 index 000000000..7e991d34b --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/query.ts @@ -0,0 +1,33 @@ +import * as edgedb from "edgedb"; +import {Cardinality, ExpressionKind} from "edgedb/dist/reflection"; +import {jsonifyComplexParams} from "./params"; +import {select} from "./select"; + +const runnableExpressionKinds = new Set([ + ExpressionKind.Select, + ExpressionKind.Update, + ExpressionKind.Insert, + ExpressionKind.InsertUnlessConflict, + ExpressionKind.Delete, + ExpressionKind.For, + ExpressionKind.With, + ExpressionKind.WithParams, +]); + +const wrappedExprCache = new WeakMap(); + +export async function $queryFunc(this: any, cxn: edgedb.Executor, args: any) { + const expr = runnableExpressionKinds.has(this.__kind__) + ? this + : wrappedExprCache.get(this) ?? + wrappedExprCache.set(this, select(this)).get(this); + const _args = jsonifyComplexParams(expr, args); + if ( + expr.__cardinality__ === Cardinality.One || + expr.__cardinality__ === Cardinality.AtMostOne + ) { + return cxn.querySingle(expr.toEdgeQL(), _args); + } else { + return cxn.query(expr.toEdgeQL(), _args); + } +} diff --git a/qb/dbschema/edgeql-js/syntax/select.ts b/qb/dbschema/edgeql-js/syntax/select.ts new file mode 100644 index 000000000..819b0cca6 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/select.ts @@ -0,0 +1,886 @@ +import { + LocalDateTime, + LocalDate, + LocalTime, + Duration, + RelativeDuration, + ConfigMemory, +} from "edgedb"; +import type {$bool, $number} from "../modules/std"; +import { + $expr_PolyShapeElement, + $scopify, + Cardinality, + cardinalityUtil, + Expression, + ExpressionKind, + LinkDesc, + makeType, + ObjectType, + ObjectTypeExpression, + ObjectTypePointers, + ObjectTypeSet, + PrimitiveTypeSet, + PropertyDesc, + ScalarType, + stripSet, + TypeKind, + TypeSet, + typeutil, +} from "edgedb/dist/reflection"; + +import type { + $expr_PathLeaf, + $expr_PathNode, + ExpressionRoot, + PathParent, +} from "edgedb/dist/reflection/path"; +import {anonymizeObject} from "./casting"; +import type {$expr_Operator} from "edgedb/dist/reflection/funcops"; +import {$expressionify, $getScopedExpr} from "./path"; +import {$getTypeByName, literal} from "./literal"; +import {spec} from "../__spec__"; +import { + scalarLiterals, + literalToScalarType, + literalToTypeSet, +} from "../castMaps"; + +export const ASC: "ASC" = "ASC"; +export const DESC: "DESC" = "DESC"; +export const EMPTY_FIRST: "EMPTY FIRST" = "EMPTY FIRST"; +export const EMPTY_LAST: "EMPTY LAST" = "EMPTY LAST"; +export type OrderByDirection = "ASC" | "DESC"; +export type OrderByEmpty = "EMPTY FIRST" | "EMPTY LAST"; + +export type OrderByExpr = TypeSet; +export type OrderByObjExpr = { + expression: OrderByExpr; + direction?: OrderByDirection; + empty?: OrderByEmpty; +}; + +export type OrderByExpression = + | OrderByExpr + | OrderByObjExpr + | [OrderByExpr | OrderByObjExpr, ...(OrderByExpr | OrderByObjExpr)[]]; + +export type OffsetExpression = TypeSet< + $number, + Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne +>; + +export type SelectFilterExpression = TypeSet<$bool, Cardinality>; +export type LimitOffsetExpression = TypeSet< + $number, + Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne +>; +export type LimitExpression = TypeSet< + $number, + Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne +>; + +export type SelectModifierNames = "filter" | "order_by" | "offset" | "limit"; + +export type SelectModifiers = { + filter?: SelectFilterExpression; + order_by?: OrderByExpression; + offset?: OffsetExpression | number; + limit?: LimitExpression | number; +}; + +export type NormalisedSelectModifiers = { + filter?: SelectFilterExpression; + order_by?: OrderByObjExpr[]; + offset?: OffsetExpression; + limit?: LimitExpression; +}; + +// type NormaliseOrderByModifier = +// Mods extends OrderByExpr +// ? [{expression: Mods}] +// : Mods extends OrderByObjExpr +// ? [Mods] +// : Mods extends (OrderByExpr | OrderByObjExpr)[] +// ? { +// [K in keyof Mods]: Mods[K] extends OrderByExpr +// ? {expression: Mods[K]} +// : Mods[K]; +// } +// : []; + +// type NormaliseSelectModifiers = { +// filter: Mods["filter"]; +// order_by: Mods["order_by"] extends OrderByExpression +// ? NormaliseOrderByModifier +// : []; +// offset: Mods["offset"] extends number +// ? $expr_Literal> +// : Mods["offset"]; +// limit: Mods["offset"] extends number +// ? $expr_Literal> +// : Mods["offset"]; +// }; + +export type $expr_Select = Expression<{ + __element__: Set["__element__"]; + __cardinality__: Set["__cardinality__"]; + __expr__: TypeSet; + __kind__: ExpressionKind.Select; + __modifiers__: NormalisedSelectModifiers; + __scope__?: ObjectTypeExpression; +}>; +// Modifier methods removed for now, until we can fix typescript inference +// problems / excessively deep errors +// & SelectModifierMethods>; + +export interface SelectModifierMethods { + filter( + filter: + | Filter + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => Filter) + ): this; + order_by( + order_by: + | OrderByExpression + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => OrderByExpression) + ): this; + offset( + offset: + | OffsetExpression + | number + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => OffsetExpression | number) + ): this; + // $expr_Select<{ + // __element__: Root["__element__"]; + // __cardinality__: cardinalityUtil.overrideLowerBound< + // Root["__cardinality__"], + // "Zero" + // >; + // }>; + limit( + limit: + | LimitExpression + | number + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => LimitExpression | number) + ): this; + // $expr_Select<{ + // __element__: Root["__element__"]; + // __cardinality__: cardinalityUtil.overrideLowerBound< + // Root["__cardinality__"], + // "Zero" + // >; + // }>; +} +// Base is ObjectTypeSet & +// Filter is equality & +// Filter.args[0] is PathLeaf +// Filter.args[0] is __exclusive__ & +// Filter.args[0].parent.__element__ === Base.__element__ +// Filter.args[1].__cardinality__ is AtMostOne or One +// if Filter.args[0] is PathNode: +// Filter.args[0] is __exclusive__ & +// if Filter.args[0].parent === null +// Filter.args[0].parent.__element__ === Base.__element__ +// Filter.args[1].__cardinality__ is AtMostOne or One +// else +// Filter.args[0].type.__element__ === Base.__element__ & +// Filter.args[1].__cardinality__ is AtMostOne or One + +type argCardToResultCard< + OpCard extends Cardinality, + BaseCase extends Cardinality +> = [OpCard] extends [Cardinality.AtMostOne | Cardinality.One] + ? Cardinality.AtMostOne + : [OpCard] extends [Cardinality.Empty] + ? Cardinality.Empty + : BaseCase; + +export type InferFilterCardinality< + Base extends TypeSet, + Filter extends TypeSet | undefined +> = Filter extends TypeSet + ? // Base is ObjectTypeExpression & + Base extends ObjectTypeSet // $expr_PathNode + ? // Filter is equality + Filter extends $expr_Operator<"=", any, infer Args, any> + ? // Filter.args[0] is PathLeaf + Args[0] extends $expr_PathLeaf + ? // Filter.args[0] is unique + Args[0]["__exclusive__"] extends true + ? // Filter.args[0].parent.__element__ === Base.__element__ + typeutil.assertEqual< + Args[0]["__parent__"]["type"]["__element__"]["__name__"], + Base["__element__"]["__name__"] + > extends true + ? // Filter.args[1].__cardinality__ is AtMostOne or One + argCardToResultCard< + Args[1]["__cardinality__"], + Base["__cardinality__"] + > + : Base["__cardinality__"] + : Base["__cardinality__"] + : Args[0] extends $expr_PathNode + ? Args[0]["__exclusive__"] extends true + ? // Filter.args[0].parent.__element__ === Base.__element__ + Args[0]["__parent__"] extends null + ? typeutil.assertEqual< + Args[0]["__element__"]["__name__"], + Base["__element__"]["__name__"] + > extends true + ? // Filter.args[1].__cardinality__ is AtMostOne or One + argCardToResultCard< + Args[1]["__cardinality__"], + Base["__cardinality__"] + > + : Base["__cardinality__"] + : Args[0]["__parent__"] extends infer Parent + ? Parent extends PathParent + ? typeutil.assertEqual< + Parent["type"]["__element__"]["__name__"], + Base["__element__"]["__name__"] + > extends true + ? // Filter.args[1].__cardinality__ is AtMostOne or One + argCardToResultCard< + Args[1]["__cardinality__"], + Base["__cardinality__"] + > + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"] + : Base["__cardinality__"]; + +export type InferOffsetLimitCardinality< + Card extends Cardinality, + Modifers extends SelectModifiers +> = Modifers["limit"] extends number | LimitExpression + ? cardinalityUtil.overrideLowerBound + : Modifers["offset"] extends number | OffsetExpression + ? cardinalityUtil.overrideLowerBound + : Card; + +export type ComputeSelectCardinality< + Expr extends ObjectTypeExpression, + Modifiers extends SelectModifiers +> = InferOffsetLimitCardinality< + InferFilterCardinality, + Modifiers +>; + +export function is< + Expr extends ObjectTypeExpression, + Shape extends pointersToSelectShape +>( + expr: Expr, + shape: Shape +): { + [k in Exclude]: $expr_PolyShapeElement< + Expr, + normaliseElement + >; +} { + const mappedShape: any = {}; + for (const [key, value] of Object.entries(shape)) { + mappedShape[key] = { + __kind__: ExpressionKind.PolyShapeElement, + __polyType__: expr, + __shapeElement__: value, + }; + } + return mappedShape; +} + +function computeFilterCardinality( + expr: SelectFilterExpression, + cardinality: Cardinality, + base: TypeSet +) { + let card = cardinality; + + const filter: any = expr; + // Base is ObjectExpression + const baseIsObjectExpr = base?.__element__?.__kind__ === TypeKind.object; + const filterExprIsEq = + filter.__kind__ === ExpressionKind.Operator && filter.__name__ === "="; + const arg0: $expr_PathLeaf | $expr_PathNode = filter?.__args__?.[0]; + const arg1: TypeSet = filter?.__args__?.[1]; + const argsExist = !!arg0 && !!arg1 && !!arg1.__cardinality__; + const arg0IsUnique = arg0?.__exclusive__ === true; + + if (baseIsObjectExpr && filterExprIsEq && argsExist && arg0IsUnique) { + const newCard = + arg1.__cardinality__ === Cardinality.One || + arg1.__cardinality__ === Cardinality.AtMostOne + ? Cardinality.AtMostOne + : arg1.__cardinality__ === Cardinality.Empty + ? Cardinality.Empty + : cardinality; + + if (arg0.__kind__ === ExpressionKind.PathLeaf) { + const arg0ParentMatchesBase = + arg0.__parent__.type.__element__.__name__ === + base.__element__.__name__; + if (arg0ParentMatchesBase) { + card = newCard; + } + } else if (arg0.__kind__ === ExpressionKind.PathNode) { + // if Filter.args[0] is PathNode: + // Filter.args[0] is __exclusive__ & + // if Filter.args[0].parent === null + // Filter.args[0].__element__ === Base.__element__ + // Filter.args[1].__cardinality__ is AtMostOne or One + // else + // Filter.args[0].type.__element__ === Base.__element__ & + // Filter.args[1].__cardinality__ is AtMostOne or One + const parent = arg0.__parent__; + if (parent === null) { + const arg0MatchesBase = + arg0.__element__.__name__ === base.__element__.__name__; + if (arg0MatchesBase) { + card = newCard; + } + } else { + const arg0ParentMatchesBase = + parent?.type.__element__.__name__ === base.__element__.__name__; + if (arg0ParentMatchesBase) { + card = newCard; + } + } + } + } + + return card; +} + +export function $handleModifiers( + modifiers: SelectModifiers, + rootExpr: TypeSet +): {modifiers: NormalisedSelectModifiers; cardinality: Cardinality} { + const mods = {...modifiers}; + let card = rootExpr.__cardinality__; + + if (mods.filter && rootExpr.__element__.__kind__ === TypeKind.object) { + card = computeFilterCardinality(mods.filter, card, rootExpr); + } + if (mods.order_by) { + const orderExprs = Array.isArray(mods.order_by) + ? mods.order_by + : [mods.order_by]; + mods.order_by = orderExprs.map(expr => + typeof (expr as any).__element__ === "undefined" + ? expr + : {expression: expr} + ) as any; + } + if (mods.offset) { + mods.offset = + typeof mods.offset === "number" + ? ($getTypeByName("std::number")(mods.offset) as any) + : mods.offset; + card = cardinalityUtil.overrideLowerBound(card, "Zero"); + } + if (mods.limit) { + let expr = mods.limit; + if (typeof expr === "number") { + expr = $getTypeByName("std::number")(expr) as any; + } else if ((expr as any).__kind__ === ExpressionKind.Set) { + expr = (expr as any).__exprs__[0]; + } + mods.limit = expr; + card = cardinalityUtil.overrideLowerBound(card, "Zero"); + } + + return {modifiers: mods as NormalisedSelectModifiers, cardinality: card}; +} + +export type $expr_Delete = + Expression<{ + __kind__: ExpressionKind.Delete; + __element__: Root["__element__"]; + __cardinality__: Root["__cardinality__"]; + __expr__: Root; + }>; + +function deleteExpr< + Expr extends ObjectTypeExpression, + Modifiers extends SelectModifiers +>( + expr: Expr, + modifiers?: (scope: $scopify) => Readonly +): $expr_Delete<{ + __element__: ObjectType< + Expr["__element__"]["__name__"], + Expr["__element__"]["__pointers__"], + {id: true} + >; + __cardinality__: ComputeSelectCardinality; +}>; +function deleteExpr(expr: any, modifiersGetter: any) { + const selectExpr = select(expr, modifiersGetter); + + return $expressionify({ + __kind__: ExpressionKind.Delete, + __element__: selectExpr.__element__, + __cardinality__: selectExpr.__cardinality__, + __expr__: selectExpr, + }) as any; +} + +export {deleteExpr as delete}; + +// Modifier methods removed for now, until we can fix typescript inference +// problems / excessively deep errors + +// function resolveModifierGetter(parent: any, modGetter: any) { +// if (typeof modGetter === "function" && !modGetter.__kind__) { +// if (parent.__expr__.__element__.__kind__ === TypeKind.object) { +// const shape = parent.__element__.__shape__; +// const _scope = +// parent.__scope__ ?? $getScopedExpr(parent.__expr__, +// $existingScopes); +// const scope = new Proxy(_scope, { +// get(target: any, prop: string) { +// if (shape[prop] && shape[prop] !== true) { +// return shape[prop]; +// } +// return target[prop]; +// }, +// }); +// return { +// scope: _scope, +// modExpr: modGetter(scope), +// }; +// } else { +// return { +// scope: undefined, +// modExpr: modGetter(parent.__expr__), +// }; +// } +// } else { +// return {scope: parent.__scope__, modExpr: modGetter}; +// } +// } + +// function updateModifier( +// parent: any, +// modName: "filter" | "order_by" | "offset" | "limit", +// modGetter: any +// ) { +// const modifiers = { +// ...parent.__modifiers__, +// }; +// const cardinality = parent.__cardinality__; + +// const {modExpr, scope} = resolveModifierGetter(parent, modGetter); + +// switch (modName) { +// case "filter": +// modifiers.filter = modifiers.filter +// ? op(modifiers.filter, "and", modExpr) +// : modExpr; + +// // methods no longer change cardinality +// // cardinality = computeFilterCardinality( +// // modExpr, +// // cardinality, +// // parent.__expr__ +// // ); +// break; +// case "order_by": +// const ordering = +// typeof (modExpr as any).__element__ === "undefined" +// ? modExpr +// : {expression: modExpr}; +// modifiers.order_by = modifiers.order_by +// ? [...modifiers.order_by, ordering] +// : [ordering]; +// break; +// case "offset": +// modifiers.offset = +// typeof modExpr === "number" ? _std.number(modExpr) : modExpr; +// // methods no longer change cardinality +// // cardinality = cardinalityUtil +// .overrideLowerBound(cardinality, "Zero"); +// break; +// case "limit": +// modifiers.limit = +// typeof modExpr === "number" +// ? _std.number(modExpr) +// : (modExpr as any).__kind__ === ExpressionKind.Set +// ? (modExpr as any).__exprs__[0] +// : modExpr; +// // methods no longer change cardinality +// // cardinality = cardinalityUtil +// .overrideLowerBound(cardinality, "Zero"); +// break; +// } + +// return $expressionify( +// $selectify({ +// __kind__: ExpressionKind.Select, +// __element__: parent.__element__, +// __cardinality__: cardinality, +// __expr__: parent.__expr__, +// __modifiers__: modifiers, +// __scope__: scope, +// }) +// ); +// } + +export function $selectify(expr: Expr) { + // Object.assign(expr, { + // filter: (filter: any) => updateModifier(expr, "filter", filter), + // order_by: (order_by: any) => updateModifier(expr, "order_by", order_by), + // offset: (offset: any) => updateModifier(expr, "offset", offset), + // limit: (limit: any) => updateModifier(expr, "limit", limit), + // }); + return expr; +} + +export type linkDescToLinkProps = { + [k in keyof Desc["properties"] & string]: $expr_PathLeaf< + TypeSet< + Desc["properties"][k]["target"], + Desc["properties"][k]["cardinality"] + >, + {type: $scopify; linkName: k}, + Desc["properties"][k]["exclusive"] + >; +}; + +export type pointersToSelectShape< + Shape extends ObjectTypePointers = ObjectTypePointers +> = Partial<{ + [k in keyof Shape]: Shape[k] extends PropertyDesc + ? + | boolean + | TypeSet< + // causes excessively deep error: + // castableFrom + Shape[k]["target"], + cardinalityUtil.assignable + > + : // | pointerToCastableExpression + Shape[k] extends LinkDesc + ? + | boolean + // | pointerToCastableExpression + | TypeSet< + anonymizeObject, + cardinalityUtil.assignable + > + | (pointersToSelectShape & + pointersToSelectShape & + SelectModifiers) + | (( + scope: $scopify & linkDescToLinkProps + ) => pointersToSelectShape & + pointersToSelectShape & + SelectModifiers) + : any; +}> & {[k: string]: unknown}; + +export type normaliseElement = El extends boolean + ? El + : El extends TypeSet + ? stripSet + : El extends (...scope: any[]) => any + ? normaliseShape> + : El extends object + ? normaliseShape> + : stripSet; + +export type normaliseShape = { + [k in Exclude]: normaliseElement; +}; + +const $FreeObject = makeType( + spec, + [...spec.values()].find(s => s.name === "std::FreeObject")!.id, + literal +); +const FreeObject = { + __kind__: ExpressionKind.PathNode, + __element__: $FreeObject, + __cardinality__: Cardinality.One, + __parent__: null, + __exclusive__: true, + __scopeRoot__: null, +}; + +export const $existingScopes = new Set(); + +export function select( + expr: Expr +): $expr_Select<{ + __element__: ObjectType< + `${Expr["__element__"]["__name__"]}`, // _shape + Expr["__element__"]["__pointers__"], + {id: true} + >; + __cardinality__: Expr["__cardinality__"]; +}>; +export function select( + expr: Expr +): $expr_Select>; +export function select< + Expr extends ObjectTypeExpression, + Shape extends pointersToSelectShape & + SelectModifiers, + Modifiers = Pick +>( + expr: Expr, + shape: (scope: $scopify) => Readonly +): $expr_Select<{ + __element__: ObjectType< + `${Expr["__element__"]["__name__"]}`, // _shape + Expr["__element__"]["__pointers__"], + Omit, SelectModifierNames> + >; + __cardinality__: ComputeSelectCardinality; +}>; +/* + +For the moment is isn't possible to implement both closure-based and plain +object overloads without breaking autocomplete on one or the other. +This is due to a limitation in TS: + +https://github.com/microsoft/TypeScript/issues/26892 +https://github.com/microsoft/TypeScript/issues/47081 + +*/ +export function select< + Expr extends PrimitiveTypeSet, + Modifiers extends SelectModifiers +>( + expr: Expr, + modifiers: (expr: Expr) => Readonly +): $expr_Select<{ + __element__: Expr["__element__"]; + __cardinality__: InferOffsetLimitCardinality< + Expr["__cardinality__"], + Modifiers + >; +}>; +export function select( + shape: Shape +): $expr_Select<{ + __element__: ObjectType<`std::FreeObject`, {}, Shape>; // _shape + __cardinality__: Cardinality.One; +}>; +export function select( + expr: Expr +): $expr_Select<{ + __element__: literalToScalarType; + __cardinality__: Cardinality.One; +}>; +export function select(...args: any[]) { + const firstArg = args[0]; + + if ( + typeof firstArg !== "object" || + firstArg instanceof Buffer || + firstArg instanceof Date || + firstArg instanceof Duration || + firstArg instanceof LocalDateTime || + firstArg instanceof LocalDate || + firstArg instanceof LocalTime || + firstArg instanceof RelativeDuration || + firstArg instanceof ConfigMemory + ) { + const literalExpr = literalToTypeSet(firstArg); + return $expressionify( + $selectify({ + __kind__: ExpressionKind.Select, + __element__: literalExpr.__element__, + __cardinality__: literalExpr.__cardinality__, + __expr__: literalExpr, + __modifiers__: {}, + }) + ) as any; + } + + const [expr, shapeGetter]: [TypeSet, (scope: any) => any] = + typeof args[0].__element__ !== "undefined" + ? (args as any) + : [FreeObject, () => args[0]]; + + if (!shapeGetter) { + if (expr.__element__.__kind__ === TypeKind.object) { + const objectExpr: ObjectTypeSet = expr as any; + return $expressionify( + $selectify({ + __kind__: ExpressionKind.Select, + __element__: { + __kind__: TypeKind.object, + __name__: `${objectExpr.__element__.__name__}`, // _shape + __pointers__: objectExpr.__element__.__pointers__, + __shape__: {id: true}, + } as any, + __cardinality__: objectExpr.__cardinality__, + __expr__: objectExpr, + __modifiers__: {}, + }) + ) as any; + } else { + return $expressionify( + $selectify({ + __kind__: ExpressionKind.Select, + __element__: expr.__element__, + __cardinality__: expr.__cardinality__, + __expr__: expr, + __modifiers__: {}, + }) + ) as any; + } + } + + const cleanScopedExprs = $existingScopes.size === 0; + + const {modifiers: mods, shape, scope} = resolveShape(shapeGetter, expr); + + if (cleanScopedExprs) { + $existingScopes.clear(); + } + + const {modifiers, cardinality} = $handleModifiers(mods, expr); + return $expressionify( + $selectify({ + __kind__: ExpressionKind.Select, + __element__: + expr !== scope + ? { + __kind__: TypeKind.object, + __name__: `${expr.__element__.__name__}`, // _shape + __pointers__: (expr.__element__ as ObjectType).__pointers__, + __shape__: shape, + } + : expr.__element__, + __cardinality__: cardinality, + __expr__: expr, + __modifiers__: modifiers, + __scope__: + expr !== scope && expr.__element__.__name__ !== "std::FreeObject" + ? scope + : undefined, + }) + ) as any; +} + +function resolveShape( + shapeGetter: ((scope: any) => any) | any, + expr: TypeSet +): {modifiers: any; shape: any; scope: TypeSet} { + const modifiers: any = {}; + const shape: any = {}; + + const scope = + expr.__element__.__kind__ === TypeKind.object + ? $getScopedExpr(expr as any, $existingScopes) + : expr; + + const selectShape = + typeof shapeGetter === "function" ? shapeGetter(scope) : shapeGetter; + + for (const [key, value] of Object.entries(selectShape)) { + if ( + key === "filter" || + key === "order_by" || + key === "offset" || + key === "limit" + ) { + modifiers[key] = value; + } else { + if (scope === expr) { + throw new Error( + `Invalid select shape key '${key}' on scalar expression, ` + + `only modifiers are allowed (filter, order_by, offset and limit)` + ); + } + shape[key] = resolveShapeElement(key, value, scope); + } + } + return {shape, modifiers, scope}; +} + +function resolveShapeElement( + key: any, + value: any, + scope: ObjectTypeExpression +): any { + if ( + (typeof value === "function" && + scope.__element__.__pointers__[key]?.__kind__ === "link") || + (typeof value === "object" && + typeof (value as any).__kind__ === "undefined") + ) { + const childExpr = (scope as any)[key]; + const { + shape: childShape, + scope: childScope, + modifiers: mods, + } = resolveShape(value as any, childExpr); + + const {modifiers} = $handleModifiers(mods, childExpr); + + return { + __kind__: ExpressionKind.Select, + __element__: { + __kind__: TypeKind.object, + __name__: `${childExpr.__element__.__name__}`, + __pointers__: childExpr.__element__.__pointers__, + __shape__: childShape, + }, + __cardinality__: scope.__element__.__pointers__[key].cardinality, + __expr__: childExpr, + __modifiers__: modifiers, + __scope__: childScope, + }; + } else if ((value as any)?.__kind__ === ExpressionKind.PolyShapeElement) { + const polyElement = value as $expr_PolyShapeElement; + const polyScope = (scope as any).is(polyElement.__polyType__); + return { + __kind__: ExpressionKind.PolyShapeElement, + __polyType__: polyScope, + __shapeElement__: resolveShapeElement( + key, + polyElement.__shapeElement__, + polyScope + ), + }; + } else if (typeof value === "boolean" && key.startsWith("@")) { + const linkProp = (scope as any)[key]; + if (!linkProp) { + throw new Error( + (scope as any).__parent__ + ? `link property '${key}' does not exist on link ${ + (scope as any).__parent__.linkName + }` + : `cannot select link property '${key}' on an object (${scope.__element__.__name__})` + ); + } + return value ? linkProp : false; + } else { + return value; + } +} diff --git a/qb/dbschema/edgeql-js/syntax/set.ts b/qb/dbschema/edgeql-js/syntax/set.ts new file mode 100644 index 000000000..9985f84ad --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/set.ts @@ -0,0 +1,117 @@ +import { + ArrayType, + BaseTypeTuple, + BaseType, + NamedTupleType, + ObjectTypeSet, + TypeSet, + TupleType, + Expression, + ExpressionKind, + mergeObjectTypes, + ObjectType, + Cardinality, + getPrimitiveBaseType, +} from "edgedb/dist/reflection"; + +// "@generated/" path gets replaced during generation step +// @ts-ignore +import {getSharedParentScalar} from "../castMaps"; + +// @ts-ignore +export {set} from "./setImpl"; + +export type $expr_Set = Expression<{ + __element__: Set["__element__"]; + __cardinality__: Set["__cardinality__"]; + __exprs__: Expression[]; + __kind__: ExpressionKind.Set; +}>; + +type mergeTypeTuples = { + [k in keyof AItems]: k extends keyof BItems + ? getSharedParentPrimitive + : never; +}; + +// find shared parent of two primitives +export type getSharedParentPrimitive = A extends undefined + ? B extends undefined + ? undefined + : B + : B extends undefined + ? A + : A extends ArrayType + ? B extends ArrayType + ? ArrayType> + : never + : A extends NamedTupleType + ? B extends NamedTupleType + ? NamedTupleType<{ + [k in keyof AShape & keyof BShape]: getSharedParentScalar< + AShape[k], + BShape[k] + >; + }> + : never + : A extends TupleType + ? B extends TupleType + ? mergeTypeTuples extends BaseTypeTuple + ? TupleType> + : never + : never + : getSharedParentScalar; + +type _getSharedParentPrimitiveVariadic = + Types extends [infer U] + ? U + : Types extends [infer A, infer B, ...infer Rest] + ? _getSharedParentPrimitiveVariadic< + [getSharedParentPrimitive, ...Rest] + > + : never; + +export type getSharedParentPrimitiveVariadic = + _getSharedParentPrimitiveVariadic; + +export type LooseTypeSet< + T extends any = any, + C extends Cardinality = Cardinality +> = { + __element__: T; + __cardinality__: C; +}; + +export type {mergeObjectTypes}; + +type _mergeObjectTypesVariadic = + Types extends [infer U] + ? U + : Types extends [infer A, infer B, ...infer Rest] + ? A extends ObjectType + ? B extends ObjectType + ? mergeObjectTypes extends BaseType + ? mergeObjectTypesVariadic<[mergeObjectTypes, ...Rest]> + : never + : never + : never + : never; + +export type mergeObjectTypesVariadic = + _mergeObjectTypesVariadic; + +export type getTypesFromExprs = { + [k in keyof Exprs]: Exprs[k] extends TypeSet + ? getPrimitiveBaseType + : never; +}; + +export type getTypesFromObjectExprs< + Exprs extends [ObjectTypeSet, ...ObjectTypeSet[]] +> = { + [k in keyof Exprs]: Exprs[k] extends TypeSet ? El : never; +}; + +export type getCardsFromExprs = { + [k in keyof Exprs]: Exprs[k] extends TypeSet ? Card : never; +}; diff --git a/qb/dbschema/edgeql-js/syntax/setImpl.ts b/qb/dbschema/edgeql-js/syntax/setImpl.ts new file mode 100644 index 000000000..191836f8d --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/setImpl.ts @@ -0,0 +1,128 @@ +import { TypeKind, ExpressionKind, Cardinality, cardinalityUtil, $mergeObjectTypes, unwrapCastableType } from "edgedb/dist/reflection/index"; +import * as castMaps from "../castMaps"; +import { $expressionify } from "./path"; +import * as _std from "../modules/std"; +import type { + ArrayType, + TypeSet, + BaseType, + ObjectTypeSet, + PrimitiveTypeSet, + AnyTupleType, + getPrimitiveBaseType, +} from "edgedb/dist/reflection"; +import type { + $expr_Set, + mergeObjectTypesVariadic, + getTypesFromExprs, + getTypesFromObjectExprs, + getCardsFromExprs, + getSharedParentPrimitiveVariadic, + LooseTypeSet, +} from "./set"; + +type getSetTypeFromExprs< + Exprs extends [TypeSet, ...TypeSet[]] +> = LooseTypeSet< + getSharedParentPrimitiveVariadic>, + cardinalityUtil.mergeCardinalitiesVariadic> +>; + +function set(): null; +function set< + Expr extends castMaps.orScalarLiteral +>(expr: Expr): $expr_Set>; +function set< + Expr extends castMaps.orScalarLiteral>, + Exprs extends [Expr, ...Expr[]] +>(...exprs: Exprs): $expr_Set>>; +function set< + Expr extends TypeSet>, + Exprs extends [Expr, ...Expr[]] +>(...exprs: Exprs): $expr_Set>; +function set< + Expr extends ObjectTypeSet, + Exprs extends [Expr, ...Expr[]] +>( + ...exprs: Exprs +): $expr_Set< + LooseTypeSet< + mergeObjectTypesVariadic>, + cardinalityUtil.mergeCardinalitiesVariadic> + > +>; +function set< + Expr extends TypeSet, + Exprs extends [Expr, ...Expr[]] +>(...exprs: Exprs): $expr_Set>; +function set< + Expr extends TypeSet | castMaps.scalarLiterals, + Exprs extends castMaps.orScalarLiteral< + TypeSet["__element__"]>> + >[] +>( + expr: Expr, + ...exprs: Exprs +): $expr_Set< + TypeSet< + getPrimitiveBaseType["__element__"]>, + cardinalityUtil.mergeCardinalitiesVariadic< + getCardsFromExprs> + > + > +>; +function set | castMaps.scalarLiterals>( + ...exprs: Expr[] +): $expr_Set< + TypeSet< + getPrimitiveBaseType["__element__"]>, + Cardinality.Many + > +>; +function set(..._exprs: any[]) { + // if no arg + // if arg + // return empty set + // if object set + // merged objects + // if primitive + // return shared parent of scalars + if(_exprs.length === 0){ + return null; + } + + const exprs: TypeSet[] = _exprs.map(expr => castMaps.literalToTypeSet(expr)); + if (exprs.every((expr) => expr.__element__.__kind__ === TypeKind.object)) { + // merge object types; + return $expressionify({ + __kind__: ExpressionKind.Set, + __element__: exprs + .map((expr) => expr.__element__ as any) + .reduce($mergeObjectTypes), + __cardinality__: cardinalityUtil.mergeCardinalitiesVariadic( + exprs.map((expr) => expr.__cardinality__) as any + ), + __exprs__: exprs, + }) as any; + } + if (exprs.every((expr) => expr.__element__.__kind__ !== TypeKind.object)) { + return $expressionify({ + __kind__: ExpressionKind.Set, + __element__: exprs + .map((expr) => expr.__element__ as any) + .reduce(castMaps.getSharedParentScalar), + __cardinality__: cardinalityUtil.mergeCardinalitiesVariadic( + exprs.map((expr) => expr.__cardinality__) as any + ), + __exprs__: exprs, + }) as any; + } + throw new Error( + `Invalid arguments to set constructor: ${(_exprs as TypeSet[]) + .map((expr) => expr.__element__.__name__) + .join(", ")}` + ); +} + + +export { set }; diff --git a/qb/dbschema/edgeql-js/syntax/syntax.ts b/qb/dbschema/edgeql-js/syntax/syntax.ts new file mode 100644 index 000000000..c0cb8eed9 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/syntax.ts @@ -0,0 +1,18 @@ +import {TypeSet, setToTsType} from "edgedb/dist/reflection"; + +export * from "./literal"; +export * from "./path"; +export * from "./set"; +export * from "./cast"; +export * from "./select"; +export * from "./update"; +export * from "./insert"; +export * from "./collections"; +export * from "./funcops"; +export * from "./for"; +export * from "./with"; +export * from "./params"; +export * from "./detached"; +export * from "./toEdgeQL"; + +export type $infer = setToTsType; diff --git a/qb/dbschema/edgeql-js/syntax/toEdgeQL.ts b/qb/dbschema/edgeql-js/syntax/toEdgeQL.ts new file mode 100644 index 000000000..2d375e65d --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/toEdgeQL.ts @@ -0,0 +1,1264 @@ +import { + Duration, + LocalDate, + LocalDateTime, + LocalTime, + RelativeDuration, +} from "edgedb"; +import { + $expr_Array, + $expr_NamedTuple, + $expr_Tuple, + $expr_TuplePath, + BaseType, + Cardinality, + ExpressionKind, + isArrayType, + isNamedTupleType, + isObjectType, + isTupleType, + OperatorKind, + TypeKind, + TypeSet, + util, +} from "edgedb/dist/reflection"; +import type {$expr_Literal} from "edgedb/dist/reflection/literal"; +import type { + $expr_PathLeaf, + $expr_PathNode, + $expr_TypeIntersection, +} from "edgedb/dist/reflection/path"; +import {reservedKeywords} from "edgedb/dist/reflection/reservedKeywords"; +import type {$expr_Cast} from "./cast"; +import type {$expr_Detached} from "./detached"; +import type {$expr_For, $expr_ForVar} from "./for"; +import type {$expr_Function, $expr_Operator} from "edgedb/dist/reflection/funcops"; +import type {$expr_Insert, $expr_InsertUnlessConflict} from "./insert"; +import type {$expr_Param, $expr_WithParams} from "./params"; +import type { + $expr_Delete, + $expr_Select, + LimitExpression, + OffsetExpression, +} from "./select"; +import type {$expr_Set} from "./set"; +import type {$expr_Update} from "./update"; +import type {$expr_Alias, $expr_With} from "./with"; + +export type SomeExpression = + | $expr_PathNode + | $expr_PathLeaf + | $expr_Literal + | $expr_Set + | $expr_Array + | $expr_Tuple + | $expr_NamedTuple + | $expr_TuplePath + | $expr_Cast + | $expr_Select + | $expr_Delete + | $expr_Update + | $expr_Insert + | $expr_InsertUnlessConflict + | $expr_Function + | $expr_Operator + | $expr_For + | $expr_ForVar + | $expr_TypeIntersection + | $expr_Alias + | $expr_With + | $expr_WithParams + | $expr_Param + | $expr_Detached; + +type WithScopeExpr = + | $expr_Select + | $expr_Update + | $expr_Insert + | $expr_InsertUnlessConflict + | $expr_For; + +const topLevelExprKinds = new Set([ + ExpressionKind.Delete, + ExpressionKind.For, + ExpressionKind.Insert, + ExpressionKind.InsertUnlessConflict, + ExpressionKind.Select, + ExpressionKind.Update, + ExpressionKind.With, + ExpressionKind.WithParams, +]); + +function shapeToEdgeQL( + shape: object | null, + ctx: RenderCtx, + pointerKeys: string[] | null = null, + keysOnly: boolean = false +) { + if (shape === null) { + return ``; + } + const lines: string[] = []; + const addLine = (line: string) => + lines.push(`${keysOnly ? "" : " "}${line}`); + + const seen = new Set(); + + for (const key in shape) { + if (!shape.hasOwnProperty(key)) continue; + if (seen.has(key)) { + // tslint:disable-next-line + console.warn(`Invalid: duplicate key "${key}"`); + continue; + } + seen.add(key); + let val = (shape as any)[key]; + let operator = ":="; + let polyType: SomeExpression | null = null; + + if (typeof val === "object" && !val.__element__) { + if (!!val["+="]) { + operator = "+="; + val = val["+="]; + } else if (!!val["-="]) { + operator = "-="; + val = val["-="]; + } + } + if (val.__kind__ === ExpressionKind.PolyShapeElement) { + polyType = val.__polyType__; + val = val.__shapeElement__; + } + const polyIntersection = polyType + ? `[IS ${polyType.__element__.__name__}].` + : ""; + + if (typeof val === "boolean") { + if (val) { + addLine(`${polyIntersection}${q(key)}`); + } + } else if (val.hasOwnProperty("__kind__")) { + if (keysOnly) { + addLine(q(key)); + continue; + } + const renderedExpr = renderEdgeQL(val, ctx); + + // For computed properties in select shapes, inject the expected + // cardinality inferred by the query builder. This ensures the actual + // type returned by the server matches the inferred return type, or an + // explicit error is thrown, instead of a silent mismatch between + // actual and inferred type. + const expectedCardinality = + pointerKeys && + !pointerKeys.includes(key) && + val.hasOwnProperty("__cardinality__") + ? val.__cardinality__ === Cardinality.Many || + val.__cardinality__ === Cardinality.AtLeastOne + ? "multi " + : "single " + : ""; + + addLine( + `${expectedCardinality}${q(key)} ${operator} (${ + renderedExpr.includes("\n") + ? `\n${indent(renderedExpr, 4)}\n ` + : renderedExpr + })` + ); + } else { + throw new Error("Invalid shape."); + } + } + + if (lines.length === 0) { + addLine("id"); + } + return keysOnly ? `{${lines.join(", ")}}` : `{\n${lines.join(",\n")}\n}`; +} + +interface RenderCtx { + withBlocks: Map>; + withVars: Map< + SomeExpression, + { + name: string; + scope: WithScopeExpr; + childExprs: Set; + scopedExpr?: SomeExpression; + } + >; + renderWithVar?: SomeExpression; + forVars: Map<$expr_ForVar, string>; + linkProps: Map; +} + +const toEdgeQLCache = new WeakMap(); + +export function $toEdgeQL(this: any) { + if (toEdgeQLCache.has(this)) { + return toEdgeQLCache.get(this)!; + } + + const walkExprCtx: WalkExprTreeCtx = { + seen: new Map(), + rootScope: null, + }; + + walkExprTree(this, null, walkExprCtx); + + const withBlocks = new Map>(); + const withVars = new Map< + SomeExpression, + { + name: string; + scope: WithScopeExpr; + childExprs: Set; + scopedExpr?: SomeExpression; + } + >(); + + const seen = new Map(walkExprCtx.seen); + const linkProps: RenderCtx["linkProps"] = new Map(); + + for (const [expr, refData] of seen) { + seen.delete(expr); + + if (refData.linkProps.length) { + linkProps.set( + expr, + refData.linkProps.map(linkProp => + linkProp.__parent__.linkName.slice(1) + ) + ); + } + + if ( + withVars.has(expr) || + ((expr.__kind__ === ExpressionKind.PathLeaf || + expr.__kind__ === ExpressionKind.PathNode || + expr.__kind__ === ExpressionKind.TypeIntersection) && + !refData.boundScope) || + expr.__kind__ === ExpressionKind.ForVar || + expr.__kind__ === ExpressionKind.Param + ) { + continue; + } + + if ( + (expr.__kind__ === ExpressionKind.Select || + expr.__kind__ === ExpressionKind.Update) && + expr.__scope__ && + !withVars.has(expr.__scope__ as any) + ) { + const withBlock = expr; + const scopeVar = expr.__scope__ as SomeExpression; + + const scopeVarName = `__scope_${withVars.size}_${ + scopeVar.__element__.__name__.split("::")[1] + }`; + + withVars.set(scopeVar, { + name: scopeVarName, + scope: withBlock, + childExprs: new Set(), + scopedExpr: + expr.__element__.__kind__ === TypeKind.object + ? (expr.__expr__ as any) + : undefined, + }); + } + + if ( + refData.boundScope || + refData.refCount > 1 || + refData.aliases.length > 0 + ) { + let withBlock = refData.boundScope; + + const parentScopes = [...refData.parentScopes].filter( + scope => scope !== null + ) as WithScopeExpr[]; + if (!withBlock) { + if (parentScopes.some(parentScope => seen.has(parentScope))) { + // parent scopes haven't all been resolved yet, re-add current + // expr to seen list to resolve later + seen.set(expr, refData); + continue; + } + + const resolvedParentScopes = parentScopes.map( + parentScope => withVars.get(parentScope)?.scope ?? parentScope + ); + withBlock = + resolvedParentScopes.find(parentScope => { + const childExprs = new Set( + walkExprCtx.seen.get(parentScope)!.childExprs + ); + return resolvedParentScopes.every( + scope => scope === parentScope || childExprs.has(scope) + ); + }) ?? walkExprCtx.rootScope; + } + + if (!withBlock) { + throw new Error( + `Cannot extract repeated expression into 'WITH' block, ` + + `query has no 'WITH'able expressions` + ); + } + + if (!withBlocks.has(withBlock)) { + withBlocks.set(withBlock, new Set()); + } + + // check all references and aliases are within this block + const validScopes = new Set([ + withBlock, + ...walkExprCtx.seen.get(withBlock)!.childExprs, + ]); + for (const scope of [ + ...refData.parentScopes, + ...util.flatMap(refData.aliases, alias => [ + ...walkExprCtx.seen.get(alias)!.parentScopes, + ]), + ]) { + if (scope === null || !validScopes.has(scope)) { + throw new Error( + refData.boundScope + ? `Expr or it's aliases used outside of declared 'WITH' block scope` + : `Cannot extract repeated or aliased expression into 'WITH' block, ` + + `expression or it's aliases appear outside root scope` + ); + } + } + + for (const withVar of [expr, ...refData.aliases]) { + const withVarBoundScope = walkExprCtx.seen.get(withVar)!.boundScope; + if (withVarBoundScope && withVarBoundScope !== refData.boundScope) { + // withVar is an alias already explicitly bound + // to an inner WITH block + continue; + } + + const withVarName = `__withVar_${withVars.size}`; + + withBlocks.get(withBlock)!.add(withVar); + withVars.set(withVar, { + name: withVarName, + scope: withBlock, + childExprs: new Set(walkExprCtx.seen.get(withVar)!.childExprs), + }); + } + } + } + + const edgeQL = renderEdgeQL(this, { + withBlocks, + withVars, + forVars: new Map(), + linkProps, + }); + toEdgeQLCache.set(this, edgeQL); + + return edgeQL; +} + +function topoSortWithVars( + vars: Set, + ctx: RenderCtx +): SomeExpression[] { + if (!vars.size) { + return []; + } + + const sorted: SomeExpression[] = []; + + const unvisited = new Set(vars); + const visiting = new Set(); + + for (const withVar of unvisited) { + visit(withVar); + } + + function visit(withVar: SomeExpression): void { + if (!unvisited.has(withVar)) { + return; + } + if (visiting.has(withVar)) { + throw new Error(`'WITH' variables contain a cyclic dependency`); + } + + visiting.add(withVar); + + for (const child of ctx.withVars.get(withVar)!.childExprs) { + if (vars.has(child)) { + visit(child); + } + } + + visiting.delete(withVar); + unvisited.delete(withVar); + + sorted.push(withVar); + } + return sorted; +} + +function renderEdgeQL( + _expr: TypeSet, + ctx: RenderCtx, + renderShape: boolean = true, + noImplicitDetached: boolean = false +): string { + if (!(_expr as any).__kind__) { + throw new Error("Invalid expression."); + } + const expr = _expr as SomeExpression; + + const withVar = ctx.withVars.get(expr); + if (withVar && ctx.renderWithVar !== expr) { + return ( + withVar.name + + (renderShape && + expr.__kind__ === ExpressionKind.Select && + isObjectType(expr.__element__) + ? " " + + shapeToEdgeQL( + (expr.__element__.__shape__ || {}) as object, + ctx, + null, + true + ) + : "") + ); + } + + function renderWithBlockExpr(varExpr: SomeExpression) { + const withBlockElement = ctx.withVars.get(varExpr)!; + let renderedExpr = renderEdgeQL( + withBlockElement.scopedExpr ?? varExpr, + { + ...ctx, + renderWithVar: varExpr, + }, + !withBlockElement.scopedExpr + ); + if (ctx.linkProps.has(varExpr)) { + renderedExpr = `SELECT ${renderedExpr} {\n${ctx.linkProps + .get(varExpr)! + .map( + linkPropName => + ` __linkprop_${linkPropName} := ${renderedExpr}@${linkPropName}` + ) + .join(",\n")}\n}`; + } + return ` ${withBlockElement.name} := (${ + renderedExpr.includes("\n") + ? `\n${indent(renderedExpr, 4)}\n ` + : renderedExpr + })`; + } + + let withBlock = ""; + const scopeExpr = + (expr.__kind__ === ExpressionKind.Select || + expr.__kind__ === ExpressionKind.Update) && + ctx.withVars.has(expr.__scope__ as any) + ? (expr.__scope__ as SomeExpression) + : undefined; + if (ctx.withBlocks.has(expr as any) || scopeExpr) { + let blockVars = topoSortWithVars( + ctx.withBlocks.get(expr as any) ?? new Set(), + ctx + ); + + const scopedWithBlock: string[] = []; + if (scopeExpr) { + const scopeVar = ctx.withVars.get(scopeExpr)!; + + const scopedBlockVars = blockVars.filter(blockVarExpr => + ctx.withVars.get(blockVarExpr)?.childExprs.has(scopeExpr) + ); + blockVars = blockVars.filter( + blockVar => !scopedBlockVars.includes(blockVar) + ); + + if (scopedBlockVars.length) { + const scopeName = scopeVar.name; + scopeVar.name = scopeName + "_expr"; + scopedWithBlock.push(renderWithBlockExpr(scopeExpr)); + + scopeVar.name = scopeName + "_inner"; + scopedWithBlock.push( + ` ${scopeName} := (FOR ${scopeVar.name} IN {${ + scopeName + "_expr" + }} UNION (\n WITH\n${indent( + scopedBlockVars + .map(blockVar => renderWithBlockExpr(blockVar)) + .join(",\n"), + 4 + )}\n SELECT ${scopeVar.name} {\n${scopedBlockVars + .map(blockVar => { + const name = ctx.withVars.get(blockVar)!.name; + return ` ${name} := ${name}`; + }) + .join(",\n")}\n }\n ))` + ); + + scopeVar.name = scopeName; + for (const blockVarExpr of scopedBlockVars) { + const blockVar = ctx.withVars.get(blockVarExpr)!; + blockVar.name = `${scopeName}.${blockVar.name}`; + } + } else { + scopedWithBlock.push(renderWithBlockExpr(scopeExpr!)); + } + } + withBlock = `WITH\n${[ + ...blockVars.map(blockVar => renderWithBlockExpr(blockVar)), + ...scopedWithBlock, + ].join(",\n")}\n`; + } + + // console.log(expr.__kind__); + if (expr.__kind__ === ExpressionKind.With) { + return renderEdgeQL(expr.__expr__, ctx); + } else if (expr.__kind__ === ExpressionKind.WithParams) { + return `WITH\n${expr.__params__ + .map(param => { + const optional = + param.__cardinality__ === Cardinality.AtMostOne ? "OPTIONAL " : ""; + return ` __param__${param.__name__} := ${ + param.__isComplex__ + ? `<${param.__element__.__name__}><${optional}json>` + : `<${optional}${param.__element__.__name__}>` + }$${param.__name__}`; + }) + .join(",\n")}\nSELECT (${renderEdgeQL(expr.__expr__, ctx)})`; + } else if (expr.__kind__ === ExpressionKind.Alias) { + const aliasedExprVar = ctx.withVars.get(expr.__expr__ as any); + if (!aliasedExprVar) { + throw new Error( + `Expression referenced by alias does not exist in 'WITH' block` + ); + } + return aliasedExprVar.name; + } else if ( + expr.__kind__ === ExpressionKind.PathNode || + expr.__kind__ === ExpressionKind.PathLeaf + ) { + if (!expr.__parent__) { + return `${noImplicitDetached ? "" : "DETACHED "}${ + expr.__element__.__name__ + }`; + } else { + const isScopedLinkProp = + expr.__parent__.linkName.startsWith("@") && + ctx.withVars.has(expr.__parent__.type as any); + const linkName = isScopedLinkProp + ? `__linkprop_${expr.__parent__.linkName.slice(1)}` + : expr.__parent__.linkName; + const parent = renderEdgeQL( + expr.__parent__.type, + ctx, + false, + noImplicitDetached + ); + return `${ + (expr.__parent__.type as any).__kind__ !== ExpressionKind.PathNode && + !(ctx.withVars.has(expr) && ctx.renderWithVar !== expr) + ? `(${parent})` + : parent + }${linkName.startsWith("@") ? "" : "."}${q(linkName)}`.trim(); + } + } else if (expr.__kind__ === ExpressionKind.Literal) { + return literalToEdgeQL(expr.__element__, expr.__value__); + } else if (expr.__kind__ === ExpressionKind.Set) { + const exprs = expr.__exprs__; + + if ( + exprs.every(ex => ex.__element__.__kind__ === TypeKind.object) || + exprs.every(ex => ex.__element__.__kind__ !== TypeKind.object) + ) { + if (exprs.length === 0) return `<${expr.__element__.__name__}>{}`; + return `{ ${exprs + .map(ex => { + const renderedExpr = renderEdgeQL(ex, ctx); + return topLevelExprKinds.has((ex as SomeExpression).__kind__) + ? `(${renderedExpr})` + : renderedExpr; + }) + .join(", ")} }`; + } else { + throw new Error( + `Invalid arguments to set constructor: ${exprs + .map(ex => expr.__element__.__name__) + .join(", ")}` + ); + } + } else if (expr.__kind__ === ExpressionKind.Array) { + return `[${expr.__items__ + .map(item => renderEdgeQL(item, ctx)) + .join(", ")}]`; + } else if (expr.__kind__ === ExpressionKind.Tuple) { + return `(\n${expr.__items__ + .map(item => ` ` + renderEdgeQL(item, ctx)) + .join(",\n")}${expr.__items__.length === 1 ? "," : ""}\n)`; + } else if (expr.__kind__ === ExpressionKind.NamedTuple) { + return `(\n${Object.keys(expr.__shape__) + .map(key => ` ${key} := ${renderEdgeQL(expr.__shape__[key], ctx)}`) + .join(",\n")}\n)`; + } else if (expr.__kind__ === ExpressionKind.TuplePath) { + return `${renderEdgeQL(expr.__parent__, ctx)}.${expr.__index__}`; + } else if (expr.__kind__ === ExpressionKind.Cast) { + if (expr.__expr__ === null) { + return `<${expr.__element__.__name__}>{}`; + } + return `<${expr.__element__.__name__}>(${renderEdgeQL(expr.__expr__, ctx)})`; + } else if (expr.__kind__ === ExpressionKind.Select) { + const lines = []; + if (isObjectType(expr.__element__)) { + lines.push( + `SELECT${ + expr.__expr__.__element__.__name__ === "std::FreeObject" + ? "" + : ` (${renderEdgeQL(expr.__scope__ ?? expr.__expr__, ctx, false)})` + }` + ); + + lines.push( + shapeToEdgeQL( + (expr.__element__.__shape__ || {}) as object, + ctx, + Object.keys(expr.__element__.__pointers__) + ) + ); + } else { + // non-object/non-shape select expression + const needsScalarVar = + (expr.__modifiers__.filter || + expr.__modifiers__.order_by || + expr.__modifiers__.offset || + expr.__modifiers__.limit) && + !ctx.withVars.has(expr.__expr__ as any); + + lines.push( + `SELECT ${needsScalarVar ? "_ := " : ""}(${renderEdgeQL( + expr.__expr__, + ctx + )})` + ); + + if (needsScalarVar) { + ctx = {...ctx, withVars: new Map(ctx.withVars)}; + ctx.withVars.set(expr.__expr__ as any, { + name: "_", + childExprs: new Set(), + scope: expr, + }); + } + } + + const modifiers = []; + + if (expr.__modifiers__.filter) { + modifiers.push(`FILTER ${renderEdgeQL(expr.__modifiers__.filter, ctx)}`); + } + if (expr.__modifiers__.order_by) { + modifiers.push( + ...expr.__modifiers__.order_by.map( + ({expression, direction, empty}, i) => { + return `${i === 0 ? "ORDER BY" : " THEN"} ${renderEdgeQL( + expression, + ctx + )}${direction ? " " + direction : ""}${empty ? " " + empty : ""}`; + } + ) + ); + } + if (expr.__modifiers__.offset) { + modifiers.push( + `OFFSET ${renderEdgeQL( + expr.__modifiers__.offset as OffsetExpression, + ctx + )}` + ); + } + if (expr.__modifiers__.limit) { + modifiers.push( + `LIMIT ${renderEdgeQL( + expr.__modifiers__.limit as LimitExpression, + ctx + )}` + ); + } + + return ( + withBlock + + lines.join(" ") + + (modifiers.length ? "\n" + modifiers.join("\n") : "") + ); + } else if (expr.__kind__ === ExpressionKind.Update) { + return ( + withBlock + + `UPDATE ${renderEdgeQL(expr.__scope__, ctx, false)}${ + expr.__modifiers__.filter + ? `\nFILTER ${renderEdgeQL(expr.__modifiers__.filter, ctx)}\n` + : " " + }SET ${shapeToEdgeQL(expr.__shape__, ctx)}` + ); + } else if (expr.__kind__ === ExpressionKind.Delete) { + return `DELETE (${renderEdgeQL(expr.__expr__, ctx)})`; + } else if (expr.__kind__ === ExpressionKind.Insert) { + return `INSERT ${renderEdgeQL( + expr.__expr__, + ctx, + false, + true + )} ${shapeToEdgeQL(expr.__shape__, ctx)}`; + } else if (expr.__kind__ === ExpressionKind.InsertUnlessConflict) { + const $on = expr.__conflict__.on; + const $else = expr.__conflict__.else; + const clause: string[] = []; + if (!$on) { + clause.push("\nUNLESS CONFLICT"); + } + if ($on) { + clause.push( + `\nUNLESS CONFLICT ON ${renderEdgeQL($on, ctx, false, true)}` + ); + } + if ($else) { + clause.push(`\nELSE (${renderEdgeQL($else, ctx, true, true)})`); + } + return `${renderEdgeQL(expr.__expr__, ctx, false, true)} ${clause.join( + "" + )}`; + } else if (expr.__kind__ === ExpressionKind.Function) { + const args = expr.__args__.map( + arg => `(${renderEdgeQL(arg!, ctx, false)})` + ); + for (const [key, arg] of Object.entries(expr.__namedargs__)) { + args.push(`${q(key)} := (${renderEdgeQL(arg, ctx, false)})`); + } + return `${expr.__name__}(${args.join(", ")})`; + } else if (expr.__kind__ === ExpressionKind.Operator) { + const operator = expr.__name__; + const args = expr.__args__; + switch (expr.__opkind__) { + case OperatorKind.Infix: + if (operator === "[]") { + let index = ""; + if (Array.isArray(args[1])) { + const [start, end] = args[1]; + if (start) { + index += renderEdgeQL(start, ctx); + } + index += ":"; + if (end) { + index += renderEdgeQL(end, ctx); + } + } else { + index = renderEdgeQL(args[1], ctx); + } + + return `(${renderEdgeQL(args[0], ctx)})[${index}]`; + } + return `(${renderEdgeQL(args[0], ctx)} ${operator} ${renderEdgeQL( + args[1], + ctx + )})`; + case OperatorKind.Postfix: + return `(${renderEdgeQL(args[0], ctx)} ${operator})`; + case OperatorKind.Prefix: + return `(${operator} ${renderEdgeQL(args[0], ctx)})`; + case OperatorKind.Ternary: + if (operator === "if_else") { + return `(${renderEdgeQL(args[0], ctx)} IF ${renderEdgeQL( + args[1], + ctx + )} ELSE ${renderEdgeQL(args[2], ctx)})`; + } else { + throw new Error(`Unknown operator: ${operator}`); + } + default: + util.assertNever( + expr.__opkind__, + new Error(`Unknown operator kind: ${expr.__opkind__}`) + ); + } + } else if (expr.__kind__ === ExpressionKind.TypeIntersection) { + return `${renderEdgeQL(expr.__expr__, ctx)}[IS ${ + expr.__element__.__name__ + }]`; + } else if (expr.__kind__ === ExpressionKind.For) { + ctx.forVars.set(expr.__forVar__, `__forVar__${ctx.forVars.size}`); + return ( + withBlock + + `FOR ${ctx.forVars.get(expr.__forVar__)} IN {${renderEdgeQL( + expr.__iterSet__, + ctx + )}} +UNION (\n${indent(renderEdgeQL(expr.__expr__, ctx), 2)}\n)` + ); + } else if (expr.__kind__ === ExpressionKind.ForVar) { + const forVar = ctx.forVars.get(expr); + if (!forVar) { + throw new Error(`'FOR' loop variable used outside of 'FOR' loop`); + } + return forVar; + } else if (expr.__kind__ === ExpressionKind.Param) { + return `__param__${expr.__name__}`; + } else if (expr.__kind__ === ExpressionKind.Detached) { + return `DETACHED ${renderEdgeQL( + expr.__expr__, + { + ...ctx, + renderWithVar: expr.__expr__ as any, + }, + undefined, + true + )}`; + } else { + util.assertNever( + expr, + new Error(`Unrecognized expression kind: "${(expr as any).__kind__}"`) + ); + } +} + +interface WalkExprTreeCtx { + seen: Map< + SomeExpression, + { + refCount: number; + parentScopes: Set; + childExprs: SomeExpression[]; + boundScope: WithScopeExpr | null; + aliases: SomeExpression[]; + linkProps: $expr_PathLeaf[]; + } + >; + rootScope: WithScopeExpr | null; +} + +function walkExprTree( + _expr: TypeSet, + parentScope: WithScopeExpr | null, + ctx: WalkExprTreeCtx +): SomeExpression[] { + if (!(_expr as any).__kind__) { + throw new Error( + `Expected a valid querybuilder expression, ` + + `instead received ${typeof _expr}${ + typeof _expr !== "undefined" ? `: '${_expr}'` : "" + }.` + + getErrorHint(_expr) + ); + } + const expr = _expr as SomeExpression; + if (!ctx.rootScope && parentScope) { + ctx.rootScope = parentScope; + } + const seenExpr = ctx.seen.get(expr); + if (seenExpr) { + seenExpr.refCount += 1; + seenExpr.parentScopes.add(parentScope); + + return [expr, ...seenExpr.childExprs]; + } else { + const childExprs: SomeExpression[] = []; + ctx.seen.set(expr, { + refCount: 1, + parentScopes: new Set([parentScope]), + childExprs, + boundScope: null, + aliases: [], + linkProps: [], + }); + + switch (expr.__kind__) { + case ExpressionKind.Alias: + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + ctx.seen.get(expr.__expr__ as any)!.aliases.push(expr); + break; + case ExpressionKind.With: + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + for (const refExpr of expr.__refs__) { + walkExprTree(refExpr, expr.__expr__, ctx); + const seenRef = ctx.seen.get(refExpr as any)!; + if (seenRef.boundScope) { + throw new Error(`Expression bound to multiple 'WITH' blocks`); + } + seenRef.boundScope = expr.__expr__; + } + break; + case ExpressionKind.Literal: + case ExpressionKind.ForVar: + case ExpressionKind.Param: + break; + case ExpressionKind.PathLeaf: + case ExpressionKind.PathNode: + if (expr.__parent__) { + childExprs.push( + ...walkExprTree(expr.__parent__.type, parentScope, ctx) + ); + if ( + // is link prop + expr.__kind__ === ExpressionKind.PathLeaf && + expr.__parent__.linkName.startsWith("@") + ) { + ctx.seen.get(expr.__parent__.type as any)?.linkProps.push(expr); + } + } + break; + case ExpressionKind.Cast: + if (expr.__expr__ === null) break; + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + break; + case ExpressionKind.Set: + for (const subExpr of expr.__exprs__) { + childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); + } + break; + case ExpressionKind.Array: + for (const subExpr of expr.__items__) { + childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); + } + break; + case ExpressionKind.Tuple: + for (const subExpr of expr.__items__) { + childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); + } + break; + case ExpressionKind.NamedTuple: + for (const subExpr of Object.values(expr.__shape__)) { + childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); + } + break; + case ExpressionKind.TuplePath: + childExprs.push(...walkExprTree(expr.__parent__, parentScope, ctx)); + break; + case ExpressionKind.Select: + case ExpressionKind.Update: { + const modifiers = expr.__modifiers__; + if (modifiers.filter) { + childExprs.push(...walkExprTree(modifiers.filter, expr, ctx)); + } + if (modifiers.order_by) { + for (const orderExpr of modifiers.order_by) { + childExprs.push(...walkExprTree(orderExpr.expression, expr, ctx)); + } + } + if (modifiers.offset) { + childExprs.push(...walkExprTree(modifiers.offset!, expr, ctx)); + } + if (modifiers.limit) { + childExprs.push(...walkExprTree(modifiers.limit!, expr, ctx)); + } + + if (expr.__kind__ === ExpressionKind.Select) { + if (isObjectType(expr.__element__)) { + const walkShape = (shape: object) => { + for (let param of Object.values(shape)) { + if (param.__kind__ === ExpressionKind.PolyShapeElement) { + param = param.__shapeElement__; + } + if (typeof param === "object") { + if (!!(param as any).__kind__) { + childExprs.push(...walkExprTree(param as any, expr, ctx)); + } else { + walkShape(param); + } + } + } + }; + walkShape(expr.__element__.__shape__ ?? {}); + } + } else { + // Update + const shape: any = expr.__shape__ ?? {}; + + for (const _element of Object.values(shape)) { + let element: any = _element; + if (!element.__element__) { + if (element["+="]) element = element["+="]; + else if (element["-="]) element = element["-="]; + } + childExprs.push(...walkExprTree(element as any, expr, ctx)); + } + } + + childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); + break; + } + case ExpressionKind.Delete: { + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + break; + } + case ExpressionKind.Insert: { + const shape: any = expr.__shape__ ?? {}; + + for (const element of Object.values(shape)) { + childExprs.push(...walkExprTree(element as any, expr, ctx)); + } + + childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); + break; + } + case ExpressionKind.InsertUnlessConflict: { + if (expr.__conflict__.on) { + childExprs.push(...walkExprTree(expr.__conflict__.on, expr, ctx)); + } + if (expr.__conflict__.else) { + childExprs.push(...walkExprTree(expr.__conflict__.else, expr, ctx)); + } + + childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); + break; + } + case ExpressionKind.TypeIntersection: + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + break; + case ExpressionKind.Operator: + case ExpressionKind.Function: + for (const subExpr of expr.__args__) { + if (Array.isArray(subExpr)) { + for (const arg of subExpr) { + if (arg) childExprs.push(...walkExprTree(arg, parentScope, ctx)); + } + } else { + childExprs.push(...walkExprTree(subExpr!, parentScope, ctx)); + } + } + if (expr.__kind__ === ExpressionKind.Function) { + for (const subExpr of Object.values(expr.__namedargs__)) { + childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); + } + } + break; + case ExpressionKind.For: { + childExprs.push(...walkExprTree(expr.__iterSet__ as any, expr, ctx)); + childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); + break; + } + case ExpressionKind.WithParams: { + if (parentScope !== null) { + throw new Error( + `'withParams' does not support being used as a nested expression` + ); + } + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + break; + } + case ExpressionKind.Detached: { + childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); + break; + } + default: + util.assertNever( + expr, + new Error( + `Unrecognized expression kind: "${(expr as any).__kind__}"` + ) + ); + } + + return [expr, ...childExprs]; + } +} + +const numericalTypes: Record = { + "std::number": true, + "std::int16": true, + "std::int32": true, + "std::int64": true, + "std::float32": true, + "std::float64": true, +}; + +function literalToEdgeQL(type: BaseType, val: any): string { + let skipCast = false; + let stringRep; + if (typeof val === "string") { + if (numericalTypes[type.__name__]) { + skipCast = true; + stringRep = val; + } else if (type.__name__ === "std::json") { + skipCast = true; + stringRep = `to_json(${JSON.stringify(val)})`; + } else { + if (type.__name__ === "std::str") { + skipCast = true; + } + stringRep = JSON.stringify(val); + } + } else if (typeof val === "number") { + if (numericalTypes[type.__name__]) { + skipCast = true; + } else { + throw new Error(`Unknown numerical type: ${type.__name__}!`); + } + stringRep = `${val.toString()}`; + } else if (typeof val === "boolean") { + stringRep = `${val.toString()}`; + skipCast = true; + } else if (typeof val === "bigint") { + stringRep = `${val.toString()}n`; + } else if (Array.isArray(val)) { + skipCast = true; + if (isArrayType(type)) { + stringRep = `[${val + .map(el => literalToEdgeQL(type.__element__ as any, el)) + .join(", ")}]`; + } else if (isTupleType(type)) { + stringRep = `( ${val + .map((el, j) => literalToEdgeQL(type.__items__[j] as any, el)) + .join(", ")} )`; + } else { + throw new Error(`Invalid value for type ${type.__name__}`); + } + } else if (val instanceof Date) { + stringRep = `'${val.toISOString()}'`; + } else if ( + val instanceof LocalDate || + val instanceof LocalDateTime || + val instanceof LocalTime || + val instanceof Duration || + val instanceof RelativeDuration + ) { + stringRep = `'${val.toString()}'`; + } else if (val instanceof Buffer) { + stringRep = bufferToStringRep(val); + skipCast = true; + } else if (typeof val === "object") { + if (isNamedTupleType(type)) { + stringRep = `( ${Object.entries(val).map( + ([key, value]) => + `${key} := ${literalToEdgeQL(type.__shape__[key], value)}` + )} )`; + skipCast = true; + } else { + throw new Error(`Invalid value for type ${type.__name__}`); + } + } else { + throw new Error(`Invalid value for type ${type.__name__}`); + } + if (skipCast) { + return stringRep; + } + return `<${type.__name__}>${stringRep}`; +} + +function indent(str: string, depth: number) { + return str + .split("\n") + .map(line => " ".repeat(depth) + line) + .join("\n"); +} + +// backtick quote identifiers if needed +// https://github.com/edgedb/edgedb/blob/master/edb/edgeql/quote.py +function q(ident: string, allowReserved: boolean = false): string { + if ( + !ident || + ident.startsWith("@") || + ident.includes("::") || + ident.startsWith("<") // backlink + ) { + return ident; + } + + const isAlphaNum = /^([^\W\d]\w*|([1-9]\d*|0))$/.test(ident); + + const lident = ident.toLowerCase(); + + const isReserved = + lident !== "__type__" && + lident !== "__std__" && + reservedKeywords.includes(lident); + + if (isAlphaNum && (allowReserved || !isReserved)) { + return ident; + } + + return "`" + ident.replace(/`/g, "``") + "`"; +} + +function bufferToStringRep(buf: Buffer): string { + let stringRep = ""; + for (const byte of buf) { + if (byte < 32 || byte > 126) { + // non printable ascii + switch (byte) { + case 8: + stringRep += "\\b"; + break; + case 9: + stringRep += "\\t"; + break; + case 10: + stringRep += "\\n"; + break; + case 12: + stringRep += "\\f"; + break; + case 13: + stringRep += "\\r"; + break; + default: + stringRep += `\\x${byte.toString(16).padStart(2, "0")}`; + } + } else { + stringRep += + (byte === 39 || byte === 92 ? "\\" : "") + String.fromCharCode(byte); + } + } + return `b'${stringRep}'`; +} + +function getErrorHint(expr: any): string { + let literalConstructor: string | null = null; + switch (typeof expr) { + case "string": + literalConstructor = "e.str()"; + break; + case "number": + literalConstructor = Number.isInteger(expr) + ? "e.int64()" + : "e.float64()"; + break; + case "bigint": + literalConstructor = "e.bigint()"; + break; + case "boolean": + literalConstructor = "e.bool()"; + break; + } + switch (true) { + case expr instanceof Date: + literalConstructor = "e.datetime()"; + break; + case expr instanceof Duration: + literalConstructor = "e.duration()"; + break; + case expr instanceof LocalDate: + literalConstructor = "e.cal.local_date()"; + break; + case expr instanceof LocalDateTime: + literalConstructor = "e.cal.local_datetime()"; + break; + case expr instanceof LocalTime: + literalConstructor = "e.cal.local_time()"; + break; + case expr instanceof RelativeDuration: + literalConstructor = "e.cal.relative_duration()"; + break; + } + + return literalConstructor + ? `\nHint: Maybe you meant to wrap the value in ` + + `a '${literalConstructor}' expression?` + : ""; +} diff --git a/qb/dbschema/edgeql-js/syntax/update.ts b/qb/dbschema/edgeql-js/syntax/update.ts new file mode 100644 index 000000000..893884705 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/update.ts @@ -0,0 +1,127 @@ +import { + Expression, + ExpressionKind, + ObjectTypePointers, + TypeSet, + ObjectTypeSet, + stripBacklinks, + stripNonWritables, + typeutil, + ObjectTypeExpression, + $scopify, + Cardinality, +} from "edgedb/dist/reflection"; +import type {pointerToAssignmentExpression} from "./casting"; +import {$expressionify, $getScopedExpr} from "./path"; +import { + SelectModifiers, + NormalisedSelectModifiers, + ComputeSelectCardinality, + $existingScopes, + $handleModifiers, +} from "./select"; +import {$normaliseInsertShape, pointerIsOptional} from "./insert"; + +///////////////// +/// UPDATE +///////////////// + +export type $expr_Update< + Set extends TypeSet = TypeSet, + Expr extends ObjectTypeSet = ObjectTypeSet, + Shape extends UpdateShape = any +> = Expression<{ + __kind__: ExpressionKind.Update; + __element__: Set["__element__"]; + __cardinality__: Set["__cardinality__"]; + __expr__: Expr; + __shape__: Shape; + __modifiers__: NormalisedSelectModifiers; + __scope__: ObjectTypeExpression; +}>; + +export type UpdateShape = typeutil.stripNever< + stripNonWritables> +> extends infer Shape + ? Shape extends ObjectTypePointers + ? { + [k in keyof Shape]?: + | (pointerToAssignmentExpression extends infer S + ? + | S + | (Shape[k]["cardinality"] extends + | Cardinality.Many + | Cardinality.AtLeastOne + ? {"+=": S} | {"-=": S} + : never) + : never) + | (pointerIsOptional extends true + ? undefined | null + : never); + } + : never + : never; + +export function update< + Expr extends ObjectTypeExpression, + Shape extends { + filter?: SelectModifiers["filter"]; + order_by?: SelectModifiers["order_by"]; + limit?: SelectModifiers["limit"]; + offset?: SelectModifiers["offset"]; + set: UpdateShape; + } + // SetShape extends UpdateShape, + // Modifiers extends Pick +>( + expr: Expr, + shape: (scope: $scopify) => Readonly +): $expr_Update< + { + __element__: Expr["__element__"]; + __cardinality__: ComputeSelectCardinality; + }, + Expr, + Shape["set"] +> { + const cleanScopedExprs = $existingScopes.size === 0; + + const scope = $getScopedExpr(expr as any, $existingScopes); + + const resolvedShape = shape(scope); + + if (cleanScopedExprs) { + $existingScopes.clear(); + } + + const mods: any = {}; + let updateShape: any | null; + for (const [key, val] of Object.entries(resolvedShape)) { + if (key === "filter") { + mods[key] = val; + } else if (key === "set") { + updateShape = val; + } else { + throw new Error( + `Invalid update shape key '${key}', only 'filter', ` + + `and 'set' are allowed` + ); + } + } + + if (!updateShape) { + throw new Error(`Update shape must contain 'set' shape`); + } + + const {modifiers, cardinality} = $handleModifiers(mods, expr); + + return $expressionify({ + __kind__: ExpressionKind.Update, + __element__: expr.__element__, + __cardinality__: cardinality, + __expr__: expr, + __shape__: $normaliseInsertShape(expr, updateShape, true), + __modifiers__: modifiers, + __scope__: scope, + }) as any; +} diff --git a/qb/dbschema/edgeql-js/syntax/with.ts b/qb/dbschema/edgeql-js/syntax/with.ts new file mode 100644 index 000000000..6ed394cf6 --- /dev/null +++ b/qb/dbschema/edgeql-js/syntax/with.ts @@ -0,0 +1,54 @@ +import {Expression, ExpressionKind, TypeSet} from "edgedb/dist/reflection"; +import {$expr_Select} from "./select"; +import {$expr_For} from "./for"; +import {$expr_Insert} from "./insert"; +import {$expr_Update} from "./update"; +import {$expressionify} from "./path"; + +export type $expr_Alias = Expression<{ + __element__: Expr["__element__"]; + __cardinality__: Expr["__cardinality__"]; + __kind__: ExpressionKind.Alias; + __expr__: Expr; +}>; + +export function alias(expr: Expr): $expr_Alias { + return $expressionify({ + __kind__: ExpressionKind.Alias, + __element__: expr.__element__, + __cardinality__: expr.__cardinality__, + __expr__: expr, + }) as any; +} + +export type WithableExpression = + | $expr_Select + | $expr_For + | $expr_Insert + | $expr_Update; + +export type $expr_With< + Refs extends TypeSet[] = TypeSet[], + Expr extends WithableExpression = WithableExpression +> = Expression<{ + __element__: Expr["__element__"]; + __cardinality__: Expr["__cardinality__"]; + __kind__: ExpressionKind.With; + __expr__: Expr; + __refs__: Refs; +}>; + +function _with( + refs: Refs, + expr: Expr +): $expr_With { + return $expressionify({ + __kind__: ExpressionKind.With, + __element__: expr.__element__, + __cardinality__: expr.__cardinality__, + __refs__: refs, + __expr__: expr as any, + }) as any; +} + +export {_with as with}; diff --git a/qb/dbschema/migrations/00001.edgeql b/qb/dbschema/migrations/00001.edgeql index a2fb28799..6ecdb23ce 100644 --- a/qb/dbschema/migrations/00001.edgeql +++ b/qb/dbschema/migrations/00001.edgeql @@ -100,7 +100,7 @@ CREATE MIGRATION m1qxdmnjre6ij6fj5u7qyvwkzcdgg33qygdldy6ntl6o24ls7yq5xa CREATE LINK nemesis -> default::Hero; }; ALTER TYPE default::Hero { - CREATE MULTI LINK villains := (. std::int16 { + SET default := (std::datetime_get(std::datetime_current(), 'year')); + }; + }; +}; diff --git a/qb/package.json b/qb/package.json index 85f792bb6..11d6b6e23 100644 --- a/qb/package.json +++ b/qb/package.json @@ -7,10 +7,11 @@ "scripts": { "test": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --detectOpenHandles --forceExit", "test:ci": "ts-node test/testRunner.ts", - "generate": "edgedb-generate", + "generate": "edgeql-js", "play": "ts-node playground.ts --project tsconfig.json --trace-warnings", "play:dev": "nodemon -e ts -w . -x ts-node playground.ts --project tsconfig.json --trace-warnings", - "build": "tsc --project tsconfig.build.json" + "build": "tsc --project tsconfig.build.json", + "build:trace": "tsc --project tsconfig.build.json --generateTrace trace" }, "keywords": [], "author": "Colin McDonnell", diff --git a/qb/playground.ts b/qb/playground.ts index 6be856a5f..b8ac6a716 100644 --- a/qb/playground.ts +++ b/qb/playground.ts @@ -1,276 +1,298 @@ // tslint:disable:no-console -import {$} from "edgedb"; -import type {$Movie} from "./dbschema/edgeql/modules/default"; -import type {pointersToSelectShape} from "./dbschema/edgeql/syntax/select"; - -import e from "./dbschema/edgeql"; +import * as edgedb from "edgedb"; +import type {$Movie} from "./dbschema/edgeql-js/modules/default"; +import type {pointersToSelectShape} from "./dbschema/edgeql-js/syntax/select"; import {setupTests} from "./test/setupTeardown"; +import e from "./dbschema/edgeql-js"; + async function run() { - // const asdf = e.tuple([e.str, e.int64]); const {client} = await setupTests(); - const backlinkQuery = await e.select( - e.Hero[" ({ - id: true, - title: true, - }) - ); - console.log(`QUERY`); - console.log(backlinkQuery.toEdgeQL()); - const result = await backlinkQuery.run(client); + const query = e.to_str(e.int64(123), undefined); + console.log(query.toEdgeQL()); + const result = await query.run(client); console.log(result); - if (1 > 0) return; + // const querr = e.array([1, 2, 3]); + // const querr2 = querr[0]; + + // console.log(querr.toEdgeQL()); + + // // const lkj = e.set("asdf", e.Hero.name); + // if (1 > 0) return; + + // const backlinkQuery = await e.select( + // e.Hero[" ({ + // id: true, + // title: true, + // }) + // ); + + // console.log(`QUERY`); + // console.log(backlinkQuery.toEdgeQL()); + // const result = await backlinkQuery.run(client); + // console.log(result); + + // if (1 > 0) return; - console.log(`asdf`); + // console.log(`asdf`); - console.log(e.Hero.__element__.__pointers__.villains.properties); + // console.log(e.Hero.__element__.__pointers__.villains.properties); - console.log(await e.select(e.int16(5)).run(client)); - console.log( - await e - .select(e.Hero, hero => ({filter: e.eq(hero.name, e.str("Loki"))})) - .run(client) - ); - console.log( - await e - .select(e.Hero, hero => ({filter: e.eq(hero.name, e.str("Loki"))})) - .update({number_of_movies: e.int16(5)}) - .run(client) - ); - console.log( - await e - .select(e.Hero, hero => ({filter: e.eq(hero.name, e.str("Loki"))})) - .delete() - .run(client) - ); + // console.log(await e.select(e.int64(5)).run(client)); + // console.log( + // await e + // .select(e.Hero, hero => ({filter: e.op(hero.name, "=", e.str("Loki"))})) + // .run(client) + // ); + // console.log( + // await e + // .update(e.Hero, hero => ({ + // filter: e.op(hero.name, "=", e.str("Loki")), + // set: {number_of_movies: 5}, + // })) + // // .update({number_of_movies: e.int64(5)}) + // .run(client) + // ); + // console.log( + // await e + // .select(e.Hero, hero => ({filter: e.op(hero.name, "=", e.str("Loki"))})) + // // .delete() + // .run(client) + // ); - console.log(await e.insert(e.Hero, {name: e.str("Loki")}).run(client)); - console.log( - await e - .insert(e.Hero, {name: e.str("Loki")}) - .unlessConflict() - .run(client) - ); + // console.log(await e.insert(e.Hero, {name: e.str("Loki")}).run(client)); + // console.log( + // await e + // .insert(e.Hero, {name: e.str("Loki")}) + // .unlessConflict() + // .run(client) + // ); - console.log(await e.for(e.Hero, hero => hero.name).run(client)); + // console.log(await e.for(e.Hero, hero => hero.name).run(client)); - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + // const numbers = e.set(1, 2, 3); - console.log(await e.with([numbers], e.select(numbers)).run(client)); + // console.log(await e.with([numbers], e.select(numbers)).run(client)); - console.log( - await e - .withParams( - { - str: e.str, - numArr: e.array(e.int64), - optBool: e.optional(e.bool), - }, - params => - e.select({ - str: params.str, - nums: e.array_unpack(params.numArr), - x: e.if_else(e.str("true"), params.optBool, e.str("false")), - }) - ) - .run(client, {numArr: [7], str: "test"}) - ); + // console.log( + // await e + // .params( + // { + // str: e.str, + // numArr: e.array(e.int64), + // optBool: e.optional(e.bool), + // }, + // params => + // e.select({ + // str: params.str, + // nums: e.array_unpack(params.numArr), + // x: e.op( + // e.str("true"), + // "if", + // params.optBool, + // "else", + // e.str("false") + // ), + // }) + // ) + // .run(client, {numArr: [7], str: "test"}) + // ); - client.close(); + // client.close(); - e.is(e.Villain, { - // id: true, - id: true, - name: true, - nemesis: hero => ({ - id: true, - secret_identity: true, - number_of_movies: true, - " ({ + // id: true, + // secret_identity: true, + // number_of_movies: true, + // "; - type moviepointers = $Movie["__pointers__"]; - type charfields = pointersToSelectShape< - moviepointers["characters"]["target"]["__pointers__"] & - moviepointers["characters"]["properties"] - >; - type charfield = charfields["@character_name"]; + // type arg = pointersToSelectShape; + // type moviepointers = $Movie["__pointers__"]; + // type charfields = pointersToSelectShape< + // moviepointers["characters"]["target"]["__pointers__"] & + // moviepointers["characters"]["properties"] + // >; + // type charfield = charfields["@character_name"]; - const arg = e.is(e.Movie, { - characters: char => ({ - "@character_name": true, - }), - }); + // const arg = e.is(e.Movie, { + // characters: char => ({ + // "@character_name": true, + // }), + // }); - const arg2 = e.is(e.Movie, { - characters: { - "@character_name": true, - }, - }); + // const arg2 = e.is(e.Movie, { + // characters: { + // "@character_name": true, + // }, + // }); - const nested = e.select(e.Object, movie => ({ - id: true, - ...e.is(e.Movie, { - characters: { - "@character_name": true, - }, - }), - })); - const chars = nested.__element__.__shape__.characters; - type nested = $.setToTsType; + // const nested = e.select(e.Object, movie => ({ + // id: true, + // ...e.is(e.Movie, { + // characters: { + // "@character_name": true, + // }, + // }), + // })); + // const chars = nested.__element__.__shape__.characters; + // type nested = $.setToTsType; - console.log(nested.toEdgeQL()); + // console.log(nested.toEdgeQL()); - const q = e.select(e.Hero, hero => ({ - id: true, - "; + // const q = e.select(e.Hero, hero => ({ + // id: true, + // "; - const val1 = e - .insert(e.Hero, { - name: e.str("Pepper Potts"), - }) - .unlessConflict(); - console.log(`\nVAL 1`); - console.log(val1.toEdgeQL()); + // const val1 = e + // .insert(e.Hero, { + // name: e.str("Pepper Potts"), + // }) + // .unlessConflict(); + // console.log(`\nVAL 1`); + // console.log(val1.toEdgeQL()); - const val2 = e - .insert(e.Hero, { - name: e.str("Pepper Potts"), - }) - .unlessConflict(hero => ({on: hero.name})); - console.log(`\nVAL 2`); - console.log(val2.toEdgeQL()); + // const val2 = e + // .insert(e.Hero, { + // name: e.str("Pepper Potts"), + // }) + // .unlessConflict(hero => ({on: hero.name})); + // console.log(`\nVAL 2`); + // console.log(val2.toEdgeQL()); - const val3 = e - .insert(e.Hero, { - name: e.str("Pepper Potts"), - }) - .unlessConflict(hero => ({ - on: hero.name, - else: e.select(hero, () => ({ - id: true, - secret_identity: true, - })), - })); - console.log(`\nVAL 3`); - console.log(val3.toEdgeQL()); + // const val3 = e + // .insert(e.Hero, { + // name: e.str("Pepper Potts"), + // }) + // .unlessConflict(hero => ({ + // on: hero.name, + // else: e.select(hero, () => ({ + // id: true, + // secret_identity: true, + // })), + // })); + // console.log(`\nVAL 3`); + // console.log(val3.toEdgeQL()); - const q3 = e.select(e.Hero, hero => ({ - id: true, - q, - })); - type q3 = $.setToTsType; - const q4 = e.select(e.Person, person => ({ - id: true, - q: q3, - ...e.is(e.Hero, { - secret_identity: true, - }), - ...e.is(e.Villain, { - nemesis: {id: true, computable: e.int64(1234)}, - computable: e.int64(1234), - }), - })); - type q4 = $.setToTsType; - const q5 = e.select(e.Hero, hero => ({ - id: true, - q: q4, - ...e.is(e.Villain, { - // id: true, - nemesis: {id: true}, - computable: e.int64(1234), - }), - })); - type q5 = $.setToTsType; - const q6 = e.select(e.Hero, hero => ({ - id: true, - q: q5, - ...e.is(e.Villain, { - nemesis: {id: true}, - computable: e.insert(e.Villain, {name: e.str("Loki")}), - }), - })); + // const q3 = e.select(e.Hero, hero => ({ + // id: true, + // q, + // })); + // type q3 = $.setToTsType; + // const q4 = e.select(e.Person, person => ({ + // id: true, + // q: q3, + // ...e.is(e.Hero, { + // secret_identity: true, + // }), + // ...e.is(e.Villain, { + // nemesis: {id: true, computable: e.int64(1234)}, + // computable: e.int64(1234), + // }), + // })); + // type q4 = $.setToTsType; + // const q5 = e.select(e.Hero, hero => ({ + // id: true, + // q: q4, + // ...e.is(e.Villain, { + // // id: true, + // nemesis: {id: true}, + // computable: e.int64(1234), + // }), + // })); + // type q5 = $.setToTsType; + // const q6 = e.select(e.Hero, hero => ({ + // id: true, + // q: q5, + // ...e.is(e.Villain, { + // nemesis: {id: true}, + // computable: e.insert(e.Villain, {name: e.str("Loki")}), + // }), + // })); - type q6 = $.setToTsType; - const q7 = e.select(e.Hero, hero => ({ - id: true, - q: q6, - ...e.is(e.Villain, { - nemesis: {id: true}, - computable: e.select( - e.insert(e.Villain, {name: e.str("Loki")}), - villain => ({ - name: true, - id: true, - }) - ), - }), - })); - type q7 = $.setToTsType; - const q8 = e.select(e.Hero, hero => ({ - id: true, - q: q7, - "; - const q9 = e.select(e.Hero, hero => ({ - id: true, - q: q8, - ...e.is(e.Villain, { - // id: true, - nemesis: {id: true}, - computable: e.int64(1234), - }), - })); - type q9 = $.setToTsType; - const q10 = e.select(e.Hero, hero => ({ - id: true, - q: q9, - ...e.is(e.Villain, { - nemesis: {id: true}, - }), - })); - type q10 = $.setToTsType; - const q11 = e.select(e.Hero, hero => ({ - id: true, - q: q10, - computable: e.select(e.Hero), - })); - type q11 = $.setToTsType; - const q12 = e.select(e.Hero, hero => ({ - id: false, - q: q11, - })); - type q12 = $.setToTsType; - const _q13 = e.select(e.Hero, hero => ({ - id: 1 > 0, - q: q12, - })); - type _q13 = $.setToTsType; + // type q6 = $.setToTsType; + // const q7 = e.select(e.Hero, hero => ({ + // id: true, + // q: q6, + // ...e.is(e.Villain, { + // nemesis: {id: true}, + // computable: e.select( + // e.insert(e.Villain, {name: e.str("Loki")}), + // villain => ({ + // name: true, + // id: true, + // }) + // ), + // }), + // })); + // type q7 = $.setToTsType; + // const q8 = e.select(e.Hero, hero => ({ + // id: true, + // q: q7, + // "; + // const q9 = e.select(e.Hero, hero => ({ + // id: true, + // q: q8, + // ...e.is(e.Villain, { + // // id: true, + // nemesis: {id: true}, + // computable: e.int64(1234), + // }), + // })); + // type q9 = $.setToTsType; + // const q10 = e.select(e.Hero, hero => ({ + // id: true, + // q: q9, + // ...e.is(e.Villain, { + // nemesis: {id: true}, + // }), + // })); + // type q10 = $.setToTsType; + // const q11 = e.select(e.Hero, hero => ({ + // id: true, + // q: q10, + // computable: e.select(e.Hero), + // })); + // type q11 = $.setToTsType; + // const q12 = e.select(e.Hero, hero => ({ + // id: false, + // q: q11, + // })); + // type q12 = $.setToTsType; + // const _q13 = e.select(e.Hero, hero => ({ + // id: 1 > 0, + // q: q12, + // })); + // type _q13 = $.setToTsType; } run(); diff --git a/qb/test/casts.test.ts b/qb/test/casts.test.ts index 2d2a5235a..f927e725c 100644 --- a/qb/test/casts.test.ts +++ b/qb/test/casts.test.ts @@ -1,10 +1,11 @@ -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; +import {$number} from "../dbschema/edgeql-js/modules/std"; import {tc} from "./setupTeardown"; test("casting", () => { const primitiveCast = e.cast(e.float32, e.float64(3.14)); - tc.assert>( - true - ); - expect(primitiveCast.toEdgeQL()).toEqual(`3.14`); + tc.assert< + tc.IsExact + >(true); + expect(primitiveCast.toEdgeQL()).toEqual(`(3.14)`); }); diff --git a/qb/test/collections.test.ts b/qb/test/collections.test.ts index af2990714..ad23f8f8f 100644 --- a/qb/test/collections.test.ts +++ b/qb/test/collections.test.ts @@ -1,6 +1,7 @@ import {Client, $} from "edgedb"; -// import {$} from "edgedb"; -import e, {$infer} from "../dbschema/edgeql"; +import e, {$infer} from "../dbschema/edgeql-js"; + +import {$VersionStageλEnum} from "../dbschema/edgeql-js/modules/sys"; import {tc} from "./setupTeardown"; import {setupTests, teardownTests, TestData} from "./setupTeardown"; @@ -23,7 +24,7 @@ test("array literal", async () => { expect(strArrayType.__element__.__kind__).toEqual($.TypeKind.scalar); expect(strArrayType.__element__.__name__).toEqual("std::str"); - const arg = e.array([e.str("asdf"), e.str("qwer")]); + const arg = e.array(["asdf", e.str("qwer")]); type arg = $.setToTsType; tc.assert>(true); expect(arg.__kind__).toEqual($.ExpressionKind.Array); @@ -31,14 +32,25 @@ test("array literal", async () => { expect(arg.__cardinality__).toEqual($.Cardinality.One); expect(arg.__element__.__element__.__kind__).toEqual($.TypeKind.scalar); expect(arg.__element__.__element__.__name__).toEqual("std::str"); - const result = await client.querySingle(e.select(arg).toEdgeQL()); expect(result).toEqual(["asdf", "qwer"]); - const multiArray = e.array([ - e.str("asdf"), - e.set(e.str("qwer"), e.str("erty")), - ]); + const arg1 = arg[1]; + tc.assert>( + true + ); + expect(arg1.__kind__).toEqual($.ExpressionKind.Operator); + tc.assert>( + true + ); + expect(arg1.__cardinality__).toEqual($.Cardinality.One); + tc.assert>( + true + ); + expect(arg1.__element__.__name__).toEqual("std::str"); + expect(await e.select(arg1).run(client)).toEqual("qwer"); + + const multiArray = e.array(["asdf", e.set(e.str("qwer"), e.str("erty"))]); type multiArray = $.setToTsType; tc.assert>(true); @@ -55,6 +67,57 @@ test("array literal", async () => { ["asdf", "qwer"], ["asdf", "erty"], ]); + + const multi0 = multiArray[0]; + tc.assert< + tc.IsExact + >(true); + expect(multi0.__cardinality__).toEqual($.Cardinality.AtLeastOne); + expect(await e.select(multi0).run(client)).toEqual(["asdf", "asdf"]); + + // array slicing + const arr = e.str_split(e.str("zxcvbnm"), e.str("")); + const sliceResult = await e + .select({ + reverseIndex: arr["-2"], + slice24: arr["2:4"], + slice2: arr["2:"], + slice4: arr[":4"], + reverseSlice2: arr["-2:"], + reverseSlice4: arr[":-4"], + reverseSlice24: arr["-4:-2"], + }) + .run(client); + tc.assert< + tc.IsExact< + typeof sliceResult, + { + reverseIndex: string; + slice24: string[]; + slice2: string[]; + slice4: string[]; + reverseSlice2: string[]; + reverseSlice4: string[]; + reverseSlice24: string[]; + } + > + >(true); + expect(JSON.stringify(sliceResult)).toEqual( + JSON.stringify({ + reverseIndex: "n", + slice24: ["c", "v"], + slice2: ["c", "v", "b", "n", "m"], + slice4: ["z", "x", "c", "v"], + reverseSlice2: ["n", "m"], + reverseSlice4: ["z", "x", "c"], + reverseSlice24: ["v", "b"], + }) + ); + + // @ts-expect-error + arr["str"]; + // @ts-expect-error + arr[":"]; }); test("tuple literal", async () => { @@ -65,25 +128,30 @@ test("tuple literal", async () => { expect(tupleType.__items__[1].__kind__).toEqual($.TypeKind.scalar); expect(tupleType.__items__[1].__name__).toEqual("std::int64"); - const myTuple = e.tuple([e.str("asdf"), e.int64(45)]); + const myTuple = e.tuple(["asdf", 45]); type myTuple = $.setToTsType; tc.assert>(true); expect(myTuple.__element__.__kind__).toEqual($.TypeKind.tuple); expect(myTuple.__element__.__items__[0].__kind__).toEqual($.TypeKind.scalar); expect(myTuple.__element__.__items__[0].__name__).toEqual("std::str"); expect(myTuple.__element__.__items__[1].__kind__).toEqual($.TypeKind.scalar); - expect(myTuple.__element__.__items__[1].__name__).toEqual("std::int64"); + expect(myTuple.__element__.__items__[1].__name__).toEqual("std::number"); const myTupleResult = await client.querySingle(e.select(myTuple).toEdgeQL()); expect(myTupleResult).toEqual(["asdf", 45]); + const myTuplePath0 = myTuple[0]; + const myTuplePath1 = myTuple[1]; + tc.assert, string>>(true); + tc.assert, number>>(true); + expect(await e.select(myTuplePath0).run(client)).toEqual("asdf"); + expect(await e.select(myTuplePath1).run(client)).toEqual(45); - const multiTuple = e.tuple([ - e.str("asdf"), - e.set(e.str("qwer"), e.str("erty")), - ]); - type multiTuple = $.setToTsType; - tc.assert>( - true - ); + const multiTuple = e.tuple(["asdf", e.set(e.str("qwer"), e.str("erty"))]); + tc.assert< + tc.IsExact< + $infer, + [[string, string], ...[string, string][]] + > + >(true); expect(multiTuple.__kind__).toEqual($.ExpressionKind.Tuple); expect(multiTuple.__element__.__kind__).toEqual($.TypeKind.tuple); expect(multiTuple.__cardinality__).toEqual($.Cardinality.AtLeastOne); @@ -97,6 +165,18 @@ test("tuple literal", async () => { ["asdf", "qwer"], ["asdf", "erty"], ]); + const multiTuplePath = multiTuple[0]; + tc.assert, [string, ...string[]]>>( + true + ); + tc.assert< + tc.IsExact< + typeof multiTuplePath["__cardinality__"], + $.Cardinality.AtLeastOne + > + >(true); + expect(multiTuplePath.__cardinality__).toEqual($.Cardinality.AtLeastOne); + expect(await e.select(multiTuplePath).run(client)).toEqual(["asdf", "asdf"]); const singleTuple = e.tuple([e.str("asdf")]); type singleTuple = $infer; @@ -111,6 +191,51 @@ test("tuple literal", async () => { ); expect(singleTupleResult).toEqual(["asdf"]); + const nestedTuple = e.tuple([ + "a", + e.tuple(["b", e.set(e.str("c"), e.str("d"))]), + ]); + type nestedTuple = $infer; + tc.assert< + tc.IsExact< + nestedTuple, + [[string, [string, string]], ...[string, [string, string]][]] + > + >(true); + const nestedTupleResult = await e.select(nestedTuple).run(client); + expect(nestedTupleResult).toEqual([ + ["a", ["b", "c"]], + ["a", ["b", "d"]], + ]); + const nestedTuplePathResult = await e + .select({ + tup0: nestedTuple[0], + tup1: nestedTuple[1], + tup10: nestedTuple[1][0], + tup11: nestedTuple[1][1], + }) + .run(client); + tc.assert< + tc.IsExact< + typeof nestedTuplePathResult, + { + tup0: [string, ...string[]]; + tup1: [[string, string], ...[string, string][]]; + tup10: [string, ...string[]]; + tup11: [string, ...string[]]; + } + > + >(true); + expect(JSON.parse(JSON.stringify(nestedTuplePathResult))).toEqual({ + tup0: ["a", "a"], + tup1: [ + ["b", "c"], + ["b", "d"], + ], + tup10: ["b", "b"], + tup11: ["c", "d"], + }); + const heroNamesTuple = e.tuple([e.Hero.name]); type heroNamesTuple = $infer; tc.assert>(true); @@ -130,7 +255,7 @@ test("tuple literal", async () => { }); test("namedTuple literal", async () => { - const tupleType = e.namedTuple({ + const tupleType = e.tuple({ string: e.str, number: e.int64, }); @@ -140,9 +265,9 @@ test("namedTuple literal", async () => { expect(tupleType.__shape__.number.__kind__).toEqual($.TypeKind.scalar); expect(tupleType.__shape__.number.__name__).toEqual("std::int64"); - const named = e.namedTuple({ - string: e.str("asdf"), - number: e.int64(1234), + const named = e.tuple({ + string: "asdf", + number: 1234, }); type named = $.setToTsType; @@ -161,18 +286,69 @@ test("namedTuple literal", async () => { expect(named.__element__.__shape__.number.__kind__).toEqual( $.TypeKind.scalar ); - expect(named.__element__.__shape__.number.__name__).toEqual("std::int64"); + expect(named.__element__.__shape__.number.__name__).toEqual("std::number"); const namedResult = await client.querySingle(e.select(named).toEdgeQL()); expect(JSON.stringify(namedResult)).toEqual( JSON.stringify({string: "asdf", number: 1234}) ); + const namedStr = named.string; + const namedNum = named.number; + tc.assert, string>>(true); + tc.assert, number>>(true); + expect(await e.select(namedStr).run(client)).toEqual("asdf"); + expect(await e.select(namedNum).run(client)).toEqual(1234); - const emptyNamedTuple = e.namedTuple({string: e.set(e.str)}); + const nested = e.tuple({ + a: "asdf", + named: e.tuple({b: 123}), + tuple: e.tuple([true, e.set(e.str("x"), e.str("y"))]), + }); + const nestedResult = await e + .select({ + nested: nested, + nestedA: nested.a, + nestedNamed: nested.named, + nestedTuple: nested.tuple, + nestedTuple0: nested.tuple[0], + nestedTuple1: nested.tuple[1], + }) + .run(client); + tc.assert< + tc.IsExact< + typeof nestedResult, + { + nested: {a: string; named: {b: number}; tuple: [boolean, string]}[]; + nestedA: string[]; + nestedNamed: {b: number}[]; + nestedTuple: [boolean, string][]; + nestedTuple0: boolean[]; + nestedTuple1: string[]; + } + > + >(true); + expect(JSON.stringify(nestedResult)).toEqual( + JSON.stringify({ + nested: [ + {a: "asdf", named: {b: 123}, tuple: [true, "x"]}, + {a: "asdf", named: {b: 123}, tuple: [true, "y"]}, + ], + nestedA: ["asdf", "asdf"], + nestedNamed: [{b: 123}, {b: 123}], + nestedTuple: [ + [true, "x"], + [true, "y"], + ], + nestedTuple0: [true, true], + nestedTuple1: ["x", "y"], + }) + ); + + const emptyNamedTuple = e.tuple({string: e.cast(e.str, e.set())}); type emptyNamedTuple = $.setToTsType; tc.assert>(true); expect(emptyNamedTuple.__cardinality__).toEqual($.Cardinality.Empty); - const multiNamedTuple = e.namedTuple({ + const multiNamedTuple = e.tuple({ hero: e.Hero, }); type multiNamedTuple = $.setToTsType; @@ -188,3 +364,54 @@ test("namedTuple literal", async () => { >(true); expect(multiNamedTuple.__cardinality__).toEqual($.Cardinality.Many); }); + +test("non literal tuples", async () => { + const ver = e.sys.get_version(); + expect(ver.major.__element__.__name__).toEqual("std::int64"); + expect(ver.major.__cardinality__).toEqual($.Cardinality.One); + expect(ver.stage.__element__.__name__).toEqual("sys::VersionStage"); + expect(ver.stage.__cardinality__).toEqual($.Cardinality.One); + expect(ver.local.__element__.__name__).toEqual("array"); + expect(ver.local.__cardinality__).toEqual($.Cardinality.One); + + const result = await e + .select({ + ver, + verMajor: ver.major, + verStage: ver.stage, + verLocal: ver.local, + verLocal0: ver.local[0], + }) + .run(client); + + tc.assert< + tc.IsExact< + typeof result, + { + ver: { + major: number; + minor: number; + stage: $VersionStageλEnum; + stage_no: number; + local: string[]; + }; + verMajor: number; + verStage: $VersionStageλEnum; + verLocal: string[]; + verLocal0: string; + } + > + >(true); + + expect({ + major: result.verMajor, + stage: result.verStage, + local: result.verLocal, + local0: result.verLocal0, + }).toEqual({ + major: result.ver.major, + stage: result.ver.stage, + local: result.ver.local, + local0: result.ver.local[0], + }); +}); diff --git a/qb/test/delete.test.ts b/qb/test/delete.test.ts index 12f89b213..0a3a6bb4e 100644 --- a/qb/test/delete.test.ts +++ b/qb/test/delete.test.ts @@ -1,34 +1,50 @@ import * as edgedb from "edgedb"; -import e from "../dbschema/edgeql"; -import {setupTests, teardownTests, TestData} from "./setupTeardown"; +import e, {Cardinality} from "../dbschema/edgeql-js"; +import {setupTests, teardownTests, tc} from "./setupTeardown"; let client: edgedb.Client; -let data: TestData; beforeAll(async () => { const setup = await setupTests(); - ({client, data} = setup); + ({client} = setup); }); afterAll(async () => { await teardownTests(client); }); -test("basic insert", async () => { +test("basic delete", async () => { const insertBlackWidow = e.insert(e.Hero, { name: e.str("Black Widow"), secret_identity: e.str("Natasha Romanoff"), }); - await client.querySingle(insertBlackWidow.toEdgeQL()); + const insertedResult = await insertBlackWidow.run(client); - const deleteBlackWidow = e - .select(e.Hero, hero => ({ - filter: e.eq(hero.name, e.str("Black Widow")), - })) - .delete(); - await client.querySingle(deleteBlackWidow.toEdgeQL()); + const deleteBlackWidow = e.delete(e.Hero, hero => ({ + filter: e.op(hero.name, "=", "Black Widow"), + })); + const deletedResult = await deleteBlackWidow.run(client); + + expect(deletedResult).not.toEqual(null); + expect(deletedResult!.id).toEqual(insertedResult.id); - return; + const deleteWrappingSelect = e.delete( + e.select(e.Hero, hero => ({ + name: true, + filter: e.op(hero.name, "=", "Black Widow"), + })) + ); + const wrappingDeleteResult = await deleteWrappingSelect.run(client); + + tc.assert>( + true + ); + expect(wrappingDeleteResult).toEqual(null); + + const deleteAll = e.delete(e.Hero); + tc.assert>( + true + ); }); diff --git a/qb/test/detached.test.ts b/qb/test/detached.test.ts index 644d53366..9f8e4c444 100644 --- a/qb/test/detached.test.ts +++ b/qb/test/detached.test.ts @@ -1,5 +1,5 @@ import * as edgedb from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; import {setupTests, tc, teardownTests, TestData} from "./setupTeardown"; let client: edgedb.Client; @@ -22,7 +22,7 @@ test("detached", async () => { id: true, name: true, friends: e.select(e.detached(e.Hero)), - filter: e.eq(hero.name, e.str("Iron Man")), + filter: e.op(hero.name, "=", "Iron Man"), })) .run(client); type result = typeof result; diff --git a/qb/test/for.test.ts b/qb/test/for.test.ts index 0fee99dc0..67548334d 100644 --- a/qb/test/for.test.ts +++ b/qb/test/for.test.ts @@ -1,14 +1,9 @@ -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; test("simple for loop", () => { - expect( - e - .for(e.set(e.int64(1), e.int64(2), e.int64(3)), x => - e.plus(e.mult(x, e.int32(2)), x) - ) - .toEdgeQL() - ).toEqual(`FOR __forVar__0 IN {{ 1, 2, 3 }} + expect(e.for(e.set(1, 2, 3), x => e.op(e.op(x, "*", 2), "+", x)).toEdgeQL()) + .toEqual(`FOR __forVar__0 IN {{ 1, 2, 3 }} UNION ( - ((__forVar__0 * 2) + __forVar__0) + ((__forVar__0 * 2) + __forVar__0) )`); }); diff --git a/qb/test/functions.test.ts b/qb/test/functions.test.ts index da4b5c398..f7cc3959e 100644 --- a/qb/test/functions.test.ts +++ b/qb/test/functions.test.ts @@ -1,7 +1,9 @@ -import type {$expr_Function} from "../dbschema/edgeql/syntax/funcops"; import superjson from "superjson"; import {$} from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; +import {$expr_Function} from "edgedb/dist/reflection"; +import {tc} from "./setupTeardown"; +import {number} from "../dbschema/edgeql-js/modules/std"; function checkFunctionExpr( expr: T, @@ -18,7 +20,7 @@ function checkFunctionExpr( expect(superjson.stringify(expr.__namedargs__)).toEqual( superjson.stringify(namedargs) ); - expect(expr.__element__).toEqual(returnType); + expect(expr.__element__.__name__).toEqual(returnType.__name__); expect(expr.__cardinality__).toEqual(cardinality); } @@ -37,7 +39,7 @@ test("no args", () => { "sys::get_version", [], {}, - e.namedTuple({ + e.tuple({ major: e.int64, minor: e.int64, stage: e.sys.VersionStage, @@ -59,7 +61,7 @@ test("positional args", () => { "std::len", [e.str("test")], {}, - e.int64, + number, $.Cardinality.One ); @@ -68,7 +70,7 @@ test("positional args", () => { "std::len", [e.bytes(Buffer.from(""))], {}, - e.int64, + number, $.Cardinality.One ); @@ -77,7 +79,7 @@ test("positional args", () => { "std::len", [e.literal(e.array(e.int32), [1, 2, 3])], {}, - e.int64, + number, $.Cardinality.One ); @@ -87,7 +89,7 @@ test("positional args", () => { "std::len", [setOfStr], {}, - e.int64, + number, $.Cardinality.AtLeastOne ); @@ -97,7 +99,7 @@ test("positional args", () => { "std::datetime_get", datetime_getArgs as $.typeutil.writeable, {}, - e.float64, + number, $.Cardinality.One ); @@ -110,7 +112,7 @@ test("positional args", () => { "std::datetime_get", datetime_getArgs2 as $.typeutil.writeable, {}, - e.float64, + number, $.Cardinality.AtLeastOne ); @@ -155,14 +157,14 @@ test("named args", () => { ); checkFunctionExpr( e.std.re_replace( - {flags: e.set(e.str)}, + {flags: e.cast(e.str, e.set())}, e.str("pattern"), e.str("sub"), e.str("str") ), "std::re_replace", [e.str("pattern"), e.str("sub"), e.str("str")], - {flags: e.set(e.str)}, + {flags: e.cast(e.str, e.set())}, e.str, $.Cardinality.One ); @@ -184,26 +186,26 @@ test("named args", () => { $.Cardinality.One ); checkFunctionExpr( - e.to_duration({hours: e.int64(5), seconds: e.float64(30)}), + e.to_duration({hours: e.int64(5), seconds: e.int64(30)}), "std::to_duration", [], - {hours: e.int64(5), seconds: e.float64(30)}, + {hours: e.int64(5), seconds: e.int64(30)}, e.duration, $.Cardinality.One ); checkFunctionExpr( - e.to_duration({hours: e.set(e.int64(5), e.int16(6))}), + e.to_duration({hours: e.set(e.int64(5), e.int64(6))}), "std::to_duration", [], - {hours: e.set(e.int64(5), e.int16(6))}, + {hours: e.set(e.int64(5), e.int64(6))}, e.duration, $.Cardinality.AtLeastOne ); checkFunctionExpr( - e.to_duration({hours: e.int16(5)}), + e.to_duration({hours: e.int64(5)}), "std::to_duration", [], - {hours: e.int16(5)}, + {hours: e.int64(5)}, e.duration, $.Cardinality.One ); @@ -213,7 +215,7 @@ test("named args", () => { "default::💯", [], {"🙀": e.int64(1)}, - e.int64, + number, $.Cardinality.One ); @@ -312,7 +314,7 @@ test("anytype", () => { "std::min", [e.set(e.int64(1), e.int64(2))], {}, - e.int64, + number, $.Cardinality.One ); @@ -350,9 +352,15 @@ test("anytype", () => { ); checkFunctionExpr( - e.contains(e.literal(e.array(e.int16), [1, 2, 3]), e.bigint(BigInt(2))), + e.contains( + e.literal(e.array(e.int16), [1, 2, 3]), + e.cast(e.int64, e.bigint(BigInt(2))) + ), "std::contains", - [e.literal(e.array(e.int16), [1, 2, 3]), e.bigint(BigInt(2))], + [ + e.literal(e.array(e.int16), [1, 2, 3]), + e.cast(e.int64, e.bigint(BigInt(2))), + ], {}, e.bool, $.Cardinality.One @@ -413,9 +421,9 @@ test("cardinality inference", () => { $.Cardinality.One ); checkFunctionExpr( - e.to_str(e.int64(123), e.set(e.str)), + e.to_str(e.int64(123), e.cast(e.str, e.set())), "std::to_str", - [e.int64(123), e.set(e.str)], + [e.int64(123), e.cast(e.str, e.set())], {}, e.str, $.Cardinality.One @@ -423,7 +431,7 @@ test("cardinality inference", () => { checkFunctionExpr( e.to_str(e.int64(123), undefined), "std::to_str", - [e.int64(123), e.set(e.str) as any as undefined], + [e.int64(123), e.cast(e.str, e.set()) as any], {}, e.str, $.Cardinality.One @@ -431,7 +439,7 @@ test("cardinality inference", () => { checkFunctionExpr( e.to_str(e.set(e.int64(123), e.int64(456)), undefined), "std::to_str", - [e.set(e.int64(123), e.int64(456)), e.set(e.str) as any as undefined], + [e.set(e.int64(123), e.int64(456)), e.cast(e.str, e.set()) as any], {}, e.str, $.Cardinality.AtLeastOne @@ -439,7 +447,7 @@ test("cardinality inference", () => { checkFunctionExpr( e.to_str(e.int64(123)), "std::to_str", - [e.int64(123), undefined], + [e.int64(123), undefined as any], {}, e.str, $.Cardinality.One @@ -451,7 +459,7 @@ test("cardinality inference", () => { "std::sum", [e.int64(1)], {}, - e.int64, + number, $.Cardinality.One ); checkFunctionExpr( @@ -459,15 +467,15 @@ test("cardinality inference", () => { "std::sum", [e.set(e.int64(1), e.int64(2))], {}, - e.int64, + number, $.Cardinality.One ); checkFunctionExpr( - e.sum(e.set(e.int64)), + e.sum(e.cast(e.int64, e.set())), "std::sum", - [e.set(e.int64)], + [e.cast(e.int64, e.set())], {}, - e.int64, + number, $.Cardinality.One ); @@ -487,9 +495,9 @@ test("cardinality inference", () => { $.Cardinality.AtMostOne ); checkFunctionExpr( - e.array_get(e.set(e.array(e.bigint)), e.int64(1)), + e.array_get(e.cast(e.array(e.bigint), e.set()), e.int64(1)), "std::array_get", - [e.set(e.array(e.bigint)), e.int64(1)], + [e.cast(e.array(e.bigint), e.set()), e.int64(1)], {}, e.bigint, $.Cardinality.Empty @@ -526,9 +534,9 @@ test("cardinality inference", () => { $.Cardinality.Many ); checkFunctionExpr( - e.array_unpack(e.set(e.array(e.str))), + e.array_unpack(e.cast(e.array(e.str), e.set())), "std::array_unpack", - [e.set(e.array(e.str))], + [e.cast(e.array(e.str), e.set())], {}, e.str, $.Cardinality.Many @@ -542,3 +550,101 @@ test("cardinality inference", () => { $.Cardinality.Many ); }); + +test("assert_*", () => { + const emptySet = e.cast(e.str, e.set()); + const oneSet = e.set("str"); + const atLeastOneSet = e.set("str", "str2"); + const atMostOneSet = { + ...oneSet, + __cardinality__: $.Cardinality.AtMostOne, + } as unknown as $.TypeSet; + const manySet = { + ...atLeastOneSet, + __cardinality__: $.Cardinality.Many, + } as unknown as $.TypeSet; + + expect(emptySet.__cardinality__).toEqual($.Cardinality.Empty); + expect(oneSet.__cardinality__).toEqual($.Cardinality.One); + expect(atLeastOneSet.__cardinality__).toEqual($.Cardinality.AtLeastOne); + expect(atMostOneSet.__cardinality__).toEqual($.Cardinality.AtMostOne); + expect(manySet.__cardinality__).toEqual($.Cardinality.Many); + tc.assert< + tc.IsExact + >(true); + tc.assert>( + true + ); + tc.assert< + tc.IsExact< + typeof atLeastOneSet["__cardinality__"], + $.Cardinality.AtLeastOne + > + >(true); + tc.assert< + tc.IsExact + >(true); + tc.assert>( + true + ); + + // assert_single + const emptySingle = e.assert_single(emptySet); + expect(emptySingle.__cardinality__).toEqual($.Cardinality.AtMostOne); + tc.assert< + tc.IsExact + >(true); + const oneSingle = e.assert_single(oneSet); + expect(oneSingle.__cardinality__).toEqual($.Cardinality.One); + tc.assert< + tc.IsExact + >(true); + const atLeastOneSingle = e.assert_single(atLeastOneSet); + expect(atLeastOneSingle.__cardinality__).toEqual($.Cardinality.One); + tc.assert< + tc.IsExact + >(true); + const atMostOneSingle = e.assert_single(atMostOneSet); + expect(atMostOneSingle.__cardinality__).toEqual($.Cardinality.AtMostOne); + tc.assert< + tc.IsExact< + typeof atMostOneSingle["__cardinality__"], + $.Cardinality.AtMostOne + > + >(true); + const manySingle = e.assert_single(manySet); + expect(manySingle.__cardinality__).toEqual($.Cardinality.AtMostOne); + tc.assert< + tc.IsExact + >(true); + + // assert_exists + const emptyExists = e.assert_exists(emptySet); + expect(emptyExists.__cardinality__).toEqual($.Cardinality.One); + tc.assert< + tc.IsExact + >(true); + const oneExists = e.assert_exists(oneSet); + expect(oneExists.__cardinality__).toEqual($.Cardinality.One); + tc.assert< + tc.IsExact + >(true); + const atLeastOneExists = e.assert_exists(atLeastOneSet); + expect(atLeastOneExists.__cardinality__).toEqual($.Cardinality.AtLeastOne); + tc.assert< + tc.IsExact< + typeof atLeastOneExists["__cardinality__"], + $.Cardinality.AtLeastOne + > + >(true); + const atMostOneExists = e.assert_exists(atMostOneSet); + expect(atMostOneExists.__cardinality__).toEqual($.Cardinality.One); + tc.assert< + tc.IsExact + >(true); + const manyExists = e.assert_exists(manySet); + expect(manyExists.__cardinality__).toEqual($.Cardinality.AtLeastOne); + tc.assert< + tc.IsExact + >(true); +}); diff --git a/qb/test/insert.test.ts b/qb/test/insert.test.ts index d0deb339c..5d151596a 100644 --- a/qb/test/insert.test.ts +++ b/qb/test/insert.test.ts @@ -1,7 +1,7 @@ import {Client} from "edgedb"; -import {Villain} from "../dbschema/edgeql/modules/default"; -import {InsertShape} from "../dbschema/edgeql/syntax/insert"; -import e from "../dbschema/edgeql"; +import {Villain} from "../dbschema/edgeql-js/modules/default"; +import {InsertShape} from "../dbschema/edgeql-js/syntax/insert"; +import e from "../dbschema/edgeql-js"; import {setupTests, teardownTests, TestData} from "./setupTeardown"; let client: Client; @@ -23,9 +23,8 @@ test("insert shape check", async () => { test("basic insert", async () => { const q1 = e.insert(e.Hero, { - name: e.str("Black Widow"), + name: "Black Widow", secret_identity: e.str("Natasha Romanoff"), - // id }); await client.querySingle(q1.toEdgeQL()); @@ -38,7 +37,7 @@ test("nested insert", async () => { const q1 = e.insert(e.Villain, { name: e.str("villain"), nemesis: e.insert(e.Hero, { - name: e.str("hero"), + name: "hero", }), }); @@ -73,7 +72,29 @@ test("insert type enforcement", async () => { e.insert(e.Villain, { // @ts-expect-error - name: e.set(e.str), + name: e.cast(e.str, e.set()), }); + + e.insert(e.Hero, { + // @ts-expect-error + name: 1234, + // @ts-expect-error + number_of_movies: "Ronin", + }); + + // should not error on missing required prop 'release_year' + // since it has a default value + e.insert(e.Movie, { + title: "test_movie", + }); + + e.insert(e.Movie, { + title: "test movie", + rating: null, + profile: null, + // @ts-expect-error release_year is required prop + release_year: null, + }).toEdgeQL(); + return; }); diff --git a/qb/test/literals.test.ts b/qb/test/literals.test.ts index ae3ffdf3b..1358d1d4c 100644 --- a/qb/test/literals.test.ts +++ b/qb/test/literals.test.ts @@ -1,5 +1,5 @@ import * as edgedb from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; test("literals", () => { const duration = new edgedb.Duration(0, 0, 0, 0, 5, 6, 7, 8, 9, 10); @@ -29,14 +29,21 @@ test("literals", () => { expect(e.std.duration(duration).toEdgeQL()).toEqual( `'PT5H6M7.00800901S'` ); - expect(e.std.float32(144.1235).toEdgeQL()).toEqual(`144.1235`); - expect(e.std.float64(1234.15).toEdgeQL()).toEqual(`1234.15`); - expect(e.std.int16(1234.1234).toEdgeQL()).toEqual(`1234.1234`); - expect(e.std.int32(124).toEdgeQL()).toEqual(`124`); + expect(e.std.int16(144.1235).toEdgeQL()).toEqual(`144.1235`); + expect(e.std.int64(1234.15).toEdgeQL()).toEqual(`1234.15`); + expect(e.std.float64(1234.1234).toEdgeQL()).toEqual(`1234.1234`); + expect(e.std.float64(124).toEdgeQL()).toEqual(`124`); + expect(e.std.int16("9223372036854775807").toEdgeQL()).toEqual( + `9223372036854775807` + ); + + expect(e.std.json("asdf").toEdgeQL()).toEqual(`to_json("\\"asdf\\"")`); + expect( + e.std.json({a: 123, b: "some string", c: [true, false]}).toEdgeQL() + ).toEqual( + `to_json("{\\"a\\":123,\\"b\\":\\"some string\\",\\"c\\":[true,false]}")` + ); - expect(e.std.int64(1234).toEdgeQL()).toEqual(`1234`); - expect(e.std.int32(1234).toEdgeQL()).toEqual(`1234`); - expect(e.std.json('"asdf"').toEdgeQL()).toEqual(`"\\"asdf\\""`); expect(e.std.str(`asdfaf`).toEdgeQL()).toEqual(`"asdfaf"`); expect(e.std.str(`string " with ' all \` quotes`).toEdgeQL()).toEqual( `"string \\" with ' all \` quotes"` @@ -60,15 +67,11 @@ test("literals", () => { test("collection type literals", () => { const literalArray = e.literal(e.array(e.str), ["adsf"]); - expect(literalArray.toEdgeQL()).toEqual(`>["adsf"]`); - const literalNamedTuple = e.literal(e.namedTuple({str: e.str}), { + expect(literalArray.toEdgeQL()).toEqual(`["adsf"]`); + const literalNamedTuple = e.literal(e.tuple({str: e.str}), { str: "asdf", }); - expect(literalNamedTuple.toEdgeQL()).toEqual( - `>( str := "asdf" )` - ); + expect(literalNamedTuple.toEdgeQL()).toEqual(`( str := "asdf" )`); const literalTuple = e.literal(e.tuple([e.str, e.int64]), ["asdf", 1234]); - expect(literalTuple.toEdgeQL()).toEqual( - `>( "asdf", 1234 )` - ); + expect(literalTuple.toEdgeQL()).toEqual(`( "asdf", 1234 )`); }); diff --git a/qb/test/objectTypes.test.ts b/qb/test/objectTypes.test.ts index 995ddbd65..c0231e9c0 100644 --- a/qb/test/objectTypes.test.ts +++ b/qb/test/objectTypes.test.ts @@ -1,20 +1,21 @@ import {$} from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; import {tc} from "./setupTeardown"; -const HeroType = e.default.$Hero; +const $Hero = e.default.Hero.__element__; +const $AnnotationSubject = e.schema.AnnotationSubject.__element__; +const $Bag = e.default.Bag.__element__; +const $Simple = e.default.Simple.__element__; test("property hydration", () => { - expect(typeof HeroType).toBe("object"); - expect(HeroType.__name__).toBe("default::Hero"); - expect(HeroType.__pointers__.name.__kind__).toBe("property"); - expect(HeroType.__pointers__.name.cardinality).toBe($.Cardinality.One); - expect(HeroType.__pointers__.name.target).toEqual(e.std.str); - expect(HeroType.__pointers__.name.target.__kind__).toEqual( - $.TypeKind.scalar - ); - expect(HeroType.__pointers__.name.exclusive).toEqual(true); - expect(HeroType.__pointers__.secret_identity.exclusive).toEqual(false); + expect(typeof $Hero).toBe("object"); + expect($Hero.__name__).toBe("default::Hero"); + expect($Hero.__pointers__.name.__kind__).toBe("property"); + expect($Hero.__pointers__.name.cardinality).toBe($.Cardinality.One); + expect($Hero.__pointers__.name.target).toEqual(e.std.str); + expect($Hero.__pointers__.name.target.__kind__).toEqual($.TypeKind.scalar); + expect($Hero.__pointers__.name.exclusive).toEqual(true); + expect($Hero.__pointers__.secret_identity.exclusive).toEqual(false); expect(e.default.Movie.__element__.__pointers__.profile.exclusive).toEqual( true @@ -27,18 +28,16 @@ test("property hydration", () => { }); test("link hydration", () => { - expect(HeroType.__pointers__.villains.__kind__).toBe("link"); - expect(HeroType.__pointers__.villains.target.__kind__).toBe( - $.TypeKind.object - ); - expect(HeroType.__pointers__.villains.cardinality).toBe($.Cardinality.Many); - expect(HeroType.__pointers__.villains.target.__name__).toEqual( + expect($Hero.__pointers__.villains.__kind__).toBe("link"); + expect($Hero.__pointers__.villains.target.__kind__).toBe($.TypeKind.object); + expect($Hero.__pointers__.villains.cardinality).toBe($.Cardinality.Many); + expect($Hero.__pointers__.villains.target.__name__).toEqual( "default::Villain" ); - expect(HeroType.__pointers__.villains.properties).toEqual({}); + expect($Hero.__pointers__.villains.properties).toEqual({}); }); -const link = e.schema.$AnnotationSubject.__pointers__.annotations; +const link = $AnnotationSubject.__pointers__.annotations; test("link properties", () => { expect(link.properties["@value"].target.__name__).toEqual("std::str"); expect(link.properties["@value"].cardinality).toEqual( @@ -49,7 +48,7 @@ test("link properties", () => { test("named tuple tests", () => { // named tuple tests - const BagShape = e.default.$Bag.__pointers__; + const BagShape = $Bag.__pointers__; expect(BagShape.namedTuple.cardinality).toEqual($.Cardinality.AtMostOne); const namedTuple = BagShape.namedTuple.target; @@ -61,7 +60,7 @@ test("named tuple tests", () => { test("unnamed tuple tests", () => { // named tuple tests - const BagShape = e.default.$Bag.__pointers__; + const BagShape = $Bag.__pointers__; const unnamedTuple = BagShape.unnamedTuple.target; expect(unnamedTuple.__kind__).toEqual($.TypeKind.tuple); expect(unnamedTuple.__items__[0].__name__).toEqual("std::str"); @@ -70,14 +69,14 @@ test("unnamed tuple tests", () => { test("array tests", () => { // named tuple tests - const BagShape = e.default.$Bag.__pointers__; + const BagShape = $Bag.__pointers__; const arrayProp = BagShape.stringsArr.target; expect(arrayProp.__kind__).toEqual($.TypeKind.array); expect(arrayProp.__element__.__name__).toEqual("std::str"); }); test("merging tests", () => { - const merged = $.$mergeObjectTypes(e.default.$Bag, e.default.$Simple); + const merged = $.$mergeObjectTypes($Bag, $Simple); expect(Object.keys(merged.__pointers__).length).toEqual(4); expect(Object.keys(merged.__pointers__).includes("id")).toEqual(true); expect(Object.keys(merged.__pointers__).includes("__type__")).toEqual(true); @@ -89,16 +88,17 @@ test("merging tests", () => { }); test("backlinks", () => { - const heroMovie = e.Hero[" ({limit: 1})).nemesis.__cardinality__ + e.select(e.Villain, () => ({limit: 1})).assert_single().nemesis + .__cardinality__ ).toEqual($.Cardinality.AtMostOne); expect(e.Profile[" { expect(merged.__pointers__["( expr: T, name: T["__name__"], - args: T["__args__"], + args: any[], returnType: T["__element__"], cardinality: T["__cardinality__"], edgeql?: string @@ -25,83 +25,106 @@ function checkOperatorExpr( test("slice and index ops", () => { checkOperatorExpr( - e.slice( - e.str("test string"), - e.literal(e.tuple([e.int64, e.int32]), [2, 5]) - ), - "std::[]", - [e.str("test string"), e.literal(e.tuple([e.int64, e.int32]), [2, 5])], + e.str("test string")["2:5"], + "[]", + [e.str("test string"), [e.int64(2), e.int64(5)]], e.str, $.Cardinality.One, - `("test string"[2:5])` + `("test string")[2:5]` ); checkOperatorExpr( - e.slice( - e.literal(e.array(e.bigint), [BigInt(1), BigInt(2), BigInt(3)]), - e.literal(e.tuple([e.int64, e.int32]), [1, 2]) - ), - "std::[]", - [ - e.literal(e.array(e.bigint), [BigInt(1), BigInt(2), BigInt(3)]), - e.literal(e.tuple([e.int64, e.int32]), [1, 2]), - ], + e.str("test string").slice(e.int64(2), e.int64(5)), + "[]", + [e.str("test string"), [e.int64(2), e.int64(5)]], + e.str, + $.Cardinality.One, + `("test string")[2:5]` + ); + + checkOperatorExpr( + e.array([BigInt(1), BigInt(2), BigInt(3)])["1:2"], + "[]", + [e.array([BigInt(1), BigInt(2), BigInt(3)]), [e.int64(1), e.int64(2)]], e.array(e.bigint), $.Cardinality.One, - `(>[1n, 2n, 3n][1:2])` + `([1n, 2n, 3n])[1:2]` ); checkOperatorExpr( - e.index(e.str("test string"), e.int32(3)), - "std::[]", - [e.str("test string"), e.int32(3)], + e.str("test string")[3], + "[]", + [e.str("test string"), e.int64(3)], e.str, $.Cardinality.One, - `("test string"[3])` + `("test string")[3]` ); checkOperatorExpr( - e.index( - e.literal(e.array(e.bigint), [BigInt(1), BigInt(2), BigInt(3)]), - e.int32(2) - ), - "std::[]", - [ - e.literal(e.array(e.bigint), [BigInt(1), BigInt(2), BigInt(3)]), - e.int32(2), - ], + e.str("test string").index(e.int64(3)), + "[]", + [e.str("test string"), e.int64(3)], + e.str, + $.Cardinality.One, + `("test string")[3]` + ); + + checkOperatorExpr( + e.array([BigInt(1), BigInt(2), BigInt(3)])[2], + "[]", + [e.array([BigInt(1), BigInt(2), BigInt(3)]), e.int64(2)], e.bigint, $.Cardinality.One, - `(>[1n, 2n, 3n][2])` + `([1n, 2n, 3n])[2]` + ); + + checkOperatorExpr( + e.to_json(e.str(`{"name":"Bob"}`)).name, + "[]", + [e.to_json(e.str(`{"name":"Bob"}`)), e.str("name")], + e.json, + $.Cardinality.One, + `(std::to_json(("{\\\"name\\\":\\\"Bob\\\"}")))["name"]` + ); + + checkOperatorExpr( + e.to_json(e.str(`{"name":"Bob"}`)).destructure(e.str("name")), + "[]", + [e.to_json(e.str(`{"name":"Bob"}`)), e.str("name")], + e.json, + $.Cardinality.One, + `(std::to_json(("{\\\"name\\\":\\\"Bob\\\"}")))["name"]` ); }); test("if else op", () => { checkOperatorExpr( - e.if_else(e.str("this"), e.eq(e.int64(42), e.float32(42)), e.str("that")), - "std::IF", - [e.str("this"), e.eq(e.int64(42), e.float32(42)), e.str("that")], + e.op( + "this", + "if", + e.op(42, "=", e.literal(e.float32, 42)), + "else", + e.str("that") + ), + "if_else", + [e.str("this"), e.op(42, "=", e.literal(e.float32, 42)), e.str("that")], e.str, $.Cardinality.One, - `("this" IF (42 = 42) ELSE "that")` + `("this" IF (42 = 42) ELSE "that")` ); checkOperatorExpr( - e.if_else(e.str("this"), e.set(e.bool), e.str("that")), - "std::IF", - [e.str("this"), e.set(e.bool), e.str("that")], + e.op("this", "if", e.cast(e.bool, e.set()), "else", "that"), + "if_else", + [e.str("this"), e.cast(e.bool, e.set()), e.str("that")], e.str, $.Cardinality.Empty, `("this" IF {} ELSE "that")` ); checkOperatorExpr( - e.if_else( - e.str("this"), - e.set(e.bool(true), e.bool(false)), - e.str("that") - ), - "std::IF", + e.op("this", "if", e.set(e.bool(true), e.bool(false)), "else", "that"), + "if_else", [e.str("this"), e.set(e.bool(true), e.bool(false)), e.str("that")], e.str, $.Cardinality.AtLeastOne, @@ -109,45 +132,59 @@ test("if else op", () => { ); checkOperatorExpr( - e.if_else( + e.op( e.str("this"), - e.eq(e.int64(42), e.float32(42)), + "if", + e.op(e.literal(e.int64, 42), "=", e.literal(e.float32, 42)), + "else", e.set(e.str("that"), e.str("other")) ), - "std::IF", + "if_else", [ e.str("this"), - e.eq(e.int64(42), e.float32(42)), + e.op(e.literal(e.int64, 42), "=", e.literal(e.float32, 42)), e.set(e.str("that"), e.str("other")), ], e.str, $.Cardinality.AtLeastOne, - `("this" IF (42 = 42) ELSE { "that", "other" })` + `("this" IF (42 = 42) ELSE { "that", "other" })` ); checkOperatorExpr( - e.if_else( - e.set(e.str), - e.eq(e.int64(42), e.float32(42)), + e.op( + e.cast(e.str, e.set()), + "if", + e.op(e.literal(e.int64, 42), "=", e.literal(e.float32, 42)), + "else", e.set(e.str("that"), e.str("other")) ), - "std::IF", + "if_else", [ - e.set(e.str), - e.eq(e.int64(42), e.float32(42)), + e.cast(e.str, e.set()), + e.op(e.literal(e.int64, 42), "=", e.literal(e.float32, 42)), e.set(e.str("that"), e.str("other")), ], e.str, $.Cardinality.Many, - `({} IF (42 = 42) ELSE { "that", "other" })` + `({} IF (42 = 42) ELSE { "that", "other" })` ); checkOperatorExpr( - e.if_else(e.str("this"), e.eq(e.int64(42), e.float32(42)), e.set(e.str)), - "std::IF", - [e.str("this"), e.eq(e.int64(42), e.float32(42)), e.set(e.str)], + e.op( + "this", + "if", + e.op(42, "=", e.literal(e.float32, 42)), + "else", + e.cast(e.str, e.set()) + ), + "if_else", + [ + e.str("this"), + e.op(42, "=", e.literal(e.float32, 42)), + e.cast(e.str, e.set()), + ], e.str, $.Cardinality.AtMostOne, - `("this" IF (42 = 42) ELSE {})` + `("this" IF (42 = 42) ELSE {})` ); }); diff --git a/qb/test/params.test.ts b/qb/test/params.test.ts index 5095b2a43..122a3e888 100644 --- a/qb/test/params.test.ts +++ b/qb/test/params.test.ts @@ -1,5 +1,5 @@ import * as edgedb from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; import {setupTests, teardownTests, tc} from "./setupTeardown"; let client: edgedb.Client; @@ -14,7 +14,7 @@ afterAll(async () => { }); test("simple params", () => { - const query = e.withParams( + const query = e.params( { str: e.str, numArr: e.array(e.int64), @@ -24,77 +24,164 @@ test("simple params", () => { e.select({ str: params.str, nums: e.array_unpack(params.numArr), - x: e.if_else(e.str("true"), params.optBool, e.str("false")), + x: e.op("true", "if", params.optBool, "else", "false"), }) ); - expect(query.toEdgeQL()).toEqual(`SELECT { - single str := ($str), - multi nums := (std::array_unpack((>$numArr))), - single x := (("true" IF $optBool ELSE "false")) -}`); + expect(query.toEdgeQL()).toEqual(`WITH + __param__str := $str, + __param__numArr := >$numArr, + __param__optBool := $optBool +SELECT (SELECT { + single str := (__param__str), + multi nums := (std::array_unpack((__param__numArr))), + single x := (("true" IF __param__optBool ELSE "false")) +})`); expect(() => e.select(query).toEdgeQL()).toThrow(); - type paramsType = typeof query["__paramststype__"]; + type paramsType = Parameters[1]; tc.assert< tc.IsExact< paramsType, { str: string; numArr: number[]; - optBool: boolean | null; + optBool?: boolean | null; } > >(true); + + expect( + // @ts-expect-error + query.run(client) + ).rejects.toThrowError(); }); -test("all param types", async () => { - const query = e.withParams( +test("complex params", async () => { + const query = e.params( { - int16: e.int16, - int32: e.int32, - int64: e.int64, - float32: e.float32, - float64: e.float64, - bigint: e.bigint, - // decimal not supported by edgedb-js - bool: e.bool, - json: e.json, str: e.str, - bytes: e.bytes, - uuid: e.uuid, - datetime: e.datetime, - duration: e.duration, - local_date: e.cal.local_date, - local_time: e.cal.local_time, - local_datetime: e.cal.local_datetime, - relative_duration: e.cal.relative_duration, - memory: e.cfg.memory, + numArr: e.array(e.int64), + optBool: e.optional(e.bool), + tuple: e.tuple([e.str, e.int32, e.array(e.bool)]), + namedTuple: e.tuple({a: e.float64, b: e.array(e.bigint), c: e.str}), + jsonTuple: e.tuple([e.json]), + people: e.array( + e.tuple({name: e.str, age: e.int64, tags: e.array(e.str)}) + ), }, - p => + params => e.select({ - int16: p.int16, - int32: p.int32, - int64: p.int64, - float32: p.float32, - float64: p.float64, - bigint: p.bigint, - bool: p.bool, - json: p.json, - str: p.str, - bytes: p.bytes, - uuid: p.uuid, - local_date: p.local_date, - local_time: p.local_time, - local_datetime: p.local_datetime, - datetime: p.datetime, - duration: p.duration, - relative_duration: p.relative_duration, - memory: p.memory, + str: params.str, + nums: e.array_unpack(params.numArr), + x: e.op("true", "if", params.optBool, "else", "false"), + tuple: params.tuple, + tupleArrSlice: params.tuple[2].slice(1, null), + namedTuple: params.namedTuple, + namedTupleA: params.namedTuple.a, + jsonTuple: params.jsonTuple, + people: params.people, }) ); + type paramsType = Parameters[1]; + tc.assert< + tc.IsExact< + paramsType, + { + str: string; + numArr: number[]; + optBool?: boolean | null; + tuple: [string, number, boolean[]]; + namedTuple: {a: number; b: bigint[]; c: string}; + jsonTuple: [string]; + people: {name: string; age: number; tags: string[]}[]; + } + > + >(true); + + const result = await query.run(client, { + str: "test string", + numArr: [1, 2, 3], + tuple: ["str", 123, [true, false]], + namedTuple: {a: 123, b: [BigInt(4), BigInt(5)], c: "str"}, + jsonTuple: [`{"a": 123, "b": ["c", "d"]}`], + people: [ + {name: "person a", age: 23, tags: ["a", "b"]}, + {name: "person b", age: 45, tags: ["b", "c"]}, + ], + }); + + expect({ + ...result, + nums: [...result.nums], + tuple: [...result.tuple], + namedTuple: { + a: result.namedTuple.a, + b: result.namedTuple.b, + c: result.namedTuple.c, + }, + jsonTuple: [...result.jsonTuple], + people: result.people.map(p => ({ + name: p.name, + age: p.age, + tags: [...p.tags], + })), + }).toEqual({ + id: (result as any).id, + str: "test string", + nums: [1, 2, 3], + x: null, + tuple: ["str", 123, [true, false]], + tupleArrSlice: [false], + namedTuple: {a: 123, b: [BigInt(4), BigInt(5)], c: "str"}, + namedTupleA: 123, + jsonTuple: [`{"a": 123, "b": ["c", "d"]}`], + people: [ + {name: "person a", age: 23, tags: ["a", "b"]}, + {name: "person b", age: 45, tags: ["b", "c"]}, + ], + }); +}); + +// test("non castable scalars", async () => { +// e.params( +// { +// // @ts-expect-error +// num: e.int64, +// // @ts-expect-error +// tuple: e.tuple([e.int64]), +// }, +// p => e.select({num: p.num, tuple: p.num}) +// ); +// }); + +test("all param types", async () => { + const params = { + int16: e.int16, + int32: e.int32, + int64: e.int64, + float32: e.float32, + float64: e.float64, + bigint: e.bigint, + // decimal not supported by edgedb-js + bool: e.bool, + json: e.json, + str: e.str, + bytes: e.bytes, + uuid: e.uuid, + datetime: e.datetime, + duration: e.duration, + local_date: e.cal.local_date, + local_time: e.cal.local_time, + local_datetime: e.cal.local_datetime, + relative_duration: e.cal.relative_duration, + memory: e.cfg.memory, + }; + + const query = e.params(params, p => e.select(p)); + const args = { int16: 1, int32: 2, @@ -151,4 +238,17 @@ test("all param types", async () => { } > >(true); + + const complexQuery = e.params( + { + tuple: e.tuple(params), + }, + p => e.select(p) + ); + + const complexResult = await complexQuery.run(client, { + tuple: args, + }); + + expect([...(complexResult.tuple as any)]).toEqual(Object.values(args)); }); diff --git a/qb/test/paths.test.ts b/qb/test/paths.test.ts index e2a7b9132..8b84823b6 100644 --- a/qb/test/paths.test.ts +++ b/qb/test/paths.test.ts @@ -1,23 +1,25 @@ import {$} from "edgedb"; -import e from "../dbschema/edgeql"; -import {$expr_PathNode} from "../dbschema/edgeql/syntax/syntax"; +import e from "../dbschema/edgeql-js/index"; +import {$PathNode} from "../dbschema/edgeql-js/syntax/syntax"; import {tc} from "./setupTeardown"; test("path structure", () => { const Hero = e.default.Hero; type Hero = typeof Hero; - const HeroSetSingleton = $.$toSet(e.default.$Hero, $.Cardinality.One); - const HeroSingleton = $expr_PathNode(HeroSetSingleton, null, false); + const $Hero = e.Hero.__element__; + const $Villain = e.Villain.__element__; + const HeroSetSingleton = $.$toSet($Hero, $.Cardinality.One); + const HeroSingleton = $PathNode(HeroSetSingleton, null, false); type HeroSingleton = typeof HeroSingleton; - const VillainRoot = $.$toSet(e.default.$Villain, $.Cardinality.One); - const Villain = $expr_PathNode(VillainRoot, null, false); + const VillainRoot = $.$toSet($Villain, $.Cardinality.One); + const Villain = $PathNode(VillainRoot, null, false); expect(Hero.name.__element__.__kind__).toEqual($.TypeKind.scalar); expect(Hero.name.__element__.__name__).toEqual("std::str"); expect(Hero.name.__cardinality__).toEqual($.Cardinality.Many); expect(HeroSingleton.name.__cardinality__).toEqual($.Cardinality.One); - expect(Villain[" { // AtMostOneHero.name // test cardinality merging - const HeroSetAtLeastOne = $.$toSet( - e.default.$Hero, - $.Cardinality.AtLeastOne - ); - const AtLeastOneHero = $expr_PathNode(HeroSetAtLeastOne, null, false); + const HeroSetAtLeastOne = $.$toSet($Hero, $.Cardinality.AtLeastOne); + const AtLeastOneHero = $PathNode(HeroSetAtLeastOne, null, false); type AtLeastOneHero = typeof AtLeastOneHero; expect(AtLeastOneHero.id.__cardinality__).toEqual($.Cardinality.AtLeastOne); expect(AtLeastOneHero.number_of_movies.__cardinality__).toEqual( @@ -82,18 +81,19 @@ test("path structure", () => { }); test("type intersection on path node", () => { + const $Hero = e.Hero.__element__; const person = e.Person; - const hero = person.$is(e.Hero); + const hero = person.is(e.Hero); tc.assert< tc.IsExact< typeof hero["__element__"]["__pointers__"], - typeof e.$Hero["__pointers__"] + typeof $Hero["__pointers__"] > >(true); tc.assert< tc.IsExact< typeof hero["__element__"]["__name__"], - typeof e.$Hero["__name__"] + typeof $Hero["__name__"] > >(true); tc.assert>( @@ -114,7 +114,7 @@ test("type intersection on path node", () => { test("type intersection on select", () => { const q2 = e.select(e.Person, () => ({id: true, name: true, limit: 5})); - const hero = q2.$is(e.Hero); + const hero = q2.is(e.Hero); expect(hero.__element__.__name__).toEqual("default::Hero"); expect(hero.__element__.__kind__).toEqual($.TypeKind.object); expect(hero.__kind__).toEqual($.ExpressionKind.TypeIntersection); @@ -124,8 +124,8 @@ test("type intersection on select", () => { expect(hero.number_of_movies.__element__.__name__).toEqual("std::int64"); }); -test("assertSingle", () => { - const singleHero = e.Hero.$assertSingle(); +test("assert_single", () => { + const singleHero = e.Hero.assert_single(); tc.assert< tc.IsExact >(true); diff --git a/qb/test/primitives.test.ts b/qb/test/primitives.test.ts index 73966bbde..353e45faf 100644 --- a/qb/test/primitives.test.ts +++ b/qb/test/primitives.test.ts @@ -3,18 +3,22 @@ import e, { $NamedTuple, $Tuple, getSharedParentPrimitiveVariadic, -} from "../dbschema/edgeql"; +} from "../dbschema/edgeql-js"; import {tc} from "./setupTeardown"; test("primitive types", () => { expect(e.int16.__name__).toEqual("std::int16"); - // expect(e.std.).toEqual("std::int64"); + expect(e.int32.__name__).toEqual("std::int32"); + expect(e.int64.__name__).toEqual("std::int64"); + expect(e.float32.__name__).toEqual("std::float32"); + expect(e.float64.__name__).toEqual("std::float64"); + expect(e.str.__name__).toEqual("std::str"); }); test("collection types", () => { const arrayType = e.array(e.str); expect(arrayType.__name__).toEqual("array"); - const named = e.namedTuple({str: e.str}); + const named = e.tuple({str: e.str}); expect(named.__name__).toEqual("tuple"); expect(named.__shape__.str.__name__).toEqual("std::str"); const unnamed = e.tuple([e.str, e.int64]); @@ -32,27 +36,4 @@ test("scalar type merging", () => { [typeof e.std.str, typeof e.std.int32] >; tc.assert>(true); - type _t3 = getSharedParentPrimitiveVariadic< - [typeof e.std.int16, typeof e.std.int32] - >; - tc.assert>(true); - type _t4 = getSharedParentPrimitiveVariadic< - [typeof e.std.int64, typeof e.std.float32] - >; - tc.assert>(true); - type _t5 = getSharedParentPrimitiveVariadic< - [$Array, $Array] - >; - tc.assert>>(true); - type _t6 = getSharedParentPrimitiveVariadic< - [$Tuple<[typeof e.std.int64]>, $Tuple<[typeof e.std.float32]>] - >; - tc.assert>>(true); - type _t7 = getSharedParentPrimitiveVariadic< - [ - $NamedTuple<{num: typeof e.std.int64}>, - $NamedTuple<{num: typeof e.std.float32}> - ] - >; - tc.assert>>(true); }); diff --git a/qb/test/select.test.ts b/qb/test/select.test.ts index 4536bc267..d988d6f1e 100644 --- a/qb/test/select.test.ts +++ b/qb/test/select.test.ts @@ -1,11 +1,12 @@ -import {Client, $} from "edgedb"; - +import * as edgedb from "edgedb"; +import {$} from "edgedb"; import * as tc from "conditional-type-checks"; -import e, {$infer} from "../dbschema/edgeql"; +import e, {$infer} from "../dbschema/edgeql-js"; +import {number} from "../dbschema/edgeql-js/modules/std"; import {setupTests, teardownTests, TestData} from "./setupTeardown"; -let client: Client; +let client: edgedb.Client; let data: TestData; beforeAll(async () => { @@ -23,11 +24,82 @@ test("basic select", () => { tc.assert>(true); }); -test("basic shape", () => { - const result = e.select(e.default.Hero); - type result = $.BaseTypeToTsType; - tc.assert>(true); - expect(result.__element__.__shape__).toEqual({id: true}); +test("selecting JS data", () => { + const strSelect = e.select("test"); + expect(strSelect.__kind__).toBe($.ExpressionKind.Select); + expect(strSelect.__element__).toBe(e.str); + expect(strSelect.__cardinality__).toBe($.Cardinality.One); + + const numberSelect = e.select(1234); + expect(numberSelect.__kind__).toBe($.ExpressionKind.Select); + expect(numberSelect.__element__).toBe(number); + expect(numberSelect.__cardinality__).toBe($.Cardinality.One); + + const boolSelect = e.select(false); + expect(boolSelect.__kind__).toBe($.ExpressionKind.Select); + expect(boolSelect.__element__).toBe(e.bool); + expect(boolSelect.__cardinality__).toBe($.Cardinality.One); + + const bigintSelect = e.select(BigInt(1234)); + expect(bigintSelect.__kind__).toBe($.ExpressionKind.Select); + expect(bigintSelect.__element__).toBe(e.bigint); + expect(bigintSelect.__cardinality__).toBe($.Cardinality.One); + + const bufferSelect = e.select(Buffer.from([])); + expect(bufferSelect.__kind__).toBe($.ExpressionKind.Select); + expect(bufferSelect.__element__).toBe(e.bytes); + expect(bufferSelect.__cardinality__).toBe($.Cardinality.One); + + const dateSelect = e.select(new Date()); + expect(dateSelect.__kind__).toBe($.ExpressionKind.Select); + expect(dateSelect.__element__).toBe(e.datetime); + expect(dateSelect.__cardinality__).toBe($.Cardinality.One); + + const durationSelect = e.select(new edgedb.Duration()); + expect(durationSelect.__kind__).toBe($.ExpressionKind.Select); + expect(durationSelect.__element__).toBe(e.duration); + expect(durationSelect.__cardinality__).toBe($.Cardinality.One); + + const ldrSelect = e.select(new edgedb.LocalDateTime(1, 2, 3)); + expect(ldrSelect.__kind__).toBe($.ExpressionKind.Select); + expect(ldrSelect.__element__).toBe(e.cal.local_datetime); + expect(ldrSelect.__cardinality__).toBe($.Cardinality.One); + + const ldSelect = e.select(new edgedb.LocalDate(1, 2, 3)); + expect(ldSelect.__kind__).toBe($.ExpressionKind.Select); + expect(ldSelect.__element__).toBe(e.cal.local_date); + expect(ldSelect.__cardinality__).toBe($.Cardinality.One); + + const ltSelect = e.select(new edgedb.LocalTime(1, 2, 3)); + expect(ltSelect.__kind__).toBe($.ExpressionKind.Select); + expect(ltSelect.__element__).toBe(e.cal.local_time); + expect(ltSelect.__cardinality__).toBe($.Cardinality.One); + + const rdSelect = e.select(new edgedb.RelativeDuration(1, 2, 3)); + expect(rdSelect.__kind__).toBe($.ExpressionKind.Select); + expect(rdSelect.__element__).toBe(e.cal.relative_duration); + expect(rdSelect.__cardinality__).toBe($.Cardinality.One); + + const memSelect = e.select(new edgedb.ConfigMemory(BigInt(1234))); + expect(memSelect.__kind__).toBe($.ExpressionKind.Select); + expect(memSelect.__element__).toBe(e.cfg.memory); + expect(memSelect.__cardinality__).toBe($.Cardinality.One); +}); + +test("no shape", async () => { + const query = e.select(e.default.Hero); + const result = await query.run(client); + tc.assert>(true); + expect(query.__element__.__shape__).toEqual({id: true}); + expect(result.every(val => !!val.id)).toEqual(true); +}); + +test("computed only shape", () => { + const query = e.select(e.Hero, hero => ({ + upper_name: e.str_upper(hero.name), + })); + + tc.assert, {upper_name: string}[]>>(true); }); const q1 = e.select(e.Hero, () => ({ @@ -179,8 +251,8 @@ test("polymorphic with nested modifiers", () => { ...e.is(e.Villain, { nemesis: hero => ({ name: true, - order: hero.name, - filter: e.eq(hero.name, hero.name), + order_by: hero.name, + filter: e.op(hero.name, "=", hero.name), limit: 1, offset: 10, }), @@ -221,63 +293,51 @@ test("shape type name", () => { tc.assert>(true); }); -test("limit inference", () => { - const r1 = e.select(e.Hero, () => ({name: true, limit: e.int64(1)})); - type c1 = typeof r1["__cardinality__"]; - tc.assert>(true); - expect(r1.__cardinality__).toEqual($.Cardinality.AtMostOne); - - const r2 = e.select(e.Hero, () => ({name: true, limit: e.int64(0)})); - type c2 = typeof r2["__cardinality__"]; - tc.assert>(true); - expect(r2.__cardinality__).toEqual($.Cardinality.Empty); - - const r3 = e.select(e.Hero, () => ({name: true, limit: e.int64(2)})); - type c3 = typeof r3["__cardinality__"]; - tc.assert>(true); - expect(r3.__cardinality__).toEqual($.Cardinality.Many); +test("limit/offset inference", () => { + const testSet = e.set(1, 2, 3); - const r4 = e.select(e.Hero, () => ({name: true, limit: e.set(e.int64(1))})); - type c4 = typeof r4["__cardinality__"]; - tc.assert>(true); - expect(r4.__cardinality__).toEqual($.Cardinality.AtMostOne); -}); + tc.assert< + tc.IsExact + >(true); + expect(testSet.__cardinality__).toEqual($.Cardinality.AtLeastOne); -test("limit literal inference", () => { - const r1 = e.select(e.Hero, () => ({name: true, limit: 1})); - type c1 = typeof r1["__cardinality__"]; - tc.assert>(true); - expect(r1.__cardinality__).toEqual($.Cardinality.AtMostOne); - // expect(r1.__modifiers__.limit.__element__.__name__).toEqual("std::int64"); - // expect(r1.__modifiers__.limit.__value__).toEqual(1); + const r0 = e.select(testSet, () => ({})); + tc.assert< + tc.IsExact + >(true); + expect(r0.__cardinality__).toEqual($.Cardinality.AtLeastOne); - const r2 = e.select(e.Hero, () => ({name: true, limit: 1})); - type c2 = typeof r2["__cardinality__"]; - tc.assert>(true); - expect(r2.__cardinality__).toEqual($.Cardinality.AtMostOne); + const r1 = e.select(testSet, () => ({limit: 1})); + tc.assert>( + true + ); + expect(r1.__cardinality__).toEqual($.Cardinality.Many); - const r3 = e.select(e.Hero, () => ({name: true, limit: 2})); - type c3 = typeof r3["__cardinality__"]; - tc.assert>(true); - expect(r3.__cardinality__).toEqual($.Cardinality.Many); + const r2 = e.select(testSet, () => ({offset: 1})); + tc.assert>( + true + ); + expect(r2.__cardinality__).toEqual($.Cardinality.Many); }); test("offset", () => { const q = e.select(e.Hero, () => ({name: true})); const r1 = e.select(q, () => ({offset: 5})); - expect(r1.__modifiers__.offset?.__element__.__name__).toEqual("std::int64"); + expect(r1.__modifiers__.offset?.__element__.__name__).toEqual("std::number"); }); test("infer cardinality - scalar filters", () => { const q = e.select(e.Hero); - const q2 = e.select(q, hero => ({filter: e.eq(hero.name, e.str("asdf"))})); + const q2 = e.select(q, hero => ({filter: e.op(hero.name, "=", "asdf")})); tc.assert>( true ); expect(q2.__cardinality__).toEqual($.Cardinality.AtMostOne); const u3 = e.uuid("asdf"); - const q3 = e.select(q, hero => ({filter: e.eq(hero.id, u3)})); + const q3 = e.select(q, hero => { + return {filter: e.op(hero.id, "=", u3)}; + }); tc.assert>( true ); @@ -290,7 +350,7 @@ test("infer cardinality - scalar filters", () => { expect(q4.__cardinality__).toEqual($.Cardinality.AtMostOne); const q5 = e.select(q, hero => ({ - filter: e.eq(hero.secret_identity, e.str("asdf")), + filter: e.op(hero.secret_identity, "=", "asdf"), })); tc.assert>( true @@ -298,7 +358,7 @@ test("infer cardinality - scalar filters", () => { expect(q5.__cardinality__).toEqual($.Cardinality.Many); const q6 = e.select(e.Villain.nemesis, nemesis => ({ - filter: e.eq(nemesis.name, e.str("asdf")), + filter: e.op(nemesis.name, "=", "asdf"), })); tc.assert>( true @@ -307,7 +367,7 @@ test("infer cardinality - scalar filters", () => { const strs = e.set(e.str("asdf"), e.str("qwer")); const q7 = e.select(e.Villain, villain => ({ - filter: e.eq(villain.name, strs), + filter: e.op(villain.name, "=", strs), })); tc.assert>( true @@ -316,7 +376,7 @@ test("infer cardinality - scalar filters", () => { const expr8 = e.select(e.Villain, () => ({id: true, name: true})); const q8 = e.select(expr8, villain => ({ - filter: e.eq(villain.name, e.str("asdf")), + filter: e.op(villain.name, "=", "asdf"), })); tc.assert>( true @@ -325,7 +385,7 @@ test("infer cardinality - scalar filters", () => { const expr9 = e.select(e.Villain, () => ({id: true, name: true})); const q9 = e.select(expr9, villain => ({ - filter: e.eq(villain.name, e.str("asdf")), + filter: e.op(villain.name, "=", "asdf"), })); tc.assert>( true @@ -333,7 +393,7 @@ test("infer cardinality - scalar filters", () => { expect(q9.__cardinality__).toEqual($.Cardinality.AtMostOne); const q10 = e.select(e.Villain, villain => ({ - filter: e.eq(villain.name, e.set(e.str)), + filter: e.op(villain.name, "=", e.cast(e.str, e.set())), })); tc.assert>( true @@ -342,23 +402,23 @@ test("infer cardinality - scalar filters", () => { // test cardinality inference on object equality // e.select(e.Profile).filter(e.eq(e.Profile - // [" { - const oneHero = e.select(e.Hero, () => ({limit: 1})); + const oneHero = e.select(e.Hero, () => ({limit: 1})).assert_single(); const singleHero = e.select(e.Hero, hero => ({ - filter: e.eq(hero, oneHero), + filter: e.op(hero, "=", oneHero), })); const c1 = singleHero.__cardinality__; tc.assert>(true); expect(c1).toEqual($.Cardinality.AtMostOne); - const oneProfile = e.select(e.Hero, () => ({limit: 1})); + const oneProfile = e.select(e.Hero, () => ({limit: 1})).assert_single(); const singleMovie = e.select(e.Movie, movie => ({ - filter: e.eq(movie.profile, oneProfile), + filter: e.op(movie.profile, "=", oneProfile), })); const c2 = singleMovie.__cardinality__; @@ -368,7 +428,7 @@ test("infer cardinality - object type filters", () => { // not a singleton const c3 = e.select(e.Villain, villain => ({ - filter: e.eq(villain.nemesis, oneHero), + filter: e.op(villain.nemesis, "=", oneHero), })).__cardinality__; tc.assert>(true); expect(c3).toEqual($.Cardinality.Many); @@ -376,7 +436,7 @@ test("infer cardinality - object type filters", () => { // not a singleton // technically a bug, but for now this behavior is expected const c4 = e.select(e.Villain, villain => ({ - filter: e.eq(villain, villain), + filter: e.op(villain, "=", villain), })).__cardinality__; tc.assert>(true); expect(c4).toEqual($.Cardinality.AtMostOne); @@ -392,11 +452,7 @@ test("non 'e.eq' filters", () => { expect(q1.__cardinality__).toEqual($.Cardinality.Many); const q2 = e.select(e.Hero, hero => ({ - filter: e.if_else( - e.bool(true), - e.eq(hero.name, e.str("Thanos")), - e.bool(false) - ), + filter: e.op(true, "if", e.op(hero.name, "=", "Thanos"), "else", false), })); tc.assert>( true @@ -413,7 +469,7 @@ test("fetch heroes", async () => { test("filter by id", async () => { const result = await e .select(e.Hero, hero => ({ - filter: e.eq(hero.id, e.uuid(data.spidey.id)), + filter: e.op(hero.id, "=", e.uuid(data.spidey.id)), })) .run(client); @@ -421,18 +477,20 @@ test("filter by id", async () => { }); test("limit 1", async () => { - const query = e.select(e.Hero, hero => ({ - order: hero.name, - offset: 1, - limit: 1, - })); - const result = await query.run(client); + const query = e + .select(e.Hero, hero => ({ + order_by: hero.name, + offset: 1, + limit: 1, + })) + .assert_single(); + const result = await e.select(query).run(client); expect(result?.id).toEqual(data.iron_man.id); }); test("limit 2", async () => { const query = e.select(e.Hero, hero => ({ - order: hero.name, + order_by: hero.name, offset: 1, limit: 2, })); @@ -444,7 +502,7 @@ test("limit 2", async () => { test("order by self", async () => { const query = e.select(e.Hero, hero => ({ - order: hero, + order_by: hero, })); const result = await query.run(client); expect(result).toEqual( @@ -457,8 +515,8 @@ test("order by self", async () => { test("shapes", async () => { const query = e.select( e - .select(e.Hero, hero => ({filter: e.eq(hero.name, e.str("Iron Man"))})) - .$assertSingle(), + .select(e.Hero, hero => ({filter: e.op(hero.name, "=", "Iron Man")})) + .assert_single(), () => ({ id: true, name: true, @@ -477,13 +535,16 @@ test("computables", async () => { // __type__: {name: true} id: true, })); - const query = e.select(e.Person.$is(e.Hero), hero => ({ - id: true, - computable: e.int64(35), - all_heroes, - order: hero.name, - limit: 1, - })); + const query = e.select( + e + .select(e.Person.is(e.Hero), hero => ({order_by: hero.name, limit: 1})) + .assert_single(), + hero => ({ + id: true, + computable: e.int64(35), + all_heroes, + }) + ); type query = $.setToTsType; tc.assert< @@ -509,7 +570,7 @@ test("computables", async () => { }); test("type intersections", async () => { - const query = e.select(e.Person.$is(e.Hero), () => ({ + const query = e.select(e.Person.is(e.Hero), () => ({ id: true, // __type__: {name: true}, })); @@ -521,21 +582,21 @@ test("type intersections", async () => { }); test("type intersections - static", () => { - const result = e.select(e.Movie.characters).$is(e.Villain); + const result = e.select(e.Movie.characters).is(e.Villain); type result = $.setToTsType; tc.assert>(true); }); test("backlinks", async () => { const result1 = await e - .select(e.Hero[" ({ + .select(e.Hero[" ({ id: true, // __type__: {name: true}, title: true, })) .run(client); - const q2 = e.select(e.Hero[" ({ + const q2 = e.select(e.Hero[" ({ id: true, // __type__: {name: true}, title: true, @@ -558,8 +619,7 @@ test("overrides with implicit casting", () => { })); }); -// Skipped because of bug: https://github.com/edgedb/edgedb/issues/3245 -test.skip("link properties", async () => { +test("link properties", async () => { const query = e.select(e.Movie, movie => ({ id: true, characters: char => ({ @@ -568,8 +628,6 @@ test.skip("link properties", async () => { }), })); - console.log(query.toEdgeQL()); - const result = await query.run(client); tc.assert< @@ -595,7 +653,7 @@ test("link properties in expressions", async () => { char_name: char["@character_name"], person_name: char.name, - filter: e.ilike(char["@character_name"], e.str("a%")), + filter: e.op(char["@character_name"], "ilike", "a%"), }), })); @@ -628,11 +686,13 @@ test("polymorphic link properties in expressions", async () => { char_name: char["@character_name"], person_name: char.name, - filter: e.ilike(char["@character_name"], e.str("a%")), + filter: e.op(char["@character_name"], "ilike", "a%"), }), }), })); + query.__element__.__shape__.characters; + const result = await query.run(client); tc.assert< @@ -654,9 +714,9 @@ test("polymorphic link properties in expressions", async () => { >(true); }); -// test("assertSingle this check", () => { +// test("assert_single this check", () => { // const inner = e.select(e.Hero); -// const outer = e.select(e.Hero).$assertSingle().__args__[0]; +// const outer = e.select(e.Hero).assert_single().__args__[0]; // tc.assert>(true); // }); @@ -667,7 +727,7 @@ test("filters in subqueries", async () => { id: true, name: true, }, - filter: e.eq(hero.name, e.str(data.spidey.name)), + filter: e.op(hero.name, "=", data.spidey.name), })); const res1 = await q1.run(client); @@ -680,9 +740,9 @@ test("filters in subqueries", async () => { villains: v => ({ id: true, name: true, - filter: e.ilike(v.name, e.str("%n%")), + filter: e.op(v.name, "ilike", "%n%"), }), - filter: e.eq(hero.name, e.str(data.spidey.name)), + filter: e.op(hero.name, "=", data.spidey.name), })); const res2 = await q2.run(client); @@ -710,14 +770,24 @@ test("filters in subqueries", async () => { villains: v => ({ id: true, name: true, - filter: e.eq(v.name, e.str("Thanos")), + filter: e.op(v.name, "=", "Thanos"), }), thanos: e.select(hero.villains, v => ({ name: true, - filter: e.eq(v.name, e.str("Thanos")), + filter: e.op(v.name, "=", "Thanos"), })), })); + const test = await e + .select(e.Hero.villains, v => ({ + name: true, + filter: e.op(v.name, "=", "Thanos"), + })) + .run(client); + + const arg = q3.__element__.__shape__.thanos.__element__.__shape__; + + // q3.__modifiers__. const res3 = await q3.run(client); expect(Array.isArray(res3)).toBe(true); @@ -729,6 +799,19 @@ test("filters in subqueries", async () => { tc.assert< tc.IsExact< typeof res3, + /** + * onst res3: + { + name: string; + villains: { + id: string; + name: string; + }[]; + thanos: { + name: string | undefined; + } | null; + }[] + */ { name: string; villains: { @@ -774,7 +857,7 @@ SELECT (__scope_0_Person) { [IS default::Hero].secret_identity, multi villains := ( WITH - __scope_1_Villain := (__scope_0_Person[IS default::Hero].villains) + __scope_1_Villain := ((__scope_0_Person[IS default::Hero]).villains) SELECT (__scope_1_Villain) { id, name, @@ -826,20 +909,58 @@ SELECT (__scope_0_Person) { >(true); }); -test("scoped expr select", async () => { - const unscopedQuery = e.select( - e.concat(e.concat(e.Hero.name, e.str(" is ")), e.Hero.secret_identity) - ); +test("polymorphic field in nested shape", async () => { + const query = e.select(e.Movie, movie => ({ + title: true, + characters: char => ({ + name: true, + order_by: char.name, + ...e.is(e.Hero, {secret_identity: true}), + }), + filter: e.op(movie.title, "=", "The Avengers"), + })); - const scopedQuery = e.select(e.Hero, hero => - e.concat(e.concat(hero.name, e.str(" is ")), hero.secret_identity) + const result = await query.run(client); + expect(JSON.parse(JSON.stringify(result))).toEqual([ + { + title: data.the_avengers.title, + characters: [ + { + name: data.cap.name, + secret_identity: data.cap.secret_identity, + }, + { + name: data.iron_man.name, + secret_identity: data.iron_man.secret_identity, + }, + ], + }, + ]); + + tc.assert< + tc.IsExact< + typeof result, + { + title: string; + characters: { + name: string; + secret_identity: string | null; + }[]; + }[] + > + >(true); +}); + +test("correlated path select", async () => { + const query = e.select( + e.op(e.op(e.Hero.name, "++", " is "), "++", e.Hero.secret_identity) ); + const correlatedQuery = e.with([e.Hero], query); + const heros = [data.cap, data.iron_man, data.spidey]; - expect((await unscopedQuery.run(client)).sort()).toEqual( - // heros - // .flatMap(h1 => heros.map(h2 => `${h1.name} is ${h2.secret_identity}`)) + expect((await query.run(client)).sort()).toEqual( $.util .flatMap(heros, h1 => heros.map(h2 => `${h1.name} is ${h2.secret_identity}`) @@ -847,7 +968,7 @@ test("scoped expr select", async () => { .sort() ); - expect((await scopedQuery.run(client)).sort()).toEqual( + expect((await correlatedQuery.run(client)).sort()).toEqual( heros.map(h => `${h.name} is ${h.secret_identity}`).sort() ); }); @@ -855,7 +976,7 @@ test("scoped expr select", async () => { test("modifiers on scalar selects", async () => { // filter const q1 = e.select(e.Hero.name, el => ({ - filter: e.ilike(el, e.str("%man%")), + filter: e.op(el, "ilike", "%man%"), })); const res1 = await q1.run(client); tc.assert>(true); @@ -871,25 +992,137 @@ test("modifiers on scalar selects", async () => { ); const q2 = e.select(unorderedSet, el => ({ - order: el, + order_by: el, })); const res2 = await q2.run(client); tc.assert>(true); expect(res2).toEqual([1, 2, 3, 4, 5]); const q3 = e.select(unorderedSet, el => ({ - order: {expression: el, direction: e.DESC}, + order_by: {expression: el, direction: e.DESC}, })); const res3 = await q3.run(client); tc.assert>(true); expect(res3).toEqual([5, 4, 3, 2, 1]); // offset and limit - const q4 = e.select(unorderedSet, el => ({ - offset: 2, - limit: 1, - })); - const res4 = await q4.run(client); + const q4 = e + .select(unorderedSet, el => ({ + offset: 2, + limit: 1, + })) + .assert_single(); + const res4 = await e.select(q4).run(client); tc.assert>(true); expect(res4).toEqual(1); }); + +test("nested matching scopes", async () => { + const q = e.select(e.Hero, h => ({ + name: h.name, + otherHeros: e.select(e.Hero, h2 => ({ + name: true, + names: e.op(h.name, "++", h2.name), + order_by: h2.name, + })), + order_by: h.name, + })); + + const result = await q.run(client); + + const heros = [data.cap, data.iron_man, data.spidey]; + + const expectedResult = heros.map(h => ({ + name: h.name, + otherHeros: heros.map(h2 => ({ + name: h2.name, + names: h.name + h2.name, + })), + })); + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expectedResult)); +}); + +test("runnable expressions", async () => { + const expr = e.op("Hello ", "++", "World"); + + expect(await expr.run(client)).toEqual(`Hello World`); +}); + +test("computed property path", async () => { + const numbers = e.set(1, 2, 3); + const expr = e.select({ + numbers, + }); + const query = e.select(expr.numbers); + + expect(await query.run(client)).toEqual([1, 2, 3]); +}); + +// Modifier methods removed for now, until we can fix typescript inference +// problems / excessively deep errors + +// test("modifier methods", async () => { +// const strs = ["c", "a", "aa", "b", "cc", "bb"]; +// let q3 = e.select(e.set(...strs), vals => ({ +// order_by: {expression: e.len(vals), direction: e.DESC}, +// })); + +// // reassignment allowed +// q3 = q3.order_by(vals => vals); +// tc.assert>( +// true +// ); + +// expect(await q3.run(client)).toEqual(["aa", "bb", "cc", "a", "b", "c"]); + +// const q4 = e +// .select(e.Hero, hero => ({ +// order_by: hero.name, +// })) +// .limit(2); +// const r4 = await q4.run(client); + +// expect(r4.length).toEqual(2); +// expect(await q4.limit(1).offset(1).run(client)).toEqual(r4.slice(1, 2)); + +// const q5 = e +// .select(e.Hero, hero => ({ +// name: true, +// nameLen: e.len(hero.name), +// })) +// .order_by(hero => hero.nameLen); + +// const r5 = await q5.run(client); +// }); + +// test("modifier methods", async () => { +// let freeQuery = e.select({ +// heroes: e.Hero, +// }); + +// const filteredFreeQuery = freeQuery.filter(arg => e.bool(false)); +// // methods do not change change cardinality +// tc.assert< +// tc.IsExact +// >(true); +// expect(filteredFreeQuery.__cardinality__).toEqual($.Cardinality.One); + +// const offsetFreeQuery = freeQuery.offset(3); +// // methods do not change change cardinality +// tc.assert< +// tc.IsExact +// >(true); +// expect(offsetFreeQuery.__cardinality__).toEqual($.Cardinality.One); + +// const limitFreeQuery = freeQuery.limit(1); +// // methods do not change change cardinality +// tc.assert< +// tc.IsExact +// >(true); +// expect(limitFreeQuery.__cardinality__).toEqual($.Cardinality.One); + +// // should allow reassignment +// freeQuery = freeQuery.offset(1).filter(e.bool(false)); +// expect(await freeQuery.run(client)).toEqual(null); +// }); diff --git a/qb/test/sets.test.ts b/qb/test/sets.test.ts index 3cfc6aa14..804192a34 100644 --- a/qb/test/sets.test.ts +++ b/qb/test/sets.test.ts @@ -1,15 +1,25 @@ import {$} from "edgedb"; import {tc} from "./setupTeardown"; -import e, {$infer} from "../dbschema/edgeql"; +import e, {$infer} from "../dbschema/edgeql-js"; test("empty sets", () => { - const stringSet = e.set(e.str); + expect(e.set()).toEqual(null); + + const stringSet = e.cast(e.str, e.set()); expect(stringSet.toEdgeQL()).toEqual(`{}`); tc.assert, null>>(true); - const heroSet = e.set(e.$Hero); + const $Hero = e.Hero.__element__; + const heroSet = e.cast($Hero, e.set()); expect(heroSet.toEdgeQL()).toEqual(`{}`); tc.assert, null>>(true); + + const int32Set = e.cast(e.int32, e.set()); + expect(int32Set.toEdgeQL()).toEqual(`{}`); + tc.assert, null>>(true); + tc.assert< + tc.IsExact + >(true); }); test("object set contructor", () => { @@ -30,11 +40,18 @@ test("object set contructor", () => { expect(merged.__element__.__name__).toEqual( "default::Hero UNION default::Villain UNION default::Person" ); + + expect(e.set(e.select(e.Hero), e.select(e.Villain)).toEdgeQL()) + .toEqual(`{ (SELECT (DETACHED default::Hero) { + id +}), (SELECT (DETACHED default::Villain) { + id +}) }`); }); test("scalar set contructor", () => { // single elements - const _f1 = e.set(e.str("asdf")); + const _f1 = e.set("asdf"); expect(_f1.__element__.__name__).toEqual("std::str"); expect(_f1.__cardinality__).toEqual($.Cardinality.One); expect(_f1.__element__.__kind__).toEqual($.TypeKind.scalar); @@ -46,37 +63,31 @@ test("scalar set contructor", () => { expect(_f4.__element__.__name__).toEqual("std::int32"); expect(_f4.__cardinality__).toEqual($.Cardinality.One); expect(_f4.__element__.__kind__).toEqual($.TypeKind.scalar); - expect(_f4.toEdgeQL()).toEqual(`{ 42 }`); + expect(_f4.toEdgeQL()).toEqual(`{ 42 }`); type _f4 = $infer; tc.assert>(true); // multiple elements - const _f2 = e.set(e.str("asdf"), e.str("qwer"), e.str("poiu")); + const _f2 = e.set("asdf", "qwer", e.str("poiu")); expect(_f2.__element__.__name__).toEqual("std::str"); expect(_f2.__cardinality__).toEqual($.Cardinality.AtLeastOne); expect(_f2.toEdgeQL()).toEqual(`{ "asdf", "qwer", "poiu" }`); type _f2 = $infer; tc.assert>(true); - const _f3 = e.set(e.int64(1), e.int64(2), e.int64(3)); - expect(_f3.__element__.__name__).toEqual("std::int64"); + const _f3 = e.set(1, 2, 3); + expect(_f3.__element__.__name__).toEqual("std::number"); expect(_f3.__cardinality__).toEqual($.Cardinality.AtLeastOne); expect(_f3.toEdgeQL()).toEqual(`{ 1, 2, 3 }`); type _f3 = $infer; tc.assert>(true); // implicit casting - const _f5 = e.set(e.int32(5), e.float32(1234.5)); - expect(_f5.__element__.__name__).toEqual("std::float64"); - expect(_f5.toEdgeQL()).toEqual(`{ 5, 1234.5 }`); + const _f5 = e.set(5, e.literal(e.float32, 1234.5)); + expect(_f5.__element__.__name__).toEqual("std::number"); + expect(_f5.toEdgeQL()).toEqual(`{ 5, 1234.5 }`); type _f5 = $infer; tc.assert>(true); - - const _f6 = e.set(e.int16(5), e.bigint(BigInt(1234))); - expect(_f6.__element__.__name__).toEqual("std::bigint"); - expect(_f6.toEdgeQL()).toEqual(`{ 5, 1234n }`); - type _f6 = $infer; - tc.assert>(true); }); test("invalid sets", () => { @@ -85,6 +96,9 @@ test("invalid sets", () => { e.set(e.Hero, e.int64(1243)); }).toThrow(); + // @ts-expect-error + expect(() => e.set(e.int64(5), e.bigint(BigInt(1234)))).toThrow(); + // never expect(() => { // @ts-expect-error diff --git a/qb/test/setupTeardown.ts b/qb/test/setupTeardown.ts index 096012229..e92f42d08 100644 --- a/qb/test/setupTeardown.ts +++ b/qb/test/setupTeardown.ts @@ -72,7 +72,7 @@ SELECT (INSERT Movie { title := "The Avengers", rating := 10, genre := Genre.Action, - characters := (SELECT Hero FILTER .id IN char_ids) + characters := (SELECT Person FILTER .id IN char_ids) }) {id, title, rating, genre, characters: {id}};`, {character_ids: [iron_man.id, cap.id]} ); diff --git a/qb/test/testRunner.ts b/qb/test/testRunner.ts index 0493ee37a..70239c34b 100644 --- a/qb/test/testRunner.ts +++ b/qb/test/testRunner.ts @@ -67,7 +67,7 @@ async function generateQB(config: ConnectConfig) { await runCommand( "yarn", - ["edgedb-generate", "--force-overwrite"], + ["edgeql-js", "--force-overwrite"], configToEnv(config) ); } diff --git a/qb/test/update.test.ts b/qb/test/update.test.ts index 16b5b2f12..f31b5219a 100644 --- a/qb/test/update.test.ts +++ b/qb/test/update.test.ts @@ -1,11 +1,14 @@ import * as edgedb from "edgedb"; -import e from "../dbschema/edgeql"; -import {setupTests, teardownTests, TestData} from "./setupTeardown"; +import e from "../dbschema/edgeql-js"; +import {setupTests, tc, teardownTests, TestData} from "./setupTeardown"; let client: edgedb.Client; let data: TestData; +const $Hero = e.Hero.__element__; +const $Villain = e.Villain.__element__; + beforeAll(async () => { const setup = await setupTests(); ({client, data} = setup); @@ -16,96 +19,155 @@ afterAll(async () => { }); test("update", async () => { - e.select(e.Hero).update({ - name: e.str("asdf"), - }); - - e.select(e.Villain).update({ - name: e.str("asdf"), - nemesis: e.set(e.$Hero), - }); + e.update(e.Hero, () => ({ + set: { + name: "asdf", + }, + })).toEdgeQL(); + + e.update(e.Villain, () => ({ + set: { + name: e.str("asdf"), + nemesis: e.cast($Hero, e.set()), + }, + })).toEdgeQL(); + + e.update(e.Bag, () => ({ + set: { + stringsMulti: { + "+=": "new string", + }, + }, + })).toEdgeQL(); }); test("update assignable", () => { - e.select(e.Bag).update({ - int32Field: e.int64(23), - int64Field: e.int16(12), - // @ts-expect-error - bigintField: e.float32(324), - // @ts-expect-error - float32Field: e.bigint(BigInt(1234)), - }); + e.update(e.Bag, () => ({ + set: { + int32Field: e.float32(23), + int64Field: e.float64(12), + // @ts-expect-error + bigintField: e.float32(324), + // @ts-expect-error + float32Field: e.bigint(BigInt(1234)), + }, + })).toEdgeQL(); + + e.update(e.Bag, () => ({ + set: { + int32Field: 23, + bigintField: BigInt(324), + // @ts-expect-error + float32Field: BigInt(1234), + }, + })).toEdgeQL(); + + e.update(e.Movie, () => ({ + set: { + rating: null, + profile: null, + // @ts-expect-error release_year is required prop + release_year: null, + }, + })).toEdgeQL(); }); -test("update link property", async () => { - const theAvengers = e.select(e.Movie, movie => ({ - filter: e.eq(movie.title, e.str("The Avengers")), - limit: 1, +test("scoped update", async () => { + const query = e.update(e.Hero, hero => ({ + filter: e.op(hero.name, "=", data.spidey.name), + set: { + name: e.op("The Amazing ", "++", hero.name), + }, })); + const result = await query.run(client); + tc.assert>(true); + + expect(result).toEqual({id: data.spidey.id}); + + expect( + await e + .select(e.Hero, hero => ({ + name: true, + filter: e.op(hero.id, "=", e.uuid(result!.id)), + })) + .run(client) + ).toEqual({id: data.spidey.id, name: `The Amazing ${data.spidey.name}`}); +}); + +test("update link property", async () => { + const theAvengers = e + .select(e.Movie, movie => ({ + filter: e.op(movie.title, "=", "The Avengers"), + limit: 1, + })) + .assert_single(); + const qq1 = await e .select(theAvengers, () => ({id: true, characters: true})) .run(client); expect(qq1?.characters.length).toEqual(2); - const q2 = theAvengers.update({ - characters: { - "+=": e.select(e.Villain, villain => ({ - filter: e.eq(villain.name, e.str(data.thanos.name)), - })), + const q2 = e.update(theAvengers, () => ({ + set: { + characters: { + "+=": e.select(e.Villain, villain => ({ + filter: e.op(villain.name, "=", data.thanos.name), + })), + }, }, - }); - // console.log(q2.toEdgeQL()); - await client.execute(q2.toEdgeQL()); + })); + await q2.run(client); const t2 = await e .select(theAvengers, () => ({id: true, characters: true})) .run(client); expect(t2?.characters.length).toEqual(3); - await client.execute( - theAvengers - .update({ + await e + .update(theAvengers, () => ({ + set: { characters: { "-=": e.select(e.Villain, villain => ({ - filter: e.eq(villain.name, e.str(data.thanos.name)), + filter: e.op(villain.name, "=", data.thanos.name), })), }, - }) - .toEdgeQL() - ); + }, + })) + .run(client); const t3 = await e .select(theAvengers, () => ({id: true, characters: true})) .run(client); expect(t3?.characters.length).toEqual(2); - await client.execute( - theAvengers - .update({ - characters: e.set(e.$Villain), - }) - .toEdgeQL() - ); + await e + .update(theAvengers, () => ({ + set: { + characters: e.cast($Villain, e.set()), + }, + })) + .run(client); const t4 = await e .select(theAvengers, () => ({id: true, characters: true})) .run(client); expect(t4?.characters.length).toEqual(0); - await client.execute( - theAvengers - .update({ + await e + .update(theAvengers, () => ({ + set: { characters: e.select(e.Hero, hero => ({ - filter: e.in( + filter: e.op( hero.id, + "in", e.set(e.uuid(data.cap.id), e.uuid(data.iron_man.id)) ), })), - }) - .toEdgeQL() - ); + }, + })) + .run(client); const t5 = await e .select(theAvengers, () => ({id: true, characters: true})) diff --git a/qb/test/with.test.ts b/qb/test/with.test.ts index 25df7d90c..59d1144fb 100644 --- a/qb/test/with.test.ts +++ b/qb/test/with.test.ts @@ -1,20 +1,21 @@ import {$} from "edgedb"; -import e from "../dbschema/edgeql"; +import e from "../dbschema/edgeql-js"; import {tc} from "./setupTeardown"; test("simple repeated expression", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); - expect(e.select(e.plus(numbers, numbers)).toEdgeQL()).toEqual(`WITH - __withVar_0 := ({ 1, 2, 3 }) + expect(e.select(e.op(numbers, "+", numbers)).toEdgeQL()).toEqual(`WITH + __withVar_0 := ({ 1, 2, 3 }) SELECT ((__withVar_0 + __withVar_0))`); }); test("simple expression with alias", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); - expect(e.select(e.plus(numbers, e.alias(numbers))).toEdgeQL()).toEqual(`WITH - __withVar_0 := ({ 1, 2, 3 }), + expect(e.select(e.op(numbers, "+", e.alias(numbers))).toEdgeQL()) + .toEqual(`WITH + __withVar_0 := ({ 1, 2, 3 }), __withVar_1 := (__withVar_0) SELECT ((__withVar_0 + __withVar_1))`); }); @@ -22,7 +23,7 @@ SELECT ((__withVar_0 + __withVar_1))`); test("implicit WITH vars referencing each other", () => { const skip = e.int64(10); const remainingHeros = e.select(e.Hero, hero => ({ - order: hero.id, + order_by: hero.id, offset: skip, })); const pageResults = e.select(remainingHeros, () => ({ @@ -33,8 +34,8 @@ test("implicit WITH vars referencing each other", () => { const query = e.select({ pageResults, - nextOffset: e.plus(skip, e.count(pageResults)), - hasMore: e.select(e.gt(e.count(remainingHeros), e.int64(10))), + nextOffset: e.op(skip, "+", e.count(pageResults)), + hasMore: e.select(e.op(e.count(remainingHeros), ">", 10)), }); expect(query.toEdgeQL()).toEqual(`WITH @@ -80,21 +81,21 @@ SELECT { }); test("simple repeated expression not in select expr", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); - expect(() => e.plus(numbers, numbers).toEdgeQL()).toThrow(); + expect(() => e.op(numbers, "+", numbers).toEdgeQL()).toThrow(); }); test("explicit WITH block", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); expect(e.with([numbers], e.select(numbers)).toEdgeQL()).toEqual(`WITH - __withVar_0 := ({ 1, 2, 3 }) + __withVar_0 := ({ 1, 2, 3 }) SELECT (__withVar_0)`); }); test("explicit WITH block in nested query", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); expect( e @@ -105,14 +106,14 @@ test("explicit WITH block in nested query", () => { ).toEqual(`SELECT { multi nested := ( WITH - __withVar_0 := ({ 1, 2, 3 }) + __withVar_0 := ({ 1, 2, 3 }) SELECT (__withVar_0) ) }`); }); test("explicit WITH in nested query, var used outside WITH block", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); expect(() => e @@ -125,7 +126,7 @@ test("explicit WITH in nested query, var used outside WITH block", () => { }); test("explicit WITH block nested in implicit WITH block", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); const explicitWith = e.with([numbers], e.select(numbers)); @@ -139,7 +140,7 @@ test("explicit WITH block nested in implicit WITH block", () => { ).toEqual(`WITH __withVar_0 := ( WITH - __withVar_1 := ({ 1, 2, 3 }) + __withVar_1 := ({ 1, 2, 3 }) SELECT (__withVar_1) ) SELECT { @@ -149,7 +150,7 @@ SELECT { }); test("explicit WITH block nested in explicit WITH block", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); const explicitWith = e.with([numbers], e.select(numbers)); @@ -165,7 +166,7 @@ test("explicit WITH block nested in explicit WITH block", () => { ).toEqual(`WITH __withVar_0 := ( WITH - __withVar_1 := ({ 1, 2, 3 }) + __withVar_1 := ({ 1, 2, 3 }) SELECT (__withVar_1) ) SELECT { @@ -174,8 +175,8 @@ SELECT { }); test("explicit WITH block nested in explicit WITH block, sub expr explicitly extracted", () => { - const number = e.int32(2); - const numbers = e.set(e.int64(1), number, e.int16(3)); + const number = e.int64(2); + const numbers = e.set(e.int64(1), number, e.int64(3)); const explicitWith = e.with([numbers], e.select(numbers)); @@ -189,10 +190,10 @@ test("explicit WITH block nested in explicit WITH block, sub expr explicitly ext ) .toEdgeQL() ).toEqual(`WITH - __withVar_2 := (2), + __withVar_2 := (2), __withVar_0 := ( WITH - __withVar_1 := ({ 1, __withVar_2, 3 }) + __withVar_1 := ({ 1, __withVar_2, 3 }) SELECT (__withVar_1) ) SELECT { @@ -201,8 +202,8 @@ SELECT { }); test("explicit WITH nested in explicit WITH, expr declared in both", () => { - const number = e.int32(2); - const numbers = e.set(e.int64(1), number, e.int16(3)); + const number = e.int64(2); + const numbers = e.set(e.int64(1), number, e.int64(3)); const explicitWith = e.with([numbers], e.select(numbers)); @@ -219,8 +220,8 @@ test("explicit WITH nested in explicit WITH, expr declared in both", () => { }); test("explicit WITH block nested in explicit WITH block, sub expr implicitly extracted", () => { - const number = e.int32(2); - const numbers = e.set(e.int64(1), number, e.int16(3)); + const number = e.int64(2); + const numbers = e.set(e.int64(1), number, e.int64(3)); const explicitWith = e.with([numbers], e.select(numbers)); @@ -235,10 +236,10 @@ test("explicit WITH block nested in explicit WITH block, sub expr implicitly ext ) .toEdgeQL() ).toEqual(`WITH - __withVar_2 := (2), + __withVar_2 := (2), __withVar_0 := ( WITH - __withVar_1 := ({ 1, __withVar_2, 3 }) + __withVar_1 := ({ 1, __withVar_2, 3 }) SELECT (__withVar_1) ) SELECT { @@ -250,7 +251,7 @@ SELECT { test("implicit WITH and explicit WITH in sub expr", () => { const skip = e.int64(10); const remainingHeros = e.select(e.Hero, hero => ({ - order: hero.id, + order_by: hero.id, offset: skip, })); const pageResults = e.select(remainingHeros, () => ({ @@ -259,12 +260,12 @@ test("implicit WITH and explicit WITH in sub expr", () => { limit: 10, })); - const nextOffset = e.plus(skip, e.count(pageResults)); + const nextOffset = e.op(skip, "+", e.count(pageResults)); const query = e.select({ pageResults, nextOffset: e.with([nextOffset], e.select(nextOffset)), - hasMore: e.select(e.gt(e.count(remainingHeros), e.int64(10))), + hasMore: e.select(e.op(e.count(remainingHeros), ">", 10)), }); expect(query.toEdgeQL()).toEqual(`WITH @@ -299,7 +300,7 @@ SELECT { }); test("explicit WITH nested in implicit WITH + alias implicit", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); const numbersAlias = e.alias(numbers); @@ -315,7 +316,7 @@ test("explicit WITH nested in implicit WITH + alias implicit", () => { ).toEqual(`WITH __withVar_0 := ( WITH - __withVar_1 := ({ 1, 2, 3 }), + __withVar_1 := ({ 1, 2, 3 }), __withVar_2 := (__withVar_1) SELECT { multi numbers := (__withVar_1), @@ -329,7 +330,7 @@ SELECT { }); test("explicit WITH nested in implicit WITH + alias explicit", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); const numbersAlias = e.alias(numbers); @@ -348,7 +349,7 @@ test("explicit WITH nested in implicit WITH + alias explicit", () => { ).toEqual(`WITH __withVar_0 := ( WITH - __withVar_1 := ({ 1, 2, 3 }), + __withVar_1 := ({ 1, 2, 3 }), __withVar_2 := (__withVar_1) SELECT { multi numbers := (__withVar_1), @@ -362,7 +363,7 @@ SELECT { }); test("explicit WITH nested in implicit WITH + alias outside WITH", () => { - const numbers = e.set(e.int64(1), e.int32(2), e.int16(3)); + const numbers = e.set(e.int64(1), e.int64(2), e.int64(3)); const numbersAlias = e.alias(numbers); @@ -383,17 +384,16 @@ test( "explicit WITH block nested in explicit WITH block, " + "alias declared in inner WITH", () => { - const number = e.int32(2); - const numbers = e.set(e.int64(1), number, e.int16(3)); + const number = e.int64(2); + const numbers = e.set(e.int64(1), number, e.int64(3)); const numbersAlias = e.alias(numbers); - const arg = e.plus(numbers, numbersAlias); + const arg = e.op(numbers, "+", numbersAlias); const explicitWith = e.with( [numbersAlias], - e.select(e.plus(numbers, numbersAlias)) + e.select(e.op(numbers, "+", numbersAlias)) ); - // explicitWith. expect( e @@ -405,7 +405,7 @@ test( ) .toEdgeQL() ).toEqual(`WITH - __withVar_1 := ({ 1, 2, 3 }), + __withVar_1 := ({ 1, 2, 3 }), __withVar_0 := ( WITH __withVar_2 := (__withVar_1) @@ -421,15 +421,15 @@ test( "explicit WITH block nested in explicit WITH block, " + "alias of alias declared in inner WITH", () => { - const number = e.int32(2); - const numbers = e.set(e.int64(1), number, e.int16(3)); + const number = e.int64(2); + const numbers = e.set(e.int64(1), number, e.int64(3)); const numbersAlias = e.alias(numbers); const numbersAlias2 = e.alias(numbersAlias); const explicitWith = e.with( [numbersAlias2], - e.select(e.plus(numbers, numbersAlias2)) + e.select(e.op(numbers, "+", numbersAlias2)) ); expect( @@ -442,7 +442,7 @@ test( ) .toEdgeQL() ).toEqual(`WITH - __withVar_1 := ({ 1, 2, 3 }), + __withVar_1 := ({ 1, 2, 3 }), __withVar_2 := (__withVar_1), __withVar_0 := ( WITH @@ -456,11 +456,11 @@ SELECT { ); test("query with no WITH block", () => { - const query = e.select(e.Person.$is(e.Hero), person => ({ + const query = e.select(e.Person.is(e.Hero), person => ({ id: true, computable: e.int64(35), all_heroes: e.select(e.Hero, () => ({__type__: {name: true}})), - order: person.name, + order_by: person.name, limit: 1, })); @@ -483,14 +483,15 @@ SELECT (__scope_0_Hero) { } ) } -ORDER BY __scope_0_Hero.name +ORDER BY (__scope_0_Hero).name LIMIT 1`); }); test("repeated expression referencing scoped select object", () => { const query = e.select(e.Hero, hero => { - const secret = e.concat( - e.concat(hero.name, e.str(" is ")), + const secret = e.op( + e.op(hero.name, "++", " is "), + "++", hero.secret_identity ); return { diff --git a/qb/tsconfig.build.json b/qb/tsconfig.build.json index 887e33d42..78717b834 100644 --- a/qb/tsconfig.build.json +++ b/qb/tsconfig.build.json @@ -4,6 +4,7 @@ "outDir": "dist", }, "include": [ - "dbschema/edgeql", + "dbschema/edgeql-js", + "test" ], } diff --git a/qb/yarn.lock b/qb/yarn.lock index 66bf8ba94..889267850 100644 --- a/qb/yarn.lock +++ b/qb/yarn.lock @@ -1521,7 +1521,7 @@ __metadata: version: 0.0.0-use.local resolution: "edgedb@portal:..::locator=query-builder%40workspace%3A." bin: - edgedb-generate: ./dist/reflection/cli.js + edgeql-js: ./dist/reflection/cli.js languageName: node linkType: soft diff --git a/src/codecs/datetime.ts b/src/codecs/datetime.ts index ee4aa6108..76181f888 100644 --- a/src/codecs/datetime.ts +++ b/src/codecs/datetime.ts @@ -114,9 +114,7 @@ export class LocalDateTimeCodec extends ScalarCodec implements ICodec { export class LocalDateCodec extends ScalarCodec implements ICodec { encode(buf: WriteBuffer, object: any): void { if (!(object instanceof LocalDate)) { - throw new Error( - `a LocalDateTime instance was expected, got "${object}"` - ); + throw new Error(`a LocalDate instance was expected, got "${object}"`); } buf.writeInt32(4); buf.writeInt32(LocalDateToOrdinal(object) - DATESHIFT_ORD); diff --git a/src/codecs/namedtuple.ts b/src/codecs/namedtuple.ts index 2a60231d4..4d263d445 100644 --- a/src/codecs/namedtuple.ts +++ b/src/codecs/namedtuple.ts @@ -41,9 +41,7 @@ export class NamedTupleCodec extends Codec implements ICodec, IArgsCodec { encodeArgs(args: any): Buffer { if (args == null) { - throw new Error( - "a named arguments was expected, got a null value instead" - ); + throw new Error("One or more named arguments expected, received null"); } const keys = Object.keys(args); @@ -55,7 +53,7 @@ export class NamedTupleCodec extends Codec implements ICodec, IArgsCodec { if (keys.length > codecsLen) { const extraKeys = keys.filter(key => !namesSet.has(key)); throw new Error( - `unexpected named argument${ + `Unused named argument${ extraKeys.length === 1 ? "" : "s" }: "${extraKeys.join('", "')}"` ); diff --git a/src/codecs/object.ts b/src/codecs/object.ts index 9a840be20..5c851e7df 100644 --- a/src/codecs/object.ts +++ b/src/codecs/object.ts @@ -112,9 +112,7 @@ export class ObjectCodec extends Codec implements ICodec { _encodeNamedArgs(args: any): Buffer { if (args == null) { - throw new Error( - "a named arguments was expected, got a null value instead" - ); + throw new Error("One or more named arguments expected, received null"); } const keys = Object.keys(args); @@ -124,9 +122,9 @@ export class ObjectCodec extends Codec implements ICodec { const codecsLen = codecs.length; if (keys.length > codecsLen) { - const extraKeys = keys.filter((key) => !namesSet.has(key)); + const extraKeys = keys.filter(key => !namesSet.has(key)); throw new Error( - `unexpected named argument${ + `Unused named argument${ extraKeys.length === 1 ? "" : "s" }: "${extraKeys.join('", "')}"` ); diff --git a/src/rawConn.ts b/src/rawConn.ts index 72f7d2fa5..ab1946073 100644 --- a/src/rawConn.ts +++ b/src/rawConn.ts @@ -953,7 +953,13 @@ export class RawConnection { private _encodeArgs(args: QueryArgs, inCodec: ICodec): Buffer { if (versionGreaterThanOrEqual(this.protocolVersion, [0, 12])) { - if (inCodec === NULL_CODEC && !args) { + if (inCodec === NULL_CODEC) { + if (args != null) { + throw new errors.QueryArgumentError( + `This query does not contain any query parameters, ` + + `but query arguments were provided to the 'query*()' method` + ); + } return NullCodec.BUFFER; } @@ -964,7 +970,13 @@ export class RawConnection { // Shouldn't ever happen. throw new Error("invalid input codec"); } else { - if (inCodec === EMPTY_TUPLE_CODEC && !args) { + if (inCodec === EMPTY_TUPLE_CODEC) { + if (args != null) { + throw new errors.QueryArgumentError( + `This query does not contain any query parameters, ` + + `but query arguments were provided to the 'query*()' method` + ); + } return EmptyTupleCodec.BUFFER; } diff --git a/src/reflection/cli.ts b/src/reflection/cli.ts index fbe9f4c15..a5c77c1b7 100644 --- a/src/reflection/cli.ts +++ b/src/reflection/cli.ts @@ -10,6 +10,9 @@ import { } from "../conUtils"; import {configFileHeader, exitWithError, generateQB} from "./generate"; +const rmdir = + Number(process.versions.node.split(".")[0]) >= 16 ? fs.rm : fs.rmdir; + interface Options { showHelp?: boolean; target?: "ts" | "esm" | "cjs"; @@ -136,7 +139,7 @@ const run = async () => { } if (options.showHelp) { - console.log(`edgedb-generate + console.log(`edgeql-js Introspects the schema of an EdgeDB instance and generates a TypeScript/JavaScript query builder @@ -202,7 +205,7 @@ OPTIONS: ); const overrideTargetMessage = ` To override this, use the --target flag. - Run \`npx edgedb-generate --help\` for details.`; + Run \`npx edgeql-js --help\` for details.`; if (tsconfigExists) { options.target = "ts"; @@ -228,7 +231,7 @@ OPTIONS: const outputDir = options.outputDir ? path.resolve(projectRoot, options.outputDir || "") - : path.join(projectRoot, "dbschema", "edgeql"); + : path.join(projectRoot, "dbschema", "edgeql-js"); const relativeOutputDir = path.posix.relative(projectRoot, outputDir); const outputDirInProject = @@ -249,7 +252,7 @@ OPTIONS: if (await exists(outputDir)) { if (await canOverwrite(outputDir, options)) { - await fs.rmdir(outputDir, {recursive: true}); + await rmdir(outputDir, {recursive: true}); } } else { // output dir doesn't exist, so assume first run @@ -327,11 +330,9 @@ async function canOverwrite(outputDir: string, options: Options) { let config: any = null; try { - const [header, ..._config] = ( - await readFileUtf8(path.join(outputDir, "config.json")) - ).split("\n"); - if (header === configFileHeader) { - config = JSON.parse(_config.join("\n")); + const configFile = await readFileUtf8(path.join(outputDir, "config.json")); + if (configFile.startsWith(configFileHeader)) { + config = JSON.parse(configFile.slice(configFileHeader.length)); if (config.target === options.target) { return true; diff --git a/src/reflection/enums.ts b/src/reflection/enums.ts index b776099a2..dd51882c3 100644 --- a/src/reflection/enums.ts +++ b/src/reflection/enums.ts @@ -8,6 +8,7 @@ export enum Cardinality { export enum TypeKind { scalar = "scalar", + // castonlyscalar = "castonlyscalar", enum = "enum", object = "object", namedtuple = "namedtuple", @@ -20,6 +21,7 @@ export enum ExpressionKind { Array = "Array", Tuple = "Tuple", NamedTuple = "NamedTuple", + TuplePath = "TuplePath", PathNode = "PathNode", PathLeaf = "PathLeaf", Literal = "Literal", diff --git a/src/reflection/funcops.ts b/src/reflection/funcops.ts new file mode 100644 index 000000000..15d8b38f6 --- /dev/null +++ b/src/reflection/funcops.ts @@ -0,0 +1,32 @@ +import {BaseTypeSet, Expression, TypeSet} from "./typesystem"; +import {ExpressionKind, OperatorKind} from "./enums"; + +export type $expr_Function< + Name extends string = string, + Args extends (BaseTypeSet | undefined)[] = (BaseTypeSet | undefined)[], + NamedArgs extends {[key: string]: BaseTypeSet} = { + [key: string]: BaseTypeSet; + }, + ReturnType extends BaseTypeSet = BaseTypeSet +> = Expression<{ + __element__: ReturnType["__element__"]; + __cardinality__: ReturnType["__cardinality__"]; + __kind__: ExpressionKind.Function; + __name__: Name; + __args__: Args; + __namedargs__: NamedArgs; +}>; + +export type $expr_Operator< + Name extends string = string, + OpKind extends OperatorKind = OperatorKind, + Args extends TypeSet[] = TypeSet[], + ReturnType extends TypeSet = TypeSet +> = Expression<{ + __element__: ReturnType["__element__"]; + __cardinality__: ReturnType["__cardinality__"]; + __kind__: ExpressionKind.Operator; + __name__: Name; + __opkind__: OpKind; + __args__: Args; +}>; diff --git a/src/reflection/generate.ts b/src/reflection/generate.ts index 4db6800d7..d42a2ae22 100644 --- a/src/reflection/generate.ts +++ b/src/reflection/generate.ts @@ -17,12 +17,12 @@ import {generateScalars} from "./generators/generateScalars"; import {generateObjectTypes} from "./generators/generateObjectTypes"; import {generateRuntimeSpec} from "./generators/generateRuntimeSpec"; import {generateFunctionTypes} from "./generators/generateFunctionTypes"; -import {generateOperatorTypes} from "./generators/generateOperatorTypes"; +import {generateOperators} from "./generators/generateOperatorTypes"; import {generateSetImpl} from "./generators/generateSetImpl"; const DEBUG = false; -export const configFileHeader = `// edgedb-js query builder - to update run 'edgedb-generate'`; +export const configFileHeader = `// EdgeDB query builder. To update, run \`npx edgeql-js\``; export type GeneratorParams = { dir: DirBuilder; @@ -94,7 +94,7 @@ export async function generateQB(params: { generateScalars(generatorParams); generateObjectTypes(generatorParams); generateFunctionTypes(generatorParams); - generateOperatorTypes(generatorParams); + generateOperators(generatorParams); generateSetImpl(generatorParams); // generate module imports @@ -104,6 +104,7 @@ export async function generateQB(params: { importsFile.addExportStarFrom("edgedb", "edgedb"); importsFile.addExportFrom({spec: true}, "./__spec__", true); importsFile.addExportStarFrom("syntax", "./syntax/syntax", true); + importsFile.addExportStarFrom("castMaps", "./castMaps", true); ///////////////////////// // generate index file @@ -113,9 +114,15 @@ export async function generateQB(params: { index.addExportStarFrom(null, "./castMaps", true); index.addExportStarFrom(null, "./syntax/syntax", true); index.addImport({$: true}, "edgedb"); + index.addExportFrom({createClient: true}, "edgedb", true); index.addStarImport("$syntax", "./syntax/syntax", true); + index.addStarImport("$op", "./operators", true); const spreadModules = [ + { + name: "$op", + keys: ["op"], + }, { name: "$syntax", keys: [ @@ -171,6 +178,7 @@ export async function generateQB(params: { } } + index.nl(); index.writeln([ dts`declare `, `const ExportDefault`, @@ -213,6 +221,17 @@ export async function generateQB(params: { }); index.writeln([r`};`]); index.addExport("ExportDefault", undefined, true); + + // re-export some reflection types + index.addExportFrom({Cardinality: true}, "edgedb/dist/reflection"); + index.writeln([ + t`export `, + dts`declare `, + t`type Set< + Type extends $.BaseType, + Cardinality extends $.Cardinality = $.Cardinality.Many +> = $.TypeSet;`, + ]); } finally { await cxn.close(); } diff --git a/src/reflection/generators/generateCastMaps.ts b/src/reflection/generators/generateCastMaps.ts index 0009972e5..cca58dd8d 100644 --- a/src/reflection/generators/generateCastMaps.ts +++ b/src/reflection/generators/generateCastMaps.ts @@ -1,16 +1,23 @@ import {CodeBuffer, dts, r, t, ts} from "../builders"; import type {GeneratorParams} from "../generate"; -import {getRef, joinFrags, quote} from "../util/genutil"; +import { + getRef, + joinFrags, + literalToScalarMapping, + quote, + scalarToLiteralMapping, +} from "../util/genutil"; import {util} from "../util/util"; import {getStringRepresentation} from "./generateObjectTypes"; const getRuntimeRef = (name: string) => getRef(name, {prefix: ""}); export const generateCastMaps = (params: GeneratorParams) => { - const {dir, types, casts} = params; + const {dir, types, casts, typesByName} = params; const {implicitCastMap} = casts; const f = dir.getPath("castMaps"); + f.addStarImport("edgedb", "edgedb"); f.addImport({$: true}, "edgedb", false, ["ts", "dts"]); const reverseTopo = Array.from(types) @@ -77,9 +84,7 @@ export const generateCastMaps = (params: GeneratorParams) => { const outerCastableTo = casting(outer.id); staticMap.writeln([t` A extends ${getRef(outer.name)} ?`]); - runtimeMap.writeln([ - r` if (a.__name__ === ${getRuntimeRef(outer.name)}.__name__) {`, - ]); + runtimeMap.writeln([r` if (a.__name__ === ${quote(outer.name)}) {`]); for (const inner of materialScalars) { const innerCastableTo = casting(inner.id); @@ -101,9 +106,7 @@ export const generateCastMaps = (params: GeneratorParams) => { if (validCast) { staticMap.writeln([t` B extends ${getRef(inner.name)} ?`]); - runtimeMap.writeln([ - r` if(b.__name__ === ${getRuntimeRef(inner.name)}.__name__) {`, - ]); + runtimeMap.writeln([r` if(b.__name__ === ${quote(inner.name)}) {`]); if (sameType) { staticMap.writeln([t` B`]); @@ -169,6 +172,8 @@ export const generateCastMaps = (params: GeneratorParams) => { )}`, r` {`, ]); + f.writeln([r` a = (a`, t` as any`, r`).__casttype__ ?? a;`]); + f.writeln([r` b = (b`, t` as any`, r`).__casttype__ ?? b;`]); f.addExport("getSharedParentScalar"); f.writeBuf(runtimeMap); @@ -251,7 +256,118 @@ export const generateCastMaps = (params: GeneratorParams) => { const _a = implicitCastMap.get(from), _b = _a != null ? _a.has(to) : null; return _b != null ? _b : false; -};\n`, +};\n\n`, ]); f.addExport("isImplicitlyCastableTo"); + + // scalar literals mapping // + + f.writeln([ + t`export `, + dts`declare `, + t`type scalarLiterals =\n | ${Object.keys(literalToScalarMapping).join( + "\n | " + )};\n\n`, + ]); + + f.writeln([ + dts`declare`, + t`type getTsType = T extends $.ScalarType`, + ]); + f.writeln([ + t` ? T extends ${joinFrags( + [...types.values()] + .filter(type => { + return ( + type.kind === "scalar" && + !type.is_abstract && + !type.enum_values && + !type.material_id && + !type.castOnlyType && + (!scalarToLiteralMapping[type.name] || + !scalarToLiteralMapping[type.name].literalKind) + ); + }) + .map(scalar => getRef(scalar.name)), + " | " + )}`, + ]); + f.writeln([t` ? never`]); + f.writeln([t` : T["__tstype__"]`]); + f.writeln([t` : never;`]); + f.writeln([ + t`export `, + dts`declare `, + t`type orScalarLiteral =`, + ]); + f.writeln([t` | T`]); + f.writeln([ + t` | ($.BaseTypeSet extends T ? scalarLiterals : getTsType);\n\n`, + ]); + + f.writeln([ + t`export `, + dts`declare `, + t`type scalarWithConstType< + T extends $.ScalarType, + TsConstType +> = $.ScalarType< + T["__name__"], + T["__tstype__"], + T["__castable__"], + TsConstType +>;`, + ]); + + f.writeln([ + t`export `, + dts`declare `, + t`type literalToScalarType =`, + ]); + for (const [literal, {type}] of Object.entries(literalToScalarMapping)) { + f.writeln([ + t` T extends ${literal} ? scalarWithConstType<${getRef(type)}, T> :`, + ]); + } + f.writeln([t` $.BaseType;\n\n`]); + + f.writeln([ + dts`declare `, + t`type literalToTypeSet = T extends $.TypeSet`, + ]); + f.writeln([t` ? T`]); + f.writeln([t` : $.$expr_Literal>;\n\n`]); + + f.writeln([t`export `, dts`declare `, t`type mapLiteralToTypeSet = {`]); + f.writeln([t` [k in keyof T]: literalToTypeSet;`]); + f.writeln([t`};\n\n`]); + + f.addImport({$getType: true}, "./syntax/literal"); + + f.writeln([ + r`function literalToTypeSet(type`, + ts`: any`, + r`)`, + ts`: $.TypeSet`, + r` {`, + ]); + f.writeln([r` if (type?.__element__) {`]); + f.writeln([r` return type;`]); + f.writeln([r` }`]); + for (const [literalType, {literalKind, type}] of Object.entries( + literalToScalarMapping + )) { + if (literalKind === "typeof") { + f.writeln([r` if (typeof type === "${literalType}") {`]); + } else { + f.writeln([r` if (type instanceof ${literalType}) {`]); + } + f.writeln([r` return $getType("${typesByName[type].id}")(type);`]); + f.writeln([r` }`]); + } + f.writeln([ + r` throw new Error(\`Cannot convert literal '\${type}' into scalar type\`);`, + ]); + f.writeln([r`}`]); + f.addExport("literalToTypeSet"); }; diff --git a/src/reflection/generators/generateFunctionTypes.ts b/src/reflection/generators/generateFunctionTypes.ts index cc26f9332..940009d66 100644 --- a/src/reflection/generators/generateFunctionTypes.ts +++ b/src/reflection/generators/generateFunctionTypes.ts @@ -21,6 +21,8 @@ import { expandFuncopAnytypeOverloads, GroupedParams, findPathOfAnytype, + AnytypeDef, + FuncopDefOverload, } from "../util/functionUtils"; import {Casts} from "../queries/getCasts"; @@ -56,6 +58,16 @@ export const generateFunctionTypes = ({ ); }; +export function allowsLiterals( + type: introspect.Type, + anytypes: AnytypeDef | null +): boolean { + return ( + (type.name === "anytype" && anytypes?.kind === "noncastable") || + type.kind === "scalar" + ); +} + export interface FuncopDef { id: string; name: string; @@ -152,7 +164,7 @@ export function generateFuncopTypes( code.writeln([ dts`declare `, t`type ${functionTypeName}${ - hasParams ? `<` : ` = _.syntax.$expr_${funcopExprKind}<` + hasParams ? `<` : ` = $.$expr_${funcopExprKind}<` }`, ]); @@ -185,10 +197,19 @@ export function generateFuncopTypes( } else { return anytypes.refName === paramTypeName ? anytypes.type - : `$.getPrimitiveBaseType<${anytypes.refName}${anytypes.refPath}>`; + : `$.getPrimitive${ + anytypes.type[0] === "$.NonArrayType" ? "NonArray" : "" + }BaseType<${ + allowsLiterals(anytypes.typeObj, anytypes) + ? `_.castMaps.literalToTypeSet<${anytypes.refName}>` + : anytypes.refName + }${anytypes.refPath}>`; } } + let hasNamedLiterals = false; + let hasPositionalLiterals = false; + if (hasParams) { // param types code.indented(() => { @@ -212,11 +233,16 @@ export function generateFuncopTypes( anytype, casts: casts.implicitCastFromMap, }); + let typeStr = frag`$.TypeSet<${paramType.staticType}>`; + if (allowsLiterals(param.type, anytypes)) { + typeStr = frag`_.castMaps.orScalarLiteral<${typeStr}>`; + hasNamedLiterals = true; + } const line = t`${quote(param.name)}${ param.typemod === "OptionalType" || param.hasDefault ? "?" : "" - }: $.TypeSet<${paramType.staticType}>,`; + }: ${typeStr},`; code.writeln([line]); overloadsBuf.writeln([line]); @@ -242,7 +268,12 @@ export function generateFuncopTypes( casts: casts.implicitCastFromMap, }); - const type = frag`$.TypeSet<${paramTypeStr.staticType}>`; + let type = frag`$.TypeSet<${paramTypeStr.staticType}>`; + + if (allowsLiterals(param.type, anytypes)) { + type = frag`_.castMaps.orScalarLiteral<${type}>`; + hasPositionalLiterals = true; + } const line = t`${param.typeName} extends ${ param.kind === "VariadicParam" @@ -261,7 +292,7 @@ export function generateFuncopTypes( }); }); - code.writeln([t`> = _.syntax.$expr_${funcopExprKind}<`]); + code.writeln([t`> = $.$expr_${funcopExprKind}<`]); overloadsBuf.writeln([t`>(`]); // args signature @@ -297,7 +328,13 @@ export function generateFuncopTypes( : anytypeParams.slice(1).reduce((parent, type) => { return `${anytypes.returnAnytypeWrapper}<${parent}, ${type}>`; }, anytypeParams[0]) - : `$.getPrimitiveBaseType<${anytypes.refName}${anytypes.refPath}>` + : `$.getPrimitive${ + anytypes.type[0] === "$.NonArrayType" ? "NonArray" : "" + }BaseType<${ + allowsLiterals(anytypes.typeObj, anytypes) + ? `_.castMaps.literalToTypeSet<${anytypes.refName}>` + : anytypes.refName + }${anytypes.refPath}>` : undefined; const returnType = getStringRepresentation( types.get(funcDef.return_type.id), @@ -307,20 +344,30 @@ export function generateFuncopTypes( } ); + const positionalParams = params.positional + .map( + param => + `${param.kind === "VariadicParam" ? "..." : ""}${ + param.typeName + }` + ) + .join(", "); + typeDefGen( code, funcDef, // args - frag`[${params.positional - .map( - param => - `${param.kind === "VariadicParam" ? "..." : ""}${ - param.typeName - }` - ) - .join(", ")}],`, + hasPositionalLiterals + ? frag`_.castMaps.mapLiteralToTypeSet<[${positionalParams}]>,` + : frag`[${positionalParams}],`, // named args - frag`${hasParams && hasNamedParams ? "NamedArgs" : "{}"},`, + frag`${ + hasParams && hasNamedParams + ? hasNamedLiterals + ? "_.castMaps.mapLiteralToTypeSet" + : "NamedArgs" + : "{}" + },`, // return type frag`$.TypeSet<${ returnType.staticType @@ -329,6 +376,7 @@ export function generateFuncopTypes( params, funcDef.return_typemod, hasNamedParams, + anytypes, funcDef.preserves_optionality )}>` ); @@ -361,48 +409,7 @@ export function generateFuncopTypes( } overloadIndex++; - const {params} = funcDef; - - function getArgSpec( - param: GroupedParams["named" | "positional"][number] - ) { - return `{typeId: ${quote(param.type.id)}, optional: ${( - param.typemod === "OptionalType" || !!param.hasDefault - ).toString()}, setoftype: ${( - param.typemod === "SetOfType" - ).toString()}, variadic: ${( - param.kind === "VariadicParam" - ).toString()}}`; - } - - const argsDef = params.positional.map(param => { - return getArgSpec(param); - }); - const namedArgsDef = params.named.length - ? `namedArgs: {${params.named - .map(param => { - return `${quote(param.name)}: ${getArgSpec(param)}`; - }) - .join(", ")}}, ` - : ""; - - code.writeln([ - r`{${ - funcDef.kind ? `kind: ${quote(funcDef.kind)}, ` : "" - }args: [${argsDef.join( - ", " - )}], ${namedArgsDef}returnTypeId: ${quote( - funcDef.return_type.id - )}${ - funcDef.return_typemod === "SingletonType" - ? "" - : `, returnTypemod: ${quote(funcDef.return_typemod)}` - }${ - funcDef.preserves_optionality - ? `, preservesOptionality: true` - : "" - }},`, - ]); + code.writeln([r`${generateFuncopDef(funcDef)},`]); } }); code.writeln([r`]);`]); @@ -423,6 +430,39 @@ export function generateFuncopTypes( } } +export function generateFuncopDef(funcopDef: FuncopDefOverload) { + const {params} = funcopDef; + + function getArgSpec(param: GroupedParams["named" | "positional"][number]) { + return `{typeId: ${quote(param.type.id)}, optional: ${( + param.typemod === "OptionalType" || !!param.hasDefault + ).toString()}, setoftype: ${( + param.typemod === "SetOfType" + ).toString()}, variadic: ${(param.kind === "VariadicParam").toString()}}`; + } + + const argsDef = params.positional.map(param => { + return getArgSpec(param); + }); + const namedArgsDef = params.named.length + ? `namedArgs: {${params.named + .map(param => { + return `${quote(param.name)}: ${getArgSpec(param)}`; + }) + .join(", ")}}, ` + : ""; + + return `{${ + funcopDef.kind ? `kind: ${quote(funcopDef.kind)}, ` : "" + }args: [${argsDef.join(", ")}], ${namedArgsDef}returnTypeId: ${quote( + funcopDef.return_type.id + )}${ + funcopDef.return_typemod === "SingletonType" + ? "" + : `, returnTypemod: ${quote(funcopDef.return_typemod)}` + }${funcopDef.preserves_optionality ? `, preservesOptionality: true` : ""}}`; +} + // default -> cardinality of cartesian product of params actual cardinality // (or overridden cardinality below) @@ -436,39 +476,55 @@ export function generateFuncopTypes( // (product with AtMostOne) (ignored if preservesOptionality) // - setoftype -> always Many -function generateReturnCardinality( +export function generateReturnCardinality( name: string, params: GroupedParams, returnTypemod: Typemod, hasNamedParams: boolean, + anytypes: AnytypeDef | null, preservesOptionality: boolean = false ) { - if (name === "std::if_else") { - return ( - `$.cardinalityUtil.multiplyCardinalities<` + - `$.cardinalityUtil.orCardinalities<` + - `${params.positional[0].typeName}["__cardinality__"],` + - ` ${params.positional[2].typeName}["__cardinality__"]` + - `>, ${params.positional[1].typeName}["__cardinality__"]>` - ); - } - - if (returnTypemod === "SetOfType") { + if ( + returnTypemod === "SetOfType" && + name !== "std::if_else" && + name !== "std::assert_exists" + ) { return `$.Cardinality.Many`; } - const paramCardinalities = [ + const cardinalities = [ ...params.positional.map(p => ({ ...p, - genTypeName: p.typeName, + genTypeName: allowsLiterals(p.type, anytypes) + ? `_.castMaps.${ + p.kind === "VariadicParam" ? "mapL" : "l" + }iteralToTypeSet<${p.typeName}>` + : p.typeName, })), ...(hasNamedParams ? params.named.map(p => ({ ...p, - genTypeName: `NamedArgs[${quote(p.name)}]`, + genTypeName: allowsLiterals(p.type, anytypes) + ? `_.castMaps.literalToTypeSet` + : `NamedArgs[${quote(p.name)}]`, })) : []), - ].map(param => { + ]; + + if (name === "std::if_else") { + return ( + `$.cardinalityUtil.multiplyCardinalities<` + + `$.cardinalityUtil.orCardinalities<` + + `${cardinalities[0].genTypeName}["__cardinality__"],` + + ` ${cardinalities[2].genTypeName}["__cardinality__"]` + + `>, ${cardinalities[1].genTypeName}["__cardinality__"]>` + ); + } + if (name === "std::assert_exists") { + return `$.cardinalityUtil.overrideLowerBound<${cardinalities[0].genTypeName}["__cardinality__"], "One">`; + } + + const paramCardinalities = cardinalities.map(param => { if (param.typemod === "SetOfType") { if (preservesOptionality) { return `$.cardinalityUtil.overrideUpperBound<${param.genTypeName}["__cardinality__"], "One">`; diff --git a/src/reflection/generators/generateObjectTypes.ts b/src/reflection/generators/generateObjectTypes.ts index b2a059ffd..06eefb3a5 100644 --- a/src/reflection/generators/generateObjectTypes.ts +++ b/src/reflection/generators/generateObjectTypes.ts @@ -163,6 +163,7 @@ export const generateObjectTypes = (params: GeneratorParams) => { key: string; isExclusive: boolean; writable: boolean; + hasDefault: boolean; kind: "link" | "property"; lines: Line[]; }; @@ -183,6 +184,7 @@ export const generateObjectTypes = (params: GeneratorParams) => { kind: ptr.kind, isExclusive: ptr.is_exclusive, writable: ptr.is_writable ?? false, + hasDefault: ptr.has_default ?? false, lines: (ptr.pointers ?? []) .filter(p => p.name !== "@target" && p.name !== "@source") .map(ptrToLine), @@ -225,7 +227,7 @@ export const generateObjectTypes = (params: GeneratorParams) => { body.writeln([ t`${quote(line.key)}: $.LinkDesc<${line.staticType}, ${ line.card - }, {}, ${line.isExclusive.toString()}, ${line.writable.toString()}>;`, + }, {}, ${line.isExclusive.toString()}, ${line.writable.toString()}, ${line.hasDefault.toString()}>;`, ]); } else { body.writeln([ @@ -243,14 +245,14 @@ export const generateObjectTypes = (params: GeneratorParams) => { } }); body.writeln([ - t`}, ${line.isExclusive.toString()}, ${line.writable.toString()}>;`, + t`}, ${line.isExclusive.toString()}, ${line.writable.toString()}, ${line.hasDefault.toString()}>;`, ]); } } else { body.writeln([ t`${quote(line.key)}: $.PropertyDesc<${line.staticType}, ${ line.card - }, ${line.isExclusive.toString()}, ${line.writable.toString()}>;`, + }, ${line.isExclusive.toString()}, ${line.writable.toString()}, ${line.hasDefault.toString()}>;`, ]); } } @@ -277,7 +279,7 @@ export const generateObjectTypes = (params: GeneratorParams) => { r`(_.spec, ${quote(type.id)}, _.syntax.literal);`, ]); body.addExport(ref); - body.addRefsDefaultExport(ref, `$${name}`); + // body.addExport(ref, `$${name}`); // dollar const typeCard = singletonObjectTypes.has(type.name) ? "One" : "Many"; @@ -287,7 +289,7 @@ export const generateObjectTypes = (params: GeneratorParams) => { ...frag`const ${literal}`, // tslint:disable-next-line t`: $.$expr_PathNode<$.TypeSet<${ref}, $.Cardinality.${typeCard}>, null, true> `, - r`= _.syntax.$expr_PathNode($.$toSet(${ref}, $.Cardinality.${typeCard}), null, true);`, + r`= _.syntax.$PathNode($.$toSet(${ref}, $.Cardinality.${typeCard}), null, true);`, ]); body.nl(); diff --git a/src/reflection/generators/generateOperatorTypes.ts b/src/reflection/generators/generateOperatorTypes.ts index 2ce34da02..e0ba730bd 100644 --- a/src/reflection/generators/generateOperatorTypes.ts +++ b/src/reflection/generators/generateOperatorTypes.ts @@ -1,14 +1,28 @@ -import {r, t} from "../builders"; +import {CodeBuffer, dts, r, t, ts} from "../builders"; import type {GeneratorParams} from "../generate"; -import {quote} from "../util/genutil"; -import {generateFuncopTypes} from "./generateFunctionTypes"; +import {frag, quote, splitName} from "../util/genutil"; +import { + allowsLiterals, + generateFuncopDef, + generateFuncopTypes, + generateReturnCardinality, +} from "./generateFunctionTypes"; +import { + getTypesSpecificity, + sortFuncopOverloads, + getImplicitCastableRootTypes, + expandFuncopAnytypeOverloads, + findPathOfAnytype, +} from "../util/functionUtils"; +import {introspect, OperatorKind} from ".."; +import {getStringRepresentation} from "./generateObjectTypes"; -export const generateOperatorTypes = ({ +export function generateOperatorFunctions({ dir, operators, types, casts, -}: GeneratorParams) => { +}: GeneratorParams) { generateFuncopTypes( dir, types, @@ -33,4 +47,302 @@ export const generateOperatorTypes = ({ code.writeln([r`__args__: positionalArgs,`]); } ); -}; +} + +const skipOperators = new Set([ + "std::index", + "std::slice", + "std::destructure", +]); + +export function generateOperators({ + dir, + operators, + types, + casts, +}: GeneratorParams) { + const typeSpecificities = getTypesSpecificity(types, casts); + const implicitCastableRootTypes = getImplicitCastableRootTypes(casts); + + const code = dir.getPath("operators"); + + code.addImport({$: true}, "edgedb"); + code.addStarImport("_", "./imports", true); + + const overloadsBuf = new CodeBuffer(); + + const overloadDefs: { + [opKind: string]: {[opSymbol: string]: string[]}; + } = {}; + for (const opKind of Object.values(OperatorKind)) { + overloadDefs[opKind] = {}; + } + + for (const [opName, _opDefs] of operators.entries()) { + if (skipOperators.has(opName)) continue; + + const opDefs = expandFuncopAnytypeOverloads( + sortFuncopOverloads(_opDefs, typeSpecificities), + types, + casts, + implicitCastableRootTypes + ); + + let overloadIndex = 0; + for (const opDef of opDefs) { + const {params} = opDef; + + const opSymbol = + opName === "std::if_else" + ? "if_else" + : splitName(opDef.originalName).name.toLowerCase(); + + if (opDef.overloadIndex === overloadIndex) { + if (!overloadDefs[opDef.operator_kind][opSymbol]) { + overloadDefs[opDef.operator_kind][opSymbol] = []; + } + + overloadDefs[opDef.operator_kind][opSymbol].push( + generateFuncopDef(opDef) + ); + + overloadIndex++; + } + + if (opDef.description) { + overloadsBuf.writeln([ + t`/** +* ${opDef.description.replace(/\*\//g, "")} +*/`, + ]); + } + + overloadsBuf.writeln([dts`declare `, t`function op<`]); + + const anytypes = opDef.anytypes; + const anytypeParams: string[] = []; + + function getParamAnytype( + paramTypeName: string, + paramType: introspect.Type + ) { + if (!anytypes) return undefined; + if (anytypes.kind === "castable") { + if (paramType.name.includes("anytype")) { + const path = findPathOfAnytype(paramType.id, types); + anytypeParams.push(`${paramTypeName}${path}`); + } + return anytypes.type; + } else { + return anytypes.refName === paramTypeName + ? anytypes.type + : `$.getPrimitive${ + anytypes.type[0] === "$.NonArrayType" ? "NonArray" : "" + }BaseType<${ + allowsLiterals(anytypes.typeObj, anytypes) + ? `_.castMaps.literalToTypeSet<${anytypes.refName}>` + : anytypes.refName + }${anytypes.refPath}>`; + } + } + + let hasLiterals = false; + overloadsBuf.indented(() => { + for (const param of params.positional) { + const anytype = getParamAnytype(param.typeName, param.type); + + const paramTypeStr = getStringRepresentation(param.type, { + types, + anytype, + casts: casts.implicitCastFromMap, + }); + + let type = frag`$.TypeSet<${paramTypeStr.staticType}>`; + + if (allowsLiterals(param.type, anytypes)) { + type = frag`_.castMaps.orScalarLiteral<${type}>`; + hasLiterals = true; + } + + overloadsBuf.writeln([t`${param.typeName} extends ${type},`]); + } + }); + + overloadsBuf.writeln([t`>(`]); + + overloadsBuf.indented(() => { + const args = params.positional.map( + param => `${param.internalName}: ${param.typeName}` + ); + switch (opDef.operator_kind) { + case OperatorKind.Infix: + overloadsBuf.writeln([ + t`${args[0]}, op: ${quote(opSymbol)}, ${args[1]}`, + ]); + break; + case OperatorKind.Prefix: + overloadsBuf.writeln([t`op: ${quote(opSymbol)}, ${args[0]}`]); + break; + case OperatorKind.Postfix: + overloadsBuf.writeln([t`${args[0]}, op: ${quote(opSymbol)}`]); + break; + case OperatorKind.Ternary: + if (opName === "std::if_else") { + overloadsBuf.writeln([ + t`${args[0]}, op: "if", ${args[1]}, op2: "else", ${args[2]}`, + ]); + } else { + throw new Error(`unknown ternary operator: ${opName}`); + } + break; + default: + throw new Error(`unknown operator kind: ${opDef.operator_kind}`); + } + }); + + const paramTypeNames = params.positional + .map(param => param.typeName) + .join(", "); + + const returnAnytype = anytypes + ? anytypes.kind === "castable" + ? anytypeParams.length <= 1 + ? anytypeParams[0] + : anytypeParams.slice(1).reduce((parent, type) => { + return `${anytypes.returnAnytypeWrapper}<${parent}, ${type}>`; + }, anytypeParams[0]) + : `$.getPrimitive${ + anytypes.type[0] === "$.NonArrayType" ? "NonArray" : "" + }BaseType<${ + allowsLiterals(anytypes.typeObj, anytypes) + ? `_.castMaps.literalToTypeSet<${anytypes.refName}>` + : anytypes.refName + }${anytypes.refPath}>` + : undefined; + const returnType = getStringRepresentation( + types.get(opDef.return_type.id), + { + types, + anytype: returnAnytype, + } + ); + + overloadsBuf.writeln([t`): $.$expr_Operator<`]); + overloadsBuf.indented(() => { + overloadsBuf.writeln([t`${quote(opSymbol)},`]); + overloadsBuf.writeln([t`$.OperatorKind.${opDef.operator_kind},`]); + overloadsBuf.writeln([ + t`${ + hasLiterals + ? `_.castMaps.mapLiteralToTypeSet<[${paramTypeNames}]>` + : `[${paramTypeNames}]` + },`, + ]); + overloadsBuf.writeln([ + t`$.TypeSet<${returnType.staticType}, ${generateReturnCardinality( + opName, + params, + opDef.return_typemod, + false, + anytypes + )}>`, + ]); + }); + overloadsBuf.writeln([t`>;`]); + } + } + + code.nl(); + code.writeln([ + r`const overloadDefs`, + ts`: { + [opKind in 'Infix' | 'Prefix' | 'Postfix' | 'Ternary']: { + [opSymbol: string]: any[] + } +}`, + r` = {`, + ]); + code.indented(() => { + for (const opKind of Object.keys(overloadDefs)) { + code.writeln([r`${opKind}: {`]); + code.indented(() => { + for (const symbol of Object.keys(overloadDefs[opKind])) { + code.writeln([r`${quote(symbol)}: [`]); + code.indented(() => { + for (const overloadDef of overloadDefs[opKind][symbol]) { + code.writeln([r`${overloadDef},`]); + } + }); + code.writeln([r`],`]); + } + }); + code.writeln([r`},`]); + } + }); + code.writeln([r`};`]); + code.nl(); + + code.writeBuf(overloadsBuf); + + // implementation + code.writeln([r`function op(...args`, ts`: any[]`, r`) {`]); + code.indented(() => { + code.writeln([ + r`let op`, + ts`: string`, + r` = ""; + let params`, + ts`: any[]`, + r` = []; + let defs`, + ts`: any[] | null`, + r` = null; + if (args.length === 2) { + if (typeof args[0] === "string" && overloadDefs.Prefix[args[0]]) { + op = args[0]; + params = [args[1]]; + defs = overloadDefs.Prefix[op]; + } else if (typeof args[1] === "string" && overloadDefs.Postfix[args[1]]) { + op = args[1]; + params = [args[0]]; + defs = overloadDefs.Postfix[op]; + } + } else if (args.length === 3) { + if (typeof args[1] === "string") { + op = args[1]; + params = [args[0], args[2]]; + defs = overloadDefs.Infix[op]; + } + } else if (args.length === 5) { + if (typeof args[1] === "string" && typeof args[3] === "string") { + op = \`\${args[1]}_\${args[3]}\`; + params = [args[0], args[2], args[4]]; + defs = overloadDefs.Ternary[op]; + } + } + + if (!defs) { + throw new Error(\`No operator exists with signature: \${args.map(arg => \`\${arg}\`).join(", ")}\`); + }`, + ]); + + code.nl(); + code.writeln([ + r`const {kind, returnType, cardinality, args: resolvedArgs} = _.syntax.$resolveOverload(op, params, _.spec, defs);`, + ]); + code.nl(); + code.writeln([r`return _.syntax.$expressionify({`]); + code.indented(() => { + code.writeln([r`__kind__: $.ExpressionKind.Operator,`]); + code.writeln([r`__element__: returnType,`]); + code.writeln([r`__cardinality__: cardinality,`]); + code.writeln([r`__name__: op,`]); + code.writeln([r`__opkind__: kind,`]); + code.writeln([r`__args__: resolvedArgs,`]); + }); + code.writeln([r`})`, ts` as any`, r`;`]); + }); + code.writeln([r`};`]); + + code.addExport("op"); +} diff --git a/src/reflection/generators/generateScalars.ts b/src/reflection/generators/generateScalars.ts index 9b25896f1..a451db064 100644 --- a/src/reflection/generators/generateScalars.ts +++ b/src/reflection/generators/generateScalars.ts @@ -6,9 +6,11 @@ import { toIdent, quote, toTSScalarType, + scalarToLiteralMapping, } from "../util/genutil"; import {dts, js, r, t, ts} from "../builders"; import type {GeneratorParams} from "../generate"; +import {nonCastableTypes, typeMapping} from "../queries/getTypes"; export const generateScalars = (params: GeneratorParams) => { const {dir, types, casts, scalars} = params; @@ -46,8 +48,14 @@ export const generateScalars = (params: GeneratorParams) => { if (scalarType.children.length) { // is abstract - const children = scalarType.children.map(desc => - desc.name === "std::anyenum" ? "$.EnumType" : getRef(desc.name) + const children = [ + ...new Set( + scalarType.children.map( + desc => (typeMapping.get(desc.id) ?? desc).name + ) + ), + ].map(descName => + descName === "std::anyenum" ? "$.EnumType" : getRef(descName) ); sc.writeln([ dts`declare `, @@ -64,7 +72,7 @@ export const generateScalars = (params: GeneratorParams) => { sc.nl(); sc.addExport(ref); - sc.addRefsDefaultExport(ref, `$${_name}`); + // sc.addExport(ref, `$${_name}`); // dollar } else if (scalarType.bases.length) { // for std::sequence const bases = scalarType.bases.map(base => getRef(base.name)); @@ -80,7 +88,7 @@ export const generateScalars = (params: GeneratorParams) => { sc.nl(); sc.addExport(ref); - sc.addRefsDefaultExport(ref, `$${_name}`); + // sc.addExport(ref, `$${_name}`); // dollar } continue; @@ -97,7 +105,7 @@ export const generateScalars = (params: GeneratorParams) => { `{`, ]); sc.indented(() => { - for (const val of type.enum_values) { + for (const val of type.enum_values!) { sc.writeln([toIdent(val), t` = `, js`: `, quote(val), `,`]); } }); @@ -127,21 +135,73 @@ export const generateScalars = (params: GeneratorParams) => { } // generate non-enum non-abstract scalar + const tsType = toTSScalarType(type, types); + // const tsType = toTSScalarType(type, types); + // const extraTypes = scalarToLiteralMapping[type.name]?.extraTypes; + // const extraTypesUnion = extraTypes ? `, ${extraTypes.join(" | ")}` : ""; + + if (type.castOnlyType) { + const mapped = types.get(type.castOnlyType); + const mappedRef = getRef(mapped.name); + + const extraTypes = ( + scalarToLiteralMapping[mapped.name]?.extraTypes || ["never"] + ).join(" | "); + // const extraTypesUnion = extraTypes ? + // `, ${extraTypes.join(" | ")}` : ""; + // sc.writeln([ + // t`export `, + // dts`declare `, + // t`type ${ref} = $.CastOnlyScalarType<"${ + // mapped.name}", ${mappedRef}>;`, + // ]); + sc.writeln([ + t`export `, + dts`declare `, + t`type ${ref} = $.ScalarType<"${mapped.name}", ${tsType}, ${ + nonCastableTypes.has(type.id) ? "false" : "true" + }>;`, + ]); + + // sc.writeln([ + // dts`declare `, + // ...frag`const ${literal}`, + // t`: ${mappedRef}`, + // r` = $.makeType`, + // ts`<${mappedRef}>`, + // r`(_.spec, "${mapped.id}", _.syntax.literal);`, + // ]); + sc.writeln([ + dts`declare `, + ...frag`const ${literal}`, + t`: $.scalarTypeWithConstructor<${mappedRef}, ${extraTypes}>`, + r` = $.makeType`, + ts`<$.scalarTypeWithConstructor<${mappedRef}, ${extraTypes}>>`, + r`(_.spec, "${type.id}", _.syntax.literal);`, + ]); + } else { + const extraTypes = ( + scalarToLiteralMapping[type.name]?.extraTypes || ["never"] + ).join(" | "); + // const extraTypesUnion = extraTypes ? + // `, ${extraTypes.join(" | ")}` : ""; + sc.writeln([ + t`export `, + dts`declare `, + t`type ${ref} = $.ScalarType<"${type.name}", ${tsType}, ${ + nonCastableTypes.has(type.id) ? "false" : "true" + }>;`, + ]); - const tsType = toTSScalarType(type, types, mod, sc); - sc.writeln([ - t`export `, - dts`declare `, - t`type ${ref} = $.ScalarType<"${type.name}", ${tsType}>;`, - ]); - sc.writeln([ - dts`declare `, - ...frag`const ${literal}`, - t`: ${ref}`, - r` = $.makeType`, - ts`<${ref}>`, - r`(_.spec, "${type.id}", _.syntax.literal);`, - ]); + sc.writeln([ + dts`declare `, + ...frag`const ${literal}`, + t`: $.scalarTypeWithConstructor<${ref}, ${extraTypes}>`, + r` = $.makeType`, + ts`<$.scalarTypeWithConstructor<${ref}, ${extraTypes}>>`, + r`(_.spec, "${type.id}", _.syntax.literal);`, + ]); + } if (casts.implicitCastFromMap[type.id]?.length) { sc.writeln([ @@ -166,7 +226,10 @@ export const generateScalars = (params: GeneratorParams) => { dts`declare `, t`type ${ref}λIAssignableBy = ${joinFrags( assignableMap.length - ? assignableMap.map(typeId => getRef(types.get(typeId).name)) + ? [ + ref, + ...assignableMap.map(typeId => getRef(types.get(typeId).name)), + ] : [ref], " | " )};`, @@ -174,7 +237,7 @@ export const generateScalars = (params: GeneratorParams) => { } sc.addExport(literal); - sc.addRefsDefaultExport(literal, _name); + if (_name !== "number") sc.addRefsDefaultExport(literal, _name); sc.nl(); } diff --git a/src/reflection/generators/generateSetImpl.ts b/src/reflection/generators/generateSetImpl.ts index 2ecb57e2e..7638905db 100644 --- a/src/reflection/generators/generateSetImpl.ts +++ b/src/reflection/generators/generateSetImpl.ts @@ -15,6 +15,7 @@ export const generateSetImpl = ({dir, types, casts}: GeneratorParams) => { Cardinality: true, cardinalityUtil: true, $mergeObjectTypes: true, + unwrapCastableType: true, }, "edgedb/dist/reflection/index", true @@ -43,6 +44,7 @@ import type { } from "./set";`, ]); + code.nl(); code.writeln([ dts`declare `, t`type getSetTypeFromExprs< @@ -52,31 +54,34 @@ import type { cardinalityUtil.mergeCardinalitiesVariadic> >;`, ]); + code.nl(); + + code.writeln([dts`declare `, t`function set(): null;`]); code.writeln([ - dts`declare `, - t`function set( - type: Type -): $expr_Set>; -`, + // dts`declare `, + // t`function set( + // type: Type + // ): $expr_Set, Cardinality.Empty>>; + // `, dts`declare `, t`function set< - Expr extends TypeSet ->(expr: Expr): $expr_Set;`, + Expr extends castMaps.orScalarLiteral +>(expr: Expr): $expr_Set>;`, ]); for (const implicitRootTypeId of implicitCastableRootTypes) { code.writeln([ dts`declare `, t`function set< - Expr extends TypeSet<${ + Expr extends castMaps.orScalarLiteral, + }>>, Exprs extends [Expr, ...Expr[]] ->(...exprs: Exprs): $expr_Set>;`, +>(...exprs: Exprs): $expr_Set>>;`, ]); code.writeln([ @@ -115,19 +120,30 @@ import type { `, dts`declare `, t`function set< - Expr extends PrimitiveTypeSet, - Exprs extends - TypeSet>[] + Expr extends TypeSet | castMaps.scalarLiterals, + Exprs extends castMaps.orScalarLiteral< + TypeSet["__element__"]>> + >[] >( expr: Expr, ...exprs: Exprs ): $expr_Set< TypeSet< - getPrimitiveBaseType, + getPrimitiveBaseType["__element__"]>, cardinalityUtil.mergeCardinalitiesVariadic< - getCardsFromExprs<[Expr, ...Exprs]> + getCardsFromExprs> > > +>; +`, + dts`declare `, + t`function set | castMaps.scalarLiterals>( + ...exprs: Expr[] +): $expr_Set< + TypeSet< + getPrimitiveBaseType["__element__"]>, + Cardinality.Many + > >;`, ]); @@ -135,33 +151,20 @@ import type { r`function set(..._exprs`, ts`: any[]`, r`) { + // if no arg // if arg // return empty set // if object set // merged objects // if primitive // return shared parent of scalars - if ( - _exprs.length === 1 && - Object.values(TypeKind).includes(_exprs[0].__kind__) - ) { - const element`, - ts`: BaseType`, - r` = _exprs[0]`, - ts` as any`, - r`; - return $expressionify({ - __kind__: ExpressionKind.Set, - __element__: element, - __cardinality__: Cardinality.Empty, - __exprs__: [], - })`, - ts` as any`, - r`; + if(_exprs.length === 0){ + return null; } + const exprs`, ts`: TypeSet[]`, - r` = _exprs; + r` = _exprs.map(expr => castMaps.literalToTypeSet(expr)); if (exprs.every((expr) => expr.__element__.__kind__ === TypeKind.object)) { // merge object types; return $expressionify({ diff --git a/src/reflection/hydrate.ts b/src/reflection/hydrate.ts index 440892d16..db0adc463 100644 --- a/src/reflection/hydrate.ts +++ b/src/reflection/hydrate.ts @@ -130,16 +130,36 @@ export function makeType( typeCache.set(id, obj); return obj; } else if (type.kind === "scalar") { - const scalarObj = ((val: any) => { - return literal(scalarObj, val); - }) as any; - scalarObj.__kind__ = type.enum_values ? TypeKind.enum : TypeKind.scalar; + const scalarObj = type.is_abstract /// || type.castOnlyType + ? {} + : type.name === "std::json" + ? (((val: any) => { + return literal(scalarObj, JSON.stringify(val)); + }) as any) + : (((val: any) => { + return literal( + // type.castOnlyType + // ? makeType(spec, type.castOnlyType, literal) + // : + scalarObj, + val + ); + }) as any); + scalarObj.__kind__ = type.enum_values + ? TypeKind.enum + : // type.castOnlyType + // ? TypeKind.castonlyscalar + // : + TypeKind.scalar; scalarObj.__name__ = type.name; if (type.enum_values) { for (const val of type.enum_values) { scalarObj[val] = val; } } + if (type.castOnlyType) { + scalarObj.__casttype__ = makeType(spec, type.castOnlyType, literal); + } typeCache.set(id, scalarObj); return scalarObj; } else if (type.kind === "array") { diff --git a/src/reflection/index.ts b/src/reflection/index.ts index ba8345e02..a83e68460 100644 --- a/src/reflection/index.ts +++ b/src/reflection/index.ts @@ -24,3 +24,4 @@ export * as introspect from "./queries/getTypes"; export * from "./hydrate"; export * from "./path"; export * from "./literal"; +export * from "./funcops"; diff --git a/src/reflection/path.ts b/src/reflection/path.ts index ea90f2050..93d7e5e9c 100644 --- a/src/reflection/path.ts +++ b/src/reflection/path.ts @@ -1,3 +1,4 @@ +import {typeutil} from "."; import {Cardinality, ExpressionKind} from "./enums"; import type { BaseType, @@ -37,38 +38,89 @@ export type $pathify< > = Root extends ObjectTypeSet ? ObjectTypeSet extends Root ? {} // Root is literally ObjectTypeSet - : ObjectTypePointers extends Root["__element__"]["__pointers__"] - ? {} - : { - // & string required to avod typeError on linkName - [k in keyof Root["__element__"]["__pointers__"] & - string]: Root["__element__"]["__pointers__"][k] extends PropertyDesc - ? $expr_PathLeaf< + : pathifyPointers & + pathifyShape & + (Parent extends PathParent + ? // tslint:disable-next-line + Parent["type"]["__element__"]["__pointers__"][Parent["linkName"]] extends LinkDesc + ? pathifyLinkProps< + // tslint:disable-next-line + Parent["type"]["__element__"]["__pointers__"][Parent["linkName"]]["properties"], + Root, + Parent + > + : {} + : {}) + : unknown; // pathify does nothing on non-object types + +export type pathifyPointers< + Root extends ObjectTypeSet + // Parent extends PathParent | null = null +> = ObjectTypePointers extends Root["__element__"]["__pointers__"] + ? unknown + : { + // & string required to avoid typeError on linkName + [k in keyof Root["__element__"]["__pointers__"] & + string]: Root["__element__"]["__pointers__"][k] extends PropertyDesc + ? $expr_PathLeaf< + getChildOfObjectTypeSet, + {type: anonymizeObjectTypeSet; linkName: k}, + Root["__element__"]["__pointers__"][k]["exclusive"] + > + : Root["__element__"]["__pointers__"][k] extends LinkDesc + ? getChildOfObjectTypeSet extends ObjectTypeSet + ? $expr_PathNode< getChildOfObjectTypeSet, - {type: $expr_PathNode; linkName: k}, + {type: anonymizeObjectTypeSet; linkName: k}, Root["__element__"]["__pointers__"][k]["exclusive"] > - : Root["__element__"]["__pointers__"][k] extends LinkDesc - ? getChildOfObjectTypeSet extends ObjectTypeSet - ? $expr_PathNode< - getChildOfObjectTypeSet, - {type: $expr_PathNode; linkName: k}, - Root["__element__"]["__pointers__"][k]["exclusive"] + : unknown + : unknown; + }; + +type anonymizeObjectTypeSet = typeutil.flatten<{ + __element__: ObjectType< + T["__element__"]["__name__"], + T["__element__"]["__pointers__"], + {id: true} + >; + __cardinality__: T["__cardinality__"]; +}>; + +export type pathifyShape< + Root extends ObjectTypeSet, + Shape extends {[k: string]: any} = Root["__element__"]["__shape__"] +> = string extends keyof Shape + ? {} + : { + [k in keyof Shape & string]: Shape[k] extends ObjectTypeSet + ? $expr_PathNode< + TypeSet< + Shape[k]["__element__"], + cardinalityUtil.multiplyCardinalities< + Root["__cardinality__"], + Shape[k]["__cardinality__"] > - : never - : never; - } & (Parent extends PathParent - ? // tslint:disable-next-line - Parent["type"]["__element__"]["__pointers__"][Parent["linkName"]] extends LinkDesc - ? pathifyLinkProps< - // tslint:disable-next-line - Parent["type"]["__element__"]["__pointers__"][Parent["linkName"]]["properties"], - Root, - Parent - > - : {} - : {}) - : unknown; // pathify does nothing on non-object types + >, + {type: Root; linkName: k}, + false + > + : Shape[k] extends TypeSet + ? $expr_PathLeaf< + TypeSet< + Shape[k]["__element__"], + cardinalityUtil.multiplyCardinalities< + Root["__cardinality__"], + Shape[k]["__cardinality__"] + > + >, + {type: Root; linkName: k}, + false + > + : // must be unknown (not never) to avoid overriding + // a pointer with the same key + unknown; + }; type pathifyLinkProps< Props extends PropertyShape, @@ -87,7 +139,7 @@ type pathifyLinkProps< {type: $expr_PathNode; linkName: k}, Props[k]["exclusive"] > - : never; + : unknown; }; export type $expr_PathNode< diff --git a/src/reflection/queries/getCasts.ts b/src/reflection/queries/getCasts.ts index d54faee8e..8a059b232 100644 --- a/src/reflection/queries/getCasts.ts +++ b/src/reflection/queries/getCasts.ts @@ -1,5 +1,6 @@ import {Executor} from "../../ifaces"; import {typeutil} from "../util/typeutil"; +import {typeMapping} from "./getTypes"; type Cast = { id: string; @@ -56,6 +57,11 @@ export const getCasts = async (cxn: Executor, params?: {debug?: boolean}) => { const assignmentCastsByTarget: Record = {}; for (const cast of allCasts) { + if (typeMapping.has(cast.source.id) || typeMapping.has(cast.target.id)) { + cast.allow_implicit = false; + cast.allow_assignment = false; + } + typesById[cast.source.id] = cast.source; typesById[cast.target.id] = cast.target; types.add(cast.source.id); diff --git a/src/reflection/queries/getFunctions.ts b/src/reflection/queries/getFunctions.ts index 3e1e7ec8e..9b5fe0d0c 100644 --- a/src/reflection/queries/getFunctions.ts +++ b/src/reflection/queries/getFunctions.ts @@ -1,6 +1,7 @@ import {Executor} from "../../ifaces"; import {StrictMap} from "../strictMap"; import {typeutil} from "../../reflection"; +import {typeMapping} from "./getTypes"; export type Typemod = "SetOfType" | "OptionalType" | "SingletonType"; @@ -53,17 +54,70 @@ export const getFunctions = async (cxn: Executor) => { const functions = new StrictMap(); + const seenFuncDefHashes = new Set(); + for (const func of JSON.parse(functionsJson)) { const {name} = func; if (!functions.has(name)) { functions.set(name, []); } - functions.get(name).push({ + const funcDef: FunctionDef = { ...func, description: func.annotations[0]?.["@value"], - }); + }; + + replaceNumberTypes(funcDef); + + const hash = hashFuncDef(funcDef); + + if (!seenFuncDefHashes.has(hash)) { + functions.get(name).push(funcDef); + seenFuncDefHashes.add(hash); + } } return functions; }; + +export function replaceNumberTypes(def: { + return_type: FunctionDef["return_type"]; + params: Param[]; +}): void { + if (typeMapping.has(def.return_type.id)) { + const type = typeMapping.get(def.return_type.id)!; + def.return_type = { + id: type.id, + name: type.name, + }; + } + + for (const param of def.params) { + if (typeMapping.has(param.type.id)) { + const type = typeMapping.get(param.type.id)!; + param.type = { + id: type.id, + name: type.name, + }; + } + } +} + +function hashFuncDef(def: FunctionDef): string { + return JSON.stringify({ + name: def.name, + return_type: def.return_type.id, + return_typemod: def.return_typemod, + params: def.params + .map(param => + JSON.stringify({ + kind: param.kind, + type: param.type.id, + typemod: param.typemod, + hasDefault: !!param.hasDefault, + }) + ) + .sort(), + preserves_optionality: def.preserves_optionality, + }); +} diff --git a/src/reflection/queries/getOperators.ts b/src/reflection/queries/getOperators.ts index b63a5b611..2fece9437 100644 --- a/src/reflection/queries/getOperators.ts +++ b/src/reflection/queries/getOperators.ts @@ -1,7 +1,7 @@ import {Executor} from "../../ifaces"; import {StrictMap} from "../strictMap"; -import {Param, Typemod} from "./getFunctions"; +import {Param, replaceNumberTypes, Typemod} from "./getFunctions"; import {genutil, typeutil} from "../util/util"; import {OperatorKind} from "../enums"; @@ -46,6 +46,8 @@ export const getOperators = async (cxn: Executor) => { const operators = new StrictMap(); + const seenOpDefHashes = new Set(); + for (const op of JSON.parse(operatorsJson)) { const identifier = op.annotations.find( (anno: any) => anno.name === "std::identifier" @@ -63,7 +65,7 @@ export const getOperators = async (cxn: Executor) => { operators.set(name, []); } - operators.get(name).push({ + const opDef: OperatorDef = { ...op, name, kind: op.operator_kind, @@ -72,8 +74,36 @@ export const getOperators = async (cxn: Executor) => { (anno: any) => anno.name === "std::description" )?.["@value"], annotations: undefined, - }); + }; + + replaceNumberTypes(opDef); + + const hash = hashOpDef(opDef); + + if (!seenOpDefHashes.has(hash)) { + operators.get(name).push(opDef); + seenOpDefHashes.add(hash); + } } return operators; }; + +function hashOpDef(def: OperatorDef): string { + return JSON.stringify({ + name: def.name, + return_type: def.return_type.id, + return_typemod: def.return_typemod, + params: def.params + .map(param => + JSON.stringify({ + kind: param.kind, + type: param.type.id, + typemod: param.typemod, + hasDefault: !!param.hasDefault, + }) + ) + .sort(), + operator_kind: def.operator_kind, + }); +} diff --git a/src/reflection/queries/getTypes.ts b/src/reflection/queries/getTypes.ts index e4fbcdd8f..531a90606 100644 --- a/src/reflection/queries/getTypes.ts +++ b/src/reflection/queries/getTypes.ts @@ -12,6 +12,7 @@ export type Pointer = { target_id: UUID; is_exclusive: boolean; is_writable: boolean; + has_default: boolean; pointers: ReadonlyArray | null; }; @@ -37,8 +38,9 @@ export type ScalarType = TypeProperties<"scalar"> & { is_abstract: boolean; bases: ReadonlyArray<{id: UUID}>; // ancestors: ReadonlyArray<{id: UUID}>; - enum_values: ReadonlyArray; + enum_values: ReadonlyArray | null; material_id: UUID | null; + castOnlyType?: UUID; }; export type ObjectType = TypeProperties<"object"> & { @@ -71,6 +73,43 @@ export type Type = PrimitiveType | ObjectType; export type Types = StrictMap; +const numberType: ScalarType = { + id: "00000000-0000-0000-0000-0000000001ff", + name: "std::number", + is_abstract: false, + kind: "scalar", + enum_values: null, + material_id: null, + bases: [], +}; + +export const nonCastableTypes = new Set([ + // numberType.id +]); + +export const typeMapping = new Map([ + [ + "00000000-0000-0000-0000-000000000103", // int16 + numberType, + ], + [ + "00000000-0000-0000-0000-000000000104", // int32 + numberType, + ], + [ + "00000000-0000-0000-0000-000000000105", // int64 + numberType, + ], + [ + "00000000-0000-0000-0000-000000000106", // float32 + numberType, + ], + [ + "00000000-0000-0000-0000-000000000107", // float64 + numberType, + ], +]); + export async function getTypes( cxn: Executor, params?: {debug?: boolean} @@ -119,6 +158,7 @@ export async function getTypes( kind := 'link' IF .__type__.name = 'schema::Link' ELSE 'property', is_exclusive := exists (select .constraints filter .name = 'std::exclusive'), is_writable := len(.computed_fields) = 0 AND .readonly = false, + has_default := EXISTS .default, [IS Link].pointers: { real_cardinality := ("One" IF .required ELSE "AtMostOne") IF .cardinality = "One" ELSE ("AtLeastOne" IF .required ELSE "Many"), name := '@' ++ .name, @@ -128,8 +168,14 @@ export async function getTypes( } filter .name != '@source' and .name != '@target', } FILTER @is_owned, backlinks := (SELECT DETACHED Link FILTER .target = Type) { - real_cardinality := "AtMostOne" IF EXISTS (select .constraints filter .name = 'std::exclusive') ELSE "Many", - name := '<' ++ .name ++ '[IS ' ++ std::assert_exists(.source.name) ++ ']', + real_cardinality := "AtMostOne" + IF + EXISTS (select .constraints filter .name = 'std::exclusive') + ELSE + "Many", + name := '<' ++ .name ++ '[is ' ++ std::assert_exists( + .source.name if .source.name[:9] != 'default::' else .source.name[9:] + ) ++ ']', stub := .name, target_id := .source.id, kind := 'link', @@ -164,6 +210,44 @@ export async function getTypes( // tslint:disable-next-line if (params?.debug) console.log(JSON.stringify(types, null, 2)); + // remap types + for (const type of types) { + switch (type.kind) { + case "scalar": + if (typeMapping.has(type.id)) { + type.castOnlyType = typeMapping.get(type.id)!.id; + } + // if (type.material_id) { + // type.material_id = + // typeMapping.get(type.material_id)?.id ?? type.material_id; + // } + // type.bases = type.bases.map(base => ({ + // id: typeMapping.get(base.id)?.id ?? base.id, + // })); + break; + case "array": + // type.array_element_id = + // typeMapping.get(type.array_element_id)?.id ?? + // type.array_element_id; + break; + case "tuple": + // type.tuple_elements = type.tuple_elements.map(element => ({ + // ...element, + // target_id: + // typeMapping.get(element.target_id)?.id ?? element.target_id, + // })); + break; + case "object": + // type.pointers = type.pointers.map(pointer => ({ + // ...pointer, + // target_id: + // typeMapping.get(pointer.target_id)?.id ?? pointer.target_id, + // })); + break; + } + } + types.push(numberType); + // Now sort `types` topologically: return topoSort(types); } diff --git a/src/reflection/reservedKeywords.ts b/src/reflection/reservedKeywords.ts index 41451f068..7a6e251b7 100644 --- a/src/reflection/reservedKeywords.ts +++ b/src/reflection/reservedKeywords.ts @@ -1,4 +1,4 @@ -export default [ +export const reservedKeywords = [ "__edgedbsys__", "__edgedbtpl__", "__source__", @@ -84,5 +84,5 @@ export default [ "variadic", "when", "window", - "with" -] + "with", +]; diff --git a/src/reflection/typesystem.ts b/src/reflection/typesystem.ts index a086a11a5..84c24cce6 100644 --- a/src/reflection/typesystem.ts +++ b/src/reflection/typesystem.ts @@ -1,8 +1,9 @@ import type {Executor} from "../ifaces"; import type {$expr_TypeIntersection, $pathify, $expr_PathNode} from "./path"; import type {$expr_Literal} from "./literal"; +import type {$expr_Operator} from "./funcops"; import type {typeutil} from "./util/typeutil"; -import {Cardinality, ExpressionKind, TypeKind} from "./enums"; +import {Cardinality, ExpressionKind, OperatorKind, TypeKind} from "./enums"; import {cardinalityUtil} from "./util/cardinalityUtil"; ////////////////// @@ -26,17 +27,86 @@ export type BaseTypeTuple = typeutil.tupleOf; export interface ScalarType< Name extends string = string, TsType extends any = any, + Castable extends boolean = boolean, TsConstType extends TsType = TsType > extends BaseType { __kind__: TypeKind.scalar; __tstype__: TsType; __tsconsttype__: TsConstType; + __castable__: Castable; __name__: Name; - (val: T): $expr_Literal< - ScalarType - >; } +export type scalarTypeWithConstructor< + S extends ScalarType, + ExtraTsTypes extends any = never +> = S & { + // tslint:disable-next-line + (val: T): $expr_Literal< + ScalarType< + S["__name__"], + S["__tstype__"], + S["__castable__"], + T extends S["__tstype__"] ? T : S["__tstype__"] + > + >; +}; +// export type scalarTypeWithConstructor< +// Root extends ScalarType, +// ExtraTsTypes extends any = never, +// ConstructorType extends ScalarType = Root +// > = Root & { +// // tslint:disable-next-line +// ( +// val: T +// ): $expr_Literal< +// ScalarType< +// ConstructorType["__name__"], +// ConstructorType["__tstype__"], +// ConstructorType["__castable__"], +// T extends ConstructorType["__tstype__"] +// ? T +// : ConstructorType["__tstype__"] +// > +// >; +// }; + +// export interface CastOnlyScalarType< +// Name extends string = string, +// CastType extends ScalarType = ScalarType +// > extends BaseType { +// __kind__: TypeKind.castonlyscalar; +// __name__: Name; +// __casttype__: CastType; +// } + +type $jsonDestructure = + Set["__element__"] extends ScalarType<"std::json"> + ? { + [path: string]: $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet + >; + } & { + destructure> | string>( + path: T + ): $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + Set["__element__"], + cardinalityUtil.multiplyCardinalities< + Set["__cardinality__"], + T extends TypeSet ? T["__cardinality__"] : Cardinality.One + > + > + >; + } + : unknown; + //////////////////// // SETS AND EXPRESSIONS //////////////////// @@ -60,20 +130,26 @@ export function $toSet( }; } -export type Expression = - BaseType extends Set["__element__"] - ? Set & {toEdgeQL(): string; $is: any; $assertSingle: any} - : Set & +export type Expression< + Set extends TypeSet = TypeSet, + Runnable extends boolean = true +> = Set & + (BaseType extends Set["__element__"] // short-circuit non-specific types + ? { + run(cxn: Executor): any; + toEdgeQL(): string; + is: any; + assert_single: any; + // warning: any; + } + : $pathify & ExpressionMethods> & - $pathify< - Set, - Set extends {__parent__: any} ? Set["__parent__"] : null - >; - -export type QueryableExpression = - Expression & { - run(cxn: Executor): Promise>; - }; + (Runnable extends true + ? {run(cxn: Executor): Promise>} + : {}) & + $tuplePathify & + $arrayLikeIndexify & + $jsonDestructure); export type stripSet = "__element__" extends keyof T ? "__cardinality__" extends keyof T @@ -84,6 +160,13 @@ export type stripSet = "__element__" extends keyof T : T : T; +// export type stripSet = T extends {__element__: any; __cardinality__: any} +// ? { +// __element__: T["__element__"]; +// __cardinality__: T["__cardinality__"]; +// } +// : any; + export type stripSetShape = { [k in keyof T]: stripSet; }; @@ -91,7 +174,7 @@ export type stripSetShape = { // importing the actual alias from // generated/modules/std didn't work. // returned 'any' every time -export type $assertSingle = Expression<{ +export type assert_single = Expression<{ __element__: Expr["__element__"]; __cardinality__: cardinalityUtil.overrideUpperBound< Expr["__cardinality__"], @@ -103,12 +186,10 @@ export type $assertSingle = Expression<{ __namedargs__: {}; }>; -export interface ExpressionMethods { - __element__: Set["__element__"]; - __cardinality__: Set["__cardinality__"]; - +export type ExpressionMethods = { toEdgeQL(): string; - $is( + + is( ixn: T ): $expr_TypeIntersection< {__cardinality__: Set["__cardinality__"]; __element__: Set["__element__"]}, @@ -119,8 +200,8 @@ export interface ExpressionMethods { {id: true} > >; - $assertSingle(): $assertSingle; -} + assert_single(): assert_single>; +}; ////////////////// // ENUMTYPE @@ -167,13 +248,15 @@ export interface PropertyDesc< Type extends BaseType = BaseType, Card extends Cardinality = Cardinality, Exclusive extends boolean = boolean, - Writable extends boolean = boolean + Writable extends boolean = boolean, + HasDefault extends boolean = boolean > { __kind__: "property"; target: Type; cardinality: Card; exclusive: Exclusive; writable: Writable; + hasDefault: HasDefault; } export type $scopify = $expr_PathNode< @@ -191,7 +274,8 @@ export interface LinkDesc< Card extends Cardinality = Cardinality, LinkProps extends PropertyShape = any, Exclusive extends boolean = boolean, - Writable extends boolean = boolean + Writable extends boolean = boolean, + HasDefault extends boolean = boolean > { __kind__: "link"; target: Type; @@ -199,6 +283,7 @@ export interface LinkDesc< properties: LinkProps; exclusive: Exclusive; writable: Writable; + hasDefault: HasDefault; } export type ObjectTypePointers = { @@ -304,13 +389,108 @@ export type PrimitiveTypeSet = TypeSet; ///////////////////////// /// ARRAYTYPE ///////////////////////// + +type $arrayLikeIndexify = Set["__element__"] extends + | ArrayType + | ScalarType<"std::str"> + | ScalarType<"std::bytes"> + ? { + [index: number]: $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + getPrimitiveBaseType< + Set["__element__"] extends ArrayType + ? Set["__element__"]["__element__"] + : Set["__element__"] + >, + Set["__cardinality__"] + > + >; + [slice: `${number}:${number | ""}` | `:${number}`]: $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + getPrimitiveBaseType, + Set["__cardinality__"] + > + >; + index> | number>( + index: T + ): $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + getPrimitiveBaseType< + Set["__element__"] extends ArrayType + ? Set["__element__"]["__element__"] + : Set["__element__"] + >, + cardinalityUtil.multiplyCardinalities< + Set["__cardinality__"], + T extends TypeSet ? T["__cardinality__"] : Cardinality.One + > + > + >; + slice< + S extends TypeSet> | number, + E extends + | TypeSet> + | number + | undefined + | null + >( + start: S, + end: E + ): $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + getPrimitiveBaseType, + cardinalityUtil.multiplyCardinalities< + cardinalityUtil.multiplyCardinalities< + Set["__cardinality__"], + S extends TypeSet ? S["__cardinality__"] : Cardinality.One + >, + E extends TypeSet ? E["__cardinality__"] : Cardinality.One + > + > + >; + slice< + E extends + | TypeSet> + | number + | undefined + | null + >( + start: undefined | null, + end: E + ): $expr_Operator< + "[]", + OperatorKind.Infix, + [Set, TypeSet], + TypeSet< + getPrimitiveBaseType, + cardinalityUtil.multiplyCardinalities< + Set["__cardinality__"], + E extends TypeSet ? E["__cardinality__"] : Cardinality.One + > + > + >; + } + : unknown; + export type $expr_Array< - Type extends BaseType = BaseType, + Type extends ArrayType = ArrayType, Card extends Cardinality = Cardinality // Items extends typeutil.tupleOf> > = Expression<{ __kind__: ExpressionKind.Array; - __items__: typeutil.tupleOf>; + __items__: typeutil.tupleOf>; __element__: Type; __cardinality__: Card; }>; @@ -331,6 +511,24 @@ type ArrayTypeToTsType = BaseTypeToTsType< ///////////////////////// /// TUPLE TYPE ///////////////////////// + +type $tuplePathify = Set["__element__"] extends TupleType + ? addTuplePaths + : Set["__element__"] extends NamedTupleType + ? addNamedTuplePaths + : unknown; + +export type $expr_TuplePath< + ItemType extends BaseType = BaseType, + ParentCard extends Cardinality = Cardinality +> = Expression<{ + __kind__: ExpressionKind.TuplePath; + __element__: ItemType; + __cardinality__: ParentCard; + __parent__: $expr_Tuple | $expr_NamedTuple | $expr_TuplePath; + __index__: string | number; +}>; + export type baseTupleElementsToTupleType> = { [k in keyof T]: T[k] extends TypeSet @@ -362,6 +560,17 @@ export type $expr_Tuple< >; }>; +export type indexKeys = T extends `${number}` ? T : never; + +type addTuplePaths< + Items extends BaseType[], + ParentCard extends Cardinality +> = { + [k in indexKeys]: Items[k] extends BaseType + ? $expr_TuplePath + : never; +}; + export interface TupleType extends BaseType { __name__: string; @@ -396,6 +605,7 @@ type inferNamedTupleCardinality = [ ] ? Cardinality.One : Cardinality.Many; + export type $expr_NamedTuple< Shape extends NamedTupleLiteralShape = NamedTupleLiteralShape > = Expression<{ @@ -405,6 +615,15 @@ export type $expr_NamedTuple< __shape__: Shape; }>; +type addNamedTuplePaths< + Shape extends NamedTupleShape, + ParentCard extends Cardinality +> = { + [k in keyof Shape]: Shape[k] extends BaseType + ? $expr_TuplePath + : never; +}; + export type NamedTupleLiteralShape = {[k: string]: TypeSet}; export type NamedTupleShape = {[k: string]: BaseType}; export interface NamedTupleType< @@ -426,9 +645,12 @@ type NamedTupleTypeToTsType = { export type BaseTypeToTsType = typeutil.flatten< Type extends ScalarType ? Type["__tsconsttype__"] - : Type extends EnumType + : // Type extends CastOnlyScalarType + // ? Type["__casttype__"]["__tsconsttype__"] + // : + Type extends EnumType ? Type["__tstype__"] - : Type extends ArrayType + : Type extends ArrayType ? ArrayTypeToTsType : Type extends TupleType ? TupleItemsToTsType @@ -444,7 +666,7 @@ export type setToTsType = computeTsType< Set["__cardinality__"] >; -type computeTsTypeCard< +export type computeTsTypeCard< T extends any, C extends Cardinality > = Cardinality extends C @@ -490,9 +712,12 @@ export type pointerToTsType = /////////////////// export type getPrimitiveBaseType = T extends ScalarType - ? ScalarType + ? ScalarType : T; +export type getPrimitiveNonArrayBaseType = + T extends NonArrayType ? getPrimitiveBaseType : never; + export function isScalarType(type: BaseType): type is ScalarType { return type.__kind__ === TypeKind.scalar; } @@ -512,6 +737,9 @@ export function isArrayType(type: BaseType): type is ArrayType { return type.__kind__ === TypeKind.array; } +export type CastableScalarType = ScalarType; +// | CastOnlyScalarType; + export type NonArrayType = | ScalarType | EnumType @@ -519,6 +747,31 @@ export type NonArrayType = | TupleType | NamedTupleType; +export type CastableNonArrayType = + | CastableScalarType + | EnumType + | ObjectType + | TupleType + | NamedTupleType; + export type AnyTupleType = TupleType | NamedTupleType; -export type ParamType = ScalarType | ArrayType; +export type CastableArrayType = ArrayType; + +export type unwrapCastableType = + // T extends CastOnlyScalarType + // ? T["__casttype__"] + // : + T extends CastableArrayType + ? ArrayType> + : T; + +export type ParamType = + | CastableScalarType + | ArrayType< + | CastableScalarType + | TupleType> + | NamedTupleType<{[k: string]: ParamType}> + > + | TupleType> + | NamedTupleType<{[k: string]: ParamType}>; diff --git a/src/reflection/util/functionUtils.ts b/src/reflection/util/functionUtils.ts index 33d67df77..78114ea84 100644 --- a/src/reflection/util/functionUtils.ts +++ b/src/reflection/util/functionUtils.ts @@ -8,16 +8,17 @@ import {StrictMap} from "../strictMap"; import {frag, makeValidIdent, quote} from "./genutil"; import {util} from "./util"; -type AnytypeDef = +export type AnytypeDef = | {kind: "castable"; type: CodeFragment[]; returnAnytypeWrapper: string} | { kind: "noncastable"; type: CodeFragment[]; + typeObj: introspect.Type; refName: string; refPath: string; }; -type FuncopDefOverload = F & { +export type FuncopDefOverload = F & { overloadIndex: number; params: GroupedParams; anytypes: AnytypeDef | null; @@ -71,6 +72,7 @@ export function expandFuncopAnytypeOverloads( anytypes: { kind: "noncastable" as const, type: [hasArrayType ? "$.NonArrayType" : "$.BaseType"], + typeObj: anytypeParams[0].type, refName: anytypeParams[0].typeName, refPath: findPathOfAnytype(anytypeParams[0].type.id, types), }, diff --git a/src/reflection/util/genutil.ts b/src/reflection/util/genutil.ts index 1083596c0..8cb1e46d9 100644 --- a/src/reflection/util/genutil.ts +++ b/src/reflection/util/genutil.ts @@ -21,62 +21,63 @@ export function quote(val: string): string { return JSON.stringify(val.toString()); } -export function toPrimitiveJsType( - s: introspect.ScalarType, - code: CodeBuilder -): string { - switch (s.name) { - case "std::int16": - case "std::int32": - case "std::int64": - case "std::float32": - case "std::float64": - return "number"; - - case "std::str": - case "std::uuid": - case "std::json": - return "string"; - - case "std::bool": - return "boolean"; - - case "std::bigint": - return "bigint"; - - case "std::datetime": - return "Date"; - - case "std::duration": - return "_.edgedb.Duration"; - case "cal::local_datetime": - return "_.edgedb.LocalDateTime"; - case "cal::local_date": - return "_.edgedb.LocalDate"; - case "cal::local_time": - return "_.edgedb.LocalTime"; - case "cal::relative_duration": - return "_.edgedb.RelativeDuration"; - case "cfg::memory": - return "_.edgedb.ConfigMemory"; - - case "std::bytes": - return "Buffer"; - - case "std::decimal": - // TODO - - default: - return "unknown"; +export const scalarToLiteralMapping: { + [key: string]: { + type: string; + literalKind?: "typeof" | "instanceof"; + extraTypes?: string[]; + }; +} = { + "std::int16": {type: "number"}, + "std::int32": {type: "number"}, + "std::int64": {type: "number"}, + "std::float32": {type: "number"}, + "std::float64": {type: "number"}, + "std::number": { + type: "number", + literalKind: "typeof", + extraTypes: ["string"], + }, + "std::str": {type: "string", literalKind: "typeof"}, + "std::uuid": {type: "string"}, + "std::json": {type: "string", extraTypes: ["any"]}, + "std::bool": {type: "boolean", literalKind: "typeof"}, + "std::bigint": {type: "bigint", literalKind: "typeof"}, + "std::bytes": {type: "Buffer", literalKind: "instanceof"}, + "std::datetime": {type: "Date", literalKind: "instanceof"}, + "std::duration": {type: "edgedb.Duration", literalKind: "instanceof"}, + "cal::local_datetime": { + type: "edgedb.LocalDateTime", + literalKind: "instanceof", + }, + "cal::local_date": {type: "edgedb.LocalDate", literalKind: "instanceof"}, + "cal::local_time": {type: "edgedb.LocalTime", literalKind: "instanceof"}, + "cal::relative_duration": { + type: "edgedb.RelativeDuration", + literalKind: "instanceof", + }, + "cfg::memory": {type: "edgedb.ConfigMemory", literalKind: "instanceof"}, +}; + +export const literalToScalarMapping: { + [key: string]: {type: string; literalKind: "typeof" | "instanceof"}; +} = {}; +for (const [scalarType, {type, literalKind}] of Object.entries( + scalarToLiteralMapping +)) { + if (literalKind) { + if (literalToScalarMapping[type]) { + throw new Error( + `literal type '${type}' cannot be mapped to multiple scalar types` + ); + } + literalToScalarMapping[type] = {type: scalarType, literalKind}; } } export function toTSScalarType( type: introspect.PrimitiveType, - types: introspect.Types, - currentModule: string, - code: CodeBuilder, - level: number = 0 + types: introspect.Types ): CodeFragment[] { switch (type.kind) { case "scalar": { @@ -87,23 +88,18 @@ export function toTSScalarType( if (type.material_id) { return toTSScalarType( types.get(type.material_id) as introspect.ScalarType, - types, - currentModule, - code, - level + 1 + types ); } - return [toPrimitiveJsType(type, code)]; + const literalType = scalarToLiteralMapping[type.name]?.type ?? "unknown"; + return [(literalType.startsWith("edgedb.") ? "_." : "") + literalType]; } case "array": { const tn = toTSScalarType( types.get(type.array_element_id) as introspect.PrimitiveType, - types, - currentModule, - code, - level + 1 + types ); return frag`${tn}[]`; } @@ -122,10 +118,7 @@ export function toTSScalarType( for (const {name, target_id} of type.tuple_elements) { const tn = toTSScalarType( types.get(target_id) as introspect.PrimitiveType, - types, - currentModule, - code, - level + 1 + types ); res.push(frag`${name}: ${tn}`); } @@ -136,10 +129,7 @@ export function toTSScalarType( for (const {target_id} of type.tuple_elements) { const tn = toTSScalarType( types.get(target_id) as introspect.PrimitiveType, - types, - currentModule, - code, - level + 1 + types ); res.push(tn); } diff --git a/src/syntax/cast.ts b/src/syntax/cast.ts index 74bf4c782..22aa8262d 100644 --- a/src/syntax/cast.ts +++ b/src/syntax/cast.ts @@ -1,24 +1,38 @@ -import {Expression, ExpressionKind, BaseType} from "../reflection"; +import { + Expression, + ExpressionKind, + BaseType, + CastableNonArrayType, + CastableArrayType, + unwrapCastableType, + TypeSet, + Cardinality, +} from "../reflection"; import {$expressionify} from "./path"; -export function cast( +export function cast( target: Target, - expr: Expr -): $expr_Cast { + arg: null +): $expr_Cast>; +export function cast< + Target extends CastableNonArrayType | CastableArrayType, + Expr extends TypeSet +>(target: Target, expr: Expr): $expr_Cast; +export function cast(target: BaseType, expr: any) { return $expressionify({ __element__: target, - __cardinality__: expr.__cardinality__, + __cardinality__: expr === null ? Cardinality.Empty : expr.__cardinality__, __expr__: expr, __kind__: ExpressionKind.Cast, - }); + }) as any; } export type $expr_Cast< Target extends BaseType = BaseType, - Expr extends Expression = Expression + Expr extends TypeSet = TypeSet > = Expression<{ - __element__: Target; + __element__: unwrapCastableType; __cardinality__: Expr["__cardinality__"]; __kind__: ExpressionKind.Cast; - __expr__: Expr; + __expr__: Expr | null; }>; diff --git a/src/syntax/casting.ts b/src/syntax/casting.ts index fc2613e78..e02d5a2e8 100644 --- a/src/syntax/casting.ts +++ b/src/syntax/casting.ts @@ -10,8 +10,13 @@ import { ScalarType, TupleType, TypeSet, + typeutil, } from "../reflection"; -import {scalarCastableFrom, scalarAssignableBy} from "@generated/castMaps"; +import { + scalarCastableFrom, + scalarAssignableBy, + orScalarLiteral, +} from "@generated/castMaps"; export type anonymizeObject = ObjectType< string, @@ -42,20 +47,22 @@ export type assignableBy = T extends ScalarType : T extends TupleType ? TupleType> : T extends NamedTupleType - ? NamedTupleType< - { - [k in keyof T["__shape__"]]: assignableBy; - } - > + ? NamedTupleType<{ + [k in keyof T["__shape__"]]: assignableBy; + }> : never; export type pointerToAssignmentExpression< Pointer extends PropertyDesc | LinkDesc > = [Pointer] extends [PropertyDesc] - ? { - __element__: assignableBy; - __cardinality__: cardinalityUtil.assignable; - } + ? typeutil.flatten< + orScalarLiteral< + TypeSet< + assignableBy, + cardinalityUtil.assignable + > + > + > : [Pointer] extends [LinkDesc] ? TypeSet< ObjectType< @@ -90,11 +97,9 @@ export type castableFrom = T extends ScalarType : T extends TupleType ? TupleType> : T extends NamedTupleType - ? NamedTupleType< - { - [k in keyof T["__shape__"]]: castableFrom; - } - > + ? NamedTupleType<{ + [k in keyof T["__shape__"]]: castableFrom; + }> : never; export type pointerToCastableExpression< diff --git a/src/syntax/collections.ts b/src/syntax/collections.ts index 673f8a03a..e79322e50 100644 --- a/src/syntax/collections.ts +++ b/src/syntax/collections.ts @@ -2,10 +2,14 @@ import { $expr_Array, $expr_NamedTuple, $expr_Tuple, + $expr_TuplePath, ArrayType, BaseType, + Cardinality, cardinalityUtil, + CastableNonArrayType, ExpressionKind, + ExpressionRoot, getPrimitiveBaseType, NamedTupleLiteralShape, NamedTupleShape, @@ -18,25 +22,130 @@ import { } from "../reflection"; import {$expressionify} from "./path"; import {getCardsFromExprs} from "./set"; +import { + literalToScalarType, + literalToTypeSet, + mapLiteralToTypeSet, + orScalarLiteral, + scalarLiterals, +} from "@generated/castMaps"; + +const indexSliceRegx = /^(-?\d+)(?:(:)(-?\d+)?)?|:(-?\d+)$/; + +const arrayLikeProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + const match = typeof prop === "string" ? prop.match(indexSliceRegx) : null; + if (match) { + const start = match[1]; + const end = match[3] ?? match[4]; + const isIndex = start && !match[2]; + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: + target.__element__.__kind__ === TypeKind.array && isIndex + ? (target.__element__ as ArrayType).__element__ + : target.__element__, + __cardinality__: target.__cardinality__, + __name__: "[]", + __opkind__: "Infix", + __args__: [ + proxy, + isIndex + ? literalToTypeSet(Number(start)) + : [ + start && literalToTypeSet(Number(start)), + end && literalToTypeSet(Number(end)), + ], + ], + }) as any; + } + return (target as any)[prop]; + }, +}; + +function arrayLikeIndex(this: ExpressionRoot, index: any) { + const indexTypeSet = literalToTypeSet(index); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: + this.__element__.__kind__ === TypeKind.array + ? (this.__element__ as ArrayType).__element__ + : this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + indexTypeSet.__cardinality__ + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, indexTypeSet], + }) as any; +} + +function arrayLikeSlice(this: ExpressionRoot, start: any, end: any) { + const startTypeSet = start && literalToTypeSet(start); + const endTypeSet = end && literalToTypeSet(end); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + startTypeSet?.__cardinality__ ?? Cardinality.One + ), + endTypeSet?.__cardinality__ ?? Cardinality.One + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, [startTypeSet, endTypeSet]], + }) as any; +} + +export function $arrayLikeIndexify(_expr: ExpressionRoot) { + if ( + _expr.__element__.__kind__ === TypeKind.array || + (_expr.__element__.__kind__ === TypeKind.scalar && + (_expr.__element__.__name__ === "std::str" || + _expr.__element__.__name__ === "std::bytes")) + ) { + const expr = new Proxy(_expr, arrayLikeProxyHandlers) as any; + + expr.index = arrayLikeIndex.bind(expr); + expr.slice = arrayLikeSlice.bind(expr); + + return expr; + } + + return _expr; +} // ARRAY -export function array( +export function array( element: Element ): ArrayType; export function array< - Expr extends TypeSet, - Exprs extends TypeSet>[] + Expr extends TypeSet | scalarLiterals, + Exprs extends orScalarLiteral< + TypeSet< + Expr extends TypeSet + ? getPrimitiveBaseType + : getPrimitiveBaseType> + > + >[] >( arg: [Expr, ...Exprs] ): $expr_Array< - ArrayType>, + ArrayType< + Expr extends TypeSet + ? getPrimitiveBaseType + : getPrimitiveBaseType> + >, cardinalityUtil.multiplyCardinalitiesVariadic< - getCardsFromExprs<[Expr, ...Exprs]> + getCardsFromExprs> > >; export function array(arg: any) { if (Array.isArray(arg)) { - const items = arg as TypeSet[]; + const items = arg.map(a => literalToTypeSet(a)); return $expressionify({ __kind__: ExpressionKind.Array, __cardinality__: cardinalityUtil.multiplyCardinalitiesVariadic( @@ -63,6 +172,46 @@ export function array(arg: any) { // TUPLE +const tupleProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + const type = target.__element__; + const items = + type.__kind__ === TypeKind.tuple + ? (type as TupleType).__items__ + : type.__kind__ === TypeKind.namedtuple + ? (type as NamedTupleType).__shape__ + : null; + return items?.hasOwnProperty(prop) + ? tuplePath(proxy, (items as any)[prop], prop as any) + : (target as any)[prop]; + }, +}; + +export function $tuplePathify(expr: ExpressionRoot) { + if ( + expr.__element__.__kind__ !== TypeKind.tuple && + expr.__element__.__kind__ !== TypeKind.namedtuple + ) { + return expr; + } + + return new Proxy(expr, tupleProxyHandlers); +} + +function tuplePath( + parent: $expr_Tuple | $expr_TuplePath, + itemType: BaseType, + index: string +): $expr_TuplePath { + return $expressionify({ + __kind__: ExpressionKind.TuplePath, + __element__: itemType, + __cardinality__: parent.__cardinality__, + __parent__: parent, + __index__: index, + }) as any; +} + function makeTupleType(name: string, items: BaseType[]) { return { __kind__: TypeKind.tuple, @@ -70,16 +219,38 @@ function makeTupleType(name: string, items: BaseType[]) { __items__: items, } as any; } + +const typeKinds = new Set(Object.values(TypeKind)); + export function tuple>( items: Items ): TupleType; export function tuple< - Item extends TypeSet, - Items extends typeutil.tupleOf ->(items: Items): $expr_Tuple; -export function tuple(_items: any[]) { - if (_items.every(item => !!item.__element__)) { - const items = _items as TypeSet[]; + Item extends TypeSet | scalarLiterals, + Items extends typeutil.tupleOf +>( + items: Items +): $expr_Tuple< + Items extends typeutil.tupleOf ? mapLiteralToTypeSet : never +>; +export function tuple( + shape: Shape +): NamedTupleType; +export function tuple( + shape: Shape +): $expr_NamedTuple>; +export function tuple(input: any) { + if (Array.isArray(input)) { + // is tuple + if (input.every(item => typeKinds.has(item.__kind__))) { + const typeItems = input as BaseType[]; + const typeName = `tuple<${typeItems + .map(item => item.__name__) + .join(", ")}>`; + return makeTupleType(typeName, typeItems); + } + + const items = input.map(item => literalToTypeSet(item)); const name = `tuple<${items .map(item => item.__element__.__name__) .join(", ")}>`; @@ -93,34 +264,29 @@ export function tuple(_items: any[]) { items.map(i => i.__cardinality__) as any ), __items__: items, - }); - } - if (_items.every(item => Object.values(TypeKind).includes(item.__kind__))) { - const items = _items as BaseType[]; - const name = `tuple<${items.map(item => item.__name__).join(", ")}>`; - return makeTupleType(name, items); - } - throw new Error("Invalid tuple input."); -} - -// NAMED TUPLE + }) as any; + } else { + // is named tuple + if (Object.values(input).every((el: any) => typeKinds.has(el.__kind__))) { + const typeName = `tuple<${Object.entries(input) + .map(([key, val]: [string, any]) => `${key}: ${val.__name__}`) + .join(", ")}>`; + return { + __kind__: TypeKind.namedtuple, + __name__: typeName, + __shape__: input, + } as any; + } -export function namedTuple( - shape: Shape -): NamedTupleType; -export function namedTuple( - shape: Shape -): $expr_NamedTuple; -export function namedTuple(shape: any): any { - if (Object.values(shape).every((el: any) => !!el.__element__)) { - const exprShape = shape as NamedTupleLiteralShape; + const exprShape: NamedTupleLiteralShape = {}; + const typeShape: NamedTupleShape = {}; + for (const [key, val] of Object.entries(input)) { + exprShape[key] = literalToTypeSet(val); + typeShape[key] = exprShape[key].__element__; + } const name = `tuple<${Object.entries(exprShape) .map(([key, val]) => `${key}: ${val.__element__.__name__}`) .join(", ")}>`; - const typeShape: any = {}; - for (const key of Object.keys(exprShape)) { - typeShape[key] = exprShape[key].__element__; - } return $expressionify({ __kind__: ExpressionKind.NamedTuple, __element__: { @@ -132,24 +298,8 @@ export function namedTuple(shape: any): any { Object.values(exprShape).map(val => val.__cardinality__) as any ), __shape__: exprShape, - }); - } - if ( - Object.values(shape).every((el: any) => - Object.values(TypeKind).includes(el.__kind__) - ) - ) { - const name = `tuple<${Object.entries(shape) - .map(([key, val]: [string, any]) => `${key}: ${val.__name__}`) - .join(", ")}>`; - return { - __kind__: TypeKind.namedtuple, - __name__: name, - __shape__: shape, - } as any; + }) as any; } - - throw new Error("Invalid named tuple input."); } export type { @@ -157,6 +307,3 @@ export type { NamedTupleType as $NamedTuple, TupleType as $Tuple, } from "../reflection"; - -// export { array, tuple, namedTuple}; -// from "../reflection"; diff --git a/src/syntax/for.ts b/src/syntax/for.ts index 92260bcd4..ad4b18d1e 100644 --- a/src/syntax/for.ts +++ b/src/syntax/for.ts @@ -5,15 +5,13 @@ import { Cardinality, ExpressionKind, cardinalityUtil, - QueryableExpression, } from "../reflection"; import {$expressionify} from "./path"; -import {$queryify} from "./query"; export type $expr_For< IterSet extends BaseTypeSet = BaseTypeSet, Expr extends Expression = Expression -> = QueryableExpression<{ +> = Expression<{ __element__: Expr["__element__"]; __cardinality__: cardinalityUtil.multiplyCardinalities< IterSet["__cardinality__"], @@ -43,19 +41,17 @@ function _for( const returnExpr = expr(forVar); - return $expressionify( - $queryify({ - __kind__: ExpressionKind.For, - __element__: returnExpr.__element__, - __cardinality__: cardinalityUtil.multiplyCardinalities( - set.__cardinality__, - returnExpr.__cardinality__ - ), - __iterSet__: set, - __expr__: returnExpr, - __forVar__: forVar, - }) - ) as any; + return $expressionify({ + __kind__: ExpressionKind.For, + __element__: returnExpr.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + set.__cardinality__, + returnExpr.__cardinality__ + ), + __iterSet__: set, + __expr__: returnExpr, + __forVar__: forVar, + }) as any; } export {_for as for}; diff --git a/src/syntax/funcops.ts b/src/syntax/funcops.ts index eb16bacd3..59d3a83b7 100644 --- a/src/syntax/funcops.ts +++ b/src/syntax/funcops.ts @@ -1,52 +1,19 @@ import { - Expression, BaseType, BaseTypeSet, Cardinality, - ExpressionKind, introspect, makeType, TypeKind, ArrayType, cardinalityUtil, ObjectType, - OperatorKind, TypeSet, } from "../reflection"; -import {set} from "./set"; -import {isImplicitlyCastableTo} from "@generated/castMaps"; +import {cast} from "./cast"; +import {isImplicitlyCastableTo, literalToTypeSet} from "@generated/castMaps"; import {literal} from "./literal"; -export type $expr_Function< - Name extends string = string, - Args extends (BaseTypeSet | undefined)[] = (BaseTypeSet | undefined)[], - NamedArgs extends {[key: string]: BaseTypeSet} = { - [key: string]: BaseTypeSet; - }, - ReturnType extends BaseTypeSet = BaseTypeSet -> = Expression<{ - __element__: ReturnType["__element__"]; - __cardinality__: ReturnType["__cardinality__"]; - __kind__: ExpressionKind.Function; - __name__: Name; - __args__: Args; - __namedargs__: NamedArgs; -}>; - -export type $expr_Operator< - Name extends string = string, - OpKind extends OperatorKind = OperatorKind, - Args extends TypeSet[] = TypeSet[], - ReturnType extends TypeSet = TypeSet -> = Expression<{ - __element__: ReturnType["__element__"]; - __cardinality__: ReturnType["__cardinality__"]; - __kind__: ExpressionKind.Operator; - __name__: Name; - __opkind__: OpKind; - __args__: Args; -}>; - interface OverloadFuncArgDef { typeId: string; optional?: boolean; @@ -63,6 +30,22 @@ interface OverloadFuncDef { preservesOptionality?: boolean; } +function mapLiteralToTypeSet(literals: any[]): TypeSet[]; +function mapLiteralToTypeSet(literals: {[key: string]: any}): { + [key: string]: TypeSet; +}; +function mapLiteralToTypeSet(literals: any[] | {[key: string]: any}) { + if (Array.isArray(literals)) { + return literals.map(lit => (lit != null ? literalToTypeSet(lit) : lit)); + } + const obj: {[key: string]: TypeSet} = {}; + for (const key of Object.keys(literals)) { + obj[key] = + literals[key] != null ? literalToTypeSet(literals[key]) : literals[key]; + } + return obj; +} + export function $resolveOverload( funcName: string, args: any[], @@ -71,8 +54,11 @@ export function $resolveOverload( ) { const [positionalArgs, namedArgs] = typeof args[0] === "object" && typeof args[0].__kind__ === "undefined" - ? [args.slice(1), args[0]] - : [args, undefined]; + ? [ + mapLiteralToTypeSet(args.slice(1)), + mapLiteralToTypeSet(args[0] as object), + ] + : [mapLiteralToTypeSet(args), undefined]; for (const def of funcDefs) { const resolvedOverload = _tryOverload( @@ -87,9 +73,11 @@ export function $resolveOverload( } } throw new Error( - `No function overload found for 'e.${ - funcName.split("::")[1] - }()' with args: ${args.map(arg => `${arg}`).join(", ")}` + `No function overload found for ${ + funcName.includes("::") + ? `'e.${funcName.split("::")[1]}()'` + : `operator '${funcName}'` + } with args: ${args.map(arg => `${arg}`).join(", ")}` ); } @@ -162,7 +150,7 @@ function _tryOverload( if (i < args.length) { // arg is explicitly undefined, inject empty set const argType = makeType(typeSpec, argDef.typeId, literal); - positionalArgs.push(set(argType)); + positionalArgs.push(cast(argType, null)); } } else { const {match, anytype} = compareType( @@ -205,19 +193,8 @@ function _tryOverload( } } - let cardinality = - funcDef.returnTypemod === "SetOfType" - ? Cardinality.Many - : cardinalityUtil.multiplyCardinalitiesVariadic(paramCardinalities); - - if ( - funcDef.returnTypemod === "OptionalType" && - !funcDef.preservesOptionality - ) { - cardinality = cardinalityUtil.overrideLowerBound(cardinality, "Zero"); - } - - if (funcName === "std::if_else") { + let cardinality: Cardinality; + if (funcName === "if_else") { cardinality = cardinalityUtil.multiplyCardinalities( cardinalityUtil.orCardinalities( positionalArgs[0].__cardinality__, @@ -225,6 +202,23 @@ function _tryOverload( ), positionalArgs[1].__cardinality__ ); + } else if (funcName === "std::assert_exists") { + cardinality = cardinalityUtil.overrideLowerBound( + positionalArgs[0].__cardinality__, + "One" + ); + } else { + cardinality = + funcDef.returnTypemod === "SetOfType" + ? Cardinality.Many + : cardinalityUtil.multiplyCardinalitiesVariadic(paramCardinalities); + + if ( + funcDef.returnTypemod === "OptionalType" && + !funcDef.preservesOptionality + ) { + cardinality = cardinalityUtil.overrideLowerBound(cardinality, "Zero"); + } } return { @@ -253,6 +247,7 @@ function compareType( } if (type.kind === "scalar") { + arg = (arg as any).__casttype__ ?? arg; return { match: arg.__kind__ === TypeKind.scalar && diff --git a/src/syntax/genMock/__spec__.ts b/src/syntax/genMock/__spec__.ts new file mode 100644 index 000000000..9c7340f42 --- /dev/null +++ b/src/syntax/genMock/__spec__.ts @@ -0,0 +1 @@ +export declare const spec: Map; diff --git a/src/syntax/genMock/castMaps.ts b/src/syntax/genMock/castMaps.ts index 30436fbb8..e6a09c845 100644 --- a/src/syntax/genMock/castMaps.ts +++ b/src/syntax/genMock/castMaps.ts @@ -1,5 +1,14 @@ export type scalarCastableFrom = any; export type scalarAssignableBy = any; +export type orScalarLiteral = any; +export type scalarLiterals = any; +export type literalToScalarType = any; +type literalToTypeSet = any; +export type mapLiteralToTypeSet = { + [k in keyof T]: literalToTypeSet; +}; +declare function literalToTypeSet(t: any): any; +export {literalToTypeSet}; export declare function isImplicitlyCastableTo( from: string, to: string diff --git a/src/syntax/genMock/modules/std.ts b/src/syntax/genMock/modules/std.ts index 7bbb629ed..edfe409ef 100644 --- a/src/syntax/genMock/modules/std.ts +++ b/src/syntax/genMock/modules/std.ts @@ -5,11 +5,14 @@ import { ObjectType, $expr_PathNode, Cardinality, + scalarTypeWithConstructor, } from "../../../reflection"; declare function assert_single(input: TypeSet): any; -declare const int64: ScalarType<"std::int64", number>; +declare const number: scalarTypeWithConstructor< + ScalarType<"std::number", number> +>; export type $FreeObject = ObjectType<"std::FreeObject", any, null>; declare const FreeObject: $expr_PathNode< @@ -20,11 +23,6 @@ declare const FreeObject: $expr_PathNode< export type $bool = ScalarType<"std::bool", boolean>; -type $int16 = ScalarType<"std::int16", number>; -type $int32 = ScalarType<"std::int32", number>; -type $int64 = ScalarType<"std::int64", number>; -type $bigint = ScalarType<"std::bigint", BigInt>; - -export type $anyint = $int16 | $int32 | $int64 | $bigint; +export type $number = ScalarType<"std::number", number>; -export default {assert_single, int64, FreeObject}; +export default {assert_single, number, FreeObject}; diff --git a/src/syntax/genMock/operators.ts b/src/syntax/genMock/operators.ts new file mode 100644 index 000000000..54fcb9b8a --- /dev/null +++ b/src/syntax/genMock/operators.ts @@ -0,0 +1 @@ +export declare function op(...args: any[]): any; diff --git a/src/syntax/insert.ts b/src/syntax/insert.ts index 3c0275919..425ffa734 100644 --- a/src/syntax/insert.ts +++ b/src/syntax/insert.ts @@ -12,14 +12,15 @@ import { $scopify, stripSet, TypeSet, - QueryableExpression, + ScalarType, + scalarTypeWithConstructor, } from "../reflection"; import type {pointerToAssignmentExpression} from "./casting"; import {$expressionify, $getScopedExpr} from "./path"; -import {$queryify} from "./query"; +import {cast} from "./cast"; import {$expr_PathNode} from "../reflection/path"; -type pointerIsOptional = +export type pointerIsOptional = T["cardinality"] extends | Cardinality.Many | Cardinality.Empty @@ -34,7 +35,10 @@ export type InsertShape = typeutil.stripNever< ? typeutil.addQuestionMarks<{ [k in keyof Shape]: | pointerToAssignmentExpression - | (pointerIsOptional extends true ? undefined : never); + | (pointerIsOptional extends true + ? undefined | null + : never) + | (Shape[k]["hasDefault"] extends true ? undefined : never); }> : never : never; @@ -55,7 +59,7 @@ export type $expr_Insert< Root extends $expr_PathNode = $expr_PathNode // Conflict = UnlessConflict | null // Shape extends InsertShape = any -> = QueryableExpression<{ +> = Expression<{ __kind__: ExpressionKind.Insert; __element__: Root["__element__"]; __cardinality__: Cardinality.One; @@ -89,7 +93,7 @@ export type $expr_Insert< export type $expr_InsertUnlessConflict< Root extends InsertBaseExpression = InsertBaseExpression, Conflict extends UnlessConflict = UnlessConflict -> = QueryableExpression<{ +> = Expression<{ __kind__: ExpressionKind.InsertUnlessConflict; __element__: Root["__element__"]; __cardinality__: Cardinality.One; @@ -111,11 +115,11 @@ function unlessConflict( if (!conflictGetter) { expr.__conflict__ = {on: null}; - return $expressionify($queryify(expr)); + return $expressionify(expr); } else { const scopedExpr = $getScopedExpr(this.__expr__); expr.__conflict__ = conflictGetter(scopedExpr); - return $expressionify($queryify(expr)); + return $expressionify(expr); } } @@ -123,7 +127,51 @@ export function $insertify( expr: Omit<$expr_Insert, "unlessConflict"> ): $expr_Insert { (expr as any).unlessConflict = unlessConflict.bind(expr as any); - return $queryify(expr) as any; + return expr as any; +} + +export function $normaliseInsertShape( + root: ObjectTypeSet, + shape: {[key: string]: any}, + isUpdate: boolean = false +): {[key: string]: TypeSet | {"+=": TypeSet} | {"-=": TypeSet}} { + const newShape: { + [key: string]: TypeSet | {"+=": TypeSet} | {"-=": TypeSet}; + } = {}; + for (const [key, _val] of Object.entries(shape)) { + let val = _val; + let setModify: string | null = null; + if (isUpdate && _val != null && typeof _val === "object") { + const valKeys = Object.keys(_val); + if ( + valKeys.length === 1 && + (valKeys[0] === "+=" || valKeys[0] === "-=") + ) { + val = _val[valKeys[0]]; + setModify = valKeys[0]; + } + } + if (val?.__kind__ || val === undefined) { + newShape[key] = _val; + } else { + const pointer = root.__element__.__pointers__[key]; + if (!pointer || (pointer.__kind__ !== "property" && val !== null)) { + throw new Error( + `Could not find property pointer for ${ + isUpdate ? "update" : "insert" + } shape key: '${key}'` + ); + } + const wrappedVal = + val === null + ? cast(pointer.target, null) + : (pointer.target as scalarTypeWithConstructor)(val); + newShape[key] = setModify + ? ({[setModify]: wrappedVal} as any) + : wrappedVal; + } + } + return newShape; } export function insert( @@ -135,7 +183,7 @@ export function insert( __element__: root.__element__, __cardinality__: Cardinality.One, __expr__: root, - __shape__: shape, + __shape__: $normaliseInsertShape(root, shape), }; (expr as any).unlessConflict = unlessConflict.bind(expr); return $expressionify($insertify(expr)) as any; diff --git a/src/syntax/literal.ts b/src/syntax/literal.ts index 630dabc4a..be16f90f6 100644 --- a/src/syntax/literal.ts +++ b/src/syntax/literal.ts @@ -3,20 +3,36 @@ import { ExpressionKind, BaseType, BaseTypeToTsType, + unwrapCastableType, + makeType, + ScalarType, } from "../reflection"; import {$expr_Literal} from "../reflection/literal"; import {$expressionify} from "./path"; +import {spec} from "@generated/__spec__"; -function $expr_Literal( +export function literal( type: T, - value: BaseTypeToTsType -): $expr_Literal { + value: BaseTypeToTsType> +): $expr_Literal> { return $expressionify({ __element__: type, __cardinality__: Cardinality.One, __kind__: ExpressionKind.Literal, __value__: value, - }); + }) as any; } -export {$expr_Literal as literal}; +const nameMapping = new Map([ + ["std::number", "00000000-0000-0000-0000-0000000001ff"], +]); + +export function $getType(id: string): (val: any) => $expr_Literal { + return makeType(spec, id, literal) as any; +} + +export function $getTypeByName( + name: string +): (val: any) => $expr_Literal { + return makeType(spec, nameMapping.get(name)!, literal) as any; +} diff --git a/src/syntax/params.ts b/src/syntax/params.ts index 881eb14f4..2b55641c5 100644 --- a/src/syntax/params.ts +++ b/src/syntax/params.ts @@ -4,13 +4,13 @@ import { ExpressionKind, ParamType, Cardinality, - ScalarType, - ArrayType, setToTsType, TypeSet, + unwrapCastableType, + TypeKind, + BaseTypeToTsType, } from "../reflection"; import {$expressionify} from "./path"; -import {$queryify} from "./query"; export type $expr_OptionalParam = { __kind__: ExpressionKind.OptionalParam; @@ -31,7 +31,7 @@ export type QueryableWithParamsExpression< Params extends { [key: string]: ParamType | $expr_OptionalParam; } = {} -> = Expression & { +> = Expression & { run( cxn: Executor, args: paramsToParamArgs @@ -49,29 +49,11 @@ export type $expr_WithParams< __element__: Expr["__element__"]; __cardinality__: Expr["__cardinality__"]; __expr__: Expr; - __paramststype__: paramsToParamTypes; + __params__: $expr_Param[]; }, Params >; -type getParamTsType = Param extends ScalarType - ? Param["__tstype__"] - : Param extends ArrayType - ? Param["__element__"]["__tstype__"][] - : never; - -type paramsToParamTypes< - Params extends { - [key: string]: ParamType | $expr_OptionalParam; - } -> = { - [key in keyof Params]: Params[key] extends $expr_OptionalParam - ? getParamTsType | null - : Params[key] extends ParamType - ? getParamTsType - : never; -}; - type paramsToParamArgs< Params extends { [key: string]: ParamType | $expr_OptionalParam; @@ -80,16 +62,15 @@ type paramsToParamArgs< [key in keyof Params as Params[key] extends ParamType ? key : never]: Params[key] extends ParamType - ? getParamTsType + ? BaseTypeToTsType : never; -} & - { - [key in keyof Params as Params[key] extends $expr_OptionalParam - ? key - : never]?: Params[key] extends $expr_OptionalParam - ? getParamTsType | null - : never; - }; +} & { + [key in keyof Params as Params[key] extends $expr_OptionalParam + ? key + : never]?: Params[key] extends $expr_OptionalParam + ? BaseTypeToTsType | null + : never; +}; export type $expr_Param< Name extends string | number | symbol = string, @@ -97,11 +78,12 @@ export type $expr_Param< Optional extends boolean = boolean > = Expression<{ __kind__: ExpressionKind.Param; - __element__: Type; + __element__: unwrapCastableType; __cardinality__: Optional extends true ? Cardinality.AtMostOne : Cardinality.One; __name__: Name; + __isComplex__: boolean; }>; type paramsToParamExprs< @@ -116,39 +98,127 @@ type paramsToParamExprs< : never; }; -export function withParams< +const complexParamKinds = new Set([TypeKind.tuple, TypeKind.namedtuple]); + +export function params< Params extends { [key: string]: ParamType | $expr_OptionalParam; } = {}, Expr extends Expression = Expression >( - params: Params, + paramsDef: Params, expr: (params: paramsToParamExprs) => Expr ): $expr_WithParams { const paramExprs: {[key: string]: $expr_Param} = {}; - for (const [key, param] of Object.entries(params)) { + for (const [key, param] of Object.entries(paramsDef)) { + const paramType = + param.__kind__ === ExpressionKind.OptionalParam ? param.__type__ : param; + const isComplex = + complexParamKinds.has(paramType.__kind__) || + (paramType.__kind__ === TypeKind.array && + complexParamKinds.has(paramType.__element__.__kind__)); paramExprs[key] = $expressionify({ __kind__: ExpressionKind.Param, - __element__: - param.__kind__ === ExpressionKind.OptionalParam - ? param.__type__ - : param, + __element__: paramType, __cardinality__: param.__kind__ === ExpressionKind.OptionalParam ? Cardinality.AtMostOne : Cardinality.One, __name__: key, - }); + __isComplex__: isComplex, + }) as any; } const returnExpr = expr(paramExprs as any); - return $expressionify( - $queryify({ - __kind__: ExpressionKind.WithParams, - __element__: returnExpr.__element__, - __cardinality__: returnExpr.__cardinality__, - __expr__: returnExpr, - }) - ) as any; + return $expressionify({ + __kind__: ExpressionKind.WithParams, + __element__: returnExpr.__element__, + __cardinality__: returnExpr.__cardinality__, + __expr__: returnExpr, + __params__: Object.values(paramExprs), + }) as any; +} + +function jsonStringify(type: ParamType, val: any): string { + if (type.__kind__ === TypeKind.array) { + if (Array.isArray(val)) { + return `[${val + .map(item => jsonStringify(type.__element__, item)) + .join()}]`; + } + throw new Error(`Param with array type is not an array`); + } + if (type.__kind__ === TypeKind.tuple) { + if (!Array.isArray(val)) { + throw new Error(`Param with tuple type is not an array`); + } + if (val.length !== type.__items__.length) { + throw new Error( + `Param with tuple type has incorrect number of items. Got ${val.length} expected ${type.__items__.length}` + ); + } + return `[${val + .map((item, i) => jsonStringify(type.__items__[i], item)) + .join()}]`; + } + if (type.__kind__ === TypeKind.namedtuple) { + if (typeof val !== "object") { + throw new Error(`Param with named tuple type is not an object`); + } + if (Object.keys(val).length !== Object.keys(type.__shape__).length) { + throw new Error( + `Param with named tuple type has incorrect number of items. Got ${ + Object.keys(val).length + } expected ${Object.keys(type.__shape__).length}` + ); + } + return `{${Object.entries(val) + .map(([key, item]) => { + if (!type.__shape__[key]) { + throw new Error( + `Unexpected key in named tuple param: ${key}, expected keys: ${Object.keys( + type.__shape__ + ).join()}` + ); + } + return `"${key}": ${jsonStringify(type.__shape__[key], item)}`; + }) + .join()}}`; + } + if ( + type.__kind__ === TypeKind.scalar + // || type.__kind__ === TypeKind.castonlyscalar + ) { + switch (type.__name__) { + case "std::bigint": + return val.toString(); + case "std::json": + return val; + case "std::bytes": + return `"${val.toString("base64")}"`; + case "cfg::memory": + return `"${val.toString()}"`; + default: + return JSON.stringify(val); + } + } + throw new Error(`Invalid param type: ${(type as any).__kind__}`); +} + +export function jsonifyComplexParams(expr: any, _args: any) { + if (_args && expr.__kind__ === ExpressionKind.WithParams) { + const args = {..._args}; + for (const param of (expr as $expr_WithParams).__params__) { + if (param.__isComplex__) { + args[param.__name__] = jsonStringify( + param.__element__ as any, + args[param.__name__] + ); + } + } + + return args; + } + return _args; } diff --git a/src/syntax/path.ts b/src/syntax/path.ts index 2af3197d0..dc2e056fd 100644 --- a/src/syntax/path.ts +++ b/src/syntax/path.ts @@ -16,17 +16,20 @@ import { $pathify, ExpressionRoot, } from "../reflection/path"; - +import {$arrayLikeIndexify, $tuplePathify} from "./collections"; +import {literalToTypeSet} from "@generated/castMaps"; import {$toEdgeQL} from "./toEdgeQL"; +import {$queryFunc} from "./query"; -function _$expr_PathLeaf< +function PathLeaf< Root extends TypeSet, Parent extends PathParent, Exclusive extends boolean = boolean >( root: Root, parent: Parent, - exclusive: Exclusive + exclusive: Exclusive, + scopeRoot: TypeSet | null = null ): $expr_PathLeaf { return $expressionify({ __kind__: ExpressionKind.PathLeaf, @@ -34,29 +37,61 @@ function _$expr_PathLeaf< __cardinality__: root.__cardinality__, __parent__: parent, __exclusive__: exclusive, + __scopeRoot__: scopeRoot, }) as any; } -function _$expr_PathNode< +function PathNode< Root extends ObjectTypeSet, Parent extends PathParent | null, Exclusive extends boolean = boolean >( root: Root, parent: Parent, - exclusive: Exclusive + exclusive: Exclusive, + scopeRoot: TypeSet | null = null ): $expr_PathNode { - const pathNode = $expressionify({ + return $expressionify({ __kind__: ExpressionKind.PathNode, __element__: root.__element__, __cardinality__: root.__cardinality__, __parent__: parent, __exclusive__: exclusive, - }); - return pathNode as any; + __scopeRoot__: scopeRoot, + }) as any; } -const pathCache = Symbol(); +const _pathCache = Symbol(); +const _pointers = Symbol(); + +const pathifyProxyHandlers: ProxyHandler = { + get(target: any, prop: string | symbol, proxy: any) { + const ptr = target[_pointers][prop as any] as LinkDesc | PropertyDesc; + if (ptr) { + return ( + target[_pathCache][prop] ?? + (target[_pathCache][prop] = ( + (ptr.__kind__ === "property" ? PathLeaf : PathNode) as any + )( + { + __element__: ptr.target, + __cardinality__: cardinalityUtil.multiplyCardinalities( + target.__cardinality__, + ptr.cardinality + ), + }, + { + linkName: prop, + type: proxy, + }, + ptr.exclusive ?? false, + target.__scopeRoot__ ?? (scopeRoots.has(proxy) ? proxy : null) + )) + ); + } + return target[prop]; + }, +}; function _$pathify( _root: Root @@ -67,8 +102,6 @@ function _$pathify( const root: $expr_PathNode = _root as any; - (root as any)[pathCache] = {}; - let pointers = { ...root.__element__.__pointers__, }; @@ -81,58 +114,23 @@ function _$pathify( } } - for (const [key, _ptr] of Object.entries(pointers)) { - const ptr: LinkDesc | PropertyDesc = _ptr as any; - if ((ptr as any).__kind__ === "property") { - Object.defineProperty(root, key, { - get() { - return ( - (root as any)[pathCache][key] ?? - ((root as any)[pathCache][key] = _$expr_PathLeaf( - { - __element__: ptr.target, - __cardinality__: cardinalityUtil.multiplyCardinalities( - root.__cardinality__, - ptr.cardinality - ), - }, - { - linkName: key, - type: root, - }, - ptr.exclusive ?? false - )) - ); - }, - enumerable: true, - }); - } else { - Object.defineProperty(root, key, { - get: () => { - return ( - (root as any)[pathCache][key] ?? - ((root as any)[pathCache][key] = _$expr_PathNode( - { - __element__: ptr.target, - __cardinality__: cardinalityUtil.multiplyCardinalities( - root.__cardinality__, - ptr.cardinality - ), - }, - { - linkName: key, - type: root, - }, - ptr.exclusive - )) - ); - }, - enumerable: true, - }); + for (const [key, val] of Object.entries(root.__element__.__shape__)) { + if ((val as any)?.__element__ && !pointers[key]) { + pointers[key] = { + __kind__: "property", + target: (val as any).__element__, + cardinality: (val as any).__cardinality__, + exclusive: false, + writable: false, + hasDefault: false, + }; } } - return root as any; + (root as any)[_pointers] = pointers; + (root as any)[_pathCache] = {}; + + return new Proxy(root, pathifyProxyHandlers); } function isFunc(this: any, expr: ObjectTypeSet) { @@ -161,35 +159,86 @@ function assert_single(expr: Expression) { }) as any; } +const jsonDestructureProxyHandlers: ProxyHandler = { + get(target: ExpressionRoot, prop: string | symbol, proxy: any) { + if ( + typeof prop === "string" && + prop !== "run" && + (target as any)[prop] === undefined + ) { + const parsedProp = Number.isInteger(Number(prop)) ? Number(prop) : prop; + return jsonDestructure.call(proxy, parsedProp); + } + return (target as any)[prop]; + }, +}; + +function jsonDestructure(this: ExpressionRoot, path: any) { + const pathTypeSet = literalToTypeSet(path); + return $expressionify({ + __kind__: ExpressionKind.Operator, + __element__: this.__element__, + __cardinality__: cardinalityUtil.multiplyCardinalities( + this.__cardinality__, + pathTypeSet.__cardinality__ + ), + __name__: "[]", + __opkind__: "Infix", + __args__: [this, pathTypeSet], + }) as any; +} + +export function $jsonDestructure(_expr: ExpressionRoot) { + if ( + _expr.__element__.__kind__ === TypeKind.scalar && + _expr.__element__.__name__ === "std::json" + ) { + const expr = new Proxy(_expr, jsonDestructureProxyHandlers) as any; + + expr.destructure = jsonDestructure.bind(expr); + + return expr; + } + + return _expr; +} + export function $expressionify( _expr: T ): Expression { - const expr: Expression = _expr as any; - expr.$is = isFunc.bind(expr) as any; + const expr: Expression = _$pathify( + $jsonDestructure($arrayLikeIndexify($tuplePathify(_expr))) + ) as any; + + expr.run = $queryFunc.bind(expr) as any; + expr.is = isFunc.bind(expr) as any; expr.toEdgeQL = $toEdgeQL.bind(expr); - _$pathify(expr); - expr.$assertSingle = () => assert_single(expr) as any; + expr.assert_single = () => assert_single(expr) as any; + return Object.freeze(expr) as any; } const scopedExprCache = new WeakMap(); +const scopeRoots = new WeakSet(); export function $getScopedExpr( - expr: T + expr: T, + existingScopes?: Set ): Expression { let scopedExpr = scopedExprCache.get(expr); - if (!scopedExpr) { + if (!scopedExpr || existingScopes?.has(scopedExpr)) { + const uncached = !scopedExpr; scopedExpr = $expressionify({ ...expr, __cardinality__: Cardinality.One, }); - scopedExprCache.set(expr, scopedExpr); + scopeRoots.add(scopedExpr); + if (uncached) { + scopedExprCache.set(expr, scopedExpr); + } } + existingScopes?.add(scopedExpr); return scopedExpr as any; } -export { - _$pathify as $pathify, - _$expr_PathLeaf as $expr_PathLeaf, - _$expr_PathNode as $expr_PathNode, -}; +export {_$pathify as $pathify, PathLeaf as $PathLeaf, PathNode as $PathNode}; diff --git a/src/syntax/query.ts b/src/syntax/query.ts index cf4b6a4b4..7290ffa65 100644 --- a/src/syntax/query.ts +++ b/src/syntax/query.ts @@ -1,19 +1,33 @@ import * as edgedb from "edgedb"; -import {Cardinality, ExpressionRoot} from "../reflection"; +import {Cardinality, ExpressionKind} from "../reflection"; +import {jsonifyComplexParams} from "./params"; +import {select} from "./select"; -async function queryFunc(this: any, cxn: edgedb.Executor, args: any) { +const runnableExpressionKinds = new Set([ + ExpressionKind.Select, + ExpressionKind.Update, + ExpressionKind.Insert, + ExpressionKind.InsertUnlessConflict, + ExpressionKind.Delete, + ExpressionKind.For, + ExpressionKind.With, + ExpressionKind.WithParams, +]); + +const wrappedExprCache = new WeakMap(); + +export async function $queryFunc(this: any, cxn: edgedb.Executor, args: any) { + const expr = runnableExpressionKinds.has(this.__kind__) + ? this + : wrappedExprCache.get(this) ?? + wrappedExprCache.set(this, select(this)).get(this); + const _args = jsonifyComplexParams(expr, args); if ( - this.__cardinality__ === Cardinality.One || - this.__cardinality__ === Cardinality.AtMostOne + expr.__cardinality__ === Cardinality.One || + expr.__cardinality__ === Cardinality.AtMostOne ) { - return cxn.querySingle(this.toEdgeQL(), args); + return cxn.querySingle(expr.toEdgeQL(), _args); } else { - return cxn.query(this.toEdgeQL(), args); + return cxn.query(expr.toEdgeQL(), _args); } } - -export function $queryify(expr: Expr) { - return Object.assign(expr, { - run: queryFunc.bind(expr), - }); -} diff --git a/src/syntax/select.ts b/src/syntax/select.ts index 15b416ed1..41e715150 100644 --- a/src/syntax/select.ts +++ b/src/syntax/select.ts @@ -1,26 +1,34 @@ -import type {$anyint, $bool} from "@generated/modules/std"; -import _std from "@generated/modules/std"; +import { + LocalDateTime, + LocalDate, + LocalTime, + Duration, + RelativeDuration, + ConfigMemory, +} from "edgedb"; +import type {$bool, $number} from "@generated/modules/std"; import { $expr_PolyShapeElement, $scopify, Cardinality, cardinalityUtil, + Expression, ExpressionKind, LinkDesc, + makeType, ObjectType, ObjectTypeExpression, ObjectTypePointers, ObjectTypeSet, PrimitiveTypeSet, PropertyDesc, - QueryableExpression, ScalarType, stripSet, TypeKind, TypeSet, typeutil, } from "../reflection"; -import type {$expr_Literal} from "../reflection/literal"; + import type { $expr_PathLeaf, $expr_PathNode, @@ -28,10 +36,15 @@ import type { PathParent, } from "../reflection/path"; import {anonymizeObject} from "./casting"; -import type {$expr_Operator} from "./funcops"; +import type {$expr_Operator} from "../reflection/funcops"; import {$expressionify, $getScopedExpr} from "./path"; -import {$queryify} from "./query"; -import type {$expr_Update, UpdateShape} from "./update"; +import {$getTypeByName, literal} from "./literal"; +import {spec} from "@generated/__spec__"; +import { + scalarLiterals, + literalToScalarType, + literalToTypeSet, +} from "@generated/castMaps"; export const ASC: "ASC" = "ASC"; export const DESC: "DESC" = "DESC"; @@ -53,32 +66,32 @@ export type OrderByExpression = | [OrderByExpr | OrderByObjExpr, ...(OrderByExpr | OrderByObjExpr)[]]; export type OffsetExpression = TypeSet< - $anyint, + $number, Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne >; export type SelectFilterExpression = TypeSet<$bool, Cardinality>; export type LimitOffsetExpression = TypeSet< - $anyint, + $number, Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne >; export type LimitExpression = TypeSet< - $anyint, + $number, Cardinality.Empty | Cardinality.One | Cardinality.AtMostOne >; -export type SelectModifierNames = "filter" | "order" | "offset" | "limit"; +export type SelectModifierNames = "filter" | "order_by" | "offset" | "limit"; export type SelectModifiers = { filter?: SelectFilterExpression; - order?: OrderByExpression; + order_by?: OrderByExpression; offset?: OffsetExpression | number; limit?: LimitExpression | number; }; export type NormalisedSelectModifiers = { filter?: SelectFilterExpression; - order?: OrderByObjExpr[]; + order_by?: OrderByObjExpr[]; offset?: OffsetExpression; limit?: LimitExpression; }; @@ -98,8 +111,8 @@ export type NormalisedSelectModifiers = { // type NormaliseSelectModifiers = { // filter: Mods["filter"]; -// order: Mods["order"] extends OrderByExpression -// ? NormaliseOrderByModifier +// order_by: Mods["order_by"] extends OrderByExpression +// ? NormaliseOrderByModifier // : []; // offset: Mods["offset"] extends number // ? $expr_Literal> @@ -109,28 +122,72 @@ export type NormalisedSelectModifiers = { // : Mods["offset"]; // }; -export type $expr_Select< - Set extends TypeSet = TypeSet, - Expr extends TypeSet = TypeSet, - Modifiers extends NormalisedSelectModifiers = NormalisedSelectModifiers -> = QueryableExpression< - { - __element__: Set["__element__"]; - __cardinality__: Set["__cardinality__"]; - __expr__: stripSet; // avoid infinite recursion - __kind__: ExpressionKind.Select; - __modifiers__: Modifiers; - __scope__?: ObjectTypeExpression; - } & (Set extends ObjectTypeSet ? SelectObjectMethods : {}) ->; - -interface SelectObjectMethods { - __element__: Root["__element__"]; - __cardinality__: Root["__cardinality__"]; - update(shape: UpdateShape): $expr_Update>; - delete(): $expr_Delete; +export type $expr_Select = Expression<{ + __element__: Set["__element__"]; + __cardinality__: Set["__cardinality__"]; + __expr__: TypeSet; + __kind__: ExpressionKind.Select; + __modifiers__: NormalisedSelectModifiers; + __scope__?: ObjectTypeExpression; +}>; +// Modifier methods removed for now, until we can fix typescript inference +// problems / excessively deep errors +// & SelectModifierMethods>; + +export interface SelectModifierMethods { + filter( + filter: + | Filter + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => Filter) + ): this; + order_by( + order_by: + | OrderByExpression + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => OrderByExpression) + ): this; + offset( + offset: + | OffsetExpression + | number + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => OffsetExpression | number) + ): this; + // $expr_Select<{ + // __element__: Root["__element__"]; + // __cardinality__: cardinalityUtil.overrideLowerBound< + // Root["__cardinality__"], + // "Zero" + // >; + // }>; + limit( + limit: + | LimitExpression + | number + | (( + scope: Root extends ObjectTypeSet + ? $scopify + : stripSet + ) => LimitExpression | number) + ): this; + // $expr_Select<{ + // __element__: Root["__element__"]; + // __cardinality__: cardinalityUtil.overrideLowerBound< + // Root["__cardinality__"], + // "Zero" + // >; + // }>; } - // Base is ObjectTypeSet & // Filter is equality & // Filter.args[0] is PathLeaf @@ -146,7 +203,7 @@ interface SelectObjectMethods { // Filter.args[0].type.__element__ === Base.__element__ & // Filter.args[1].__cardinality__ is AtMostOne or One -export type argCardToResultCard< +type argCardToResultCard< OpCard extends Cardinality, BaseCase extends Cardinality > = [OpCard] extends [Cardinality.AtMostOne | Cardinality.One] @@ -162,7 +219,7 @@ export type InferFilterCardinality< ? // Base is ObjectTypeExpression & Base extends ObjectTypeSet // $expr_PathNode ? // Filter is equality - Filter extends $expr_Operator<"std::=", any, infer Args, any> + Filter extends $expr_Operator<"=", any, infer Args, any> ? // Filter.args[0] is PathLeaf Args[0] extends $expr_PathLeaf ? // Filter.args[0] is unique @@ -213,46 +270,36 @@ export type InferFilterCardinality< : Base["__cardinality__"] : Base["__cardinality__"]; -type InferLimitCardinality< +export type InferOffsetLimitCardinality< Card extends Cardinality, - Limit extends LimitExpression | number | undefined -> = Limit extends number - ? Limit extends 0 - ? Cardinality.Empty - : Limit extends 1 - ? Cardinality.AtMostOne - : Card - : Limit extends LimitExpression - ? Limit["__element__"]["__tsconsttype__"] extends 0 - ? Cardinality.Empty - : Limit["__element__"]["__tsconsttype__"] extends 1 - ? Cardinality.AtMostOne - : Card + Modifers extends SelectModifiers +> = Modifers["limit"] extends number | LimitExpression + ? cardinalityUtil.overrideLowerBound + : Modifers["offset"] extends number | OffsetExpression + ? cardinalityUtil.overrideLowerBound : Card; -type ComputeSelectCardinality< +export type ComputeSelectCardinality< Expr extends ObjectTypeExpression, Modifiers extends SelectModifiers -> = InferLimitCardinality< +> = InferOffsetLimitCardinality< InferFilterCardinality, - Modifiers["limit"] + Modifiers >; export function is< Expr extends ObjectTypeExpression, - Shape extends pointersToSelectShape, - NormalisedShape = normaliseShape + Shape extends pointersToSelectShape >( expr: Expr, shape: Shape ): { - [k in keyof NormalisedShape]: $expr_PolyShapeElement< + [k in Exclude]: $expr_PolyShapeElement< Expr, - NormalisedShape[k] + normaliseElement >; } { const mappedShape: any = {}; - // const {shape: resolvedShape, scope} = resolveShape(shape, expr); for (const [key, value] of Object.entries(shape)) { mappedShape[key] = { __kind__: ExpressionKind.PolyShapeElement, @@ -274,8 +321,7 @@ function computeFilterCardinality( // Base is ObjectExpression const baseIsObjectExpr = base?.__element__?.__kind__ === TypeKind.object; const filterExprIsEq = - filter.__kind__ === ExpressionKind.Operator && - filter.__name__ === "std::="; + filter.__kind__ === ExpressionKind.Operator && filter.__name__ === "="; const arg0: $expr_PathLeaf | $expr_PathNode = filter?.__args__?.[0]; const arg1: TypeSet = filter?.__args__?.[1]; const argsExist = !!arg0 && !!arg1 && !!arg1.__cardinality__; @@ -326,7 +372,7 @@ function computeFilterCardinality( return card; } -function handleModifiers( +export function $handleModifiers( modifiers: SelectModifiers, rootExpr: TypeSet ): {modifiers: NormalisedSelectModifiers; cardinality: Cardinality} { @@ -336,9 +382,11 @@ function handleModifiers( if (mods.filter && rootExpr.__element__.__kind__ === TypeKind.object) { card = computeFilterCardinality(mods.filter, card, rootExpr); } - if (mods.order) { - const orderExprs = Array.isArray(mods.order) ? mods.order : [mods.order]; - mods.order = orderExprs.map(expr => + if (mods.order_by) { + const orderExprs = Array.isArray(mods.order_by) + ? mods.order_by + : [mods.order_by]; + mods.order_by = orderExprs.map(expr => typeof (expr as any).__element__ === "undefined" ? expr : {expression: expr} @@ -346,70 +394,170 @@ function handleModifiers( } if (mods.offset) { mods.offset = - typeof mods.offset === "number" ? _std.int64(mods.offset) : mods.offset; + typeof mods.offset === "number" + ? ($getTypeByName("std::number")(mods.offset) as any) + : mods.offset; + card = cardinalityUtil.overrideLowerBound(card, "Zero"); } if (mods.limit) { let expr = mods.limit; if (typeof expr === "number") { - expr = _std.int64(expr); + expr = $getTypeByName("std::number")(expr) as any; } else if ((expr as any).__kind__ === ExpressionKind.Set) { expr = (expr as any).__exprs__[0]; } mods.limit = expr; - - if ((expr as any).__kind__ === ExpressionKind.Literal) { - const literalExpr: $expr_Literal = expr as any; - if (literalExpr.__value__ === 1) { - card = Cardinality.AtMostOne; - } else if (literalExpr.__value__ === 0) { - card = Cardinality.Empty; - } - } + card = cardinalityUtil.overrideLowerBound(card, "Zero"); } return {modifiers: mods as NormalisedSelectModifiers, cardinality: card}; } -function updateFunc(this: any, shape: any) { - return $expressionify( - $queryify({ - __kind__: ExpressionKind.Update, - __element__: this.__element__, - __cardinality__: this.__cardinality__, - __expr__: this, - __shape__: shape, - }) - ) as $expr_Update; -} - export type $expr_Delete = - QueryableExpression<{ + Expression<{ __kind__: ExpressionKind.Delete; __element__: Root["__element__"]; __cardinality__: Root["__cardinality__"]; __expr__: Root; }>; -function deleteFunc(this: any) { - return $expressionify( - $queryify({ - __kind__: ExpressionKind.Delete, - __element__: this.__element__, - __cardinality__: this.__cardinality__, - __expr__: this, - }) - ) as $expr_Delete; +function deleteExpr< + Expr extends ObjectTypeExpression, + Modifiers extends SelectModifiers +>( + expr: Expr, + modifiers?: (scope: $scopify) => Readonly +): $expr_Delete<{ + __element__: ObjectType< + Expr["__element__"]["__name__"], + Expr["__element__"]["__pointers__"], + {id: true} + >; + __cardinality__: ComputeSelectCardinality; +}>; +function deleteExpr(expr: any, modifiersGetter: any) { + const selectExpr = select(expr, modifiersGetter); + + return $expressionify({ + __kind__: ExpressionKind.Delete, + __element__: selectExpr.__element__, + __cardinality__: selectExpr.__cardinality__, + __expr__: selectExpr, + }) as any; } +export {deleteExpr as delete}; + +// Modifier methods removed for now, until we can fix typescript inference +// problems / excessively deep errors + +// function resolveModifierGetter(parent: any, modGetter: any) { +// if (typeof modGetter === "function" && !modGetter.__kind__) { +// if (parent.__expr__.__element__.__kind__ === TypeKind.object) { +// const shape = parent.__element__.__shape__; +// const _scope = +// parent.__scope__ ?? $getScopedExpr(parent.__expr__, +// $existingScopes); +// const scope = new Proxy(_scope, { +// get(target: any, prop: string) { +// if (shape[prop] && shape[prop] !== true) { +// return shape[prop]; +// } +// return target[prop]; +// }, +// }); +// return { +// scope: _scope, +// modExpr: modGetter(scope), +// }; +// } else { +// return { +// scope: undefined, +// modExpr: modGetter(parent.__expr__), +// }; +// } +// } else { +// return {scope: parent.__scope__, modExpr: modGetter}; +// } +// } + +// function updateModifier( +// parent: any, +// modName: "filter" | "order_by" | "offset" | "limit", +// modGetter: any +// ) { +// const modifiers = { +// ...parent.__modifiers__, +// }; +// const cardinality = parent.__cardinality__; + +// const {modExpr, scope} = resolveModifierGetter(parent, modGetter); + +// switch (modName) { +// case "filter": +// modifiers.filter = modifiers.filter +// ? op(modifiers.filter, "and", modExpr) +// : modExpr; + +// // methods no longer change cardinality +// // cardinality = computeFilterCardinality( +// // modExpr, +// // cardinality, +// // parent.__expr__ +// // ); +// break; +// case "order_by": +// const ordering = +// typeof (modExpr as any).__element__ === "undefined" +// ? modExpr +// : {expression: modExpr}; +// modifiers.order_by = modifiers.order_by +// ? [...modifiers.order_by, ordering] +// : [ordering]; +// break; +// case "offset": +// modifiers.offset = +// typeof modExpr === "number" ? _std.number(modExpr) : modExpr; +// // methods no longer change cardinality +// // cardinality = cardinalityUtil +// .overrideLowerBound(cardinality, "Zero"); +// break; +// case "limit": +// modifiers.limit = +// typeof modExpr === "number" +// ? _std.number(modExpr) +// : (modExpr as any).__kind__ === ExpressionKind.Set +// ? (modExpr as any).__exprs__[0] +// : modExpr; +// // methods no longer change cardinality +// // cardinality = cardinalityUtil +// .overrideLowerBound(cardinality, "Zero"); +// break; +// } + +// return $expressionify( +// $selectify({ +// __kind__: ExpressionKind.Select, +// __element__: parent.__element__, +// __cardinality__: cardinality, +// __expr__: parent.__expr__, +// __modifiers__: modifiers, +// __scope__: scope, +// }) +// ); +// } + export function $selectify(expr: Expr) { - Object.assign(expr, { - update: updateFunc.bind(expr), - delete: deleteFunc.bind(expr), - }); - return $queryify(expr); + // Object.assign(expr, { + // filter: (filter: any) => updateModifier(expr, "filter", filter), + // order_by: (order_by: any) => updateModifier(expr, "order_by", order_by), + // offset: (offset: any) => updateModifier(expr, "offset", offset), + // limit: (limit: any) => updateModifier(expr, "limit", limit), + // }); + return expr; } -type linkDescToLinkProps = { +export type linkDescToLinkProps = { [k in keyof Desc["properties"] & string]: $expr_PathLeaf< TypeSet< Desc["properties"][k]["target"], @@ -441,56 +589,60 @@ export type pointersToSelectShape< anonymizeObject, cardinalityUtil.assignable > - | ((pointersToSelectShape & - pointersToSelectShape) & + | (pointersToSelectShape & + pointersToSelectShape & SelectModifiers) - | ((( + | (( scope: $scopify & linkDescToLinkProps ) => pointersToSelectShape & - pointersToSelectShape) & + pointersToSelectShape & SelectModifiers) : any; -}>; +}> & {[k: string]: unknown}; + +export type normaliseElement = El extends boolean + ? El + : El extends TypeSet + ? stripSet + : El extends (...scope: any[]) => any + ? normaliseShape> + : El extends object + ? normaliseShape> + : stripSet; + +export type normaliseShape = { + [k in Exclude]: normaliseElement; +}; -type normaliseShape< - Shape extends pointersToSelectShape, - Pointers extends ObjectTypePointers -> = { - [k in keyof Shape]: Shape[k] extends boolean - ? stripSet - : Shape[k] extends TypeSet - ? stripSet - : [k] extends [keyof Pointers] - ? Pointers[k] extends LinkDesc - ? Omit< - normaliseShape< - Shape[k] extends (...scope: any[]) => any - ? ReturnType - : Shape[k], - Pointers[k]["target"]["__pointers__"] - >, - SelectModifierNames - > - : stripSet - : stripSet; +const $FreeObject = makeType( + spec, + [...spec.values()].find(s => s.name === "std::FreeObject")!.id, + literal +); +const FreeObject = { + __kind__: ExpressionKind.PathNode, + __element__: $FreeObject, + __cardinality__: Cardinality.One, + __parent__: null, + __exclusive__: true, + __scopeRoot__: null, }; +export const $existingScopes = new Set(); + export function select( expr: Expr -): $expr_Select< - { - __element__: ObjectType< - `${Expr["__element__"]["__name__"]}`, // _shape - Expr["__element__"]["__pointers__"], - {id: true} - >; - __cardinality__: Expr["__cardinality__"]; - }, - Expr ->; +): $expr_Select<{ + __element__: ObjectType< + `${Expr["__element__"]["__name__"]}`, // _shape + Expr["__element__"]["__pointers__"], + {id: true} + >; + __cardinality__: Expr["__cardinality__"]; +}>; export function select( expr: Expr -): $expr_Select, Expr>; +): $expr_Select>; export function select< Expr extends ObjectTypeExpression, Shape extends pointersToSelectShape & @@ -499,63 +651,79 @@ export function select< >( expr: Expr, shape: (scope: $scopify) => Readonly -): $expr_Select< - { - __element__: ObjectType< - `${Expr["__element__"]["__name__"]}`, // _shape - Expr["__element__"]["__pointers__"], - Omit< - normaliseShape, - SelectModifierNames - > - >; - __cardinality__: ComputeSelectCardinality; - }, - Expr ->; -export function select( - expr: Expr, - shape: (scope: $scopify) => Set -): $expr_Select< - { - __element__: Set["__element__"]; - __cardinality__: cardinalityUtil.multiplyCardinalities< - Expr["__cardinality__"], - Set["__cardinality__"] - >; - }, - Expr ->; +): $expr_Select<{ + __element__: ObjectType< + `${Expr["__element__"]["__name__"]}`, // _shape + Expr["__element__"]["__pointers__"], + Omit, SelectModifierNames> + >; + __cardinality__: ComputeSelectCardinality; +}>; +/* + +For the moment is isn't possible to implement both closure-based and plain +object overloads without breaking autocomplete on one or the other. +This is due to a limitation in TS: + +https://github.com/microsoft/TypeScript/issues/26892 +https://github.com/microsoft/TypeScript/issues/47081 + +*/ export function select< Expr extends PrimitiveTypeSet, Modifiers extends SelectModifiers >( expr: Expr, modifiers: (expr: Expr) => Readonly -): $expr_Select< - { - __element__: Expr["__element__"]; - __cardinality__: InferLimitCardinality< - Expr["__cardinality__"], - Modifiers["limit"] - >; - }, - Expr ->; +): $expr_Select<{ + __element__: Expr["__element__"]; + __cardinality__: InferOffsetLimitCardinality< + Expr["__cardinality__"], + Modifiers + >; +}>; export function select( shape: Shape -): $expr_Select< - { - __element__: ObjectType<`std::FreeObject`, {}, Shape>; // _shape - __cardinality__: Cardinality.One; - }, - typeof _std.FreeObject ->; +): $expr_Select<{ + __element__: ObjectType<`std::FreeObject`, {}, Shape>; // _shape + __cardinality__: Cardinality.One; +}>; +export function select( + expr: Expr +): $expr_Select<{ + __element__: literalToScalarType; + __cardinality__: Cardinality.One; +}>; export function select(...args: any[]) { + const firstArg = args[0]; + + if ( + typeof firstArg !== "object" || + firstArg instanceof Buffer || + firstArg instanceof Date || + firstArg instanceof Duration || + firstArg instanceof LocalDateTime || + firstArg instanceof LocalDate || + firstArg instanceof LocalTime || + firstArg instanceof RelativeDuration || + firstArg instanceof ConfigMemory + ) { + const literalExpr = literalToTypeSet(firstArg); + return $expressionify( + $selectify({ + __kind__: ExpressionKind.Select, + __element__: literalExpr.__element__, + __cardinality__: literalExpr.__cardinality__, + __expr__: literalExpr, + __modifiers__: {}, + }) + ) as any; + } + const [expr, shapeGetter]: [TypeSet, (scope: any) => any] = typeof args[0].__element__ !== "undefined" ? (args as any) - : [_std.FreeObject, () => args[0]]; + : [FreeObject, () => args[0]]; if (!shapeGetter) { if (expr.__element__.__kind__ === TypeKind.object) { @@ -573,44 +741,29 @@ export function select(...args: any[]) { __expr__: objectExpr, __modifiers__: {}, }) - ); + ) as any; } else { return $expressionify( - $queryify({ + $selectify({ __kind__: ExpressionKind.Select, __element__: expr.__element__, __cardinality__: expr.__cardinality__, __expr__: expr, __modifiers__: {}, }) - ); + ) as any; } } - const { - modifiers: mods, - shape, - scope, - expr: selectExpr, - } = resolveShape(shapeGetter, expr); + const cleanScopedExprs = $existingScopes.size === 0; - if (selectExpr) { - return $expressionify( - $queryify({ - __kind__: ExpressionKind.Select, - __element__: selectExpr.__element__, - __cardinality__: cardinalityUtil.multiplyCardinalities( - selectExpr.__cardinality__, - expr.__cardinality__ - ), - __expr__: selectExpr, - __modifiers__: {}, - __scope__: scope, - }) - ); + const {modifiers: mods, shape, scope} = resolveShape(shapeGetter, expr); + + if (cleanScopedExprs) { + $existingScopes.clear(); } - const {modifiers, cardinality} = handleModifiers(mods, expr); + const {modifiers, cardinality} = $handleModifiers(mods, expr); return $expressionify( $selectify({ __kind__: ExpressionKind.Select, @@ -627,34 +780,32 @@ export function select(...args: any[]) { __expr__: expr, __modifiers__: modifiers, __scope__: - expr !== scope && expr !== _std.FreeObject ? scope : undefined, + expr !== scope && expr.__element__.__name__ !== "std::FreeObject" + ? scope + : undefined, }) - ); + ) as any; } function resolveShape( shapeGetter: ((scope: any) => any) | any, expr: TypeSet -): {modifiers: any; shape: any; scope: TypeSet; expr?: TypeSet} { +): {modifiers: any; shape: any; scope: TypeSet} { const modifiers: any = {}; const shape: any = {}; const scope = expr.__element__.__kind__ === TypeKind.object - ? $getScopedExpr(expr as any) + ? $getScopedExpr(expr as any, $existingScopes) : expr; const selectShape = typeof shapeGetter === "function" ? shapeGetter(scope) : shapeGetter; - if (typeof selectShape.__kind__ !== "undefined") { - return {expr: selectShape, shape, modifiers, scope}; - } - for (const [key, value] of Object.entries(selectShape)) { if ( key === "filter" || - key === "order" || + key === "order_by" || key === "offset" || key === "limit" ) { @@ -663,7 +814,7 @@ function resolveShape( if (scope === expr) { throw new Error( `Invalid select shape key '${key}' on scalar expression, ` + - `only modifiers are allowed (filter, order, offset and limit)` + `only modifiers are allowed (filter, order_by, offset and limit)` ); } shape[key] = resolveShapeElement(key, value, scope); @@ -690,7 +841,7 @@ function resolveShapeElement( modifiers: mods, } = resolveShape(value as any, childExpr); - const {modifiers} = handleModifiers(mods, childExpr); + const {modifiers} = $handleModifiers(mods, childExpr); return { __kind__: ExpressionKind.Select, @@ -707,7 +858,7 @@ function resolveShapeElement( }; } else if ((value as any)?.__kind__ === ExpressionKind.PolyShapeElement) { const polyElement = value as $expr_PolyShapeElement; - const polyScope = (scope as any).$is(polyElement.__polyType__); + const polyScope = (scope as any).is(polyElement.__polyType__); return { __kind__: ExpressionKind.PolyShapeElement, __polyType__: polyScope, diff --git a/src/syntax/syntax.ts b/src/syntax/syntax.ts index 88948dd60..59f3c55f6 100644 --- a/src/syntax/syntax.ts +++ b/src/syntax/syntax.ts @@ -5,6 +5,7 @@ export * from "./path"; export * from "./set"; export * from "./cast"; export * from "./select"; +export * from "./update"; export * from "./insert"; export * from "./collections"; export * from "./funcops"; diff --git a/src/syntax/toEdgeQL.ts b/src/syntax/toEdgeQL.ts index 4ee16062e..df1c5ecf9 100644 --- a/src/syntax/toEdgeQL.ts +++ b/src/syntax/toEdgeQL.ts @@ -9,6 +9,7 @@ import { $expr_Array, $expr_NamedTuple, $expr_Tuple, + $expr_TuplePath, BaseType, Cardinality, ExpressionKind, @@ -27,11 +28,11 @@ import type { $expr_PathNode, $expr_TypeIntersection, } from "../reflection/path"; -import reservedKeywords from "../reflection/reservedKeywords"; +import {reservedKeywords} from "../reflection/reservedKeywords"; import type {$expr_Cast} from "./cast"; import type {$expr_Detached} from "./detached"; import type {$expr_For, $expr_ForVar} from "./for"; -import type {$expr_Function, $expr_Operator} from "./funcops"; +import type {$expr_Function, $expr_Operator} from "../reflection/funcops"; import type {$expr_Insert, $expr_InsertUnlessConflict} from "./insert"; import type {$expr_Param, $expr_WithParams} from "./params"; import type { @@ -52,6 +53,7 @@ export type SomeExpression = | $expr_Array | $expr_Tuple | $expr_NamedTuple + | $expr_TuplePath | $expr_Cast | $expr_Select | $expr_Delete @@ -76,6 +78,17 @@ type WithScopeExpr = | $expr_InsertUnlessConflict | $expr_For; +const topLevelExprKinds = new Set([ + ExpressionKind.Delete, + ExpressionKind.For, + ExpressionKind.Insert, + ExpressionKind.InsertUnlessConflict, + ExpressionKind.Select, + ExpressionKind.Update, + ExpressionKind.With, + ExpressionKind.WithParams, +]); + function shapeToEdgeQL( shape: object | null, ctx: RenderCtx, @@ -103,13 +116,14 @@ function shapeToEdgeQL( let operator = ":="; let polyType: SomeExpression | null = null; - if (!!val["+="]) { - operator = "+="; - val = val["+="]; - } - if (!!val["-="]) { - operator = "-="; - val = val["-="]; + if (typeof val === "object" && !val.__element__) { + if (!!val["+="]) { + operator = "+="; + val = val["+="]; + } else if (!!val["-="]) { + operator = "-="; + val = val["-="]; + } } if (val.__kind__ === ExpressionKind.PolyShapeElement) { polyType = val.__polyType__; @@ -221,16 +235,19 @@ export function $toEdgeQL(this: any) { if ( withVars.has(expr) || - expr.__kind__ === ExpressionKind.PathLeaf || - expr.__kind__ === ExpressionKind.PathNode || + ((expr.__kind__ === ExpressionKind.PathLeaf || + expr.__kind__ === ExpressionKind.PathNode || + expr.__kind__ === ExpressionKind.TypeIntersection) && + !refData.boundScope) || expr.__kind__ === ExpressionKind.ForVar || - expr.__kind__ === ExpressionKind.TypeIntersection + expr.__kind__ === ExpressionKind.Param ) { continue; } if ( - expr.__kind__ === ExpressionKind.Select && + (expr.__kind__ === ExpressionKind.Select || + expr.__kind__ === ExpressionKind.Update) && expr.__scope__ && !withVars.has(expr.__scope__ as any) ) { @@ -445,7 +462,8 @@ function renderEdgeQL( let withBlock = ""; const scopeExpr = - expr.__kind__ === ExpressionKind.Select && + (expr.__kind__ === ExpressionKind.Select || + expr.__kind__ === ExpressionKind.Update) && ctx.withVars.has(expr.__scope__ as any) ? (expr.__scope__ as SomeExpression) : undefined; @@ -503,11 +521,21 @@ function renderEdgeQL( ].join(",\n")}\n`; } - if ( - expr.__kind__ === ExpressionKind.With || - expr.__kind__ === ExpressionKind.WithParams - ) { + // console.log(expr.__kind__); + if (expr.__kind__ === ExpressionKind.With) { return renderEdgeQL(expr.__expr__, ctx); + } else if (expr.__kind__ === ExpressionKind.WithParams) { + return `WITH\n${expr.__params__ + .map(param => { + const optional = + param.__cardinality__ === Cardinality.AtMostOne ? "OPTIONAL " : ""; + return ` __param__${param.__name__} := ${ + param.__isComplex__ + ? `<${param.__element__.__name__}><${optional}json>` + : `<${optional}${param.__element__.__name__}>` + }$${param.__name__}`; + }) + .join(",\n")}\nSELECT (${renderEdgeQL(expr.__expr__, ctx)})`; } else if (expr.__kind__ === ExpressionKind.Alias) { const aliasedExprVar = ctx.withVars.get(expr.__expr__ as any); if (!aliasedExprVar) { @@ -531,12 +559,18 @@ function renderEdgeQL( const linkName = isScopedLinkProp ? `__linkprop_${expr.__parent__.linkName.slice(1)}` : expr.__parent__.linkName; - return `${renderEdgeQL( + const parent = renderEdgeQL( expr.__parent__.type, ctx, false, noImplicitDetached - )}${linkName.startsWith("@") ? "" : "."}${q(linkName)}`.trim(); + ); + return `${ + (expr.__parent__.type as any).__kind__ !== ExpressionKind.PathNode && + !(ctx.withVars.has(expr) && ctx.renderWithVar !== expr) + ? `(${parent})` + : parent + }${linkName.startsWith("@") ? "" : "."}${q(linkName)}`.trim(); } } else if (expr.__kind__ === ExpressionKind.Literal) { return literalToEdgeQL(expr.__element__, expr.__value__); @@ -548,7 +582,14 @@ function renderEdgeQL( exprs.every(ex => ex.__element__.__kind__ !== TypeKind.object) ) { if (exprs.length === 0) return `<${expr.__element__.__name__}>{}`; - return `{ ${exprs.map(ex => renderEdgeQL(ex, ctx)).join(", ")} }`; + return `{ ${exprs + .map(ex => { + const renderedExpr = renderEdgeQL(ex, ctx); + return topLevelExprKinds.has((ex as SomeExpression).__kind__) + ? `(${renderedExpr})` + : renderedExpr; + }) + .join(", ")} }`; } else { throw new Error( `Invalid arguments to set constructor: ${exprs @@ -557,22 +598,24 @@ function renderEdgeQL( ); } } else if (expr.__kind__ === ExpressionKind.Array) { - // ExpressionKind.Array - return `[\n${expr.__items__ - .map(item => ` ` + renderEdgeQL(item, ctx)) - .join(",\n")}\n]`; + return `[${expr.__items__ + .map(item => renderEdgeQL(item, ctx)) + .join(", ")}]`; } else if (expr.__kind__ === ExpressionKind.Tuple) { - // ExpressionKind.Tuple return `(\n${expr.__items__ .map(item => ` ` + renderEdgeQL(item, ctx)) .join(",\n")}${expr.__items__.length === 1 ? "," : ""}\n)`; } else if (expr.__kind__ === ExpressionKind.NamedTuple) { - // ExpressionKind.NamedTuple return `(\n${Object.keys(expr.__shape__) .map(key => ` ${key} := ${renderEdgeQL(expr.__shape__[key], ctx)}`) .join(",\n")}\n)`; + } else if (expr.__kind__ === ExpressionKind.TuplePath) { + return `${renderEdgeQL(expr.__parent__, ctx)}.${expr.__index__}`; } else if (expr.__kind__ === ExpressionKind.Cast) { - return `<${expr.__element__.__name__}>${renderEdgeQL(expr.__expr__, ctx)}`; + if (expr.__expr__ === null) { + return `<${expr.__element__.__name__}>{}`; + } + return `<${expr.__element__.__name__}>(${renderEdgeQL(expr.__expr__, ctx)})`; } else if (expr.__kind__ === ExpressionKind.Select) { const lines = []; if (isObjectType(expr.__element__)) { @@ -595,7 +638,7 @@ function renderEdgeQL( // non-object/non-shape select expression const needsScalarVar = (expr.__modifiers__.filter || - expr.__modifiers__.order || + expr.__modifiers__.order_by || expr.__modifiers__.offset || expr.__modifiers__.limit) && !ctx.withVars.has(expr.__expr__ as any); @@ -622,9 +665,9 @@ function renderEdgeQL( if (expr.__modifiers__.filter) { modifiers.push(`FILTER ${renderEdgeQL(expr.__modifiers__.filter, ctx)}`); } - if (expr.__modifiers__.order) { + if (expr.__modifiers__.order_by) { modifiers.push( - ...expr.__modifiers__.order.map( + ...expr.__modifiers__.order_by.map( ({expression, direction, empty}, i) => { return `${i === 0 ? "ORDER BY" : " THEN"} ${renderEdgeQL( expression, @@ -657,10 +700,14 @@ function renderEdgeQL( (modifiers.length ? "\n" + modifiers.join("\n") : "") ); } else if (expr.__kind__ === ExpressionKind.Update) { - return `UPDATE (${renderEdgeQL(expr.__expr__, ctx)}) SET ${shapeToEdgeQL( - expr.__shape__, - ctx - )}`; + return ( + withBlock + + `UPDATE ${renderEdgeQL(expr.__scope__, ctx, false)}${ + expr.__modifiers__.filter + ? `\nFILTER ${renderEdgeQL(expr.__modifiers__.filter, ctx)}\n` + : " " + }SET ${shapeToEdgeQL(expr.__shape__, ctx)}` + ); } else if (expr.__kind__ === ExpressionKind.Delete) { return `DELETE (${renderEdgeQL(expr.__expr__, ctx)})`; } else if (expr.__kind__ === ExpressionKind.Insert) { @@ -697,15 +744,26 @@ function renderEdgeQL( } return `${expr.__name__}(${args.join(", ")})`; } else if (expr.__kind__ === ExpressionKind.Operator) { - const operator = expr.__name__.split("::")[1]; + const operator = expr.__name__; const args = expr.__args__; switch (expr.__opkind__) { case OperatorKind.Infix: if (operator === "[]") { - const val = (args[1] as any).__value__; - return `(${renderEdgeQL(args[0], ctx)}[${ - Array.isArray(val) ? val.join(":") : val - }])`; + let index = ""; + if (Array.isArray(args[1])) { + const [start, end] = args[1]; + if (start) { + index += renderEdgeQL(start, ctx); + } + index += ":"; + if (end) { + index += renderEdgeQL(end, ctx); + } + } else { + index = renderEdgeQL(args[1], ctx); + } + + return `(${renderEdgeQL(args[0], ctx)})[${index}]`; } return `(${renderEdgeQL(args[0], ctx)} ${operator} ${renderEdgeQL( args[1], @@ -716,7 +774,7 @@ function renderEdgeQL( case OperatorKind.Prefix: return `(${operator} ${renderEdgeQL(args[0], ctx)})`; case OperatorKind.Ternary: - if (operator === "IF") { + if (operator === "if_else") { return `(${renderEdgeQL(args[0], ctx)} IF ${renderEdgeQL( args[1], ctx @@ -751,11 +809,17 @@ UNION (\n${indent(renderEdgeQL(expr.__expr__, ctx), 2)}\n)` } return forVar; } else if (expr.__kind__ === ExpressionKind.Param) { - return `<${ - expr.__cardinality__ === Cardinality.AtMostOne ? "OPTIONAL " : "" - }${expr.__element__.__name__}>$${expr.__name__}`; + return `__param__${expr.__name__}`; } else if (expr.__kind__ === ExpressionKind.Detached) { - return `DETACHED ${renderEdgeQL(expr.__expr__, ctx)}`; + return `DETACHED ${renderEdgeQL( + expr.__expr__, + { + ...ctx, + renderWithVar: expr.__expr__ as any, + }, + undefined, + true + )}`; } else { util.assertNever( expr, @@ -850,6 +914,7 @@ function walkExprTree( } break; case ExpressionKind.Cast: + if (expr.__expr__ === null) break; childExprs.push(...walkExprTree(expr.__expr__, parentScope, ctx)); break; case ExpressionKind.Set: @@ -872,13 +937,17 @@ function walkExprTree( childExprs.push(...walkExprTree(subExpr, parentScope, ctx)); } break; - case ExpressionKind.Select: { + case ExpressionKind.TuplePath: + childExprs.push(...walkExprTree(expr.__parent__, parentScope, ctx)); + break; + case ExpressionKind.Select: + case ExpressionKind.Update: { const modifiers = expr.__modifiers__; if (modifiers.filter) { childExprs.push(...walkExprTree(modifiers.filter, expr, ctx)); } - if (modifiers.order) { - for (const orderExpr of modifiers.order) { + if (modifiers.order_by) { + for (const orderExpr of modifiers.order_by) { childExprs.push(...walkExprTree(orderExpr.expression, expr, ctx)); } } @@ -889,36 +958,36 @@ function walkExprTree( childExprs.push(...walkExprTree(modifiers.limit!, expr, ctx)); } - if (isObjectType(expr.__element__)) { - const walkShape = (shape: object) => { - for (let param of Object.values(shape)) { - if (param.__kind__ === ExpressionKind.PolyShapeElement) { - param = param.__shapeElement__; - } - if (typeof param === "object") { - if (!!(param as any).__kind__) { - childExprs.push(...walkExprTree(param as any, expr, ctx)); - } else { - walkShape(param); + if (expr.__kind__ === ExpressionKind.Select) { + if (isObjectType(expr.__element__)) { + const walkShape = (shape: object) => { + for (let param of Object.values(shape)) { + if (param.__kind__ === ExpressionKind.PolyShapeElement) { + param = param.__shapeElement__; + } + if (typeof param === "object") { + if (!!(param as any).__kind__) { + childExprs.push(...walkExprTree(param as any, expr, ctx)); + } else { + walkShape(param); + } } } + }; + walkShape(expr.__element__.__shape__ ?? {}); + } + } else { + // Update + const shape: any = expr.__shape__ ?? {}; + + for (const _element of Object.values(shape)) { + let element: any = _element; + if (!element.__element__) { + if (element["+="]) element = element["+="]; + else if (element["-="]) element = element["-="]; } - }; - walkShape(expr.__element__.__shape__ ?? {}); - } - - childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); - break; - } - - case ExpressionKind.Update: { - const shape: any = expr.__shape__ ?? {}; - - for (const _element of Object.values(shape)) { - let element: any = _element; - if (element["+="]) element = element["+="]; - if (element["-="]) element = element["-="]; - childExprs.push(...walkExprTree(element as any, expr, ctx)); + childExprs.push(...walkExprTree(element as any, expr, ctx)); + } } childExprs.push(...walkExprTree(expr.__expr__, expr, ctx)); @@ -955,7 +1024,13 @@ function walkExprTree( case ExpressionKind.Operator: case ExpressionKind.Function: for (const subExpr of expr.__args__) { - childExprs.push(...walkExprTree(subExpr!, parentScope, ctx)); + if (Array.isArray(subExpr)) { + for (const arg of subExpr) { + if (arg) childExprs.push(...walkExprTree(arg, parentScope, ctx)); + } + } else { + childExprs.push(...walkExprTree(subExpr!, parentScope, ctx)); + } } if (expr.__kind__ === ExpressionKind.Function) { for (const subExpr of Object.values(expr.__namedargs__)) { @@ -994,21 +1069,36 @@ function walkExprTree( } } +const numericalTypes: Record = { + "std::number": true, + "std::int16": true, + "std::int32": true, + "std::int64": true, + "std::float32": true, + "std::float64": true, +}; + function literalToEdgeQL(type: BaseType, val: any): string { let skipCast = false; let stringRep; if (typeof val === "string") { - if (type.__name__ === "std::str") { + if (numericalTypes[type.__name__]) { + skipCast = true; + stringRep = val; + } else if (type.__name__ === "std::json") { skipCast = true; + stringRep = `to_json(${JSON.stringify(val)})`; + } else { + if (type.__name__ === "std::str") { + skipCast = true; + } + stringRep = JSON.stringify(val); } - stringRep = JSON.stringify(val); } else if (typeof val === "number") { - const isInt = Number.isInteger(val); - if ( - (type.__name__ === "std::int64" && isInt) || - (type.__name__ === "std::float64" && !isInt) - ) { + if (numericalTypes[type.__name__]) { skipCast = true; + } else { + throw new Error(`Unknown numerical type: ${type.__name__}!`); } stringRep = `${val.toString()}`; } else if (typeof val === "boolean") { @@ -1017,6 +1107,7 @@ function literalToEdgeQL(type: BaseType, val: any): string { } else if (typeof val === "bigint") { stringRep = `${val.toString()}n`; } else if (Array.isArray(val)) { + skipCast = true; if (isArrayType(type)) { stringRep = `[${val .map(el => literalToEdgeQL(type.__element__ as any, el)) @@ -1047,6 +1138,7 @@ function literalToEdgeQL(type: BaseType, val: any): string { ([key, value]) => `${key} := ${literalToEdgeQL(type.__shape__[key], value)}` )} )`; + skipCast = true; } else { throw new Error(`Invalid value for type ${type.__name__}`); } diff --git a/src/syntax/update.ts b/src/syntax/update.ts index bdd21d51a..42f9ceded 100644 --- a/src/syntax/update.ts +++ b/src/syntax/update.ts @@ -1,39 +1,127 @@ import { - QueryableExpression, + Expression, ExpressionKind, ObjectTypePointers, + TypeSet, ObjectTypeSet, stripBacklinks, stripNonWritables, typeutil, + ObjectTypeExpression, + $scopify, + Cardinality, } from "../reflection"; import type {pointerToAssignmentExpression} from "./casting"; +import {$expressionify, $getScopedExpr} from "./path"; +import { + SelectModifiers, + NormalisedSelectModifiers, + ComputeSelectCardinality, + $existingScopes, + $handleModifiers, +} from "./select"; +import {$normaliseInsertShape, pointerIsOptional} from "./insert"; ///////////////// /// UPDATE ///////////////// +export type $expr_Update< + Set extends TypeSet = TypeSet, + Expr extends ObjectTypeSet = ObjectTypeSet, + Shape extends UpdateShape = any +> = Expression<{ + __kind__: ExpressionKind.Update; + __element__: Set["__element__"]; + __cardinality__: Set["__cardinality__"]; + __expr__: Expr; + __shape__: Shape; + __modifiers__: NormalisedSelectModifiers; + __scope__: ObjectTypeExpression; +}>; + export type UpdateShape = typeutil.stripNever< stripNonWritables> > extends infer Shape ? Shape extends ObjectTypePointers ? { - [k in keyof Shape]?: pointerToAssignmentExpression< - Shape[k] - > extends infer S - ? S | {"+=": S} | {"-=": S} - : never; + [k in keyof Shape]?: + | (pointerToAssignmentExpression extends infer S + ? + | S + | (Shape[k]["cardinality"] extends + | Cardinality.Many + | Cardinality.AtLeastOne + ? {"+=": S} | {"-=": S} + : never) + : never) + | (pointerIsOptional extends true + ? undefined | null + : never); } : never : never; -export type $expr_Update< - Root extends ObjectTypeSet = ObjectTypeSet, - Shape extends UpdateShape = any -> = QueryableExpression<{ - __kind__: ExpressionKind.Update; - __element__: Root["__element__"]; - __cardinality__: Root["__cardinality__"]; - __expr__: Root; - __shape__: Shape; -}>; +export function update< + Expr extends ObjectTypeExpression, + Shape extends { + filter?: SelectModifiers["filter"]; + order_by?: SelectModifiers["order_by"]; + limit?: SelectModifiers["limit"]; + offset?: SelectModifiers["offset"]; + set: UpdateShape; + } + // SetShape extends UpdateShape, + // Modifiers extends Pick +>( + expr: Expr, + shape: (scope: $scopify) => Readonly +): $expr_Update< + { + __element__: Expr["__element__"]; + __cardinality__: ComputeSelectCardinality; + }, + Expr, + Shape["set"] +> { + const cleanScopedExprs = $existingScopes.size === 0; + + const scope = $getScopedExpr(expr as any, $existingScopes); + + const resolvedShape = shape(scope); + + if (cleanScopedExprs) { + $existingScopes.clear(); + } + + const mods: any = {}; + let updateShape: any | null; + for (const [key, val] of Object.entries(resolvedShape)) { + if (key === "filter") { + mods[key] = val; + } else if (key === "set") { + updateShape = val; + } else { + throw new Error( + `Invalid update shape key '${key}', only 'filter', ` + + `and 'set' are allowed` + ); + } + } + + if (!updateShape) { + throw new Error(`Update shape must contain 'set' shape`); + } + + const {modifiers, cardinality} = $handleModifiers(mods, expr); + + return $expressionify({ + __kind__: ExpressionKind.Update, + __element__: expr.__element__, + __cardinality__: cardinality, + __expr__: expr, + __shape__: $normaliseInsertShape(expr, updateShape, true), + __modifiers__: modifiers, + __scope__: scope, + }) as any; +} diff --git a/src/syntax/with.ts b/src/syntax/with.ts index 424cac5cd..01a07fddc 100644 --- a/src/syntax/with.ts +++ b/src/syntax/with.ts @@ -1,15 +1,9 @@ -import { - Expression, - ExpressionKind, - QueryableExpression, - TypeSet, -} from "../reflection"; +import {Expression, ExpressionKind, TypeSet} from "../reflection"; import {$expr_Select} from "./select"; import {$expr_For} from "./for"; import {$expr_Insert} from "./insert"; import {$expr_Update} from "./update"; import {$expressionify} from "./path"; -import {$queryify} from "./query"; export type $expr_Alias = Expression<{ __element__: Expr["__element__"]; @@ -36,7 +30,7 @@ export type WithableExpression = export type $expr_With< Refs extends TypeSet[] = TypeSet[], Expr extends WithableExpression = WithableExpression -> = QueryableExpression<{ +> = Expression<{ __element__: Expr["__element__"]; __cardinality__: Expr["__cardinality__"]; __kind__: ExpressionKind.With; @@ -48,15 +42,13 @@ function _with( refs: Refs, expr: Expr ): $expr_With { - return $expressionify( - $queryify({ - __kind__: ExpressionKind.With, - __element__: expr.__element__, - __cardinality__: expr.__cardinality__, - __refs__: refs, - __expr__: expr as any, - }) - ) as any; + return $expressionify({ + __kind__: ExpressionKind.With, + __element__: expr.__element__, + __cardinality__: expr.__cardinality__, + __refs__: refs, + __expr__: expr as any, + }) as any; } export {_with as with}; diff --git a/test/client.test.ts b/test/client.test.ts index 6f8e30b92..cf3af8c12 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -563,7 +563,7 @@ test("fetch: named args", async () => { ); }) .catch(e => { - expect(e.toString()).toMatch(/unexpected named argument: "c"/); + expect(e.toString()).toMatch(/Unused named argument: "c"/); }); res = await con.querySingle(`select len($a ?? "aa")`, { diff --git a/test/globalTeardown.ts b/test/globalTeardown.ts index d555bdc46..425a9744b 100644 --- a/test/globalTeardown.ts +++ b/test/globalTeardown.ts @@ -12,7 +12,7 @@ export const shutdown = async ( // tslint:disable-next-line console.error("!!! EdgeDB exit timeout... !!!"); proc.kill("SIGTERM"); - }, 20_000); + }, 30_000); proc.on("exit", (code: number, signal: string) => { clearTimeout(to); diff --git a/tools/copySyntaxToDist.sh b/tools/copySyntaxToDist.sh index b491670f7..3e58e8a95 100755 --- a/tools/copySyntaxToDist.sh +++ b/tools/copySyntaxToDist.sh @@ -5,4 +5,4 @@ done mv dist/__esm/syntax/*.mjs dist/syntax rm -r dist/__esm cp src/syntax/*.ts dist/syntax/ -rm -r dist/syntax/genMock +rm -rf dist/syntax/genMock diff --git a/tools/genReservedKeywords.js b/tools/genReservedKeywords.js index 707583a97..0db339aa2 100644 --- a/tools/genReservedKeywords.js +++ b/tools/genReservedKeywords.js @@ -21,6 +21,10 @@ const prettier = require("prettier"); await fs.writeFile( path.join(__dirname, "../src/reflection/reservedKeywords.ts"), - `export default ${JSON.stringify(reservedKeywords, null, 2)}\n` + `export const reservedKeywords = ${JSON.stringify( + reservedKeywords, + null, + 2 + )}\n` ); })(); diff --git a/tsconfig.json b/tsconfig.json index 966285c2c..4a0fda308 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,7 +28,7 @@ "./src/index.node" ], "@generated/*": [ - "./qb/dbschema/edgeql/*" + "./qb/dbschema/edgeql-js/*" ], } }, diff --git a/yarn.lock b/yarn.lock index 488aa4440..4d68baa50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2034,7 +2034,7 @@ __metadata: tslint-plugin-prettier: ^2.3.0 typescript: ^4.5.2 bin: - edgedb-generate: ./dist/reflection/cli.js + edgeql-js: ./dist/reflection/cli.js languageName: unknown linkType: soft