@osdk/maker 0.16.0-beta.8 → 0.16.0
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 +142 -0
- package/build/browser/api/defineFunction.js +6 -5
- package/build/browser/api/defineFunction.js.map +1 -1
- package/build/browser/api/defineInterface.js +3 -0
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineLink.js +3 -0
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineObject.js +9 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/interface/InterfaceType.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/cli/main.js +4 -147
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +9 -4
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/util/ApiNameValidator.js +26 -0
- package/build/browser/util/ApiNameValidator.js.map +1 -0
- package/build/cjs/index.cjs +107 -218
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +5 -1
- package/build/esm/api/defineFunction.js +6 -5
- package/build/esm/api/defineFunction.js.map +1 -1
- package/build/esm/api/defineInterface.js +3 -0
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineLink.js +3 -0
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineObject.js +9 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/interface/InterfaceType.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/cli/main.js +4 -147
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +2 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +9 -4
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/util/ApiNameValidator.js +26 -0
- package/build/esm/util/ApiNameValidator.js.map +1 -0
- package/build/types/api/defineFunction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/interface/InterfaceType.d.ts +1 -1
- package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
- package/build/types/api/links/LinkType.d.ts +2 -0
- package/build/types/api/links/LinkType.d.ts.map +1 -1
- package/build/types/api/object/ObjectType.d.ts +1 -0
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/build/types/util/ApiNameValidator.d.ts +4 -0
- package/build/types/util/ApiNameValidator.d.ts.map +1 -0
- package/package.json +6 -7
- package/build/browser/api/test/actions.test.js +0 -14402
- package/build/browser/api/test/actions.test.js.map +0 -1
- package/build/browser/api/test/interfaces.test.js +0 -1189
- package/build/browser/api/test/interfaces.test.js.map +0 -1
- package/build/browser/api/test/links.test.js +0 -2019
- package/build/browser/api/test/links.test.js.map +0 -1
- package/build/browser/api/test/markingconstraint.test.js +0 -134
- package/build/browser/api/test/markingconstraint.test.js.map +0 -1
- package/build/browser/api/test/misc.test.js +0 -1315
- package/build/browser/api/test/misc.test.js.map +0 -1
- package/build/browser/api/test/objectStatus.test.js +0 -252
- package/build/browser/api/test/objectStatus.test.js.map +0 -1
- package/build/browser/api/test/objects.test.js +0 -4441
- package/build/browser/api/test/objects.test.js.map +0 -1
- package/build/browser/api/test/spt.test.js +0 -751
- package/build/browser/api/test/spt.test.js.map +0 -1
- package/build/browser/api/test/valueTypes.test.js +0 -307
- package/build/browser/api/test/valueTypes.test.js.map +0 -1
- package/build/cjs/defineFunction-7ORD7HD4.cjs +0 -72
- package/build/cjs/defineFunction-7ORD7HD4.cjs.map +0 -1
- package/build/esm/api/test/actions.test.js +0 -14402
- package/build/esm/api/test/actions.test.js.map +0 -1
- package/build/esm/api/test/interfaces.test.js +0 -1189
- package/build/esm/api/test/interfaces.test.js.map +0 -1
- package/build/esm/api/test/links.test.js +0 -2019
- package/build/esm/api/test/links.test.js.map +0 -1
- package/build/esm/api/test/markingconstraint.test.js +0 -134
- package/build/esm/api/test/markingconstraint.test.js.map +0 -1
- package/build/esm/api/test/misc.test.js +0 -1315
- package/build/esm/api/test/misc.test.js.map +0 -1
- package/build/esm/api/test/objectStatus.test.js +0 -252
- package/build/esm/api/test/objectStatus.test.js.map +0 -1
- package/build/esm/api/test/objects.test.js +0 -4441
- package/build/esm/api/test/objects.test.js.map +0 -1
- package/build/esm/api/test/spt.test.js +0 -751
- package/build/esm/api/test/spt.test.js.map +0 -1
- package/build/esm/api/test/valueTypes.test.js +0 -307
- package/build/esm/api/test/valueTypes.test.js.map +0 -1
- package/build/types/api/test/actions.test.d.ts +0 -1
- package/build/types/api/test/actions.test.d.ts.map +0 -1
- package/build/types/api/test/interfaces.test.d.ts +0 -1
- package/build/types/api/test/interfaces.test.d.ts.map +0 -1
- package/build/types/api/test/links.test.d.ts +0 -1
- package/build/types/api/test/links.test.d.ts.map +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts +0 -1
- package/build/types/api/test/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/test/misc.test.d.ts +0 -1
- package/build/types/api/test/misc.test.d.ts.map +0 -1
- package/build/types/api/test/objectStatus.test.d.ts +0 -1
- package/build/types/api/test/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/test/objects.test.d.ts +0 -1
- package/build/types/api/test/objects.test.d.ts.map +0 -1
- package/build/types/api/test/spt.test.d.ts +0 -1
- package/build/types/api/test/spt.test.d.ts.map +0 -1
- package/build/types/api/test/valueTypes.test.d.ts +0 -1
- package/build/types/api/test/valueTypes.test.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,147 @@
|
|
|
1
1
|
# @osdk/maker
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 322c5bc: Simulated release
|
|
8
|
+
- cc7f505: Add maximum length validation (100 characters) for API names to match server-side constraints
|
|
9
|
+
- 8f92197: update code snippet to have interface dependent properties
|
|
10
|
+
- 963626f: Add function discovery support (TypeScript and Python) and generate intermediate OSDK from CLI for use by function definitions
|
|
11
|
+
- f487a6a: Maker experimental
|
|
12
|
+
- e462938: Support PSGs in OAC
|
|
13
|
+
- 6499ff9: Support reducers and struct main values in oac
|
|
14
|
+
- 0e45a37: Add better api name validation for OAC
|
|
15
|
+
- fcf81ba: Validate link api names
|
|
16
|
+
- ab50d31: Remove propertiesV2 from code-snippets
|
|
17
|
+
- 034081a: oac direct datasources
|
|
18
|
+
- 77aa4a9: Detect imported objects for OAC links
|
|
19
|
+
- fd3f6d3: Add support for empty backing datasources
|
|
20
|
+
- 9ee82f4: Dedupe many-to-many PK property names in datasource
|
|
21
|
+
- 5b938ef: Enforce OT and prop statuses match
|
|
22
|
+
- 7fa6de3: Revert breaking change
|
|
23
|
+
- 2b15836: Disallow ILCs on imported interfaces
|
|
24
|
+
- 684b6c6: Always use valid import path
|
|
25
|
+
- acb4ed6: Support custom decimal types
|
|
26
|
+
- e8ca289: Fix key resolution
|
|
27
|
+
- 35f2f1a: Add Media inputs/outputs for Queries
|
|
28
|
+
- e0ba9eb: Shallow clone arrays in definition when passed in to defineFoo methods
|
|
29
|
+
- 972bda6: Support assumed markings for oac PSGs
|
|
30
|
+
- 6941b4f: extendsInterfaceMetadata on the IR to fix interface impl
|
|
31
|
+
- e9f9f58: Allow primitive struct main values to be title props
|
|
32
|
+
- eac64f4: Link backing dataset generation
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [322c5bc]
|
|
37
|
+
- Updated dependencies [150da1a]
|
|
38
|
+
- Updated dependencies [776ae8a]
|
|
39
|
+
- Updated dependencies [4bb9769]
|
|
40
|
+
- Updated dependencies [abb0e0f]
|
|
41
|
+
- Updated dependencies [4762f4b]
|
|
42
|
+
- Updated dependencies [beba0cd]
|
|
43
|
+
- Updated dependencies [8561a8b]
|
|
44
|
+
- Updated dependencies [f294f5a]
|
|
45
|
+
- Updated dependencies [908b519]
|
|
46
|
+
- Updated dependencies [c4d7052]
|
|
47
|
+
- Updated dependencies [0df859a]
|
|
48
|
+
- Updated dependencies [d284bf2]
|
|
49
|
+
- Updated dependencies [4ef6adc]
|
|
50
|
+
- Updated dependencies [60b5ffb]
|
|
51
|
+
- Updated dependencies [8c30908]
|
|
52
|
+
- Updated dependencies [4a856cb]
|
|
53
|
+
- Updated dependencies [b68cebd]
|
|
54
|
+
- Updated dependencies [35f2f1a]
|
|
55
|
+
- Updated dependencies [cde6b85]
|
|
56
|
+
- Updated dependencies [32c6a0c]
|
|
57
|
+
- Updated dependencies [12fe33f]
|
|
58
|
+
- Updated dependencies [46f0a47]
|
|
59
|
+
- Updated dependencies [61e33ab]
|
|
60
|
+
- @osdk/api@2.8.0
|
|
61
|
+
- @osdk/generator-converters.ontologyir@2.8.0
|
|
62
|
+
- @osdk/typescript-sdk-docs@0.7.0
|
|
63
|
+
|
|
64
|
+
## 0.16.0-beta.15
|
|
65
|
+
|
|
66
|
+
### Minor Changes
|
|
67
|
+
|
|
68
|
+
- e8ca289: Fix key resolution
|
|
69
|
+
|
|
70
|
+
## 0.16.0-beta.14
|
|
71
|
+
|
|
72
|
+
### Minor Changes
|
|
73
|
+
|
|
74
|
+
- 684b6c6: Always use valid import path
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [f294f5a]
|
|
79
|
+
- Updated dependencies [d284bf2]
|
|
80
|
+
- Updated dependencies [b68cebd]
|
|
81
|
+
- Updated dependencies [12fe33f]
|
|
82
|
+
- @osdk/api@2.8.0-beta.28
|
|
83
|
+
- @osdk/generator-converters.ontologyir@2.8.0-beta.28
|
|
84
|
+
|
|
85
|
+
## 0.16.0-beta.13
|
|
86
|
+
|
|
87
|
+
### Minor Changes
|
|
88
|
+
|
|
89
|
+
- 9ee82f4: Dedupe many-to-many PK property names in datasource
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [60b5ffb]
|
|
94
|
+
- Updated dependencies [61e33ab]
|
|
95
|
+
- @osdk/api@2.8.0-beta.26
|
|
96
|
+
- @osdk/generator-converters.ontologyir@2.8.0-beta.26
|
|
97
|
+
|
|
98
|
+
## 0.16.0-beta.12
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- 77aa4a9: Detect imported objects for OAC links
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- @osdk/api@2.8.0-beta.24
|
|
107
|
+
- @osdk/generator-converters.ontologyir@2.8.0-beta.24
|
|
108
|
+
|
|
109
|
+
## 0.16.0-beta.11
|
|
110
|
+
|
|
111
|
+
### Minor Changes
|
|
112
|
+
|
|
113
|
+
- cc7f505: Add maximum length validation (100 characters) for API names to match server-side constraints
|
|
114
|
+
- 0e45a37: Add better api name validation for OAC
|
|
115
|
+
- fcf81ba: Validate link api names
|
|
116
|
+
- fd3f6d3: Add support for empty backing datasources
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [4bb9769]
|
|
121
|
+
- Updated dependencies [beba0cd]
|
|
122
|
+
- Updated dependencies [c4d7052]
|
|
123
|
+
- Updated dependencies [32c6a0c]
|
|
124
|
+
- @osdk/api@2.8.0-beta.23
|
|
125
|
+
- @osdk/typescript-sdk-docs@0.7.0-beta.3
|
|
126
|
+
- @osdk/generator-converters.ontologyir@2.8.0-beta.23
|
|
127
|
+
|
|
128
|
+
## 0.16.0-beta.10
|
|
129
|
+
|
|
130
|
+
### Minor Changes
|
|
131
|
+
|
|
132
|
+
- 6941b4f: extendsInterfaceMetadata on the IR to fix interface impl
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- @osdk/api@2.8.0-beta.16
|
|
137
|
+
- @osdk/generator-converters.ontologyir@2.8.0-beta.16
|
|
138
|
+
|
|
139
|
+
## 0.16.0-beta.9
|
|
140
|
+
|
|
141
|
+
### Minor Changes
|
|
142
|
+
|
|
143
|
+
- 7fa6de3: Revert breaking change
|
|
144
|
+
|
|
3
145
|
## 0.16.0-beta.8
|
|
4
146
|
|
|
5
147
|
### Minor Changes
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
|
|
18
18
|
import { consola } from "consola";
|
|
19
|
-
import * as path from "node:path";
|
|
20
19
|
|
|
21
20
|
// Type definitions for optional function discovery dependencies
|
|
22
21
|
|
|
@@ -49,10 +48,12 @@ export async function generateFunctionsIr(rootDir, configPath, entityMappings) {
|
|
|
49
48
|
if (!functionsDiscoverer) {
|
|
50
49
|
throw new Error("Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed");
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
51
|
+
|
|
52
|
+
// Normalize to forward slashes to match TypeScript's internal path format
|
|
53
|
+
const normalizedRootDir = rootDir.replace(/\\/g, "/");
|
|
54
|
+
const tsConfigPath = configPath?.replace(/\\/g, "/") ?? normalizedRootDir + "/tsconfig.json";
|
|
55
|
+
const program = OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, normalizedRootDir);
|
|
56
|
+
const fd = new functionsDiscoverer(program, normalizedRootDir, normalizedRootDir + "/functions", entityMappings);
|
|
56
57
|
const functions = fd.discover();
|
|
57
58
|
return {
|
|
58
59
|
functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineFunction.js","names":["OntologyIrToFullMetadataConverter","consola","
|
|
1
|
+
{"version":3,"file":"defineFunction.js","names":["OntologyIrToFullMetadataConverter","consola","cachedFunctionDiscoverer","loadFunctionDiscoverer","module","FunctionDiscoverer","e","warn","Error","message","extractFunctionEntries","discoveredFunctions","map","fn","locator","type","typescriptOsdk","functionName","generateFunctionsIr","rootDir","configPath","entityMappings","functionsDiscoverer","normalizedRootDir","replace","tsConfigPath","program","createProgram","fd","functions","discover","functionsBlockDataV1","Object","fromEntries"],"sources":["defineFunction.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport type * as ts from \"typescript\";\n\nexport interface FunctionIrBlockData {\n functionsBlockDataV1: Record<string, unknown>;\n}\n\n// Type definitions for optional function discovery dependencies\ntype IFunctionDiscoverer = new(\n program: ts.Program,\n entryPointPath: string,\n fullFilePath: string,\n entityMappings?: IEntityMetadataMapping,\n) => {\n discover(): {\n discoveredFunctions: IDiscoveredFunction[];\n diagnostics?: unknown;\n };\n};\n\ninterface IDiscoveredFunction {\n locator:\n | { type: \"typescriptOsdk\"; typescriptOsdk: { functionName: string } }\n | { type: string };\n [key: string]: unknown;\n}\n\nexport interface IEntityMetadataMapping {\n ontologies: Record<\n string,\n {\n objectTypes: Record<\n string,\n {\n objectTypeId: string;\n primaryKey: { propertyId: string };\n propertyTypes: Record<string, { propertyId: string }>;\n linkTypes: Record<string, unknown>;\n }\n >;\n interfaceTypes: Record<string, unknown>;\n }\n >;\n}\n\n// Lazy-loaded function discovery module\nlet cachedFunctionDiscoverer: IFunctionDiscoverer | null = null;\n\nasync function loadFunctionDiscoverer(): Promise<IFunctionDiscoverer | null> {\n if (cachedFunctionDiscoverer != null) {\n return cachedFunctionDiscoverer;\n }\n try {\n const modulePath = \"@foundry/functions-typescript-osdk-discovery\";\n const module = await import(/* @vite-ignore */ modulePath);\n cachedFunctionDiscoverer = module.FunctionDiscoverer;\n return cachedFunctionDiscoverer;\n } catch (e: unknown) {\n consola.warn(\n \"Failed to load @foundry/functions-typescript-osdk-discovery:\",\n e instanceof Error ? e.message : e,\n );\n return null;\n }\n}\n\nfunction extractFunctionEntries(\n discoveredFunctions: IDiscoveredFunction[],\n): Array<[string, IDiscoveredFunction]> {\n return discoveredFunctions.map((fn: IDiscoveredFunction) => {\n if (fn.locator.type !== \"typescriptOsdk\") {\n throw new Error(\n `OAC functions must be TypeScript, got type: ${fn.locator.type}`,\n );\n }\n const locator = fn.locator as {\n typescriptOsdk: { functionName: string };\n };\n return [locator.typescriptOsdk.functionName, fn];\n });\n}\n\nexport async function generateFunctionsIr(\n rootDir: string,\n configPath?: string,\n entityMappings?: IEntityMetadataMapping,\n): Promise<FunctionIrBlockData> {\n const functionsDiscoverer = await loadFunctionDiscoverer();\n if (!functionsDiscoverer) {\n throw new Error(\n \"Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed\",\n );\n }\n\n // Normalize to forward slashes to match TypeScript's internal path format\n const normalizedRootDir = rootDir.replace(/\\\\/g, \"/\");\n const tsConfigPath = configPath?.replace(/\\\\/g, \"/\")\n ?? (normalizedRootDir + \"/tsconfig.json\");\n const program = OntologyIrToFullMetadataConverter.createProgram(\n tsConfigPath,\n normalizedRootDir,\n );\n const functionsDir = normalizedRootDir + \"/functions\";\n const fd = new functionsDiscoverer(\n program,\n normalizedRootDir,\n functionsDir,\n entityMappings,\n );\n const functions = fd.discover();\n\n return {\n functionsBlockDataV1: Object.fromEntries(\n extractFunctionEntries(functions.discoveredFunctions),\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,OAAO,QAAQ,SAAS;;AAOjC;;AAsCA;AACA,IAAIC,wBAAoD,GAAG,IAAI;AAE/D,eAAeC,sBAAsBA,CAAA,EAAwC;EAC3E,IAAID,wBAAwB,IAAI,IAAI,EAAE;IACpC,OAAOA,wBAAwB;EACjC;EACA,IAAI;IAEF,MAAME,MAAM,GAAG,MAAM,MAAM,CAAC,kBADT,8CACsC,CAAC;IAC1DF,wBAAwB,GAAGE,MAAM,CAACC,kBAAkB;IACpD,OAAOH,wBAAwB;EACjC,CAAC,CAAC,OAAOI,CAAU,EAAE;IACnBL,OAAO,CAACM,IAAI,CACV,8DAA8D,EAC9DD,CAAC,YAAYE,KAAK,GAAGF,CAAC,CAACG,OAAO,GAAGH,CACnC,CAAC;IACD,OAAO,IAAI;EACb;AACF;AAEA,SAASI,sBAAsBA,CAC7BC,mBAA0C,EACJ;EACtC,OAAOA,mBAAmB,CAACC,GAAG,CAAEC,EAAuB,IAAK;IAC1D,IAAIA,EAAE,CAACC,OAAO,CAACC,IAAI,KAAK,gBAAgB,EAAE;MACxC,MAAM,IAAIP,KAAK,CACb,+CAA+CK,EAAE,CAACC,OAAO,CAACC,IAAI,EAChE,CAAC;IACH;IACA,MAAMD,OAAO,GAAGD,EAAE,CAACC,OAElB;IACD,OAAO,CAACA,OAAO,CAACE,cAAc,CAACC,YAAY,EAAEJ,EAAE,CAAC;EAClD,CAAC,CAAC;AACJ;AAEA,OAAO,eAAeK,mBAAmBA,CACvCC,OAAe,EACfC,UAAmB,EACnBC,cAAuC,EACT;EAC9B,MAAMC,mBAAmB,GAAG,MAAMnB,sBAAsB,CAAC,CAAC;EAC1D,IAAI,CAACmB,mBAAmB,EAAE;IACxB,MAAM,IAAId,KAAK,CACb,0FACF,CAAC;EACH;;EAEA;EACA,MAAMe,iBAAiB,GAAGJ,OAAO,CAACK,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACrD,MAAMC,YAAY,GAAGL,UAAU,EAAEI,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAC9CD,iBAAiB,GAAG,gBAAiB;EAC3C,MAAMG,OAAO,GAAG1B,iCAAiC,CAAC2B,aAAa,CAC7DF,YAAY,EACZF,iBACF,CAAC;EAED,MAAMK,EAAE,GAAG,IAAIN,mBAAmB,CAChCI,OAAO,EACPH,iBAAiB,EAHEA,iBAAiB,GAAG,YAAY,EAKnDF,cACF,CAAC;EACD,MAAMQ,SAAS,GAAGD,EAAE,CAACE,QAAQ,CAAC,CAAC;EAE/B,OAAO;IACLC,oBAAoB,EAAEC,MAAM,CAACC,WAAW,CACtCvB,sBAAsB,CAACmB,SAAS,CAAClB,mBAAmB,CACtD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
+
import { API_NAME_PATTERN, isValidApiName } from "../util/ApiNameValidator.js";
|
|
18
19
|
import { cloneDefinition } from "./cloneDefinition.js";
|
|
19
20
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
20
21
|
import { namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
@@ -26,6 +27,7 @@ export function defineInterface(interfaceDefInput) {
|
|
|
26
27
|
const interfaceDef = cloneDefinition(interfaceDefInput);
|
|
27
28
|
const apiName = namespace + interfaceDef.apiName;
|
|
28
29
|
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;
|
|
30
|
+
!isValidApiName(interfaceDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid API name ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant(false) : void 0;
|
|
29
31
|
|
|
30
32
|
// legacy support for propertiesV2 (only SPTs)
|
|
31
33
|
const spts = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {
|
|
@@ -45,6 +47,7 @@ export function defineInterface(interfaceDefInput) {
|
|
|
45
47
|
}];
|
|
46
48
|
}));
|
|
47
49
|
const propertiesV3 = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([apiName, prop]) => {
|
|
50
|
+
!isValidApiName(apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid API name ${apiName} for property on interface ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant(false) : void 0;
|
|
48
51
|
const required = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.required : true;
|
|
49
52
|
const propertyBase = typeof prop === "object" && isInterfaceSharedPropertyType(prop) ? prop.sharedPropertyType : prop;
|
|
50
53
|
if (typeof propertyBase === "object" && "nonNameSpacedApiName" in propertyBase) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineInterface.js","names":["invariant","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","withoutNamespace","isInterfaceSharedPropertyType","mapSimplifiedStatusToInterfaceTypeStatus","combineApiNamespaceIfMissing","isExotic","isPropertyTypeType","defineInterface","interfaceDefInput","interfaceDef","apiName","INTERFACE_TYPE","undefined","process","env","NODE_ENV","spts","Object","fromEntries","entries","properties","filter","_name","prop","map","s","spt","required","sharedPropertyType","propertiesV2","propName","type","sptApiName","verifyBasePropertyDefinition","propertiesV3","propertyBase","extendsInterfaces","extends","Array","isArray","status","deprecated","message","deadline","fullInterface","displayMetadata","displayName","description","icon","blueprint","color","locator","links","searchable","__type","unNamespacedTypeApiName","JSON","stringify","key"],"sources":["defineInterface.ts"],"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 */\n\nimport type { InterfaceTypeStatus } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { BlueprintIcon } from \"./common/BlueprintIcons.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport {\n type InterfaceDefinedProperty,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport { type InterfaceType } from \"./interface/InterfaceType.js\";\nimport { mapSimplifiedStatusToInterfaceTypeStatus } from \"./interface/mapSimplifiedStatusToInterfaceTypeStatus.js\";\nimport { combineApiNamespaceIfMissing } from \"./namespace/combineApiNamespaceIfMissing.js\";\nimport { isExotic, isPropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\n\nexport type SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" }\n | { type: \"example\" };\n\ntype PropertyBase =\n | SharedPropertyType\n | InterfaceDefinedProperty;\ntype SptWithOptional = {\n required: boolean;\n sharedPropertyType: SharedPropertyType;\n};\n\nexport type InterfaceTypeDefinition = {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n PropertyBase | SptWithOptional\n >;\n extends?: InterfaceType | InterfaceType[];\n searchable?: boolean;\n};\n\nexport function defineInterface(\n interfaceDefInput: InterfaceTypeDefinition,\n): InterfaceType {\n const interfaceDef = cloneDefinition(interfaceDefInput);\n const apiName = namespace + interfaceDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName]\n === undefined,\n `Interface ${apiName} already exists`,\n );\n\n // legacy support for propertiesV2 (only SPTs)\n const spts: Record<string, SptWithOptional> = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {\n return isInterfaceSharedPropertyType(prop) || \"apiName\" in prop;\n }).map(([s, spt]) => {\n const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;\n return [s, {\n sharedPropertyType: (isInterfaceSharedPropertyType(spt)\n ? spt.sharedPropertyType\n : spt) as SharedPropertyType,\n required: required,\n }];\n }),\n );\n const propertiesV2 = Object.fromEntries(\n Object.entries(spts).map<\n [string, { required: boolean; sharedPropertyType: SharedPropertyType }]\n >(\n ([propName, type]) => {\n const sptApiName = combineApiNamespaceIfMissing(\n namespace,\n type.sharedPropertyType.apiName,\n );\n return [sptApiName, {\n required: type.required,\n sharedPropertyType: verifyBasePropertyDefinition(\n namespace,\n propName,\n type.sharedPropertyType,\n ),\n }];\n },\n ),\n );\n\n const propertiesV3 = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).map<\n [string, InterfacePropertyType]\n >(([apiName, prop]) => {\n const required =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.required\n : true;\n const propertyBase: PropertyBase =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.sharedPropertyType\n : prop;\n if (\n typeof propertyBase === \"object\"\n && \"nonNameSpacedApiName\" in propertyBase\n ) {\n // SPT\n return [apiName, {\n required: required,\n sharedPropertyType: propertyBase,\n }];\n } else {\n // IDP\n return [apiName, propertyBase];\n }\n }),\n );\n\n const extendsInterfaces = interfaceDef.extends\n ? (Array.isArray(interfaceDef.extends)\n ? interfaceDef.extends\n : [interfaceDef.extends])\n : [];\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n interfaceDef.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const fullInterface: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: interfaceDef.displayName ?? interfaceDef.apiName,\n description: interfaceDef.description ?? interfaceDef.displayName\n ?? interfaceDef.apiName,\n icon: interfaceDef.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: {\n color: interfaceDef.icon.color,\n locator: interfaceDef.icon.locator,\n },\n }\n : undefined,\n },\n extendsInterfaces,\n links: [],\n status,\n propertiesV2: propertiesV2,\n propertiesV3: propertiesV3,\n searchable: interfaceDef.searchable ?? true,\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE,\n };\n\n updateOntology(fullInterface);\n return fullInterface;\n}\n\nfunction verifyBasePropertyDefinition(\n namespace: string,\n apiName: string,\n type: SharedPropertyType,\n): SharedPropertyType {\n const unNamespacedTypeApiName = withoutNamespace(type.apiName);\n invariant(\n isPropertyTypeType(type.type) || isExotic(type.type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return type;\n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,EAAEzD,sBAAsB,CAACc;EACjC,CAAC;EAEDX,cAAc,CAAC4C,aAAa,CAAC;EAC7B,OAAOA,aAAa;AACtB;AAEA,SAASX,4BAA4BA,CACnCnC,SAAiB,EACjBY,OAAe,EACfqB,IAAwB,EACJ;EACpB,MAAMwB,uBAAuB,GAAGtD,gBAAgB,CAAC8B,IAAI,CAACrB,OAAO,CAAC;EAC9D,EACEJ,kBAAkB,CAACyB,IAAI,CAACA,IAAI,CAAC,IAAI1B,QAAQ,CAAC0B,IAAI,CAACA,IAAI,CAAC,IAAAlB,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADtDpB,SAAS,QAEP,qBACE6D,IAAI,CAACC,SAAS,CAAC1B,IAAI,CAAC,iBACLrB,OAAO,qBAAqBA,OAAO,EAAE,IAJxDf,SAAS;EAMT,EACEG,SAAS,GAAGY,OAAO,KAAKqB,IAAI,CAACrB,OAAO,IAC/BA,OAAO,KAAK6C,uBAAuB,IAAA1C,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAF1CpB,SAAS,QAGP,oDACE6D,IAAI,CAACC,SAAS,CAAC;IAAEC,GAAG,EAAEhD,OAAO;IAAEA,OAAO,EAAEqB,IAAI,CAACrB;EAAQ,CAAC,CAAC,EACvD,IALJf,SAAS;EAOT,OAAOoC,IAAI;AACb","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","API_NAME_PATTERN","isValidApiName","cloneDefinition","OntologyEntityTypeEnum","namespace","ontologyDefinition","updateOntology","withoutNamespace","isInterfaceSharedPropertyType","mapSimplifiedStatusToInterfaceTypeStatus","combineApiNamespaceIfMissing","isExotic","isPropertyTypeType","defineInterface","interfaceDefInput","interfaceDef","apiName","INTERFACE_TYPE","undefined","process","env","NODE_ENV","spts","Object","fromEntries","entries","properties","filter","_name","prop","map","s","spt","required","sharedPropertyType","propertiesV2","propName","type","sptApiName","verifyBasePropertyDefinition","propertiesV3","propertyBase","extendsInterfaces","extends","Array","isArray","status","deprecated","message","deadline","fullInterface","displayMetadata","displayName","description","icon","blueprint","color","locator","links","searchable","__type","unNamespacedTypeApiName","JSON","stringify","key"],"sources":["defineInterface.ts"],"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 */\n\nimport type { InterfaceTypeStatus } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { API_NAME_PATTERN, isValidApiName } from \"../util/ApiNameValidator.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport type { BlueprintIcon } from \"./common/BlueprintIcons.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport {\n type InterfaceDefinedProperty,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport { type InterfaceType } from \"./interface/InterfaceType.js\";\nimport { mapSimplifiedStatusToInterfaceTypeStatus } from \"./interface/mapSimplifiedStatusToInterfaceTypeStatus.js\";\nimport { combineApiNamespaceIfMissing } from \"./namespace/combineApiNamespaceIfMissing.js\";\nimport { isExotic, isPropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { type SharedPropertyType } from \"./properties/SharedPropertyType.js\";\n\nexport type SimplifiedInterfaceTypeStatus =\n | { type: \"deprecated\"; message: string; deadline: string }\n | { type: \"active\" }\n | { type: \"experimental\" }\n | { type: \"example\" };\n\ntype PropertyBase =\n | SharedPropertyType\n | InterfaceDefinedProperty;\ntype SptWithOptional = {\n required: boolean;\n sharedPropertyType: SharedPropertyType;\n};\n\nexport type InterfaceTypeDefinition = {\n apiName: string;\n displayName?: string;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n status?: SimplifiedInterfaceTypeStatus;\n properties?: Record<\n string,\n PropertyBase | SptWithOptional\n >;\n extends?: InterfaceType | InterfaceType[];\n searchable?: boolean;\n};\n\nexport function defineInterface(\n interfaceDefInput: InterfaceTypeDefinition,\n): InterfaceType {\n const interfaceDef = cloneDefinition(interfaceDefInput);\n const apiName = namespace + interfaceDef.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName]\n === undefined,\n `Interface ${apiName} already exists`,\n );\n\n invariant(\n isValidApiName(interfaceDef.apiName),\n `Invalid API name ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n\n // legacy support for propertiesV2 (only SPTs)\n const spts: Record<string, SptWithOptional> = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).filter(([_name, prop]) => {\n return isInterfaceSharedPropertyType(prop) || \"apiName\" in prop;\n }).map(([s, spt]) => {\n const required = isInterfaceSharedPropertyType(spt) ? spt.required : true;\n return [s, {\n sharedPropertyType: (isInterfaceSharedPropertyType(spt)\n ? spt.sharedPropertyType\n : spt) as SharedPropertyType,\n required: required,\n }];\n }),\n );\n const propertiesV2 = Object.fromEntries(\n Object.entries(spts).map<\n [string, { required: boolean; sharedPropertyType: SharedPropertyType }]\n >(\n ([propName, type]) => {\n const sptApiName = combineApiNamespaceIfMissing(\n namespace,\n type.sharedPropertyType.apiName,\n );\n return [sptApiName, {\n required: type.required,\n sharedPropertyType: verifyBasePropertyDefinition(\n namespace,\n propName,\n type.sharedPropertyType,\n ),\n }];\n },\n ),\n );\n\n const propertiesV3 = Object.fromEntries(\n Object.entries(interfaceDef.properties ?? {}).map<\n [string, InterfacePropertyType]\n >(([apiName, prop]) => {\n invariant(\n isValidApiName(apiName),\n `Invalid API name ${apiName} for property on interface ${interfaceDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n const required =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.required\n : true;\n const propertyBase: PropertyBase =\n (typeof prop === \"object\" && isInterfaceSharedPropertyType(prop))\n ? prop.sharedPropertyType\n : prop;\n if (\n typeof propertyBase === \"object\"\n && \"nonNameSpacedApiName\" in propertyBase\n ) {\n // SPT\n return [apiName, {\n required: required,\n sharedPropertyType: propertyBase,\n }];\n } else {\n // IDP\n return [apiName, propertyBase];\n }\n }),\n );\n\n const extendsInterfaces = interfaceDef.extends\n ? (Array.isArray(interfaceDef.extends)\n ? interfaceDef.extends\n : [interfaceDef.extends])\n : [];\n\n const status: InterfaceTypeStatus = mapSimplifiedStatusToInterfaceTypeStatus(\n interfaceDef.status ?? { type: \"active\" },\n );\n\n invariant(\n status.type !== \"deprecated\"\n || (status.deprecated.message && status.deprecated.deadline),\n `Deprecated status must include message and deadline properties.`,\n );\n\n const fullInterface: InterfaceType = {\n apiName,\n displayMetadata: {\n displayName: interfaceDef.displayName ?? interfaceDef.apiName,\n description: interfaceDef.description ?? interfaceDef.displayName\n ?? interfaceDef.apiName,\n icon: interfaceDef.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: {\n color: interfaceDef.icon.color,\n locator: interfaceDef.icon.locator,\n },\n }\n : undefined,\n },\n extendsInterfaces,\n links: [],\n status,\n propertiesV2: propertiesV2,\n propertiesV3: propertiesV3,\n searchable: interfaceDef.searchable ?? true,\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE,\n };\n\n updateOntology(fullInterface);\n return fullInterface;\n}\n\nfunction verifyBasePropertyDefinition(\n namespace: string,\n apiName: string,\n type: SharedPropertyType,\n): SharedPropertyType {\n const unNamespacedTypeApiName = withoutNamespace(type.apiName);\n invariant(\n isPropertyTypeType(type.type) || isExotic(type.type),\n `Invalid data type ${\n JSON.stringify(type)\n } for property ${apiName} on InterfaceType ${apiName}`,\n );\n invariant(\n namespace + apiName === type.apiName\n || apiName === unNamespacedTypeApiName,\n `property key and it's apiName must be identical. ${\n JSON.stringify({ key: apiName, apiName: type.apiName })\n }`,\n );\n return type;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,6BAA6B;AAC9E,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAGEC,6BAA6B,QACxB,sCAAsC;AAE7C,SAASC,wCAAwC,QAAQ,yDAAyD;AAClH,SAASC,4BAA4B,QAAQ,6CAA6C;AAC1F,SAASC,QAAQ,EAAEC,kBAAkB,QAAQ,kCAAkC;AA+B/E,OAAO,SAASC,eAAeA,CAC7BC,iBAA0C,EAC3B;EACf,MAAMC,YAAY,GAAGb,eAAe,CAACY,iBAAiB,CAAC;EACvD,MAAME,OAAO,GAAGZ,SAAS,GAAGW,YAAY,CAACC,OAAO;EAChD,EACEX,kBAAkB,CAACF,sBAAsB,CAACc,cAAc,CAAC,CAACD,OAAO,CAAC,KAC5DE,SAAS,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAFjBtB,SAAS,QAGP,aAAaiB,OAAO,iBAAiB,IAHvCjB,SAAS;EAMT,CACEE,cAAc,CAACc,YAAY,CAACC,OAAO,CAAC,GAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADtCtB,SAAS,QAEP,oBAAoBgB,YAAY,CAACC,OAAO,oCAAoChB,gBAAgB,GAAG,IAFjGD,SAAS;;EAKT;EACA,MAAMuB,IAAqC,GAAGC,MAAM,CAACC,WAAW,CAC9DD,MAAM,CAACE,OAAO,CAACV,YAAY,CAACW,UAAU,IAAI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AG,EAAEhD,OAAO;IAAEA,OAAO,EAAEqB,IAAI,CAACrB;EAAQ,CAAC,CAAC,EACvD,IALJjB,SAAS;EAOT,OAAOsC,IAAI;AACb","ignoreList":[]}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import invariant from "tiny-invariant";
|
|
18
|
+
import { isValidApiName } from "../util/ApiNameValidator.js";
|
|
17
19
|
import { cloneDefinition } from "./cloneDefinition.js";
|
|
18
20
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
19
21
|
import { convertToPluralDisplayName, uppercaseFirstLetter } from "./defineObject.js";
|
|
@@ -72,6 +74,7 @@ function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
function convertLinkTypeMetadata(metadata) {
|
|
77
|
+
!isValidApiName(metadata.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid API name for link: ${metadata.apiName}`) : invariant(false) : void 0;
|
|
75
78
|
return {
|
|
76
79
|
apiName: metadata.apiName,
|
|
77
80
|
displayMetadata: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineLink.js","names":["cloneDefinition","OntologyEntityTypeEnum","convertToPluralDisplayName","uppercaseFirstLetter","updateOntology","defineLink","linkDefinitionInput","linkDefinition","fullLinkDefinition","one","convertUserOneToManyLinkDefinition","toMany","many","convertUserIntermediaryLinkDefinition","convertUserManyToManyLinkDefinition","linkType","cardinality","undefined","apiName","__type","LINK_TYPE","oneToMany","metadata","convertLinkTypeMetadata","manyToMany","intermediary","displayMetadata","displayName","pluralDisplayName","visibility","groupDisplayName","typeClasses"],"sources":["defineLink.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type { LinkTypeMetadata } from \"@osdk/client.unstable\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n convertToPluralDisplayName,\n uppercaseFirstLetter,\n} from \"./defineObject.js\";\nimport { updateOntology } from \"./defineOntology.js\";\nimport type {\n IntermediaryObjectLinkReference,\n IntermediaryObjectLinkReferenceUserDefinition,\n LinkType,\n LinkTypeDefinition,\n LinkTypeMetadataUserDefinition,\n ManyToManyObjectLinkReference,\n ManyToManyObjectLinkReferenceUserDefinition,\n OneToManyObjectLinkReference,\n OneToManyObjectLinkReferenceUserDefinition,\n} from \"./links/LinkType.js\";\n\nexport function defineLink(\n linkDefinitionInput: LinkTypeDefinition,\n): LinkType {\n const linkDefinition = cloneDefinition(linkDefinitionInput);\n // NOTE: we would normally do validation here, but because of circular dependencies\n // we have to wait to validate until everything has been defined. The code for validation\n // was moved to convertLink.ts.\n\n let fullLinkDefinition;\n if (\"one\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n one: convertUserOneToManyLinkDefinition(linkDefinition.one),\n toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany),\n };\n } else if (\"intermediaryObjectType\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserIntermediaryLinkDefinition(\n linkDefinition.many,\n ),\n toMany: convertUserIntermediaryLinkDefinition(\n linkDefinition.toMany,\n ),\n };\n } else {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserManyToManyLinkDefinition(linkDefinition.many),\n toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany),\n };\n }\n const linkType: LinkType = {\n cardinality: \"one\" in linkDefinition\n ? linkDefinition.cardinality\n : undefined,\n ...fullLinkDefinition,\n apiName: linkDefinition.apiName,\n __type: OntologyEntityTypeEnum.LINK_TYPE,\n };\n updateOntology(linkType);\n return linkType;\n}\n\nfunction convertUserOneToManyLinkDefinition(\n oneToMany: OneToManyObjectLinkReferenceUserDefinition,\n): OneToManyObjectLinkReference {\n return {\n ...oneToMany,\n metadata: convertLinkTypeMetadata(oneToMany.metadata),\n };\n}\n\nfunction convertUserManyToManyLinkDefinition(\n manyToMany: ManyToManyObjectLinkReferenceUserDefinition,\n): ManyToManyObjectLinkReference {\n return {\n ...manyToMany,\n metadata: convertLinkTypeMetadata(manyToMany.metadata),\n };\n}\n\nfunction convertUserIntermediaryLinkDefinition(\n intermediary: IntermediaryObjectLinkReferenceUserDefinition,\n): IntermediaryObjectLinkReference {\n return {\n ...intermediary,\n metadata: convertLinkTypeMetadata(intermediary.metadata),\n };\n}\n\nfunction convertLinkTypeMetadata(\n metadata: LinkTypeMetadataUserDefinition,\n): LinkTypeMetadata {\n return {\n apiName: metadata.apiName,\n displayMetadata: {\n displayName: metadata.displayName\n ?? uppercaseFirstLetter(metadata.apiName),\n pluralDisplayName: metadata.pluralDisplayName\n ?? convertToPluralDisplayName(metadata.apiName),\n visibility: metadata.visibility ?? \"NORMAL\",\n groupDisplayName: metadata.groupDisplayName ?? \"\",\n },\n typeClasses: [],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,
|
|
1
|
+
{"version":3,"file":"defineLink.js","names":["invariant","isValidApiName","cloneDefinition","OntologyEntityTypeEnum","convertToPluralDisplayName","uppercaseFirstLetter","updateOntology","defineLink","linkDefinitionInput","linkDefinition","fullLinkDefinition","one","convertUserOneToManyLinkDefinition","toMany","many","convertUserIntermediaryLinkDefinition","convertUserManyToManyLinkDefinition","linkType","cardinality","undefined","apiName","__type","LINK_TYPE","oneToMany","metadata","convertLinkTypeMetadata","manyToMany","intermediary","process","env","NODE_ENV","displayMetadata","displayName","pluralDisplayName","visibility","groupDisplayName","typeClasses"],"sources":["defineLink.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type { LinkTypeMetadata } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { isValidApiName } from \"../util/ApiNameValidator.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n convertToPluralDisplayName,\n uppercaseFirstLetter,\n} from \"./defineObject.js\";\nimport { updateOntology } from \"./defineOntology.js\";\nimport type {\n IntermediaryObjectLinkReference,\n IntermediaryObjectLinkReferenceUserDefinition,\n LinkType,\n LinkTypeDefinition,\n LinkTypeMetadataUserDefinition,\n ManyToManyObjectLinkReference,\n ManyToManyObjectLinkReferenceUserDefinition,\n OneToManyObjectLinkReference,\n OneToManyObjectLinkReferenceUserDefinition,\n} from \"./links/LinkType.js\";\n\nexport function defineLink(\n linkDefinitionInput: LinkTypeDefinition,\n): LinkType {\n const linkDefinition = cloneDefinition(linkDefinitionInput);\n // NOTE: we would normally do validation here, but because of circular dependencies\n // we have to wait to validate until everything has been defined. The code for validation\n // was moved to convertLink.ts.\n\n let fullLinkDefinition;\n if (\"one\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n one: convertUserOneToManyLinkDefinition(linkDefinition.one),\n toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany),\n };\n } else if (\"intermediaryObjectType\" in linkDefinition) {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserIntermediaryLinkDefinition(\n linkDefinition.many,\n ),\n toMany: convertUserIntermediaryLinkDefinition(\n linkDefinition.toMany,\n ),\n };\n } else {\n fullLinkDefinition = {\n ...linkDefinition,\n many: convertUserManyToManyLinkDefinition(linkDefinition.many),\n toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany),\n };\n }\n const linkType: LinkType = {\n cardinality: \"one\" in linkDefinition\n ? linkDefinition.cardinality\n : undefined,\n ...fullLinkDefinition,\n apiName: linkDefinition.apiName,\n __type: OntologyEntityTypeEnum.LINK_TYPE,\n };\n updateOntology(linkType);\n return linkType;\n}\n\nfunction convertUserOneToManyLinkDefinition(\n oneToMany: OneToManyObjectLinkReferenceUserDefinition,\n): OneToManyObjectLinkReference {\n return {\n ...oneToMany,\n metadata: convertLinkTypeMetadata(oneToMany.metadata),\n };\n}\n\nfunction convertUserManyToManyLinkDefinition(\n manyToMany: ManyToManyObjectLinkReferenceUserDefinition,\n): ManyToManyObjectLinkReference {\n return {\n ...manyToMany,\n metadata: convertLinkTypeMetadata(manyToMany.metadata),\n };\n}\n\nfunction convertUserIntermediaryLinkDefinition(\n intermediary: IntermediaryObjectLinkReferenceUserDefinition,\n): IntermediaryObjectLinkReference {\n return {\n ...intermediary,\n metadata: convertLinkTypeMetadata(intermediary.metadata),\n };\n}\n\nfunction convertLinkTypeMetadata(\n metadata: LinkTypeMetadataUserDefinition,\n): LinkTypeMetadata {\n invariant(\n isValidApiName(metadata.apiName),\n `Invalid API name for link: ${metadata.apiName}`,\n );\n return {\n apiName: metadata.apiName,\n displayMetadata: {\n displayName: metadata.displayName\n ?? uppercaseFirstLetter(metadata.apiName),\n pluralDisplayName: metadata.pluralDisplayName\n ?? convertToPluralDisplayName(metadata.apiName),\n visibility: metadata.visibility ?? \"NORMAL\",\n groupDisplayName: metadata.groupDisplayName ?? \"\",\n },\n typeClasses: [],\n };\n}\n"],"mappings":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|
import { getObject } from "../conversion/toMarketplace/convertLink.js";
|
|
19
|
+
import { API_NAME_PATTERN, isValidApiName, isValidObjectApiName, OBJECT_API_NAME_PATTERN } from "../util/ApiNameValidator.js";
|
|
19
20
|
import { cloneDefinition } from "./cloneDefinition.js";
|
|
20
21
|
import { OntologyEntityTypeEnum } from "./common/OntologyEntityTypeEnum.js";
|
|
21
22
|
import { addNamespaceIfNone, importedTypes, namespace, ontologyDefinition, updateOntology, withoutNamespace } from "./defineOntology.js";
|
|
@@ -27,7 +28,6 @@ const ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M
|
|
|
27
28
|
|
|
28
29
|
// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)
|
|
29
30
|
const ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
30
|
-
const API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
31
31
|
export function defineObject(objectDefInput) {
|
|
32
32
|
const objectDef = cloneDefinition(objectDefInput);
|
|
33
33
|
const apiName = namespace + objectDef.apiName;
|
|
@@ -35,10 +35,17 @@ export function defineObject(objectDefInput) {
|
|
|
35
35
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== undefined) {
|
|
36
36
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
37
37
|
}
|
|
38
|
-
!
|
|
38
|
+
!isValidObjectApiName(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${OBJECT_API_NAME_PATTERN}.`) : invariant(false) : void 0;
|
|
39
|
+
propertyApiNames.forEach(apiName => {
|
|
40
|
+
!isValidApiName(apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Invalid API name ${apiName} for property on object ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant(false) : void 0;
|
|
41
|
+
});
|
|
39
42
|
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant(false) : void 0;
|
|
40
43
|
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant(false) : void 0;
|
|
41
44
|
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant(false) : void 0;
|
|
45
|
+
if (objectDef.includeEmptyBackingDatasource && objectDef.datasources) {
|
|
46
|
+
const nonDatasetDatasources = objectDef.datasources.filter(ds => ds.type !== "dataset");
|
|
47
|
+
!(nonDatasetDatasources.length === 0) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object type "${objectDef.apiName}" has non-dataset datasources (${nonDatasetDatasources.map(ds => ds.type).join(", ")}) and cannot use includeEmptyBackingDatasource. ` + `Empty backing datasources are only supported for object types with dataset datasources.`) : invariant(false) : void 0;
|
|
48
|
+
}
|
|
42
49
|
const retentionPeriods = (objectDef.datasources ?? []).filter(ds => ds.type === "stream").map(ds => ds.retentionPeriod);
|
|
43
50
|
retentionPeriods.forEach(retentionPeriod => {
|
|
44
51
|
!(retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant(false) : void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineObject.js","names":["invariant","getObject","cloneDefinition","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","withoutNamespace","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","isExotic","isStruct","ISO_8601_DURATION","ISO_8601_DATETIME","API_NAME_PATTERN","defineObject","objectDefInput","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","test","process","env","NODE_ENV","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","retentionPeriods","datasources","filter","ds","type","map","retentionPeriod","forEach","baseDatasources","length","join","derivedDatasources","validateDerivedDatasource","objectStatusType","getStatusType","status","mismatchedProperties","entries","property","propertyStatusType","push","deadline","titleProp","mainValue","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","mappedObjectProp","object","objProp","propertyType","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"sources":["defineObject.ts"],"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 */\n\nimport invariant from \"tiny-invariant\";\nimport { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { ObjectTypeStatus } from \"./object/ObjectTypeStatus.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic, isStruct } from \"./properties/PropertyTypeType.js\";\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nconst API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\\\-]*)$/;\n\nexport function defineObject(\n objectDefInput: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const objectDef = cloneDefinition(objectDefInput);\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n API_NAME_PATTERN.test(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate property statuses match the object status.\n // An experimental object can only have experimental properties.\n // A deprecated object can only have deprecated properties.\n // An example object can only have example properties.\n // There is no restriction on property statuses of an active object.\n const objectStatusType = getStatusType(objectDef.status);\n if (\n objectStatusType === \"experimental\" || objectStatusType === \"deprecated\"\n || objectStatusType === \"example\"\n ) {\n const mismatchedProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status !== undefined) {\n const propertyStatusType = getStatusType(property.status);\n if (propertyStatusType !== objectStatusType) {\n mismatchedProperties.push(apiName);\n }\n }\n },\n );\n invariant(\n mismatchedProperties.length === 0,\n `Object \"${objectDef.apiName}\" has \"${objectStatusType}\" status, but the following properties have a different status: ${\n mismatchedProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]\n ?.type;\n invariant(\n !isExotic(titleProp)\n || (isStruct(titleProp) && titleProp.mainValue\n && !isExotic(titleProp.mainValue.type)),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined\n && allInterfaceProperties[withoutNamespace(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n mapping.interfaceProperty,\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n const apiName = isInterfaceSharedPropertyType(interfaceProp[1])\n ? interfaceProp[1].sharedPropertyType.apiName\n : interfaceProp[0];\n if (apiName in interfaceToObjectProperties) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n apiName,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason:\n `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n type: InterfacePropertyType,\n apiName: string,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n const propertyType = getInterfacePropertyTypeType(type);\n if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction getStatusType(status: ObjectTypeStatus | undefined): string {\n if (status === undefined) {\n return \"active\";\n }\n if (typeof status === \"string\") {\n return status;\n }\n return status.type;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,4CAA4C;AACtE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SACEC,kBAAkB,EAClBC,aAAa,EACbC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,+BAA+B,QAAQ,gDAAgD;AAChG,SACEC,4BAA4B,EAE5BC,6BAA6B,QACxB,sCAAsC;AAY7C,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,kCAAkC;AACrE;AACA,MAAMC,iBAAiB,GACrB,+OAA+O;;AAEjP;AACA,MAAMC,iBAAiB,GACrB,sEAAsE;AAExE,MAAMC,gBAAgB,GAAG,6BAA6B;AAEtD,OAAO,SAASC,YAAYA,CAC1BC,cAAoC,EACd;EACtB,MAAMC,SAAS,GAAGlB,eAAe,CAACiB,cAAc,CAAC;EACjD,MAAME,OAAO,GAAGf,SAAS,GAAGc,SAAS,CAACC,OAAO;EAC7C,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,UAAU,GACzCC,MAAM,CAACC,IAAI,CAACL,SAAS,CAACG,UAA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isValidApiName","isValidObjectApiName","OBJECT_API_NAME_PATTERN","cloneDefinition","OntologyEntityTypeEnum","addNamespaceIfNone","importedTypes","namespace","ontologyDefinition","updateOntology","withoutNamespace","getFlattenedInterfaceProperties","getInterfacePropertyTypeType","isInterfaceSharedPropertyType","isExotic","isStruct","ISO_8601_DURATION","ISO_8601_DATETIME","defineObject","objectDefInput","objectDef","apiName","propertyApiNames","properties","Object","keys","OBJECT_TYPE","undefined","Error","process","env","NODE_ENV","forEach","includes","titlePropertyApiName","primaryKeyPropertyApiName","editOnly","includeEmptyBackingDatasource","datasources","nonDatasetDatasources","filter","ds","type","length","map","join","retentionPeriods","retentionPeriod","test","baseDatasources","derivedDatasources","validateDerivedDatasource","objectStatusType","getStatusType","status","mismatchedProperties","entries","property","propertyStatusType","push","deadline","titleProp","mainValue","implementsInterfaces","interfaceImpl","allInterfaceProperties","implements","nonExistentInterfaceProperties","propertyMapping","val","interfaceProperty","interfaceProp","reason","interfaceToObjectProperties","fromEntries","mapping","mapsTo","validateProperty","sharedPropertyType","validateInterfaceImplProperty","validations","allFailedValidations","concat","formatValidationErrors","flattenedProperties","convertUserObjectPropertyType","finalObject","__type","error","mappedObjectProp","object","objProp","propertyType","JSON","stringify","uppercaseFirstLetter","s","charAt","toUpperCase","slice","convertToPluralDisplayName","endsWith","displayName","datasource","linkDefinition","link","linkApiName","linkType","LINK_TYPE","prop","isLinkedProperties","values","validateLinkedProperties","validateAggregations","getPropertiesForValidation","linkObject","targetApiName","selfApiName","hasProperty","propName","find","p","foreignProperties","targetObject","at","toMany","props","agg","isCollectible","limit","isNumeric","isPrimitive","foreignProperty","array","typeType"],"sources":["defineObject.ts"],"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 */\n\nimport invariant from \"tiny-invariant\";\nimport { getObject } from \"../conversion/toMarketplace/convertLink.js\";\nimport {\n API_NAME_PATTERN,\n isValidApiName,\n isValidObjectApiName,\n OBJECT_API_NAME_PATTERN,\n} from \"../util/ApiNameValidator.js\";\nimport { cloneDefinition } from \"./cloneDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"./common/OntologyEntityTypeEnum.js\";\nimport {\n addNamespaceIfNone,\n importedTypes,\n namespace,\n ontologyDefinition,\n updateOntology,\n withoutNamespace,\n} from \"./defineOntology.js\";\nimport { getFlattenedInterfaceProperties } from \"./interface/getFlattenedInterfaceProperties.js\";\nimport {\n getInterfacePropertyTypeType,\n type InterfacePropertyType,\n isInterfaceSharedPropertyType,\n} from \"./interface/InterfacePropertyType.js\";\nimport type { ObjectPropertyType } from \"./object/ObjectPropertyType.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./object/ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectType } from \"./object/ObjectType.js\";\nimport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_stream,\n} from \"./object/ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeDefinition } from \"./object/ObjectTypeDefinition.js\";\nimport type { ObjectTypeStatus } from \"./object/ObjectTypeStatus.js\";\nimport type { PropertyTypeType } from \"./properties/PropertyTypeType.js\";\nimport { isExotic, isStruct } from \"./properties/PropertyTypeType.js\";\n// From https://stackoverflow.com/a/79288714\nconst ISO_8601_DURATION =\n /^P(?!$)(?:(?:((?:\\d+Y)|(?:\\d+(?:\\.|,)\\d+Y$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+D)|(?:\\d+(?:\\.|,)\\d+D$))?(T((?:\\d+H)|(?:\\d+(?:\\.|,)\\d+H$))?((?:\\d+M)|(?:\\d+(?:\\.|,)\\d+M$))?((?:\\d+S)|(?:\\d+(?:\\.|,)\\d+S$))?)?)|(?:\\d+(?:(?:\\.|,)\\d+)?W))$/;\n\n// ISO 8601 date and time format (YYYY-MM-DDThh:mm:ss.sssZ)\nconst ISO_8601_DATETIME =\n /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/;\n\nexport function defineObject(\n objectDefInput: ObjectTypeDefinition,\n): ObjectTypeDefinition {\n const objectDef = cloneDefinition(objectDefInput);\n const apiName = namespace + objectDef.apiName;\n const propertyApiNames = objectDef.properties\n ? Object.keys(objectDef.properties)\n : [];\n if (\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName]\n !== undefined\n ) {\n throw new Error(\n `Object type with apiName ${objectDef.apiName} is already defined`,\n );\n }\n invariant(\n isValidObjectApiName(objectDef.apiName),\n `Invalid API name ${objectDef.apiName}. API names must match the regex ${OBJECT_API_NAME_PATTERN}.`,\n );\n propertyApiNames.forEach(apiName => {\n invariant(\n isValidApiName(apiName),\n `Invalid API name ${apiName} for property on object ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`,\n );\n });\n invariant(\n propertyApiNames.includes(objectDef.titlePropertyApiName),\n `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`,\n );\n invariant(\n propertyApiNames.includes(objectDef.primaryKeyPropertyApiName),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`,\n );\n\n invariant(\n !(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`,\n );\n\n if (objectDef.includeEmptyBackingDatasource && objectDef.datasources) {\n const nonDatasetDatasources = objectDef.datasources.filter(\n ds => ds.type !== \"dataset\",\n );\n invariant(\n nonDatasetDatasources.length === 0,\n `Object type \"${objectDef.apiName}\" has non-dataset datasources (${\n nonDatasetDatasources.map(ds => ds.type).join(\", \")\n }) and cannot use includeEmptyBackingDatasource. `\n + `Empty backing datasources are only supported for object types with dataset datasources.`,\n );\n }\n\n const retentionPeriods =\n ((objectDef.datasources ?? []).filter(ds =>\n ds.type === \"stream\"\n ) as ObjectTypeDatasourceDefinition_stream[]).map(ds => ds.retentionPeriod);\n retentionPeriods.forEach(retentionPeriod => {\n invariant(\n retentionPeriod === undefined || ISO_8601_DURATION.test(retentionPeriod),\n `Retention period \"${retentionPeriod}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 duration string`,\n );\n });\n\n const baseDatasources = (objectDef.datasources ?? []).filter(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n invariant(\n baseDatasources.length <= 1,\n `Object ${objectDef.apiName} has more than one base datasource (got: [${\n baseDatasources.map(ds => ds.type).join(\", \")\n }])`,\n );\n const derivedDatasources = (objectDef.datasources ?? []).filter(ds =>\n ds.type === \"derived\"\n );\n if (derivedDatasources.length > 0) {\n derivedDatasources.forEach(ds => validateDerivedDatasource(objectDef, ds));\n }\n\n // Validate property statuses match the object status.\n // An experimental object can only have experimental properties.\n // A deprecated object can only have deprecated properties.\n // An example object can only have example properties.\n // There is no restriction on property statuses of an active object.\n const objectStatusType = getStatusType(objectDef.status);\n if (\n objectStatusType === \"experimental\" || objectStatusType === \"deprecated\"\n || objectStatusType === \"example\"\n ) {\n const mismatchedProperties: string[] = [];\n Object.entries(objectDef.properties ?? {}).forEach(\n ([apiName, property]) => {\n if (property.status !== undefined) {\n const propertyStatusType = getStatusType(property.status);\n if (propertyStatusType !== objectStatusType) {\n mismatchedProperties.push(apiName);\n }\n }\n },\n );\n invariant(\n mismatchedProperties.length === 0,\n `Object \"${objectDef.apiName}\" has \"${objectStatusType}\" status, but the following properties have a different status: ${\n mismatchedProperties.join(\", \")\n }`,\n );\n }\n\n // Validate deprecated status deadline is in ISO 8601 format\n if (\n objectDef.status && typeof objectDef.status === \"object\"\n && objectDef.status.type === \"deprecated\"\n ) {\n const deadline = objectDef.status.deadline;\n invariant(\n deadline !== undefined && ISO_8601_DATETIME.test(deadline),\n `Deprecated status deadline \"${deadline}\" on object \"${objectDef.apiName}\" is not a valid ISO 8601 datetime string`,\n );\n }\n const titleProp = objectDef.properties?.[objectDef.titlePropertyApiName]\n ?.type;\n invariant(\n !isExotic(titleProp)\n || (isStruct(titleProp) && titleProp.mainValue\n && !isExotic(titleProp.mainValue.type)),\n `Title property ${objectDef.titlePropertyApiName} must be a primitive type`,\n );\n invariant(\n !isExotic(\n objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type,\n ),\n `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`,\n );\n\n objectDef.implementsInterfaces?.forEach(interfaceImpl => {\n const allInterfaceProperties = getFlattenedInterfaceProperties(\n interfaceImpl.implements,\n );\n const nonExistentInterfaceProperties: ValidationResult[] = interfaceImpl\n .propertyMapping.map(val => val.interfaceProperty).filter(\n interfaceProperty =>\n allInterfaceProperties[addNamespaceIfNone(interfaceProperty)]\n === undefined\n && allInterfaceProperties[withoutNamespace(interfaceProperty)]\n === undefined,\n ).map(interfaceProp => ({\n type: \"invalid\",\n reason:\n `Interface property ${interfaceProp} referenced in ${objectDef.apiName} object does not exist`,\n }));\n\n const interfaceToObjectProperties = Object.fromEntries(\n interfaceImpl.propertyMapping.map(\n mapping => [\n mapping.interfaceProperty,\n mapping.mapsTo,\n ],\n ),\n );\n const validateProperty = (\n interfaceProp: [string, InterfacePropertyType],\n ): ValidationResult => {\n const apiName = isInterfaceSharedPropertyType(interfaceProp[1])\n ? interfaceProp[1].sharedPropertyType.apiName\n : interfaceProp[0];\n if (apiName in interfaceToObjectProperties) {\n return validateInterfaceImplProperty(\n interfaceProp[1],\n apiName,\n interfaceToObjectProperties[interfaceProp[0]],\n objectDef,\n );\n }\n return {\n type: \"invalid\",\n reason:\n `Interface spt ${apiName} not implemented by ${objectDef.apiName} object definition`,\n };\n };\n const validations = Object.entries(\n getFlattenedInterfaceProperties(interfaceImpl.implements),\n ).map(validateProperty);\n const allFailedValidations = validations.concat(\n nonExistentInterfaceProperties,\n ).filter(val => val.type === \"invalid\");\n invariant(\n allFailedValidations.length === 0,\n \"\\n\" + allFailedValidations.map(formatValidationErrors).join(\"\\n\"),\n );\n });\n\n const flattenedProperties: Array<ObjectPropertyType> = Object.entries(\n objectDef.properties ?? {},\n ).map(([apiName, property]) =>\n convertUserObjectPropertyType(apiName, property)\n );\n\n const finalObject: ObjectType = {\n ...objectDef,\n apiName: apiName,\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n properties: flattenedProperties,\n };\n updateOntology(finalObject);\n objectDef.apiName = apiName;\n return objectDef;\n}\n\ntype ValidationResult = { type: \"valid\" } | { type: \"invalid\"; reason: string };\n\nfunction formatValidationErrors(\n error: { type: \"invalid\"; reason: string },\n): string {\n return `Ontology Definition Error: ${error.reason}\\n`;\n}\n\n// Validate that the object and the interface property match up\nfunction validateInterfaceImplProperty(\n type: InterfacePropertyType,\n apiName: string,\n mappedObjectProp: string,\n object: ObjectTypeDefinition,\n): ValidationResult {\n const objProp = object.properties?.[mappedObjectProp];\n if (objProp === undefined) {\n return {\n type: \"invalid\",\n reason:\n `Object property mapped to interface does not exist. Object Property Mapped: ${mappedObjectProp}`,\n };\n }\n const propertyType = getInterfacePropertyTypeType(type);\n if (JSON.stringify(propertyType) !== JSON.stringify(objProp?.type)) {\n return {\n type: \"invalid\",\n reason:\n `Object property type does not match the interface property it is mapped to. Interface Property: ${apiName}, objectProperty: ${mappedObjectProp}`,\n };\n }\n\n return { type: \"valid\" };\n}\n\nexport function uppercaseFirstLetter(s: string | undefined | null): string {\n return s === undefined || s == null\n ? \"\"\n : s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n// TODO: edge cases\nexport function convertToPluralDisplayName(\n s: string | undefined | null,\n): string {\n return s === undefined || s == null\n ? \"\"\n : s.endsWith(\"s\")\n ? uppercaseFirstLetter(s)\n : uppercaseFirstLetter(s) + \"s\";\n}\n\nfunction convertUserObjectPropertyType(\n apiName: string,\n property: ObjectPropertyTypeUserDefinition,\n): ObjectPropertyType {\n // fill in missing fields to be used by actions\n property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);\n return {\n ...property,\n apiName: apiName,\n displayName: property.displayName ?? uppercaseFirstLetter(apiName),\n type: property.type,\n };\n}\nfunction validateDerivedDatasource(\n objectDef: ObjectTypeDefinition,\n datasource: ObjectTypeDatasourceDefinition_derived,\n) {\n // there should be at least one link\n invariant(\n datasource.linkDefinition.length > 0,\n `Derived datasource for object '${objectDef.apiName}' must have at least one link.`,\n );\n\n // all of the links references should exist\n datasource.linkDefinition.forEach(link => {\n const linkApiName = link.linkType.apiName;\n invariant(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined\n || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName]\n !== undefined,\n `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n // all of the properties references on the source object should exist\n Object.keys(datasource.propertyMapping).forEach(prop => {\n invariant(\n objectDef.properties?.[prop] !== undefined,\n `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`,\n );\n });\n\n const isLinkedProperties =\n (typeof Object.values(datasource.propertyMapping)[0]) === \"string\";\n if (isLinkedProperties) {\n validateLinkedProperties(datasource, objectDef);\n } else {\n validateAggregations(datasource, objectDef);\n }\n}\n\n/**\n * Gets properties for validation, handling self-referential links where\n * the target object is the same as the object being defined (not yet in registry).\n */\nfunction getPropertiesForValidation(\n linkObject: string | ObjectTypeDefinition,\n objectDef: ObjectTypeDefinition,\n): { apiName: string; hasProperty: (propName: string) => boolean } {\n const targetApiName = typeof linkObject === \"string\"\n ? linkObject\n : linkObject.apiName;\n const selfApiName = namespace + objectDef.apiName;\n\n // Self-referential: use objectDef directly (not yet in registry)\n if (targetApiName === selfApiName) {\n return {\n apiName: selfApiName,\n hasProperty: (propName: string) =>\n objectDef.properties?.[propName] !== undefined,\n };\n }\n\n // Non-self-referential: look up from registry\n const { apiName, object } = getObject(linkObject);\n return {\n apiName,\n hasProperty: (propName: string) =>\n object.properties?.find(p => p.apiName === propName) !== undefined,\n };\n}\n\nfunction validateLinkedProperties(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const foreignProperties = Object.values(\n datasource.propertyMapping,\n ) as string[];\n // the foreign property must exist in the final object in the link chain\n const targetObject = datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n foreignProperties.forEach(prop => {\n invariant(\n hasProperty(prop),\n `Property '${prop}' on object '${apiName}' is not defined`,\n );\n });\n}\n\nfunction validateAggregations(\n datasource: ObjectTypeDatasourceDefinition_derived,\n objectDef: ObjectTypeDefinition,\n) {\n const props = datasource.propertyMapping as Record<\n string,\n DerivedPropertyAggregation\n >;\n\n Object.entries(props).forEach(([propName, agg]) => {\n // TODO(dpaquin): check that the property type matches the foreign property type,\n // for collectList/collectSet and maybe min/max too?\n const property = objectDef.properties![propName];\n switch (agg.type) {\n case \"collectList\":\n case \"collectSet\":\n // property's type is collectible\n invariant(\n isCollectible(property),\n `Property '${propName}' on object '${objectDef.apiName}' is not collectible`,\n );\n // limit <= 100\n invariant(\n agg.limit <= 100,\n `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`,\n );\n break;\n case \"avg\":\n case \"sum\":\n // property's type is numeric\n invariant(\n isNumeric(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not numeric`,\n );\n break;\n case \"min\":\n case \"max\":\n case \"approximateCardinality\":\n case \"exactCardinality\":\n // property's type is primitive\n invariant(\n isPrimitive(property.type),\n `Property '${propName}' on object '${objectDef.apiName}' is not primitive`,\n );\n break;\n default:\n break;\n }\n\n // if a foreign property is referenced, it must exist in the final object\n if (agg.type !== \"count\") {\n const foreignProperty = agg.property;\n const targetObject =\n datasource.linkDefinition.at(-1)!.linkType.toMany.object;\n const { apiName, hasProperty } = getPropertiesForValidation(\n targetObject,\n objectDef,\n );\n invariant(\n hasProperty(foreignProperty),\n `Property '${foreignProperty}' on object '${apiName}' is not defined`,\n );\n }\n });\n}\n\nfunction isCollectible(property: ObjectPropertyTypeUserDefinition): boolean {\n if (!(property.array ?? false)) {\n return false;\n }\n const typeType = typeof property.type === \"string\"\n ? property.type\n : property.type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"geohash\",\n \"geoshape\",\n \"integer\",\n \"long\",\n \"mediareference\",\n \"short\",\n \"string\",\n \"struct\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction isNumeric(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"byte\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n ].includes(typeType);\n}\n\nfunction isPrimitive(type: PropertyTypeType): boolean {\n const typeType = typeof type === \"string\" ? type : type.type;\n return [\n \"boolean\",\n \"byte\",\n \"date\",\n \"double\",\n \"float\",\n \"integer\",\n \"long\",\n \"short\",\n \"string\",\n \"timestamp\",\n ].includes(typeType);\n}\n\nfunction getStatusType(status: ObjectTypeStatus | undefined): string {\n if (status === undefined) {\n return \"active\";\n }\n if (typeof status === \"string\") {\n return status;\n }\n return status.type;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,4CAA4C;AACtE,SACEC,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,EACpBC,uBAAuB,QAClB,6BAA6B;AACpC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,sBAAsB,QAAQ,oCAAoC;AAC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1
|
-
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type {\n InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {\n InterfacePropertyType,\n InterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\n\nexport interface InterfaceType extends\n OntologyEntityBase,\n Omit<\n OntologyIrMarketplaceInterfaceType,\n // we want our simplified representation\n | \"properties\"\n // these things don't need to exist as the system works fine without them (I'm told)\n | \"propertiesV2\"\n | \"propertiesV3\"\n | \"extendsInterfaces\"\n >\n{\n propertiesV2: Record<string, InterfaceSharedPropertyType>;\n propertiesV3: Record<string, InterfacePropertyType>;\n extendsInterfaces: Array<InterfaceType>;\n status: InterfaceTypeStatus;\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InterfaceType.js","names":[],"sources":["InterfaceType.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type {\n InterfaceTypeStatus,\n OntologyIrMarketplaceInterfaceType,\n} from \"@osdk/client.unstable\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type {\n InterfacePropertyType,\n InterfaceSharedPropertyType,\n} from \"./InterfacePropertyType.js\";\n\nexport interface InterfaceType extends\n OntologyEntityBase,\n Omit<\n OntologyIrMarketplaceInterfaceType,\n // we want our simplified representation\n | \"properties\"\n // these things don't need to exist as the system works fine without them (I'm told)\n | \"propertiesV2\"\n | \"propertiesV3\"\n | \"extendsInterfaces\"\n | \"extendsInterfacesMetadata\"\n >\n{\n propertiesV2: Record<string, InterfaceSharedPropertyType>;\n propertiesV3: Record<string, InterfacePropertyType>;\n extendsInterfaces: Array<InterfaceType>;\n status: InterfaceTypeStatus;\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkType.js","names":[],"sources":["LinkType.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type {\n LinkTypeDisplayMetadata,\n LinkTypeId,\n LinkTypeMetadata,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OptionalFields } from \"../../util/OptionalFields.js\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { ObjectTypeDefinition } from \"../object/ObjectTypeDefinition.js\";\n\nexport type LinkType =\n | (OntologyEntityBase & OneToManyLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n })\n | (OntologyEntityBase & ManyToManyLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n })\n | (OntologyEntityBase & IntermediaryLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n });\n\nexport type LinkTypeDefinition =\n | Omit<\n OntologyEntityBase & OneToManyLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >\n | Omit<\n OntologyEntityBase & ManyToManyLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >\n | Omit<\n OntologyEntityBase & IntermediaryLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >;\n\nexport type ObjectTypePropertyApiName = string;\n\nexport interface OneToManyLinkTypeDefinition {\n apiName: string;\n one: OneToManyObjectLinkReference;\n toMany: OneToManyObjectLinkReference;\n manyForeignKeyProperty: ObjectTypePropertyApiName;\n cardinality: \"OneToMany\" | \"OneToOne\" | undefined;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n}\n\nexport interface OneToManyObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n}\n\nexport interface OneToManyLinkTypeUserDefinition {\n apiName: string;\n one: OneToManyObjectLinkReferenceUserDefinition;\n toMany: OneToManyObjectLinkReferenceUserDefinition;\n manyForeignKeyProperty: ObjectTypePropertyApiName;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n cardinality?: \"OneToMany\" | \"OneToOne\" | undefined;\n}\n\nexport interface OneToManyObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n}\n\nexport interface ManyToManyLinkTypeDefinition {\n apiName: string;\n many: ManyToManyObjectLinkReference;\n toMany: ManyToManyObjectLinkReference;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n}\n\nexport interface ManyToManyObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n}\n\nexport interface ManyToManyLinkTypeUserDefinition {\n apiName: string;\n many: ManyToManyObjectLinkReferenceUserDefinition;\n toMany: ManyToManyObjectLinkReferenceUserDefinition;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n}\n\nexport interface ManyToManyObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n}\n\nexport interface IntermediaryLinkTypeDefinition {\n apiName: string;\n many: IntermediaryObjectLinkReference;\n toMany: IntermediaryObjectLinkReference;\n intermediaryObjectType: ObjectTypeDefinition;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n}\n\nexport interface IntermediaryObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n linkToIntermediary: LinkType;\n}\n\nexport interface IntermediaryLinkTypeUserDefinition {\n apiName: string;\n many: IntermediaryObjectLinkReferenceUserDefinition;\n toMany: IntermediaryObjectLinkReferenceUserDefinition;\n intermediaryObjectType: ObjectTypeDefinition | string;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n}\n\nexport interface IntermediaryObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n linkToIntermediary: LinkType;\n}\n\nexport interface LinkTypeMetadataUserDefinition {\n apiName: string;\n displayName?: string;\n pluralDisplayName?: string;\n visibility?: Visibility;\n groupDisplayName?: string;\n}\n\nexport type LinkSideMetadata = OptionalFields<\n RequiredFields<\n Omit<LinkTypeMetadata, \"displayMetadata\"> & LinkTypeDisplayMetadata,\n \"apiName\"\n >,\n \"visibility\" | \"typeClasses\"\n>;\n\nexport type UserLinkTypeStatus =\n | \"active\"\n | \"experimental\"\n | \"example\"\n | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: LinkTypeId;\n };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LinkType.js","names":[],"sources":["LinkType.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport type {\n LinkTypeDisplayMetadata,\n LinkTypeId,\n LinkTypeMetadata,\n Visibility,\n} from \"@osdk/client.unstable\";\nimport type { OptionalFields } from \"../../util/OptionalFields.js\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { ObjectTypeDefinition } from \"../object/ObjectTypeDefinition.js\";\n\nexport type LinkType =\n | (OntologyEntityBase & OneToManyLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n })\n | (OntologyEntityBase & ManyToManyLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n })\n | (OntologyEntityBase & IntermediaryLinkTypeDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n });\n\nexport type LinkTypeDefinition =\n | Omit<\n OntologyEntityBase & OneToManyLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >\n | Omit<\n OntologyEntityBase & ManyToManyLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >\n | Omit<\n OntologyEntityBase & IntermediaryLinkTypeUserDefinition & {\n __type: OntologyEntityTypeEnum.LINK_TYPE;\n },\n \"__type\"\n >;\n\nexport type ObjectTypePropertyApiName = string;\n\nexport interface OneToManyLinkTypeDefinition {\n apiName: string;\n one: OneToManyObjectLinkReference;\n toMany: OneToManyObjectLinkReference;\n manyForeignKeyProperty: ObjectTypePropertyApiName;\n cardinality: \"OneToMany\" | \"OneToOne\" | undefined;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n}\n\nexport interface OneToManyObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n}\n\nexport interface OneToManyLinkTypeUserDefinition {\n apiName: string;\n one: OneToManyObjectLinkReferenceUserDefinition;\n toMany: OneToManyObjectLinkReferenceUserDefinition;\n manyForeignKeyProperty: ObjectTypePropertyApiName;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n cardinality?: \"OneToMany\" | \"OneToOne\" | undefined;\n}\n\nexport interface OneToManyObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n}\n\nexport interface ManyToManyLinkTypeDefinition {\n apiName: string;\n many: ManyToManyObjectLinkReference;\n toMany: ManyToManyObjectLinkReference;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n includeEmptyBackingDatasource?: boolean;\n}\n\nexport interface ManyToManyObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n}\n\nexport interface ManyToManyLinkTypeUserDefinition {\n apiName: string;\n many: ManyToManyObjectLinkReferenceUserDefinition;\n toMany: ManyToManyObjectLinkReferenceUserDefinition;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n includeEmptyBackingDatasource?: boolean;\n}\n\nexport interface ManyToManyObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n}\n\nexport interface IntermediaryLinkTypeDefinition {\n apiName: string;\n many: IntermediaryObjectLinkReference;\n toMany: IntermediaryObjectLinkReference;\n intermediaryObjectType: ObjectTypeDefinition;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n redacted?: boolean;\n}\n\nexport interface IntermediaryObjectLinkReference {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadata;\n linkToIntermediary: LinkType;\n}\n\nexport interface IntermediaryLinkTypeUserDefinition {\n apiName: string;\n many: IntermediaryObjectLinkReferenceUserDefinition;\n toMany: IntermediaryObjectLinkReferenceUserDefinition;\n intermediaryObjectType: ObjectTypeDefinition | string;\n editsEnabled?: boolean;\n status?: UserLinkTypeStatus;\n}\n\nexport interface IntermediaryObjectLinkReferenceUserDefinition {\n object: ObjectTypeDefinition | string;\n metadata: LinkTypeMetadataUserDefinition;\n linkToIntermediary: LinkType;\n}\n\nexport interface LinkTypeMetadataUserDefinition {\n apiName: string;\n displayName?: string;\n pluralDisplayName?: string;\n visibility?: Visibility;\n groupDisplayName?: string;\n}\n\nexport type LinkSideMetadata = OptionalFields<\n RequiredFields<\n Omit<LinkTypeMetadata, \"displayMetadata\"> & LinkTypeDisplayMetadata,\n \"apiName\"\n >,\n \"visibility\" | \"typeClasses\"\n>;\n\nexport type UserLinkTypeStatus =\n | \"active\"\n | \"experimental\"\n | \"example\"\n | {\n type: \"deprecated\";\n message: string;\n deadline: string;\n replacedBy?: LinkTypeId;\n };\n"],"mappings":"","ignoreList":[]}
|