@edgerules/portable 0.0.0-alpha.202607042221 → 0.0.0-alpha.202607061032

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/portable.d.ts +57 -6
  2. package/package.json +1 -1
@@ -88,7 +88,7 @@ export interface PortableTypedValue extends PortableObject {
88
88
  * The value of any field inside a context node. Reserved `@`-prefixed keys carry
89
89
  * string|number metadata (see the index signature below); all other keys hold a PortableNode.
90
90
  */
91
- export type PortableNode = PortableValue | PortableContext | PortableContext[] | PortableExpression | PortableTypedValue | PortableFunctionDefinition | PortableTypeDefinition | PortableInvocationDefinition;
91
+ export type PortableNode = PortableValue | PortableContext | PortableContext[] | PortableExpression | PortableTypedValue | PortableFunctionDefinition | PortableRulesetDefinition | PortableTypeDefinition | PortableInvocationDefinition;
92
92
  /**
93
93
  * A context node — the model's record/object construct. In EdgeRules a record literal *is* a
94
94
  * context, so data records and model contexts are one and the same node.
@@ -171,10 +171,14 @@ export interface PortableFunctionSchema extends PortableObject {
171
171
  '@return': PortableTypeReference | PortableTypedValue;
172
172
  }
173
173
  /**
174
- * Used for setting or getting function invocation definitions.
175
- * - `@method` holds the function name, can also hold decision table hit-policy keywords (`firstMatch`, `uniqueMatch`, ...).
176
- * - `@arguments` holds the argument values; if the call takes no arguments, an empty array must be set.
177
- * `@arguments` can also hold a decision table definition (a `PortableContext` with `inputs`, `rules`, and optional `default`).
174
+ * Used for setting or getting function invocation definitions. A call to a `ruleset` is an
175
+ * ordinary invocation too a ruleset is a callable just like a function, so there is no
176
+ * decision-table special case here.
177
+ * - `@method` holds the callee name (a function or a ruleset).
178
+ * - `@arguments` holds the argument values, either positional (an array, in call order; if the call takes no arguments,
179
+ * an empty array must be set) or named (a `Record<string, PortableValue>` keyed by parameter name) — never both in
180
+ * the same invocation. Named arguments are valid only for calls to user-defined functions/rulesets; built-in
181
+ * functions always use the array form and reject the named form at link time.
178
182
  *
179
183
  * `@type` is available only in return object, it is linked type information for the invocation result, inferred by the engine and provided
180
184
  * for the host's convenience.
@@ -183,7 +187,54 @@ export interface PortableInvocationDefinition extends PortableObject {
183
187
  '@kind': 'invocation';
184
188
  '@type'?: PortableTypeReference;
185
189
  '@method': string;
186
- '@arguments': PortableValue[];
190
+ '@arguments': PortableValue[] | Record<string, PortableValue>;
191
+ }
192
+ /**
193
+ * Used for setting or getting ruleset definitions. Mirrors `PortableFunctionDefinition`: the
194
+ * `@parameters` field holds the signature, `@hitPolicy` selects how matches resolve, `@rules`
195
+ * holds the ordered rule matrix, and `@default` is the optional fallback result.
196
+ *
197
+ * - `@default` is rejected when `@hitPolicy` is `"collect-matches"`.
198
+ * - Every rule's `then` (and `@default`, when present) must share one structural record shape.
199
+ *
200
+ * To get a ruleset definition, use:
201
+ * - `service.get("risk.*")` -> returns the full `risk` ruleset definition
202
+ * - `service.get("risk")` -> returns `risk`'s `ruleset-schema` (compact signature)
203
+ */
204
+ export interface PortableRulesetDefinition extends PortableObject {
205
+ '@kind': 'ruleset';
206
+ '@parameters': Record<string, PortableTypeReference | PortableTypedValue | null>;
207
+ '@hitPolicy': 'first-match' | 'unique-match' | 'collect-matches' | 'best-match';
208
+ '@rules': PortableRule[];
209
+ '@default'?: PortableContext;
210
+ }
211
+ /**
212
+ * One rule row of a `PortableRulesetDefinition`. `when` maps a declared parameter name to a
213
+ * unary-test expression string (e.g. `"18..25"`, `"> 30000"`, `"any"`); an omitted column means
214
+ * "any" for that parameter. `then` is the rule's result record. `priority` is required when the
215
+ * ruleset's `@hitPolicy` is `"best-match"` and rejected otherwise.
216
+ */
217
+ export interface PortableRule extends PortableObject {
218
+ '@kind': 'rule';
219
+ name?: string;
220
+ when?: Record<string, PortableExpressionString>;
221
+ then: PortableContext;
222
+ priority?: number;
223
+ }
224
+ /**
225
+ * Use only for getting ruleset schemas, usage:
226
+ * - `service.get("risk")` -> returns `risk`'s schema
227
+ * - `service.get("*")` -> returns all ruleset (and function) schemas in the context, because
228
+ * default filter is "FIELDS"
229
+ *
230
+ * `@return` is the engine-inferred result type (structural), not a declared one — get-only, like
231
+ * `PortableFunctionSchema['@return']`.
232
+ */
233
+ export interface PortableRulesetSchema extends PortableObject {
234
+ '@kind': 'ruleset-schema';
235
+ '@parameters': Record<string, PortableTypeReference | PortableTypedValue | null>;
236
+ '@hitPolicy': 'first-match' | 'unique-match' | 'collect-matches' | 'best-match';
237
+ '@return': PortableTypeReference | PortableTypedValue;
187
238
  }
188
239
  /** Machine-readable discriminant of a `PortableError`. */
189
240
  export type PortableErrorType =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgerules/portable",
3
- "version": "0.0.0-alpha.202607042221",
3
+ "version": "0.0.0-alpha.202607061032",
4
4
  "type": "module",
5
5
  "description": "Portable JSON type definitions for EdgeRules.",
6
6
  "exports": {