Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 21 additions & 49 deletions inputs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,18 @@
},
"definitions": {
"Balances": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [major] Keep the inputs schema aligned with CLI JSON

When users follow inputs.schema.json, this now validates balances as an account-to-asset object map, but internal/cmd/run.go still unmarshals balances into interpreter.Balances ([]BalanceRow) and metadata into AccountsMetadata ([]AccountMetadataRow). A file accepted by this schema will therefore fail at runtime with a JSON unmarshal error, while the currently supported array form is marked invalid by the unversioned schema.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false negative

"type": "array",
"description": "List of account balances. The (account, asset, color, scope) tuple of each entry must be unique within the list.",
"items": { "$ref": "#/definitions/BalanceRow" }
},

"BalanceRow": {
"type": "object",
"description": "The balance of a given (account, asset, color, scope)",
"description": "Map of account names to asset balances",
"additionalProperties": false,
"required": ["account", "asset", "amount"],
"properties": {
"account": {
"type": "string",
"pattern": "^([a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*)$"
},
"asset": {
"type": "string",
"pattern": "^([A-Z]+(/[0-9]+)?)$"
},
"amount": {
"type": "number"
},
"color": {
"type": "string",
"pattern": "^[A-Z]*$"
},
"scope": {
"type": "string",
"pattern": "^[a-z0-9_]*$"
"patternProperties": {
"^([a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*)$": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^([A-Z]+(/[0-9]+)?)$": {
"type": "number"
}
}
}
}
},
Expand All @@ -64,32 +47,21 @@
},

"AccountsMetadata": {
"type": "array",
"description": "List of account metadata entries. The (account, key, scope) tuple of each entry must be unique within the list.",
"items": { "$ref": "#/definitions/AccountMetadataRow" }
},

"AccountMetadataRow": {
"type": "object",
"description": "A single metadata entry: the value of a given (account, key, scope)",
"description": "Map of an account metadata to the account's metadata",
"additionalProperties": false,
"required": ["account", "key", "value"],
"properties": {
"account": {
"type": "string",
"pattern": "^([a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*)$"
},
"key": {
"type": "string"
},
"value": {
"type": "string"
},
"scope": {
"type": "string",
"pattern": "^[a-z0-9_]*$"
"patternProperties": {
"^([a-zA-Z0-9_-]+(:[a-zA-Z0-9_-]+)*)$": {
"type": "object",
"additionalProperties": { "type": "string" }
}
}
},

"TxMetadata": {
"type": "object",
"description": "Map from a metadata's key to the transaction's metadata stringied value",
"additionalProperties": { "type": "string" }
}
}
}
2 changes: 1 addition & 1 deletion internal/cmd/test_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func makeSpecsFile(
}

specs := specs_format.Specs{
Schema: "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
Schema: "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
Balances: store.StaticStore.Balances,
Vars: vars,
FeatureFlags: featureFlags_,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-overdraft-function",
"experimental-mid-script-function-call",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"variables": {
"amt": "10"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-overdraft-function",
"experimental-mid-script-function-call",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-overdraft-function"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-overdraft-function",
"experimental-mid-script-function-call",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"variables": {
"cap": "10",
"fee": "10%"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "matches sources and destinations allotments",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "is capped to USD100 when balance is higher",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"variables": {
"amt": "EUR/2 100",
"limit": "EUR/2 150"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "example spec",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-oneof",
"experimental-asset-scaling"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-asset-scaling"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": ["experimental-scoped-function", "experimental-mid-script-function-call"],
"balances": [
{ "account": "treasury", "asset": "EUR/2", "amount": 42 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-scoped-function",
"experimental-mid-script-function-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"featureFlags": [
"experimental-mid-script-function-call",
"experimental-scoped-function"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"balances": [
{
"account": "src",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"balances": [
{
"account": "acc",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "../../../../specs.schema.json",
"$schema": "../../../../v1.specs.schema.json",
"testCases": [
{
"it": "should handle the floating syntax",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "example spec",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "should subtract the monetaries",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "should subtract the numbers",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/specs.schema.json",
"$schema": "https://raw.githubusercontent.com/formancehq/numscript/main/v1.specs.schema.json",
"testCases": [
{
"it": "should subtract the numbers",
Expand Down
Loading