@osdk/generator 2.22.0 → 2.23.0-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
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 +10 -0
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.js +6 -1
- package/build/browser/GenerateContext/EnhancedOntologyDefinition.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/wireInterfaceTypeV2ToSdkObjectConst.js +5 -3
- package/build/browser/v2.0/wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +6 -2
- package/build/browser/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/cjs/index.cjs +15 -5
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.js +6 -1
- package/build/esm/GenerateContext/EnhancedOntologyDefinition.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/wireInterfaceTypeV2ToSdkObjectConst.js +5 -3
- package/build/esm/v2.0/wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js +6 -2
- package/build/esm/v2.0/wireObjectTypeV2ToSdkObjectConstV2.js.map +1 -1
- package/build/types/GenerateContext/EnhancedOntologyDefinition.d.ts.map +1 -1
- package/build/types/v2.0/wireObjectTypeV2ToSdkObjectConstV2.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
+
## 2.23.0-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9fb5afb: Emit structured `service.1` JSON logs to stdout for log forwarders, with timing for ontology metadata loading and OSDK package generation phases. Reads `JOB_ID` and `TRACE_ID` from env and threads them into every record's params for cross-process correlation. The previous human-readable console output (via consola) has been removed; the CLI now exits with a non-zero status code on failure.
|
|
8
|
+
- Updated dependencies [9fb5afb]
|
|
9
|
+
- Updated dependencies [198f219]
|
|
10
|
+
- @osdk/generator-converters@2.23.0-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
11
|
+
- @osdk/api@2.23.0-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
12
|
+
|
|
3
13
|
## 2.22.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { GeneratorError } from "@osdk/generator-converters";
|
|
17
18
|
import { EnhancedAction } from "./EnhancedAction.js";
|
|
18
19
|
import { extractNamespace } from "./EnhancedBase.js";
|
|
19
20
|
import { EnhancedInterfaceType } from "./EnhancedInterfaceType.js";
|
|
@@ -41,7 +42,11 @@ export class EnhancedOntologyDefinition {
|
|
|
41
42
|
const ret = this[type][fullApiName];
|
|
42
43
|
if (!ret) {
|
|
43
44
|
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
44
|
-
throw new
|
|
45
|
+
throw new GeneratorError("Unable to find entity", {
|
|
46
|
+
fullApiName
|
|
47
|
+
}, {
|
|
48
|
+
entityType: type
|
|
49
|
+
});
|
|
45
50
|
}
|
|
46
51
|
return ret;
|
|
47
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedOntologyDefinition.js","names":["EnhancedAction","extractNamespace","EnhancedInterfaceType","EnhancedObjectType","EnhancedQuery","EnhancedSharedPropertyType","ForeignType","EnhancedOntologyDefinition","foreignTypes","constructor","raw","importExt","externalObjects","externalInterfaces","externalSpts","common","enhancedOntology","ontology","objectTypes","remap","actionTypes","queryTypes","interfaceTypes","sharedPropertyTypes","createRequireType","type","fullApiName","ret","apiNamespace","shortApiName","
|
|
1
|
+
{"version":3,"file":"EnhancedOntologyDefinition.js","names":["GeneratorError","EnhancedAction","extractNamespace","EnhancedInterfaceType","EnhancedObjectType","EnhancedQuery","EnhancedSharedPropertyType","ForeignType","EnhancedOntologyDefinition","foreignTypes","constructor","raw","importExt","externalObjects","externalInterfaces","externalSpts","common","enhancedOntology","ontology","objectTypes","remap","actionTypes","queryTypes","interfaceTypes","sharedPropertyTypes","createRequireType","type","fullApiName","ret","apiNamespace","shortApiName","entityType","requireObjectType","requireInterfaceType","requireActionType","requireQueryType","requireSharedPropertyType","r","Constructor","externalMap","entries","v","Object","has","push","destPackage","fromEntries","sort","a","b","localeCompare"],"sources":["EnhancedOntologyDefinition.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { OntologyV2 } from \"@osdk/foundry.ontologies\";\nimport { GeneratorError } from \"@osdk/generator-converters\";\nimport type { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\nimport type { EnhanceCommon } from \"./EnhanceCommon.js\";\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\";\n\ntype RequiredType<\n K extends\n | \"objectTypes\"\n | \"actionTypes\"\n | \"interfaceTypes\"\n | \"queryTypes\"\n | \"sharedPropertyTypes\",\n> = <\n L extends boolean = false,\n>(\n fullApiName: string,\n localOnly?: L,\n) => L extends true ? EnhancedOntologyDefinition[K][string] : ForeignType;\n\nexport class EnhancedOntologyDefinition {\n ontology: OntologyV2;\n objectTypes: Record<string, EnhancedObjectType | ForeignType>;\n actionTypes: Record<string, EnhancedAction>;\n queryTypes: Record<string, EnhancedQuery>;\n interfaceTypes: Record<\n string,\n EnhancedInterfaceType | ForeignType\n >;\n sharedPropertyTypes: Record<\n string,\n EnhancedSharedPropertyType | ForeignType\n >;\n #foreignTypes: Record<string, ForeignType> = {};\n\n raw: WireOntologyDefinition;\n common: EnhanceCommon;\n\n constructor(\n raw: WireOntologyDefinition,\n importExt: string,\n externalObjects?: Map<string, string>,\n externalInterfaces?: Map<string, string>,\n externalSpts?: Map<string, string>,\n ) {\n this.common = {\n enhancedOntology: this,\n importExt,\n };\n this.raw = raw;\n this.ontology = raw.ontology;\n this.objectTypes = remap(\n raw.objectTypes,\n this.common,\n EnhancedObjectType,\n externalObjects,\n );\n this.actionTypes = remap(\n raw.actionTypes,\n this.common,\n EnhancedAction,\n );\n this.queryTypes = remap(\n raw.queryTypes,\n this.common,\n EnhancedQuery,\n );\n this.interfaceTypes = remap(\n raw.interfaceTypes,\n this.common,\n EnhancedInterfaceType,\n externalInterfaces,\n );\n this.sharedPropertyTypes = remap(\n raw.sharedPropertyTypes,\n this.common,\n EnhancedSharedPropertyType,\n externalSpts,\n );\n }\n\n #createRequireType = <\n K extends\n | \"objectTypes\"\n | \"actionTypes\"\n | \"interfaceTypes\"\n | \"queryTypes\"\n | \"sharedPropertyTypes\",\n >(\n type: K & keyof this,\n ) => {\n return <L extends boolean = false>(\n fullApiName: string,\n localOnly?: L,\n ): L extends true ? this[K][string] : ForeignType => {\n const ret = this[type][fullApiName];\n if (!ret) {\n const [apiNamespace, shortApiName] = extractNamespace(fullApiName);\n\n throw new GeneratorError(\"Unable to find entity\", { fullApiName }, {\n entityType: type,\n });\n }\n return ret as this[K][string] as L extends true ? this[K][string]\n : ForeignType;\n };\n };\n\n public requireObjectType: RequiredType<\"objectTypes\"> = this\n .#createRequireType(\"objectTypes\");\n public requireInterfaceType: RequiredType<\"interfaceTypes\"> = this\n .#createRequireType(\"interfaceTypes\");\n public requireActionType: RequiredType<\"actionTypes\"> = this\n .#createRequireType(\"actionTypes\");\n public requireQueryType: RequiredType<\"queryTypes\"> = this\n .#createRequireType(\"queryTypes\");\n public requireSharedPropertyType: RequiredType<\"sharedPropertyTypes\"> = this\n .#createRequireType(\n \"sharedPropertyTypes\",\n );\n}\n\nfunction remap<T, X>(\n r: Record<string, T>,\n common: EnhanceCommon,\n Constructor: { new(common: EnhanceCommon, og: T): X },\n): Record<string, X>;\nfunction remap<T, X>(\n r: Record<string, T>,\n common: EnhanceCommon,\n Constructor: { new(common: EnhanceCommon, original: T): X },\n externalMap?: Map<string, string>,\n): Record<string, X | ForeignType>;\nfunction remap<T, X, const Q extends Map<string, string> | undefined>(\n r: Record<string, T>,\n common: EnhanceCommon,\n Constructor: { new(common: EnhanceCommon, og: T): X },\n externalMap?: Q,\n): Record<string, X | ForeignType> {\n const entries: [string, X | ForeignType][] = [];\n\n for (const [fullApiName, v] of Object.entries(r ?? {})) {\n if (externalMap?.has(fullApiName)) {\n // skip it, we handle it below\n } else {\n entries.push([fullApiName, new Constructor(common, v)]);\n }\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(\n common,\n apiNamespace,\n shortApiName,\n destPackage,\n ),\n ]);\n }\n }\n\n return Object.fromEntries(\n entries.sort((a, b) => a[0].localeCompare(b[0])),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,4BAA4B;AAG3D,SAASC,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;AAgB9C,OAAO,MAAMC,0BAA0B,CAAC;EAatC,CAACC,YAAY,GAAgC,CAAC,CAAC;EAK/CC,WAAWA,CACTC,GAA2B,EAC3BC,SAAiB,EACjBC,eAAqC,EACrCC,kBAAwC,EACxCC,YAAkC,EAClC;IACA,IAAI,CAACC,MAAM,GAAG;MACZC,gBAAgB,EAAE,IAAI;MACtBL;IACF,CAAC;IACD,IAAI,CAACD,GAAG,GAAGA,GAAG;IACd,IAAI,CAACO,QAAQ,GAAGP,GAAG,CAACO,QAAQ;IAC5B,IAAI,CAACC,WAAW,GAAGC,KAAK,CACtBT,GAAG,CAACQ,WAAW,EACf,IAAI,CAACH,MAAM,EACXZ,kBAAkB,EAClBS,eACF,CAAC;IACD,IAAI,CAACQ,WAAW,GAAGD,KAAK,CACtBT,GAAG,CAACU,WAAW,EACf,IAAI,CAACL,MAAM,EACXf,cACF,CAAC;IACD,IAAI,CAACqB,UAAU,GAAGF,KAAK,CACrBT,GAAG,CAACW,UAAU,EACd,IAAI,CAACN,MAAM,EACXX,aACF,CAAC;IACD,IAAI,CAACkB,cAAc,GAAGH,KAAK,CACzBT,GAAG,CAACY,cAAc,EAClB,IAAI,CAACP,MAAM,EACXb,qBAAqB,EACrBW,kBACF,CA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AIW,WAAW,CAACtB,MAAM,EAAEyB,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,CAHC;EAIJ;EAEA,IAAIF,WAAW,EAAE;IACf,KAAK,MAAM,CAACZ,WAAW,EAAEkB,WAAW,CAAC,IAAIN,WAAW,EAAE;MACpD,MAAM,CAACV,YAAY,EAAEC,YAAY,CAAC,GAAG5B,gBAAgB,CAACyB,WAAW,CAAC;MAClE;MACA;MACA;MACA;MACA;MACA;MACAa,OAAO,CAACI,IAAI,CAAC,CACXjB,WAAW,EACX,IAAIpB,WAAW,CACbS,MAAM,EACNa,YAAY,EACZC,YAAY,EACZe,WACF,CAAC,CACF,CAAC;IACJ;EACF;EAEA,OAAOH,MAAM,CAACI,WAAW,CACvBN,OAAO,CAACO,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAAC,CAAC,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC,CAAC,CAAC,CACjD,CAAC;AACH","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ import path from "path";
|
|
|
18
18
|
import { formatTs } from "../util/test/formatTs.js";
|
|
19
19
|
|
|
20
20
|
// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
21
|
-
const ExpectedOsdkVersion = "2.
|
|
21
|
+
const ExpectedOsdkVersion = "2.23.0";
|
|
22
22
|
// END: THIS IS GENERATED CODE. DO NOT EDIT.
|
|
23
23
|
|
|
24
24
|
export async function generateOntologyMetadataFile({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateMetadata.js","names":["path","formatTs","ExpectedOsdkVersion","generateOntologyMetadataFile","fs","outDir","ontology","ontologyApiNamespace","userAgent","writeFile","join","rid","raw","branch"],"sources":["generateMetadata.ts"],"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 */\n\nimport path from \"path\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst ExpectedOsdkVersion = \"2.
|
|
1
|
+
{"version":3,"file":"generateMetadata.js","names":["path","formatTs","ExpectedOsdkVersion","generateOntologyMetadataFile","fs","outDir","ontology","ontologyApiNamespace","userAgent","writeFile","join","rid","raw","branch"],"sources":["generateMetadata.ts"],"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 */\n\nimport path from \"path\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst ExpectedOsdkVersion = \"2.23.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\n\nexport async function generateOntologyMetadataFile(\n { fs, outDir, ontology, ontologyApiNamespace }: GenerateContext,\n userAgent: string,\n): Promise<void> {\n await fs.writeFile(\n path.join(outDir, \"OntologyMetadata.ts\"),\n await formatTs(\n `\n export type $ExpectedClientVersion = \"${ExpectedOsdkVersion}\";\n export const $osdkMetadata = { extraUserAgent: \"${userAgent}\" };\n ${\n ontologyApiNamespace == null\n ? `\n export const $ontologyRid = \"${ontology.ontology.rid}\";\n `\n : \"\"\n }\n ${\n ontology.raw.branch != null\n ? `\n export const $branch = \"${ontology.raw.branch.rid}\";\n `\n : \"\"\n }\n `,\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AAEvB,SAASC,QAAQ,QAAQ,0BAA0B;;AAEnD;AACA,MAAMC,mBAAmB,GAAG,QAAQ;AACpC;;AAEA,OAAO,eAAeC,4BAA4BA,CAChD;EAAEC,EAAE;EAAEC,MAAM;EAAEC,QAAQ;EAAEC;AAAsC,CAAC,EAC/DC,SAAiB,EACF;EACf,MAAMJ,EAAE,CAACK,SAAS,CAChBT,IAAI,CAACU,IAAI,CAACL,MAAM,EAAE,qBAAqB,CAAC,EACxC,MAAMJ,QAAQ,CACZ;AACN,8CAA8CC,mBAAmB;AACjE,wDAAwDM,SAAS;AACjE,QACQD,oBAAoB,IAAI,IAAI,GACxB;AACZ,uCAAuCD,QAAQ,CAACA,QAAQ,CAACK,GAAG;AAC5D,SAAS,GACG,EAAE;AACd,SAEQL,QAAQ,CAACM,GAAG,CAACC,MAAM,IAAI,IAAI,GACvB;AACZ,kCAAkCP,QAAQ,CAACM,GAAG,CAACC,MAAM,CAACF,GAAG;AACzD,SAAS,GACG,EAAE;AACd,OAEI,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { wireInterfaceTypeV2ToSdkObjectDefinition } from "@osdk/generator-converters";
|
|
17
|
+
import { GeneratorError, wireInterfaceTypeV2ToSdkObjectDefinition } from "@osdk/generator-converters";
|
|
18
18
|
import consola from "consola";
|
|
19
19
|
import fastDeepEqual from "fast-deep-equal";
|
|
20
20
|
import invariant from "tiny-invariant";
|
|
@@ -74,8 +74,10 @@ export function wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 =
|
|
|
74
74
|
};
|
|
75
75
|
const maybeBadProperties = getInvalidInterfaceProperties(interfaceDef, definition);
|
|
76
76
|
if (maybeBadProperties.length > 0) {
|
|
77
|
-
throw new
|
|
78
|
-
|
|
77
|
+
throw new GeneratorError("Property name collision in interface: cannot have both an unqualified property and a namespaced property with matching root name when the namespace matches the interface.", {
|
|
78
|
+
interfaceApiName: interfaceDef.fullApiName,
|
|
79
|
+
collidingProperties: maybeBadProperties
|
|
80
|
+
});
|
|
79
81
|
}
|
|
80
82
|
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
81
83
|
return `${imports}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireInterfaceTypeV2ToSdkObjectConst.js","names":["wireInterfaceTypeV2ToSdkObjectDefinition","consola","fastDeepEqual","invariant","extractNamespace","EnhancedInterfaceType","getObjectImports","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","wireInterfaceTypeV2ToSdkObjectConst","interfaceDef","ontology","v2","forInternalUse","currentFilePath","definition","raw","uniqueLinkTargetTypes","Set","links","Object","values","map","a","targetType","requireObjectType","targetTypeApiName","requireInterfaceType","objectDefIdentifier","getDefinitionIdentifier","parents","implements","p","parent","it","mergedProperties","properties","apiName","keys","process","env","NODE_ENV","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","ids","maybeBadProperties","getInvalidInterfaceProperties","length","Error","fullApiName","join","imports","linkTarget","getImportedDefinitionIdentifier","multiplicity","valueTypes","rid","apiNamespace","unqualifiedPropNames","filter","namespace","rootName","badProperties","ns","has"],"sources":["wireInterfaceTypeV2ToSdkObjectConst.ts"],"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 */\n\nimport type { InterfaceMetadata } from \"@osdk/api\";\nimport { wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport invariant from \"tiny-invariant\";\nimport { extractNamespace } from \"../GenerateContext/EnhancedBase.js\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport type { Identifiers } from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\nimport {\n createDefinition,\n createObjectSet,\n createOsdkObject,\n createPropertyKeys,\n createProps,\n} from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\n\n/** @internal */\nexport function wireInterfaceTypeV2ToSdkObjectConst(\n interfaceDef: EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n v2: boolean = false,\n forInternalUse: boolean = false,\n currentFilePath: string = \"\",\n) {\n const definition = deleteUndefineds(\n wireInterfaceTypeV2ToSdkObjectDefinition(\n interfaceDef.raw,\n v2,\n ),\n );\n const uniqueLinkTargetTypes = new Set(\n definition.links\n ? Object.values(definition.links).map(a =>\n a.targetType === \"object\"\n ? ontology.requireObjectType(\n a.targetTypeApiName,\n )\n : ontology.requireInterfaceType(\n a.targetTypeApiName,\n )\n )\n : [],\n );\n\n const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);\n\n const parents = definition.implements?.map(p => {\n const parent = ontology.requireInterfaceType(p, true);\n if (parent instanceof EnhancedInterfaceType) {\n const it = deleteUndefineds(\n wireInterfaceTypeV2ToSdkObjectDefinition(\n parent.raw,\n v2,\n consola,\n ),\n );\n return it;\n }\n }) ?? [];\n\n const mergedProperties = { ...definition.properties };\n for (const parent of parents) {\n if (parent == null) {\n // came from a foreign type and we cannot merge properties yet\n // so if they weren't listed on the interface its over\n continue;\n }\n for (const apiName of Object.keys(parent.properties)) {\n if (definition.properties[apiName] != null) {\n invariant(\n fastDeepEqual(\n definition.properties[apiName],\n parent.properties[apiName],\n ),\n `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`,\n );\n } else if (mergedProperties[apiName] != null) {\n invariant(\n fastDeepEqual(\n mergedProperties[apiName],\n parent.properties[apiName],\n ),\n `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`,\n );\n }\n mergedProperties[apiName] = parent.properties[apiName];\n }\n }\n\n definition.properties = mergedProperties;\n\n const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier =\n `${interfaceDef.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;\n const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;\n\n const ids: Identifiers = {\n objectDefIdentifier: interfaceDef.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n const maybeBadProperties = getInvalidInterfaceProperties(\n interfaceDef,\n definition,\n );\n if (maybeBadProperties.length > 0) {\n throw new Error(\n `Property name collision in interface \"${interfaceDef.fullApiName}\": ${\n maybeBadProperties.join(\", \")\n }. +\nCannot have both an unqualified property and a namespaced property with matching root name when the namespace matches the interface.`,\n );\n }\n\n function getV2Types(forInternalUse: boolean = false) {\n return `import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n \n ${\n definition.links\n ? Object.keys(definition.links).length > 0\n ? `\n export interface ${osdkObjectLinksIdentifier} {\n${\n stringify(definition.links, {\n \"*\": (definition) => {\n const linkTarget = definition.targetType === \"object\"\n ? ontology.requireObjectType(\n definition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(v2)\n : ontology.requireInterfaceType(\n definition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(v2);\n\n return `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `;\n },\n })\n }\n }\n `\n : `export type ${osdkObjectLinksIdentifier} = {};`\n : `export type ${osdkObjectLinksIdentifier} = {};`\n }\n\n export namespace ${interfaceDef.shortApiName} {\n\n ${createPropertyKeys(interfaceDef)}\n\n\n ${createProps(interfaceDef, \"Props\", false, ontology.raw.valueTypes)}\n ${createProps(interfaceDef, \"StrictProps\", true, ontology.raw.valueTypes)}\n\n\n ${createObjectSet(interfaceDef, ids)}\n\n ${createOsdkObject(interfaceDef, \"OsdkInstance\", ids)}\n \n } \n\n ${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}\n\n`;\n }\n\n const imports: string = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n definition;\n return `${imports}\n ${v2 ? getV2Types(forInternalUse) : \"\"}\n\n export const ${interfaceDef.shortApiName} = {\n type: \"interface\",\n apiName: \"${interfaceDef.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"${definition.rid}\",\n },\n } satisfies ${interfaceDef.shortApiName} & { internalDoNotUseMetadata: { rid: string } } as ${interfaceDef.shortApiName};`;\n}\n/** @internal */\nexport function getInvalidInterfaceProperties(\n interfaceDef: EnhancedInterfaceType,\n definition: InterfaceMetadata,\n): string[] {\n if (interfaceDef.apiNamespace == null) {\n return [];\n }\n const unqualifiedPropNames = new Set(\n Object.keys(definition.properties)\n .map(apiName => extractNamespace(apiName))\n .filter(([namespace]) => namespace == null)\n .map(([, rootName]) => rootName),\n );\n\n // Find namespaced properties whose namespace matches the interface\n // AND whose root name conflicts with an un-namespaced property\n const badProperties = Object.keys(definition.properties).filter(apiName => {\n const [ns, rootName] = extractNamespace(apiName);\n return ns === interfaceDef.apiNamespace\n && unqualifiedPropNames.has(rootName);\n });\n\n return badProperties;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,wCAAwC,QAAQ,4BAA4B;AACrF,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,qBAAqB,QAAQ,6CAA6C;AAEnF,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SACEC,gBAAgB,EAChBC,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,EAClBC,WAAW,QACN,yCAAyC;;AAEhD;AACA,OAAO,SAASC,mCAAmCA,CACjDC,YAAmC,EACnCC,QAAoC,EACpCC,EAAW,GAAG,KAAK,EACnBC,cAAuB,GAAG,KAAK,EAC/BC,eAAuB,GAAG,EAAE,EA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QAAQ,CAAC,KAAKA,QAAQ,CACnC,CAAC;;EAED;EACA;EACA,MAAMC,aAAa,GAAG/C,MAAM,CAACkB,IAAI,CAACvB,UAAU,CAACqB,UAAU,CAAC,CAAC4B,MAAM,CAAC3B,OAAO,IAAI;IACzE,MAAM,CAAC+B,EAAE,EAAEF,QAAQ,CAAC,GAAGnE,gBAAgB,CAACsC,OAAO,CAAC;IAChD,OAAO+B,EAAE,KAAK1D,YAAY,CAACoD,YAAY,IAClCC,oBAAoB,CAACM,GAAG,CAACH,QAAQ,CAAC;EACzC,CAAC,CAAC;EAEF,OAAOC,aAAa;AACtB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"wireInterfaceTypeV2ToSdkObjectConst.js","names":["GeneratorError","wireInterfaceTypeV2ToSdkObjectDefinition","consola","fastDeepEqual","invariant","extractNamespace","EnhancedInterfaceType","getObjectImports","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","wireInterfaceTypeV2ToSdkObjectConst","interfaceDef","ontology","v2","forInternalUse","currentFilePath","definition","raw","uniqueLinkTargetTypes","Set","links","Object","values","map","a","targetType","requireObjectType","targetTypeApiName","requireInterfaceType","objectDefIdentifier","getDefinitionIdentifier","parents","implements","p","parent","it","mergedProperties","properties","apiName","keys","process","env","NODE_ENV","objectSetIdentifier","shortApiName","propertyKeysIdentifier","osdkObjectPropsIdentifier","osdkObjectStrictPropsIdentifier","osdkObjectLinksIdentifier","osdkObjectIdentifier","ids","maybeBadProperties","getInvalidInterfaceProperties","length","interfaceApiName","fullApiName","collidingProperties","imports","linkTarget","getImportedDefinitionIdentifier","multiplicity","valueTypes","rid","apiNamespace","unqualifiedPropNames","filter","namespace","rootName","badProperties","ns","has"],"sources":["wireInterfaceTypeV2ToSdkObjectConst.ts"],"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 */\n\nimport type { InterfaceMetadata } from \"@osdk/api\";\nimport {\n GeneratorError,\n wireInterfaceTypeV2ToSdkObjectDefinition,\n} from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport fastDeepEqual from \"fast-deep-equal\";\nimport invariant from \"tiny-invariant\";\nimport { extractNamespace } from \"../GenerateContext/EnhancedBase.js\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport type { Identifiers } from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\nimport {\n createDefinition,\n createObjectSet,\n createOsdkObject,\n createPropertyKeys,\n createProps,\n} from \"./wireObjectTypeV2ToSdkObjectConstV2.js\";\n\n/** @internal */\nexport function wireInterfaceTypeV2ToSdkObjectConst(\n interfaceDef: EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n v2: boolean = false,\n forInternalUse: boolean = false,\n currentFilePath: string = \"\",\n) {\n const definition = deleteUndefineds(\n wireInterfaceTypeV2ToSdkObjectDefinition(\n interfaceDef.raw,\n v2,\n ),\n );\n const uniqueLinkTargetTypes = new Set(\n definition.links\n ? Object.values(definition.links).map(a =>\n a.targetType === \"object\"\n ? ontology.requireObjectType(\n a.targetTypeApiName,\n )\n : ontology.requireInterfaceType(\n a.targetTypeApiName,\n )\n )\n : [],\n );\n\n const objectDefIdentifier = interfaceDef.getDefinitionIdentifier(v2);\n\n const parents = definition.implements?.map(p => {\n const parent = ontology.requireInterfaceType(p, true);\n if (parent instanceof EnhancedInterfaceType) {\n const it = deleteUndefineds(\n wireInterfaceTypeV2ToSdkObjectDefinition(\n parent.raw,\n v2,\n consola,\n ),\n );\n return it;\n }\n }) ?? [];\n\n const mergedProperties = { ...definition.properties };\n for (const parent of parents) {\n if (parent == null) {\n // came from a foreign type and we cannot merge properties yet\n // so if they weren't listed on the interface its over\n continue;\n }\n for (const apiName of Object.keys(parent.properties)) {\n if (definition.properties[apiName] != null) {\n invariant(\n fastDeepEqual(\n definition.properties[apiName],\n parent.properties[apiName],\n ),\n `Interface ${definition.apiName} redefines property '${apiName}' from parent '${parent.apiName}' but the properties do not match`,\n );\n } else if (mergedProperties[apiName] != null) {\n invariant(\n fastDeepEqual(\n mergedProperties[apiName],\n parent.properties[apiName],\n ),\n `Some interface defines a conflicting property '${apiName}' that does not match property from parent '${parent.apiName}'`,\n );\n }\n mergedProperties[apiName] = parent.properties[apiName];\n }\n }\n\n definition.properties = mergedProperties;\n\n const objectSetIdentifier = `${interfaceDef.shortApiName}.ObjectSet`;\n const propertyKeysIdentifier = `${interfaceDef.shortApiName}.PropertyKeys`;\n // const osdkObjectPropsIdentifier = `OsdkObjectProps$${objectDefIdentifier}`;\n const osdkObjectPropsIdentifier = `${interfaceDef.shortApiName}.Props`;\n const osdkObjectStrictPropsIdentifier =\n `${interfaceDef.shortApiName}.StrictProps`;\n const osdkObjectLinksIdentifier = `OsdkObjectLinks$${objectDefIdentifier}`;\n const osdkObjectIdentifier = `${interfaceDef.shortApiName}.OsdkObject`;\n\n const ids: Identifiers = {\n objectDefIdentifier: interfaceDef.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n const maybeBadProperties = getInvalidInterfaceProperties(\n interfaceDef,\n definition,\n );\n if (maybeBadProperties.length > 0) {\n throw new GeneratorError(\n \"Property name collision in interface: cannot have both an unqualified property and a namespaced property with matching root name when the namespace matches the interface.\",\n {\n interfaceApiName: interfaceDef.fullApiName,\n collidingProperties: maybeBadProperties,\n },\n );\n }\n\n function getV2Types(forInternalUse: boolean = false) {\n return `import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n SingleLinkAccessor as $SingleLinkAccessor,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n \n ${\n definition.links\n ? Object.keys(definition.links).length > 0\n ? `\n export interface ${osdkObjectLinksIdentifier} {\n${\n stringify(definition.links, {\n \"*\": (definition) => {\n const linkTarget = definition.targetType === \"object\"\n ? ontology.requireObjectType(\n definition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(v2)\n : ontology.requireInterfaceType(\n definition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(v2);\n\n return `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `;\n },\n })\n }\n }\n `\n : `export type ${osdkObjectLinksIdentifier} = {};`\n : `export type ${osdkObjectLinksIdentifier} = {};`\n }\n\n export namespace ${interfaceDef.shortApiName} {\n\n ${createPropertyKeys(interfaceDef)}\n\n\n ${createProps(interfaceDef, \"Props\", false, ontology.raw.valueTypes)}\n ${createProps(interfaceDef, \"StrictProps\", true, ontology.raw.valueTypes)}\n\n\n ${createObjectSet(interfaceDef, ids)}\n\n ${createOsdkObject(interfaceDef, \"OsdkInstance\", ids)}\n \n } \n\n ${createDefinition(interfaceDef, ontology, interfaceDef.shortApiName, ids)}\n\n`;\n }\n\n const imports: string = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n definition;\n return `${imports}\n ${v2 ? getV2Types(forInternalUse) : \"\"}\n\n export const ${interfaceDef.shortApiName} = {\n type: \"interface\",\n apiName: \"${interfaceDef.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"${definition.rid}\",\n },\n } satisfies ${interfaceDef.shortApiName} & { internalDoNotUseMetadata: { rid: string } } as ${interfaceDef.shortApiName};`;\n}\n/** @internal */\nexport function getInvalidInterfaceProperties(\n interfaceDef: EnhancedInterfaceType,\n definition: InterfaceMetadata,\n): string[] {\n if (interfaceDef.apiNamespace == null) {\n return [];\n }\n const unqualifiedPropNames = new Set(\n Object.keys(definition.properties)\n .map(apiName => extractNamespace(apiName))\n .filter(([namespace]) => namespace == null)\n .map(([, rootName]) => rootName),\n );\n\n // Find namespaced properties whose namespace matches the interface\n // AND whose root name conflicts with an un-namespaced property\n const badProperties = Object.keys(definition.properties).filter(apiName => {\n const [ns, rootName] = extractNamespace(apiName);\n return ns === interfaceDef.apiNamespace\n && unqualifiedPropNames.has(rootName);\n });\n\n return badProperties;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,cAAc,EACdC,wCAAwC,QACnC,4BAA4B;AACnC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,qBAAqB,QAAQ,6CAA6C;AAEnF,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAEhD,SACEC,gBAAgB,EAChBC,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,EAClBC,WAAW,QACN,yCAAyC;;AAEhD;AACA,OAAO,SAASC,mCAAmCA,CACjDC,YAAmC,EACnCC,QAAoC,EACpCC,EAAW,GAAG,KAAK,EACnBC,cAAuB,GAAG,KAAK,EAC/BC,eAAuB,GAAG,EAAE,EAC5B;EACA,MAAM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AC,KAAKA,QAAQ,CACnC,CAAC;;EAED;EACA;EACA,MAAMC,aAAa,GAAG/C,MAAM,CAACkB,IAAI,CAACvB,UAAU,CAACqB,UAAU,CAAC,CAAC4B,MAAM,CAAC3B,OAAO,IAAI;IACzE,MAAM,CAAC+B,EAAE,EAAEF,QAAQ,CAAC,GAAGnE,gBAAgB,CAACsC,OAAO,CAAC;IAChD,OAAO+B,EAAE,KAAK1D,YAAY,CAACoD,YAAY,IAClCC,oBAAoB,CAACM,GAAG,CAACH,QAAQ,CAAC;EACzC,CAAC,CAAC;EAEF,OAAOC,aAAa;AACtB","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { wireObjectTypeFullMetadataToSdkObjectMetadata } from "@osdk/generator-converters";
|
|
17
|
+
import { GeneratorError, wireObjectTypeFullMetadataToSdkObjectMetadata } from "@osdk/generator-converters";
|
|
18
18
|
import consola from "consola";
|
|
19
19
|
import { EnhancedInterfaceType } from "../GenerateContext/EnhancedInterfaceType.js";
|
|
20
20
|
import { EnhancedObjectType } from "../GenerateContext/EnhancedObjectType.js";
|
|
@@ -254,7 +254,11 @@ function getPropTypeOrValueTypeEnum(propertyDefinition, valueTypeMetadata) {
|
|
|
254
254
|
return defaultPropString;
|
|
255
255
|
}
|
|
256
256
|
if (valueType.constraints.length !== 1) {
|
|
257
|
-
throw new
|
|
257
|
+
throw new GeneratorError("Expected exactly one constraint for value type", {
|
|
258
|
+
valueTypeApiName: propertyDefinition.valueTypeApiName
|
|
259
|
+
}, {
|
|
260
|
+
constraintCount: valueType.constraints.length
|
|
261
|
+
});
|
|
258
262
|
}
|
|
259
263
|
let shouldWrapWithParentheses = false;
|
|
260
264
|
let constraint = valueType.constraints[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["wireObjectTypeFullMetadataToSdkObjectMetadata","consola","EnhancedInterfaceType","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","stringify","stringUnionFrom","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","forInternalUse","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","valueTypes","createObjectSet","createOsdkObject","createDefinition","fullApiName","primaryKeyApiName","primaryKeyType","rid","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","valueTypeMetadata","propertyMetadata","properties","undefined","*","propertyDefinition","_","metadata","remapStructType","getPropTypeOrValueTypeEnum","multiplicity","nullable","links","linkDefinition","targetType","requireInterfaceType","targetTypeApiName","getImportedDefinitionIdentifier","hasMainValue","mainValue","fields","hasReducers","extraParams","mainValueParam","JSON","hasReducersParam","Object","keys","key","linkTarget","sort","b","localeCompare","structType","output","entries","value","defaultPropString","valueTypeApiName","valueType","constraints","shouldWrapWithParentheses","constraint","valueConstraint","maybeEnumString","maybeGetEnumString","options","x","String","warn","filter","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.ts"],"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 */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport type {\n ObjectTypeFullMetadata,\n OntologyValueType,\n PropertyApiName,\n SharedPropertyTypeApiName,\n ValueTypeApiName,\n ValueTypeConstraint,\n} from \"@osdk/foundry.ontologies\";\nimport { wireObjectTypeFullMetadataToSdkObjectMetadata } from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { stringUnionFrom } from \"../util/stringUnionFrom.js\";\n\ntype PropertyApiNameUnion = PropertyApiName | SharedPropertyTypeApiName;\n\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(\n wireObject: ObjectTypeFullMetadata,\n { ontology, forInternalUse }: Pick<\n GenerateContext,\n \"ontology\" | \"forInternalUse\"\n >,\n currentFilePath: string,\n) {\n const object = ontology.requireObjectType(\n wireObject.objectType.apiName,\n true,\n );\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(\n wireObject.linkTypes.map(a =>\n ontology.requireObjectType(a.objectTypeApiName, false)\n ),\n );\n\n const definition = wireObjectTypeFullMetadataToSdkObjectMetadata(\n object.raw,\n true,\n consola,\n );\n\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n\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\n const identifiers: Identifiers = {\n objectDefIdentifier: object.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n function getV2Types(\n object: EnhancedObjectType,\n forInternalUse: boolean = false,\n ) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\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 \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false, ontology.raw.valueTypes)}\n ${createProps(object, \"StrictProps\", true, ontology.raw.valueTypes)}\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\n const imports = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n\n return `${imports}${getV2Types(object, forInternalUse)}\n\n export const ${object.shortApiName}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n primaryKeyApiName: \"${definition.primaryKeyApiName}\",\n primaryKeyType: \"${definition.primaryKeyType}\",\n internalDoNotUseMetadata: {\n rid: \"${definition.rid}\",\n },\n } satisfies ${objectDefIdentifier} & { internalDoNotUseMetadata: { rid: string } } as ${objectDefIdentifier};`;\n}\n\nexport interface Identifiers extends\n Record<\n | \"osdkObjectIdentifier\"\n | \"propertyKeysIdentifier\"\n | \"osdkObjectPropsIdentifier\"\n | \"objectDefIdentifier\"\n | \"osdkObjectLinksIdentifier\"\n | \"osdkObjectStrictPropsIdentifier\"\n | \"objectSetIdentifier\",\n string\n >\n{}\n\nexport function createOsdkObject(\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n {\n osdkObjectPropsIdentifier,\n objectDefIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$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 | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\n\nexport function createObjectSet(\n object: EnhancedObjectType | EnhancedInterfaceType,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n propertyKeysIdentifier,\n osdkObjectIdentifier,\n }: Identifiers,\n) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\n\nfunction maybeStripNamespace(\n type: EnhancedInterfaceType | EnhancedObjectType,\n q: string,\n) {\n if (\n type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)\n ) {\n return q.slice(type.apiNamespace.length + 1);\n } else {\n return q;\n }\n}\n\nexport function createProps(\n type: EnhancedInterfaceType | EnhancedObjectType,\n identifier: string,\n strict: boolean,\n valueTypeMetadata: Record<ValueTypeApiName, OntologyValueType>,\n): string {\n if (identifier === \"StrictProps\") {\n return `export type StrictProps = Props`;\n }\n const definition = type.getCleanedUpDefinition(true);\n const propertyMetadata = type instanceof EnhancedObjectType\n ? type.raw.objectType.properties\n : type instanceof EnhancedInterfaceType\n ? type.raw.properties\n : undefined;\n return `export interface ${identifier} {\n${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n const metadata = propertyMetadata\n ? (propertyMetadata as Record<PropertyApiNameUnion, any>)[apiName]\n : undefined;\n return [\n `${\n propertyJsdoc(propertyDefinition, metadata, {\n apiName,\n })\n }readonly \"${maybeStripNamespace(type, apiName)}\"`,\n (typeof propertyDefinition.type === \"object\"\n ? remapStructType(propertyDefinition.type)\n : getPropTypeOrValueTypeEnum(\n propertyDefinition,\n valueTypeMetadata,\n ))\n + `${propertyDefinition.multiplicity ? \"[]\" : \"\"}${\n propertyDefinition.nullable\n || (!strict\n && !(definition.type === \"object\"\n && definition.primaryKeyApiName === apiName))\n ? `| undefined`\n : \"\"\n }`,\n ] as [string, string];\n },\n })\n }\n }`;\n}\n\nexport function createDefinition(\n object: EnhancedObjectType | EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n identifier: string,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n const propertyMetadata = object instanceof EnhancedObjectType\n ? object.raw.objectType.properties\n : object instanceof EnhancedInterfaceType\n ? object.raw.properties\n : undefined;\n return `\n export interface ${identifier} extends ${\n object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`\n } {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";${\n object instanceof EnhancedObjectType && definition.type === \"object\"\n ? `\n primaryKeyApiName: \"${definition.primaryKeyApiName}\";\n primaryKeyType: \"${definition.primaryKeyType}\";`\n : \"\"\n }\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${\n stringify(definition, {\n links: (_value) =>\n `{\n ${\n definition.type === \"interface\"\n ? stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$InterfaceMetadata.Link<${\n linkDefinition.targetType === \"interface\"\n ? ontology.requireInterfaceType(\n linkDefinition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(true)\n : ontology.requireObjectType(\n linkDefinition.targetTypeApiName,\n ).getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n : stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$ObjectMetadata.Link<${\n ontology.requireObjectType(linkDefinition.targetType)\n .getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n }\n }`,\n properties: (_value) => (`{\n ${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n const hasMainValue = propertyDefinition.mainValue?.fields != null;\n const hasReducers = propertyDefinition.hasReducers === true;\n\n let extraParams = \"\";\n if (hasMainValue || hasReducers) {\n const mainValueParam = hasMainValue\n ? JSON.stringify(propertyDefinition.mainValue!.fields)\n : \"undefined\";\n const hasReducersParam = hasReducers ? \"true\" : \"false\";\n extraParams = `, ${mainValueParam}, ${hasReducersParam}`;\n }\n\n return [\n `${\n propertyJsdoc(\n propertyDefinition,\n (propertyMetadata as Record<PropertyApiNameUnion, any>)[\n apiName\n ],\n {\n apiName,\n },\n )\n }\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, \"${\n propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"\n }\", \"${\n propertyDefinition.multiplicity ? \"array\" : \"single\"\n }\"${extraParams}>`,\n ] as [string, string];\n },\n })\n }\n }`),\n })\n }\n } \n}\n `;\n}\n\nexport function createLinks(\n ontology: EnhancedOntologyDefinition,\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n) {\n const definition = object.getCleanedUpDefinition(true);\n\n return `\n ${\n Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${\n stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(\n definition.targetType,\n )\n .getImportedDefinitionIdentifier(true);\n\n return [\n `readonly ${key}`,\n `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `,\n ];\n },\n })\n }\n }\n `\n }`;\n}\n\nexport function createPropertyKeys(\n type: EnhancedObjectType | EnhancedInterfaceType,\n) {\n const properties = Object.keys(type.getCleanedUpDefinition(true).properties)\n .sort((a, b) => a.localeCompare(b));\n return `export type PropertyKeys = ${\n stringUnionFrom(\n properties.map((a) => maybeStripNamespace(type, a)),\n )\n };`;\n}\n\nfunction remapStructType(structType: Record<string, any>): string {\n let output = `{`;\n Object.entries(structType).sort(([a], [b]) => a.localeCompare(b)).map((\n [key, value],\n ) => output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;`);\n output += \"}\";\n return output;\n}\n\nfunction getPropTypeOrValueTypeEnum(\n propertyDefinition: ObjectMetadata.Property,\n valueTypeMetadata: Record<ValueTypeApiName, OntologyValueType>,\n): string {\n const defaultPropString = `$PropType[${\n JSON.stringify(propertyDefinition.type)\n }]`;\n if (\n !(propertyDefinition.type === \"string\"\n || propertyDefinition.type === \"boolean\")\n || !propertyDefinition.valueTypeApiName\n ) {\n return defaultPropString;\n }\n const valueType = valueTypeMetadata[propertyDefinition.valueTypeApiName];\n if (valueType == null || valueType.constraints.length === 0) {\n return defaultPropString;\n }\n if (valueType.constraints.length !== 1) {\n throw new Error(\n `Expected exactly one constraint for value type ${propertyDefinition.valueTypeApiName} but got ${valueType.constraints.length}`,\n );\n }\n\n let shouldWrapWithParentheses = false;\n let constraint = valueType.constraints[0];\n if (constraint.type === \"array\" && constraint.valueConstraint) {\n constraint = constraint.valueConstraint;\n shouldWrapWithParentheses = true;\n }\n\n const maybeEnumString = maybeGetEnumString(\n propertyDefinition,\n constraint,\n );\n\n return maybeEnumString\n ? (\n shouldWrapWithParentheses ? `(${maybeEnumString})` : maybeEnumString\n )\n : defaultPropString;\n}\n\nfunction maybeGetEnumString(\n propertyDefinition: ObjectMetadata.Property,\n constraint: ValueTypeConstraint,\n) {\n if (constraint.type !== \"enum\" || constraint.options.length === 0) {\n return undefined;\n }\n if (propertyDefinition.type === \"string\") {\n return stringUnionFrom(constraint.options.map(x => String(x)));\n }\n if (propertyDefinition.type === \"boolean\") {\n return constraint.options.map(value => {\n if (value === true) {\n return true;\n } else if (value === false) {\n return false;\n } else if (value == null) {\n // Always infer nullability from the property definition\n return undefined;\n } else {\n consola.warn(`Unexpected boolean value in enum: ${value}. Ignoring.`);\n }\n }).filter(value => value != null).join(\n \" | \",\n );\n }\n return undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASA,6CAA6C,QAAQ,4BAA4B;AAC1F,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,kBAAkB,QAAQ,0CAA0C;AAE7E,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,eAAe,QAAQ,4BAA4B;AAI5D;AACA,OAAO,SAASC,kCAAkCA,CAChDC,UAAkC,EAClC;EAAEC,QAAQ;EAAEC;AAGZ,CAAC,EACDC,eAAuB,EACvB;EACA,MAAMC,MAAM,GAAGH,QAAQ,CAACI,iBAAiB,CACvCL,UAAU,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ACzBxC,kBAA2C,EAC3CqC,UAA+B,EAC/B;EACA,IAAIA,UAAU,CAACjD,IAAI,KAAK,MAAM,IAAIiD,UAAU,CAACI,OAAO,CAAChD,MAAM,KAAK,CAAC,EAAE;IACjE,OAAOK,SAAS;EAClB;EACA,IAAIE,kBAAkB,CAACZ,IAAI,KAAK,QAAQ,EAAE;IACxC,OAAO5C,eAAe,CAAC6F,UAAU,CAACI,OAAO,CAACnF,GAAG,CAACoF,CAAC,IAAIC,MAAM,CAACD,CAAC,CAAC,CAAC,CAAC;EAChE;EACA,IAAI1C,kBAAkB,CAACZ,IAAI,KAAK,SAAS,EAAE;IACzC,OAAOiD,UAAU,CAACI,OAAO,CAACnF,GAAG,CAACyE,KAAK,IAAI;MACrC,IAAIA,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,IAAI;MACb,CAAC,MAAM,IAAIA,KAAK,KAAK,KAAK,EAAE;QAC1B,OAAO,KAAK;MACd,CAAC,MAAM,IAAIA,KAAK,IAAI,IAAI,EAAE;QACxB;QACA,OAAOjC,SAAS;MAClB,CAAC,MAAM;QACL7D,OAAO,CAAC2G,IAAI,CAAC,qCAAqCb,KAAK,aAAa,CAAC;MACvE;IACF,CAAC,CAAC,CAACc,MAAM,CAACd,KAAK,IAAIA,KAAK,IAAI,IAAI,CAAC,CAACe,IAAI,CACpC,KACF,CAAC;EACH;EACA,OAAOhD,SAAS;AAClB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"wireObjectTypeV2ToSdkObjectConstV2.js","names":["GeneratorError","wireObjectTypeFullMetadataToSdkObjectMetadata","consola","EnhancedInterfaceType","EnhancedObjectType","ForeignType","getObjectImports","propertyJsdoc","stringify","stringUnionFrom","wireObjectTypeV2ToSdkObjectConstV2","wireObject","ontology","forInternalUse","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","valueTypes","createObjectSet","createOsdkObject","createDefinition","fullApiName","primaryKeyApiName","primaryKeyType","rid","identifier","getCleanedUpDefinition","maybeStripNamespace","type","q","apiNamespace","startsWith","slice","length","strict","valueTypeMetadata","propertyMetadata","properties","undefined","*","propertyDefinition","_","metadata","remapStructType","getPropTypeOrValueTypeEnum","multiplicity","nullable","links","linkDefinition","targetType","requireInterfaceType","targetTypeApiName","getImportedDefinitionIdentifier","hasMainValue","mainValue","fields","hasReducers","extraParams","mainValueParam","JSON","hasReducersParam","Object","keys","key","linkTarget","sort","b","localeCompare","structType","output","entries","value","defaultPropString","valueTypeApiName","valueType","constraints","constraintCount","shouldWrapWithParentheses","constraint","valueConstraint","maybeEnumString","maybeGetEnumString","options","x","String","warn","filter","join"],"sources":["wireObjectTypeV2ToSdkObjectConstV2.ts"],"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 */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport type {\n ObjectTypeFullMetadata,\n OntologyValueType,\n PropertyApiName,\n SharedPropertyTypeApiName,\n ValueTypeApiName,\n ValueTypeConstraint,\n} from \"@osdk/foundry.ontologies\";\nimport {\n GeneratorError,\n wireObjectTypeFullMetadataToSdkObjectMetadata,\n} from \"@osdk/generator-converters\";\nimport consola from \"consola\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { EnhancedObjectType } from \"../GenerateContext/EnhancedObjectType.js\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { propertyJsdoc } from \"../shared/propertyJsdoc.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { stringUnionFrom } from \"../util/stringUnionFrom.js\";\n\ntype PropertyApiNameUnion = PropertyApiName | SharedPropertyTypeApiName;\n\n/** @internal */\nexport function wireObjectTypeV2ToSdkObjectConstV2(\n wireObject: ObjectTypeFullMetadata,\n { ontology, forInternalUse }: Pick<\n GenerateContext,\n \"ontology\" | \"forInternalUse\"\n >,\n currentFilePath: string,\n) {\n const object = ontology.requireObjectType(\n wireObject.objectType.apiName,\n true,\n );\n if (object instanceof ForeignType) {\n throw new Error(\"Should not be generating types for an external type\");\n }\n const uniqueLinkTargetTypes = new Set(\n wireObject.linkTypes.map(a =>\n ontology.requireObjectType(a.objectTypeApiName, false)\n ),\n );\n\n const definition = wireObjectTypeFullMetadataToSdkObjectMetadata(\n object.raw,\n true,\n consola,\n );\n\n const objectDefIdentifier = object.getDefinitionIdentifier(true);\n\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\n const identifiers: Identifiers = {\n objectDefIdentifier: object.shortApiName,\n osdkObjectLinksIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n objectSetIdentifier,\n osdkObjectIdentifier,\n propertyKeysIdentifier,\n };\n\n function getV2Types(\n object: EnhancedObjectType,\n forInternalUse: boolean = false,\n ) {\n return `import type {\n PropertyKeys as $PropertyKeys, \n ObjectTypeDefinition as $ObjectTypeDefinition,\n ObjectMetadata as $ObjectMetadata,\n } from \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\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 \"${forInternalUse ? \"@osdk/api\" : \"@osdk/client\"}\";\n\n\n export namespace ${object.shortApiName} {\n\n ${createPropertyKeys(object)}\n\n\n ${createLinks(ontology, object, \"Links\")}\n\n ${createProps(object, \"Props\", false, ontology.raw.valueTypes)}\n ${createProps(object, \"StrictProps\", true, ontology.raw.valueTypes)}\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\n const imports = getObjectImports(\n uniqueLinkTargetTypes,\n definition.apiName,\n currentFilePath,\n true,\n );\n\n return `${imports}${getV2Types(object, forInternalUse)}\n\n export const ${object.shortApiName}\n = {\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\",\n apiName: \"${object.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n primaryKeyApiName: \"${definition.primaryKeyApiName}\",\n primaryKeyType: \"${definition.primaryKeyType}\",\n internalDoNotUseMetadata: {\n rid: \"${definition.rid}\",\n },\n } satisfies ${objectDefIdentifier} & { internalDoNotUseMetadata: { rid: string } } as ${objectDefIdentifier};`;\n}\n\nexport interface Identifiers extends\n Record<\n | \"osdkObjectIdentifier\"\n | \"propertyKeysIdentifier\"\n | \"osdkObjectPropsIdentifier\"\n | \"objectDefIdentifier\"\n | \"osdkObjectLinksIdentifier\"\n | \"osdkObjectStrictPropsIdentifier\"\n | \"objectSetIdentifier\",\n string\n >\n{}\n\nexport function createOsdkObject(\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n {\n osdkObjectPropsIdentifier,\n objectDefIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n return `\n export type ${identifier}<\n OPTIONS extends never | \"$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 | \"$rid\" = never,\n K extends keyof ${osdkObjectPropsIdentifier}= keyof ${osdkObjectPropsIdentifier},\n > = ${identifier}<OPTIONS, K>;\n ;\n `;\n}\n\nexport function createObjectSet(\n object: EnhancedObjectType | EnhancedInterfaceType,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n propertyKeysIdentifier,\n osdkObjectIdentifier,\n }: Identifiers,\n) {\n return `\nexport interface ObjectSet extends \n$ObjectSet<${objectDefIdentifier},\n\n${objectSetIdentifier}\n>\n{\n\n}\n`;\n}\n\nfunction maybeStripNamespace(\n type: EnhancedInterfaceType | EnhancedObjectType,\n q: string,\n) {\n if (\n type.apiNamespace && q.startsWith(`${type.apiNamespace}.`)\n ) {\n return q.slice(type.apiNamespace.length + 1);\n } else {\n return q;\n }\n}\n\nexport function createProps(\n type: EnhancedInterfaceType | EnhancedObjectType,\n identifier: string,\n strict: boolean,\n valueTypeMetadata: Record<ValueTypeApiName, OntologyValueType>,\n): string {\n if (identifier === \"StrictProps\") {\n return `export type StrictProps = Props`;\n }\n const definition = type.getCleanedUpDefinition(true);\n const propertyMetadata = type instanceof EnhancedObjectType\n ? type.raw.objectType.properties\n : type instanceof EnhancedInterfaceType\n ? type.raw.properties\n : undefined;\n return `export interface ${identifier} {\n${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n const metadata = propertyMetadata\n ? (propertyMetadata as Record<PropertyApiNameUnion, any>)[apiName]\n : undefined;\n return [\n `${\n propertyJsdoc(propertyDefinition, metadata, {\n apiName,\n })\n }readonly \"${maybeStripNamespace(type, apiName)}\"`,\n (typeof propertyDefinition.type === \"object\"\n ? remapStructType(propertyDefinition.type)\n : getPropTypeOrValueTypeEnum(\n propertyDefinition,\n valueTypeMetadata,\n ))\n + `${propertyDefinition.multiplicity ? \"[]\" : \"\"}${\n propertyDefinition.nullable\n || (!strict\n && !(definition.type === \"object\"\n && definition.primaryKeyApiName === apiName))\n ? `| undefined`\n : \"\"\n }`,\n ] as [string, string];\n },\n })\n }\n }`;\n}\n\nexport function createDefinition(\n object: EnhancedObjectType | EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n identifier: string,\n {\n objectDefIdentifier,\n objectSetIdentifier,\n osdkObjectPropsIdentifier,\n osdkObjectStrictPropsIdentifier,\n osdkObjectLinksIdentifier,\n }: Identifiers,\n) {\n const definition = object.getCleanedUpDefinition(true);\n const propertyMetadata = object instanceof EnhancedObjectType\n ? object.raw.objectType.properties\n : object instanceof EnhancedInterfaceType\n ? object.raw.properties\n : undefined;\n return `\n export interface ${identifier} extends ${\n object instanceof EnhancedObjectType\n ? `$ObjectTypeDefinition`\n : `$InterfaceDefinition`\n } {\n osdkMetadata: typeof $osdkMetadata;\n type: \"${object instanceof EnhancedObjectType ? \"object\" : \"interface\"}\";\n apiName: \"${object.fullApiName}\";${\n object instanceof EnhancedObjectType && definition.type === \"object\"\n ? `\n primaryKeyApiName: \"${definition.primaryKeyApiName}\";\n primaryKeyType: \"${definition.primaryKeyType}\";`\n : \"\"\n }\n __DefinitionMetadata?: {\n objectSet: ${objectSetIdentifier};\n props: ${osdkObjectPropsIdentifier};\n linksType: ${osdkObjectLinksIdentifier};\n strictProps: ${osdkObjectStrictPropsIdentifier};\n ${\n stringify(definition, {\n links: (_value) =>\n `{\n ${\n definition.type === \"interface\"\n ? stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$InterfaceMetadata.Link<${\n linkDefinition.targetType === \"interface\"\n ? ontology.requireInterfaceType(\n linkDefinition.targetTypeApiName,\n )\n .getImportedDefinitionIdentifier(true)\n : ontology.requireObjectType(\n linkDefinition.targetTypeApiName,\n ).getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n : stringify(definition.links, {\n \"*\": (linkDefinition) =>\n `$ObjectMetadata.Link<${\n ontology.requireObjectType(linkDefinition.targetType)\n .getImportedDefinitionIdentifier(true)\n }, ${linkDefinition.multiplicity}>`,\n })\n }\n }`,\n properties: (_value) => (`{\n ${\n stringify(definition.properties, {\n \"*\": (propertyDefinition, _, apiName) => {\n const hasMainValue = propertyDefinition.mainValue?.fields != null;\n const hasReducers = propertyDefinition.hasReducers === true;\n\n let extraParams = \"\";\n if (hasMainValue || hasReducers) {\n const mainValueParam = hasMainValue\n ? JSON.stringify(propertyDefinition.mainValue!.fields)\n : \"undefined\";\n const hasReducersParam = hasReducers ? \"true\" : \"false\";\n extraParams = `, ${mainValueParam}, ${hasReducersParam}`;\n }\n\n return [\n `${\n propertyJsdoc(\n propertyDefinition,\n (propertyMetadata as Record<PropertyApiNameUnion, any>)[\n apiName\n ],\n {\n apiName,\n },\n )\n }\"${maybeStripNamespace(object, apiName)}\"`,\n `$PropertyDef<${JSON.stringify(propertyDefinition.type)}, \"${\n propertyDefinition.nullable ? \"nullable\" : \"non-nullable\"\n }\", \"${\n propertyDefinition.multiplicity ? \"array\" : \"single\"\n }\"${extraParams}>`,\n ] as [string, string];\n },\n })\n }\n }`),\n })\n }\n } \n}\n `;\n}\n\nexport function createLinks(\n ontology: EnhancedOntologyDefinition,\n object: EnhancedObjectType | EnhancedInterfaceType,\n identifier: string,\n) {\n const definition = object.getCleanedUpDefinition(true);\n\n return `\n ${\n Object.keys(definition.links).length === 0\n ? `export type ${identifier} = {};`\n : `\n export interface ${identifier} {\n${\n stringify(definition.links, {\n \"*\": (definition, _, key) => {\n const linkTarget = ontology.requireObjectType(\n definition.targetType,\n )\n .getImportedDefinitionIdentifier(true);\n\n return [\n `readonly ${key}`,\n `${\n definition.multiplicity\n ? `${linkTarget}.ObjectSet`\n : `$SingleLinkAccessor<${linkTarget}>`\n }\n `,\n ];\n },\n })\n }\n }\n `\n }`;\n}\n\nexport function createPropertyKeys(\n type: EnhancedObjectType | EnhancedInterfaceType,\n) {\n const properties = Object.keys(type.getCleanedUpDefinition(true).properties)\n .sort((a, b) => a.localeCompare(b));\n return `export type PropertyKeys = ${\n stringUnionFrom(\n properties.map((a) => maybeStripNamespace(type, a)),\n )\n };`;\n}\n\nfunction remapStructType(structType: Record<string, any>): string {\n let output = `{`;\n Object.entries(structType).sort(([a], [b]) => a.localeCompare(b)).map((\n [key, value],\n ) => output += `${key}:$PropType[${JSON.stringify(value)}]|undefined;`);\n output += \"}\";\n return output;\n}\n\nfunction getPropTypeOrValueTypeEnum(\n propertyDefinition: ObjectMetadata.Property,\n valueTypeMetadata: Record<ValueTypeApiName, OntologyValueType>,\n): string {\n const defaultPropString = `$PropType[${\n JSON.stringify(propertyDefinition.type)\n }]`;\n if (\n !(propertyDefinition.type === \"string\"\n || propertyDefinition.type === \"boolean\")\n || !propertyDefinition.valueTypeApiName\n ) {\n return defaultPropString;\n }\n const valueType = valueTypeMetadata[propertyDefinition.valueTypeApiName];\n if (valueType == null || valueType.constraints.length === 0) {\n return defaultPropString;\n }\n if (valueType.constraints.length !== 1) {\n throw new GeneratorError(\n \"Expected exactly one constraint for value type\",\n { valueTypeApiName: propertyDefinition.valueTypeApiName },\n { constraintCount: valueType.constraints.length },\n );\n }\n\n let shouldWrapWithParentheses = false;\n let constraint = valueType.constraints[0];\n if (constraint.type === \"array\" && constraint.valueConstraint) {\n constraint = constraint.valueConstraint;\n shouldWrapWithParentheses = true;\n }\n\n const maybeEnumString = maybeGetEnumString(\n propertyDefinition,\n constraint,\n );\n\n return maybeEnumString\n ? (\n shouldWrapWithParentheses ? `(${maybeEnumString})` : maybeEnumString\n )\n : defaultPropString;\n}\n\nfunction maybeGetEnumString(\n propertyDefinition: ObjectMetadata.Property,\n constraint: ValueTypeConstraint,\n) {\n if (constraint.type !== \"enum\" || constraint.options.length === 0) {\n return undefined;\n }\n if (propertyDefinition.type === \"string\") {\n return stringUnionFrom(constraint.options.map(x => String(x)));\n }\n if (propertyDefinition.type === \"boolean\") {\n return constraint.options.map(value => {\n if (value === true) {\n return true;\n } else if (value === false) {\n return false;\n } else if (value == null) {\n // Always infer nullability from the property definition\n return undefined;\n } else {\n consola.warn(`Unexpected boolean value in enum: ${value}. Ignoring.`);\n }\n }).filter(value => value != null).join(\n \" | \",\n );\n }\n return undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SACEA,cAAc,EACdC,6CAA6C,QACxC,4BAA4B;AACnC,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,kBAAkB,QAAQ,0CAA0C;AAE7E,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,eAAe,QAAQ,4BAA4B;AAI5D;AACA,OAAO,SAASC,kCAAkCA,CAChDC,UAAkC,EAClC;EAAEC,QAAQ;EAAEC;AAGZ,CAAC,EACDC,eAAuB,EACvB;EACA,MAAMC,MAAM,GAAGH,QAAQ,CAACI,iBAAiB,CACvCL,UAAU,CAACM,UAAU,CAACC,OAAO,EAC7B,IACF,CAAC;EACD,IAAIH,MAAM,YAAYV,WAAW,EAAE;IACjC,MAAM,IAAIc,KAAK,CAAC,qDAAqD,CAAC;EACxE;EACA,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CACnCV,UAAU,CAACW,SA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IACjE,OAAOK,SAAS;EAClB;EACA,IAAIE,kBAAkB,CAACZ,IAAI,KAAK,QAAQ,EAAE;IACxC,OAAO5C,eAAe,CAAC8F,UAAU,CAACI,OAAO,CAACpF,GAAG,CAACqF,CAAC,IAAIC,MAAM,CAACD,CAAC,CAAC,CAAC,CAAC;EAChE;EACA,IAAI3C,kBAAkB,CAACZ,IAAI,KAAK,SAAS,EAAE;IACzC,OAAOkD,UAAU,CAACI,OAAO,CAACpF,GAAG,CAACyE,KAAK,IAAI;MACrC,IAAIA,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,IAAI;MACb,CAAC,MAAM,IAAIA,KAAK,KAAK,KAAK,EAAE;QAC1B,OAAO,KAAK;MACd,CAAC,MAAM,IAAIA,KAAK,IAAI,IAAI,EAAE;QACxB;QACA,OAAOjC,SAAS;MAClB,CAAC,MAAM;QACL7D,OAAO,CAAC4G,IAAI,CAAC,qCAAqCd,KAAK,aAAa,CAAC;MACvE;IACF,CAAC,CAAC,CAACe,MAAM,CAACf,KAAK,IAAIA,KAAK,IAAI,IAAI,CAAC,CAACgB,IAAI,CACpC,KACF,CAAC;EACH;EACA,OAAOjD,SAAS;AAClB","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -219,7 +219,11 @@ var EnhancedOntologyDefinition = class {
|
|
|
219
219
|
const ret = this[type][fullApiName];
|
|
220
220
|
if (!ret) {
|
|
221
221
|
const [apiNamespace, shortApiName] = extractNamespace(fullApiName);
|
|
222
|
-
throw new
|
|
222
|
+
throw new generatorConverters.GeneratorError("Unable to find entity", {
|
|
223
|
+
fullApiName
|
|
224
|
+
}, {
|
|
225
|
+
entityType: type
|
|
226
|
+
});
|
|
223
227
|
}
|
|
224
228
|
return ret;
|
|
225
229
|
};
|
|
@@ -287,7 +291,7 @@ function formatTs(contents) {
|
|
|
287
291
|
}
|
|
288
292
|
|
|
289
293
|
// src/v2.0/generateMetadata.ts
|
|
290
|
-
var ExpectedOsdkVersion = "2.
|
|
294
|
+
var ExpectedOsdkVersion = "2.23.0";
|
|
291
295
|
async function generateOntologyMetadataFile({
|
|
292
296
|
fs: fs2,
|
|
293
297
|
outDir,
|
|
@@ -855,7 +859,11 @@ function getPropTypeOrValueTypeEnum(propertyDefinition, valueTypeMetadata) {
|
|
|
855
859
|
return defaultPropString;
|
|
856
860
|
}
|
|
857
861
|
if (valueType.constraints.length !== 1) {
|
|
858
|
-
throw new
|
|
862
|
+
throw new generatorConverters.GeneratorError("Expected exactly one constraint for value type", {
|
|
863
|
+
valueTypeApiName: propertyDefinition.valueTypeApiName
|
|
864
|
+
}, {
|
|
865
|
+
constraintCount: valueType.constraints.length
|
|
866
|
+
});
|
|
859
867
|
}
|
|
860
868
|
let shouldWrapWithParentheses = false;
|
|
861
869
|
let constraint = valueType.constraints[0];
|
|
@@ -935,8 +943,10 @@ function wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ontology, v2 = false,
|
|
|
935
943
|
};
|
|
936
944
|
const maybeBadProperties = getInvalidInterfaceProperties(interfaceDef, definition);
|
|
937
945
|
if (maybeBadProperties.length > 0) {
|
|
938
|
-
throw new
|
|
939
|
-
|
|
946
|
+
throw new generatorConverters.GeneratorError("Property name collision in interface: cannot have both an unqualified property and a namespaced property with matching root name when the namespace matches the interface.", {
|
|
947
|
+
interfaceApiName: interfaceDef.fullApiName,
|
|
948
|
+
collidingProperties: maybeBadProperties
|
|
949
|
+
});
|
|
940
950
|
}
|
|
941
951
|
function getV2Types(forInternalUse2 = false) {
|
|
942
952
|
return `import type {
|