@osdk/maker 0.14.0-beta.2 → 0.14.0-beta.4
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.
- package/CHANGELOG.md +20 -0
- package/build/browser/api/defineAction.js +121 -413
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +69 -0
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateObjectAction.js +76 -0
- package/build/browser/api/defineCreateObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js +92 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/browser/api/defineDeleteObjectAction.js +56 -0
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
- package/build/browser/api/defineModifyInterfaceObjectAction.js +68 -0
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineModifyObjectAction.js +91 -0
- package/build/browser/api/defineModifyObjectAction.js.map +1 -0
- package/build/browser/api/test/actions.test.js +12014 -0
- package/build/browser/api/test/actions.test.js.map +1 -0
- package/build/browser/api/test/interfaces.test.js +924 -0
- package/build/browser/api/test/interfaces.test.js.map +1 -0
- package/build/browser/api/test/links.test.js +1974 -0
- package/build/browser/api/test/links.test.js.map +1 -0
- package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/browser/api/test/markingconstraint.test.js.map +1 -0
- package/build/browser/api/test/misc.test.js +1058 -0
- package/build/browser/api/test/misc.test.js.map +1 -0
- package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/browser/api/test/objectStatus.test.js.map +1 -0
- package/build/browser/api/test/objects.test.js +1494 -0
- package/build/browser/api/test/objects.test.js.map +1 -0
- package/build/browser/api/test/spt.test.js +387 -0
- package/build/browser/api/test/spt.test.js.map +1 -0
- package/build/browser/api/test/valueTypes.test.js +156 -0
- package/build/browser/api/test/valueTypes.test.js.map +1 -0
- package/build/browser/cli/main.js +1 -1
- package/build/browser/index.js +7 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +561 -503
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +27 -13
- package/build/esm/api/defineAction.js +121 -413
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +69 -0
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateObjectAction.js +76 -0
- package/build/esm/api/defineCreateObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js +92 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/esm/api/defineDeleteObjectAction.js +56 -0
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
- package/build/esm/api/defineModifyInterfaceObjectAction.js +68 -0
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineModifyObjectAction.js +91 -0
- package/build/esm/api/defineModifyObjectAction.js.map +1 -0
- package/build/esm/api/test/actions.test.js +12014 -0
- package/build/esm/api/test/actions.test.js.map +1 -0
- package/build/esm/api/test/interfaces.test.js +924 -0
- package/build/esm/api/test/interfaces.test.js.map +1 -0
- package/build/esm/api/test/links.test.js +1974 -0
- package/build/esm/api/test/links.test.js.map +1 -0
- package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/esm/api/test/markingconstraint.test.js.map +1 -0
- package/build/esm/api/test/misc.test.js +1058 -0
- package/build/esm/api/test/misc.test.js.map +1 -0
- package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/esm/api/test/objectStatus.test.js.map +1 -0
- package/build/esm/api/test/objects.test.js +1494 -0
- package/build/esm/api/test/objects.test.js.map +1 -0
- package/build/esm/api/test/spt.test.js +387 -0
- package/build/esm/api/test/spt.test.js.map +1 -0
- package/build/esm/api/test/valueTypes.test.js +156 -0
- package/build/esm/api/test/valueTypes.test.js.map +1 -0
- package/build/esm/cli/main.js +1 -1
- package/build/esm/index.js +7 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/api/defineAction.d.ts +22 -6
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/test/actions.test.d.ts.map +1 -0
- package/build/types/api/test/interfaces.test.d.ts.map +1 -0
- package/build/types/api/test/links.test.d.ts.map +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
- package/build/types/api/test/misc.test.d.ts +1 -0
- package/build/types/api/test/misc.test.d.ts.map +1 -0
- package/build/types/api/test/objectStatus.test.d.ts +1 -0
- package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
- package/build/types/api/test/objects.test.d.ts +1 -0
- package/build/types/api/test/objects.test.d.ts.map +1 -0
- package/build/types/api/test/spt.test.d.ts +1 -0
- package/build/types/api/test/spt.test.d.ts.map +1 -0
- package/build/types/api/test/valueTypes.test.d.ts +1 -0
- package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
- package/build/types/index.d.ts +7 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/build/browser/api/markingconstraint.test.js.map +0 -1
- package/build/browser/api/objectStatus.test.js.map +0 -1
- package/build/browser/api/overall.test.js +0 -14002
- package/build/browser/api/overall.test.js.map +0 -1
- package/build/esm/api/markingconstraint.test.js.map +0 -1
- package/build/esm/api/objectStatus.test.js.map +0 -1
- package/build/esm/api/overall.test.js +0 -14002
- package/build/esm/api/overall.test.js.map +0 -1
- package/build/types/api/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/overall.test.d.ts.map +0 -1
- /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
- /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
- /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
package/build/cjs/index.cjs
CHANGED
|
@@ -1705,7 +1705,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
1705
1705
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1706
1706
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1707
1707
|
async function main(args = process.argv) {
|
|
1708
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.
|
|
1708
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.4").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1709
1709
|
input: {
|
|
1710
1710
|
alias: "i",
|
|
1711
1711
|
describe: "Input file",
|
|
@@ -1796,29 +1796,6 @@ function addDependency(namespaceNoDot, fileInPackage) {
|
|
|
1796
1796
|
const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1797
1797
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1798
1798
|
}
|
|
1799
|
-
function convertMappingValue(value) {
|
|
1800
|
-
switch (value.type) {
|
|
1801
|
-
case "uuid":
|
|
1802
|
-
return {
|
|
1803
|
-
type: "uniqueIdentifier",
|
|
1804
|
-
uniqueIdentifier: {
|
|
1805
|
-
linkId: value.linkId ?? crypto.randomUUID()
|
|
1806
|
-
}
|
|
1807
|
-
};
|
|
1808
|
-
case "currentTime":
|
|
1809
|
-
return {
|
|
1810
|
-
type: "currentTime",
|
|
1811
|
-
currentTime: {}
|
|
1812
|
-
};
|
|
1813
|
-
case "currentUser":
|
|
1814
|
-
return {
|
|
1815
|
-
type: "currentUser",
|
|
1816
|
-
currentUser: {}
|
|
1817
|
-
};
|
|
1818
|
-
default:
|
|
1819
|
-
return value;
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
1799
|
|
|
1823
1800
|
// src/api/action/ActionParameterType.ts
|
|
1824
1801
|
function isActionParameterTypePrimitive(type) {
|
|
@@ -1828,383 +1805,8 @@ function isActionParameterTypePrimitive(type) {
|
|
|
1828
1805
|
// src/api/defineAction.ts
|
|
1829
1806
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1830
1807
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1834
|
-
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the create action because they are structs`);
|
|
1835
|
-
}
|
|
1836
|
-
return defineAction({
|
|
1837
|
-
apiName: `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1838
|
-
displayName: `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
1839
|
-
parameters: [{
|
|
1840
|
-
id: "objectTypeParameter",
|
|
1841
|
-
displayName: "Object type to create",
|
|
1842
|
-
type: {
|
|
1843
|
-
type: "objectTypeReference",
|
|
1844
|
-
objectTypeReference: {
|
|
1845
|
-
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1846
|
-
}
|
|
1847
|
-
},
|
|
1848
|
-
validation: {
|
|
1849
|
-
required: true,
|
|
1850
|
-
allowedValues: def.objectType === void 0 ? {
|
|
1851
|
-
type: "objectTypeReference",
|
|
1852
|
-
interfaceTypes: [def.interfaceType.apiName]
|
|
1853
|
-
} : {
|
|
1854
|
-
type: "oneOf",
|
|
1855
|
-
oneOf: [{
|
|
1856
|
-
label: def.objectType.displayName,
|
|
1857
|
-
value: {
|
|
1858
|
-
type: "objectType",
|
|
1859
|
-
objectType: {
|
|
1860
|
-
objectTypeId: def.objectType.apiName
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
}]
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
}, ...allProperties.map(([id, prop]) => ({
|
|
1867
|
-
id,
|
|
1868
|
-
displayName: prop.sharedPropertyType.displayName ?? prop.sharedPropertyType.nonNameSpacedApiName,
|
|
1869
|
-
type: extractActionParameterType(prop.sharedPropertyType),
|
|
1870
|
-
typeClasses: prop.sharedPropertyType.typeClasses ?? [],
|
|
1871
|
-
validation: {
|
|
1872
|
-
required: prop.sharedPropertyType.array ?? false ? {
|
|
1873
|
-
listLength: {}
|
|
1874
|
-
} : prop.required,
|
|
1875
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1876
|
-
}
|
|
1877
|
-
}))],
|
|
1878
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1879
|
-
entities: {
|
|
1880
|
-
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1881
|
-
affectedObjectTypes: [],
|
|
1882
|
-
affectedLinkTypes: [],
|
|
1883
|
-
typeGroups: []
|
|
1884
|
-
},
|
|
1885
|
-
rules: [{
|
|
1886
|
-
type: "addInterfaceRule",
|
|
1887
|
-
addInterfaceRule: {
|
|
1888
|
-
interfaceApiName: def.interfaceType.apiName,
|
|
1889
|
-
objectTypeParameter: "objectTypeParameter",
|
|
1890
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1891
|
-
type: "parameterId",
|
|
1892
|
-
parameterId: id
|
|
1893
|
-
}]))
|
|
1894
|
-
}
|
|
1895
|
-
}],
|
|
1896
|
-
...def.validation ? {
|
|
1897
|
-
validation: convertValidationRule(def.validation)
|
|
1898
|
-
} : {}
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
1901
|
-
function defineCreateObjectAction(def) {
|
|
1902
|
-
validateActionParameters(def);
|
|
1903
|
-
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type));
|
|
1904
|
-
const parameterNames = new Set(propertyParameters);
|
|
1905
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
1906
|
-
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
1907
|
-
if (def.parameterOrdering) {
|
|
1908
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
1909
|
-
}
|
|
1910
|
-
const parameters = createParameters(def, parameterNames);
|
|
1911
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1912
|
-
return defineAction({
|
|
1913
|
-
apiName: actionApiName,
|
|
1914
|
-
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
1915
|
-
parameters,
|
|
1916
|
-
status: def.status ?? "active",
|
|
1917
|
-
entities: {
|
|
1918
|
-
affectedInterfaceTypes: [],
|
|
1919
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
1920
|
-
affectedLinkTypes: [],
|
|
1921
|
-
typeGroups: []
|
|
1922
|
-
},
|
|
1923
|
-
rules: [{
|
|
1924
|
-
type: "addObjectRule",
|
|
1925
|
-
addObjectRule: {
|
|
1926
|
-
objectTypeId: def.objectType.apiName,
|
|
1927
|
-
propertyValues: {
|
|
1928
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
1929
|
-
type: "parameterId",
|
|
1930
|
-
parameterId: p
|
|
1931
|
-
}])),
|
|
1932
|
-
...mappings
|
|
1933
|
-
},
|
|
1934
|
-
structFieldValues: {}
|
|
1935
|
-
}
|
|
1936
|
-
}],
|
|
1937
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1938
|
-
...def.actionLevelValidation ? {
|
|
1939
|
-
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
1940
|
-
} : {},
|
|
1941
|
-
...def.defaultFormat && {
|
|
1942
|
-
defaultFormat: def.defaultFormat
|
|
1943
|
-
},
|
|
1944
|
-
...def.enableLayoutSwitch && {
|
|
1945
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
1946
|
-
},
|
|
1947
|
-
...def.displayAndFormat && {
|
|
1948
|
-
displayAndFormat: def.displayAndFormat
|
|
1949
|
-
},
|
|
1950
|
-
...def.sections && {
|
|
1951
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
1952
|
-
},
|
|
1953
|
-
...def.submissionMetadata && {
|
|
1954
|
-
submissionMetadata: def.submissionMetadata
|
|
1955
|
-
}
|
|
1956
|
-
});
|
|
1957
|
-
}
|
|
1958
|
-
function defineModifyInterfaceObjectAction(def) {
|
|
1959
|
-
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1960
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1961
|
-
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1962
|
-
}
|
|
1963
|
-
return defineAction({
|
|
1964
|
-
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1965
|
-
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1966
|
-
parameters: [{
|
|
1967
|
-
id: "interfaceObjectToModifyParameter",
|
|
1968
|
-
displayName: "Object type to modify",
|
|
1969
|
-
type: {
|
|
1970
|
-
type: "interfaceReference",
|
|
1971
|
-
interfaceReference: {
|
|
1972
|
-
interfaceTypeRid: def.interfaceType.apiName
|
|
1973
|
-
}
|
|
1974
|
-
},
|
|
1975
|
-
validation: {
|
|
1976
|
-
required: true,
|
|
1977
|
-
allowedValues: def.objectType === void 0 ? {
|
|
1978
|
-
type: "interfaceObjectQuery"
|
|
1979
|
-
} : {
|
|
1980
|
-
type: "oneOf",
|
|
1981
|
-
oneOf: [{
|
|
1982
|
-
label: def.objectType.displayName,
|
|
1983
|
-
value: {
|
|
1984
|
-
type: "objectType",
|
|
1985
|
-
objectType: {
|
|
1986
|
-
objectTypeId: def.objectType.apiName
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
}]
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}, ...allProperties.map(([id, prop]) => ({
|
|
1993
|
-
id,
|
|
1994
|
-
displayName: prop.sharedPropertyType.displayName ?? prop.sharedPropertyType.nonNameSpacedApiName,
|
|
1995
|
-
type: extractActionParameterType(prop.sharedPropertyType),
|
|
1996
|
-
typeClasses: prop.sharedPropertyType.typeClasses ?? [],
|
|
1997
|
-
validation: {
|
|
1998
|
-
required: prop.sharedPropertyType.array ?? false ? {
|
|
1999
|
-
listLength: {}
|
|
2000
|
-
} : prop.required,
|
|
2001
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
2002
|
-
}
|
|
2003
|
-
}))],
|
|
2004
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
2005
|
-
entities: {
|
|
2006
|
-
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2007
|
-
affectedObjectTypes: [],
|
|
2008
|
-
affectedLinkTypes: [],
|
|
2009
|
-
typeGroups: []
|
|
2010
|
-
},
|
|
2011
|
-
rules: [{
|
|
2012
|
-
type: "modifyInterfaceRule",
|
|
2013
|
-
modifyInterfaceRule: {
|
|
2014
|
-
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
2015
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
2016
|
-
type: "parameterId",
|
|
2017
|
-
parameterId: id
|
|
2018
|
-
}]))
|
|
2019
|
-
}
|
|
2020
|
-
}],
|
|
2021
|
-
...def.validation ? {
|
|
2022
|
-
validation: convertValidationRule(def.validation)
|
|
2023
|
-
} : {}
|
|
2024
|
-
});
|
|
2025
|
-
}
|
|
2026
|
-
function defineModifyObjectAction(def) {
|
|
2027
|
-
validateActionParameters(def);
|
|
2028
|
-
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2029
|
-
const parameterNames = new Set(propertyParameters);
|
|
2030
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2031
|
-
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
2032
|
-
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2033
|
-
if (def.parameterOrdering) {
|
|
2034
|
-
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
2035
|
-
def.parameterOrdering = [MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2036
|
-
}
|
|
2037
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2038
|
-
}
|
|
2039
|
-
const parameters = createParameters(def, parameterNames);
|
|
2040
|
-
parameters.forEach((p) => {
|
|
2041
|
-
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2042
|
-
p.defaultValue = {
|
|
2043
|
-
type: "objectParameterPropertyValue",
|
|
2044
|
-
objectParameterPropertyValue: {
|
|
2045
|
-
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
2046
|
-
propertyTypeId: p.id
|
|
2047
|
-
}
|
|
2048
|
-
};
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2052
|
-
return defineAction({
|
|
2053
|
-
apiName: actionApiName,
|
|
2054
|
-
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
2055
|
-
parameters,
|
|
2056
|
-
status: def.status ?? "active",
|
|
2057
|
-
rules: [{
|
|
2058
|
-
type: "modifyObjectRule",
|
|
2059
|
-
modifyObjectRule: {
|
|
2060
|
-
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2061
|
-
propertyValues: {
|
|
2062
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2063
|
-
type: "parameterId",
|
|
2064
|
-
parameterId: p
|
|
2065
|
-
}])),
|
|
2066
|
-
...mappings
|
|
2067
|
-
},
|
|
2068
|
-
structFieldValues: {}
|
|
2069
|
-
}
|
|
2070
|
-
}],
|
|
2071
|
-
entities: {
|
|
2072
|
-
affectedInterfaceTypes: [],
|
|
2073
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2074
|
-
affectedLinkTypes: [],
|
|
2075
|
-
typeGroups: []
|
|
2076
|
-
},
|
|
2077
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2078
|
-
...def.actionLevelValidation ? {
|
|
2079
|
-
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2080
|
-
} : {},
|
|
2081
|
-
...def.defaultFormat && {
|
|
2082
|
-
defaultFormat: def.defaultFormat
|
|
2083
|
-
},
|
|
2084
|
-
...def.enableLayoutSwitch && {
|
|
2085
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2086
|
-
},
|
|
2087
|
-
...def.displayAndFormat && {
|
|
2088
|
-
displayAndFormat: def.displayAndFormat
|
|
2089
|
-
},
|
|
2090
|
-
...def.sections && {
|
|
2091
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2092
|
-
},
|
|
2093
|
-
...def.submissionMetadata && {
|
|
2094
|
-
submissionMetadata: def.submissionMetadata
|
|
2095
|
-
}
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
|
-
function defineDeleteObjectAction(def) {
|
|
2099
|
-
return defineAction({
|
|
2100
|
-
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2101
|
-
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
2102
|
-
parameters: [{
|
|
2103
|
-
id: "objectToDeleteParameter",
|
|
2104
|
-
displayName: "Delete object",
|
|
2105
|
-
type: {
|
|
2106
|
-
type: "objectReference",
|
|
2107
|
-
objectReference: {
|
|
2108
|
-
objectTypeId: def.objectType.apiName
|
|
2109
|
-
}
|
|
2110
|
-
},
|
|
2111
|
-
validation: {
|
|
2112
|
-
required: true,
|
|
2113
|
-
allowedValues: {
|
|
2114
|
-
type: "objectQuery"
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
}],
|
|
2118
|
-
status: def.status ?? "active",
|
|
2119
|
-
rules: [{
|
|
2120
|
-
type: "deleteObjectRule",
|
|
2121
|
-
deleteObjectRule: {
|
|
2122
|
-
objectToDelete: "objectToDeleteParameter"
|
|
2123
|
-
}
|
|
2124
|
-
}],
|
|
2125
|
-
entities: {
|
|
2126
|
-
affectedInterfaceTypes: [],
|
|
2127
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2128
|
-
affectedLinkTypes: [],
|
|
2129
|
-
typeGroups: []
|
|
2130
|
-
},
|
|
2131
|
-
...def.actionLevelValidation ? {
|
|
2132
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2133
|
-
} : {}
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
function defineCreateOrModifyObjectAction(def) {
|
|
2137
|
-
validateActionParameters(def);
|
|
2138
|
-
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2139
|
-
const parameterNames = new Set(propertyParameters);
|
|
2140
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2141
|
-
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2142
|
-
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2143
|
-
if (def.parameterOrdering) {
|
|
2144
|
-
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2145
|
-
def.parameterOrdering = [CREATE_OR_MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2146
|
-
}
|
|
2147
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2148
|
-
}
|
|
2149
|
-
const parameters = createParameters(def, parameterNames);
|
|
2150
|
-
parameters.forEach((p) => {
|
|
2151
|
-
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2152
|
-
p.defaultValue = {
|
|
2153
|
-
type: "objectParameterPropertyValue",
|
|
2154
|
-
objectParameterPropertyValue: {
|
|
2155
|
-
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2156
|
-
propertyTypeId: p.id
|
|
2157
|
-
}
|
|
2158
|
-
};
|
|
2159
|
-
}
|
|
2160
|
-
});
|
|
2161
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2162
|
-
return defineAction({
|
|
2163
|
-
apiName: actionApiName,
|
|
2164
|
-
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2165
|
-
parameters,
|
|
2166
|
-
status: def.status ?? "active",
|
|
2167
|
-
rules: [{
|
|
2168
|
-
type: "addOrModifyObjectRuleV2",
|
|
2169
|
-
addOrModifyObjectRuleV2: {
|
|
2170
|
-
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2171
|
-
propertyValues: {
|
|
2172
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2173
|
-
type: "parameterId",
|
|
2174
|
-
parameterId: p
|
|
2175
|
-
}])),
|
|
2176
|
-
...mappings
|
|
2177
|
-
},
|
|
2178
|
-
structFieldValues: {}
|
|
2179
|
-
}
|
|
2180
|
-
}],
|
|
2181
|
-
entities: {
|
|
2182
|
-
affectedInterfaceTypes: [],
|
|
2183
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2184
|
-
affectedLinkTypes: [],
|
|
2185
|
-
typeGroups: []
|
|
2186
|
-
},
|
|
2187
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2188
|
-
...def.actionLevelValidation ? {
|
|
2189
|
-
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2190
|
-
} : {},
|
|
2191
|
-
...def.defaultFormat && {
|
|
2192
|
-
defaultFormat: def.defaultFormat
|
|
2193
|
-
},
|
|
2194
|
-
...def.enableLayoutSwitch && {
|
|
2195
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2196
|
-
},
|
|
2197
|
-
...def.displayAndFormat && {
|
|
2198
|
-
displayAndFormat: def.displayAndFormat
|
|
2199
|
-
},
|
|
2200
|
-
...def.sections && {
|
|
2201
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2202
|
-
},
|
|
2203
|
-
...def.submissionMetadata && {
|
|
2204
|
-
submissionMetadata: def.submissionMetadata
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
}
|
|
1808
|
+
var CREATE_INTERFACE_OBJECT_PARAMETER = "objectTypeParameter";
|
|
1809
|
+
var MODIFY_INTERFACE_OBJECT_PARAMETER = "interfaceObjectToModifyParameter";
|
|
2208
1810
|
function defineAction(actionDef) {
|
|
2209
1811
|
const apiName = namespace + actionDef.apiName;
|
|
2210
1812
|
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
@@ -2260,11 +1862,36 @@ function defineAction(actionDef) {
|
|
|
2260
1862
|
updateOntology(fullAction);
|
|
2261
1863
|
return fullAction;
|
|
2262
1864
|
}
|
|
2263
|
-
function
|
|
2264
|
-
|
|
1865
|
+
function isPropertyParameter(def, name, type) {
|
|
1866
|
+
return !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
1867
|
+
}
|
|
1868
|
+
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
1869
|
+
const targetParams = getTargetParameters(def, parameterSet);
|
|
1870
|
+
return [...targetParams, ...Array.from(parameterSet).map((id) => ({
|
|
1871
|
+
id,
|
|
1872
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? propertyMap[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
1873
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(propertyMap[id]),
|
|
1874
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
1875
|
+
...def.parameterConfiguration?.[id],
|
|
1876
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(propertyMap[id]?.type)),
|
|
1877
|
+
required: def.parameterConfiguration?.[id].required ?? propertyMap[id]?.nullability?.noNulls ?? false
|
|
1878
|
+
} : {
|
|
1879
|
+
required: propertyMap[id]?.array ?? false ? {
|
|
1880
|
+
listLength: propertyMap[id]?.nullability?.noEmptyCollections ? {
|
|
1881
|
+
min: 1
|
|
1882
|
+
} : {}
|
|
1883
|
+
} : requiredMap?.[id] ?? propertyMap[id]?.nullability?.noNulls ?? false,
|
|
1884
|
+
allowedValues: extractAllowedValuesFromPropertyType(propertyMap[id]?.type)
|
|
1885
|
+
},
|
|
1886
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
1887
|
+
description: def.parameterConfiguration?.[id]?.description
|
|
1888
|
+
}))];
|
|
1889
|
+
}
|
|
1890
|
+
function getTargetParameters(def, parameterSet) {
|
|
1891
|
+
const targetParams = [];
|
|
2265
1892
|
parameterSet.forEach((name) => {
|
|
2266
1893
|
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2267
|
-
|
|
1894
|
+
targetParams.push({
|
|
2268
1895
|
id: MODIFY_OBJECT_PARAMETER,
|
|
2269
1896
|
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2270
1897
|
type: {
|
|
@@ -2286,14 +1913,17 @@ function createParameters(def, parameterSet) {
|
|
|
2286
1913
|
parameterSet.delete(MODIFY_OBJECT_PARAMETER);
|
|
2287
1914
|
}
|
|
2288
1915
|
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2289
|
-
|
|
1916
|
+
targetParams.push({
|
|
2290
1917
|
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2291
1918
|
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2292
1919
|
type: {
|
|
2293
1920
|
type: "objectReference",
|
|
2294
1921
|
objectReference: {
|
|
2295
1922
|
objectTypeId: def.objectType.apiName,
|
|
2296
|
-
maybeCreateObjectOption: !
|
|
1923
|
+
maybeCreateObjectOption: !("primaryKeyOption" in def) ? {
|
|
1924
|
+
type: "autoGenerated",
|
|
1925
|
+
autoGenerated: {}
|
|
1926
|
+
} : def.primaryKeyOption === "autoGenerated" ? {
|
|
2297
1927
|
type: "autoGenerated",
|
|
2298
1928
|
autoGenerated: {}
|
|
2299
1929
|
} : {
|
|
@@ -2314,26 +1944,75 @@ function createParameters(def, parameterSet) {
|
|
|
2314
1944
|
});
|
|
2315
1945
|
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2316
1946
|
}
|
|
1947
|
+
if (name === CREATE_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
1948
|
+
targetParams.push({
|
|
1949
|
+
id: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
1950
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to create",
|
|
1951
|
+
type: {
|
|
1952
|
+
type: "objectTypeReference",
|
|
1953
|
+
objectTypeReference: {
|
|
1954
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1955
|
+
}
|
|
1956
|
+
},
|
|
1957
|
+
validation: {
|
|
1958
|
+
...def.parameterConfiguration?.[name],
|
|
1959
|
+
required: true,
|
|
1960
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1961
|
+
type: "objectTypeReference",
|
|
1962
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
1963
|
+
} : {
|
|
1964
|
+
type: "oneOf",
|
|
1965
|
+
oneOf: [{
|
|
1966
|
+
label: def.objectType.displayName,
|
|
1967
|
+
value: {
|
|
1968
|
+
type: "objectType",
|
|
1969
|
+
objectType: {
|
|
1970
|
+
objectTypeId: def.objectType.apiName
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
}]
|
|
1974
|
+
}
|
|
1975
|
+
},
|
|
1976
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
1977
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
1978
|
+
});
|
|
1979
|
+
parameterSet.delete(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
1980
|
+
}
|
|
1981
|
+
if (name === MODIFY_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
1982
|
+
targetParams.push({
|
|
1983
|
+
id: MODIFY_INTERFACE_OBJECT_PARAMETER,
|
|
1984
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to modify",
|
|
1985
|
+
type: {
|
|
1986
|
+
type: "interfaceReference",
|
|
1987
|
+
interfaceReference: {
|
|
1988
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
1989
|
+
}
|
|
1990
|
+
},
|
|
1991
|
+
validation: {
|
|
1992
|
+
...def.parameterConfiguration?.[name],
|
|
1993
|
+
required: true,
|
|
1994
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1995
|
+
type: "interfaceObjectQuery"
|
|
1996
|
+
} : {
|
|
1997
|
+
type: "oneOf",
|
|
1998
|
+
oneOf: [{
|
|
1999
|
+
label: def.objectType.displayName,
|
|
2000
|
+
value: {
|
|
2001
|
+
type: "objectType",
|
|
2002
|
+
objectType: {
|
|
2003
|
+
objectTypeId: def.objectType.apiName
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
}]
|
|
2007
|
+
}
|
|
2008
|
+
},
|
|
2009
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2010
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2011
|
+
});
|
|
2012
|
+
parameterSet.delete(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
2013
|
+
}
|
|
2317
2014
|
});
|
|
2318
|
-
return
|
|
2319
|
-
id,
|
|
2320
|
-
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2321
|
-
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2322
|
-
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2323
|
-
...def.parameterConfiguration?.[id],
|
|
2324
|
-
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)),
|
|
2325
|
-
required: def.parameterConfiguration?.[id].required ?? def.objectType.properties?.[id]?.nullability?.noNulls ?? false
|
|
2326
|
-
} : {
|
|
2327
|
-
required: def.objectType.properties?.[id].array ?? false ? {
|
|
2328
|
-
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
2329
|
-
min: 1
|
|
2330
|
-
} : {}
|
|
2331
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ?? false,
|
|
2332
|
-
allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
|
|
2333
|
-
},
|
|
2334
|
-
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2335
|
-
description: def.parameterConfiguration?.[id]?.description
|
|
2336
|
-
}))];
|
|
2015
|
+
return targetParams;
|
|
2337
2016
|
}
|
|
2338
2017
|
function referencedParameterIds(actionDef) {
|
|
2339
2018
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2608,90 +2287,344 @@ function convertValidationRule(actionValidation, actionParameters) {
|
|
|
2608
2287
|
}
|
|
2609
2288
|
};
|
|
2610
2289
|
});
|
|
2611
|
-
}
|
|
2612
|
-
function validateActionConfiguration(action) {
|
|
2613
|
-
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
2614
|
-
const parameterMap = action.parameters?.reduce((acc, param) => {
|
|
2615
|
-
acc[param.id] = param;
|
|
2616
|
-
return acc;
|
|
2617
|
-
}, {}) ?? {};
|
|
2618
|
-
const orderedParameters = action.parameterOrdering?.map((id) => parameterMap[id]) ?? action.parameters;
|
|
2619
|
-
orderedParameters?.forEach((param) => {
|
|
2620
|
-
param.validation.conditionalOverrides?.forEach((override) => {
|
|
2621
|
-
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
2622
|
-
});
|
|
2623
|
-
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
2624
|
-
seenParameterIds.add(param.id);
|
|
2290
|
+
}
|
|
2291
|
+
function validateActionConfiguration(action) {
|
|
2292
|
+
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
2293
|
+
const parameterMap = action.parameters?.reduce((acc, param) => {
|
|
2294
|
+
acc[param.id] = param;
|
|
2295
|
+
return acc;
|
|
2296
|
+
}, {}) ?? {};
|
|
2297
|
+
const orderedParameters = action.parameterOrdering?.map((id) => parameterMap[id]) ?? action.parameters;
|
|
2298
|
+
orderedParameters?.forEach((param) => {
|
|
2299
|
+
param.validation.conditionalOverrides?.forEach((override) => {
|
|
2300
|
+
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
2301
|
+
});
|
|
2302
|
+
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
2303
|
+
seenParameterIds.add(param.id);
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
function validateParameterCondition(condition, currentParameterId, seenParameterIds, parameters) {
|
|
2307
|
+
switch (condition.type) {
|
|
2308
|
+
case "parameter":
|
|
2309
|
+
const overrideParamId = condition.parameterId;
|
|
2310
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2311
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant6__default.default(false) : void 0;
|
|
2312
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant6__default.default(false) : void 0;
|
|
2313
|
+
break;
|
|
2314
|
+
case "and":
|
|
2315
|
+
if ("conditions" in condition) {
|
|
2316
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2317
|
+
}
|
|
2318
|
+
break;
|
|
2319
|
+
case "or":
|
|
2320
|
+
if ("conditions" in condition) {
|
|
2321
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2322
|
+
}
|
|
2323
|
+
break;
|
|
2324
|
+
case "comparison":
|
|
2325
|
+
case "group":
|
|
2326
|
+
case "not":
|
|
2327
|
+
case "markings":
|
|
2328
|
+
case "regex":
|
|
2329
|
+
case "redacted":
|
|
2330
|
+
case "true":
|
|
2331
|
+
break;
|
|
2332
|
+
default:
|
|
2333
|
+
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2337
|
+
if (!defaultValue) return;
|
|
2338
|
+
switch (defaultValue.type) {
|
|
2339
|
+
case "objectParameterPropertyValue":
|
|
2340
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2341
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2342
|
+
break;
|
|
2343
|
+
case "staticValue":
|
|
2344
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant6__default.default(false) : void 0;
|
|
2345
|
+
break;
|
|
2346
|
+
case "staticObject":
|
|
2347
|
+
case "interfaceParameterPropertyValue":
|
|
2348
|
+
case "objectQueryPrefill":
|
|
2349
|
+
case "objectQueryPropertyValue":
|
|
2350
|
+
case "objectSetRidPrefill":
|
|
2351
|
+
case "redacted":
|
|
2352
|
+
break;
|
|
2353
|
+
default:
|
|
2354
|
+
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function validateActionParameters(def, properties, name) {
|
|
2358
|
+
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2359
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant6__default.default(false) : void 0;
|
|
2360
|
+
});
|
|
2361
|
+
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2362
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id))) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant6__default.default(false) : void 0;
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
2366
|
+
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}).filter((id) => id !== priorityId), ...properties.filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2367
|
+
}
|
|
2368
|
+
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2369
|
+
const orderingSet = new Set(parameterOrdering);
|
|
2370
|
+
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2371
|
+
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2372
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant6__default.default(false) : void 0;
|
|
2373
|
+
}
|
|
2374
|
+
function isTargetParameter(parameterId) {
|
|
2375
|
+
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
2376
|
+
}
|
|
2377
|
+
function addNamespaceToActionDefinition(def) {
|
|
2378
|
+
def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [isTargetParameter(id) ? id : addNamespaceIfNone(id), config]));
|
|
2379
|
+
def.nonParameterMappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [addNamespaceIfNone(id), value]));
|
|
2380
|
+
def.excludedProperties = def.excludedProperties ?? [].map((id) => addNamespaceIfNone(id));
|
|
2381
|
+
}
|
|
2382
|
+
function convertMappingValue(value) {
|
|
2383
|
+
switch (value.type) {
|
|
2384
|
+
case "uuid":
|
|
2385
|
+
return {
|
|
2386
|
+
type: "uniqueIdentifier",
|
|
2387
|
+
uniqueIdentifier: {
|
|
2388
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
case "currentTime":
|
|
2392
|
+
return {
|
|
2393
|
+
type: "currentTime",
|
|
2394
|
+
currentTime: {}
|
|
2395
|
+
};
|
|
2396
|
+
case "currentUser":
|
|
2397
|
+
return {
|
|
2398
|
+
type: "currentUser",
|
|
2399
|
+
currentUser: {}
|
|
2400
|
+
};
|
|
2401
|
+
default:
|
|
2402
|
+
return value;
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
// src/api/defineCreateInterfaceObjectAction.ts
|
|
2407
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
2408
|
+
addNamespaceToActionDefinition(def);
|
|
2409
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2410
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2411
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
2412
|
+
const parameterNames = new Set(propertyParameters);
|
|
2413
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(isTargetParameter(param) ? param : addNamespaceIfNone(param)));
|
|
2414
|
+
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2415
|
+
const actionApiName = def.apiName ?? `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
2416
|
+
if (def.parameterOrdering) {
|
|
2417
|
+
if (!def.parameterOrdering.includes(CREATE_INTERFACE_OBJECT_PARAMETER)) {
|
|
2418
|
+
def.parameterOrdering.unshift(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2419
|
+
}
|
|
2420
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2421
|
+
}
|
|
2422
|
+
const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2423
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2424
|
+
return defineAction({
|
|
2425
|
+
apiName: actionApiName,
|
|
2426
|
+
displayName: def.displayName ?? `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
2427
|
+
parameters,
|
|
2428
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
2429
|
+
entities: {
|
|
2430
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2431
|
+
affectedObjectTypes: [],
|
|
2432
|
+
affectedLinkTypes: [],
|
|
2433
|
+
typeGroups: []
|
|
2434
|
+
},
|
|
2435
|
+
rules: [{
|
|
2436
|
+
type: "addInterfaceRule",
|
|
2437
|
+
addInterfaceRule: {
|
|
2438
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
2439
|
+
objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2440
|
+
sharedPropertyValues: {
|
|
2441
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
2442
|
+
type: "parameterId",
|
|
2443
|
+
parameterId: id
|
|
2444
|
+
}])),
|
|
2445
|
+
...mappings
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
}],
|
|
2449
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
|
|
2450
|
+
...def.validation ? {
|
|
2451
|
+
validation: convertValidationRule(def.validation)
|
|
2452
|
+
} : {}
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
// src/api/defineCreateObjectAction.ts
|
|
2457
|
+
function defineCreateObjectAction(def) {
|
|
2458
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2459
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type));
|
|
2460
|
+
const parameterNames = new Set(propertyParameters);
|
|
2461
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2462
|
+
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2463
|
+
if (def.parameterOrdering) {
|
|
2464
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2465
|
+
}
|
|
2466
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
2467
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2468
|
+
return defineAction({
|
|
2469
|
+
apiName: actionApiName,
|
|
2470
|
+
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
2471
|
+
parameters,
|
|
2472
|
+
status: def.status ?? "active",
|
|
2473
|
+
entities: {
|
|
2474
|
+
affectedInterfaceTypes: [],
|
|
2475
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2476
|
+
affectedLinkTypes: [],
|
|
2477
|
+
typeGroups: []
|
|
2478
|
+
},
|
|
2479
|
+
rules: [{
|
|
2480
|
+
type: "addObjectRule",
|
|
2481
|
+
addObjectRule: {
|
|
2482
|
+
objectTypeId: def.objectType.apiName,
|
|
2483
|
+
propertyValues: {
|
|
2484
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2485
|
+
type: "parameterId",
|
|
2486
|
+
parameterId: p
|
|
2487
|
+
}])),
|
|
2488
|
+
...mappings
|
|
2489
|
+
},
|
|
2490
|
+
structFieldValues: {}
|
|
2491
|
+
}
|
|
2492
|
+
}],
|
|
2493
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters),
|
|
2494
|
+
...def.actionLevelValidation ? {
|
|
2495
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2496
|
+
} : {},
|
|
2497
|
+
...def.defaultFormat && {
|
|
2498
|
+
defaultFormat: def.defaultFormat
|
|
2499
|
+
},
|
|
2500
|
+
...def.enableLayoutSwitch && {
|
|
2501
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2502
|
+
},
|
|
2503
|
+
...def.displayAndFormat && {
|
|
2504
|
+
displayAndFormat: def.displayAndFormat
|
|
2505
|
+
},
|
|
2506
|
+
...def.sections && {
|
|
2507
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2508
|
+
},
|
|
2509
|
+
...def.submissionMetadata && {
|
|
2510
|
+
submissionMetadata: def.submissionMetadata
|
|
2511
|
+
}
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// src/api/defineCreateOrModifyObjectAction.ts
|
|
2516
|
+
function defineCreateOrModifyObjectAction(def) {
|
|
2517
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2518
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2519
|
+
const parameterNames = new Set(propertyParameters);
|
|
2520
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2521
|
+
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2522
|
+
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2523
|
+
if (def.parameterOrdering) {
|
|
2524
|
+
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2525
|
+
def.parameterOrdering.unshift(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2526
|
+
}
|
|
2527
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2528
|
+
}
|
|
2529
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
2530
|
+
parameters.forEach((p) => {
|
|
2531
|
+
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2532
|
+
p.defaultValue = {
|
|
2533
|
+
type: "objectParameterPropertyValue",
|
|
2534
|
+
objectParameterPropertyValue: {
|
|
2535
|
+
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2536
|
+
propertyTypeId: p.id
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
});
|
|
2541
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2542
|
+
return defineAction({
|
|
2543
|
+
apiName: actionApiName,
|
|
2544
|
+
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2545
|
+
parameters,
|
|
2546
|
+
status: def.status ?? "active",
|
|
2547
|
+
rules: [{
|
|
2548
|
+
type: "addOrModifyObjectRuleV2",
|
|
2549
|
+
addOrModifyObjectRuleV2: {
|
|
2550
|
+
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2551
|
+
propertyValues: {
|
|
2552
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2553
|
+
type: "parameterId",
|
|
2554
|
+
parameterId: p
|
|
2555
|
+
}])),
|
|
2556
|
+
...mappings
|
|
2557
|
+
},
|
|
2558
|
+
structFieldValues: {}
|
|
2559
|
+
}
|
|
2560
|
+
}],
|
|
2561
|
+
entities: {
|
|
2562
|
+
affectedInterfaceTypes: [],
|
|
2563
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2564
|
+
affectedLinkTypes: [],
|
|
2565
|
+
typeGroups: []
|
|
2566
|
+
},
|
|
2567
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2568
|
+
...def.actionLevelValidation ? {
|
|
2569
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2570
|
+
} : {},
|
|
2571
|
+
...def.defaultFormat && {
|
|
2572
|
+
defaultFormat: def.defaultFormat
|
|
2573
|
+
},
|
|
2574
|
+
...def.enableLayoutSwitch && {
|
|
2575
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2576
|
+
},
|
|
2577
|
+
...def.displayAndFormat && {
|
|
2578
|
+
displayAndFormat: def.displayAndFormat
|
|
2579
|
+
},
|
|
2580
|
+
...def.sections && {
|
|
2581
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2582
|
+
},
|
|
2583
|
+
...def.submissionMetadata && {
|
|
2584
|
+
submissionMetadata: def.submissionMetadata
|
|
2585
|
+
}
|
|
2625
2586
|
});
|
|
2626
2587
|
}
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2588
|
+
|
|
2589
|
+
// src/api/defineDeleteObjectAction.ts
|
|
2590
|
+
function defineDeleteObjectAction(def) {
|
|
2591
|
+
return defineAction({
|
|
2592
|
+
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2593
|
+
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
2594
|
+
parameters: [{
|
|
2595
|
+
id: "objectToDeleteParameter",
|
|
2596
|
+
displayName: "Delete object",
|
|
2597
|
+
type: {
|
|
2598
|
+
type: "objectReference",
|
|
2599
|
+
objectReference: {
|
|
2600
|
+
objectTypeId: def.objectType.apiName
|
|
2601
|
+
}
|
|
2602
|
+
},
|
|
2603
|
+
validation: {
|
|
2604
|
+
required: true,
|
|
2605
|
+
allowedValues: {
|
|
2606
|
+
type: "objectQuery"
|
|
2607
|
+
}
|
|
2638
2608
|
}
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2609
|
+
}],
|
|
2610
|
+
status: def.status ?? "active",
|
|
2611
|
+
rules: [{
|
|
2612
|
+
type: "deleteObjectRule",
|
|
2613
|
+
deleteObjectRule: {
|
|
2614
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2643
2615
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2658
|
-
if (!defaultValue) return;
|
|
2659
|
-
switch (defaultValue.type) {
|
|
2660
|
-
case "objectParameterPropertyValue":
|
|
2661
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2662
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2663
|
-
break;
|
|
2664
|
-
case "staticValue":
|
|
2665
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant6__default.default(false) : void 0;
|
|
2666
|
-
break;
|
|
2667
|
-
case "staticObject":
|
|
2668
|
-
case "interfaceParameterPropertyValue":
|
|
2669
|
-
case "objectQueryPrefill":
|
|
2670
|
-
case "objectQueryPropertyValue":
|
|
2671
|
-
case "objectSetRidPrefill":
|
|
2672
|
-
case "redacted":
|
|
2673
|
-
break;
|
|
2674
|
-
default:
|
|
2675
|
-
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
function validateActionParameters(def) {
|
|
2679
|
-
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2680
|
-
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant6__default.default(false) : void 0;
|
|
2681
|
-
});
|
|
2682
|
-
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2683
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2616
|
+
}],
|
|
2617
|
+
entities: {
|
|
2618
|
+
affectedInterfaceTypes: [],
|
|
2619
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2620
|
+
affectedLinkTypes: [],
|
|
2621
|
+
typeGroups: []
|
|
2622
|
+
},
|
|
2623
|
+
...def.actionLevelValidation ? {
|
|
2624
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2625
|
+
} : {}
|
|
2684
2626
|
});
|
|
2685
2627
|
}
|
|
2686
|
-
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
2687
|
-
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}), ...Object.keys(def.objectType.properties ?? {}).filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2688
|
-
}
|
|
2689
|
-
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2690
|
-
const orderingSet = new Set(parameterOrdering);
|
|
2691
|
-
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2692
|
-
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2693
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant6__default.default(false) : void 0;
|
|
2694
|
-
}
|
|
2695
2628
|
function defineSharedPropertyType(sptDef) {
|
|
2696
2629
|
const apiName = namespace + sptDef.apiName;
|
|
2697
2630
|
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${apiName} already exists`) : invariant6__default.default(false) : void 0;
|
|
@@ -2907,6 +2840,129 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
2907
2840
|
typeClasses: []
|
|
2908
2841
|
};
|
|
2909
2842
|
}
|
|
2843
|
+
|
|
2844
|
+
// src/api/defineModifyInterfaceObjectAction.ts
|
|
2845
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
2846
|
+
addNamespaceToActionDefinition(def);
|
|
2847
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2848
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2849
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
2850
|
+
const parameterNames = new Set(propertyParameters);
|
|
2851
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(isTargetParameter(param) ? param : addNamespaceIfNone(param)));
|
|
2852
|
+
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
2853
|
+
const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
2854
|
+
if (def.parameterOrdering) {
|
|
2855
|
+
if (!def.parameterOrdering.includes(MODIFY_INTERFACE_OBJECT_PARAMETER)) {
|
|
2856
|
+
def.parameterOrdering.unshift(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
2857
|
+
}
|
|
2858
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2859
|
+
}
|
|
2860
|
+
const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2861
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2862
|
+
return defineAction({
|
|
2863
|
+
apiName: actionApiName,
|
|
2864
|
+
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
2865
|
+
parameters,
|
|
2866
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
2867
|
+
entities: {
|
|
2868
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2869
|
+
affectedObjectTypes: [],
|
|
2870
|
+
affectedLinkTypes: [],
|
|
2871
|
+
typeGroups: []
|
|
2872
|
+
},
|
|
2873
|
+
rules: [{
|
|
2874
|
+
type: "modifyInterfaceRule",
|
|
2875
|
+
modifyInterfaceRule: {
|
|
2876
|
+
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
2877
|
+
sharedPropertyValues: {
|
|
2878
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
2879
|
+
type: "parameterId",
|
|
2880
|
+
parameterId: id
|
|
2881
|
+
}])),
|
|
2882
|
+
...mappings
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}],
|
|
2886
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
|
|
2887
|
+
...def.validation ? {
|
|
2888
|
+
validation: convertValidationRule(def.validation)
|
|
2889
|
+
} : {}
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
// src/api/defineModifyObjectAction.ts
|
|
2894
|
+
function defineModifyObjectAction(def) {
|
|
2895
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2896
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2897
|
+
const parameterNames = new Set(propertyParameters);
|
|
2898
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2899
|
+
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
2900
|
+
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2901
|
+
if (def.parameterOrdering) {
|
|
2902
|
+
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
2903
|
+
def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);
|
|
2904
|
+
}
|
|
2905
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2906
|
+
}
|
|
2907
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
2908
|
+
parameters.forEach((p) => {
|
|
2909
|
+
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2910
|
+
p.defaultValue = {
|
|
2911
|
+
type: "objectParameterPropertyValue",
|
|
2912
|
+
objectParameterPropertyValue: {
|
|
2913
|
+
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
2914
|
+
propertyTypeId: p.id
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
}
|
|
2918
|
+
});
|
|
2919
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2920
|
+
return defineAction({
|
|
2921
|
+
apiName: actionApiName,
|
|
2922
|
+
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
2923
|
+
parameters,
|
|
2924
|
+
status: def.status ?? "active",
|
|
2925
|
+
rules: [{
|
|
2926
|
+
type: "modifyObjectRule",
|
|
2927
|
+
modifyObjectRule: {
|
|
2928
|
+
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2929
|
+
propertyValues: {
|
|
2930
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2931
|
+
type: "parameterId",
|
|
2932
|
+
parameterId: p
|
|
2933
|
+
}])),
|
|
2934
|
+
...mappings
|
|
2935
|
+
},
|
|
2936
|
+
structFieldValues: {}
|
|
2937
|
+
}
|
|
2938
|
+
}],
|
|
2939
|
+
entities: {
|
|
2940
|
+
affectedInterfaceTypes: [],
|
|
2941
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2942
|
+
affectedLinkTypes: [],
|
|
2943
|
+
typeGroups: []
|
|
2944
|
+
},
|
|
2945
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, MODIFY_OBJECT_PARAMETER),
|
|
2946
|
+
...def.actionLevelValidation ? {
|
|
2947
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2948
|
+
} : {},
|
|
2949
|
+
...def.defaultFormat && {
|
|
2950
|
+
defaultFormat: def.defaultFormat
|
|
2951
|
+
},
|
|
2952
|
+
...def.enableLayoutSwitch && {
|
|
2953
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2954
|
+
},
|
|
2955
|
+
...def.displayAndFormat && {
|
|
2956
|
+
displayAndFormat: def.displayAndFormat
|
|
2957
|
+
},
|
|
2958
|
+
...def.sections && {
|
|
2959
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2960
|
+
},
|
|
2961
|
+
...def.submissionMetadata && {
|
|
2962
|
+
submissionMetadata: def.submissionMetadata
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2910
2966
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
2911
2967
|
switch (true) {
|
|
2912
2968
|
case (typeof valueType === "object" && valueType.type === "array"):
|
|
@@ -3039,7 +3095,9 @@ function wrapWithProxy(entity) {
|
|
|
3039
3095
|
});
|
|
3040
3096
|
}
|
|
3041
3097
|
|
|
3098
|
+
exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
|
|
3042
3099
|
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
3100
|
+
exports.MODIFY_INTERFACE_OBJECT_PARAMETER = MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
3043
3101
|
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
3044
3102
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
3045
3103
|
exports.addDependency = addDependency;
|