@osdk/maker 0.8.0-beta.9 → 0.8.1
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 +95 -0
- package/build/browser/api/defineInterface.d.ts +14 -0
- package/build/browser/api/defineInterface.d.ts.map +1 -0
- package/build/browser/api/defineInterface.js +67 -0
- package/build/browser/api/defineInterface.js.map +1 -0
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts +21 -0
- package/build/browser/api/defineInterfaceLinkConstraint.d.ts.map +1 -0
- package/build/browser/api/defineInterfaceLinkConstraint.js +50 -0
- package/build/browser/api/defineInterfaceLinkConstraint.js.map +1 -0
- package/build/browser/api/defineLink.d.ts +18 -0
- package/build/browser/api/defineLink.d.ts.map +1 -0
- package/build/browser/api/defineLink.js +37 -0
- package/build/browser/api/defineLink.js.map +1 -0
- package/build/browser/api/defineObject.d.ts +15 -0
- package/build/browser/api/defineObject.d.ts.map +1 -0
- package/build/browser/api/defineObject.js +86 -0
- package/build/browser/api/defineObject.js.map +1 -0
- package/build/browser/api/defineOntology.d.ts +10 -0
- package/build/browser/api/defineOntology.d.ts.map +1 -0
- package/build/browser/api/defineOntology.js +174 -0
- package/build/browser/api/defineOntology.js.map +1 -0
- package/build/browser/api/defineSpt.d.ts +13 -0
- package/build/browser/api/defineSpt.d.ts.map +1 -0
- package/build/browser/api/defineSpt.js +36 -0
- package/build/browser/api/defineSpt.js.map +1 -0
- package/build/browser/api/defineValueType.d.ts +26 -0
- package/build/browser/api/defineValueType.d.ts.map +1 -0
- package/build/browser/api/defineValueType.js +61 -0
- package/build/browser/api/defineValueType.js.map +1 -0
- package/build/browser/api/iconNames.d.ts +3 -0
- package/build/browser/api/iconNames.d.ts.map +1 -0
- package/build/browser/api/iconNames.js +17 -0
- package/build/browser/api/iconNames.js.map +1 -0
- package/build/browser/api/overall.test.d.ts +2 -0
- package/build/browser/api/overall.test.d.ts.map +1 -0
- package/build/browser/api/overall.test.js +617 -0
- package/build/browser/api/overall.test.js.map +1 -0
- package/build/browser/api/types.d.ts +38 -0
- package/build/browser/api/types.d.ts.map +1 -0
- package/build/browser/api/types.js +17 -0
- package/build/browser/api/types.js.map +1 -0
- package/build/browser/cli/main.d.ts +2 -0
- package/build/browser/cli/main.d.ts.map +1 -0
- package/build/browser/cli/main.js +121 -0
- package/build/browser/cli/main.js.map +1 -0
- package/build/browser/index.d.ts +6 -0
- package/build/browser/index.d.ts.map +1 -0
- package/build/browser/index.js +20 -280
- package/build/browser/index.js.map +1 -1
- package/build/esm/api/defineInterface.d.ts +1 -0
- package/build/esm/api/defineInterface.d.ts.map +1 -1
- package/build/esm/api/defineInterface.js +67 -0
- package/build/esm/api/defineInterface.js.map +1 -0
- package/build/esm/api/defineInterfaceLinkConstraint.js +50 -0
- package/build/esm/api/defineInterfaceLinkConstraint.js.map +1 -0
- package/build/esm/api/defineLink.js +37 -0
- package/build/esm/api/defineLink.js.map +1 -0
- package/build/esm/api/defineObject.d.ts +2 -2
- package/build/esm/api/defineObject.d.ts.map +1 -1
- package/build/esm/api/defineObject.js +86 -0
- package/build/esm/api/defineObject.js.map +1 -0
- package/build/esm/api/defineOntology.d.ts +8 -2
- package/build/esm/api/defineOntology.d.ts.map +1 -1
- package/build/esm/api/defineOntology.js +174 -0
- package/build/esm/api/defineOntology.js.map +1 -0
- package/build/esm/api/defineSpt.d.ts +2 -1
- package/build/esm/api/defineSpt.d.ts.map +1 -1
- package/build/esm/api/defineSpt.js +36 -0
- package/build/esm/api/defineSpt.js.map +1 -0
- package/build/esm/api/defineValueType.d.ts +26 -0
- package/build/esm/api/defineValueType.d.ts.map +1 -0
- package/build/esm/api/defineValueType.js +61 -0
- package/build/esm/api/defineValueType.js.map +1 -0
- package/build/esm/api/iconNames.js +17 -0
- package/build/esm/api/iconNames.js.map +1 -0
- package/build/esm/api/overall.test.js +617 -0
- package/build/esm/api/overall.test.js.map +1 -0
- package/build/esm/api/types.d.ts +12 -1
- package/build/esm/api/types.d.ts.map +1 -1
- package/build/esm/api/types.js +17 -0
- package/build/esm/api/types.js.map +1 -0
- package/build/esm/cli/main.d.ts.map +1 -1
- package/build/esm/cli/main.js +121 -0
- package/build/esm/cli/main.js.map +1 -0
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +20 -280
- package/build/esm/index.js.map +1 -1
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,100 @@
|
|
|
1
1
|
# @osdk/maker
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @osdk/api@2.0.1
|
|
8
|
+
|
|
9
|
+
## 0.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b916b3d: Fix api namespacing of shared property types
|
|
14
|
+
- 465660b: Add icon support to maker
|
|
15
|
+
- dc25fb4: Further simplify types
|
|
16
|
+
- 1252d94: ESM Only
|
|
17
|
+
- ee39a61: Adding value types to ont as code
|
|
18
|
+
- 6e3726b: Support namespacing maker generate ontologies
|
|
19
|
+
- 465660b: Fix double namespacing bug.
|
|
20
|
+
- ee39a61: Add support for gotham mapping of SPTs in maker
|
|
21
|
+
- 7282cf6: Add Default Type Classes to maker
|
|
22
|
+
- d4d6605: Audited and cleaned up deps
|
|
23
|
+
- 64818dc: Drop support for internal gateway package
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [dc25fb4]
|
|
28
|
+
- Updated dependencies [3affe49]
|
|
29
|
+
- Updated dependencies [b946e00]
|
|
30
|
+
- Updated dependencies [a2c7b37]
|
|
31
|
+
- Updated dependencies [0ea1a17]
|
|
32
|
+
- Updated dependencies [dc25fb4]
|
|
33
|
+
- Updated dependencies [9b0617d]
|
|
34
|
+
- Updated dependencies [94105a5]
|
|
35
|
+
- Updated dependencies [dc25fb4]
|
|
36
|
+
- Updated dependencies [a2c7b37]
|
|
37
|
+
- Updated dependencies [dc25fb4]
|
|
38
|
+
- Updated dependencies [1252d94]
|
|
39
|
+
- Updated dependencies [e6ade8b]
|
|
40
|
+
- Updated dependencies [dc25fb4]
|
|
41
|
+
- Updated dependencies [dc25fb4]
|
|
42
|
+
- Updated dependencies [a2c7b37]
|
|
43
|
+
- Updated dependencies [795777a]
|
|
44
|
+
- Updated dependencies [fe9547e]
|
|
45
|
+
- Updated dependencies [95f9247]
|
|
46
|
+
- Updated dependencies [d2f75f9]
|
|
47
|
+
- Updated dependencies [b7cd0a1]
|
|
48
|
+
- Updated dependencies [512ee35]
|
|
49
|
+
- Updated dependencies [e86c505]
|
|
50
|
+
- Updated dependencies [dc25fb4]
|
|
51
|
+
- Updated dependencies [0ce2858]
|
|
52
|
+
- Updated dependencies [dc25fb4]
|
|
53
|
+
- Updated dependencies [7c2db00]
|
|
54
|
+
- Updated dependencies [dc25fb4]
|
|
55
|
+
- Updated dependencies [dc25fb4]
|
|
56
|
+
- Updated dependencies [fc28eae]
|
|
57
|
+
- Updated dependencies [56df85a]
|
|
58
|
+
- Updated dependencies [dc25fb4]
|
|
59
|
+
- Updated dependencies [a9923f3]
|
|
60
|
+
- Updated dependencies [1f633f7]
|
|
61
|
+
- Updated dependencies [d4d6605]
|
|
62
|
+
- Updated dependencies [64818dc]
|
|
63
|
+
- @osdk/api@2.0.0
|
|
64
|
+
|
|
65
|
+
## 0.8.0-beta.12
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- dc25fb4: Further simplify types
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [dc25fb4]
|
|
74
|
+
- Updated dependencies [dc25fb4]
|
|
75
|
+
- @osdk/api@2.0.0-beta.16
|
|
76
|
+
|
|
77
|
+
## 0.8.0-beta.11
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [dc25fb4]
|
|
82
|
+
- @osdk/api@2.0.0-beta.15
|
|
83
|
+
|
|
84
|
+
## 0.8.0-beta.10
|
|
85
|
+
|
|
86
|
+
### Minor Changes
|
|
87
|
+
|
|
88
|
+
- d4d6605: Audited and cleaned up deps
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [a2c7b37]
|
|
93
|
+
- Updated dependencies [fe9547e]
|
|
94
|
+
- Updated dependencies [1f633f7]
|
|
95
|
+
- Updated dependencies [d4d6605]
|
|
96
|
+
- @osdk/api@2.0.0-beta.14
|
|
97
|
+
|
|
3
98
|
## 0.8.0-beta.9
|
|
4
99
|
|
|
5
100
|
### Patch Changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BlueprintIcon } from "./iconNames.js";
|
|
2
|
+
import type { InterfaceType, PropertyTypeType, SharedPropertyType } from "./types.js";
|
|
3
|
+
export declare function defineInterface(opts: {
|
|
4
|
+
apiName: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: {
|
|
8
|
+
locator: BlueprintIcon;
|
|
9
|
+
color: string;
|
|
10
|
+
};
|
|
11
|
+
properties?: Record<string, SharedPropertyType | PropertyTypeType>;
|
|
12
|
+
extends?: InterfaceType[] | string[];
|
|
13
|
+
}): InterfaceType;
|
|
14
|
+
//# sourceMappingURL=defineInterface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineInterface.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterface.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,eAAe,CAC7B,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACN,kBAAkB,GAAG,gBAAgB,CACtC,CAAC;IACF,OAAO,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAAC;CACtC,GACA,aAAa,CA2Df"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import invariant from "tiny-invariant";
|
|
17
|
+
import { namespace, ontologyDefinition } from "./defineOntology.js";
|
|
18
|
+
import { defineSharedPropertyType } from "./defineSpt.js";
|
|
19
|
+
export function defineInterface(opts) {
|
|
20
|
+
const apiName = namespace + opts.apiName;
|
|
21
|
+
!(ontologyDefinition.interfaceTypes[apiName] === undefined) ? invariant(false, `Interface ${apiName} already exists`) : void 0;
|
|
22
|
+
const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {
|
|
23
|
+
if (typeof type === "string") {
|
|
24
|
+
!isSimpleType(type) ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : void 0;
|
|
25
|
+
const spt = defineSharedPropertyType({
|
|
26
|
+
apiName,
|
|
27
|
+
displayName: apiName,
|
|
28
|
+
type,
|
|
29
|
+
array: false
|
|
30
|
+
});
|
|
31
|
+
return [apiName, spt];
|
|
32
|
+
} else {
|
|
33
|
+
!(namespace + apiName === type.apiName) ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
34
|
+
key: apiName,
|
|
35
|
+
apiName: type.apiName
|
|
36
|
+
})}`) : void 0;
|
|
37
|
+
return [apiName, type];
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
// (opts.extends ?? []).map(val => {(val is InterfaceType) ? val :;});
|
|
41
|
+
const a = {
|
|
42
|
+
apiName,
|
|
43
|
+
displayMetadata: {
|
|
44
|
+
displayName: opts.displayName ?? opts.apiName,
|
|
45
|
+
description: opts.description ?? opts.displayName ?? opts.apiName,
|
|
46
|
+
icon: opts.icon !== undefined ? {
|
|
47
|
+
type: "blueprint",
|
|
48
|
+
blueprint: {
|
|
49
|
+
color: opts.icon.color,
|
|
50
|
+
locator: opts.icon.locator
|
|
51
|
+
}
|
|
52
|
+
} : undefined
|
|
53
|
+
},
|
|
54
|
+
extendsInterfaces: [],
|
|
55
|
+
links: [],
|
|
56
|
+
properties,
|
|
57
|
+
status: {
|
|
58
|
+
type: "active",
|
|
59
|
+
active: {}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return ontologyDefinition.interfaceTypes[apiName] = a;
|
|
63
|
+
}
|
|
64
|
+
function isSimpleType(v) {
|
|
65
|
+
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=defineInterface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineInterface.js","names":["invariant","namespace","ontologyDefinition","defineSharedPropertyType","defineInterface","opts","apiName","interfaceTypes","undefined","properties","Object","fromEntries","entries","map","type","isSimpleType","spt","displayName","array","JSON","stringify","key","a","displayMetadata","description","icon","blueprint","color","locator","extendsInterfaces","links","status","active","v"],"sources":["defineInterface.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n invariant(ontologyDefinition.interfaceTypes[apiName] === undefined, `Interface ${apiName} already exists`);\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n invariant(isSimpleType(type), `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`);\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false,\n });\n return [apiName, spt];\n }\n else {\n invariant(namespace + apiName === type.apiName, `property key and it's apiName must be identical. ${JSON.stringify({ key: apiName, apiName: type.apiName })}`);\n return [apiName, type];\n }\n }));\n // (opts.extends ?? []).map(val => {(val is InterfaceType) ? val :;});\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined\n ? {\n type: \"blueprint\",\n blueprint: { color: opts.icon.color, locator: opts.icon.locator },\n }\n : undefined,\n },\n extendsInterfaces: [],\n links: [],\n properties,\n status: { type: \"active\", active: {} },\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\"\n || v === \"date\" || v === \"decimal\" || v === \"double\"\n || v === \"float\" || v === \"geopoint\" || v === \"geoshape\"\n || v === \"integer\" || v === \"long\" || v === \"marking\"\n || v === \"short\" || v === \"string\"\n || v === \"timestamp\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,qBAAqB;AACnE,SAASC,wBAAwB,QAAQ,gBAAgB;AACzD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAMC,OAAO,GAAGL,SAAS,GAAGI,IAAI,CAACC,OAAO;EACxC,EAAUJ,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,KAAKE,SAAS,IAAlER,SAAS,QAA2D,aAAaM,OAAO,iBAAiB;EACzG,MAAMG,UAAU,GAAGC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACP,IAAI,CAACI,UAAU,IAAI,CAAC,CAAC,CAAC,CAACI,GAAG,CAAC,CAAC,CAACP,OAAO,EAAEQ,IAAI,CAAC,KAAK;IACjG,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1B,CAAUC,YAAY,CAACD,IAAI,CAAC,GAA5Bd,SAAS,QAAqB,qBAAqBc,IAAI,iBAAiBR,OAAO,qBAAqBA,OAAO,EAAE;MAC7G,MAAMU,GAAG,GAAGb,wBAAwB,CAAC;QACjCG,OAAO;QACPW,WAAW,EAAEX,OAAO;QACpBQ,IAAI;QACJI,KAAK,EAAE;MACX,CAAC,CAAC;MACF,OAAO,CAACZ,OAAO,EAAEU,GAAG,CAAC;IACzB,CAAC,MACI;MACD,EAAUf,SAAS,GAAGK,OAAO,KAAKQ,IAAI,CAACR,OAAO,IAA9CN,SAAS,QAAuC,oDAAoDmB,IAAI,CAACC,SAAS,CAAC;QAAEC,GAAG,EAAEf,OAAO;QAAEA,OAAO,EAAEQ,IAAI,CAACR;MAAQ,CAAC,CAAC,EAAE;MAC7J,OAAO,CAACA,OAAO,EAAEQ,IAAI,CAAC;IAC1B;EACJ,CAAC,CAAC,CAAC;EACH;EACA,MAAMQ,CAAC,GAAG;IACNhB,OAAO;IACPiB,eAAe,EAAE;MACbN,WAAW,EAAEZ,IAAI,CAACY,WAAW,IAAIZ,IAAI,CAACC,OAAO;MAC7CkB,WAAW,EAAEnB,IAAI,CAACmB,WAAW,IAAInB,IAAI,CAACY,WAAW,IAAIZ,IAAI,CAACC,OAAO;MACjEmB,IAAI,EAAEpB,IAAI,CAACoB,IAAI,KAAKjB,SAAS,GACvB;QACEM,IAAI,EAAE,WAAW;QACjBY,SAAS,EAAE;UAAEC,KAAK,EAAEtB,IAAI,CAACoB,IAAI,CAACE,KAAK;UAAEC,OAAO,EAAEvB,IAAI,CAACoB,IAAI,CAACG;QAAQ;MACpE,CAAC,GACCpB;IACV,CAAC;IACDqB,iBAAiB,EAAE,EAAE;IACrBC,KAAK,EAAE,EAAE;IACTrB,UAAU;IACVsB,MAAM,EAAE;MAAEjB,IAAI,EAAE,QAAQ;MAAEkB,MAAM,EAAE,CAAC;IAAE;EACzC,CAAC;EACD,OAAO9B,kBAAkB,CAACK,cAAc,CAACD,OAAO,CAAC,GAAGgB,CAAC;AACzD;AACA,SAASP,YAAYA,CAACkB,CAAC,EAAE;EACrB,OAAOA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAC/BA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,QAAQ,IACjDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,UAAU,IAAIA,CAAC,KAAK,UAAU,IACrDA,CAAC,KAAK,SAAS,IAAIA,CAAC,KAAK,MAAM,IAAIA,CAAC,KAAK,SAAS,IAClDA,CAAC,KAAK,OAAO,IAAIA,CAAC,KAAK,QAAQ,IAC/BA,CAAC,KAAK,WAAW;AAC5B","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InterfaceType } from "./types.js";
|
|
2
|
+
type ApiNameOrInterfaceType = string | InterfaceType;
|
|
3
|
+
type Many = {
|
|
4
|
+
apiName: string;
|
|
5
|
+
from: InterfaceType;
|
|
6
|
+
toMany: ApiNameOrInterfaceType;
|
|
7
|
+
toOne?: never;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
};
|
|
11
|
+
type One = {
|
|
12
|
+
apiName: string;
|
|
13
|
+
from: InterfaceType;
|
|
14
|
+
toOne: ApiNameOrInterfaceType;
|
|
15
|
+
toMany?: never;
|
|
16
|
+
displayName?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function defineInterfaceLinkConstraint(linkDef: One | Many): void;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=defineInterfaceLinkConstraint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.d.ts","sourceRoot":"","sources":["../../../src/api/defineInterfaceLinkConstraint.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,sBAAsB,GAAG,MAAM,GAAG,aAAa,CAAC;AAErD,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,GAAG,GAAG,IAAI,QAgBpB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import invariant from "tiny-invariant";
|
|
17
|
+
import { namespace } from "./defineOntology.js";
|
|
18
|
+
export function defineInterfaceLinkConstraint(linkDef) {
|
|
19
|
+
const fromLinkMeta = getLinkMeta(linkDef);
|
|
20
|
+
!(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : void 0;
|
|
21
|
+
linkDef.from.links.push({
|
|
22
|
+
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
23
|
+
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
24
|
+
metadata: fromLinkMeta,
|
|
25
|
+
required: true // TODO: expose this?
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function getLinkedType(t) {
|
|
29
|
+
return {
|
|
30
|
+
type: "interfaceType",
|
|
31
|
+
interfaceType: typeof t === "string" ? t : t.apiName
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getLinkMeta(meta) {
|
|
35
|
+
return typeof meta === "string" ? withDefaults({
|
|
36
|
+
apiName: namespace + meta
|
|
37
|
+
}) : withDefaults(meta);
|
|
38
|
+
}
|
|
39
|
+
function withDefaults({
|
|
40
|
+
apiName,
|
|
41
|
+
description,
|
|
42
|
+
displayName
|
|
43
|
+
}) {
|
|
44
|
+
return {
|
|
45
|
+
apiName: namespace + apiName,
|
|
46
|
+
displayName: displayName ?? apiName,
|
|
47
|
+
description: description ?? displayName ?? apiName
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=defineInterfaceLinkConstraint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineInterfaceLinkConstraint.js","names":["invariant","namespace","defineInterfaceLinkConstraint","linkDef","fromLinkMeta","getLinkMeta","from","links","find","a","metadata","apiName","push","cardinality","toMany","linkedEntityTypeId","getLinkedType","toOne","required","t","type","interfaceType","meta","withDefaults","description","displayName"],"sources":["defineInterfaceLinkConstraint.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n invariant(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName)\n == null, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`);\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true, // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName,\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\"\n ? withDefaults({ apiName: namespace + meta })\n : withDefaults(meta);\n}\nfunction withDefaults({ apiName, description, displayName }) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,OAAO,SAASC,6BAA6BA,CAACC,OAAO,EAAE;EACnD,MAAMC,YAAY,GAAGC,WAAW,CAACF,OAAO,CAAC;EACzC,EAAUA,OAAO,CAACG,IAAI,CAACC,KAAK,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAACC,OAAO,KAAKP,YAAY,CAACO,OAAO,CAAC,IAC5E,IAAI,IADXX,SAAS,QACI,qBAAqBI,YAAY,CAACO,OAAO,sBAAsBR,OAAO,CAACQ,OAAO,EAAE;EAC7FR,OAAO,CAACG,IAAI,CAACC,KAAK,CAACK,IAAI,CAAC;IACpBC,WAAW,EAAEV,OAAO,CAACW,MAAM,GAAG,MAAM,GAAG,QAAQ;IAC/CC,kBAAkB,EAAEC,aAAa,CAACb,OAAO,CAACW,MAAM,IAAIX,OAAO,CAACc,KAAK,CAAC;IAClEP,QAAQ,EAAEN,YAAY;IACtBc,QAAQ,EAAE,IAAI,CAAE;EACpB,CAAC,CAAC;AACN;AACA,SAASF,aAAaA,CAACG,CAAC,EAAE;EACtB,OAAO;IACHC,IAAI,EAAE,eAAe;IACrBC,aAAa,EAAE,OAAOF,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACR;EACjD,CAAC;AACL;AACA,SAASN,WAAWA,CAACiB,IAAI,EAAE;EACvB,OAAO,OAAOA,IAAI,KAAK,QAAQ,GACzBC,YAAY,CAAC;IAAEZ,OAAO,EAAEV,SAAS,GAAGqB;EAAK,CAAC,CAAC,GAC3CC,YAAY,CAACD,IAAI,CAAC;AAC5B;AACA,SAASC,YAAYA,CAAC;EAAEZ,OAAO;EAAEa,WAAW;EAAEC;AAAY,CAAC,EAAE;EACzD,OAAO;IACHd,OAAO,EAAEV,SAAS,GAAGU,OAAO;IAC5Bc,WAAW,EAAEA,WAAW,IAAId,OAAO;IACnCa,WAAW,EAAEA,WAAW,IAAIC,WAAW,IAAId;EAC/C,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ObjectType } from "./defineObject.js";
|
|
2
|
+
export declare function defineLink(from: ObjectType, opts: {
|
|
3
|
+
many: string;
|
|
4
|
+
to: ObjectType;
|
|
5
|
+
reverse: {
|
|
6
|
+
one: string;
|
|
7
|
+
};
|
|
8
|
+
}): unknown;
|
|
9
|
+
export declare function defineLink(from: ObjectType, opts: {
|
|
10
|
+
one: string;
|
|
11
|
+
to: ObjectType;
|
|
12
|
+
reverse: {
|
|
13
|
+
one: string;
|
|
14
|
+
} | {
|
|
15
|
+
many: string;
|
|
16
|
+
};
|
|
17
|
+
}): unknown;
|
|
18
|
+
//# sourceMappingURL=defineLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineLink.d.ts","sourceRoot":"","sources":["../../../src/api/defineLink.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,UAAU,CACxB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE;IACJ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,UAAU,CAAC;IACf,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B,GACA,OAAO,CAAC;AACX,wBAAgB,UAAU,CACxB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE;IACJ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,UAAU,CAAC;IACf,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,GACA,OAAO,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import invariant from "tiny-invariant";
|
|
17
|
+
export function defineLink(from, opts) {
|
|
18
|
+
const apiName = opts.one ?? opts.many;
|
|
19
|
+
const toApiName = opts.reverse.one ?? opts.reverse.many;
|
|
20
|
+
const to = opts.to;
|
|
21
|
+
!(from.linkTypes[apiName] == null) ? invariant(false, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`) : void 0;
|
|
22
|
+
!(from.linkTypes[toApiName] == null) ? invariant(false, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`) : void 0;
|
|
23
|
+
from.linkTypes[apiName] = {
|
|
24
|
+
cardinality: "ONE",
|
|
25
|
+
displayName: apiName,
|
|
26
|
+
objectTypeApiName: to.data.objectType.apiName,
|
|
27
|
+
status: "ACTIVE"
|
|
28
|
+
};
|
|
29
|
+
to.linkTypes[toApiName] = {
|
|
30
|
+
apiName: toApiName,
|
|
31
|
+
cardinality: "ONE",
|
|
32
|
+
displayName: apiName,
|
|
33
|
+
objectTypeApiName: from.data.objectType.apiName,
|
|
34
|
+
status: "ACTIVE"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=defineLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineLink.js","names":["invariant","defineLink","from","opts","apiName","one","many","toApiName","reverse","to","linkTypes","data","objectType","cardinality","displayName","objectTypeApiName","status"],"sources":["defineLink.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nexport function defineLink(from, opts) {\n const apiName = opts.one ?? opts.many;\n const toApiName = opts.reverse.one ?? opts.reverse.many;\n const to = opts.to;\n invariant(from.linkTypes[apiName] == null, `Link with apiName ${apiName} already exists on ${from.data.objectType.apiName}`);\n invariant(from.linkTypes[toApiName] == null, `Link with apiName ${toApiName} already exists on ${to.data.objectType.apiName}`);\n from.linkTypes[apiName] = {\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: to.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n to.linkTypes[toApiName] = {\n apiName: toApiName,\n cardinality: \"ONE\",\n displayName: apiName,\n objectTypeApiName: from.data.objectType.apiName,\n status: \"ACTIVE\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAO,SAASC,UAAUA,CAACC,IAAI,EAAEC,IAAI,EAAE;EACnC,MAAMC,OAAO,GAAGD,IAAI,CAACE,GAAG,IAAIF,IAAI,CAACG,IAAI;EACrC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,OAAO,CAACH,GAAG,IAAIF,IAAI,CAACK,OAAO,CAACF,IAAI;EACvD,MAAMG,EAAE,GAAGN,IAAI,CAACM,EAAE;EAClB,EAAUP,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,IAAI,IAAI,IAAzCJ,SAAS,QAAkC,qBAAqBI,OAAO,sBAAsBF,IAAI,CAACS,IAAI,CAACC,UAAU,CAACR,OAAO,EAAE;EAC3H,EAAUF,IAAI,CAACQ,SAAS,CAACH,SAAS,CAAC,IAAI,IAAI,IAA3CP,SAAS,QAAoC,qBAAqBO,SAAS,sBAAsBE,EAAE,CAACE,IAAI,CAACC,UAAU,CAACR,OAAO,EAAE;EAC7HF,IAAI,CAACQ,SAAS,CAACN,OAAO,CAAC,GAAG;IACtBS,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEV,OAAO;IACpBW,iBAAiB,EAAEN,EAAE,CAACE,IAAI,CAACC,UAAU,CAACR,OAAO;IAC7CY,MAAM,EAAE;EACZ,CAAC;EACDP,EAAE,CAACC,SAAS,CAACH,SAAS,CAAC,GAAG;IACtBH,OAAO,EAAEG,SAAS;IAClBM,WAAW,EAAE,KAAK;IAClBC,WAAW,EAAEV,OAAO;IACpBW,iBAAiB,EAAEb,IAAI,CAACS,IAAI,CAACC,UAAU,CAACR,OAAO;IAC/CY,MAAM,EAAE;EACZ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as api from "@osdk/api";
|
|
2
|
+
import type { ObjectTypeFullMetadata } from "@osdk/internal.foundry.core";
|
|
3
|
+
export interface ObjectType {
|
|
4
|
+
data: ObjectTypeFullMetadata;
|
|
5
|
+
linkTypes: Record<string, {}>;
|
|
6
|
+
}
|
|
7
|
+
export declare function defineObject(apiName: string, opts: {
|
|
8
|
+
displayName?: string;
|
|
9
|
+
pluralDisplayName?: string;
|
|
10
|
+
primaryKey: api.ObjectMetadata.Property & {
|
|
11
|
+
apiName: string;
|
|
12
|
+
};
|
|
13
|
+
properties?: Record<string, api.WirePropertyTypes | api.ObjectMetadata.Property>;
|
|
14
|
+
}): ObjectType;
|
|
15
|
+
//# sourceMappingURL=defineObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineObject.d.ts","sourceRoot":"","sources":["../../../src/api/defineObject.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AASrC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,EAIzB,CAAC,CAAC;CACJ;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IACJ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9D,UAAU,CAAC,EAAE,MAAM,CACjB,MAAM,EACJ,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,cAAc,CAAC,QAAQ,CAC9B,CAAC;CACH,GACA,UAAU,CAiCZ"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import invariant from "tiny-invariant";
|
|
17
|
+
import { ontologyDefinition } from "./defineOntology.js";
|
|
18
|
+
export function defineObject(apiName, opts) {
|
|
19
|
+
ontologyDefinition.objectTypes[apiName] = {
|
|
20
|
+
implementsInterfaces: [],
|
|
21
|
+
implementsInterfaces2: {},
|
|
22
|
+
linkTypes: [],
|
|
23
|
+
objectType: {
|
|
24
|
+
apiName,
|
|
25
|
+
primaryKey: opts.primaryKey.apiName,
|
|
26
|
+
displayName: opts.displayName ?? apiName,
|
|
27
|
+
pluralDisplayName: opts.pluralDisplayName ?? apiName,
|
|
28
|
+
icon: {
|
|
29
|
+
color: "blue",
|
|
30
|
+
name: "cube",
|
|
31
|
+
type: "blueprint"
|
|
32
|
+
},
|
|
33
|
+
properties: {
|
|
34
|
+
[opts.primaryKey.apiName]: {
|
|
35
|
+
dataType: convertType(opts.primaryKey)
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
rid: "PLACEHOLDER",
|
|
39
|
+
status: "ACTIVE",
|
|
40
|
+
titleProperty: opts.primaryKey.apiName
|
|
41
|
+
},
|
|
42
|
+
sharedPropertyTypeMapping: {}
|
|
43
|
+
};
|
|
44
|
+
// FIXME: don't return the raw value
|
|
45
|
+
return {
|
|
46
|
+
data: ontologyDefinition.objectTypes[apiName],
|
|
47
|
+
linkTypes: {}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function convertType(t) {
|
|
51
|
+
switch (true) {
|
|
52
|
+
case t.multiplicity === true:
|
|
53
|
+
return {
|
|
54
|
+
type: "array",
|
|
55
|
+
subType: convertType({
|
|
56
|
+
...t,
|
|
57
|
+
multiplicity: false
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
case t.type === "stringTimeseries":
|
|
61
|
+
return {
|
|
62
|
+
itemType: {
|
|
63
|
+
type: "string"
|
|
64
|
+
},
|
|
65
|
+
type: "timeseries"
|
|
66
|
+
};
|
|
67
|
+
break;
|
|
68
|
+
case t.type === "numericTimeseries":
|
|
69
|
+
return {
|
|
70
|
+
itemType: {
|
|
71
|
+
type: "double"
|
|
72
|
+
},
|
|
73
|
+
type: "timeseries"
|
|
74
|
+
};
|
|
75
|
+
case t.type === "datetime":
|
|
76
|
+
return {
|
|
77
|
+
type: "timestamp"
|
|
78
|
+
};
|
|
79
|
+
default:
|
|
80
|
+
return {
|
|
81
|
+
type: t.type
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
invariant(false);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=defineObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineObject.js","names":["invariant","ontologyDefinition","defineObject","apiName","opts","objectTypes","implementsInterfaces","implementsInterfaces2","linkTypes","objectType","primaryKey","displayName","pluralDisplayName","icon","color","name","type","properties","dataType","convertType","rid","status","titleProperty","sharedPropertyTypeMapping","data","t","multiplicity","subType","itemType"],"sources":["defineObject.js"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport invariant from \"tiny-invariant\";\nimport { ontologyDefinition } from \"./defineOntology.js\";\nexport function defineObject(apiName, opts) {\n ontologyDefinition.objectTypes[apiName] = {\n implementsInterfaces: [],\n implementsInterfaces2: {},\n linkTypes: [],\n objectType: {\n apiName,\n primaryKey: opts.primaryKey.apiName,\n displayName: opts.displayName ?? apiName,\n pluralDisplayName: opts.pluralDisplayName ?? apiName,\n icon: {\n color: \"blue\",\n name: \"cube\",\n type: \"blueprint\",\n },\n properties: {\n [opts.primaryKey.apiName]: {\n dataType: convertType(opts.primaryKey),\n },\n },\n rid: \"PLACEHOLDER\",\n status: \"ACTIVE\",\n titleProperty: opts.primaryKey.apiName,\n },\n sharedPropertyTypeMapping: {},\n };\n // FIXME: don't return the raw value\n return {\n data: ontologyDefinition.objectTypes[apiName],\n linkTypes: {},\n };\n}\nfunction convertType(t) {\n switch (true) {\n case t.multiplicity === true:\n return {\n type: \"array\",\n subType: convertType({ ...t, multiplicity: false }),\n };\n case t.type === \"stringTimeseries\":\n return {\n itemType: {\n type: \"string\",\n },\n type: \"timeseries\",\n };\n break;\n case t.type === \"numericTimeseries\":\n return {\n itemType: {\n type: \"double\",\n },\n type: \"timeseries\",\n };\n case t.type === \"datetime\":\n return {\n type: \"timestamp\",\n };\n default:\n return {\n type: t.type,\n };\n }\n invariant(false);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,kBAAkB,QAAQ,qBAAqB;AACxD,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAEC,IAAI,EAAE;EACxCH,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC,GAAG;IACtCG,oBAAoB,EAAE,EAAE;IACxBC,qBAAqB,EAAE,CAAC,CAAC;IACzBC,SAAS,EAAE,EAAE;IACbC,UAAU,EAAE;MACRN,OAAO;MACPO,UAAU,EAAEN,IAAI,CAACM,UAAU,CAACP,OAAO;MACnCQ,WAAW,EAAEP,IAAI,CAACO,WAAW,IAAIR,OAAO;MACxCS,iBAAiB,EAAER,IAAI,CAACQ,iBAAiB,IAAIT,OAAO;MACpDU,IAAI,EAAE;QACFC,KAAK,EAAE,MAAM;QACbC,IAAI,EAAE,MAAM;QACZC,IAAI,EAAE;MACV,CAAC;MACDC,UAAU,EAAE;QACR,CAACb,IAAI,CAACM,UAAU,CAACP,OAAO,GAAG;UACvBe,QAAQ,EAAEC,WAAW,CAACf,IAAI,CAACM,UAAU;QACzC;MACJ,CAAC;MACDU,GAAG,EAAE,aAAa;MAClBC,MAAM,EAAE,QAAQ;MAChBC,aAAa,EAAElB,IAAI,CAACM,UAAU,CAACP;IACnC,CAAC;IACDoB,yBAAyB,EAAE,CAAC;EAChC,CAAC;EACD;EACA,OAAO;IACHC,IAAI,EAAEvB,kBAAkB,CAACI,WAAW,CAACF,OAAO,CAAC;IAC7CK,SAAS,EAAE,CAAC;EAChB,CAAC;AACL;AACA,SAASW,WAAWA,CAACM,CAAC,EAAE;EACpB,QAAQ,IAAI;IACR,KAAKA,CAAC,CAACC,YAAY,KAAK,IAAI;MACxB,OAAO;QACHV,IAAI,EAAE,OAAO;QACbW,OAAO,EAAER,WAAW,CAAC;UAAE,GAAGM,CAAC;UAAEC,YAAY,EAAE;QAAM,CAAC;MACtD,CAAC;IACL,KAAKD,CAAC,CAACT,IAAI,KAAK,kBAAkB;MAC9B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;MACD;IACJ,KAAKS,CAAC,CAACT,IAAI,KAAK,mBAAmB;MAC/B,OAAO;QACHY,QAAQ,EAAE;UACNZ,IAAI,EAAE;QACV,CAAC;QACDA,IAAI,EAAE;MACV,CAAC;IACL,KAAKS,CAAC,CAACT,IAAI,KAAK,UAAU;MACtB,OAAO;QACHA,IAAI,EAAE;MACV,CAAC;IACL;MACI,OAAO;QACHA,IAAI,EAAES,CAAC,CAACT;MACZ,CAAC;EACT;EACAhB,SAAS;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OntologyIrOntologyBlockDataV2, OntologyIrValueTypeBlockData } from "@osdk/client.unstable";
|
|
2
|
+
type OntologyAndValueTypeIrs = {
|
|
3
|
+
ontology: OntologyIrOntologyBlockDataV2;
|
|
4
|
+
valueType: OntologyIrValueTypeBlockData;
|
|
5
|
+
};
|
|
6
|
+
export declare function defineOntology(ns: string, body: () => void | Promise<void>): Promise<OntologyAndValueTypeIrs>;
|
|
7
|
+
export declare function dumpOntologyFullMetadata(): OntologyIrOntologyBlockDataV2;
|
|
8
|
+
export declare function dumpValueTypeWireType(): OntologyIrValueTypeBlockData;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=defineOntology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineOntology.d.ts","sourceRoot":"","sources":["../../../src/api/defineOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAGV,6BAA6B,EAG7B,4BAA4B,EAG7B,MAAM,uBAAuB,CAAC;AAc/B,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,6BAA6B,CAAC;IACxC,SAAS,EAAE,4BAA4B,CAAC;CACzC,CAAC;AAEF,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA0BlC;AAsED,wBAAgB,wBAAwB,IAAI,6BAA6B,CAExE;AAED,wBAAgB,qBAAqB,IAAI,4BAA4B,CAEpE"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/** @internal */
|
|
17
|
+
export let ontologyDefinition;
|
|
18
|
+
/** @internal */
|
|
19
|
+
export let namespace;
|
|
20
|
+
export async function defineOntology(ns, body) {
|
|
21
|
+
namespace = ns;
|
|
22
|
+
ontologyDefinition = {
|
|
23
|
+
actionTypes: {},
|
|
24
|
+
objectTypes: {},
|
|
25
|
+
queryTypes: {},
|
|
26
|
+
interfaceTypes: {},
|
|
27
|
+
sharedPropertyTypes: {},
|
|
28
|
+
valueTypes: {}
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
await body();
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.error("Unexpected error while processing the body of the ontology", e);
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
ontology: convertToWireOntologyIr(ontologyDefinition),
|
|
39
|
+
valueType: convertOntologyToValueTypeIr(ontologyDefinition)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function convertOntologyToValueTypeIr(ontology) {
|
|
43
|
+
return {
|
|
44
|
+
valueTypes: Object.values(ontology.valueTypes).map(definitions => ({
|
|
45
|
+
metadata: {
|
|
46
|
+
apiName: definitions[0].apiName,
|
|
47
|
+
displayMetadata: definitions[0].displayMetadata,
|
|
48
|
+
status: definitions[0].status
|
|
49
|
+
},
|
|
50
|
+
versions: definitions.map(definition => ({
|
|
51
|
+
version: definition.version,
|
|
52
|
+
baseType: definition.baseType,
|
|
53
|
+
constraints: definition.constraints,
|
|
54
|
+
exampleValues: definition.exampleValues
|
|
55
|
+
}))
|
|
56
|
+
}))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function convertToWireOntologyIr(ontology) {
|
|
60
|
+
return {
|
|
61
|
+
sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {
|
|
62
|
+
sharedPropertyType: convertSpt(spt)
|
|
63
|
+
}])),
|
|
64
|
+
interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {
|
|
65
|
+
return [apiName, {
|
|
66
|
+
interfaceType: convertInterface(interfaceType)
|
|
67
|
+
}];
|
|
68
|
+
})),
|
|
69
|
+
blockPermissionInformation: {
|
|
70
|
+
actionTypes: {},
|
|
71
|
+
linkTypes: {},
|
|
72
|
+
objectTypes: {}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function convertInterface(interfaceType) {
|
|
77
|
+
return {
|
|
78
|
+
...interfaceType,
|
|
79
|
+
properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),
|
|
80
|
+
// these are omitted from our internal types but we need to re-add them for the final json
|
|
81
|
+
allExtendsInterfaces: [],
|
|
82
|
+
allLinks: [],
|
|
83
|
+
allProperties: []
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function dumpOntologyFullMetadata() {
|
|
87
|
+
return convertToWireOntologyIr(ontologyDefinition);
|
|
88
|
+
}
|
|
89
|
+
export function dumpValueTypeWireType() {
|
|
90
|
+
return convertOntologyToValueTypeIr(ontologyDefinition);
|
|
91
|
+
}
|
|
92
|
+
function convertSpt({
|
|
93
|
+
type,
|
|
94
|
+
array,
|
|
95
|
+
description,
|
|
96
|
+
apiName,
|
|
97
|
+
displayName,
|
|
98
|
+
gothamMapping,
|
|
99
|
+
typeClasses,
|
|
100
|
+
valueType
|
|
101
|
+
}) {
|
|
102
|
+
return {
|
|
103
|
+
apiName,
|
|
104
|
+
displayMetadata: {
|
|
105
|
+
displayName: displayName ?? apiName,
|
|
106
|
+
visibility: "NORMAL",
|
|
107
|
+
description
|
|
108
|
+
},
|
|
109
|
+
type: array ? {
|
|
110
|
+
type: "array",
|
|
111
|
+
array: {
|
|
112
|
+
subtype: convertType(type)
|
|
113
|
+
}
|
|
114
|
+
} : convertType(type),
|
|
115
|
+
aliases: [],
|
|
116
|
+
baseFormatter: undefined,
|
|
117
|
+
dataConstraints: undefined,
|
|
118
|
+
gothamMapping: gothamMapping,
|
|
119
|
+
indexedForSearch: true,
|
|
120
|
+
provenance: undefined,
|
|
121
|
+
typeClasses: typeClasses ?? [],
|
|
122
|
+
valueType: valueType
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function convertType(type) {
|
|
126
|
+
switch (type) {
|
|
127
|
+
case "marking":
|
|
128
|
+
return {
|
|
129
|
+
type,
|
|
130
|
+
[type]: {
|
|
131
|
+
markingType: "MANDATORY"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
case "geopoint":
|
|
135
|
+
return {
|
|
136
|
+
type: "geohash",
|
|
137
|
+
geohash: {}
|
|
138
|
+
};
|
|
139
|
+
case "decimal":
|
|
140
|
+
return {
|
|
141
|
+
type,
|
|
142
|
+
[type]: {
|
|
143
|
+
precision: undefined,
|
|
144
|
+
scale: undefined
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
case "string":
|
|
148
|
+
return {
|
|
149
|
+
type,
|
|
150
|
+
[type]: {
|
|
151
|
+
analyzerOverride: undefined,
|
|
152
|
+
enableAsciiFolding: undefined,
|
|
153
|
+
isLongText: false,
|
|
154
|
+
supportsExactMatching: true
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
default:
|
|
158
|
+
// use helper function to distribute `type` properly
|
|
159
|
+
return distributeTypeHelper(type);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Helper function to avoid duplication. Makes the types match properly with the correct
|
|
164
|
+
* behavior without needing to switch on type.
|
|
165
|
+
* @param type
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
function distributeTypeHelper(type) {
|
|
169
|
+
return {
|
|
170
|
+
type,
|
|
171
|
+
[type]: {}
|
|
172
|
+
}; // any cast to match conditional return type
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=defineOntology.js.map
|