@osdk/maker 0.15.0-beta.5 → 0.15.0-beta.6
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 +6 -0
- package/build/browser/api/defineObject.js +40 -5
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/test/objects.test.js +401 -0
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/cjs/index.cjs +32 -6
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/api/defineObject.js +40 -5
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/test/objects.test.js +401 -0
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ import { defineOntology } from "../api/defineOntology.js";
|
|
|
24
24
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
25
25
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
26
26
|
export default async function main(args = process.argv) {
|
|
27
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.15.0-beta.
|
|
27
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.15.0-beta.6" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
28
28
|
input: {
|
|
29
29
|
alias: "i",
|
|
30
30
|
describe: "Input file",
|
package/build/cjs/index.cjs
CHANGED
|
@@ -405,16 +405,38 @@ function validateDerivedDatasource(objectDef, datasource) {
|
|
|
405
405
|
});
|
|
406
406
|
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
407
407
|
if (isLinkedProperties) {
|
|
408
|
-
validateLinkedProperties(datasource);
|
|
408
|
+
validateLinkedProperties(datasource, objectDef);
|
|
409
409
|
} else {
|
|
410
410
|
validateAggregations(datasource, objectDef);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
+
function getPropertiesForValidation(linkObject, objectDef) {
|
|
414
|
+
const targetApiName = typeof linkObject === "string" ? linkObject : linkObject.apiName;
|
|
415
|
+
const selfApiName = namespace + objectDef.apiName;
|
|
416
|
+
if (targetApiName === selfApiName) {
|
|
417
|
+
return {
|
|
418
|
+
apiName: selfApiName,
|
|
419
|
+
hasProperty: (propName) => objectDef.properties?.[propName] !== void 0
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
const {
|
|
423
|
+
apiName,
|
|
424
|
+
object
|
|
425
|
+
} = getObject(linkObject);
|
|
426
|
+
return {
|
|
427
|
+
apiName,
|
|
428
|
+
hasProperty: (propName) => object.properties?.find((p) => p.apiName === propName) !== void 0
|
|
429
|
+
};
|
|
430
|
+
}
|
|
413
431
|
function validateLinkedProperties(datasource, objectDef) {
|
|
414
432
|
const foreignProperties = Object.values(datasource.propertyMapping);
|
|
415
|
-
const
|
|
433
|
+
const targetObject = datasource.linkDefinition.at(-1).linkType.toMany.object;
|
|
434
|
+
const {
|
|
435
|
+
apiName,
|
|
436
|
+
hasProperty
|
|
437
|
+
} = getPropertiesForValidation(targetObject, objectDef);
|
|
416
438
|
foreignProperties.forEach((prop) => {
|
|
417
|
-
!(
|
|
439
|
+
!hasProperty(prop) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${prop}' on object '${apiName}' is not defined`) : invariant7__default.default(false) : void 0;
|
|
418
440
|
});
|
|
419
441
|
}
|
|
420
442
|
function validateAggregations(datasource, objectDef) {
|
|
@@ -440,8 +462,12 @@ function validateAggregations(datasource, objectDef) {
|
|
|
440
462
|
}
|
|
441
463
|
if (agg.type !== "count") {
|
|
442
464
|
const foreignProperty = agg.property;
|
|
443
|
-
const
|
|
444
|
-
|
|
465
|
+
const targetObject = datasource.linkDefinition.at(-1).linkType.toMany.object;
|
|
466
|
+
const {
|
|
467
|
+
apiName,
|
|
468
|
+
hasProperty
|
|
469
|
+
} = getPropertiesForValidation(targetObject, objectDef);
|
|
470
|
+
!hasProperty(foreignProperty) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${foreignProperty}' on object '${apiName}' is not defined`) : invariant7__default.default(false) : void 0;
|
|
445
471
|
}
|
|
446
472
|
});
|
|
447
473
|
}
|
|
@@ -2081,7 +2107,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2081
2107
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2082
2108
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2083
2109
|
async function main(args = process.argv) {
|
|
2084
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.
|
|
2110
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.6").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2085
2111
|
input: {
|
|
2086
2112
|
alias: "i",
|
|
2087
2113
|
describe: "Input file",
|