@osdk/maker 0.9.0-beta.2 → 0.9.0-beta.21
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 +183 -0
- package/build/browser/api/defineImportSpt.d.ts +10 -0
- package/build/browser/api/defineImportSpt.d.ts.map +1 -0
- package/build/browser/api/defineImportSpt.js +44 -0
- package/build/browser/api/defineImportSpt.js.map +1 -0
- package/build/browser/api/defineInterface.d.ts +11 -0
- package/build/browser/api/defineInterface.d.ts.map +1 -1
- package/build/browser/api/defineInterface.js +38 -11
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts +2 -0
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
- package/build/browser/api/defineInterfaceLinkConstraint.js +2 -2
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/browser/api/defineLink.js +2 -2
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.d.ts.map +1 -1
- package/build/browser/api/defineObject.js +19 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.d.ts +3 -3
- package/build/browser/api/defineOntology.d.ts.map +1 -1
- package/build/browser/api/defineOntology.js +85 -24
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.d.ts +8 -17
- package/build/browser/api/defineValueType.d.ts.map +1 -1
- package/build/browser/api/defineValueType.js +57 -11
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/overall.test.js +351 -60
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/types.d.ts +196 -3
- package/build/browser/api/types.d.ts.map +1 -1
- package/build/browser/cli/main.js +3 -3
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/index.d.ts +1 -0
- package/build/browser/index.d.ts.map +1 -1
- package/build/browser/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/esm/api/defineImportSpt.d.ts +10 -0
- package/build/esm/api/defineImportSpt.d.ts.map +1 -0
- package/build/esm/api/defineImportSpt.js +44 -0
- package/build/esm/api/defineImportSpt.js.map +1 -0
- package/build/esm/api/defineInterface.d.ts +11 -0
- package/build/esm/api/defineInterface.d.ts.map +1 -1
- package/build/esm/api/defineInterface.js +38 -11
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.d.ts +2 -0
- package/build/esm/api/defineInterfaceLinkConstraint.d.ts.map +1 -1
- package/build/esm/api/defineInterfaceLinkConstraint.js +2 -2
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -1
- package/build/esm/api/defineLink.js +2 -2
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.d.ts.map +1 -1
- package/build/esm/api/defineObject.js +19 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.d.ts +3 -3
- package/build/esm/api/defineOntology.d.ts.map +1 -1
- package/build/esm/api/defineOntology.js +85 -24
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.d.ts +8 -17
- package/build/esm/api/defineValueType.d.ts.map +1 -1
- package/build/esm/api/defineValueType.js +57 -11
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/overall.test.js +351 -60
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/types.d.ts +196 -3
- package/build/esm/api/types.d.ts.map +1 -1
- package/build/esm/cli/main.js +3 -3
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/package.json +11 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
package/build/browser/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { default } from "./cli/main.js";
|
|
17
|
+
export { importSharedPropertyType } from "./api/defineImportSpt.js";
|
|
17
18
|
export { defineInterface } from "./api/defineInterface.js";
|
|
18
19
|
export { defineInterfaceLinkConstraint } from "./api/defineInterfaceLinkConstraint.js";
|
|
19
20
|
export { defineSharedPropertyType } from "./api/defineSpt.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","defineInterface","defineInterfaceLinkConstraint","defineSharedPropertyType","defineValueType"],"sources":["index.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport { default as default } from \"./cli/main.js\";\nexport { defineInterface } from \"./api/defineInterface.js\";\nexport { defineInterfaceLinkConstraint } from \"./api/defineInterfaceLinkConstraint.js\";\nexport { defineSharedPropertyType } from \"./api/defineSpt.js\";\nexport { defineValueType } from \"./api/defineValueType.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAkB,QAAQ,eAAe;AAClD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,6BAA6B,QAAQ,wCAAwC;AACtF,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,eAAe,QAAQ,0BAA0B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","importSharedPropertyType","defineInterface","defineInterfaceLinkConstraint","defineSharedPropertyType","defineValueType"],"sources":["index.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport { default as default } from \"./cli/main.js\";\nexport { importSharedPropertyType } from \"./api/defineImportSpt.js\";\nexport { defineInterface } from \"./api/defineInterface.js\";\nexport { defineInterfaceLinkConstraint } from \"./api/defineInterfaceLinkConstraint.js\";\nexport { defineSharedPropertyType } from \"./api/defineSpt.js\";\nexport { defineValueType } from \"./api/defineValueType.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAkB,QAAQ,eAAe;AAClD,SAASC,wBAAwB,QAAQ,0BAA0B;AACnE,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,6BAA6B,QAAQ,wCAAwC;AACtF,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,eAAe,QAAQ,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PropertyTypeType, SharedPropertyType } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation
|
|
4
|
+
*/
|
|
5
|
+
export declare function importSharedPropertyType(opts: {
|
|
6
|
+
apiName: string;
|
|
7
|
+
packageName?: string;
|
|
8
|
+
typeHint: PropertyTypeType;
|
|
9
|
+
}): SharedPropertyType;
|
|
10
|
+
//# sourceMappingURL=defineImportSpt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineImportSpt.d.ts","sourceRoot":"","sources":["../../../src/api/defineImportSpt.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GACA,kBAAkB,CAoBpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import invariant from "tiny-invariant";
|
|
17
|
+
import { ontologyDefinition } from "./defineOntology.js";
|
|
18
|
+
/**
|
|
19
|
+
* Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation
|
|
20
|
+
*/
|
|
21
|
+
export function importSharedPropertyType(opts) {
|
|
22
|
+
const {
|
|
23
|
+
apiName,
|
|
24
|
+
packageName,
|
|
25
|
+
typeHint
|
|
26
|
+
} = opts;
|
|
27
|
+
if (packageName !== undefined) {
|
|
28
|
+
ontologyDefinition.importedTypes.sharedPropertyTypes.push({
|
|
29
|
+
apiName,
|
|
30
|
+
packageName
|
|
31
|
+
});
|
|
32
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name format invalid ends with period") : invariant(false) : void 0;
|
|
33
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Package name includes upper case characters") : invariant(false) : void 0;
|
|
34
|
+
return {
|
|
35
|
+
apiName: packageName + "." + apiName,
|
|
36
|
+
type: typeHint
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
apiName: apiName,
|
|
41
|
+
type: typeHint
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=defineImportSpt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineImportSpt.js","names":["invariant","ontologyDefinition","importSharedPropertyType","opts","apiName","packageName","typeHint","undefined","importedTypes","sharedPropertyTypes","push","endsWith","process","env","NODE_ENV","match","type"],"sources":["defineImportSpt.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(opts) {\n const { apiName, packageName, typeHint } = opts;\n if (packageName !== undefined) {\n ontologyDefinition.importedTypes.sharedPropertyTypes.push({\n apiName,\n packageName,\n });\n invariant(!packageName.endsWith(\".\"), \"Package name format invalid ends with period\");\n invariant(packageName.match(\"[A-Z]\") == null, \"Package name includes upper case characters\");\n return { apiName: packageName + \".\" + apiName, type: typeHint };\n }\n return { apiName: apiName, type: typeHint };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAACC,IAAI,EAAE;EAC3C,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAS,CAAC,GAAGH,IAAI;EAC/C,IAAIE,WAAW,KAAKE,SAAS,EAAE;IAC3BN,kBAAkB,CAACO,aAAa,CAACC,mBAAmB,CAACC,IAAI,CAAC;MACtDN,OAAO;MACPC;IACJ,CAAC,CAAC;IACF,CAAU,CAACA,WAAW,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAApCd,SAAS,QAA6B,8CAA8C,IAApFA,SAAS;IACT,EAAUK,WAAW,CAACU,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAA5Cd,SAAS,QAAqC,6CAA6C,IAA3FA,SAAS;IACT,OAAO;MAAEI,OAAO,EAAEC,WAAW,GAAG,GAAG,GAAGD,OAAO;MAAEY,IAAI,EAAEV;IAAS,CAAC;EACnE;EACA,OAAO;IAAEF,OAAO,EAAEA,OAAO;IAAEY,IAAI,EAAEV;EAAS,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { BlueprintIcon } from "./iconNames.js";
|
|
2
2
|
import type { InterfaceType, PropertyTypeType, SharedPropertyType } from "./types.js";
|
|
3
|
+
type SimplifiedInterfaceTypeStatus = {
|
|
4
|
+
type: "deprecated";
|
|
5
|
+
message: string;
|
|
6
|
+
deadline: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "active";
|
|
9
|
+
} | {
|
|
10
|
+
type: "experimental";
|
|
11
|
+
};
|
|
3
12
|
export declare function defineInterface(opts: {
|
|
4
13
|
apiName: string;
|
|
5
14
|
displayName?: string;
|
|
@@ -8,7 +17,9 @@ export declare function defineInterface(opts: {
|
|
|
8
17
|
locator: BlueprintIcon;
|
|
9
18
|
color: string;
|
|
10
19
|
};
|
|
20
|
+
status?: SimplifiedInterfaceTypeStatus;
|
|
11
21
|
properties?: Record<string, SharedPropertyType | PropertyTypeType>;
|
|
12
22
|
extends?: InterfaceType | InterfaceType[] | string | string[];
|
|
13
23
|
}): InterfaceType;
|
|
24
|
+
export {};
|
|
14
25
|
//# sourceMappingURL=defineInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterface.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterface.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,
|
|
1
|
+
{"version":3,"file":"defineInterface.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterface.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EAEb,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,KAAK,6BAA6B,GAC9B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7B,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,MAAM,CAAC,EAAE,6BAA6B,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,kBAAkB,GAAG,gBAAgB,CACtC,CAAC;IAEF,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/D,GACA,aAAa,CA4Ff"}
|
|
@@ -18,10 +18,10 @@ import { namespace, ontologyDefinition } from "./defineOntology.js";
|
|
|
18
18
|
import { defineSharedPropertyType } from "./defineSpt.js";
|
|
19
19
|
export function defineInterface(opts) {
|
|
20
20
|
const apiName = namespace + opts.apiName;
|
|
21
|
-
!(ontologyDefinition.interfaceTypes[apiName] === undefined) ? invariant(false, `Interface ${apiName} already exists`) : void 0;
|
|
21
|
+
!(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
|
|
22
22
|
const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {
|
|
23
|
-
if (typeof type === "string") {
|
|
24
|
-
!
|
|
23
|
+
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
24
|
+
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;
|
|
25
25
|
const spt = defineSharedPropertyType({
|
|
26
26
|
apiName,
|
|
27
27
|
displayName: apiName,
|
|
@@ -30,10 +30,11 @@ export function defineInterface(opts) {
|
|
|
30
30
|
});
|
|
31
31
|
return [apiName, spt];
|
|
32
32
|
} else {
|
|
33
|
-
|
|
33
|
+
const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(".") + 1);
|
|
34
|
+
!(namespace + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
34
35
|
key: apiName,
|
|
35
36
|
apiName: type.apiName
|
|
36
|
-
})}`) : void 0;
|
|
37
|
+
})}`) : invariant(false) : void 0;
|
|
37
38
|
return [apiName, type];
|
|
38
39
|
}
|
|
39
40
|
}));
|
|
@@ -49,6 +50,10 @@ export function defineInterface(opts) {
|
|
|
49
50
|
extendsInterfaces = opts.extends.map(item => item.apiName);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
53
|
+
const status = mapSimplifiedStatusToInterfaceTypeStatus(opts.status ?? {
|
|
54
|
+
type: "active"
|
|
55
|
+
});
|
|
56
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant(false, `Deprecated status must include message and deadline properties.`) : invariant(false) : void 0;
|
|
52
57
|
const a = {
|
|
53
58
|
apiName,
|
|
54
59
|
displayMetadata: {
|
|
@@ -65,14 +70,36 @@ export function defineInterface(opts) {
|
|
|
65
70
|
extendsInterfaces: extendsInterfaces,
|
|
66
71
|
links: [],
|
|
67
72
|
properties,
|
|
68
|
-
status
|
|
69
|
-
type: "active",
|
|
70
|
-
active: {}
|
|
71
|
-
}
|
|
73
|
+
status
|
|
72
74
|
};
|
|
73
75
|
return ontologyDefinition.interfaceTypes[apiName] = a;
|
|
74
76
|
}
|
|
75
|
-
function
|
|
76
|
-
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
77
|
+
function isPropertyTypeType(v) {
|
|
78
|
+
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || typeof v === "object" && v.type === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
79
|
+
}
|
|
80
|
+
function mapSimplifiedStatusToInterfaceTypeStatus(status) {
|
|
81
|
+
switch (status.type) {
|
|
82
|
+
case "deprecated":
|
|
83
|
+
return {
|
|
84
|
+
type: "deprecated",
|
|
85
|
+
deprecated: {
|
|
86
|
+
message: status.message,
|
|
87
|
+
deadline: status.deadline,
|
|
88
|
+
replacedBy: undefined
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
case "active":
|
|
92
|
+
return {
|
|
93
|
+
type: "active",
|
|
94
|
+
active: {}
|
|
95
|
+
};
|
|
96
|
+
case "experimental":
|
|
97
|
+
return {
|
|
98
|
+
type: "experimental",
|
|
99
|
+
experimental: {}
|
|
100
|
+
};
|
|
101
|
+
default:
|
|
102
|
+
throw new Error(`Invalid status type: ${status.type}`);
|
|
103
|
+
}
|
|
77
104
|
}
|
|
78
105
|
//# sourceMappingURL=defineInterface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","properties","Object","fromEntries","entries","map","type","
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","process","env","NODE_ENV","properties","Object","fromEntries","entries","map","type","isPropertyTypeType","spt","displayName","array","unNamespacedTypeApiName","slice","lastIndexOf","JSON","stringify","key","extendsInterfaces","extends","Array","isArray","every","item","status","mapSimplifiedStatusToInterfaceTypeStatus","deprecated","message","deadline","a","displayMetadata","description","icon","blueprint","color","locator","links","v","replacedBy","active","experimental","Error"],"sources":["defineInterface.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.interfaceTypes[apiName] === undefined, `Interface ${apiName} already exists`);\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\"\n || (typeof type === \"object\" && !(\"apiName\" in type))) {\n invariant(isPropertyTypeType(type), `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`);\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n }\n else {\n const unNamespacedTypeApiName = type.apiName.slice(type.apiName.lastIndexOf(\".\") + 1);\n invariant(namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName, `property key and it's apiName must be identical. ${JSON.stringify({ key: apiName, apiName: type.apiName })}`);\n return [apiName, type];\n }\n }));\n let extendsInterfaces = [];\n if (opts.extends) {\n if (typeof opts.extends === \"string\") {\n extendsInterfaces = [opts.extends];\n }\n else if (Array.isArray(opts.extends)\n && opts.extends.every(item => typeof item === \"string\")) {\n extendsInterfaces = opts.extends;\n }\n else if (opts.extends.apiName !== undefined) {\n extendsInterfaces = [opts.extends.apiName];\n }\n else {\n extendsInterfaces = opts.extends.map(item => item.apiName);\n }\n }\n const status = mapSimplifiedStatusToInterfaceTypeStatus(opts.status ?? { type: \"active\" });\n invariant(status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline), `Deprecated status must include message and deadline properties.`);\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: extendsInterfaces,\n links: [],\n properties,\n status,\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isPropertyTypeType(v) {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\"\n || (typeof v === \"object\" && v.type === \"marking\")\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\nfunction mapSimplifiedStatusToInterfaceTypeStatus(status) {\n switch (status.type) {\n case \"deprecated\":\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n replacedBy: undefined,\n },\n };\n case \"active\":\n return {\n type: \"active\",\n active: {},\n };\n case \"experimental\":\n return {\n type: \"experimental\",\n experimental: {},\n };\n default:\n throw new Error(`Invalid status type: ${status.type}`);\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ type Many = {
|
|
|
7
7
|
toOne?: never;
|
|
8
8
|
displayName?: string;
|
|
9
9
|
description?: string;
|
|
10
|
+
required?: boolean;
|
|
10
11
|
};
|
|
11
12
|
type One = {
|
|
12
13
|
apiName: string;
|
|
@@ -15,6 +16,7 @@ type One = {
|
|
|
15
16
|
toMany?: never;
|
|
16
17
|
displayName?: string;
|
|
17
18
|
description?: string;
|
|
19
|
+
required?: boolean;
|
|
18
20
|
};
|
|
19
21
|
export declare function defineInterfaceLinkConstraint(linkDef: One | Many): void;
|
|
20
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterfaceLinkConstraint.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterfaceLinkConstraint.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,sBAAsB,GAAG,MAAM,GAAG,aAAa,CAAC;AAErD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterfaceLinkConstraint.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,sBAAsB,GAAG,MAAM,GAAG,aAAa,CAAC;AAErD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,GAAG,GAAG,IAAI,QAgBpB"}
|
|
@@ -17,12 +17,12 @@ import invariant from "tiny-invariant";
|
|
|
17
17
|
import { namespace } from "./defineOntology.js";
|
|
18
18
|
export function defineInterfaceLinkConstraint(linkDef) {
|
|
19
19
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
20
|
-
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : void 0;
|
|
20
|
+
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;
|
|
21
21
|
linkDef.from.links.push({
|
|
22
22
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
23
23
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
24
24
|
metadata: fromLinkMeta,
|
|
25
|
-
required:
|
|
25
|
+
required: linkDef.required ?? true
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function getLinkedType(t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n invariant(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`);\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required:
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","process","env","NODE_ENV","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n invariant(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`);\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: linkDef.required ?? true,\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\nfunction withDefaults({ apiName, description, displayName }) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAO,SAASC,6BAA6BA,CAACC,OAAO,EAAE;EACnD,MAAMC,YAAY,GAAGC,WAAW,CAACF,OAAO,CAAC;EACzC,EAAUA,OAAO,CAACG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAACC,OAAO,KAAKP,YAAY,CAACO,OAAO,CAAC,IAC5E,IAAI,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADXd,SAAS,QACI,qBAAqBI,YAAY,CAACO,OAAO,sBAAsBR,OAAO,CAACQ,OAAO,EAAE,IAD7FX,SAAS;EAETG,OAAO,CAACG,IAAI,CAACC,KAAK,CAACQ,IAAI,CAAC;IACpBC,WAAW,EAAEb,OAAO,CAACc,MAAM,GAAG,MAAM,GAAG,QAAQ;IAC/CC,kBAAkB,EAAEC,aAAa,CAAChB,OAAO,CAACc,MAAM,IAAId,OAAO,CAACiB,KAAK,CAAC;IAClEV,QAAQ,EAAEN,YAAY;IACtBiB,QAAQ,EAAElB,OAAO,CAACkB,QAAQ,IAAI;EAClC,CAAC,CAAC;AACN;AACA,SAASF,aAAaA,CAACG,CAAC,EAAE;EACtB,OAAO;IACHC,IAAI,EAAE,eAAe;IACrBC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACX;EACjD,CAAC;AACL;AACA,SAASN,WAAWA,CAACoB,IAAI,EAAE;EACvB,OAAO,OAAOA,IAAI,KAAK,QAAQ,GACzBC,YAAY,CAAC;IAAEf,OAAO,EAAEV,SAAS,GAAGwB;EAAK,CAAC,CAAC,GAC3CC,YAAY,CAACD,IAAI,CAAC;AAC5B;AACA,SAASC,YAAYA,CAAC;EAAEf,OAAO;EAAEgB,WAAW;EAAEC;AAAY,CAAC,EAAE;EACzD,OAAO;IACHjB,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5BiB,WAAW,EAAEA,WAAW,IAAIjB,OAAO;IACnCgB,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAIjB;EAC/C,CAAC;AACL","ignoreList":[]}
|
|
@@ -18,8 +18,8 @@ export function defineLink(from, opts) {
|
|
|
18
18
|
const apiName = opts.one ?? opts.many;
|
|
19
19
|
const toApiName = opts.reverse.one ?? opts.reverse.many;
|
|
20
20
|
const to = opts.to;
|
|
21
|
-
!(from.linkTypes[apiName] == null) ? invariant(false, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`) : void 0;
|
|
22
|
-
!(from.linkTypes[toApiName] == null) ? invariant(false, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`) : void 0;
|
|
21
|
+
!(from.linkTypes[apiName] == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`) : invariant(false) : void 0;
|
|
22
|
+
!(from.linkTypes[toApiName] == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`) : invariant(false) : void 0;
|
|
23
23
|
from.linkTypes[apiName] = {
|
|
24
24
|
cardinality: "ONE",
|
|
25
25
|
displayName: apiName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineLink.js","names":["invariant","defineLink","from","opts","apiName","one","many","toApiName","reverse","to","linkTypes","data","objectType","cardinality","displayName","objectTypeApiName","status"],"sources":["defineLink.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nexport function defineLink(from, opts) {\n const apiName = opts.one ?? opts.many;\n const toApiName = opts.reverse.one ?? opts.reverse.many;\n const to = opts.to;\n invariant(from.linkTypes[apiName] == null, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`);\n invariant(from.linkTypes[toApiName] == null, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`);\n from.linkTypes[apiName] = {\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: to.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n to.linkTypes[toApiName] = {\n apiName: toApiName,\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: from.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,UAAUA,CAACC,IAAI,EAAEC,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAGD,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACG,IAAI;EACrC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,OAAO,CAACH,GAAG,IAAIF,IAAI,CAACK,OAAO,CAACF,IAAI;EACvD,MAAMG,EAAE,GAAGN,IAAI,CAACM,EAAE;EAClB,EAAUP,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"defineLink.js","names":["invariant","defineLink","from","opts","apiName","one","many","toApiName","reverse","to","linkTypes","process","env","NODE_ENV","data","objectType","cardinality","displayName","objectTypeApiName","status"],"sources":["defineLink.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nexport function defineLink(from, opts) {\n const apiName = opts.one ?? opts.many;\n const toApiName = opts.reverse.one ?? opts.reverse.many;\n const to = opts.to;\n invariant(from.linkTypes[apiName] == null, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`);\n invariant(from.linkTypes[toApiName] == null, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`);\n from.linkTypes[apiName] = {\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: to.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n to.linkTypes[toApiName] = {\n apiName: toApiName,\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: from.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,UAAUA,CAACC,IAAI,EAAEC,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAGD,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACG,IAAI;EACrC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,OAAO,CAACH,GAAG,IAAIF,IAAI,CAACK,OAAO,CAACF,IAAI;EACvD,MAAMG,EAAE,GAAGN,IAAI,CAACM,EAAE;EAClB,EAAUP,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,IAAI,IAAI,IAAAO,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAzCb,SAAS,QAAkC,qBAAqBI,OAAO,sBAAsBF,IAAI,CAACY,IAAI,CAACC,UAAU,CAACX,OAAO,EAAE,IAA3HJ,SAAS;EACT,EAAUE,IAAI,CAACQ,SAAS,CAACH,SAAS,CAAC,IAAI,IAAI,IAAAI,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAA3Cb,SAAS,QAAoC,qBAAqBO,SAAS,sBAAsBE,EAAE,CAACK,IAAI,CAACC,UAAU,CAACX,OAAO,EAAE,IAA7HJ,SAAS;EACTE,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,GAAG;IACtBY,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEb,OAAO;IACpBc,iBAAiB,EAAET,EAAE,CAACK,IAAI,CAACC,UAAU,CAACX,OAAO;IAC7Ce,MAAM,EAAE;EACZ,CAAC;EACDV,EAAE,CAACC,SAAS,CAACH,SAAS,CAAC,GAAG;IACtBH,OAAO,EAAEG,SAAS;IAClBS,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEb,OAAO;IACpBc,iBAAiB,EAAEhB,IAAI,CAACY,IAAI,CAACC,UAAU,CAACX,OAAO;IAC/Ce,MAAM,EAAE;EACZ,CAAC;AACL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineObject.d.ts","sourceRoot":"","sources":["../../../src/api/defineObject.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"defineObject.d.ts","sourceRoot":"","sources":["../../../src/api/defineObject.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AASrC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAIzB,CAAC,CAAC;CACJ;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACJ,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,cAAc,CAAC,QAAQ,CAC9B,CAAC;CACH,GACA,UAAU,CAkCZ"}
|
|
@@ -32,7 +32,8 @@ export function defineObject(apiName, opts) {
|
|
|
32
32
|
},
|
|
33
33
|
properties: {
|
|
34
34
|
[opts.primaryKey.apiName]: {
|
|
35
|
-
dataType: convertType(opts.primaryKey)
|
|
35
|
+
dataType: convertType(opts.primaryKey),
|
|
36
|
+
rid: "rid"
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
rid: "PLACEHOLDER",
|
|
@@ -72,15 +73,31 @@ function convertType(t) {
|
|
|
72
73
|
},
|
|
73
74
|
type: "timeseries"
|
|
74
75
|
};
|
|
76
|
+
case t.type === "sensorTimeseries":
|
|
77
|
+
return {
|
|
78
|
+
type: "timeseries"
|
|
79
|
+
};
|
|
75
80
|
case t.type === "datetime":
|
|
76
81
|
return {
|
|
77
82
|
type: "timestamp"
|
|
78
83
|
};
|
|
84
|
+
case typeof t.type === "object":
|
|
85
|
+
{
|
|
86
|
+
return {
|
|
87
|
+
type: "struct",
|
|
88
|
+
structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({
|
|
89
|
+
apiName,
|
|
90
|
+
dataType: {
|
|
91
|
+
type: dataType
|
|
92
|
+
}
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
79
96
|
default:
|
|
80
97
|
return {
|
|
81
98
|
type: t.type
|
|
82
99
|
};
|
|
83
100
|
}
|
|
84
|
-
invariant(false);
|
|
101
|
+
process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false);
|
|
85
102
|
}
|
|
86
103
|
//# sourceMappingURL=defineObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType"],"sources":["defineObject.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineObject(apiName, opts) {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\nfunction convertType(t) {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n default:\n return {\n type: t.type,\n };\n }\n invariant(false);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAEC,IAAI,EAAE;EACxCH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACtCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACRN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACFC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACV,CAAC;MACDC,UAAU,EAAE;QACR,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACvBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU;
|
|
1
|
+
{"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType","structFieldTypes","Object","entries","map","process","env","NODE_ENV"],"sources":["defineObject.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineObject(apiName, opts) {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n rid: \"rid\",\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\nfunction convertType(t) {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n case t.type === \"sensorTimeseries\":\n return {\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n case typeof t.type === \"object\": {\n return {\n type: \"struct\",\n structFieldTypes: Object.entries(t.type).map(([apiName, dataType]) => ({\n apiName,\n dataType: { type: dataType },\n })),\n };\n }\n default:\n return {\n type: t.type,\n };\n }\n invariant(false);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAEC,IAAI,EAAE;EACxCH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACtCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACRN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACFC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACV,CAAC;MACDC,UAAU,EAAE;QACR,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACvBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU,CAAC;UACtCU,GAAG,EAAE;QACT;MACJ,CAAC;MACDA,GAAG,EAAE,aAAa;MAClBC,MAAM,EAAE,QAAQ;MAChBC,aAAa,EAAElB,IAAI,CAACM,UAAU,CAACP;IACnC,CAAC;IACDoB,yBAAyB,EAAE,CAAC;EAChC,CAAC;EACD;EACA,OAAO;IACHC,IAAI,EAAEvB,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC;IAC7CK,SAAS,EAAE,CAAC;EAChB,CAAC;AACL;AACA,SAASW,WAAWA,CAACM,CAAC,EAAE;EACpB,QAAQ,IAAI;IACR,KAAKA,CAAC,CAACC,YAAY,KAAK,IAAI;MACxB,OAAO;QACHV,IAAI,EAAE,OAAO;QACbW,OAAO,EAAER,WAAW,CAAC;UAAE,GAAGM,CAAC;UAAEC,YAAY,EAAE;QAAM,CAAC;MACtD,CAAC;IACL,KAAKD,CAAC,CAACT,IAAI,KAAK,kBAAkB;MAC9B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;MACD;IACJ,KAAKS,CAAC,CAACT,IAAI,KAAK,mBAAmB;MAC/B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;IACL,KAAKS,CAAC,CAACT,IAAI,KAAK,kBAAkB;MAC9B,OAAO;QACHA,IAAI,EAAE;MACV,CAAC;IACL,KAAKS,CAAC,CAACT,IAAI,KAAK,UAAU;MACtB,OAAO;QACHA,IAAI,EAAE;MACV,CAAC;IACL,KAAK,OAAOS,CAAC,CAACT,IAAI,KAAK,QAAQ;MAAE;QAC7B,OAAO;UACHA,IAAI,EAAE,QAAQ;UACda,gBAAgB,EAAEC,MAAM,CAACC,OAAO,CAACN,CAAC,CAACT,IAAI,CAAC,CAACgB,GAAG,CAAC,CAAC,CAAC7B,OAAO,EAAEe,QAAQ,CAAC,MAAM;YACnEf,OAAO;YACPe,QAAQ,EAAE;cAAEF,IAAI,EAAEE;YAAS;UAC/B,CAAC,CAAC;QACN,CAAC;MACL;IACA;MACI,OAAO;QACHF,IAAI,EAAES,CAAC,CAACT;MACZ,CAAC;EACT;EACAiB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAAnC,SAAS,UAATA,SAAS;AACb","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OntologyIr, OntologyIrValueTypeBlockData } from "@osdk/client.unstable";
|
|
2
2
|
type OntologyAndValueTypeIrs = {
|
|
3
|
-
ontology:
|
|
3
|
+
ontology: OntologyIr;
|
|
4
4
|
valueType: OntologyIrValueTypeBlockData;
|
|
5
5
|
};
|
|
6
6
|
export declare function defineOntology(ns: string, body: () => void | Promise<void>): Promise<OntologyAndValueTypeIrs>;
|
|
7
|
-
export declare function dumpOntologyFullMetadata():
|
|
7
|
+
export declare function dumpOntologyFullMetadata(): OntologyIr;
|
|
8
8
|
export declare function dumpValueTypeWireType(): OntologyIrValueTypeBlockData;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=defineOntology.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineOntology.d.ts","sourceRoot":"","sources":["../../../src/api/defineOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"defineOntology.d.ts","sourceRoot":"","sources":["../../../src/api/defineOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,UAAU,EAOV,4BAA4B,EAE7B,MAAM,uBAAuB,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,4BAA4B,CAAC;CACzC,CAAC;AAEF,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA6BlC;AAyED,wBAAgB,wBAAwB,IAAI,UAAU,CAErD;AAED,wBAAgB,qBAAqB,IAAI,4BAA4B,CAEpE"}
|
|
@@ -25,7 +25,10 @@ export async function defineOntology(ns, body) {
|
|
|
25
25
|
queryTypes: {},
|
|
26
26
|
interfaceTypes: {},
|
|
27
27
|
sharedPropertyTypes: {},
|
|
28
|
-
valueTypes: {}
|
|
28
|
+
valueTypes: {},
|
|
29
|
+
importedTypes: {
|
|
30
|
+
sharedPropertyTypes: []
|
|
31
|
+
}
|
|
29
32
|
};
|
|
30
33
|
try {
|
|
31
34
|
await body();
|
|
@@ -58,19 +61,22 @@ function convertOntologyToValueTypeIr(ontology) {
|
|
|
58
61
|
}
|
|
59
62
|
function convertToWireOntologyIr(ontology) {
|
|
60
63
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
blockData: {
|
|
65
|
+
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {
|
|
66
|
+
sharedPropertyType: convertSpt(spt)
|
|
67
|
+
}])),
|
|
68
|
+
interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {
|
|
69
|
+
return [apiName, {
|
|
70
|
+
interfaceType: convertInterface(interfaceType)
|
|
71
|
+
}];
|
|
72
|
+
})),
|
|
73
|
+
blockPermissionInformation: {
|
|
74
|
+
actionTypes: {},
|
|
75
|
+
linkTypes: {},
|
|
76
|
+
objectTypes: {}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
importedTypes: ontology.importedTypes
|
|
74
80
|
};
|
|
75
81
|
}
|
|
76
82
|
function convertInterface(interfaceType) {
|
|
@@ -99,6 +105,14 @@ function convertSpt({
|
|
|
99
105
|
typeClasses,
|
|
100
106
|
valueType
|
|
101
107
|
}) {
|
|
108
|
+
const dataConstraint = typeof type === "object" && type.type === "marking" ? {
|
|
109
|
+
propertyTypeConstraints: [],
|
|
110
|
+
nullability: "NO_EXPLICIT_NULLS",
|
|
111
|
+
nullabilityV2: {
|
|
112
|
+
noEmptyCollections: true,
|
|
113
|
+
noNulls: true
|
|
114
|
+
}
|
|
115
|
+
} : undefined;
|
|
102
116
|
return {
|
|
103
117
|
apiName,
|
|
104
118
|
displayMetadata: {
|
|
@@ -114,7 +128,7 @@ function convertSpt({
|
|
|
114
128
|
} : convertType(type),
|
|
115
129
|
aliases: [],
|
|
116
130
|
baseFormatter: undefined,
|
|
117
|
-
dataConstraints:
|
|
131
|
+
dataConstraints: dataConstraint,
|
|
118
132
|
gothamMapping: gothamMapping,
|
|
119
133
|
indexedForSearch: true,
|
|
120
134
|
provenance: undefined,
|
|
@@ -123,20 +137,67 @@ function convertSpt({
|
|
|
123
137
|
};
|
|
124
138
|
}
|
|
125
139
|
function convertType(type) {
|
|
126
|
-
switch (
|
|
127
|
-
case "
|
|
140
|
+
switch (true) {
|
|
141
|
+
case typeof type === "object" && "markingType" in type:
|
|
128
142
|
return {
|
|
129
|
-
type,
|
|
130
|
-
|
|
131
|
-
markingType:
|
|
143
|
+
"type": "marking",
|
|
144
|
+
marking: {
|
|
145
|
+
markingType: type.markingType
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
case typeof type === "object" && "structDefinition" in type:
|
|
149
|
+
const structFields = new Array();
|
|
150
|
+
for (const key in type.structDefinition) {
|
|
151
|
+
const fieldTypeDefinition = type.structDefinition[key];
|
|
152
|
+
var field;
|
|
153
|
+
if (typeof fieldTypeDefinition === "string") {
|
|
154
|
+
field = {
|
|
155
|
+
apiName: key,
|
|
156
|
+
displayMetadata: {
|
|
157
|
+
displayName: key,
|
|
158
|
+
description: undefined
|
|
159
|
+
},
|
|
160
|
+
typeClasses: [],
|
|
161
|
+
aliases: [],
|
|
162
|
+
fieldType: convertType(fieldTypeDefinition)
|
|
163
|
+
};
|
|
164
|
+
} else {
|
|
165
|
+
// If it is a full form type definition then process it as such
|
|
166
|
+
if ("fieldType" in fieldTypeDefinition) {
|
|
167
|
+
field = {
|
|
168
|
+
...fieldTypeDefinition,
|
|
169
|
+
apiName: key,
|
|
170
|
+
fieldType: convertType(fieldTypeDefinition.fieldType),
|
|
171
|
+
typeClasses: fieldTypeDefinition.typeClasses ?? [],
|
|
172
|
+
aliases: fieldTypeDefinition.aliases ?? []
|
|
173
|
+
};
|
|
174
|
+
} else {
|
|
175
|
+
field = {
|
|
176
|
+
apiName: key,
|
|
177
|
+
displayMetadata: {
|
|
178
|
+
displayName: key,
|
|
179
|
+
description: undefined
|
|
180
|
+
},
|
|
181
|
+
typeClasses: [],
|
|
182
|
+
aliases: [],
|
|
183
|
+
fieldType: convertType(fieldTypeDefinition)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
structFields.push(field);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
type: "struct",
|
|
191
|
+
struct: {
|
|
192
|
+
structFields
|
|
132
193
|
}
|
|
133
194
|
};
|
|
134
|
-
case "geopoint":
|
|
195
|
+
case type === "geopoint":
|
|
135
196
|
return {
|
|
136
197
|
type: "geohash",
|
|
137
198
|
geohash: {}
|
|
138
199
|
};
|
|
139
|
-
case "decimal":
|
|
200
|
+
case type === "decimal":
|
|
140
201
|
return {
|
|
141
202
|
type,
|
|
142
203
|
[type]: {
|
|
@@ -144,7 +205,7 @@ function convertType(type) {
|
|
|
144
205
|
scale: undefined
|
|
145
206
|
}
|
|
146
207
|
};
|
|
147
|
-
case "string":
|
|
208
|
+
case type === "string":
|
|
148
209
|
return {
|
|
149
210
|
type,
|
|
150
211
|
[type]: {
|
|
@@ -154,7 +215,7 @@ function convertType(type) {
|
|
|
154
215
|
supportsExactMatching: true
|
|
155
216
|
}
|
|
156
217
|
};
|
|
157
|
-
case "mediaReference":
|
|
218
|
+
case type === "mediaReference":
|
|
158
219
|
return {
|
|
159
220
|
type: type,
|
|
160
221
|
mediaReference: {}
|