Skip to content

Commit

Permalink
Support valueOnError, AccessCheck in readiness files (#164)
Browse files Browse the repository at this point in the history
* Add valueOnError to readiness definitions

* add internal AccessCheck readines type

* Add to templateRequirement type

* Remove stale version availability notes in hover text on various fields.
  • Loading branch information
smithgp committed Oct 23, 2023
1 parent 6c29554 commit 78f77e9
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
"OrgDatasetRowCount",
"AppDatasetRowCount",
"DataCloudRowCount",
"ApexCallout",
"OrgPreferenceCheck",
"ApexCallout"
"AccessCheck"
]
},
{
Expand All @@ -58,9 +59,10 @@
"A check against the number of objects in the org.",
"A check against the number of rows in a dataset in the org",
"A check against the number of rows in a dataset that will be created by this template in the app",
"A check against the number of Data Cloud objects in the org. Only available in Winter '24 release.",
"A check against the number of Data Cloud objects in the org.",
"A check using a method on the template's apexCallback class.",
"",
"A check using a method on the template's apexCallback class."
""
]
},
"successMessage": {
Expand Down Expand Up @@ -150,25 +152,29 @@
"OrgDatasetRowCount",
"AppDatasetRowCount",
"DataCloudRowCount",
"ApexCallout",
"OrgPreferenceCheck",
"ApexCallout"
"AccessCheck"
],
"enumDescriptions": [
"A check against the number of objects in the org.",
"A check against the number of rows in a dataset in the org",
"A check against the number of rows in a dataset that will be created by this template in the app",
"A check against the number of Data Cloud objects in the org. Only available in Winter '24 release.",
"A check against the number of Data Cloud objects in the org.",
"A check using a method on the template's apexCallback class.",
"",
"A check using a method on the template's apexCallback class."
""
]
},
"valueOnError": {},
"filters": { "doNotSuggest": true },
"sobject": { "doNotSuggest": true },
"object": { "doNotSuggest": true },
"dataset": { "doNotSuggest": true },
"names": { "doNotSuggest": true },
"method": { "doNotSuggest": true },
"arguments": { "doNotSuggest": true }
"arguments": { "doNotSuggest": true },
"expression": { "doNotSuggest": true }
},
"$comment": "Customize the type-specifc fields.",
"anyOf": [
Expand All @@ -185,6 +191,11 @@
"$ref": "#/definitions/filters",
"description": "The query filter to use when counting the number of rows.",
"doNotSuggest": false
},
"valueOnError": {
"description": "Numeric value to return instead if an error occurs at runtime.",
"type": ["integer", "null"],
"examples": [-1, 0]
}
},
"required": ["type", "sobject"]
Expand All @@ -202,6 +213,11 @@
"$ref": "#/definitions/filters",
"description": "The query filter to use when counting the number of rows.",
"doNotSuggest": false
},
"valueOnError": {
"description": "Numeric value to return instead if an error occurs at runtime.",
"type": ["integer", "null"],
"examples": [-1, 0]
}
},
"required": ["type", "dataset"]
Expand All @@ -219,6 +235,11 @@
"$ref": "#/definitions/filters",
"description": "The query filter to use when counting the number of rows.",
"doNotSuggest": false
},
"valueOnError": {
"description": "Numeric value to return instead if an error occurs at runtime.",
"type": ["integer", "null"],
"examples": [-1, 0]
}
},
"required": ["type", "dataset"]
Expand All @@ -236,6 +257,11 @@
"$ref": "#/definitions/filters",
"description": "The query filter to use when counting the number of rows.",
"doNotSuggest": false
},
"valueOnError": {
"description": "Numeric value to return instead if an error occurs at runtime.",
"type": ["integer", "null"],
"examples": [-1, 0]
}
},
"required": ["type", "object"]
Expand All @@ -248,6 +274,14 @@
"minItems": 1,
"items": { "type": "string" },
"doNotSuggest": false
},
"valueOnError": {
"description": "Value to return instead if an error occurs at runtime. If non-null, should be a map of name to boolean value for each pref requested.",
"type": ["object", "null"],
"additionalProperties": {
"type": "boolean"
},
"examples": [{}]
}
},
"required": ["type", "names"]
Expand All @@ -266,10 +300,31 @@
"description": "The values for the method arguments. The values can use ${...} expressions.",
"additionalProperties": true,
"doNotSuggest": false
},
"valueOnError": {
"description": "Value to return instead if an error occurs at runtime.",
"type": ["array", "boolean", "null", "number", "object", "string"],
"examples": [[], {}, 0],
"defaultSnippets": [{ "label": "\"\"", "body": "${0}" }]
}
},
"required": ["type", "method", "arguments"]
},
{
"properties": {
"type": { "const": "AccessCheck" },
"expression": {
"type": "string",
"minLength": 1,
"doNotSuggest": false
},
"valueOnError": {
"description": "Value to return instead if an error occurs at runtime.",
"type": ["boolean", "null"]
}
},
"required": ["type", "expression"]
},
{
"properties": {
"type": {
Expand All @@ -280,7 +335,8 @@
"OrgDatasetRowCount",
"DataCloudRowCount",
"OrgPreferenceCheck",
"ApexCallout"
"ApexCallout",
"AccessCheck"
]
}
}
Expand Down Expand Up @@ -312,6 +368,14 @@
"filters": []
}
},
{
"label": "New DataCloudRowCount definition",
"body": {
"type": "DataCloudRowCount",
"object": "${0}",
"filters": []
}
},
{
"label": "New ApexCallout definition",
"body": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
},
"readinessDefinition": {
"type": ["null", "string"],
"description": "Path to the template org readiness definition file. Only available in Summer '23 release.",
"description": "Path to the template org readiness definition file.",
"defaultSnippets": [
{
"label": "\"\"",
Expand Down Expand Up @@ -304,7 +304,7 @@
},
"autoInstallDefinition": {
"type": ["null", "string"],
"description": "Path to the auto install configuration file. Only available for app and embeddedapp template types. Available in Winter '21 release.",
"description": "Path to the auto install configuration file. Only available for app and embeddedapp template types.",
"defaultSnippets": [
{
"label": "\"\"",
Expand Down Expand Up @@ -1240,7 +1240,7 @@
},
"onFailure": {
"type": ["null", "object"],
"description": "Controls how to handle failures when processing this asset. Only available in Winter '24 release.",
"description": "Controls how to handle failures when processing this asset.",
"additionalProperties": false,
"properties": {
"defaultStatus": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
"References a list of values, controlled by the `itemsType` variable type.",
"References true or false value.",
"References connectors defined in the org.",
"References calculated insights defined in the org. Only available in Summer '23 release.",
"References calculated insight fields in the org. Only available in Summer '23 release.",
"References data lake objects in the org. Only available in Summer '23 release.",
"References data lake object fields in the org. Only available in Summer '23 release.",
"References data model objects in the org. Only available in Summer '23 release.",
"References data model object fields in the org. Only available in Summer '23 release.",
"References calculated insights defined in the org.",
"References calculated insight fields in the org.",
"References data lake objects in the org.",
"References data lake object fields in the org.",
"References data model objects in the org.",
"References data model object fields in the org.",
"References fields from datasets in the org.",
"References date fields from datasets in the org.",
"References dimensions from dataset in the org.",
Expand Down Expand Up @@ -216,7 +216,7 @@
"enumsLabels": {
"type": ["array", "null"],
"minItems": 0,
"description": "The optional display labels for the enumerated values. Only available in Summer '23 release.",
"description": "The optional display labels for the enumerated values.",
"items": {
"type": ["string", "null"]
},
Expand Down
1 change: 1 addition & 0 deletions packages/analyticsdx-template-lint/test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export class SchemaErrors {
(error.keyword === 'const' ||
error.keyword === 'pattern' ||
error.keyword === 'oneOf' ||
error.keyword === 'anyOf' ||
error.keyword === 'type' ||
error.keyword === 'enum' ||
error.keyword === 'not' ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ describe('readiness-schema.json finds errors in', () => {
'definition.sobject.error',
'definition.sobject.sobject',
'definition.sobject.filters[0].field',
'definition.sobject.valueOnError',
'definition.dataset.dataset',
'definition.dataset.valueOnError',
'definition.appDataset.dataset',
'definition.datacloud.object'
'definition.appDataset.valueOnError',
'definition.datacloud.object',
'definition.datacloud.valueOnError',
'definition.prefs1.valueOnError',
'definition.prefs2.valueOnError.name',
'definition.access.valueOnError'
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,40 @@
"operator": "Equal",
"value": ""
}
]
],
"valueOnError": "only numbers"
},
"dataset": {
"type": "OrgDatasetRowCount",
"dataset": ""
"dataset": "",
"valueOnError": "only numbers"
},
"appDataset": {
"type": "AppDatasetRowCount",
"dataset": ""
"dataset": "",
"valueOnError": "only numbers"
},
"datacloud": {
"type": "DataCloudRowCount",
"object": ""
"object": "",
"valueOnError": "only numbers"
},
"prefs1": {
"type": "OrgPreferenceCheck",
"names": ["name"],
"valueOnError": "only object"
},
"prefs2": {
"type": "OrgPreferenceCheck",
"names": ["name"],
"valueOnError": {
"name": "only booleans"
}
},
"access": {
"type": "AccessCheck",
"expression": "foo",
"valueOnError": "only boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"failMessage": "${Readiness.orgPrefs.someName} Nope!",
"successMessage": "${Readiness.orgPrefs.someName} Yep!",
"type": "OrgPreferenceCheck"
},
{
"expression": "${Readiness.access}",
"failMessage": "${Readiness.access} Nope!",
"successMessage": "${Readiness.access} Yep!",
"type": "AccessCheck"
}
],
"definition": {
Expand All @@ -59,6 +65,10 @@
"strArg": "value",
"numArg": 100,
"arrayArg": ["${Variables.a"]
},
"valueOnError": {
"foo": "bar",
"baz": [42]
}
},
"accountCount": {
Expand Down Expand Up @@ -110,12 +120,14 @@
"operator": "${Variables.op}",
"value": "1"
}
]
],
"valueOnError": -1
},
"orgDatasetCount": {
"type": "OrgDatasetRowCount",
"dataset": "${Variable.selectedDS.datasetId}",
"filters": []
"filters": [],
"valueOnError": 0
},
"dataCloudCount": {
"type": "DataCloudRowCount",
Expand All @@ -126,7 +138,8 @@
"operator": "Equal",
"value": ""
}
]
],
"valueOnError": 10000000
},
"appDatasetCount": {
"type": "AppDatasetRowCount",
Expand All @@ -137,11 +150,21 @@
"operator": "Equal",
"value": "foo"
}
]
],
"valueOnError": 42
},
"orgPrefs": {
"type": "OrgPreferenceCheck",
"names": ["prefName", "prefName2"]
"names": ["prefName", "prefName2"],
"valueOnError": {
"prefName": true,
"prefName2": false
}
},
"access": {
"type": "AccessCheck",
"expression": "foo",
"valueOnError": false
}
}
}

0 comments on commit 78f77e9

Please sign in to comment.