@osdk/generator 2.0.2-rc.3 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/build/browser/GenerateContext/EnhanceCommon.d.ts +0 -2
- package/build/browser/GenerateContext/EnhanceCommon.d.ts.map +1 -1
- package/build/browser/GenerateContext/EnhancedBase.d.ts +1 -3
- package/build/browser/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/browser/GenerateContext/EnhancedBase.js +2 -11
- package/build/browser/GenerateContext/EnhancedBase.js.map +1 -1
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts +4 -4
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.js +27 -21
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
- package/build/browser/GenerateContext/ForeignType.d.ts +1 -2
- package/build/browser/GenerateContext/ForeignType.d.ts.map +1 -1
- package/build/browser/GenerateContext/ForeignType.js +5 -11
- package/build/browser/GenerateContext/ForeignType.js.map +1 -1
- package/build/browser/GenerateContext/enhanceOntology.d.ts +7 -1
- package/build/browser/GenerateContext/enhanceOntology.d.ts.map +1 -1
- package/build/browser/GenerateContext/enhanceOntology.js +8 -2
- package/build/browser/GenerateContext/enhanceOntology.js.map +1 -1
- package/build/browser/generateClientSdkPackage.d.ts +1 -1
- package/build/browser/generateClientSdkPackage.d.ts.map +1 -1
- package/build/browser/generateClientSdkPackage.js +2 -2
- package/build/browser/generateClientSdkPackage.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +12 -6
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +40 -6
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +16 -80
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +118 -52
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/browser/v2.0/generateMetadata.js +1 -1
- package/build/browser/v2.0/generateMetadata.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.js +2 -2
- package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.test.js +14 -2
- package/build/browser/v2.0/generatePerActionDataFiles.test.js.map +1 -1
- package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts +2 -0
- package/build/browser/v2.0/generatePerInterfaceDataFiles.d.ts.map +1 -0
- package/build/browser/v2.0/generatePerInterfaceDataFiles.js +45 -0
- package/build/browser/v2.0/generatePerInterfaceDataFiles.js.map +1 -0
- package/build/browser/v2.0/generatePerObjectDataFiles.d.ts +3 -0
- package/build/browser/v2.0/generatePerObjectDataFiles.d.ts.map +1 -0
- package/build/browser/v2.0/generatePerObjectDataFiles.js +47 -0
- package/build/browser/v2.0/generatePerObjectDataFiles.js.map +1 -0
- package/build/browser/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.js +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js +9 -3
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/browser/v2.0/generateRootIndexTsFile.d.ts +3 -0
- package/build/browser/v2.0/generateRootIndexTsFile.d.ts.map +1 -0
- package/build/browser/v2.0/generateRootIndexTsFile.js +40 -0
- package/build/browser/v2.0/generateRootIndexTsFile.js.map +1 -0
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +0 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +19 -12
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/esm/GenerateContext/EnhanceCommon.d.ts +0 -2
- package/build/esm/GenerateContext/EnhanceCommon.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.d.ts +1 -3
- package/build/esm/GenerateContext/EnhancedBase.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedBase.js +2 -11
- package/build/esm/GenerateContext/EnhancedBase.js.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts +4 -4
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.js +27 -21
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.js.map +1 -1
- package/build/esm/GenerateContext/ForeignType.d.ts +1 -2
- package/build/esm/GenerateContext/ForeignType.d.ts.map +1 -1
- package/build/esm/GenerateContext/ForeignType.js +5 -11
- package/build/esm/GenerateContext/ForeignType.js.map +1 -1
- package/build/esm/GenerateContext/enhanceOntology.d.ts +7 -1
- package/build/esm/GenerateContext/enhanceOntology.d.ts.map +1 -1
- package/build/esm/GenerateContext/enhanceOntology.js +8 -2
- package/build/esm/GenerateContext/enhanceOntology.js.map +1 -1
- package/build/esm/generateClientSdkPackage.d.ts +1 -1
- package/build/esm/generateClientSdkPackage.d.ts.map +1 -1
- package/build/esm/generateClientSdkPackage.js +2 -2
- package/build/esm/generateClientSdkPackage.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +12 -6
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +40 -6
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +16 -80
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +118 -52
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/esm/v2.0/generateMetadata.js +1 -1
- package/build/esm/v2.0/generateMetadata.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.js +2 -2
- package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.test.js +14 -2
- package/build/esm/v2.0/generatePerActionDataFiles.test.js.map +1 -1
- package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts +2 -0
- package/build/esm/v2.0/generatePerInterfaceDataFiles.d.ts.map +1 -0
- package/build/esm/v2.0/generatePerInterfaceDataFiles.js +45 -0
- package/build/esm/v2.0/generatePerInterfaceDataFiles.js.map +1 -0
- package/build/esm/v2.0/generatePerObjectDataFiles.d.ts +3 -0
- package/build/esm/v2.0/generatePerObjectDataFiles.d.ts.map +1 -0
- package/build/esm/v2.0/generatePerObjectDataFiles.js +47 -0
- package/build/esm/v2.0/generatePerObjectDataFiles.js.map +1 -0
- package/build/esm/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.js +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js +9 -3
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/esm/v2.0/generateRootIndexTsFile.d.ts +3 -0
- package/build/esm/v2.0/generateRootIndexTsFile.d.ts.map +1 -0
- package/build/esm/v2.0/generateRootIndexTsFile.js +40 -0
- package/build/esm/v2.0/generateRootIndexTsFile.js.map +1 -0
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts +0 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +19 -12
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/package.json +4 -4
|
@@ -15,18 +15,19 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { wireObjectTypeFullMetadataToSdkObjectMetadata } from "@osdk/generator-converters";
|
|
17
17
|
import { EnhancedObjectType } from "../GenerateContext/EnhancedObjectType.js";
|
|
18
|
+
import { ForeignType } from "../GenerateContext/ForeignType.js";
|
|
18
19
|
import { getObjectImports } from "../shared/getObjectImports.js";
|
|
19
20
|
import { propertyJsdoc } from "../shared/propertyJsdoc.js";
|
|
20
21
|
import { deleteUndefineds } from "../util/deleteUndefineds.js";
|
|
21
22
|
import { stringify } from "../util/stringify.js";
|
|
22
|
-
export function getObjectDefIdentifier(name, v2) {
|
|
23
|
-
return v2 ? name : `${name}Def`;
|
|
24
|
-
}
|
|
25
23
|
/** @internal */
|
|
26
24
|
export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
27
25
|
ontology
|
|
28
26
|
}, currentFilePath) {
|
|
29
27
|
const object = ontology.requireObjectType(wireObject.objectType.apiName, true);
|
|
28
|
+
if (object instanceof ForeignType) {
|
|
29
|
+
throw new Error("Should not be generating types for an external type");
|
|
30
|
+
}
|
|
30
31
|
const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map(a => ontology.requireObjectType(a.objectTypeApiName, false)));
|
|
31
32
|
const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));
|
|
32
33
|
const objectDefIdentifier = object.getDefinitionIdentifier(true);
|
|
@@ -47,7 +48,7 @@ export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
47
48
|
propertyKeysIdentifier
|
|
48
49
|
};
|
|
49
50
|
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
50
|
-
return `${imports}${function () {
|
|
51
|
+
return `${imports}${function (object) {
|
|
51
52
|
return `import type {
|
|
52
53
|
PropertyKeys as $PropertyKeys,
|
|
53
54
|
ObjectTypeDefinition as $ObjectTypeDefinition,
|
|
@@ -74,14 +75,14 @@ export function wireObjectTypeV2ToSdkObjectConstV2(wireObject, {
|
|
|
74
75
|
|
|
75
76
|
${createObjectSet(object, identifiers)}
|
|
76
77
|
|
|
77
|
-
${createOsdkObject(object, "
|
|
78
|
+
${createOsdkObject(object, "OsdkInstance", identifiers)}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
|
|
82
83
|
${createDefinition(object, ontology, object.shortApiName, identifiers)}
|
|
83
84
|
`;
|
|
84
|
-
}()}
|
|
85
|
+
}(object)}
|
|
85
86
|
|
|
86
87
|
export const ${object.shortApiName}: ${objectDefIdentifier}
|
|
87
88
|
= {
|
|
@@ -98,16 +99,22 @@ export function createOsdkObject(object, identifier, {
|
|
|
98
99
|
}) {
|
|
99
100
|
object.getCleanedUpDefinition(true);
|
|
100
101
|
return `
|
|
101
|
-
|
|
102
|
+
export type ${identifier}<
|
|
102
103
|
OPTIONS extends never | "$notStrict" | "$rid" = never,
|
|
103
104
|
K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
= $Osdk<
|
|
105
|
+
>
|
|
106
|
+
= $Osdk.Instance<
|
|
107
107
|
${objectDefIdentifier},
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
OPTIONS,
|
|
109
|
+
K
|
|
110
|
+
>;
|
|
110
111
|
|
|
112
|
+
|
|
113
|
+
/** @deprecated use ${identifier} */
|
|
114
|
+
export type OsdkObject<
|
|
115
|
+
OPTIONS extends never | "$notStrict" | "$rid" = never,
|
|
116
|
+
K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},
|
|
117
|
+
> = ${identifier}<OPTIONS, K>;
|
|
111
118
|
;
|
|
112
119
|
`;
|
|
113
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","EnhancedObjectType","getObjectImports","propertyJsdoc","deleteUndefineds","stringify","getObjectDefIdentifier","name","v2","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","currentFilePath","object","requireObjectType","objectType","apiName","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","properties","*","propertyDefinition","_","JSON","multiplicity","nullable","links","targetType","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.js"],"sourcesContent":["/*\n * Copyright 2023 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 { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nexport function getObjectDefIdentifier(name, v2) {\n return v2 ? name : `${name}Def`;\n}\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(wireObject, { ontology }, currentFilePath) {\n const object = ontology.requireObjectType(wireObject.objectType.apiName, true);\n const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map(a => ontology.requireObjectType(a.objectTypeApiName, false)));\n const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n const identifiers = {\n objectDefIdentifier: `${object.shortApiName}`,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n function getV2Types() {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"@osdk/api\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"@osdk/api\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkObject\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);\n return `${imports}${getV2Types()}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\nexport function createOsdkObject(object, identifier, { osdkObjectPropsIdentifier, objectDefIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n\n > \n = $Osdk<\n ${objectDefIdentifier}, \n K | OPTIONS\n > \n \n ;\n `;\n}\nexport function createObjectSet(object, { objectDefIdentifier, objectSetIdentifier, propertyKeysIdentifier, osdkObjectIdentifier, }) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\nfunction maybeStripNamespace(type, q) {\n if (type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)) {\n return q.slice(type.apiNamespace.length + 1);\n }\n else {\n return q;\n }\n}\nexport function createProps(type, identifier, strict) {\n const definition = type.getCleanedUpDefinition(true);\n return `export interface ${identifier} {\n${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `readonly \"${maybeStripNamespace(type, apiName)}\"${\n // after we convert everything over we can do this:\n // !strict || propertyDefinition.nullable ? \"?\" : \"\"\n \"\"}`,\n `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? \"[]\" : \"\"}${propertyDefinition.nullable || !strict ? `| undefined` : \"\"}`,\n ];\n },\n })}\n }`;\n}\nexport function createDefinition(object, ontology, identifier, { objectDefIdentifier, objectSetIdentifier, osdkObjectPropsIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export interface ${identifier} extends ${object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`} {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${stringify(definition, {\n links: (_value) => `{\n ${stringify(definition.links, {\n \"*\": (definition) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true)}, ${definition.multiplicity}>`,\n })}\n }`,\n properties: (_value) => (`{\n ${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => [\n `${propertyJsdoc(propertyDefinition, { apiName })}\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<\"${propertyDefinition.type}\", \"${propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"}\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ],\n })}\n }`),\n })}\n } \n}\n `;\n}\nexport function createLinks(ontology, object, identifier) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n ${Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true);\n return [\n `readonly ${key}`,\n `${definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`}\n `,\n ];\n },\n })}\n }\n `}`;\n}\nexport function createPropertyKeys(type) {\n return `export type PropertyKeys = ${Object.keys(type.getCleanedUpDefinition(true).properties).map((a) => maybeStripNamespace(type, a)).map(a => `\"${a}\"`).join(\"|\")};`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,OAAO,SAASC,sBAAsBA,CAACC,IAAI,EAAEC,EAAE,EAAE;EAC7C,OAAOA,EAAE,GAAGD,IAAI,GAAG,GAAGA,IAAI,KAAK;AACnC;AACA;AACA,OAAO,SAASE,kCAAkCA,CAACC,UAAU,EAAE;EAAEC;AAAS,CAAC,EAAEC,eAAe,EAAE;EAC1F,MAAMC,MAAM,GAAGF,QAAQ,CAACG,iBAAiB,CAACJ,UAAU,CAACK,UAAU,CAACC,OAAO,EAAE,IAAI,CAAC;EAC9E,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAACR,UAAU,CAACS,SAAS,CAACC,GAAG,CAACC,CAAC,IAAIV,QAAQ,CAACG,iBAAiB,CAACO,CAAC,CAACC,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;EAC5H,MAAMC,UAA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AAU,GAAGvD,QAAQ,CAACG,iBAAiB,CAACS,UAAU,CAACsC,UAAU,CAAC,CAC/DC,+BAA+B,CAAC,IAAI,CAAC;MAC1C,OAAO,CACH,YAAYG,GAAG,EAAE,EACjB,GAAG1C,UAAU,CAACmC,YAAY,GACpB,GAAGQ,UAAU,YAAY,GACzB,uBAAuBA,UAAU,GAAG;AAC9D,WAAW,CACM;IACL;EACJ,CAAC,CAAC;AACV;AACA,KAAK,EAAE;AACP;AACA,OAAO,SAAS9B,kBAAkBA,CAACU,IAAI,EAAE;EACrC,OAAO,8BAA8BiB,MAAM,CAACC,IAAI,CAAClB,IAAI,CAACF,sBAAsB,CAAC,IAAI,CAAC,CAACS,UAAU,CAAC,CAACjC,GAAG,CAAEC,CAAC,IAAKwB,mBAAmB,CAACC,IAAI,EAAEzB,CAAC,CAAC,CAAC,CAACD,GAAG,CAACC,CAAC,IAAI,IAAIA,CAAC,GAAG,CAAC,CAAC8C,IAAI,CAAC,GAAG,CAAC,GAAG;AAC3K","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","deleteUndefineds","stringify","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","currentFilePath","object","requireObjectType","objectType","apiName","Error","uniqueLinkTargetTypes","Set","linkTypes","map","a","objectTypeApiName","definition","raw","objectDefIdentifier","getDefinitionIdentifier","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","identifiers","imports","createPropertyKeys","createLinks","createProps","createObjectSet","createOsdkObject","createDefinition","fullApiName","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","properties","*","propertyDefinition","_","JSON","multiplicity","nullable","links","targetType","getImportedDefinitionIdentifier","Object","keys","key","linkTarget","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.js"],"sourcesContent":["/*\n * Copyright 2023 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 { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(wireObject, { ontology }, currentFilePath) {\n const object = ontology.requireObjectType(wireObject.objectType.apiName, true);\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(wireObject.linkTypes.map(a => ontology.requireObjectType(a.objectTypeApiName, false)));\n const definition = deleteUndefineds(wireObjectTypeFullMetadataToSdkObjectMetadata(object.raw, true));\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n const objectSetIdentifier = `${object.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${object.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${object.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier = `${object.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `${object.shortApiName}.Links`;\n const osdkObjectIdentifier = `${object.shortApiName}.OsdkObject`;\n const identifiers = {\n objectDefIdentifier: `${object.shortApiName}`,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n function getV2Types(object) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"@osdk/api\";\n import type {\n ObjectSet as $ObjectSet, \n Osdk as $Osdk,\n OsdkObject as $OsdkObject,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"@osdk/api\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false)}\n ${createProps(object, \"StrictProps\", true)}\n\n ${createObjectSet(object, identifiers)}\n \n ${createOsdkObject(object, \"OsdkInstance\", identifiers)}\n } \n\n\n\n ${createDefinition(object, ontology, object.shortApiName, identifiers)}\n `;\n }\n const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);\n return `${imports}${getV2Types(object)}\n\n export const ${object.shortApiName}: ${objectDefIdentifier}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata, \n };`;\n}\nexport function createOsdkObject(object, identifier, { osdkObjectPropsIdentifier, objectDefIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > \n = $Osdk.Instance<\n ${objectDefIdentifier}, \n OPTIONS,\n K\n >;\n \n\n /** @deprecated use ${identifier} */\n export type OsdkObject<\n OPTIONS extends never | \"$notStrict\" | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\nexport function createObjectSet(object, { objectDefIdentifier, objectSetIdentifier, propertyKeysIdentifier, osdkObjectIdentifier, }) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\nfunction maybeStripNamespace(type, q) {\n if (type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)) {\n return q.slice(type.apiNamespace.length + 1);\n }\n else {\n return q;\n }\n}\nexport function createProps(type, identifier, strict) {\n const definition = type.getCleanedUpDefinition(true);\n return `export interface ${identifier} {\n${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n return [\n `readonly \"${maybeStripNamespace(type, apiName)}\"${\n // after we convert everything over we can do this:\n // !strict || propertyDefinition.nullable ? \"?\" : \"\"\n \"\"}`,\n `$PropType[${JSON.stringify(propertyDefinition.type)}]${propertyDefinition.multiplicity ? \"[]\" : \"\"}${propertyDefinition.nullable || !strict ? `| undefined` : \"\"}`,\n ];\n },\n })}\n }`;\n}\nexport function createDefinition(object, ontology, identifier, { objectDefIdentifier, objectSetIdentifier, osdkObjectPropsIdentifier, osdkObjectStrictPropsIdentifier, osdkObjectLinksIdentifier, }) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export interface ${identifier} extends ${object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`} {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${stringify(definition, {\n links: (_value) => `{\n ${stringify(definition.links, {\n \"*\": (definition) => `$ObjectMetadata.Link<${ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true)}, ${definition.multiplicity}>`,\n })}\n }`,\n properties: (_value) => (`{\n ${stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => [\n `${propertyJsdoc(propertyDefinition, { apiName })}\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<\"${propertyDefinition.type}\", \"${propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"}\", \"${propertyDefinition.multiplicity ? \"array\" : \"single\"}\">`,\n ],\n })}\n }`),\n })}\n } \n}\n `;\n}\nexport function createLinks(ontology, object, identifier) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n ${Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(definition.targetType)\n .getImportedDefinitionIdentifier(true);\n return [\n `readonly ${key}`,\n `${definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`}\n `,\n ];\n },\n })}\n }\n `}`;\n}\nexport function createPropertyKeys(type) {\n return `export type PropertyKeys = ${Object.keys(type.getCleanedUpDefinition(true).properties).map((a) => maybeStripNamespace(type, a)).map(a => `\"${a}\"`).join(\"|\")};`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD;AACA,OAAO,SAASC,kCAAkCA,CAACC,UAAU,EAA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
|
import type { EnhancedOntologyDefinition } from "./EnhancedOntologyDefinition.js";
|
|
2
2
|
export interface EnhanceCommon {
|
|
3
|
-
ontologyApiNamespace: string | undefined;
|
|
4
|
-
apiNamespacePackageMap: Map<string, string>;
|
|
5
3
|
importExt: string;
|
|
6
4
|
/** DO NOT USE THIS IN THE CONSTRUCTOR(S) */
|
|
7
5
|
enhancedOntology: EnhancedOntologyDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhanceCommon.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhanceCommon.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"EnhanceCommon.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhanceCommon.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,gBAAgB,EAAE,0BAA0B,CAAC;CAC9C"}
|
|
@@ -10,9 +10,7 @@ export declare abstract class AbstractImportable {
|
|
|
10
10
|
*/
|
|
11
11
|
importPath: string;
|
|
12
12
|
uniqueImportName: string;
|
|
13
|
-
|
|
14
|
-
readonly sourcePackage: string | undefined;
|
|
15
|
-
constructor(common: EnhanceCommon, fullApiName: string, basePath: string);
|
|
13
|
+
constructor(common: EnhanceCommon, fullApiName: string, basePath: string, isLocal?: boolean);
|
|
16
14
|
getImportPathRelTo: (filePath: string) => string;
|
|
17
15
|
}
|
|
18
16
|
export declare abstract class EnhancedBase<T> extends AbstractImportable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedBase.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhancedBase.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,8BAAsB,kBAAkB;IACtC,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;IAEjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"EnhancedBase.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhancedBase.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,8BAAsB,kBAAkB;IACtC,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC;IAEjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;gBAGvB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAc;IAiBzB,kBAAkB,aAAc,MAAM,YAapC;CACH;AAED,8BAAsB,YAAY,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IAC9D,GAAG,EAAE,CAAC,CAAC;gBAGL,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,CAAC,EACN,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM;CAKnB;AAED,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAChB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAI9B"}
|
|
@@ -25,20 +25,14 @@ export class AbstractImportable {
|
|
|
25
25
|
*/
|
|
26
26
|
importPath;
|
|
27
27
|
uniqueImportName;
|
|
28
|
-
isLocal
|
|
29
|
-
sourcePackage;
|
|
30
|
-
constructor(common, fullApiName, basePath) {
|
|
28
|
+
constructor(common, fullApiName, basePath, isLocal = true) {
|
|
31
29
|
this._common = common;
|
|
32
30
|
this.fullApiName = fullApiName;
|
|
33
31
|
[this.apiNamespace, this.shortApiName] = extractNamespace(this.fullApiName);
|
|
34
32
|
const {
|
|
35
|
-
ontologyApiNamespace,
|
|
36
|
-
apiNamespacePackageMap,
|
|
37
33
|
importExt
|
|
38
34
|
} = common;
|
|
39
|
-
this.
|
|
40
|
-
this.sourcePackage = this.apiNamespace && !this.isLocal ? apiNamespacePackageMap.get(this.apiNamespace) : undefined;
|
|
41
|
-
this.importPath = this.isLocal ? `${basePath}/${this.shortApiName}${importExt}` : this.sourcePackage;
|
|
35
|
+
this.importPath = isLocal ? `${basePath}/${this.shortApiName}${importExt}` : basePath;
|
|
42
36
|
this.uniqueImportName = this.shortApiName;
|
|
43
37
|
}
|
|
44
38
|
getImportPathRelTo = filePath => {
|
|
@@ -59,9 +53,6 @@ export class EnhancedBase extends AbstractImportable {
|
|
|
59
53
|
constructor(common, raw, fullApiName, basePath) {
|
|
60
54
|
super(common, fullApiName, basePath);
|
|
61
55
|
this.raw = raw;
|
|
62
|
-
if (!this.isLocal && !this.sourcePackage) {
|
|
63
|
-
throw new Error(`Expected { ns:'${this.apiNamespace}', shortName: '${this.shortApiName}'} to be in namespace '${common.ontologyApiNamespace}' or in a provided package mapping`);
|
|
64
|
-
}
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
58
|
export function extractNamespace(fqApiName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedBase.js","names":["path","AbstractImportable","_common","shortApiName","fullApiName","apiNamespace","importPath","uniqueImportName","
|
|
1
|
+
{"version":3,"file":"EnhancedBase.js","names":["path","AbstractImportable","_common","shortApiName","fullApiName","apiNamespace","importPath","uniqueImportName","constructor","common","basePath","isLocal","extractNamespace","importExt","getImportPathRelTo","filePath","startsWith","result","relative","dirname","split","sep","join","EnhancedBase","raw","fqApiName","last","lastIndexOf","undefined","slice"],"sources":["EnhancedBase.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 * as path from \"node:path\";\nexport class AbstractImportable {\n _common;\n shortApiName;\n fullApiName;\n apiNamespace;\n /**\n * Either a path relative to the ourDir (e.g. \"./ontology/objects/foo.js\") or a normal\n * module import (e.g. \"@something/foo\")/\n */\n importPath;\n uniqueImportName;\n constructor(common, fullApiName, basePath, isLocal = true) {\n this._common = common;\n this.fullApiName = fullApiName;\n [this.apiNamespace, this.shortApiName] = extractNamespace(this.fullApiName);\n const { importExt } = common;\n this.importPath = isLocal\n ? `${basePath}/${this.shortApiName}${importExt}`\n : basePath;\n this.uniqueImportName = this.shortApiName;\n }\n getImportPathRelTo = (filePath) => {\n if (this.importPath.startsWith(\".\")) {\n const result = path.relative(path.dirname(filePath), this.importPath)\n .split(path.sep).join(\"/\");\n if (result.startsWith(\".\")) {\n return result;\n }\n else {\n return `./${result}`;\n }\n }\n else {\n return this.importPath;\n }\n };\n}\nexport class EnhancedBase extends AbstractImportable {\n raw;\n constructor(common, raw, fullApiName, basePath) {\n super(common, fullApiName, basePath);\n this.raw = raw;\n }\n}\nexport function extractNamespace(fqApiName) {\n const last = fqApiName.lastIndexOf(\".\");\n if (last === -1)\n return [undefined, fqApiName];\n return [fqApiName.slice(0, last), fqApiName.slice(last + 1)];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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B,GAAG;EACHhB,WAAWA,CAACC,MAAM,EAAEe,GAAG,EAAEpB,WAAW,EAAEM,QAAQ,EAAE;IAC5C,KAAK,CAACD,MAAM,EAAEL,WAAW,EAAEM,QAAQ,CAAC;IACpC,IAAI,CAACc,GAAG,GAAGA,GAAG;EAClB;AACJ;AACA,OAAO,SAASZ,gBAAgBA,CAACa,SAAS,EAAE;EACxC,MAAMC,IAAI,GAAGD,SAAS,CAACE,WAAW,CAAC,GAAG,CAAC;EACvC,IAAID,IAAI,KAAK,CAAC,CAAC,EACX,OAAO,CAACE,SAAS,EAAEH,SAAS,CAAC;EACjC,OAAO,CAACA,SAAS,CAACI,KAAK,CAAC,CAAC,EAAEH,IAAI,CAAC,EAAED,SAAS,CAACI,KAAK,CAACH,IAAI,GAAG,CAAC,CAAC,CAAC;AAChE","ignoreList":[]}
|
|
@@ -10,14 +10,14 @@ import { ForeignType } from "./ForeignType.js";
|
|
|
10
10
|
export declare class EnhancedOntologyDefinition {
|
|
11
11
|
#private;
|
|
12
12
|
ontology: OntologyV2;
|
|
13
|
-
objectTypes: Record<string, EnhancedObjectType>;
|
|
13
|
+
objectTypes: Record<string, EnhancedObjectType | ForeignType>;
|
|
14
14
|
actionTypes: Record<string, EnhancedAction>;
|
|
15
15
|
queryTypes: Record<string, EnhancedQuery>;
|
|
16
|
-
interfaceTypes: Record<string, EnhancedInterfaceType>;
|
|
17
|
-
sharedPropertyTypes: Record<string, EnhancedSharedPropertyType>;
|
|
16
|
+
interfaceTypes: Record<string, EnhancedInterfaceType | ForeignType>;
|
|
17
|
+
sharedPropertyTypes: Record<string, EnhancedSharedPropertyType | ForeignType>;
|
|
18
18
|
raw: WireOntologyDefinition;
|
|
19
19
|
common: EnhanceCommon;
|
|
20
|
-
constructor(raw: WireOntologyDefinition,
|
|
20
|
+
constructor(raw: WireOntologyDefinition, importExt: string, externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>, externalSpts?: Map<string, string>);
|
|
21
21
|
requireObjectType: <L extends boolean = false>(fullApiName: string, localOnly?: L | undefined) => L extends true ? this["objectTypes"][string] : ForeignType;
|
|
22
22
|
requireInterfaceType: <L extends boolean = false>(fullApiName: string, localOnly?: L | undefined) => L extends true ? this["interfaceTypes"][string] : ForeignType;
|
|
23
23
|
requireActionType: <L extends boolean = false>(fullApiName: string, localOnly?: L | undefined) => L extends true ? this["actionTypes"][string] : ForeignType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedOntologyDefinition.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhancedOntologyDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,0BAA0B;;IACrC,QAAQ,EAAE,UAAU,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"EnhancedOntologyDefinition.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/EnhancedOntologyDefinition.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,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,MAAM,2FAkB2C;IAC3D,gBAAgB,GApBb,CAAC,SAAS,OAAO,uBACV,MAAM,0FAmByC;IACzD,yBAAyB,GArBtB,CAAC,SAAS,OAAO,uBACV,MAAM,mGAsBrB;CACH"}
|
|
@@ -30,35 +30,25 @@ export class EnhancedOntologyDefinition {
|
|
|
30
30
|
#foreignTypes = {};
|
|
31
31
|
raw;
|
|
32
32
|
common;
|
|
33
|
-
constructor(raw,
|
|
33
|
+
constructor(raw, importExt, externalObjects, externalInterfaces, externalSpts) {
|
|
34
34
|
this.common = {
|
|
35
|
-
apiNamespacePackageMap,
|
|
36
35
|
enhancedOntology: this,
|
|
37
|
-
importExt
|
|
38
|
-
ontologyApiNamespace
|
|
36
|
+
importExt
|
|
39
37
|
};
|
|
40
38
|
this.raw = raw;
|
|
41
39
|
this.ontology = raw.ontology;
|
|
42
|
-
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType);
|
|
40
|
+
this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType, externalObjects);
|
|
43
41
|
this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);
|
|
44
42
|
this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);
|
|
45
|
-
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType);
|
|
46
|
-
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType);
|
|
43
|
+
this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType, externalInterfaces);
|
|
44
|
+
this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType, externalSpts);
|
|
47
45
|
}
|
|
48
46
|
#createRequireType = type => {
|
|
49
|
-
return
|
|
47
|
+
return fullApiName => {
|
|
50
48
|
const ret = this[type][fullApiName];
|
|
51
49
|
if (!ret) {
|
|
52
50
|
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
53
|
-
|
|
54
|
-
throw new Error(`Unable to find ${type}: No entry for '${fullApiName}`);
|
|
55
|
-
}
|
|
56
|
-
if (!this.common.apiNamespacePackageMap.has(apiNamespace)) {
|
|
57
|
-
throw new Error(`Unable to find ${type}: Unknown namespace '${apiNamespace}'`);
|
|
58
|
-
}
|
|
59
|
-
const ret = this.#foreignTypes[fullApiName] ?? new ForeignType(this.common, type, apiNamespace, shortApiName);
|
|
60
|
-
this.#foreignTypes[fullApiName] = ret;
|
|
61
|
-
return ret;
|
|
51
|
+
throw new Error(`Unable to find ${type}: No entry for '${fullApiName}`);
|
|
62
52
|
}
|
|
63
53
|
return ret;
|
|
64
54
|
};
|
|
@@ -69,9 +59,25 @@ export class EnhancedOntologyDefinition {
|
|
|
69
59
|
requireQueryType = this.#createRequireType("queryTypes");
|
|
70
60
|
requireSharedPropertyType = this.#createRequireType("sharedPropertyTypes");
|
|
71
61
|
}
|
|
72
|
-
function remap(r, common, Constructor) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
function remap(r, common, Constructor, externalMap) {
|
|
63
|
+
const entries = [];
|
|
64
|
+
for (const [fullApiName, v] of Object.entries(r ?? {})) {
|
|
65
|
+
if (!externalMap?.has(fullApiName)) {
|
|
66
|
+
entries.push([fullApiName, new Constructor(common, v)]);
|
|
67
|
+
} // skip it, we handle it below
|
|
68
|
+
}
|
|
69
|
+
if (externalMap) {
|
|
70
|
+
for (const [fullApiName, destPackage] of externalMap) {
|
|
71
|
+
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
72
|
+
// I think this check should be required but the ontology manager / dev console doesn't enforce it right now
|
|
73
|
+
// if (apiNamespace === undefined) {
|
|
74
|
+
// throw new Error(
|
|
75
|
+
// `Cannot reference an external type (${fullApiName}) that is missing a namespace`,
|
|
76
|
+
// );
|
|
77
|
+
// }
|
|
78
|
+
entries.push([fullApiName, new ForeignType(common, apiNamespace, shortApiName, destPackage)]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return Object.fromEntries(entries.sort((a, b) => a[0].localeCompare(b[0])));
|
|
76
82
|
}
|
|
77
83
|
//# sourceMappingURL=EnhancedOntologyDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedOntologyDefinition.js","names":["EnhancedAction","extractNamespace","EnhancedInterfaceType","EnhancedObjectType","EnhancedQuery","EnhancedSharedPropertyType","ForeignType","EnhancedOntologyDefinition","ontology","objectTypes","actionTypes","queryTypes","interfaceTypes","sharedPropertyTypes","foreignTypes","raw","common","constructor","
|
|
1
|
+
{"version":3,"file":"EnhancedOntologyDefinition.js","names":["EnhancedAction","extractNamespace","EnhancedInterfaceType","EnhancedObjectType","EnhancedQuery","EnhancedSharedPropertyType","ForeignType","EnhancedOntologyDefinition","ontology","objectTypes","actionTypes","queryTypes","interfaceTypes","sharedPropertyTypes","foreignTypes","raw","common","constructor","importExt","externalObjects","externalInterfaces","externalSpts","enhancedOntology","remap","createRequireType","type","fullApiName","ret","apiNamespace","shortApiName","Error","requireObjectType","requireInterfaceType","requireActionType","requireQueryType","requireSharedPropertyType","r","Constructor","externalMap","entries","v","Object","has","push","destPackage","fromEntries","sort","a","b","localeCompare"],"sources":["EnhancedOntologyDefinition.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 { EnhancedAction } from \"./EnhancedAction.js\";\nimport { extractNamespace } from \"./EnhancedBase.js\";\nimport { EnhancedInterfaceType } from \"./EnhancedInterfaceType.js\";\nimport { EnhancedObjectType } from \"./EnhancedObjectType.js\";\nimport { EnhancedQuery } from \"./EnhancedQuery.js\";\nimport { EnhancedSharedPropertyType } from \"./EnhancedSharedPropertyType.js\";\nimport { ForeignType } from \"./ForeignType.js\";\nexport class EnhancedOntologyDefinition {\n ontology;\n objectTypes;\n actionTypes;\n queryTypes;\n interfaceTypes;\n sharedPropertyTypes;\n #foreignTypes = {};\n raw;\n common;\n constructor(raw, importExt, externalObjects, externalInterfaces, externalSpts) {\n this.common = {\n enhancedOntology: this,\n importExt,\n };\n this.raw = raw;\n this.ontology = raw.ontology;\n this.objectTypes = remap(raw.objectTypes, this.common, EnhancedObjectType, externalObjects);\n this.actionTypes = remap(raw.actionTypes, this.common, EnhancedAction);\n this.queryTypes = remap(raw.queryTypes, this.common, EnhancedQuery);\n this.interfaceTypes = remap(raw.interfaceTypes, this.common, EnhancedInterfaceType, externalInterfaces);\n this.sharedPropertyTypes = remap(raw.sharedPropertyTypes, this.common, EnhancedSharedPropertyType, externalSpts);\n }\n #createRequireType = (type) => {\n return (fullApiName, localOnly) => {\n const ret = this[type][fullApiName];\n if (!ret) {\n const [apiNamespace, shortApiName] = extractNamespace(fullApiName);\n throw new Error(`Unable to find ${type}: No entry for '${fullApiName}`);\n }\n return ret;\n };\n };\n requireObjectType = this.#createRequireType(\"objectTypes\");\n requireInterfaceType = this.#createRequireType(\"interfaceTypes\");\n requireActionType = this.#createRequireType(\"actionTypes\");\n requireQueryType = this.#createRequireType(\"queryTypes\");\n requireSharedPropertyType = this.#createRequireType(\"sharedPropertyTypes\");\n}\nfunction remap(r, common, Constructor, externalMap) {\n const entries = [];\n for (const [fullApiName, v] of Object.entries(r ?? {})) {\n if (externalMap?.has(fullApiName)) {\n // skip it, we handle it below\n }\n else {\n entries.push([fullApiName, new Constructor(common, v)]);\n }\n }\n if (externalMap) {\n for (const [fullApiName, destPackage] of externalMap) {\n const [apiNamespace, shortApiName] = extractNamespace(fullApiName);\n // I think this check should be required but the ontology manager / dev console doesn't enforce it right now\n // if (apiNamespace === undefined) {\n // throw new Error(\n // `Cannot reference an external type (${fullApiName}) that is missing a namespace`,\n // );\n // }\n entries.push([\n fullApiName,\n new ForeignType(common, apiNamespace, shortApiName, destPackage),\n ]);\n }\n }\n return Object.fromEntries(entries.sort((a, b) => a[0].localeCompare(b[0])));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,qBAAqB;AACpD,SAASC,gBAAgB,QAAQ,mBAAmB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,0BAA0B,QAAQ,iCAAiC;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAO,MAAMC,0BAA0B,CAAC;EACpCC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,UAAU;EACVC,cAAc;EACdC,mBAAmB;EACnB,CAACC,YAAY,GAAG,CAAC,CAAC;EAClBC,GAAG;EACHC,MAAM;EACNC,WAAWA,CAACF,GAAG,EAAEG,SAAS,EAAEC,eAAe,EAAEC,kBAAkB,EAAEC,YAAY,EAAE;IAC3E,IAAI,CAACL,MAAM,GAAG;MACVM,gBAAgB,EAAE,IAAI;MACtBJ;IACJ,CAAC;IACD,IAAI,CAACH,GAAG,GAAGA,GAAG;IACd,IAAI,CAACP,QAAQ,GAAGO,GAAG,CAACP,QAAQ;IAC5B,IAAI,CAACC,WAAW,GAAGc,KAAK,CAACR,GAAG,CAACN,WAAW,EAAE,IAAI,CAACO,MAAM,EAAEb,kBAAkB,EAAEgB,eAAe,CAAC;IAC3F,IAAI,CAACT,WAAW,GAAGa,KAAK,CAACR,GAAG,CAACL,WAAW,EAAE,IAAI,CAACM,MAAM,EAAEhB,cAAc,CAAC;IACtE,IAAI,CAACW,UAAU,GAAGY,KAAK,CAACR,GAAG,CAACJ,UAAU,EAAE,IAAI,CAACK,MAAM,EAA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I,GAAG,CAAChB,WAAW,CAAC,EAG5B;MACDa,OAAO,CAACI,IAAI,CAAC,CAACjB,WAAW,EAAE,IAAIW,WAAW,CAACrB,MAAM,EAAEwB,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC,CAJG;EAKR;EACA,IAAIF,WAAW,EAAE;IACb,KAAK,MAAM,CAACZ,WAAW,EAAEkB,WAAW,CAAC,IAAIN,WAAW,EAAE;MAClD,MAAM,CAACV,YAAY,EAAEC,YAAY,CAAC,GAAG5B,gBAAgB,CAACyB,WAAW,CAAC;MAClE;MACA;MACA;MACA;MACA;MACA;MACAa,OAAO,CAACI,IAAI,CAAC,CACTjB,WAAW,EACX,IAAIpB,WAAW,CAACU,MAAM,EAAEY,YAAY,EAAEC,YAAY,EAAEe,WAAW,CAAC,CACnE,CAAC;IACN;EACJ;EACA,OAAOH,MAAM,CAACI,WAAW,CAACN,OAAO,CAACO,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E","ignoreList":[]}
|
|
@@ -2,8 +2,7 @@ import type { EnhanceCommon } from "./EnhanceCommon.js";
|
|
|
2
2
|
import { AbstractImportable } from "./EnhancedBase.js";
|
|
3
3
|
export declare class ForeignType extends AbstractImportable {
|
|
4
4
|
_common: EnhanceCommon;
|
|
5
|
-
|
|
6
|
-
constructor(_common: EnhanceCommon, type: string, apiNamespace: string, shortApiName: string);
|
|
5
|
+
constructor(_common: EnhanceCommon, apiNamespace: string | undefined, shortApiName: string, destinationPackage: string);
|
|
7
6
|
getImportedDefinitionIdentifier(v2: boolean): string;
|
|
8
7
|
getDefinitionIdentifier(v2: boolean): string;
|
|
9
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForeignType.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/ForeignType.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,qBAAa,WAAY,SAAQ,kBAAkB;IAExC,OAAO,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"ForeignType.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/ForeignType.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,qBAAa,WAAY,SAAQ,kBAAkB;IAExC,OAAO,EAAE,aAAa;gBAAtB,OAAO,EAAE,aAAa,EAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM;IAU5B,+BAA+B,CAAC,EAAE,EAAE,OAAO;IAM3C,uBAAuB,CAAC,EAAE,EAAE,OAAO;CAGpC"}
|
|
@@ -16,21 +16,15 @@
|
|
|
16
16
|
import { AbstractImportable } from "./EnhancedBase.js";
|
|
17
17
|
export class ForeignType extends AbstractImportable {
|
|
18
18
|
_common;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
super(_common, `${apiNamespace}.${shortApiName}`, _common.apiNamespacePackageMap.get(apiNamespace));
|
|
19
|
+
constructor(_common, apiNamespace, shortApiName, destinationPackage) {
|
|
20
|
+
super(_common, apiNamespace ? `${apiNamespace}.${shortApiName}` : shortApiName, destinationPackage, false);
|
|
22
21
|
this._common = _common;
|
|
23
|
-
this.type = type;
|
|
24
22
|
}
|
|
25
23
|
getImportedDefinitionIdentifier() {
|
|
26
|
-
return `$Imported$${this.
|
|
24
|
+
return `$Imported$${this.apiNamespace?.replace(/\./g, "$")}$${this.shortApiName}`;
|
|
27
25
|
}
|
|
28
|
-
getDefinitionIdentifier(
|
|
29
|
-
|
|
30
|
-
return v2 ? this.uniqueImportName : `${this.uniqueImportName}Def`;
|
|
31
|
-
} else {
|
|
32
|
-
return this.uniqueImportName;
|
|
33
|
-
}
|
|
26
|
+
getDefinitionIdentifier() {
|
|
27
|
+
return this.uniqueImportName;
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
//# sourceMappingURL=ForeignType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForeignType.js","names":["AbstractImportable","ForeignType","_common","
|
|
1
|
+
{"version":3,"file":"ForeignType.js","names":["AbstractImportable","ForeignType","_common","constructor","apiNamespace","shortApiName","destinationPackage","getImportedDefinitionIdentifier","replace","getDefinitionIdentifier","uniqueImportName"],"sources":["ForeignType.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 { AbstractImportable } from \"./EnhancedBase.js\";\nexport class ForeignType extends AbstractImportable {\n _common;\n constructor(_common, apiNamespace, shortApiName, destinationPackage) {\n super(_common, apiNamespace ? `${apiNamespace}.${shortApiName}` : shortApiName, destinationPackage, false);\n this._common = _common;\n }\n getImportedDefinitionIdentifier(v2) {\n return `$Imported$${this.apiNamespace?.replace(/\\./g, \"$\")}$${this.shortApiName}`;\n }\n getDefinitionIdentifier(v2) {\n return this.uniqueImportName;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAkB,QAAQ,mBAAmB;AACtD,OAAO,MAAMC,WAAW,SAASD,kBAAkB,CAAC;EAChDE,OAAO;EACPC,WAAWA,CAACD,OAAO,EAAEE,YAAY,EAAEC,YAAY,EAAEC,kBAAkB,EAAE;IACjE,KAAK,CAACJ,OAAO,EAAEE,YAAY,GAAG,GAAGA,YAAY,IAAIC,YAAY,EAAE,GAAGA,YAAY,EAAEC,kBAAkB,EAAE,KAAK,CAAC;IAC1G,IAAI,CAACJ,OAAO,GAAGA,OAAO;EAC1B;EACAK,+BAA+BA,CAAA,EAAK;IAChC,OAAO,aAAa,IAAI,CAACH,YAAY,EAAEI,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,IAAI,CAACH,YAAY,EAAE;EACrF;EACAI,uBAAuBA,CAAA,EAAK;IACxB,OAAO,IAAI,CAACC,gBAAgB;EAChC;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { WireOntologyDefinition } from "../WireOntologyDefinition.js";
|
|
2
2
|
import { EnhancedOntologyDefinition } from "./EnhancedOntologyDefinition.js";
|
|
3
|
-
export declare function enhanceOntology(sanitized
|
|
3
|
+
export declare function enhanceOntology({ sanitized, importExt, externalObjects, externalInterfaces, externalSpts, }: {
|
|
4
|
+
sanitized: WireOntologyDefinition;
|
|
5
|
+
externalObjects?: Map<string, string>;
|
|
6
|
+
externalInterfaces?: Map<string, string>;
|
|
7
|
+
externalSpts?: Map<string, string>;
|
|
8
|
+
importExt: string;
|
|
9
|
+
}): EnhancedOntologyDefinition;
|
|
4
10
|
//# sourceMappingURL=enhanceOntology.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enhanceOntology.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/enhanceOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,wBAAgB,eAAe,CAC7B,SAAS,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"enhanceOntology.d.ts","sourceRoot":"","sources":["../../../src/GenerateContext/enhanceOntology.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,wBAAgB,eAAe,CAC7B,EACE,SAAS,EACT,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,YAAY,GACb,EAAE;IACD,SAAS,EAAE,sBAAsB,CAAC;IAClC,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;CACnB,GACA,0BAA0B,CAQ5B"}
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { EnhancedOntologyDefinition } from "./EnhancedOntologyDefinition.js";
|
|
17
|
-
export function enhanceOntology(
|
|
18
|
-
|
|
17
|
+
export function enhanceOntology({
|
|
18
|
+
sanitized,
|
|
19
|
+
importExt,
|
|
20
|
+
externalObjects,
|
|
21
|
+
externalInterfaces,
|
|
22
|
+
externalSpts
|
|
23
|
+
}) {
|
|
24
|
+
return new EnhancedOntologyDefinition(sanitized, importExt, externalObjects, externalInterfaces, externalSpts);
|
|
19
25
|
}
|
|
20
26
|
//# sourceMappingURL=enhanceOntology.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enhanceOntology.js","names":["EnhancedOntologyDefinition","enhanceOntology","sanitized","
|
|
1
|
+
{"version":3,"file":"enhanceOntology.js","names":["EnhancedOntologyDefinition","enhanceOntology","sanitized","importExt","externalObjects","externalInterfaces","externalSpts"],"sources":["enhanceOntology.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 { EnhancedOntologyDefinition } from \"./EnhancedOntologyDefinition.js\";\nexport function enhanceOntology({ sanitized, importExt, externalObjects, externalInterfaces, externalSpts, }) {\n return new EnhancedOntologyDefinition(sanitized, importExt, externalObjects, externalInterfaces, externalSpts);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,iCAAiC;AAC5E,OAAO,SAASC,eAAeA,CAAC;EAAEC,SAAS;EAAEC,SAAS;EAAEC,eAAe;EAAEC,kBAAkB;EAAEC;AAAc,CAAC,EAAE;EAC1G,OAAO,IAAIN,0BAA0B,CAACE,SAAS,EAAEC,SAAS,EAAEC,eAAe,EAAEC,kBAAkB,EAAEC,YAAY,CAAC;AAClH","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MinimalFs } from "./MinimalFs.js";
|
|
2
2
|
import type { WireOntologyDefinition } from "./WireOntologyDefinition.js";
|
|
3
|
-
export declare function generateClientSdkPackage(packageName: string, packageVersion: string, sdkVersion: "1.1" | "2.0", baseOutDir: string, ontology: WireOntologyDefinition, minimalFs: MinimalFs, dependencyVersions: DependencyVersions, cliVersion: string,
|
|
3
|
+
export declare function generateClientSdkPackage(packageName: string, packageVersion: string, sdkVersion: "1.1" | "2.0", baseOutDir: string, ontology: WireOntologyDefinition, minimalFs: MinimalFs, dependencyVersions: DependencyVersions, cliVersion: string, externalObjects?: Map<string, string>, externalInterfaces?: Map<string, string>): Promise<void>;
|
|
4
4
|
export interface DependencyVersions {
|
|
5
5
|
typescriptVersion: string;
|
|
6
6
|
tslibVersion: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateClientSdkPackage.d.ts","sourceRoot":"","sources":["../../src/generateClientSdkPackage.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,KAAK,GAAG,KAAK,EACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,MAAM,EAClB,
|
|
1
|
+
{"version":3,"file":"generateClientSdkPackage.d.ts","sourceRoot":"","sources":["../../src/generateClientSdkPackage.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,KAAK,GAAG,KAAK,EACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,MAAM,EAClB,eAAe,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,EAChD,kBAAkB,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,iBA4DpD;AA+BD,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,uBAAuB,CACrC,EACE,cAAc,EACd,iBAAiB,GAClB,EAAE,kBAAkB;;;;;;;;EAWtB;AA0BD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BvC"}
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
import * as fs from "node:fs";
|
|
17
17
|
import * as path from "node:path";
|
|
18
18
|
import { generateClientSdkVersionTwoPointZero } from "./v2.0/generateClientSdkVersionTwoPointZero.js";
|
|
19
|
-
export async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion,
|
|
19
|
+
export async function generateClientSdkPackage(packageName, packageVersion, sdkVersion, baseOutDir, ontology, minimalFs, dependencyVersions, cliVersion, externalObjects = new Map(), externalInterfaces = new Map()) {
|
|
20
20
|
if (!packageName) throw new Error("Package name is required");
|
|
21
21
|
if (sdkVersion === "1.1") {
|
|
22
22
|
throw new Error("This generator version does not support generating v1 sdks");
|
|
23
23
|
}
|
|
24
24
|
for (const packageType of ["module", "commonjs"]) {
|
|
25
25
|
const outDir = path.join(baseOutDir, "dist", packageType);
|
|
26
|
-
generateClientSdkVersionTwoPointZero(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType,
|
|
26
|
+
generateClientSdkVersionTwoPointZero(ontology, `typescript-sdk/${packageVersion} osdk-cli/${cliVersion}`, minimalFs, outDir, packageType, externalObjects, externalInterfaces);
|
|
27
27
|
await fs.promises.mkdir(outDir, {
|
|
28
28
|
recursive: true
|
|
29
29
|
});
|