@osdk/generator 2.7.0-beta.9 → 2.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +24 -7
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +38 -9
- package/build/browser/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +39 -10
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/browser/v2.0/generatePerActionDataFiles.js +12 -2
- package/build/browser/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/build/cjs/index.cjs +30 -9
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js +24 -7
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map +1 -1
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js +38 -9
- package/build/esm/v2.0/UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +39 -10
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/esm/v2.0/generatePerActionDataFiles.js +12 -2
- package/build/esm/v2.0/generatePerActionDataFiles.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
+
## 2.7.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @osdk/api@2.7.0-beta.14
|
|
8
|
+
- @osdk/generator-converters@2.7.0-beta.14
|
|
9
|
+
|
|
10
|
+
## 2.7.0-beta.13
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [fb83808]
|
|
15
|
+
- @osdk/api@2.7.0-beta.13
|
|
16
|
+
- @osdk/generator-converters@2.7.0-beta.13
|
|
17
|
+
|
|
18
|
+
## 2.7.0-beta.12
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [bb9d25c]
|
|
23
|
+
- @osdk/api@2.7.0-beta.12
|
|
24
|
+
- @osdk/generator-converters@2.7.0-beta.12
|
|
25
|
+
|
|
26
|
+
## 2.7.0-beta.11
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- 211cb0d: Add internalDoNotUseMetadata.rid to interfaces
|
|
31
|
+
- d5cfc38: Add null option to actions to allow clearing data
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [d5cfc38]
|
|
36
|
+
- @osdk/api@2.7.0-beta.11
|
|
37
|
+
- @osdk/generator-converters@2.7.0-beta.11
|
|
38
|
+
|
|
39
|
+
## 2.7.0-beta.10
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies [db44f6b]
|
|
44
|
+
- Updated dependencies [24a1e29]
|
|
45
|
+
- @osdk/api@2.7.0-beta.10
|
|
46
|
+
- @osdk/generator-converters@2.7.0-beta.10
|
|
47
|
+
|
|
3
48
|
## 2.7.0-beta.9
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
|
@@ -72,11 +72,10 @@ export function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(interfaceDef, ont
|
|
|
72
72
|
osdkObjectIdentifier,
|
|
73
73
|
propertyKeysIdentifier
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
75
|
+
const maybeBadProperties = getInvalidInterfaceProperties(interfaceDef, definition);
|
|
76
|
+
if (maybeBadProperties.length > 0) {
|
|
77
|
+
throw new Error(`Property name collision in interface "${interfaceDef.fullApiName}": ${maybeBadProperties.join(", ")}. +
|
|
78
|
+
Cannot have both an unqualified property and a namespaced property with matching root name when the namespace matches the interface.`);
|
|
80
79
|
}
|
|
81
80
|
const imports = getObjectImports(uniqueLinkTargetTypes, definition.apiName, currentFilePath, true);
|
|
82
81
|
return `${imports}
|
|
@@ -121,10 +120,28 @@ ${stringify(definition.links, {
|
|
|
121
120
|
`;
|
|
122
121
|
}(forInternalUse) : ""}
|
|
123
122
|
|
|
124
|
-
export const ${interfaceDef.shortApiName}
|
|
123
|
+
export const ${interfaceDef.shortApiName} = {
|
|
125
124
|
type: "interface",
|
|
126
125
|
apiName: "${interfaceDef.fullApiName}",
|
|
127
126
|
osdkMetadata: $osdkMetadata,
|
|
128
|
-
|
|
127
|
+
internalDoNotUseMetadata: {
|
|
128
|
+
rid: "${definition.rid}",
|
|
129
|
+
},
|
|
130
|
+
} satisfies ${interfaceDef.shortApiName} & { internalDoNotUseMetadata: { rid: string } } as ${interfaceDef.shortApiName};`;
|
|
131
|
+
}
|
|
132
|
+
/** @internal */
|
|
133
|
+
export function getInvalidInterfaceProperties(interfaceDef, definition) {
|
|
134
|
+
if (interfaceDef.apiNamespace == null) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
const unqualifiedPropNames = new Set(Object.keys(definition.properties).map(apiName => extractNamespace(apiName)).filter(([namespace]) => namespace == null).map(([, rootName]) => rootName));
|
|
138
|
+
|
|
139
|
+
// Find namespaced properties whose namespace matches the interface
|
|
140
|
+
// AND whose root name conflicts with an un-namespaced property
|
|
141
|
+
const badProperties = Object.keys(definition.properties).filter(apiName => {
|
|
142
|
+
const [ns, rootName] = extractNamespace(apiName);
|
|
143
|
+
return ns === interfaceDef.apiNamespace && unqualifiedPropNames.has(rootName);
|
|
144
|
+
});
|
|
145
|
+
return badProperties;
|
|
129
146
|
}
|
|
130
147
|
//# sourceMappingURL=UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js","names":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","consola","fastDeepEqual","invariant","extractNamespace","EnhancedInterfaceType","getObjectImports","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","__UNSTABLE_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","apiNamespace","badProperties","filter","length","Error","fullApiName","join","imports","linkTarget","getImportedDefinitionIdentifier","multiplicity","valueTypes"],"sources":["UNSTABLE_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 { __UNSTABLE_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 __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n interfaceDef: EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n v2: boolean = false,\n forInternalUse: boolean = false,\n currentFilePath: string = \"\",\n) {\n const definition = deleteUndefineds(\n __UNSTABLE_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 __UNSTABLE_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 if (interfaceDef.apiNamespace) {\n const badProperties = Object.keys(definition.properties).filter(apiName =>\n extractNamespace(apiName)[0] == null\n );\n if (badProperties.length > 0) {\n throw new Error(\n `Interfaces with fully qualified api names MUST NOT have any properties with an unqualified api name. Interface: ${interfaceDef.fullApiName}, properties: ${\n badProperties.join(\", \")\n }`,\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 } 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 : `${linkTarget}.ObjectSet`\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}: ${interfaceDef.shortApiName} = {\n type: \"interface\",\n apiName: \"${interfaceDef.fullApiName}\",\n osdkMetadata: $osdkMetadata,\n };`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,mDAAmD,QAAQ,4BAA4B;AAChG,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,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,YAAY,CAAC6C,WAAW;AAC1C;AACA,UAAU;AACV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js","names":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","consola","fastDeepEqual","invariant","extractNamespace","EnhancedInterfaceType","getObjectImports","deleteUndefineds","stringify","createDefinition","createObjectSet","createOsdkObject","createPropertyKeys","createProps","__UNSTABLE_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":["UNSTABLE_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 { __UNSTABLE_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 __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n interfaceDef: EnhancedInterfaceType,\n ontology: EnhancedOntologyDefinition,\n v2: boolean = false,\n forInternalUse: boolean = false,\n currentFilePath: string = \"\",\n) {\n const definition = deleteUndefineds(\n __UNSTABLE_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 __UNSTABLE_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 } 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 : `${linkTarget}.ObjectSet`\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,mDAAmD,QAAQ,4BAA4B;AAChG,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,8CAA8CA,CAC5DC,YAAmC,EACnCC,QAAoC,EACpCC,EAAW,GAAG,KAAK,EACnBC,cAAuB,GAAG,KAAK,EAC/BC,eAAuB,GAAG,EAAE,EAC5B;EACA,MAAMC,UAAU,GAAGb,gBAAgB,CACjCP,mDAAmD,CACjDe,YAAY,CAACM,GAAG,EAChBJ,EACF,CACF,CAAC;EACD,MAAMK,qBAAqB,GAAG,IAAIC,GAAG,CACnCH,UAAU,CAACI,KAAK,GACZC,MAAM,CAACC,MAAM,CAACN,UAAU,CAACI,KAAK,CAAC,CAACG,GAAG,CAACC,CAAC,IACrCA,CAAC,CAACC,UAAU,KAAK,QAAQ,GACrBb,QAAQ,CAACc,iBAAiB,CAC1BF,CAAC,CAACG,iBACJ,CAAC,GACCf,QAAQ,CAACg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aAAa;AACtB","ignoreList":[]}
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from "@osdk/generator-converters";
|
|
17
18
|
import { format } from "prettier";
|
|
18
19
|
import { describe, expect, it } from "vitest";
|
|
19
20
|
import { EnhancedInterfaceType } from "../GenerateContext/EnhancedInterfaceType.js";
|
|
20
21
|
import { enhanceOntology } from "../GenerateContext/enhanceOntology.js";
|
|
21
22
|
import { ForeignType } from "../GenerateContext/ForeignType.js";
|
|
22
|
-
import {
|
|
23
|
+
import { deleteUndefineds } from "../util/deleteUndefineds.js";
|
|
24
|
+
import { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, getInvalidInterfaceProperties } from "./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js";
|
|
23
25
|
function simpleSpt(apiName, metadataLevel = 2) {
|
|
24
26
|
return {
|
|
25
27
|
apiName,
|
|
@@ -148,11 +150,14 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
|
|
|
148
150
|
};
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
export const Bar
|
|
153
|
+
export const Bar = {
|
|
152
154
|
type: "interface",
|
|
153
155
|
apiName: "Bar",
|
|
154
156
|
osdkMetadata: $osdkMetadata,
|
|
155
|
-
|
|
157
|
+
internalDoNotUseMetadata: {
|
|
158
|
+
rid: "BarRid",
|
|
159
|
+
},
|
|
160
|
+
} satisfies Bar & { internalDoNotUseMetadata: { rid: string } } as Bar;
|
|
156
161
|
"
|
|
157
162
|
`);
|
|
158
163
|
});
|
|
@@ -232,11 +237,14 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
|
|
|
232
237
|
};
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
export const Foo
|
|
240
|
+
export const Foo = {
|
|
236
241
|
type: "interface",
|
|
237
242
|
apiName: "Foo",
|
|
238
243
|
osdkMetadata: $osdkMetadata,
|
|
239
|
-
|
|
244
|
+
internalDoNotUseMetadata: {
|
|
245
|
+
rid: "FooRid",
|
|
246
|
+
},
|
|
247
|
+
} satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
|
|
240
248
|
"
|
|
241
249
|
`);
|
|
242
250
|
});
|
|
@@ -328,11 +336,14 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
|
|
|
328
336
|
};
|
|
329
337
|
}
|
|
330
338
|
|
|
331
|
-
export const Foo
|
|
339
|
+
export const Foo = {
|
|
332
340
|
type: "interface",
|
|
333
341
|
apiName: "Foo",
|
|
334
342
|
osdkMetadata: $osdkMetadata,
|
|
335
|
-
|
|
343
|
+
internalDoNotUseMetadata: {
|
|
344
|
+
rid: "FooRid",
|
|
345
|
+
},
|
|
346
|
+
} satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
|
|
336
347
|
"
|
|
337
348
|
`);
|
|
338
349
|
});
|
|
@@ -412,11 +423,14 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
|
|
|
412
423
|
};
|
|
413
424
|
}
|
|
414
425
|
|
|
415
|
-
export const Foo
|
|
426
|
+
export const Foo = {
|
|
416
427
|
type: "interface",
|
|
417
428
|
apiName: "Foo",
|
|
418
429
|
osdkMetadata: $osdkMetadata,
|
|
419
|
-
|
|
430
|
+
internalDoNotUseMetadata: {
|
|
431
|
+
rid: "FooRid",
|
|
432
|
+
},
|
|
433
|
+
} satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;
|
|
420
434
|
"
|
|
421
435
|
`);
|
|
422
436
|
});
|
|
@@ -439,5 +453,20 @@ describe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {
|
|
|
439
453
|
expect(implementsStr).toContain("\"ParentA\", \"ParentC\", \"ParentZ\"");
|
|
440
454
|
}
|
|
441
455
|
});
|
|
456
|
+
it("correctly identifies invalid properties", async () => {
|
|
457
|
+
const ontology = enhanceOntology({
|
|
458
|
+
sanitized: simpleOntology("ontology", [simpleInterface("Child", [simpleSpt("child")], []), simpleInterface("com.A.myChild", [simpleSpt("son"), simpleSpt("com.B.son"), simpleSpt("com.A.daughter")], []), simpleInterface("com.A.myChildNo", [simpleSpt("son"), simpleSpt("com.A.son"), simpleSpt("com.B.daughter")], [])]),
|
|
459
|
+
importExt: ""
|
|
460
|
+
});
|
|
461
|
+
const interfaceDefNoNamespace = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes.Child.raw, false));
|
|
462
|
+
const interfaceDefWithNamespaceOk = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes["com.A.myChild"].raw, false));
|
|
463
|
+
const interfaceDefWithNamespaceNotOk = deleteUndefineds(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(ontology.interfaceTypes["com.A.myChildNo"].raw, false));
|
|
464
|
+
const noBadProperties = getInvalidInterfaceProperties(ontology.interfaceTypes.Child, interfaceDefNoNamespace);
|
|
465
|
+
expect(noBadProperties.length).toBe(0);
|
|
466
|
+
const noBadProperties2 = getInvalidInterfaceProperties(ontology.interfaceTypes["com.A.myChild"], interfaceDefWithNamespaceOk);
|
|
467
|
+
expect(noBadProperties2.length).toBe(0);
|
|
468
|
+
const badProperties = getInvalidInterfaceProperties(ontology.interfaceTypes["com.A.myChildNo"], interfaceDefWithNamespaceNotOk);
|
|
469
|
+
expect(badProperties.length).toBe(1);
|
|
470
|
+
});
|
|
442
471
|
});
|
|
443
472
|
//# sourceMappingURL=UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js","names":["format","describe","expect","it","EnhancedInterfaceType","enhanceOntology","ForeignType","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","simpleSpt","apiName","metadataLevel","dataType","type","rid","displayName","description","undefined","simpleInterface","spts","parents","implementedByObjectTypes","properties","Object","fromEntries","map","spt","required","extendsInterfaces","links","propertiesV2","allExtendsInterfaces","allLinks","allProperties","allPropertiesV2","simpleOntology","interfaces","interfaceTypes","i","sharedPropertyTypes","flatMap","entries","actionTypes","objectTypes","ontology","queryTypes","valueTypes","sanitized","importExt","Bar","toBe","Error","formattedCode","parser","printWidth","toMatchInlineSnapshot","fooSpt","barSpt","Foo","Child","implementsMatch","match","not","toBeNull","implementsStr","toContain"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.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 {\n InterfaceType,\n SharedPropertyType,\n} from \"@osdk/foundry.ontologies\";\nimport { format } from \"prettier\";\nimport { describe, expect, it } from \"vitest\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport type { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst } from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\n\nfunction simpleSpt<T extends string>(apiName: T, metadataLevel: 0 | 1 | 2 = 2) {\n return {\n apiName,\n dataType: {\n type: \"integer\",\n },\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} property dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} property desc` : undefined,\n } as const satisfies SharedPropertyType;\n}\n\nfunction simpleInterface<T extends string, Q extends SharedPropertyType>(\n apiName: T,\n spts: Q[],\n parents: string[],\n metadataLevel: 0 | 1 | 2 = 2,\n implementedByObjectTypes: string[] = [],\n) {\n const properties = Object.fromEntries(\n spts.map(spt => [spt.apiName, { ...spt, required: true }]),\n );\n\n return {\n apiName,\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} interface dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} interface desc` : undefined,\n extendsInterfaces: parents,\n links: {},\n properties,\n propertiesV2: {},\n implementedByObjectTypes,\n allExtendsInterfaces: parents,\n allLinks: {},\n allProperties: properties,\n allPropertiesV2: {},\n } as const satisfies InterfaceType;\n}\n\nfunction simpleOntology<I extends InterfaceType>(\n apiName: string,\n interfaces: I[],\n) {\n const interfaceTypes: Record<I[\"apiName\"], I> = Object\n .fromEntries(\n interfaces.map(i => [i.apiName, i]),\n ) as Record<string, I>;\n\n const sharedPropertyTypes: Record<string, I[\"properties\"][string]> = Object\n .fromEntries(\n interfaces.flatMap(i => Object.entries(i.properties)),\n ) as Record<string, I[\"properties\"][string]>;\n\n return {\n actionTypes: {},\n interfaceTypes,\n objectTypes: {},\n ontology: {\n apiName,\n description: `${apiName} ontology desc`,\n displayName: `${apiName} ontology dn`,\n rid: `${apiName} ontology rid`,\n },\n queryTypes: {},\n sharedPropertyTypes,\n valueTypes: {},\n } as const satisfies WireOntologyDefinition;\n}\n\ndescribe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {\n it(\"Does not say (inherited) on properties locally defined\", async () => {\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Bar\", [simpleSpt(\"bar\", 0)], [], 0),\n ]),\n importExt: \"\",\n });\n\n expect(ontology.interfaceTypes.Bar instanceof EnhancedInterfaceType).toBe(\n true,\n );\n\n // type guard for below\n if (ontology.interfaceTypes.Bar instanceof ForeignType) {\n throw new Error(\"Expected Bar to be an EnhancedInterfaceType\");\n }\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Bar,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n printWidth: 100,\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Bar = {};\n\n export namespace Bar {\n export type PropertyKeys = \"bar\";\n\n export interface Props {\n /**\n * (no ontology metadata)\n */\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = $Osdk.Instance<Bar, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Bar extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Bar\";\n __DefinitionMetadata?: {\n objectSet: Bar.ObjectSet;\n props: Bar.Props;\n linksType: OsdkObjectLinks$Bar;\n strictProps: Bar.StrictProps;\n apiName: \"Bar\";\n description: undefined;\n displayName: \"Bar\";\n implementedBy: [];\n implements: [];\n links: {};\n properties: {\n /**\n * (no ontology metadata)\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"BarRid\";\n type: \"interface\";\n };\n }\n\n export const Bar: Bar = {\n type: \"interface\",\n apiName: \"Bar\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n\n it(\"Generates properties for inherited SPTs\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n\n it(\"allows for SPT reuse if the same\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt, barSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\" | \"bar\";\n\n export interface Props {\n /**\n * display name: 'bar property dn',\n *\n * description: bar property desc\n */\n readonly bar: $PropType[\"integer\"] | undefined;\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'bar property dn',\n *\n * description: bar property desc\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n it(\"Generates map for implementedBy\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"], 2, [\"childrenObject\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [\"childrenObject\"];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo: Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n\n it(\"sorts the implements array for stable output\", async () => {\n // Test with multiple parent interfaces in non-alphabetical order\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Child\", [simpleSpt(\"child\")], [\n \"ParentZ\",\n \"ParentA\",\n \"ParentC\",\n ]),\n simpleInterface(\"ParentZ\", [simpleSpt(\"z\")], []),\n simpleInterface(\"ParentA\", [simpleSpt(\"a\")], []),\n simpleInterface(\"ParentC\", [simpleSpt(\"c\")], []),\n ]),\n importExt: \"\",\n });\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Child as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n\n // Extract the implements array from the generated code\n const implementsMatch = formattedCode.match(/implements:\\s*\\[([^\\]]+)\\]/s);\n expect(implementsMatch).not.toBeNull();\n\n if (implementsMatch) {\n const implementsStr = implementsMatch[1];\n // Check that the array is sorted alphabetically\n expect(implementsStr).toContain(\"\\\"ParentA\\\", \\\"ParentC\\\", \\\"ParentZ\\\"\");\n }\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,WAAW,QAAQ,mCAAmC;AAE/D,SAASC,8CAA8C,QAAQ,mDAAmD;AAElH,SAASC,SAASA,CAAmBC,OAAU,EAAEC,aAAwB,GAAG,CAAC,EAAE;EAC7E,OAAO;IACLD,OAAO;IACPE,QAAQ,EAAE;MACRC,IAAI,EAAE;IACR,CAAC;IACDC,GAAG,EAAE,GAAGJ,OAAO,KAAK;IACpBK,WAAW,EAAEJ,aAAa,IAAI,CAAC,GAAG,GAAGD,OAAO,cAAc,GAAGA,OAAO;IACpEM,WAAW,EAAEL,aAAa,IAAI,CAAC,GAAG,GAAGD,OAAO,gBAAgB,GAAGO;EACjE,CAAC;AACH;AAEA,SAASC,eAAeA,CACtBR,OAAU,EACVS,IAAS,EACTC,OAAiB,EACjBT,aAAwB,GAAG,CAAC,EAC5BU,wBAAkC,GAAG,EAAE,EACvC;EACA,MAAMC,UAAU,GAAGC,MAAM,CAACC,WAAW,CACnCL,I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C,eAAe,CAC9B;MACEyC,SAAS,EAAEZ,cAAc,CAAC,UAAU,EAAE,CACpCjB,eAAe,CAAC,KAAK,EAAE,CAACsC,MAAM,EAAEC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EACpDvC,eAAe,CAAC,QAAQ,EAAE,CAACuC,MAAM,CAAC,EAAE,EAAE,CAAC,CACxC,CAAC;MACFT,SAAS,EAAE;IACb,CACF,CAAC;IAED,MAAMI,aAAa,GAAG,MAAMnD,MAAM,CAChCO,8CAA8C,CAC5CoC,QAAQ,CAACP,cAAc,CAACqB,GAAG,EAC3Bd,QAAQ,EACR,IAAI,EACJ,IACF,CAAC,EACD;MACES,MAAM,EAAE;IACV,CACF,CAAC;IACDlD,MAAM,CAACiD,aAAa,CAAC,CAACG,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EACFnD,EAAE,CAAC,iCAAiC,EAAE,YAAY;IAChD,MAAMoD,MAAM,GAAG/C,SAAS,CAAC,KAAK,CAAC;IAC/B,MAAMgD,MAAM,GAAGhD,SAAS,CAAC,KAAK,CAAC;IAE/B,MAAMmC,QAAQ,GAAGtC,eAAe,CAC9B;MACEyC,SAAS,EAAEZ,cAAc,CAAC,UAAU,EAAE,CACpCjB,eAAe,CAAC,KAAK,EAAE,CAACsC,MAAM,CAAC,EA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e,CAAC,SAAS,EAAE,CAACT,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CACjD,CAAC;MACFuC,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMI,aAAa,GAAG,MAAMnD,MAAM,CAChCO,8CAA8C,CAC5CoC,QAAQ,CAACP,cAAc,CAACsB,KAAK,EAC7Bf,QAAQ,EACR,IAAI,EACJ,IACF,CAAC,EACD;MACES,MAAM,EAAE;IACV,CACF,CAAC;;IAED;IACA,MAAMO,eAAe,GAAGR,aAAa,CAACS,KAAK,CAAC,6BAA6B,CAAC;IAC1E1D,MAAM,CAACyD,eAAe,CAAC,CAACE,GAAG,CAACC,QAAQ,CAAC,CAAC;IAEtC,IAAIH,eAAe,EAAE;MACnB,MAAMI,aAAa,GAAGJ,eAAe,CAAC,CAAC,CAAC;MACxC;MACAzD,MAAM,CAAC6D,aAAa,CAAC,CAACC,SAAS,CAAC,uCAAuC,CAAC;IAC1E;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.js","names":["__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","format","describe","expect","it","EnhancedInterfaceType","enhanceOntology","ForeignType","deleteUndefineds","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst","getInvalidInterfaceProperties","simpleSpt","apiName","metadataLevel","dataType","type","rid","displayName","description","undefined","simpleInterface","spts","parents","implementedByObjectTypes","properties","Object","fromEntries","map","spt","required","extendsInterfaces","links","propertiesV2","allExtendsInterfaces","allLinks","allProperties","allPropertiesV2","simpleOntology","interfaces","interfaceTypes","i","sharedPropertyTypes","flatMap","entries","actionTypes","objectTypes","ontology","queryTypes","valueTypes","sanitized","importExt","Bar","toBe","Error","formattedCode","parser","printWidth","toMatchInlineSnapshot","fooSpt","barSpt","Foo","Child","implementsMatch","match","not","toBeNull","implementsStr","toContain","interfaceDefNoNamespace","raw","interfaceDefWithNamespaceOk","interfaceDefWithNamespaceNotOk","noBadProperties","length","noBadProperties2","badProperties"],"sources":["UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.test.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 {\n InterfaceType,\n SharedPropertyType,\n} from \"@osdk/foundry.ontologies\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nimport { format } from \"prettier\";\nimport { describe, expect, it } from \"vitest\";\nimport { EnhancedInterfaceType } from \"../GenerateContext/EnhancedInterfaceType.js\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { ForeignType } from \"../GenerateContext/ForeignType.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport type { WireOntologyDefinition } from \"../WireOntologyDefinition.js\";\nimport {\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst,\n getInvalidInterfaceProperties,\n} from \"./UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst.js\";\n\nfunction simpleSpt<T extends string>(apiName: T, metadataLevel: 0 | 1 | 2 = 2) {\n return {\n apiName,\n dataType: {\n type: \"integer\",\n },\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} property dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} property desc` : undefined,\n } as const satisfies SharedPropertyType;\n}\n\nfunction simpleInterface<T extends string, Q extends SharedPropertyType>(\n apiName: T,\n spts: Q[],\n parents: string[],\n metadataLevel: 0 | 1 | 2 = 2,\n implementedByObjectTypes: string[] = [],\n) {\n const properties = Object.fromEntries(\n spts.map(spt => [spt.apiName, { ...spt, required: true }]),\n );\n\n return {\n apiName,\n rid: `${apiName}Rid`,\n displayName: metadataLevel >= 1 ? `${apiName} interface dn` : apiName,\n description: metadataLevel >= 2 ? `${apiName} interface desc` : undefined,\n extendsInterfaces: parents,\n links: {},\n properties,\n propertiesV2: {},\n implementedByObjectTypes,\n allExtendsInterfaces: parents,\n allLinks: {},\n allProperties: properties,\n allPropertiesV2: {},\n } as const satisfies InterfaceType;\n}\n\nfunction simpleOntology<I extends InterfaceType>(\n apiName: string,\n interfaces: I[],\n) {\n const interfaceTypes: Record<I[\"apiName\"], I> = Object\n .fromEntries(\n interfaces.map(i => [i.apiName, i]),\n ) as Record<string, I>;\n\n const sharedPropertyTypes: Record<string, I[\"properties\"][string]> = Object\n .fromEntries(\n interfaces.flatMap(i => Object.entries(i.properties)),\n ) as Record<string, I[\"properties\"][string]>;\n\n return {\n actionTypes: {},\n interfaceTypes,\n objectTypes: {},\n ontology: {\n apiName,\n description: `${apiName} ontology desc`,\n displayName: `${apiName} ontology dn`,\n rid: `${apiName} ontology rid`,\n },\n queryTypes: {},\n sharedPropertyTypes,\n valueTypes: {},\n } as const satisfies WireOntologyDefinition;\n}\n\ndescribe(__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst, () => {\n it(\"Does not say (inherited) on properties locally defined\", async () => {\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Bar\", [simpleSpt(\"bar\", 0)], [], 0),\n ]),\n importExt: \"\",\n });\n\n expect(ontology.interfaceTypes.Bar instanceof EnhancedInterfaceType).toBe(\n true,\n );\n\n // type guard for below\n if (ontology.interfaceTypes.Bar instanceof ForeignType) {\n throw new Error(\"Expected Bar to be an EnhancedInterfaceType\");\n }\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Bar,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n printWidth: 100,\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Bar = {};\n\n export namespace Bar {\n export type PropertyKeys = \"bar\";\n\n export interface Props {\n /**\n * (no ontology metadata)\n */\n readonly bar: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Bar, Bar.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = $Osdk.Instance<Bar, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Bar.Props = keyof Bar.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Bar extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Bar\";\n __DefinitionMetadata?: {\n objectSet: Bar.ObjectSet;\n props: Bar.Props;\n linksType: OsdkObjectLinks$Bar;\n strictProps: Bar.StrictProps;\n apiName: \"Bar\";\n description: undefined;\n displayName: \"Bar\";\n implementedBy: [];\n implements: [];\n links: {};\n properties: {\n /**\n * (no ontology metadata)\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"BarRid\";\n type: \"interface\";\n };\n }\n\n export const Bar = {\n type: \"interface\",\n apiName: \"Bar\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"BarRid\",\n },\n } satisfies Bar & { internalDoNotUseMetadata: { rid: string } } as Bar;\n \"\n `);\n });\n\n it(\"Generates properties for inherited SPTs\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"FooRid\",\n },\n } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;\n \"\n `);\n });\n\n it(\"allows for SPT reuse if the same\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt, barSpt], [\"Parent\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\" | \"bar\";\n\n export interface Props {\n /**\n * display name: 'bar property dn',\n *\n * description: bar property desc\n */\n readonly bar: $PropType[\"integer\"] | undefined;\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'bar property dn',\n *\n * description: bar property desc\n */\n bar: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"FooRid\",\n },\n } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;\n \"\n `);\n });\n it(\"Generates map for implementedBy\", async () => {\n const fooSpt = simpleSpt(\"foo\");\n const barSpt = simpleSpt(\"bar\");\n\n const ontology = enhanceOntology(\n {\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Foo\", [fooSpt], [\"Parent\"], 2, [\"childrenObject\"]),\n simpleInterface(\"Parent\", [barSpt], []),\n ]),\n\n importExt: \"\",\n },\n );\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Foo as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n expect(formattedCode).toMatchInlineSnapshot(`\n \"import type {\n InterfaceDefinition as $InterfaceDefinition,\n InterfaceMetadata as $InterfaceMetadata,\n ObjectSet as $ObjectSet,\n Osdk as $Osdk,\n PropertyValueWireToClient as $PropType,\n } from \"@osdk/api\";\n\n export type OsdkObjectLinks$Foo = {};\n\n export namespace Foo {\n export type PropertyKeys = \"foo\";\n\n export interface Props {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n readonly foo: $PropType[\"integer\"] | undefined;\n }\n export type StrictProps = Props;\n\n export interface ObjectSet extends $ObjectSet<Foo, Foo.ObjectSet> {}\n\n export type OsdkInstance<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = $Osdk.Instance<Foo, OPTIONS, K>;\n\n /** @deprecated use OsdkInstance */\n export type OsdkObject<\n OPTIONS extends never | \"$rid\" = never,\n K extends keyof Foo.Props = keyof Foo.Props,\n > = OsdkInstance<OPTIONS, K>;\n }\n\n export interface Foo extends $InterfaceDefinition {\n osdkMetadata: typeof $osdkMetadata;\n type: \"interface\";\n apiName: \"Foo\";\n __DefinitionMetadata?: {\n objectSet: Foo.ObjectSet;\n props: Foo.Props;\n linksType: OsdkObjectLinks$Foo;\n strictProps: Foo.StrictProps;\n apiName: \"Foo\";\n description: \"Foo interface desc\";\n displayName: \"Foo interface dn\";\n implementedBy: [\"childrenObject\"];\n implements: [\"Parent\"];\n links: {};\n properties: {\n /**\n * display name: 'foo property dn',\n *\n * description: foo property desc\n */\n foo: $PropertyDef<\"integer\", \"nullable\", \"single\">;\n };\n rid: \"FooRid\";\n type: \"interface\";\n };\n }\n\n export const Foo = {\n type: \"interface\",\n apiName: \"Foo\",\n osdkMetadata: $osdkMetadata,\n internalDoNotUseMetadata: {\n rid: \"FooRid\",\n },\n } satisfies Foo & { internalDoNotUseMetadata: { rid: string } } as Foo;\n \"\n `);\n });\n\n it(\"sorts the implements array for stable output\", async () => {\n // Test with multiple parent interfaces in non-alphabetical order\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Child\", [simpleSpt(\"child\")], [\n \"ParentZ\",\n \"ParentA\",\n \"ParentC\",\n ]),\n simpleInterface(\"ParentZ\", [simpleSpt(\"z\")], []),\n simpleInterface(\"ParentA\", [simpleSpt(\"a\")], []),\n simpleInterface(\"ParentC\", [simpleSpt(\"c\")], []),\n ]),\n importExt: \"\",\n });\n\n const formattedCode = await format(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(\n ontology.interfaceTypes.Child as EnhancedInterfaceType,\n ontology,\n true,\n true,\n ),\n {\n parser: \"typescript\",\n },\n );\n\n // Extract the implements array from the generated code\n const implementsMatch = formattedCode.match(/implements:\\s*\\[([^\\]]+)\\]/s);\n expect(implementsMatch).not.toBeNull();\n\n if (implementsMatch) {\n const implementsStr = implementsMatch[1];\n // Check that the array is sorted alphabetically\n expect(implementsStr).toContain(\"\\\"ParentA\\\", \\\"ParentC\\\", \\\"ParentZ\\\"\");\n }\n });\n it(\"correctly identifies invalid properties\", async () => {\n const ontology = enhanceOntology({\n sanitized: simpleOntology(\"ontology\", [\n simpleInterface(\"Child\", [simpleSpt(\"child\")], []),\n simpleInterface(\"com.A.myChild\", [\n simpleSpt(\"son\"),\n simpleSpt(\"com.B.son\"),\n simpleSpt(\"com.A.daughter\"),\n ], []),\n simpleInterface(\"com.A.myChildNo\", [\n simpleSpt(\"son\"),\n simpleSpt(\"com.A.son\"),\n simpleSpt(\"com.B.daughter\"),\n ], []),\n ]),\n importExt: \"\",\n });\n\n const interfaceDefNoNamespace = deleteUndefineds(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(\n (ontology.interfaceTypes.Child as EnhancedInterfaceType).raw,\n false,\n ),\n );\n\n const interfaceDefWithNamespaceOk = deleteUndefineds(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(\n (ontology.interfaceTypes[\"com.A.myChild\"] as EnhancedInterfaceType).raw,\n false,\n ),\n );\n\n const interfaceDefWithNamespaceNotOk = deleteUndefineds(\n __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(\n (ontology.interfaceTypes[\"com.A.myChildNo\"] as EnhancedInterfaceType)\n .raw,\n false,\n ),\n );\n\n const noBadProperties = getInvalidInterfaceProperties(\n ontology.interfaceTypes.Child as EnhancedInterfaceType,\n interfaceDefNoNamespace,\n );\n\n expect(noBadProperties.length).toBe(0);\n\n const noBadProperties2 = getInvalidInterfaceProperties(\n ontology.interfaceTypes[\"com.A.myChild\"] as EnhancedInterfaceType,\n interfaceDefWithNamespaceOk,\n );\n\n expect(noBadProperties2.length).toBe(0);\n\n const badProperties = getInvalidInterfaceProperties(\n ontology.interfaceTypes[\"com.A.myChildNo\"] as EnhancedInterfaceType,\n interfaceDefWithNamespaceNotOk,\n );\n\n expect(badProperties.length).toBe(1);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,mDAAmD,QAAQ,4BAA4B;AAChG,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ,6CAA6C;AACnF,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,WAAW,QAAQ,mCAAmC;AAC/D,SAASC,gBAAgB,QAAQ,6BAA6B;AAE9D,SACEC,8CAA8C,EAC9CC,6BAA6B,QACxB,mDAAmD;AAE1D,SAASC,SAASA,CAAmBC,OAAU,EAAEC,aAAwB,GAAG,CAAC,EAAE;EAC7E,OAAO;IACLD,OAAO;IACPE,QAAQ,EAAE;MACRC,IAAI,EAAE;IACR,CAAC;IACDC,GAAG,EAAE,GAAGJ,OAAO,KAAK;IACpBK,WAAW,EAAEJ,aAAa,IAAI,CAAC,GAAG,GAAGD,OAAO,cAAc,GAAGA,OAAO;IACpEM,WAAW,EAAEL,aAAa,IAAI,CAAC,GAAG,GAAGD,OAAO,gBAAgB,GAAGO;EACjE,CAAC;AACH;AAEA,SAASC,eAAeA,CACtBR,OAAU,EACVS,IAAS,EACTC,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFrD,EAAE,CAAC,yCAAyC,EAAE,YAAY;IACxD,MAAMsD,MAAM,GAAG/C,SAAS,CAAC,KAAK,CAAC;IAC/B,MAAMgD,MAAM,GAAGhD,SAAS,CAAC,KAAK,CAAC;IAE/B,MAAMmC,QAAQ,GAAGxC,eAAe,CAC9B;MACE2C,SAAS,EAAEZ,cAAc,CAAC,UAAU,EAAE,CACpCjB,eAAe,CAAC,KAAK,EAAE,CAACsC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAC5CtC,eAAe,CAAC,QAAQ,EAAE,CAACuC,MAAM,CAAC,EAAE,EAAE,CAAC,CACxC,CAAC;MAEFT,SAAS,EAAE;IACb,CACF,CAAC;IAED,MAAMI,aAAa,GAAG,MAAMrD,MAAM,CAChCQ,8CAA8C,CAC5CqC,QAAQ,CAACP,cAAc,CAACqB,GAAG,EAC3Bd,QAAQ,EACR,IAAI,EACJ,IACF,CAAC,EACD;MACES,MAAM,EAAE;IACV,CACF,CAAC;IACDpD,MAAM,CAACmD,aAAa,CAAC,CAACG,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EAEFrD,EAAE,CAAC,kCAAkC,EAAE,YAAY;IACjD,MAAMsD,MAAM,GAAG/C,SAAS,CAAC,KAAK,CAAC;IAC/B,MAAMgD,MAAM,GAAGhD,SAAS,CAAC,KAAK,CAAC;IAE/B,MAAMmC,QAAQ,GAAGxC,eAAe,CAC9B;MACE2C,SAAS,EAAEZ,cAAc,CAAC,UAAU,EAAE,CACpCjB,eAAe,CAAC,KAAK,EAAE,CAACsC,MAAM,EAAEC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EACpDvC,eAAe,CAAC,QAAQ,EAAE,CAACuC,MAAM,CAAC,EAAE,EAAE,CAAC,CACxC,CAAC;MACFT,SAAS,EAAE;IACb,CACF,CAAC;IAED,MAAMI,aAAa,GAAG,MAAMrD,MAAM,CAChCQ,8CAA8C,CAC5CqC,QAAQ,CAACP,cAAc,CAACqB,GAAG,EAC3Bd,QAAQ,EACR,IAAI,EACJ,IACF,CAAC,EACD;MACES,MAAM,EAAE;IACV,CACF,CAAC;IACDpD,MAAM,CAACmD,aAAa,CAAC,CAACG,qBAAqB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EACFrD,EAAE,CAAC,iCAAiC,EAAE,YAAY;IAChD,MAAMsD,MAAM,GAAG/C,SAAS,CAAC,KAAK,CAAC;IAC/B,MAAMgD,MAAM,GAAGhD,S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477
|
*/
|
|
478
|
-
readonly object?: ReadonlyArray<ActionParam.ObjectType<Todo
|
|
478
|
+
readonly object?: ReadonlyArray<ActionParam.ObjectType<Todo>> | null;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
// Represents a fqn of the action
|
|
@@ -497,6 +497,11 @@ describe("generator", () => {
|
|
|
497
497
|
|
|
498
498
|
/**
|
|
499
499
|
* An action which takes in an array of objects
|
|
500
|
+
*
|
|
501
|
+
* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined
|
|
502
|
+
* can change the behavior of the applied action. If prefills are configured, null prevents them
|
|
503
|
+
* from being applied. If a parameter modifies an object's property, null will clear the data from
|
|
504
|
+
* the object, whereas undefined would not modify that property._
|
|
500
505
|
* @param {ActionParam.ObjectType<Todo>} [object] Todo(s) to be deleted
|
|
501
506
|
*/
|
|
502
507
|
export interface deleteTodos extends ActionDefinition<deleteTodos.Signatures> {
|
|
@@ -551,7 +556,7 @@ describe("generator", () => {
|
|
|
551
556
|
/**
|
|
552
557
|
* A Todo to mark completed
|
|
553
558
|
*/
|
|
554
|
-
readonly object?: ActionParam.ObjectType<Todo
|
|
559
|
+
readonly object?: ActionParam.ObjectType<Todo> | null;
|
|
555
560
|
}
|
|
556
561
|
|
|
557
562
|
// Represents a fqn of the action
|
|
@@ -573,6 +578,11 @@ describe("generator", () => {
|
|
|
573
578
|
|
|
574
579
|
/**
|
|
575
580
|
* An action which takes different types of parameters
|
|
581
|
+
*
|
|
582
|
+
* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined
|
|
583
|
+
* can change the behavior of the applied action. If prefills are configured, null prevents them
|
|
584
|
+
* from being applied. If a parameter modifies an object's property, null will clear the data from
|
|
585
|
+
* the object, whereas undefined would not modify that property._
|
|
576
586
|
* @param {ActionParam.ObjectType<Todo>} [object] A Todo to mark completed
|
|
577
587
|
*/
|
|
578
588
|
export interface markTodoCompleted extends ActionDefinition<markTodoCompleted.Signatures> {
|
|
@@ -673,11 +683,14 @@ describe("generator", () => {
|
|
|
673
683
|
};
|
|
674
684
|
}
|
|
675
685
|
|
|
676
|
-
export const SomeInterface
|
|
686
|
+
export const SomeInterface = {
|
|
677
687
|
type: 'interface',
|
|
678
688
|
apiName: 'SomeInterface',
|
|
679
689
|
osdkMetadata: $osdkMetadata,
|
|
680
|
-
|
|
690
|
+
internalDoNotUseMetadata: {
|
|
691
|
+
rid: 'idk',
|
|
692
|
+
},
|
|
693
|
+
} satisfies SomeInterface & { internalDoNotUseMetadata: { rid: string } } as SomeInterface;
|
|
681
694
|
",
|
|
682
695
|
"/foo/ontology/objects.ts": "export { Person } from './objects/Person.js';
|
|
683
696
|
export { Todo } from './objects/Todo.js';
|
|
@@ -1100,7 +1113,7 @@ describe("generator", () => {
|
|
|
1100
1113
|
/**
|
|
1101
1114
|
* Todo(s) to be deleted
|
|
1102
1115
|
*/
|
|
1103
|
-
readonly object?: ReadonlyArray<ActionParam.ObjectType<Todo
|
|
1116
|
+
readonly object?: ReadonlyArray<ActionParam.ObjectType<Todo>> | null;
|
|
1104
1117
|
}
|
|
1105
1118
|
|
|
1106
1119
|
// Represents a fqn of the action
|
|
@@ -1122,6 +1135,11 @@ describe("generator", () => {
|
|
|
1122
1135
|
|
|
1123
1136
|
/**
|
|
1124
1137
|
* An action which takes in an array of objects
|
|
1138
|
+
*
|
|
1139
|
+
* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined
|
|
1140
|
+
* can change the behavior of the applied action. If prefills are configured, null prevents them
|
|
1141
|
+
* from being applied. If a parameter modifies an object's property, null will clear the data from
|
|
1142
|
+
* the object, whereas undefined would not modify that property._
|
|
1125
1143
|
* @param {ActionParam.ObjectType<Todo>} [object] Todo(s) to be deleted
|
|
1126
1144
|
*/
|
|
1127
1145
|
export interface deleteTodos extends ActionDefinition<deleteTodos.Signatures> {
|
|
@@ -1176,7 +1194,7 @@ describe("generator", () => {
|
|
|
1176
1194
|
/**
|
|
1177
1195
|
* A Todo to mark completed
|
|
1178
1196
|
*/
|
|
1179
|
-
readonly object?: ActionParam.ObjectType<Todo
|
|
1197
|
+
readonly object?: ActionParam.ObjectType<Todo> | null;
|
|
1180
1198
|
}
|
|
1181
1199
|
|
|
1182
1200
|
// Represents a fqn of the action
|
|
@@ -1198,6 +1216,11 @@ describe("generator", () => {
|
|
|
1198
1216
|
|
|
1199
1217
|
/**
|
|
1200
1218
|
* An action which takes different types of parameters
|
|
1219
|
+
*
|
|
1220
|
+
* **Note on null values:** _For optional parameters, explicitly providing a null value instead of undefined
|
|
1221
|
+
* can change the behavior of the applied action. If prefills are configured, null prevents them
|
|
1222
|
+
* from being applied. If a parameter modifies an object's property, null will clear the data from
|
|
1223
|
+
* the object, whereas undefined would not modify that property._
|
|
1201
1224
|
* @param {ActionParam.ObjectType<Todo>} [object] A Todo to mark completed
|
|
1202
1225
|
*/
|
|
1203
1226
|
export interface markTodoCompleted extends ActionDefinition<markTodoCompleted.Signatures> {
|
|
@@ -1298,11 +1321,14 @@ describe("generator", () => {
|
|
|
1298
1321
|
};
|
|
1299
1322
|
}
|
|
1300
1323
|
|
|
1301
|
-
export const SomeInterface
|
|
1324
|
+
export const SomeInterface = {
|
|
1302
1325
|
type: 'interface',
|
|
1303
1326
|
apiName: 'foo.bar.SomeInterface',
|
|
1304
1327
|
osdkMetadata: $osdkMetadata,
|
|
1305
|
-
|
|
1328
|
+
internalDoNotUseMetadata: {
|
|
1329
|
+
rid: 'idk',
|
|
1330
|
+
},
|
|
1331
|
+
} satisfies SomeInterface & { internalDoNotUseMetadata: { rid: string } } as SomeInterface;
|
|
1306
1332
|
",
|
|
1307
1333
|
"/foo/ontology/objects.ts": "export { Person } from './objects/Person.js';
|
|
1308
1334
|
export { Todo } from './objects/Todo.js';
|
|
@@ -2452,11 +2478,14 @@ describe("generator", () => {
|
|
|
2452
2478
|
};
|
|
2453
2479
|
}
|
|
2454
2480
|
|
|
2455
|
-
export const SomeInterface
|
|
2481
|
+
export const SomeInterface = {
|
|
2456
2482
|
type: 'interface',
|
|
2457
2483
|
apiName: 'com.example.dep.SomeInterface',
|
|
2458
2484
|
osdkMetadata: $osdkMetadata,
|
|
2459
|
-
|
|
2485
|
+
internalDoNotUseMetadata: {
|
|
2486
|
+
rid: 'idk2',
|
|
2487
|
+
},
|
|
2488
|
+
} satisfies SomeInterface & { internalDoNotUseMetadata: { rid: string } } as SomeInterface;
|
|
2460
2489
|
",
|
|
2461
2490
|
"/foo/ontology/objects.ts": "export { Task } from './objects/Task.js';
|
|
2462
2491
|
",
|