diff --git a/docs/API/DataClassClass.md b/docs/API/DataClassClass.md index dff84253be03d2..0a06212fd70c79 100644 --- a/docs/API/DataClassClass.md +++ b/docs/API/DataClassClass.md @@ -1219,7 +1219,7 @@ In this case, the *value* parameter must be a **comparison vector object** conta |Property|Type|Description| |---|---|---| |vector|[4D.Vector](../API/VectorClass.md)|Mandatory. The vector to be compared| -|metric|Text|Optional. [Vector computation](../API/VectorClass.md#understanding-the-different-vector-computations) to use for the query. You can use one of the following (Text) constants:
  • `mk cosine` (default if omitted): calculates the cosine similarity between vectors.
  • `mk dot`: calculates the dot similarity of vectors.
  • `mk euclidean`: calculates the Euclidean distance between vectors.| +|metric|Text|Optional. [Vector computation](../API/VectorClass.md#understanding-the-different-vector-computations) to use for the query. You can use one of the following (Text) constants:
  • `mk cosine` (default if omitted): calculates the [cosine similarity](./VectorClass.md#cosinesimilarity) between vectors.
  • `mk dot`: calculates the [dot similarity](VectorClass.md#dotsimilarity) of vectors.
  • `mk euclidean`: calculates the [Euclidean distance](./VectorClass.md#euclideandistance) between vectors.| |threshold|Real|Optional (default: 0.5). A threshold value used to filter vector comparisons based on their cosine, dot or euclidean similarity score according to the selected "metric". It is highly recommended to choose a similarity that best fits your specific use case for optimal results.| Only a subset of **comparator** symbols are supported. Note that they compare results to the threshold value: @@ -1236,7 +1236,7 @@ For example, you want to return entities of MyClass where the similarity with a ```4d var $myVector : 4D.Vector $myVector := getVector //method to get a vector, e.g. from 4D.AIKit -var $comparisonVector := {vector: $myVector; metric: mk euclidean; threshold: 1.2} +var $comparisonVector := {vector: $myVector; metric: mk cosine; threshold: 1.2} var $results := ds.MyClass.query("myVectorField <= :1"; $comparisonVector) ``` @@ -1244,21 +1244,24 @@ The **order by** statement is supported in the query string so that entities in ```4d var $results := ds.MyClass.query("myVectorField > :1 order by myVectorField desc"; $comparisonVector) - //the first entity is the most similar + //$results.first() entity is the most similar ``` :::note -The default order is ascending, although a descending order is usually the most useful for vector similarity queries. Thus, you will usually have to add the `desc` keyword in your vector similarity query strings. +You will generally want vector similarity query results to be sorted from "most similar" to "least similar." By default, results returned with an **order by** clause are sorted in ascending order. Depending on the similarity metric used, you may need to adjust the sorting direction to obtain the correct ranking: +- for [**cosine**](./VectorClass.md#cosinesimilarity) and [**dot**](./VectorClass.md#dotsimilarity) similarity, higher values indicate greater similarity. Therefore, you will typically need to include the `desc` keyword in the query string. +- for [**euclidean distance**](./VectorClass.md#euclideandistance) similarity, lower values indicate greater similarity. In this case, the default ascending order (or explicitly using the `asc` keyword) is appropriate. ::: -If the same vector appears multiple times in the query string, the order by will be applied to the results of the first one, for example: +You can only order on a single vector field. If the same vector appears multiple times in the query string, the order by will be applied to the results of the first one, for example: ```4d var $results := ds.MyClass.query("myVectorField > :1 and myVectorField > :2 order by myVectorField desc"; / - {vector : $myVector1 };{vector : $myVector2 }) //myVectorField > :1 is used for the order by + {vector : $myVector1 };{vector : $myVector2 }) + //myVectorField > :1 is used for the order by ``` See [more examples below](#example-4-2) (examples 4 and 5). @@ -1267,6 +1270,7 @@ See [more examples below](#example-4-2) (examples 4 and 5). :::tip Related blog posts - [4D AI: Searching Entities by Vector Similarity in 4D](https://blog.4d.com/4d-ai-searching-entities-by-vector-similarity-in-4d) +- [4D AI: Sorting Query Results by Vector Similarity](https://blog.4d.com/4d-ai-sorting-query-results-by-vector-similarity/) - [Why Your Search Stack Feels Broken — and How Vector Search Fixes It](https://blog.4d.com/why-your-search-stack-feels-broken-and-how-vector-search-fixes-it) ::: @@ -1635,12 +1639,16 @@ var $result:=$client.embeddings.create("my long text to search"; "text-embedding var $vector:=$result.vector //embedding attribute is based upon a 4D field storing 4D.Vector class objects + //search with default metric (cosine) -var $employees:=ds.Employee.query("embedding > :1"; {vector : $vector}) +var $employees:=ds.Employee.query("embedding > :1 order by embedding desc"; {vector : $vector}) + //search with euclidean metric -var $employees:=ds.Employee.query("embedding > :1"; {vector: $vector; metric: mk euclidean}) +var $employees:=ds.Employee.query("embedding < :1 order by embedding"; {vector: $vector; metric: mk euclidean}) + //search with explicit cosine metric and custom threshold -var $employees:=ds.Employee.query("embedding > :1"; {vector: $vector; metric: mk cosine; threshold: 0.9}) +var $employees:=ds.Employee.query("embedding > :1 order by embedding desc"; {vector: $vector; metric: mk cosine; threshold: 0.9}) + //search with a formula var $employees:=ds.Employee.query(Formula(This.embdedding.cosineSimilarity($vector)>0.9)) @@ -1649,19 +1657,15 @@ var $employees:=ds.Employee.query(Formula(This.embdedding.cosineSimilarity($vect #### Example 5 -We want to execute a query by vector similarity using vectors with different metrics and order the results by cosine similarity: +Vector-based semantic ordering can be combined with traditional ORDA filters in the same query. -```4d - //Create the comparison vectors -var $vector1Comparison:={vector: $myvector; metric: mk cosine; threshold: 0.4} -var $vector2Comparison:={vector: $myvector; metric: mk euclidean; threshold:1} - - //embedding attribute is based upon a 4D field storing 4D.Vector class objects -ds.VectorTable.query("embedding>:1 and embedding<:2";$vector1Comparison;$vector2Comparison)\ - .orderByFormula(Formula(This.embedding.cosineSimilarity($vector1Comparison))) +```4d +var $comparisonVector := {vector: $myVector; metric: mk cosine; threshold: 0.4} +var $results := ds.MyTable.query("myVectorField <= :1 AND salary>100000 order by myVectorField, salary desc"; $comparisonVector) ``` + #### See also [`.query()`](EntitySelectionClass.md#query) for entity selections diff --git a/docs/API/QuotaManagerClass.md b/docs/API/QuotaManagerClass.md new file mode 100644 index 00000000000000..dac7c5f63e38c9 --- /dev/null +++ b/docs/API/QuotaManagerClass.md @@ -0,0 +1,148 @@ +--- +id: QuotaManagerClass +title: QuotaManager +--- + + +The `4D.QuotaManager` class provides you with an interface to configure and monitor some usage limits you apply to your 4D application. Thresholds are useful for example to protect the server from poorly optimized requests or excessive use of server resources. Typically, the quota manager allows you to provide thresholds to ORDA resources a REST server session can access. + + +`4D.QuotaManager` objects can be instantiated by the [`quotas` property of a session](./SessionClass.md#quotas) object. + + +
    History + +|Release|Changes| +|---|---| +|21 R4|Class added| + +
    + + + +### QuotaManager Object + + +4D.QuotaManager objects provide the following properties: + +|| +|---| +|[](#currentvalues)
    | +|[](#defaultentitysettimeout)
    | +|[](#maxentitysettimeout)
    | +|[](#nbentitysets)
    | + + + + +## .currentValues + +**currentValues** : Object + +#### Description + +The `.currentValues` property contains the current values related to the defined quotas properties. This object is automatically updated by the server. + + + + + + +## .defaultEntitySetTimeout + +**defaultEntitySetTimeout** : Integer + +#### Description + +The `.defaultEntitySetTimeout` property contains the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds). + +By default, this value is 2 hours (7200 seconds). It can also be defined at the entity set creation using the [`$timeout` REST API](../REST/$timeout.md). + +You can change this value dynamically using the [`quotas.defaultEntitySetTimeout` property of the Session](./SessionClass.md#quotas), so that it will be used for any entity set created afterwards in the session (existing entity set default timeout values are not modified). + +:::note + +If you define a value higher than the `maxEntitySetTimeout` property value, it will be aligned with the `maxEntitySetTimeout` value. + +::: + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + + +#### Example + +In some 4D code in a REST process: + +```4d +Session.quotas.defaultEntitySetTimeout:=1200 +``` + + + + + + +## .maxEntitySetTimeout + +**maxEntitySetTimeout** : Integer + +#### Description + +The `.maxEntitySetTimeout` property contains the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds). + +You can set this value using the [`quotas.maxEntitySetTimeout` property of the Session](./SessionClass.md#quotas), so that it will be used for any entity set created afterward in the session (existing entity set maximum timeout values are not modified). + +Once the `.maxEntitySetTimeout` property is set, any entity set created afterward in the session could not have a timeout value longer than the `.maxEntitySetTimeout` value. + +For example, assuming the maximum inactivity timeout is set to 40 minutes (2400 seconds), if an entity set is created with a required timeout which exceeds the maximum value: + +``` +http://127.0.0.1/rest/People?$filter=ID>=4&$method=entityset&$timeout=3000 +``` + +... then the timeout defined in the request is ignored and the entity set will be released after 40 minutes if not used during this period of time. + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + +#### Example + +In some 4D code in a REST process: + +```4d +Session.quotas.maxEntitySetTimeout:=2400 +``` + + + + + + +## .nbEntitySets + +**nbEntitySets** : Integer + +#### Description + +The `.nbEntitySets` property contains the maximum number of REST entity sets allowed in memory for the current session (in seconds). + +By default, there is no limit for entity sets [stored in memory by REST requests](../REST/$info.md) (the value is 0). You can set a limit to control the server payload for a specific session. + +When the maximum number of allowed entity sets is reached, a REST request that need to create an entity set will get a [**429** HTTP status code and an error response](../REST/REST_requests.md#rest-status-and-response), until at least one entity set is released. You can release an entity set from the cache using the [`$release` REST command](../REST/$entityset.md#entitysetrelease). + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + + +#### Example + +In some 4D code in a REST process: + +```4d + //max 50 entity sets +Session.quotas.nbEntitySets:=50 +``` + + + + + + diff --git a/docs/API/SessionClass.md b/docs/API/SessionClass.md index 04140e68c650c3..43853194a25773 100644 --- a/docs/API/SessionClass.md +++ b/docs/API/SessionClass.md @@ -53,6 +53,7 @@ All session types can handle privileges, but only the code executed in a **web c |[](#info)
    | |[](#isguest)
    | |[](#promote)
    | +|[](#quotas)
    | |[](#restore)
    | |[](#setprivileges)
    | |[](#storage)
    | @@ -571,6 +572,8 @@ Since `.info` is a computed property, it is recommended to call it once and then ::: +This property is **read only**. + @@ -718,6 +721,61 @@ End if + +## .quotas + +
    History + +|Release|Changes| +|---|---| +|21 R4|Added| + +
    + +**.quotas** : 4D.QuotaManager + +#### Description + + +The `.quotas` property contains a `4D.QuotaManager` object with current values and set values for server thresholds in the current session. Server thresholds are used to control the requests to the server and help preventing excessive use of resources (see [`4D.QuotaManager` class](./QuotaManagerClass.md)). + +This property is **read only**. + +The following properties of the `4D.QuotaManager` object are available for the session: + +|Property||Type|Writable|Description| +|---|---|---|---|---| +|[nbEntitySets](./QuotaManagerClass.md#nbentitysets)||Integer|yes|Maximum allowed number of entity sets in server's memory| +|[defaultEntitySetTimeout](./QuotaManagerClass.md#defaultentitysettimeout) ||Integer|yes|Default inactivity timeout for entity sets in memory (seconds)| +|[maxEntitySetTimeout](./QuotaManagerClass.md#maxentitysettimeout) ||Integer|yes|Maximum inactivity timeout for entity sets in memory (seconds)| +|currentValues||Object|no|| +||nbEntitySets|Integer|no|Number of entity sets currently in memory| + +When you modify a value, it is immediately taken into account by the server (no need to restart) and will be applied to further REST requests. + +:::tip Related blog post + +[Make your REST server at the top of its game ... Forget throttling or crashing and tune yourself the memory usage](https://blog.4d.com/make-your-rest-server-at-the-top-of-its-game-forget-throttling-or-crashing-and-tune-yourself-the-memory-usage). + +::: + +#### Example + +```4d + //set the maximum number of entity sets in memory + //for the session to 50 +Session.quotas.nbEntitySets:=50 +``` + + + + +#### See also + +[QuotaManager class](./QuotaManagerClass.md) + + + ## .restore() diff --git a/docs/Concepts/classes.md b/docs/Concepts/classes.md index 5aabc1427cb823..adec7f24ac37aa 100644 --- a/docs/Concepts/classes.md +++ b/docs/Concepts/classes.md @@ -115,7 +115,7 @@ You want to list 4D built-in classes: ## Class object -When a class is [defined](#class-definition) in the project, it is loaded in the 4D language environment. A class is an object itself, of ["Class" class](API/ClassClass.md). A class object has the following properties and function: +When a class is [defined](../Project/code-overview.md#creating-classes) in the project, it is loaded in the 4D language environment. A class is an object itself, of ["Class" class](API/ClassClass.md). A class object has the following properties and function: - [`name`](API/ClassClass.md#name) string - [`superclass`](API/ClassClass.md#superclass) object (null if none) diff --git a/docs/Concepts/flow-control.md b/docs/Concepts/flow-control.md index 66776000bc18e7..2b7ba877de8419 100644 --- a/docs/Concepts/flow-control.md +++ b/docs/Concepts/flow-control.md @@ -59,6 +59,14 @@ The expression is TRUE only if both methods are TRUE. However, even if _MethodA_ End if ``` +However, the most elegant solution is then to use the [`&&` short-circuit operator](./operators.md#short-circuit-and-operator-) and to write: + +```4d +If (MethodA && MethodB) + ... +End if +``` + The result is similar and _MethodB_ is evaluated only if necessary. > **Note:** The [ternary operator](operators.md#ternary-operator) allows writing one-line conditional expressions and can replace a full sequence of If..Else statements. diff --git a/docs/FormObjects/properties_Reference.md b/docs/FormObjects/properties_Reference.md index 2dc38d3de1884c..97bbe5b71b5a72 100644 --- a/docs/FormObjects/properties_Reference.md +++ b/docs/FormObjects/properties_Reference.md @@ -98,7 +98,8 @@ You will find in this page a comprehensive list of all object properties sorted |[`hideFocusRing`](properties_Appearance.md#hide-focus-rectangle)|Hides the selection rectangle when the object has the focus.|true, false| |[`hideSystemHighlight`](properties_Appearance.md#hide-selection-highlight)|Used to specify hiding highlighted records in the list box.|true, false| |[`highlightSet`](properties_ListBox.md#highlight-set)|Name of the set.| string| -|[`horizontalLineStroke`](properties_Gridlines.md#horizontal-line-color)|Defines the color of the horizontal lines in a list box (gray by default).|Any CSS value, "transparent", "automatic"| +|[`horizontalLineStroke`](properties_Gridlines.md#horizontal-line-color)|Defines the color of the horizontal lines in a list box (gray by default).|Any CSS value, "transparent", "automatic"| +|[`horizontalPadding`](./properties_CoordinatesAndSizing.md#horizontal-padding)|Sets a horizontal padding for listbox cells.|Number of pixels (must be >=0)| |**i**||| |[`icon`](properties_TextAndPicture.md#picture-pathname)|The pathname of the picture used for buttons, check boxes, radio buttons, list box headers.|Relative or filesystem path in POSIX syntax.| |[`iconFrames`](properties_TextAndPicture.md#number-of-states)|Sets the exact number of states present in the picture. |minimum: 1| @@ -216,6 +217,7 @@ You will find in this page a comprehensive list of all object properties sorted |[`variableCalculation`](properties_Object.md#variable-calculation)|Allows mathematical calculations to be performed.|"none", "minimum", "maximum", "sum", "count", "average", "standardDeviation", "variance", "sumSquare"| |[`verticalAlign`](properties_Text.md#vertical-alignment)|Vertical location of text within the area that contains it. |"automatic", "top", "middle", "bottom"| |[`verticalLineStroke`](properties_Gridlines.md#vertical-line-color)|Defines the color of the vertical lines in a list box (gray by default).|Any CSS value, "transparent", "automatic"| +|[`verticalPadding`](./properties_CoordinatesAndSizing.md#vertical-padding)|Sets a vertical padding for listbox cells.|Number of pixels (must be >=0)| |[`visibility`](properties_Display.md#visibility)|Allows hiding the object in the Application environment.|"visible", "hidden", "selectedRows", "unselectedRows"| |**w**||| |[`webEngine`](properties_WebArea.md#use-embedded-web-rendering-engine)| Used to choose between two rendering engines for the Web area, depending on the specifics of the application.|"embedded", "system"| diff --git a/docs/Notes/updates.md b/docs/Notes/updates.md index c6b70c075008d7..bd06f44b029def 100644 --- a/docs/Notes/updates.md +++ b/docs/Notes/updates.md @@ -9,8 +9,15 @@ Read [**What’s new in 4D 21 R4**](https://blog.4d.com/whats-new-in-4d-21-r4/), #### Highlights -- New [`defer`](../commands/defer) command to declare some code to be always executed at method or function exit. +- Multi-level list style sheets are now [supported in 4D Write Pro Interface](../WritePro/writeprointerface#multi-level-list-style-sheets), allowing users to create and manage structured multi-level lists directly from the toolbar and sidebar. +- New [`defer`](../commands/defer) command to declare some code to be always executed at method or function exit; new [`Deferred formulas`](../commands/deferred-formulas) command to get the list of deferred formulas. +- New session `.quotas` property to configure thresholds for sessions. +- New [`4D.QuotaManager`](../API/QuotaManagerClass.md) class to handle threshold objects for protecting the server. +- New [`$entityset/$release`](../REST/$entityset.md#entitysetrelease) REST request to delete entity sets from server cache. +#### Behavior changes + +- The **`GET /Employee/$entityset/?$method=release`** REST syntax is **deprecated** and should no longer be used. To delete entity sets, you must now use [`/$entityset/$release` with a POST verb](./$entityset.md). ## 4D 21 R3 @@ -20,7 +27,7 @@ Read [**What’s new in 4D 21 R3**](https://blog.4d.com/whats-new-in-4d-21-r3/), #### Highlights - The [`JSON Validate`](../commands/json-validate) command now supports of JSON Schema draft 2020-12. -- 4D Write Pro now supports [hierarchical list style sheets](../WritePro/user-legacy/stylesheets.md#hierarchical-list-style-sheets), enabling the creation and management of structured [multi-level lists](../WritePro/user-legacy/using-a-4d-write-pro-area.md#multi-level-lists) with automatic numbering. +- 4D Write Pro now supports [multi-level list style sheets](../WritePro/user-legacy/stylesheets.md#multi-level-list-style-sheets), enabling the creation and management of structured [multi-level lists](../WritePro/user-legacy/using-a-4d-write-pro-area.md#multi-level-lists) with automatic numbering. - Ability to use a custom certificate from the macOS keychain instead of a local certificates folder in [`HTTPRequest`](../API/HTTPRequestClass.md#4dhttprequestnew) and [`HTTPAgent`](../API/HTTPAgentClass.md#4dhttpagentnew) classes. - New [`4D.Method` class](../API/MethodClass.md) to create and execute a 4D method code from text source. [`METHOD Get path`](../commands/method-get-path) and [`METHOD RESOLVE PATH`](../commands/method-resolve-path) commands support a new `path volatile method` constant (128). - IMAP transporter now supports mailbox event notifications using the IDLE protocol through a [notifier object](../API/IMAPTransporterClass.md#notifier) of the [4D.IMAPNotifier](../API/IMAPNotifierClass.md) class, configurable via the `listener` property of [IMAP New transporter](../commands/imap-new-transporter). @@ -100,6 +107,7 @@ Read [**What’s new in 4D 21 R2**](https://blog.4d.com/whats-new-in-4d-21-r2/), |PDFWriter|4.7.0|21|Used for [`WP Export document`](../WritePro/commands/wp-export-document.md) and [`WP Export variable`](../WritePro/commands/wp-export-variable.md) | |SpreadJS|18.2.0|21 R2|See [this blog post](https://blog.4d.com/4d-view-pro-whats-new-in-4d-21-r2/) for an overview of the new features| |webKit|WKWebView|19|| +|Windows App SDK|2.0.1|**21 R4**|Used for [Fluent UI rendering](../FormEditor/forms.md#fluent-ui-rendering)| |Xerces|3.3.0|21|Used for XML commands| |Zlib|1.3.1|21|| diff --git a/docs/Project/components.md b/docs/Project/components.md index 58c684002fa61c..5a3103ad8fd84b 100644 --- a/docs/Project/components.md +++ b/docs/Project/components.md @@ -637,7 +637,7 @@ In addition, you can check for updates at any moment, for a single dependency or ![check components](../assets/en/Project/check-component-all.png) -If a new component version matching your [component versioning configuration](#defining-a-github-dependency-version-range) is detected on GitHub, a specific dependency status is displayed: +If a new component version matching your [component versioning configuration](#defining-a-dependency-version-range) is detected on GitHub, a specific dependency status is displayed: ![dependency-new-version](../assets/en/Project/dependency-available.png) diff --git a/docs/REST/$entityset.md b/docs/REST/$entityset.md index cf88b6ac9739ea..e5330a59ced842 100644 --- a/docs/REST/$entityset.md +++ b/docs/REST/$entityset.md @@ -12,6 +12,7 @@ After [creating an entity set]($method.md#methodentityset) by using `$method=ent |---|---|---| |[**$entityset/\{entitySetID\}**](#entitysetentitysetid)|`/People/$entityset/0ANUMBER`|Retrieves an existing entity set| |[**$entityset/\{entitySetID\}?$logicOperator...&$otherCollection**](#entitysetentitysetidlogicoperatorothercollection)|`/Employee/$entityset/0ANUMBER?$logicOperator=AND&$otherCollection=0ANUMBER`|Creates a new entity set from comparing existing entity sets| +|[**$entityset/$release**](#entitysetrelease)|`/Employee/$entityset/$release`|Releases one or more existing entity sets from the 4D Server's cache| @@ -98,3 +99,29 @@ If there is an intersection, this query returns true. Otherwise, it returns fals In the following example we create a new entity set that combines all the entities in both entity sets: ` GET /rest/Employee/$entityset/9718A30BF61343C796345F3BE5B01CE7?$logicOperator=OR&$otherCollection=C05A0D887C664D4DA1B38366DD21629B&$method=entityset` + + +## $entityset/$release + +Releases on or more existing entity set(s) stored in [4D Server's cache](./$info.md). + +### Description + +You can use this command to release a collection of entity sets, which you created using [`$method=entityset`](#methodentityset), from 4D Server's cache. + +### Example + +Release two entity sets from the server's cache: + +`POST /rest/Employee/$entityset/$release` + +The body must contain a collection with the entity sets ids to release: + +**POST data**: + +```json +[ +"552AE0C8329045FDB65A8C151AEBC532", "9D0617688D7540C090D7675CAF21D7C8" +] +``` + diff --git a/docs/REST/$info.md b/docs/REST/$info.md index 6b44ea8919d83d..1f4eac250775e9 100644 --- a/docs/REST/$info.md +++ b/docs/REST/$info.md @@ -12,27 +12,28 @@ When you call this request for your project, you retrieve information in the fol |---|---|---| |cacheSize| Number |4D Server's cache size.| |usedCache |Number |How much of 4D Server's cache has been used.| -|entitySetCount |Number |Number of entity selections.| -|entitySet |Collection|A collection in which each object contains information about each entity selection.| +|entitySetCount |Number |Number of entity sets.| +|entitySet |Collection|A collection in which each object contains information about each entity set.| |ProgressInfo| Collection |A collection containing information about progress indicator information.| |sessionInfo| Collection |A collection in which each object contains information about each user session.| |privileges| Object |An object with a "privileges" property (collection of objects). Each object of the collection has a "privilege" property with a privilege name of the user session as value.| ### entitySet -For each entity selection currently stored in 4D Server's cache, the following information is returned: + +For each entity set currently stored in 4D Server's cache, the following information is returned: |Property| Type| Description| |---|---|---| |id|Text| A UUID that references the entity set.| |dataClass|Text |Name of the dataclass.| -|selectionSize| Number| Number of entities in the entity selection.| +|selectionSize| Number| Number of entities in the entity set.| |sorted|Boolean|Returns true if the set was sorted (using `$orderby`) or false if it's not sorted.| |refreshed|Date|When the entity set was created or the last time it was used.| -|expires|Date|When the entity set will expire (this date/time changes each time when the entity set is refreshed). The difference between refreshed and expires is the timeout for an entity set. This value is either two hours by default or what you defined using `$timeout`. +|expires|Date|When the entity set will expire (this date/time changes each time when the entity set is refreshed). The difference between refreshed and expires is the timeout for an entity set. This value is either two hours by default or what you defined using `$timeout`. It can also be modified for the session through the [`Session.quotas`](../API/SessionClass.md#quotas) property. | -For information about how to create an entity selection, refer to `$method=entityset`. If you want to remove the entity selection from 4D Server's cache, use `$method=release`. +For information about how to create an entity set, refer to [`$method=entityset`](./$method.md#methodentityset). If you want to remove the entity selection from 4D Server's cache, use [`$entityset/$release`](./$entityset.md#entitysetrelease). >4D also creates its own entity selections for optimization purposes, so the ones you create with `$method=entityset` are not the only ones returned. diff --git a/docs/REST/$method.md b/docs/REST/$method.md index 81c619bc05a291..9e7be729e0bb27 100644 --- a/docs/REST/$method.md +++ b/docs/REST/$method.md @@ -9,16 +9,13 @@ This parameter allows you to define the operation to execute with the returned e |Syntax|Example|Description| |---|---|---| -|[**$method=delete**](#methoddelete)|`POST /Employee?$filter="ID=11"& $method=delete`|Deletes the current entity, entity collection, or entity selection| +|[**$method=delete**](#methoddelete)|`POST /Employee?$filter="ID=11"& $method=delete`|Deletes the current entity, entity collection, or entity set| |[**$method=entityset**](#methodentityset)|`GET /People/?$filter="ID>320"& $method=entityset& $timeout=600`|Creates an entity set in 4D Server's cache based on the collection of entities defined in the REST request| -|[**$method=release**](#methodrelease)|`GET /Employee/$entityset/?$method=release`|Releases an existing entity set stored in 4D Server's cache| |[**$method=subentityset**](#methodsubentityset)|`GET /Company(1)/staff?$expand=staff& $method=subentityset& $subOrderby=lastName ASC`|Creates an entity set based on the collection of related entities defined in the REST request| |[**$method=update**](#methodupdate)|`POST /Person/?$method=update`|Updates and/or creates one or more entities| - - ## $method=delete Deletes the current entity, entity collection, or entity selection (created through REST) @@ -60,10 +57,16 @@ Creates an entity set in 4D Server's cache based on the collection of entities d ### Description -When you create a collection of entities in REST, you can also create an entity set that will be saved in 4D Server's cache. The entity set will have a reference number that you can pass to `$entityset/\{entitySetID\}` to access it. By default, it is valid for two hours; however, you can modify that amount of time by passing a value (in seconds) to $timeout. +When you create a collection of entities in REST, you can also create an entity set that will be saved in 4D Server's cache. The entity set will have a reference number that you can pass to `$entityset/\{entitySetID\}` to access it. By default, it is valid for two hours; however, you can modify that amount of time by passing a value (in seconds) to [`$timeout`](./$timeout.md). It can also be modified for the session through the [`Session.quotas`](../API/SessionClass.md#quotas) property. If you have used `$savedfilter` and/or `$savedorderby` (in conjunction with `$filter` and/or `$orderby`) when you created your entity set, you can recreate it with the same reference ID even if it has been removed from 4D Server's cache. +:::note + +By default, you can create as many entity sets as you want. However, the total number of entity sets in the 4D Server cache can be limited for a session through the [`Session.quotas`](../API/SessionClass.md#quotas) property. + +::: + ### Example To create an entity set, which will be saved in 4D Server's cache for two hours, add `$method=entityset` at the end of your REST request: @@ -86,41 +89,6 @@ __ENTITYSET: "http://127.0.0.1:8081/rest/Employee/$entityset/9718A30BF61343C7963 -## $method=release - -Releases an existing entity set stored in 4D Server's cache. - -### Description - -You can release an entity set, which you created using [`$method=entityset`](#methodentityset), from 4D Server's cache. - -### Example - -Release an existing entity set: - -`GET /rest/Employee/$entityset/4C51204DD8184B65AC7D79F09A077F24?$method=release` - -#### Response: - -If the request was successful, the following response is returned: - -```json -{ - "ok": true -} -If the entity set wasn't found, an error is returned: - -{ - "__ERROR": [ - { - "message": "Error code: 1802\nEntitySet \"4C51204DD8184B65AC7D79F09A077F24\" cannot be found\ncomponent: 'dbmg'\ntask 22, name: 'HTTP connection handler'\n", - "componentSignature": "dbmg", - "errCode": 1802 - } - ] -} -``` - ## $method=subentityset diff --git a/docs/REST/$timeout.md b/docs/REST/$timeout.md index 0463f12e19b760..2f6be153cae4ea 100644 --- a/docs/REST/$timeout.md +++ b/docs/REST/$timeout.md @@ -14,6 +14,12 @@ Once the timeout has been defined, each time an entity set is called upon (by us If an entity set is removed and then recreated using `$method=entityset` along with [`$savedfilter`]($savedfilter.md), the new default timeout is 10 minutes regardless of the timeout you defined when calling `$timeout`. +:::note + +The timeout can also be modified for a session using the [`Session.quotas`](../API/SessionClass.md#quotas) property. + +::: + ## Example In our entity set that we're creating, we define the timeout to 20 minutes: diff --git a/docs/WritePro/commands-legacy/wp-new.md b/docs/WritePro/commands-legacy/wp-new.md index 772c7022ba2bbc..ef9fddb5ea7a5c 100644 --- a/docs/WritePro/commands-legacy/wp-new.md +++ b/docs/WritePro/commands-legacy/wp-new.md @@ -42,7 +42,7 @@ If the *source* parameter is used, the new 4D Write Pro object will be filled wi By defaut, HTML expressions inserted in legacy 4D Write documents are not imported (no 4D Write Pro support). If you pass the `wk import html expressions as text` constant in the *option* parameter, HTML expressions will be imported as raw text within *##htmlBegin##* and *##htmlEnd##* tags -- which will require formatting actions afterwards. For example: -```RAW +```html ##htmlBegin##Imported titlebold##htmlEnd## ``` diff --git a/docs/WritePro/user-legacy/stylesheets.md b/docs/WritePro/user-legacy/stylesheets.md index 5f003784d7d479..ea1773f06d4fd0 100644 --- a/docs/WritePro/user-legacy/stylesheets.md +++ b/docs/WritePro/user-legacy/stylesheets.md @@ -24,7 +24,7 @@ Style sheets allow you to define the attributes of entire paragraphs or specific Note that paragraph styles apply to whole paragraphs. To apply a style only to a specific part of a paragraph, you must use a character style sheet. - + ## Style sheet precedence diff --git a/docs/WritePro/user/user-new.md b/docs/WritePro/user/user-new.md index 77f1d00da79f72..78b6142c73ca68 100644 --- a/docs/WritePro/user/user-new.md +++ b/docs/WritePro/user/user-new.md @@ -10,7 +10,7 @@ to import ## Lists -4D Write Pro supports flat lists (single-level) and hierarchical lists (multi-level). +4D Write Pro supports flat lists (single-level) and multi-level lists. ### Single-level lists @@ -38,7 +38,7 @@ When the list is created using [the WP SET ATTRIBUTE command](../commands-legacy ### Multi-level lists -Multi-level lists are based on [hierarchical list style sheets](../user-legacy/stylesheets.md#hierarchical-list-style-sheets). Multi-level lists contain a root-level style sheet and one or more sub-level style sheet(s). Each level is attached to a hierarchical list style sheet and represents a depth in the list (level 1, level 2, level 3, etc.). +Multi-level lists are based on [multi-level list style sheets](../user-legacy/stylesheets.md#multi-level-list-style-sheets). Multi-level lists contain a root-level style sheet and one or more sub-level style sheet(s). Each level is attached to a multi-level list style sheet and represents a depth in the list (level 1, level 2, level 3, etc.). When a new sub-level is created, the level numbering restarts at 1. When you add or remove an element in your multi-level list, the numbers are automatically adjusted. @@ -54,30 +54,30 @@ Multi-level lists can be managed using: :::tip Related blog post -[4D Write Pro – Creating Multi-level Bullet or Numbered Lists Using Hierarchical list Style Sheets](https://blog.4d.com/4d-write-pro-creating-multi-level-bullet-or-numbered-lists-using-hierarchical-paragraph-style-sheets) +[4D Write Pro – Creating Multi-level Bullet or Numbered Lists Using Multi-level list Style Sheets](https://blog.4d.com/4d-write-pro-creating-multi-level-bullet-or-numbered-lists-using-multi-level-paragraph-style-sheets) ::: - + -## Hierarchical list style sheets +## Multi-level list style sheets -Hierarchical list style sheets are used to create [multi-level lists](../user-legacy/using-a-4d-write-pro-area.md#multi-level-lists). +Multi-level list style sheets are used to create [multi-level lists](../user-legacy/using-a-4d-write-pro-area.md#multi-level-lists). -To create a hierarchical list style sheet, use [WP New style sheet](../commands/wp-new-style-sheet.md) and pass in *listLevelCount* the desired number of levels. You then define a hierarchy of related paragraph style sheets: one **root-level** style sheet and one or more **sub-level** style sheets linked to it. Each level represents a depth in the list (level 1, level 2, level 3, etc.) and is automatically named "root-level name + lvl + index", for example "Mylist lvl 2". +To create a multi-level list style sheet, use [WP New style sheet](../commands/wp-new-style-sheet.md) and pass in *listLevelCount* the desired number of levels. You then define a hierarchy of related paragraph style sheets: one **root-level** style sheet and one or more **sub-level** style sheets linked to it. Each level represents a depth in the list (level 1, level 2, level 3, etc.) and is automatically named "root-level name + lvl + index", for example "Mylist lvl 2". -To customize hierarchical list styles, the paragraph style sheet object can be customized using [style sheet attributes](../commands-legacy/4d-write-pro-attributes.md#style-sheets). +To customize multi-level list styles, the paragraph style sheet object can be customized using [style sheet attributes](../commands-legacy/4d-write-pro-attributes.md#style-sheets). -Hierarchical list style sheets are fully supported by the following commands: [`WP Get style sheet`](../commands/wp-get-style-sheet.md), [`WP SET ATTRIBUTES`](../commands/wp-set-attributes.md), [`WP DELETE STYLE SHEET`](../commands/wp-delete-style-sheet.md). +Multi-level list style sheets are fully supported by the following commands: [`WP Get style sheet`](../commands/wp-get-style-sheet.md), [`WP SET ATTRIBUTES`](../commands/wp-set-attributes.md), [`WP DELETE STYLE SHEET`](../commands/wp-delete-style-sheet.md). ### Example -The following example creates a three-level hierarchical list style sheet and applies it to paragraphs. +The following example creates a three-level multi-level list style sheet and applies it to paragraphs. ```4d -// Create 3 hierarchical list style sheets +// Create 3 multi-level list style sheets WP New style sheet(wpArea; wk type paragraph; "MyList"; 3) // Retrieve each level @@ -91,7 +91,7 @@ WP SET ATTRIBUTES($level1; {listStyleType: wk upper latin; fontBold: wk true}) WP SET ATTRIBUTES($level2; {listConcatStringFormat: True}) WP SET ATTRIBUTES($level3; {listStringFormatLtr: "(#)"}) -// Apply hierarchical style sheets to paragraphs +// Apply multi-level style sheets to paragraphs var $paragraphs : Collection $paragraphs:=WP Get elements(wpArea; wk type paragraph) @@ -101,7 +101,7 @@ WP SET ATTRIBUTES($paragraphs[2]; wk style sheet; $level3) ``` result: -![](../../assets/en/WritePro/hierarchical-paragraph-stylesheets-1.png) +![](../../assets/en/WritePro/multi-level-paragraph-stylesheets-1.png) To delete the first sub-leve: @@ -110,11 +110,11 @@ WP DELETE STYLE SHEET(wpArea; "MyList"; 2) ``` result: -![](../../assets/en/WritePro/hierarchical-paragraph-stylesheets-2.png) +![](../../assets/en/WritePro/multi-level-paragraph-stylesheets-2.png) ### Predefined attribute values -When created, hierarchical list style sheets use predefined values: +When created, multi-level list style sheets use predefined values: * `wk margin left` = 0.75 cm \* (number of previous levels) or 0.25 inches \* (number of previous levels), depending on current layout unit * `wk list type` = `wk decimal` diff --git a/docs/WritePro/writeprointerface.md b/docs/WritePro/writeprointerface.md index 3d2ea53d183948..e3a9170cedd4ef 100644 --- a/docs/WritePro/writeprointerface.md +++ b/docs/WritePro/writeprointerface.md @@ -418,3 +418,155 @@ The History area lists all your prompts sent to the AI. You can hide/show this a The Erase button allows you to reset the whole window and erase all interactions. It is equivalent to close/reopen the AI dialog box. + +## Multi-level list style sheets + +4D Write Pro Interface allows users to create and manage [multi-level lists](./user-legacy/using-a-4d-write-pro-area.md#multi-level-lists) directly from both the toolbar and widget sidebar. + +**Toolbar:** + +![](../assets/en/WritePro/wp-multi-level-list-stylesheets1.png) + +**Sidebar:** + +![](../assets/en/WritePro/wp-multi-level-list-stylesheets2.png) + +To manage multi-level list style sheets, click the ![](../assets/en/WritePro/wp-multi-level-list-button.png) multi-level list button. + +When the multi-level list mode is enabled, the Style Sheets panel displays the [multi-level list style sheets](./user-legacy/stylesheets.md#multi-level-list-style-sheets) defined in the document as well as [predefined templates](#predefined-templates). + +![](../assets/en/WritePro/wp-multi-level-list-panel.png) + +### Managing multi-level style sheets + +The Style Sheets panel allows you in general to: + +* ![](../assets/en/WritePro/wp-multi-level-list-button1.png) Create a new style sheet. +* ![](../assets/en/WritePro/wp-multi-level-list-button2.png) Delete a style sheet. +* ![](../assets/en/WritePro/wp-multi-level-list-button3.png) Update a style sheet. + +Once a multi-level list style sheet is selected, the panel provides also tools to manage the hierarchy and numbering of the list: + +* ![](../assets/en/WritePro/wp-multi-level-list-button4.png) Increase the list level of selected paragraphs. +* ![](../assets/en/WritePro/wp-multi-level-list-button5.png) Decrease the list level of selected paragraphs. +* ![](../assets/en/WritePro/wp-multi-level-list-button6.png) Append a level to the list and create a new sub-level. +* ![](../assets/en/WritePro/wp-multi-level-list7.png) Modify numbering formats. +* ![](../assets/en/WritePro/wp-multi-level-list-button8.png) Concatenate numbering markers between levels. + +### Creating a style sheet + +To create a multi-level list style sheet you can either: + +* Select and apply one of the predefined templates to the paragraph(s), the selected template and all it sub-levels are then displayed on the top part of the sytle sheets panel. You can customize its levels and formatting (such as numbering styles, colors, fonts, or hierarchy), and then create a new style sheet based on the resulting selection. + +* Duplicate one of the existing style sheets via the Duplicate option in the ![](../assets/en/WritePro/wp-multi-level-list-button1.png) bottom menu. + +* Click the ![](../assets/en/WritePro/wp-multi-level-list-button1.png) button and then "New style sheet based on selection" after having selected paragraph(s) to use for the style sheet according to the following: + * If the selected paragraph(s) use(s) a list marker, a new multi-level list style sheet made of one level is created based on the current formatting. + * If the selected paragraph(s) already use(s) a root-level or a sub-level of a multi-level list style sheet, the complete hierarchy is duplicated. + +:::note + +For detailed information about creating and configuring multi-level list style sheets by programming, see [Multi-level list style sheets](./user-legacy/stylesheets.md#multi-level-list-style-sheets). + +::: + +### Applying a multi-level list + +You can apply either a multi-level list style sheet defined in the document or one of the predefined templates to the selected paragraphs using the Style Sheets panel: + +![](../assets/en/WritePro/wp-multi-level-list-panel2.png) + + +### Predefined templates + +The interface provides the following predefined multi-level list templates: + +**Technical Blueprint** + +Level 1: 1 +Level 2: 1.1 +Level 3: 1.1.1 +Level 4: 1.1.1.1 +Level 5: 1.1.1.1.1 + +**Legal & Governance** + +Level 1: I. +Level 2: A. +Level 3: 1. +Level 4: a) +Level 5: (1) +Level 6: (a) +Level 7: (i) + +**Educational Material** + +Level 1: I. +Level 2: 1. +Level 3: 1.1. +Level 4: a. +Level 5: ● + +**Meeting Minutes** + +Level 1: 1. +Level 2: ● + +**Visual Hierarchy** + +Level 1: ♣ (Club) +Level 2: ♦ (Diamond) +Level 3: ■ (Square) +Level 4: □ (Hollow Square) +Level 5: ● (Disc) +Level 6: ○ (Circle) +Level 7: – (Dash) + +### Customizing predefined templates + +You can customize the available templates to provide users with predefined multi-level lists that match the needs of your application. + +The predefined multi-level list templates are defined in a JSON file named `multiLevelStyles.json`. This file is located in the 4D Write Pro Interface component Resources folder. + +You can customize the available templates by adding your own `multiLevelStyles.json` file in either: + +* the project's local Resources folder directly, +* a `4D WritePro Interface` folder located within the project Resources folder. + +If a `multiLevelStyles.json` file is present in both locations, the file located in the `4D WritePro Interface` folder takes precedence. + +Each template definition includes: + +* a template name, +* one or more list levels, +* the 4D Write Pro attributes applied to each level. Any 4D Write Pro attribute can be used in a template definition. + +You can use either the attribute names or the corresponding 4D Write Pro constants as JSON keys and values. +For example, the following definitions are equivalent: + +* `"listStyleType": "wk upper roman"` +* `"wk list style type": "wk upper roman"` + +#### Example + +Example of a customized JSON file: + +```json +{ + "predefinedMultiLevelLists": [ + { + "name": "Technical Blue Print Updated", + "levels": [ + { "listStyleType": "wk decimal" }, + { "listStyleType": "wk decimal", "listConcatStringFormat": true } + ] + } + ] +} +``` + +### See also +* [Related blog post: Multi-Level Style Sheets in 4D Write Pro: Now With a Dedicated UI](https://blog.4d.com/multi-level-style-sheets-in-4d-write-pro-now-with-a-dedicated-ui) +* [multi-level list style sheets](./user-legacy/stylesheets.md#multi-level-list-style-sheets) +* [multi-level lists](./user-legacy/using-a-4d-write-pro-area.md#multi-level-lists) diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button.png b/docs/assets/en/WritePro/wp-multi-level-list-button.png new file mode 100644 index 00000000000000..5f8e7ee323f616 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button1.png b/docs/assets/en/WritePro/wp-multi-level-list-button1.png new file mode 100644 index 00000000000000..07da3e87098960 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button1.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button2.png b/docs/assets/en/WritePro/wp-multi-level-list-button2.png new file mode 100644 index 00000000000000..088e4c64ed531e Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button2.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button3.png b/docs/assets/en/WritePro/wp-multi-level-list-button3.png new file mode 100644 index 00000000000000..ddda09768ac90f Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button3.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button4.png b/docs/assets/en/WritePro/wp-multi-level-list-button4.png new file mode 100644 index 00000000000000..aadcadc4745659 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button4.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button5.png b/docs/assets/en/WritePro/wp-multi-level-list-button5.png new file mode 100644 index 00000000000000..7de845916f4a1f Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button5.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button6.png b/docs/assets/en/WritePro/wp-multi-level-list-button6.png new file mode 100644 index 00000000000000..636cb5780823cd Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button6.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-button8.png b/docs/assets/en/WritePro/wp-multi-level-list-button8.png new file mode 100644 index 00000000000000..0d5031837e8773 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-button8.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-panel.png b/docs/assets/en/WritePro/wp-multi-level-list-panel.png new file mode 100644 index 00000000000000..652d71520d5fe7 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-panel.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-panel2.png b/docs/assets/en/WritePro/wp-multi-level-list-panel2.png new file mode 100644 index 00000000000000..6e3c56f16b0d7a Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-panel2.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-stylesheets1.png b/docs/assets/en/WritePro/wp-multi-level-list-stylesheets1.png new file mode 100644 index 00000000000000..10c1d6e47429a9 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-stylesheets1.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list-stylesheets2.png b/docs/assets/en/WritePro/wp-multi-level-list-stylesheets2.png new file mode 100644 index 00000000000000..a0d750f5bd4f62 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list-stylesheets2.png differ diff --git a/docs/assets/en/WritePro/wp-multi-level-list7.png b/docs/assets/en/WritePro/wp-multi-level-list7.png new file mode 100644 index 00000000000000..646a3d751ced01 Binary files /dev/null and b/docs/assets/en/WritePro/wp-multi-level-list7.png differ diff --git a/docs/commands-legacy/on-web-authentication-database-method.md b/docs/commands-legacy/on-web-authentication-database-method.md index ac669a182f81ef..49a6ad45b9e1da 100644 --- a/docs/commands-legacy/on-web-authentication-database-method.md +++ b/docs/commands-legacy/on-web-authentication-database-method.md @@ -53,7 +53,7 @@ You must declare these parameters as follows: ```4d   // On Web Authentication Database Method   - #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ;\ $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean + #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ; $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean     // Code for the method ``` @@ -127,7 +127,7 @@ Example of the On Web Authentication database method in BASIC mode: ```4d   //On Web Authentication Database Method - #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ;\ $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean + #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ; $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean  var $ipServerDuser : Boolean  ARRAY TEXT($users;0)  ARRAY LONGINT($nums;0) @@ -172,7 +172,7 @@ Example of the On Web Authentication database method in DIGEST mode: ```4d   //On Web Authentication Database Method - #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ;\ $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean + #DECLARE($url : Text ; $http : Text ; $BrowserIP : Text ; $ServerIP : Text ; $user : Text ; $password: Text) -> $result : Boolean  $result:=False   //For security reasons, refuse names that contain @  If(WithWildcard($user)) diff --git a/docs/language-legacy/Date and Time/timestamp.md b/docs/language-legacy/Date and Time/timestamp.md index 0d8374cd15407c..15b7205e1e1e4d 100644 --- a/docs/language-legacy/Date and Time/timestamp.md +++ b/docs/language-legacy/Date and Time/timestamp.md @@ -45,8 +45,13 @@ You can use **Timestamp** in a log file to know precisely when the events occurr Result: -```RAW -2016-12-12T13:31:29.477Z   Log with timestamp2016-12-12T13:31:29.478Z   Connection of user12016-12-12T13:31:29.486Z   ERROR - Exception of type 'System exception'2016-12-12T13:31:29.492Z   Click on button16842016-12-12T13:31:29.502Z   [SP_HELP- 1 rows] Command processed2016-12-12T13:31:29.512Z   [SP_HELP- 5 rows] Result set fetched +```txt +2016-12-12T13:31:29.477Z   Log with timestamp +2016-12-12T13:31:29.478Z   Connection of user +12016-12-12T13:31:29.486Z   ERROR - Exception of type 'System exception' +2016-12-12T13:31:29.492Z   Click on button1684 +2016-12-12T13:31:29.502Z   [SP_HELP- 1 rows] Command processed +2016-12-12T13:31:29.512Z   [SP_HELP- 5 rows] Result set fetched ``` ## See also diff --git a/docs/language-legacy/Design Object Access/form-get-names.md b/docs/language-legacy/Design Object Access/form-get-names.md index 97b15a143d2bcb..811aba14c4cb65 100644 --- a/docs/language-legacy/Design Object Access/form-get-names.md +++ b/docs/language-legacy/Design Object Access/form-get-names.md @@ -5,7 +5,7 @@ slug: /commands/form-get-names displayed_sidebar: docs --- -**FORM GET NAMES** ( {*aTable* : Table ;} *arrNames* : Text array {; *filter* : Text {; *marker* : Real}}{; *} ) +**FORM GET NAMES** ( {*aTable* : Table ;} *arrNames* : Text array {; *filter* : Text} {; *marker* : Real} {; *} )
    diff --git a/docs/language-legacy/Design Object Access/method-get-code.md b/docs/language-legacy/Design Object Access/method-get-code.md index 81c5ec8a125f70..a42cd7150200ad 100644 --- a/docs/language-legacy/Design Object Access/method-get-code.md +++ b/docs/language-legacy/Design Object Access/method-get-code.md @@ -110,8 +110,12 @@ If you execute the following code: The resulting document will contain: -```RAW -  //%attributes = {"lang":"en"} comment added and reserved by 4DCase of    : (Form event code=On Load)        ALL RECORDS([Customer])End case +```json +  //%attributes = {"lang":"en"} comment added and reserved by 4D +Case of +    : (Form event code=On Load) +        ALL RECORDS([Customer]) +End case ``` If you execute the following code: @@ -126,8 +130,12 @@ If you execute the following code: The resulting document will contain: -```RAW -  //%attributes = {"lang":"en"} comment added and reserved by 4DCase of    : (Form event code:C388=On Load:K2:1)        ALL RECORDS:C47([Customer:1])End case +```json +  //%attributes = {"lang":"en"} comment added and reserved by 4D +Case of +    : (Form event code:C388=On Load:K2:1) +        ALL RECORDS:C47([Customer:1]) +End case ``` ## See also diff --git a/docs/language-legacy/Formulas/parse-formula.md b/docs/language-legacy/Formulas/parse-formula.md index d40d818afa4b14..c8de963307e464 100644 --- a/docs/language-legacy/Formulas/parse-formula.md +++ b/docs/language-legacy/Formulas/parse-formula.md @@ -34,7 +34,7 @@ displayed_sidebar: docs **\*\*** *Tokenized equivalents are 4D language and structure elements in plain text* **expressed with token syntax as shown below (* *see also Using tokens in formulas):* -```RAW +```txt [Table:1]Field:1+String:C10(1) ``` diff --git a/docs/language-legacy/Interruptions/defer.md b/docs/language-legacy/Interruptions/defer.md index 4bdf5d0cc8a256..9fbb0957567345 100644 --- a/docs/language-legacy/Interruptions/defer.md +++ b/docs/language-legacy/Interruptions/defer.md @@ -48,6 +48,8 @@ defer(ALERT("2")) In *exitFormula*, you pass the expression that you want to be evaluated upon method or function exit, whatever the way it exited. Behind the scenes, every time a `defer` is called, 4D converts *exitFormula* into a [formula](../../commands/formula) and adds it to a stack associated with the method or function. When the method or function ends, all formulas stored in the stack are evaluated in the order they appear in the collection. +For debugging purposes, you can get the current stack of formulas at any moment using the [`Deferred formulas`](../../commands/deferred-formulas) command. + As for all [formulas](../../commands/formula), if the *exitFormula* expression uses local variables, their current values are copied and stored in the formula object returned **when it is put in the *deferred stack***. When executed, the formula uses these copied values rather than the current values of the local variables. :::note Notes @@ -112,16 +114,17 @@ defer(SET DATABASE PARAMETER(Diagnostic log level; $logLevel)) ## See also -[throw](../commands/throw) +[Deferred formulas](../commands/deferred-formulas) [Last errors](../commands/last-errors) [ON ERR CALL](../commands/on-err-call) +[throw](../commands/throw) ## Properties | | | | --- | --- | -| Command number | 1805 | -| Thread safe | no | +| Command number | 1860 | +| Thread safe | yes | diff --git a/docs/language-legacy/Interruptions/deferred-formulas.md b/docs/language-legacy/Interruptions/deferred-formulas.md new file mode 100644 index 00000000000000..8df60a9b9ec640 --- /dev/null +++ b/docs/language-legacy/Interruptions/deferred-formulas.md @@ -0,0 +1,58 @@ +--- +id: deferred-formulas +title: Deferred formulas +slug: /commands/deferred-formulas +displayed_sidebar: docs +--- + +**Deferred formulas** : Collection + +
    + +| Parameter | Type | | Description | +| --- | --- | --- | --- | +| Function result | Collection | ← |Stack of formulas deferred in the function or method| +
    + + +
    +
    History + +|Release|Changes| +|---|---| +|21 R4|Created| + +
    +
    + +## Description + +The `Deferred formulas` command returns the collection of all formulas that have been deferred using the [`defer`](../../commands/defer) command in the current function or method. + +If the command is called from another context, it returns an empty collection. + + + +## Example + +```4d +defer(ALERT("1")) +defer(ALERT("2")) +... +var $colStack:=Deferred formulas + //$colStack = [<>,<>] +``` + +## See also + +[defer](../commands/defer) + +## Properties + +| | | +| --- | --- | +| Command number | 1861 | +| Thread safe | yes | + + + diff --git a/docs/language-legacy/Printing/accumulate.md b/docs/language-legacy/Printing/accumulate.md index e39883fdc4a8db..8641735413262c 100644 --- a/docs/language-legacy/Printing/accumulate.md +++ b/docs/language-legacy/Printing/accumulate.md @@ -5,14 +5,14 @@ slug: /commands/accumulate displayed_sidebar: docs --- -**ACCUMULATE** ( {*...dataField* : Field} {; *...dataVar* : Variable ) +**ACCUMULATE** ( {*...data* : any} )
    | Parameter | Type | | Description | | --- | --- | --- | --- | -| dataField | Field | → | Numeric field on which to accumulate | -| dataVar | Variable | → | Numeric variable on which to accumulate | +| data | Field, Variable | → | Numeric field or variable on which to accumulate | +
    diff --git a/docs/language-legacy/Processes/session.md b/docs/language-legacy/Processes/session.md index 540214e6309334..aaa2b1a57004dd 100644 --- a/docs/language-legacy/Processes/session.md +++ b/docs/language-legacy/Processes/session.md @@ -34,7 +34,7 @@ The `Session` command returns the `Sessio Depending on the process from which the command is called, the current session can be: -- a web session (when [scalable sessions are enabled](../../WebServer/sessions.md#enabling-web-sessions)), +- a web session (when [scalable sessions are enabled](../../WebServer/sessions.md#enabling-web-sessions)), which includes REST sessions, - a remote user session (on the server or on the client), - a stored procedures session, - a standalone session. @@ -43,6 +43,12 @@ For more information, see the [Session types](../../API/SessionClass.md#session- The command returns *Null* if it is called in a web process and scalable sessions are disabled on the web server. +:::note + +There is always at least one REST session on the server, even if [scalable sessions are disabled](../../WebServer/sessions.md#enabling-web-sessions). Thus, the `Session` command always returns a REST session object when called from a REST process. + +::: + ### Web sessions The `Session` object of web sessions is available from any web process: diff --git a/docs/language-legacy/Queries/describe-query-execution.md b/docs/language-legacy/Queries/describe-query-execution.md index a99b3233786ccd..eb2bc27d537748 100644 --- a/docs/language-legacy/Queries/describe-query-execution.md +++ b/docs/language-legacy/Queries/describe-query-execution.md @@ -58,8 +58,10 @@ The following example illustrates the type of information obtained using these c After executing this code, *$vResultPlan* and *$vResultPath* contain descriptions of the queries performed, for example: -```RAW -$vResultPlan :    Employees.LastName == T@ And Employees.Salary > 2500 And Join on Table : Companies  :  Employees.Company = Companies.Name [index : Companies.Name ] LIKE H@ And Join on Table : Cities  :  Employees.City = Cities.Name [index : Cities.Pop ] < 50000$vResultPath : (Employees.LastName == T@ And Employees.Salary  > 2500) And (Join on Table : Companies  :  Employees.Company  = Companies.Name with filter {[index : Companies.Name ] LIKE H@}) And (Join on Table : Cities  :  Employees.City = Cities.Name with filter {[index : Cities.Pop ] < 50000})   (3 records found in 1 ms) +```txt +$vResultPlan : +    Employees.LastName == T@ And Employees.Salary > 2500 And Join on Table : Companies  :  Employees.Company = Companies.Name [index : Companies.Name ] LIKE H@ And Join on Table : Cities  :  Employees.City = Cities.Name [index : Cities.Pop ] < 50000$ +vResultPath : (Employees.LastName == T@ And Employees.Salary  > 2500) And (Join on Table : Companies  :  Employees.Company  = Companies.Name with filter {[index : Companies.Name ] LIKE H@}) And (Join on Table : Cities  :  Employees.City = Cities.Name with filter {[index : Cities.Pop ] < 50000})   (3 records found in 1 ms) ``` If the Description in XML Format constant is passed to the [Last query path](../commands/last-query-path) command, *$vResultPath* contains the description of the query expressed in XML: diff --git a/docs/language-legacy/Record Locking/locked-records-info.md b/docs/language-legacy/Record Locking/locked-records-info.md index 4a8a3055d38d37..482b6ca7cdc629 100644 --- a/docs/language-legacy/Record Locking/locked-records-info.md +++ b/docs/language-legacy/Record Locking/locked-records-info.md @@ -77,14 +77,59 @@ You execute the following code: If two records were locked in the \[Table\] table, the following object is returned in $vOlocked: -```RAW -{    "records": [        {            "contextID": "A9BB84C0E57349E089FA44E04C0F2F25",            "contextAttributes": {                "task_id": 8,                "user_name": "roland",                "user4d_id": 1,                "host_name": "iMac de roland",                "task_name": "P_RandomLock",                "client_version": -1342106592            },            "recordNumber": 1        },        {            "contextID": "8916338D1B8A4D86B857D92F593CCAC3",            "contextAttributes": {                "task_id": 9,                "user_name": "roland",                "user4d_id": 1,                "host_name": "iMac de roland",                "task_name": "P_RandomLock",                "client_version": -1342106592            },            "recordNumber": 2        }    ]} +```json +{ + "records": [ + { + "contextID": "A9BB84C0E57349E089FA44E04C0F2F25", + "contextAttributes": { + "task_id": 8, + "user_name": "roland", + "user4d_id": 1, + "host_name": "iMac de roland", + "task_name": "P_RandomLock", + "client_version": -1342106592 + }, + "recordNumber": 1 + }, + { + "contextID": "8916338D1B8A4D86B857D92F593CCAC3", + "contextAttributes": { + "task_id": 9, + "user_name": "roland", + "user4d_id": 1, + "host_name": "iMac de roland", + "task_name": "P_RandomLock", + "client_version": -1342106592 + }, + "recordNumber": 2 + } + ] +} ``` If the code is executed on a 4D Server and the locking is caused by a remote client machine, the following object is returned in $vOlocked: ```json -{    "records": [        {            "contextID": "B0EC087DC2FA704496C0EA15DC011D1C",            "contextAttributes": {                "task_id": 2,                 "user_name": "achim",                 "user4d_id": 1,                "host_name": "achim-pcwin",                "task_name": "P_RandomLock",                 "is_remote_context": true,                "client_uid": "0696E66F6CD731468E6XXX581A87554A",                "client_version": -268364752            },            "recordNumber": 1        }    ]} +{ + "records": [ + { + "contextID": "B0EC087DC2FA704496C0EA15DC011D1C", + "contextAttributes": { + "task_id": 2, + "user_name": "achim", + "user4d_id": 1, + "host_name": "achim-pcwin", + "task_name": "P_RandomLock", + "is_remote_context": true, + "client_uid": "0696E66F6CD731468E6XXX581A87554A", + "client_version": -268364752 + }, + "recordNumber": 1 + } + ] +} + ``` ## See also diff --git a/docs/language-legacy/Styled Text/st-get-plain-text.md b/docs/language-legacy/Styled Text/st-get-plain-text.md index 5510544d1f18c9..4bc828941d96d1 100644 --- a/docs/language-legacy/Styled Text/st-get-plain-text.md +++ b/docs/language-legacy/Styled Text/st-get-plain-text.md @@ -81,10 +81,11 @@ You are looking for the text "very nice" among the values of a multistyle text f Given the following text placed in the multi-style area entitled "MyArea": -```RAW -It is now Go to the 4D site or Open a window +```html +It is now Go to the 4D site or Open a window ``` + This text is displayed: ![](../../assets/en/commands/pict1217332.en.png) diff --git a/docs/language-legacy/System Documents/document-to-text.md b/docs/language-legacy/System Documents/document-to-text.md index f591edab429b3b..b0466ee07cd2b0 100644 --- a/docs/language-legacy/System Documents/document-to-text.md +++ b/docs/language-legacy/System Documents/document-to-text.md @@ -67,8 +67,9 @@ By default, when you omit the *breakMode* parameter, line breaks are processed i Given the following text document (fields are separated by tabs): -```RAW -id    name    price    vat3    4D Tags    99    19.6 +```txt +id    name    price    vat +3    4D Tags    99    19.6 ``` When you execute this code: diff --git a/docs/language-legacy/Triggers/trigger-event.md b/docs/language-legacy/Triggers/trigger-event.md index ffa0b2ee502193..012df26b80aa48 100644 --- a/docs/language-legacy/Triggers/trigger-event.md +++ b/docs/language-legacy/Triggers/trigger-event.md @@ -5,7 +5,7 @@ slug: /commands/trigger-event displayed_sidebar: docs --- -**Trigger event** : Integer +**Trigger event** : Integer
    diff --git a/docs/language-legacy/Web Server/web-set-option.md b/docs/language-legacy/Web Server/web-set-option.md index 86f3e99a676ac4..f9a3a5984e0979 100644 --- a/docs/language-legacy/Web Server/web-set-option.md +++ b/docs/language-legacy/Web Server/web-set-option.md @@ -90,8 +90,39 @@ Enabling the HTTP debug log without body parts: A log entry looks like this: -```RAW -# REQUEST# SocketID: 1592# PeerIP: 127.0.0.1# PeerPort: 54912# TimeStamp: 39089388#ConnectionID: 9808E3B4B06E4EB5A60E9A3FC69116BD#SequenceNumber:5GET /4DWEBTEST HTTP/1.1Accept: text/html,(...)Accept-Encoding: gzip, deflateConnection: keep-aliveHost: 127.0.0.1User-Agent: 4D_HTTP_Client/0.0.0.0# RESPONSE# SocketID: 1592# PeerIP: 127.0.0.1# PeerPort: 54912# TimeStamp: 39089389 (elapsed time: 1 ms)#ConnectionID: 9808E3B4B06E4EB5A60E9A3FC69116BD#SequenceNumber:6HTTP/1.1 200 OKAccept-Ranges: bytesConnection: keep-aliveContent-Encoding: gzipContent-Length: 3555Content-Type: text/plain; charset=UTF-8Date: Thu, 20 Apr 2017 10:51:29 GMTExpires: Thu, 20 Apr 2017 10:51:29 GMTServer: 4D/16.0.1[Body Size: 3555] +```txt +# REQUEST +# SocketID: 1592 +# PeerIP: 127.0.0.1 +# PeerPort: 54912 +# TimeStamp: 39089388 +#ConnectionID: 9808E3B4B06E4EB5A60E9A3FC69116BD +#SequenceNumber:5 +GET /4DWEBTEST HTTP/1.1 +Accept: text/html,(...) +Accept-Encoding: gzip, deflate +Connection: keep-alive +Host: 127.0.0.1 +User-Agent: 4D_HTTP_Client/0.0.0.0 + +# RESPONSE +# SocketID: 1592 +# PeerIP: 127.0.0.1 +# PeerPort: 54912 +# TimeStamp: 39089389 (elapsed time: 1 ms) +#ConnectionID: 9808E3B4B06E4EB5A60E9A3FC69116BD +#SequenceNumber:6 +HTTP/1.1 200 OK +Accept-Ranges: bytes +Connection: keep-alive +Content-Encoding: gzip +Content-Length: 3555 +Content-Type: text/plain; charset=UTF-8 +Date: Thu, 20 Apr 2017 10:51:29 GMT +Expires: Thu, 20 Apr 2017 10:51:29 GMT +Server: 4D/16.0.1 + +[Body Size: 3555] ``` ## See also diff --git a/docs/preprocessing.conf b/docs/preprocessing.conf index 17789410c6d96b..964d8ab9ae72e6 100644 --- a/docs/preprocessing.conf +++ b/docs/preprocessing.conf @@ -1,48 +1,48 @@ -Transporter -POP3Transporter -IMAPNotifier -IMAPTransporter -SMTPTransporter -MailAttachment -Email -File -ZipFile -ZipFolder -ZipArchive -Document -Folder -CryptoKey -Function -Formula -Method +Class Collection +CryptoKey +DataClass +DataStore Directory -Signal -Session -SystemWorker +Document +Email Entity EntitySelection -DataClass -DataStore -Class -ClassStore -WebServer +File +FileHandle +Folder +Formula +Function HTTPAgent HTTPRequest -FileHandle -WebSocket -WebSocketServer -WebSocketConnection -WebForm -WebFormItem +IMAPNotifier +IMAPTransporter IncomingMessage +MailAttachment +Method OutgoingMessage -UDPEvent -UDPSocket +POP3Transporter +QuotaManager +Session +Signal +SMTPTransporter +SystemWorker TCPConnection TCPEvent TCPListener +Transporter +UDPEvent +UDPSocket Vector +WebForm +WebFormItem +WebServer +WebSocket +WebSocketConnection +WebSocketServer +ZipArchive +ZipFile +ZipFolder diff --git a/i18n/es/docusaurus-plugin-content-docs/current/API/DataClassClass.md b/i18n/es/docusaurus-plugin-content-docs/current/API/DataClassClass.md index efc843f388794b..d83668efbea10c 100644 --- a/i18n/es/docusaurus-plugin-content-docs/current/API/DataClassClass.md +++ b/i18n/es/docusaurus-plugin-content-docs/current/API/DataClassClass.md @@ -1222,11 +1222,11 @@ Si *attributePath* designa un atributo que almacena [**objetos vectores**](../AP En este caso, el parámetro *value* debe ser un **objeto vectorial de comparación** que contenga las siguientes propiedades: -| Propiedad | Tipo | Descripción | -| --------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| vector | [4D.Vector](../API/VectorClass.md) | Obligatorio. El vector a comparar | -| metric | Text | Opcional. [Cálculo vectorial](../API/VectorClass.md#understanding-the-different-vector-computations) a utilizar para la consulta. Puede utilizar una de las siguientes constantes (Texto)
  • :`mk cosine` (por defecto si se omite): calcula la similaridad en cosenos entre los vectores.
  • `mk dot`: calcula la similaridad en puntos de los vectores.
  • `mk euclidean`: calcula la distancia euclideana entre vectores. | -| threshold | Real | Opcional (por defecto: 0,5). Un valor umbral utilizado para filtrar las comparaciones de vectores en función de su puntuación de similitud coseno, punto o euclídea según la "métrica" seleccionada. Es altamente recomendable elegir una similitud que se adapte mejor a su caso de uso específico para obtener resultados óptimos. | +| Propiedad | Tipo | Descripción | +| --------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| vector | [4D.Vector](../API/VectorClass.md) | Obligatorio. El vector a comparar | +| metric | Text | Opcional. [Cálculo vectorial](../API/VectorClass.md#understanding-the-different-vector-computations) a utilizar para la consulta. You can use one of the following (Text) constants:
  • `mk cosine` (default if omitted): calculates the [cosine similarity](./VectorClass.md#cosinesimilarity) between vectors.
  • `mk dot`: calculates the [dot similarity](VectorClass.md#dotsimilarity) of vectors.
  • `mk euclidean`: calculates the [Euclidean distance](./VectorClass.md#euclideandistance) between vectors. | +| threshold | Real | Opcional (por defecto: 0,5). Un valor umbral utilizado para filtrar las comparaciones de vectores en función de su puntuación de similitud coseno, punto o euclídea según la "métrica" seleccionada. Es altamente recomendable elegir una similitud que se adapte mejor a su caso de uso específico para obtener resultados óptimos. | Sólo se admite un subconjunto de símbolos **comparadores**. Tenga en cuenta que comparan los resultados con el valor umbral: @@ -1241,23 +1241,33 @@ Por ejemplo, se desea devolver entidades de MyClass donde la similaridad con un ```4d var $myVector : 4D.Vector -$myVector := getVector ///método para obtener un vector, por ejemplo a partir de 4D.AIKit -var $comparisonVector := {vector: $myVector; metric: mk euclidean; threshold: 1.2} +$myVector := getVector //method to get a vector, e.g. from 4D.AIKit +var $comparisonVector := {vector: $myVector; metric: mk cosine; threshold: 1.2} var $results := ds.MyClass.query("myVectorField <= :1"; $comparisonVector) ``` La instrucción **orden by** es soportada en la cadena de consulta para que las entidades en la selección de entidad resultante estén ordenadas por similitud. Por ejemplo: ```4d -var $results := ds.MyClass.query("myVectorField > :1 order by myVectorField"; $comparisonVector) - //orden por defecto, la primera entidad es la más parecida +var $results := ds.MyClass.query("myVectorField > :1 order by myVectorField desc"; $comparisonVector) + //$results.first() entity is the most similar ``` -Si el mismo vector aparece varias veces en la cadena de consulta, el orden por se aplicará a los resultados del primero, por ejemplo: +:::note + +You will generally want vector similarity query results to be sorted from "most similar" to "least similar." By default, results returned with an **order by** clause are sorted in ascending order. Depending on the similarity metric used, you may need to adjust the sorting direction to obtain the correct ranking: + +- for [**cosine**](./VectorClass.md#cosinesimilarity) and [**dot**](./VectorClass.md#dotsimilarity) similarity, higher values indicate greater similarity. Therefore, you will typically need to include the `desc` keyword in the query string. +- for [**euclidean distance**](./VectorClass.md#euclideandistance) similarity, lower values indicate greater similarity. In this case, the default ascending order (or explicitly using the `asc` keyword) is appropriate. + +::: + +You can only order on a single vector field. Si el mismo vector aparece varias veces en la cadena de consulta, el orden por se aplicará a los resultados del primero, por ejemplo: ```4d var $results := ds.MyClass.query("myVectorField > :1 and myVectorField > :2 order by myVectorField desc"; / - {vector : $myVector1 };{vector : $myVector2 }) //myVectorField > :1 is used for the order by + {vector : $myVector1 };{vector : $myVector2 }) + //myVectorField > :1 is used for the order by ``` Ver [más ejemplos a continuación](#example-4-2) (ejemplos 4 y 5). @@ -1265,6 +1275,7 @@ Ver [más ejemplos a continuación](#example-4-2) (ejemplos 4 y 5). :::tip Entradas de blog relacionadas - [4D AI: Búsqueda de entidades por similaridad vectorial en 4D](https://blog.4d.com/4d-ai-searching-entities-by-vector-similarity-in-4d) +- [4D AI: Sorting Query Results by Vector Similarity](https://blog.4d.com/4d-ai-sorting-query-results-by-vector-similarity/) - [Por qué su Pila de búsqueda está rota y cómo lo soluciona la búsqueda vectorial](https://blog.4d.com/why-your-search-stack-feels-broken-and-how-vector-search-fixes-it) ::: @@ -1631,31 +1642,29 @@ var $client:=cs.AIKit.OpenAI.new("my api key") var $result:=$client.embeddings.create("my long text to search"; "text-embedding-ada-002") var $vector:=$result.vector - //el atributo embedding se basa en un campo 4D que almacena objetos de clase 4D.Vector - //buscar con la métrica por defecto (coseno) -var $employees:=ds.Employee.query("embedding > :1"; {vector : $vector}) - //buscar con la métrica euclídea -var $employees:=ds.Employee.query("embedding > :1"; {vector: $vector; metric: mk euclidean}) - //búsqueda con métrica coseno explícita y umbral personalizado -var $employees:=ds.Employee.query("embedding > :1"; {vector: $vector; metric: mk cosine; threshold: 0.9}) - //buscar con una fórmula + //embedding attribute is based upon a 4D field storing 4D.Vector class objects + + //search with default metric (cosine) +var $employees:=ds.Employee.query("embedding > :1 order by embedding desc"; {vector : $vector}) + + //search with euclidean metric +var $employees:=ds.Employee.query("embedding < :1 order by embedding"; {vector: $vector; metric: mk euclidean}) + + //search with explicit cosine metric and custom threshold +var $employees:=ds.Employee.query("embedding > :1 order by embedding desc"; {vector: $vector; metric: mk cosine; threshold: 0.9}) + + //search with a formula var $employees:=ds.Employee.query(Formula(This.embdedding.cosineSimilarity($vector)>0.9)) ``` #### Ejemplo 5 -Queremos ejecutar una consulta por similitud vectorial utilizando vectores con diferentes métricas y ordenar los resultados por similaridades de coseno: +Vector-based semantic ordering can be combined with traditional ORDA filters in the same query. ```4d - //Crear los vectores de comparación -var $vector1Comparison:={vector: $myvector; métrica: mk coseno; umbral: 0.4} -var $vector2Comparison:={vector: $myvector; metric: mk euclidean; threshold:1} - - //el atributo embedding se basa en un campo 4D que almacena objetos de clase 4D.Vector -ds.VectorTable.query("embedding>:1 and embedding<:2";$vector1Comparison;$vector2Comparison)\ - .orderByFormula(Formula(This.embedding.cosineSimilarity($vector1Comparison))) - +var $comparisonVector := {vector: $myVector; metric: mk cosine; threshold: 0.4} +var $results := ds.MyTable.query("myVectorField <= :1 AND salary>100000 order by myVectorField, salary desc"; $comparisonVector) ``` #### Ver también diff --git a/i18n/es/docusaurus-plugin-content-docs/current/API/QuotaManagerClass.md b/i18n/es/docusaurus-plugin-content-docs/current/API/QuotaManagerClass.md new file mode 100644 index 00000000000000..b24f2a26f47e50 --- /dev/null +++ b/i18n/es/docusaurus-plugin-content-docs/current/API/QuotaManagerClass.md @@ -0,0 +1,136 @@ +--- +id: QuotaManagerClass +title: QuotaManager +--- + +The `4D.QuotaManager` class provides you with an interface to configure and monitor some usage limits you apply to your 4D application. Thresholds are useful for example to protect the server from poorly optimized requests or excessive use of server resources. Typically, the quota manager allows you to provide thresholds to ORDA resources a REST server session can access. + +`4D.QuotaManager` objects can be instantiated by the [`quotas` property of a session](./SessionClass.md#quotas) object. + +
    Historia + +| Lanzamiento | Modificaciones | +| ----------- | -------------- | +| 21 R4 | Clase añadida | + +
    + +### QuotaManager Object + +4D.QuotaManager objects provide the following properties: + +| | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [](#currentvalues)
    | +| [](#defaultentitysettimeout)
    | +| [](#maxentitysettimeout)
    | +| [](#nbentitysets)
    | + + + +## .currentValues + +**currentValues** : Object + +#### Descripción + +The `.currentValues` property contains the current values related to the defined quotas properties. This object is automatically updated by the server. + + + + + +## .defaultEntitySetTimeout + +**defaultEntitySetTimeout** : Integer + +#### Descripción + +The `.defaultEntitySetTimeout` property contains the default inactivity timeout for REST entity sets stored in memory during the current session (in seconds). + +By default, this value is 2 hours (7200 seconds). It can also be defined at the entity set creation using the [`$timeout` REST API](../REST/$timeout.md). + +You can change this value dynamically using the [`quotas.defaultEntitySetTimeout` property of the Session](./SessionClass.md#quotas), so that it will be used for any entity set created afterwards in the session (existing entity set default timeout values are not modified). + +:::note + +If you define a value higher than the `maxEntitySetTimeout` property value, it will be aligned with the `maxEntitySetTimeout` value. + +::: + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + +#### Ejemplo + +In some 4D code in a REST process: + +```4d +Session.quotas.defaultEntitySetTimeout:=1200 +``` + + + + + +## .maxEntitySetTimeout + +**maxEntitySetTimeout** : Integer + +#### Descripción + +The `.maxEntitySetTimeout` property contains the maximum inactivity timeout value for REST entity sets stored in memory during the current session (in seconds). + +You can set this value using the [`quotas.maxEntitySetTimeout` property of the Session](./SessionClass.md#quotas), so that it will be used for any entity set created afterward in the session (existing entity set maximum timeout values are not modified). + +Once the `.maxEntitySetTimeout` property is set, any entity set created afterward in the session could not have a timeout value longer than the `.maxEntitySetTimeout` value. + +For example, assuming the maximum inactivity timeout is set to 40 minutes (2400 seconds), if an entity set is created with a required timeout which exceeds the maximum value: + +``` +http://127.0.0.1/rest/People?$filter=ID>=4&$method=entityset&$timeout=3000 +``` + +... then the timeout defined in the request is ignored and the entity set will be released after 40 minutes if not used during this period of time. + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + +#### Ejemplo + +In some 4D code in a REST process: + +```4d +Session.quotas.maxEntitySetTimeout:=2400 +``` + + + + + +## .nbEntitySets + +**nbEntitySets** : Integer + +#### Descripción + +The `.nbEntitySets` property contains the maximum number of REST entity sets allowed in memory for the current session (in seconds). + +By default, there is no limit for entity sets [stored in memory by REST requests](../REST/$info.md) (the value is 0). You can set a limit to control the server payload for a specific session. + +When the maximum number of allowed entity sets is reached, a REST request that need to create an entity set will get a [**429** HTTP status code and an error response](../REST/REST_requests.md#rest-status-and-response), until at least one entity set is released. You can release an entity set from the cache using the [`$release` REST command](../REST/$entityset.md#entitysetrelease). + +You cannot pass a value <=0 (an error is generated in this case). To reset the property value for the session, pass *undefined*. + +#### Ejemplo + +In some 4D code in a REST process: + +```4d + //max 50 entity sets +Session.quotas.nbEntitySets:=50 +``` + + + + + + diff --git a/i18n/es/docusaurus-plugin-content-docs/current/API/SessionClass.md b/i18n/es/docusaurus-plugin-content-docs/current/API/SessionClass.md index 35ff62b1d5db0d..f21cdbd7475e04 100644 --- a/i18n/es/docusaurus-plugin-content-docs/current/API/SessionClass.md +++ b/i18n/es/docusaurus-plugin-content-docs/current/API/SessionClass.md @@ -19,8 +19,8 @@ Los objetos de sesión son devueltos por el comando [`Session`](../commands/sess Los siguientes tipos de sesiones están soportados por esta clase: - [**Sesiones usuario web**](WebServer/sessions.md): las sesiones usuario web están disponibles cuando [las sesiones escalables están activas en su proyecto](WebServer/sessions.md#enabling-web-sessions). Se utilizan para las conexiones Web (incluidos los accesos REST) y se controlan mediante los [privilegios](../ORDA/privileges.md) asignados. -- [**Remote user sessions**](../Desktop/sessions.md#remote-user-sessions): In client/server applications, remote users have their own sessions, managed from the client and from the server. -- [Sesiones procedimientos almacenados\*\*](../Desktop/sessions.md#stored-procedure-sessions): sesión usuario virtual para todos los procedimientos almacenados ejecutados en el servidor. +- [**Sesiones usuario remoto**](../Desktop/sessions.md#remote-user-sessions): en las aplicaciones cliente/servidor, los usuarios remotos tienen sus propias sesiones gestionadas desde el cliente y el servidor. +- [**Sesiones procedimientos almacenados**](../Desktop/sessions.md#stored-procedure-sessions): sesión usuario virtual para todos los procedimientos almacenados ejecutados en el servidor. - [**Sesiones autónomas**](../Desktop/sessions.md#standalone-sessions): sesión local devuelta en una aplicación mono usuario (útil en las fases de desarrollo y de prueba de las aplicaciones cliente/servidor). :::warning Acerca de los privilegios de sesión @@ -44,6 +44,7 @@ Todos los tipos de sesión pueden manejar privilegios, pero sólo el código eje | [](#info)
    | | [](#isguest)
    | | [](#promote)
    | +| [](#quotas)
    | | [](#restore)
    | | [](#setprivileges)
    | | [](#storage)
    | @@ -83,7 +84,7 @@ La función `.clearPrivileges()` describe la sesión. -- **Remote user sessions** and **Stored procedure sessions**: The `.info` object is the same object as the one returned in the "session" property by the [`Process activity`](../commands/process-activity) command. +- **Sesiones usuario remotas** y **Sesiones de procedimientos almacenados**: el objeto `.info` es el mismo objeto que el devuelto en la propiedad "session" por el comando [`Process activity`](../commands/process-activity). - **Sesiones estándar**: el objeto `.info` es el mismo objeto que el devuelto por el comando [`Session info`](../commands/session-info). - **Sesiones usuario web**: el objeto `.info` contiene las propiedades disponibles para las sesiones de usuario web. El objeto `.info` contiene las siguientes propiedades: -| Propiedad | Tipo | Descripción | -| ---------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| type | Text | Tipo de sesión: "remote", "storedProcedure", "standalone", "rest", "web" | -| userName | Text | Nombre de usuario 4D (mismo valor que [`.userName`](#username)) | -| machineName | Text | | -| systemUserName | Text |