@osdk/maker-import 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/bin/maker-import.mjs +6 -0
  2. package/build/browser/cli/main.js +47 -0
  3. package/build/browser/cli/main.js.map +1 -0
  4. package/build/browser/generate/convertActionType.js +63 -0
  5. package/build/browser/generate/convertActionType.js.map +1 -0
  6. package/build/browser/generate/convertInterfaceType.js +74 -0
  7. package/build/browser/generate/convertInterfaceType.js.map +1 -0
  8. package/build/browser/generate/convertObjectType.js +64 -0
  9. package/build/browser/generate/convertObjectType.js.map +1 -0
  10. package/build/browser/generate/convertSharedPropertyType.js +37 -0
  11. package/build/browser/generate/convertSharedPropertyType.js.map +1 -0
  12. package/build/browser/generate/mapActionParameterType.js +211 -0
  13. package/build/browser/generate/mapActionParameterType.js.map +1 -0
  14. package/build/browser/generate/mapPropertyType.js +117 -0
  15. package/build/browser/generate/mapPropertyType.js.map +1 -0
  16. package/build/browser/generate/utils.js +52 -0
  17. package/build/browser/generate/utils.js.map +1 -0
  18. package/build/browser/generate/writeImportedOntology.js +169 -0
  19. package/build/browser/generate/writeImportedOntology.js.map +1 -0
  20. package/build/browser/index.js +19 -0
  21. package/build/browser/index.js.map +1 -0
  22. package/build/cjs/index.cjs +601 -0
  23. package/build/cjs/index.cjs.map +1 -0
  24. package/build/cjs/index.d.cts +88 -0
  25. package/build/esm/cli/main.js +47 -0
  26. package/build/esm/cli/main.js.map +1 -0
  27. package/build/esm/generate/convertActionType.js +63 -0
  28. package/build/esm/generate/convertActionType.js.map +1 -0
  29. package/build/esm/generate/convertInterfaceType.js +74 -0
  30. package/build/esm/generate/convertInterfaceType.js.map +1 -0
  31. package/build/esm/generate/convertObjectType.js +64 -0
  32. package/build/esm/generate/convertObjectType.js.map +1 -0
  33. package/build/esm/generate/convertSharedPropertyType.js +37 -0
  34. package/build/esm/generate/convertSharedPropertyType.js.map +1 -0
  35. package/build/esm/generate/mapActionParameterType.js +211 -0
  36. package/build/esm/generate/mapActionParameterType.js.map +1 -0
  37. package/build/esm/generate/mapPropertyType.js +117 -0
  38. package/build/esm/generate/mapPropertyType.js.map +1 -0
  39. package/build/esm/generate/utils.js +52 -0
  40. package/build/esm/generate/utils.js.map +1 -0
  41. package/build/esm/generate/writeImportedOntology.js +169 -0
  42. package/build/esm/generate/writeImportedOntology.js.map +1 -0
  43. package/build/esm/index.js +19 -0
  44. package/build/esm/index.js.map +1 -0
  45. package/package.json +73 -0
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+
4
+ import cli from "../build/esm/index.js";
5
+
6
+ cli();
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { consola } from "consola";
18
+ import * as fs from "node:fs/promises";
19
+ import * as path from "node:path";
20
+ import yargs from "yargs";
21
+ import { hideBin } from "yargs/helpers";
22
+ import { writeImportedOntology } from "../generate/writeImportedOntology.js";
23
+ export default async function main(args = process.argv) {
24
+ const commandLineOpts = await yargs(hideBin(args)).version("0.1.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
25
+ input: {
26
+ alias: "i",
27
+ describe: "Path to OntologyFullMetadata JSON file",
28
+ type: "string",
29
+ demandOption: true,
30
+ coerce: path.resolve
31
+ },
32
+ output: {
33
+ alias: "o",
34
+ describe: "Output directory for generated TypeScript files",
35
+ type: "string",
36
+ default: "./generated-imports",
37
+ coerce: path.resolve
38
+ }
39
+ }).parseAsync();
40
+ consola.info(`Reading OntologyFullMetadata from ${commandLineOpts.input}`);
41
+ const jsonContent = await fs.readFile(commandLineOpts.input, "utf-8");
42
+ const metadata = JSON.parse(jsonContent);
43
+ consola.info(`Writing generated imports to ${commandLineOpts.output}`);
44
+ writeImportedOntology(metadata, commandLineOpts.output);
45
+ consola.success(`Generated import files in ${commandLineOpts.output}`);
46
+ }
47
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["consola","fs","path","yargs","hideBin","writeImportedOntology","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","demandOption","coerce","resolve","output","default","parseAsync","info","jsonContent","readFile","metadata","JSON","parse","success"],"sources":["main.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { writeImportedOntology } from \"../generate/writeImportedOntology.js\";\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Path to OntologyFullMetadata JSON file\",\n type: \"string\",\n demandOption: true,\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output directory for generated TypeScript files\",\n type: \"string\",\n default: \"./generated-imports\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n\n consola.info(`Reading OntologyFullMetadata from ${commandLineOpts.input}`);\n\n const jsonContent = await fs.readFile(commandLineOpts.input, \"utf-8\");\n const metadata = JSON.parse(jsonContent);\n\n consola.info(`Writing generated imports to ${commandLineOpts.output}`);\n\n writeImportedOntology(metadata, commandLineOpts.output);\n\n consola.success(`Generated import files in ${commandLineOpts.output}`);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,qBAAqB,QAAQ,sCAAsC;AAE5E,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eAAe,GAAG,MAAMP,KAAK,CAACC,OAAO,CAACG,IAAI,CAAC,CAAC,CAC/CI,OAAO,CAAC,WAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEX,KAAK,CAAC,CAAC,CAACY,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5CC,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,OAAO,CAAC;IACPC,KAAK,EAAE;MACLC,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,wCAAwC;MAClDC,IAAI,EAAE,QAAQ;MACdC,YAAY,EAAE,IAAI;MAClBC,MAAM,EAAEtB,IAAI,CAACuB;IACf,CAAC;IACDC,MAAM,EAAE;MACNN,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,iDAAiD;MAC3DC,IAAI,EAAE,QAAQ;MACdK,OAAO,EAAE,qBAAqB;MAC9BH,MAAM,EAAEtB,IAAI,CAACuB;IACf;EACF,CAAC,CAAC,CACDG,UAAU,CAAC,CAAC;EAEf5B,OAAO,CAAC6B,IAAI,CAAC,qCAAqCnB,eAAe,CAACS,KAAK,EAAE,CAAC;EAE1E,MAAMW,WAAW,GAAG,MAAM7B,EAAE,CAAC8B,QAAQ,CAACrB,eAAe,CAACS,KAAK,EAAE,OAAO,CAAC;EACrE,MAAMa,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACJ,WAAW,CAAC;EAExC9B,OAAO,CAAC6B,IAAI,CAAC,gCAAgCnB,eAAe,CAACgB,MAAM,EAAE,CAAC;EAEtErB,qBAAqB,CAAC2B,QAAQ,EAAEtB,eAAe,CAACgB,MAAM,CAAC;EAEvD1B,OAAO,CAACmC,OAAO,CAAC,6BAA6BzB,eAAe,CAACgB,MAAM,EAAE,CAAC;AACxE","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { OntologyEntityTypeEnum } from "@osdk/maker";
18
+ import { consola } from "consola";
19
+ import { mapActionParameterType } from "./mapActionParameterType.js";
20
+ import { withoutNamespace } from "./utils.js";
21
+
22
+ // Structural type matching maker's ActionParameter (ActionParameterType is not exported)
23
+
24
+ // Structural type matching maker's ActionType
25
+
26
+ export function convertActionType(action) {
27
+ const parameters = [];
28
+ for (const [paramId, paramV2] of Object.entries(action.parameters)) {
29
+ const mappedType = mapActionParameterType(paramV2.dataType);
30
+ if (!mappedType) {
31
+ consola.warn(`Skipping parameter "${paramId}" on action "${action.apiName}": unsupported type "${paramV2.dataType.type}"`);
32
+ continue;
33
+ }
34
+ parameters.push({
35
+ id: paramId,
36
+ displayName: paramV2.displayName ?? paramId,
37
+ type: mappedType,
38
+ validation: {
39
+ required: paramV2.required
40
+ }
41
+ });
42
+ }
43
+ const shortName = withoutNamespace(action.apiName);
44
+ return {
45
+ __type: OntologyEntityTypeEnum.ACTION_TYPE,
46
+ apiName: action.apiName,
47
+ displayName: action.displayName ?? shortName,
48
+ status: mapActionStatus(action.status),
49
+ rules: [],
50
+ parameters
51
+ };
52
+ }
53
+ function mapActionStatus(status) {
54
+ switch (status) {
55
+ case "ACTIVE":
56
+ return "active";
57
+ case "EXPERIMENTAL":
58
+ return "experimental";
59
+ default:
60
+ return "active";
61
+ }
62
+ }
63
+ //# sourceMappingURL=convertActionType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertActionType.js","names":["OntologyEntityTypeEnum","consola","mapActionParameterType","withoutNamespace","convertActionType","action","parameters","paramId","paramV2","Object","entries","mappedType","dataType","warn","apiName","type","push","id","displayName","validation","required","shortName","__type","ACTION_TYPE","status","mapActionStatus","rules"],"sources":["convertActionType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { mapActionParameterType } from \"./mapActionParameterType.js\";\nimport { withoutNamespace } from \"./utils.js\";\n\ninterface GatewayActionTypeV2 {\n apiName: string;\n displayName?: string;\n description?: string;\n status: string;\n parameters: Record<\n string,\n {\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n required: boolean;\n }\n >;\n operations: Array<{ type: string; [key: string]: unknown }>;\n}\n\n// Structural type matching maker's ActionParameter (ActionParameterType is not exported)\ninterface ConvertedActionParameter {\n id: string;\n displayName: string;\n type: string | { type: string; [key: string]: unknown };\n validation: { required?: boolean };\n}\n\n// Structural type matching maker's ActionType\ninterface ConvertedActionType {\n __type: OntologyEntityTypeEnum.ACTION_TYPE;\n apiName: string;\n displayName: string;\n status: string;\n rules: Array<unknown>;\n parameters: Array<ConvertedActionParameter>;\n}\n\nexport function convertActionType(\n action: GatewayActionTypeV2,\n): ConvertedActionType {\n const parameters: Array<ConvertedActionParameter> = [];\n\n for (const [paramId, paramV2] of Object.entries(action.parameters)) {\n const mappedType = mapActionParameterType(paramV2.dataType);\n if (!mappedType) {\n consola.warn(\n `Skipping parameter \"${paramId}\" on action \"${action.apiName}\": unsupported type \"${paramV2.dataType.type}\"`,\n );\n continue;\n }\n\n parameters.push({\n id: paramId,\n displayName: paramV2.displayName ?? paramId,\n type: mappedType,\n validation: {\n required: paramV2.required,\n },\n });\n }\n\n const shortName = withoutNamespace(action.apiName);\n\n return {\n __type: OntologyEntityTypeEnum.ACTION_TYPE,\n apiName: action.apiName,\n displayName: action.displayName ?? shortName,\n status: mapActionStatus(action.status),\n rules: [],\n parameters,\n };\n}\n\nfunction mapActionStatus(\n status: string,\n): \"active\" | \"experimental\" | \"example\" {\n switch (status) {\n case \"ACTIVE\":\n return \"active\";\n case \"EXPERIMENTAL\":\n return \"experimental\";\n default:\n return \"active\";\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,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1,74 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { OntologyEntityTypeEnum } from "@osdk/maker";
18
+ import { convertSharedPropertyType } from "./convertSharedPropertyType.js";
19
+ import { withoutNamespace } from "./utils.js";
20
+ /**
21
+ * Converts a gateway InterfaceType to a maker InterfaceType.
22
+ *
23
+ * `allInterfaces` is the full map so we can resolve extendsInterfaces references.
24
+ */
25
+ export function convertInterfaceType(iface, allInterfaces) {
26
+ const shortName = withoutNamespace(iface.apiName);
27
+
28
+ // Convert properties to propertiesV2 (SharedPropertyType-based)
29
+ const propertiesV2 = {};
30
+ const propertiesV3 = {};
31
+ for (const [sptApiName, sptDef] of Object.entries(iface.properties)) {
32
+ const converted = convertSharedPropertyType({
33
+ apiName: sptApiName,
34
+ displayName: sptDef.displayName,
35
+ description: sptDef.description,
36
+ dataType: sptDef.dataType
37
+ });
38
+ if (converted) {
39
+ const entry = {
40
+ sharedPropertyType: converted,
41
+ required: true
42
+ };
43
+ propertiesV2[sptApiName] = entry;
44
+ propertiesV3[withoutNamespace(sptApiName)] = entry;
45
+ }
46
+ }
47
+
48
+ // Resolve extendsInterfaces — recursively convert referenced interfaces
49
+ const extendsInterfaces = [];
50
+ for (const extApiName of iface.extendsInterfaces) {
51
+ const extIface = allInterfaces[extApiName];
52
+ if (extIface) {
53
+ extendsInterfaces.push(convertInterfaceType(extIface, allInterfaces));
54
+ }
55
+ }
56
+ return {
57
+ __type: OntologyEntityTypeEnum.INTERFACE_TYPE,
58
+ apiName: iface.apiName,
59
+ displayMetadata: {
60
+ displayName: iface.displayName ?? shortName,
61
+ description: iface.description ?? shortName
62
+ },
63
+ extendsInterfaces,
64
+ links: [],
65
+ status: {
66
+ type: "active",
67
+ active: {}
68
+ },
69
+ propertiesV2,
70
+ propertiesV3,
71
+ searchable: true
72
+ };
73
+ }
74
+ //# sourceMappingURL=convertInterfaceType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertInterfaceType.js","names":["OntologyEntityTypeEnum","convertSharedPropertyType","withoutNamespace","convertInterfaceType","iface","allInterfaces","shortName","apiName","propertiesV2","propertiesV3","sptApiName","sptDef","Object","entries","properties","converted","displayName","description","dataType","entry","sharedPropertyType","required","extendsInterfaces","extApiName","extIface","push","__type","INTERFACE_TYPE","displayMetadata","links","status","type","active","searchable"],"sources":["convertInterfaceType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { InterfaceType, SharedPropertyType } from \"@osdk/maker\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { convertSharedPropertyType } from \"./convertSharedPropertyType.js\";\nimport { withoutNamespace } from \"./utils.js\";\n\ninterface GatewayInterfaceType {\n apiName: string;\n displayName?: string;\n description?: string;\n extendsInterfaces: ReadonlyArray<string>;\n properties: Record<\n string,\n {\n apiName: string;\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n }\n >;\n links: Record<\n string,\n {\n apiName: string;\n displayName?: string;\n description?: string;\n cardinality: string;\n required: boolean;\n linkedEntityApiName: { type: string; apiName?: string };\n }\n >;\n}\n\n/**\n * Converts a gateway InterfaceType to a maker InterfaceType.\n *\n * `allInterfaces` is the full map so we can resolve extendsInterfaces references.\n */\nexport function convertInterfaceType(\n iface: GatewayInterfaceType,\n allInterfaces: Record<string, GatewayInterfaceType>,\n): InterfaceType {\n const shortName = withoutNamespace(iface.apiName);\n\n // Convert properties to propertiesV2 (SharedPropertyType-based)\n const propertiesV2: Record<\n string,\n { sharedPropertyType: SharedPropertyType; required: boolean }\n > = {};\n const propertiesV3: Record<\n string,\n { sharedPropertyType: SharedPropertyType; required: boolean }\n > = {};\n\n for (const [sptApiName, sptDef] of Object.entries(iface.properties)) {\n const converted = convertSharedPropertyType({\n apiName: sptApiName,\n displayName: sptDef.displayName,\n description: sptDef.description,\n dataType: sptDef.dataType,\n });\n if (converted) {\n const entry = { sharedPropertyType: converted, required: true };\n propertiesV2[sptApiName] = entry;\n propertiesV3[withoutNamespace(sptApiName)] = entry;\n }\n }\n\n // Resolve extendsInterfaces — recursively convert referenced interfaces\n const extendsInterfaces: Array<InterfaceType> = [];\n for (const extApiName of iface.extendsInterfaces) {\n const extIface = allInterfaces[extApiName];\n if (extIface) {\n extendsInterfaces.push(convertInterfaceType(extIface, allInterfaces));\n }\n }\n\n return {\n __type: OntologyEntityTypeEnum.INTERFACE_TYPE,\n apiName: iface.apiName,\n displayMetadata: {\n displayName: iface.displayName ?? shortName,\n description: iface.description ?? shortName,\n },\n extendsInterfaces,\n links: [],\n status: { type: \"active\", active: {} },\n propertiesV2,\n propertiesV3,\n searchable: true,\n } as unknown as InterfaceType;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1E,SAASC,gBAAgB,QAAQ,YAAY;AA6B7C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,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CAAC;IACDgB,iBAAiB;IACjBO,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;IACtCxB,YAAY;IACZC,YAAY;IACZwB,UAAU,EAAE;EACd,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { OntologyEntityTypeEnum } from "@osdk/maker";
18
+ import { consola } from "consola";
19
+ import { mapPropertyType } from "./mapPropertyType.js";
20
+ import { withoutNamespace } from "./utils.js";
21
+ export function convertObjectType(fullMetadata) {
22
+ const obj = fullMetadata.objectType;
23
+ const properties = [];
24
+ for (const [propApiName, propV2] of Object.entries(obj.properties)) {
25
+ const mapped = mapPropertyType(propV2.dataType);
26
+ if (!mapped) {
27
+ consola.warn(`Skipping property "${propApiName}" on object "${obj.apiName}": unsupported type "${propV2.dataType.type}"`);
28
+ continue;
29
+ }
30
+ const prop = {
31
+ apiName: propApiName,
32
+ displayName: propV2.displayName ?? propApiName,
33
+ type: mapped.type
34
+ };
35
+ if (mapped.array) {
36
+ prop.array = true;
37
+ }
38
+ properties.push(prop);
39
+ }
40
+ const shortName = withoutNamespace(obj.apiName);
41
+ return {
42
+ __type: OntologyEntityTypeEnum.OBJECT_TYPE,
43
+ apiName: obj.apiName,
44
+ displayName: obj.displayName ?? shortName,
45
+ pluralDisplayName: (obj.displayName ?? shortName) + "s",
46
+ primaryKeyPropertyApiName: obj.primaryKey,
47
+ titlePropertyApiName: obj.titleProperty,
48
+ properties,
49
+ description: obj.description,
50
+ visibility: obj.visibility,
51
+ status: mapObjectStatus(obj.status)
52
+ };
53
+ }
54
+ function mapObjectStatus(status) {
55
+ switch (status) {
56
+ case "ACTIVE":
57
+ return "active";
58
+ case "EXPERIMENTAL":
59
+ return "experimental";
60
+ default:
61
+ return "active";
62
+ }
63
+ }
64
+ //# sourceMappingURL=convertObjectType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertObjectType.js","names":["OntologyEntityTypeEnum","consola","mapPropertyType","withoutNamespace","convertObjectType","fullMetadata","obj","objectType","properties","propApiName","propV2","Object","entries","mapped","dataType","warn","apiName","type","prop","displayName","array","push","shortName","__type","OBJECT_TYPE","pluralDisplayName","primaryKeyPropertyApiName","primaryKey","titlePropertyApiName","titleProperty","description","visibility","status","mapObjectStatus"],"sources":["convertObjectType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectPropertyType, ObjectType } from \"@osdk/maker\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { mapPropertyType } from \"./mapPropertyType.js\";\nimport { withoutNamespace } from \"./utils.js\";\n\ninterface GatewayObjectTypeFullMetadata {\n objectType: {\n apiName: string;\n displayName?: string;\n description?: string;\n primaryKey: string;\n titleProperty: string;\n status: string;\n visibility?: string;\n properties: Record<\n string,\n {\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n }\n >;\n };\n sharedPropertyTypeMapping?: Record<string, string>;\n}\n\nexport function convertObjectType(\n fullMetadata: GatewayObjectTypeFullMetadata,\n): ObjectType {\n const obj = fullMetadata.objectType;\n const properties: Array<ObjectPropertyType> = [];\n\n for (const [propApiName, propV2] of Object.entries(obj.properties)) {\n const mapped = mapPropertyType(propV2.dataType);\n if (!mapped) {\n consola.warn(\n `Skipping property \"${propApiName}\" on object \"${obj.apiName}\": unsupported type \"${propV2.dataType.type}\"`,\n );\n continue;\n }\n\n const prop: ObjectPropertyType = {\n apiName: propApiName,\n displayName: propV2.displayName ?? propApiName,\n type: mapped.type,\n };\n if (mapped.array) {\n (prop as ObjectPropertyType & { array?: boolean }).array = true;\n }\n properties.push(prop);\n }\n\n const shortName = withoutNamespace(obj.apiName);\n\n return {\n __type: OntologyEntityTypeEnum.OBJECT_TYPE,\n apiName: obj.apiName,\n displayName: obj.displayName ?? shortName,\n pluralDisplayName: (obj.displayName ?? shortName) + \"s\",\n primaryKeyPropertyApiName: obj.primaryKey,\n titlePropertyApiName: obj.titleProperty,\n properties,\n description: obj.description,\n visibility: obj.visibility as \"NORMAL\" | \"PROMINENT\" | \"HIDDEN\" | undefined,\n status: mapObjectStatus(obj.status),\n };\n}\n\nfunction mapObjectStatus(\n status: string,\n): \"active\" | \"experimental\" | undefined {\n switch (status) {\n case \"ACTIVE\":\n return \"active\";\n case \"EXPERIMENTAL\":\n return \"experimental\";\n default:\n return \"active\";\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,YAAY;AAuB7C,OAAO,SAASC,iBAAiBA,CAC/BC,YAA2C,EAC/B;EACZ,MAAMC,GAAG,GAAGD,YAAY,CAACE,UAAU;EACn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EACyB;EACvC,QAAQA,MAAM;IACZ,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,cAAc;MACjB,OAAO,cAAc;IACvB;MACE,OAAO,QAAQ;EACnB;AACF","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { OntologyEntityTypeEnum } from "@osdk/maker";
18
+ import { consola } from "consola";
19
+ import { mapPropertyType } from "./mapPropertyType.js";
20
+ import { withoutNamespace } from "./utils.js";
21
+ export function convertSharedPropertyType(spt) {
22
+ const mapped = mapPropertyType(spt.dataType);
23
+ if (!mapped) {
24
+ consola.warn(`Skipping shared property type "${spt.apiName}": unsupported type "${spt.dataType.type}"`);
25
+ return undefined;
26
+ }
27
+ return {
28
+ __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,
29
+ apiName: spt.apiName,
30
+ nonNameSpacedApiName: withoutNamespace(spt.apiName),
31
+ displayName: spt.displayName ?? withoutNamespace(spt.apiName),
32
+ type: mapped.type,
33
+ array: mapped.array,
34
+ description: spt.description
35
+ };
36
+ }
37
+ //# sourceMappingURL=convertSharedPropertyType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertSharedPropertyType.js","names":["OntologyEntityTypeEnum","consola","mapPropertyType","withoutNamespace","convertSharedPropertyType","spt","mapped","dataType","warn","apiName","type","undefined","__type","SHARED_PROPERTY_TYPE","nonNameSpacedApiName","displayName","array","description"],"sources":["convertSharedPropertyType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SharedPropertyType } from \"@osdk/maker\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { mapPropertyType } from \"./mapPropertyType.js\";\nimport { withoutNamespace } from \"./utils.js\";\n\ninterface GatewaySharedPropertyType {\n apiName: string;\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n}\n\nexport function convertSharedPropertyType(\n spt: GatewaySharedPropertyType,\n): SharedPropertyType | undefined {\n const mapped = mapPropertyType(spt.dataType);\n if (!mapped) {\n consola.warn(\n `Skipping shared property type \"${spt.apiName}\": unsupported type \"${spt.dataType.type}\"`,\n );\n return undefined;\n }\n\n return {\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n apiName: spt.apiName,\n nonNameSpacedApiName: withoutNamespace(spt.apiName),\n displayName: spt.displayName ?? withoutNamespace(spt.apiName),\n type: mapped.type,\n array: mapped.array,\n description: spt.description,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,YAAY;AAS7C,OAAO,SAASC,yBAAyBA,CACvCC,GAA8B,EACE;EAChC,MAAMC,MAAM,GAAGJ,eAAe,CAACG,GAAG,CAACE,QAAQ,CAAC;EAC5C,IAAI,CAACD,MAAM,EAAE;IACXL,OAAO,CAACO,IAAI,CACV,kCAAkCH,GAAG,CAACI,OAAO,wBAAwBJ,GAAG,CAACE,QAAQ,CAACG,IAAI,GACxF,CAAC;IACD,OAAOC,SAAS;EAClB;EAEA,OAAO;IACLC,MAAM,EAAEZ,sBAAsB,CAACa,oBAAoB;IACnDJ,OAAO,EAAEJ,GAAG,CAACI,OAAO;IACpBK,oBAAoB,EAAEX,gBAAgB,CAACE,GAAG,CAACI,OAAO,CAAC;IACnDM,WAAW,EAAEV,GAAG,CAACU,WAAW,IAAIZ,gBAAgB,CAACE,GAAG,CAACI,OAAO,CAAC;IAC7DC,IAAI,EAAEJ,MAAM,CAACI,IAAI;IACjBM,KAAK,EAAEV,MAAM,CAACU,KAAK;IACnBC,WAAW,EAAEZ,GAAG,CAACY;EACnB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,211 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { consola } from "consola";
18
+
19
+ // ActionParameterType from maker is not exported, so we use structural typing.
20
+ // The generated JSON will have the correct shape at runtime.
21
+
22
+ const SIMPLE_PARAM_TYPES = {
23
+ string: "string",
24
+ integer: "integer",
25
+ boolean: "boolean",
26
+ double: "double",
27
+ long: "long",
28
+ date: "date",
29
+ timestamp: "timestamp",
30
+ attachment: "attachment",
31
+ marking: "marking",
32
+ geohash: "geohash",
33
+ geoshape: "geoshape",
34
+ mediaReference: "mediaReference",
35
+ decimal: "decimal"
36
+ };
37
+ const LIST_VARIANT_MAP = {
38
+ string: "stringList",
39
+ integer: "integerList",
40
+ boolean: "booleanList",
41
+ double: "doubleList",
42
+ long: "longList",
43
+ date: "dateList",
44
+ timestamp: "timestampList",
45
+ attachment: "attachmentList",
46
+ marking: "markingList",
47
+ geohash: "geohashList",
48
+ geoshape: "geoshapeList",
49
+ mediaReference: "mediaReferenceList",
50
+ decimal: "decimalList"
51
+ };
52
+
53
+ // Maps gateway struct field types to OntologyIrStructFieldBaseParameterType format
54
+ const STRUCT_FIELD_IR_TYPES = {
55
+ boolean: "boolean",
56
+ integer: "integer",
57
+ long: "long",
58
+ double: "double",
59
+ string: "string",
60
+ geohash: "geohash",
61
+ geoshape: "geoshape",
62
+ timestamp: "timestamp",
63
+ date: "date"
64
+ };
65
+
66
+ /**
67
+ * Converts gateway struct field types to the IR structFieldTypes record.
68
+ * Returns undefined if structFieldTypes is missing.
69
+ */
70
+ function mapGatewayStructFieldsToIr(dataType) {
71
+ const fields = dataType.structFieldTypes;
72
+ if (!fields) {
73
+ consola.warn("Struct parameter type missing structFieldTypes, skipping");
74
+ return undefined;
75
+ }
76
+ const structFieldTypes = {};
77
+ for (const field of fields) {
78
+ const fieldType = field.dataType.type;
79
+ const irType = STRUCT_FIELD_IR_TYPES[fieldType];
80
+ if (irType) {
81
+ structFieldTypes[field.apiName] = {
82
+ type: irType,
83
+ [irType]: {}
84
+ };
85
+ } else if (fieldType === "object") {
86
+ const objectTypeApiName = field.dataType.objectTypeApiName ?? "";
87
+ structFieldTypes[field.apiName] = {
88
+ type: "objectReference",
89
+ objectReference: {
90
+ objectTypeId: objectTypeApiName
91
+ }
92
+ };
93
+ } else {
94
+ consola.warn(`Skipping struct param field "${field.apiName}": unsupported type "${fieldType}"`);
95
+ }
96
+ }
97
+ return structFieldTypes;
98
+ }
99
+
100
+ /**
101
+ * Maps a gateway ActionParameterType (discriminated union from OntologyFullMetadata)
102
+ * to a maker ActionParameterType (string primitives or complex objects).
103
+ *
104
+ * Returns undefined for unsupported types (with a warning).
105
+ */
106
+ export function mapActionParameterType(dataType) {
107
+ const simpleType = SIMPLE_PARAM_TYPES[dataType.type];
108
+ if (simpleType !== undefined) {
109
+ return simpleType;
110
+ }
111
+ switch (dataType.type) {
112
+ case "object":
113
+ {
114
+ const objectTypeApiName = dataType.objectTypeApiName ?? "";
115
+ return {
116
+ type: "objectReference",
117
+ objectReference: {
118
+ objectTypeId: objectTypeApiName
119
+ }
120
+ };
121
+ }
122
+ case "objectSet":
123
+ {
124
+ const objectTypeApiName = dataType.objectTypeApiName ?? "";
125
+ return {
126
+ type: "objectSetRid",
127
+ objectSetRid: {
128
+ objectTypeId: objectTypeApiName
129
+ }
130
+ };
131
+ }
132
+ case "interfaceObject":
133
+ {
134
+ const interfaceApiName = dataType.interfaceApiName ?? "";
135
+ return {
136
+ type: "interfaceReference",
137
+ interfaceReference: {
138
+ interfaceTypeRid: interfaceApiName
139
+ }
140
+ };
141
+ }
142
+ case "array":
143
+ {
144
+ const subType = dataType.subType;
145
+ if (!subType) {
146
+ consola.warn("Array parameter type missing subType, skipping");
147
+ return undefined;
148
+ }
149
+
150
+ // For simple types, use the list variant
151
+ const listVariant = LIST_VARIANT_MAP[subType.type];
152
+ if (listVariant !== undefined) {
153
+ return listVariant;
154
+ }
155
+
156
+ // For object references, use objectReferenceList
157
+ if (subType.type === "object") {
158
+ const objectTypeApiName = subType.objectTypeApiName ?? "";
159
+ return {
160
+ type: "objectReferenceList",
161
+ objectReferenceList: {
162
+ objectTypeId: objectTypeApiName
163
+ }
164
+ };
165
+ }
166
+
167
+ // For interface references, use interfaceReferenceList
168
+ if (subType.type === "interfaceObject") {
169
+ const interfaceApiName = subType.interfaceApiName ?? "";
170
+ return {
171
+ type: "interfaceReferenceList",
172
+ interfaceReferenceList: {
173
+ interfaceTypeRid: interfaceApiName
174
+ }
175
+ };
176
+ }
177
+ if (subType.type === "struct") {
178
+ const structFields = mapGatewayStructFieldsToIr(subType);
179
+ if (!structFields) return undefined;
180
+ return {
181
+ type: "structList",
182
+ structList: {
183
+ structFieldTypes: structFields
184
+ }
185
+ };
186
+ }
187
+ consola.warn(`Skipping array parameter with unsupported subType: ${subType.type}`);
188
+ return undefined;
189
+ }
190
+ case "struct":
191
+ {
192
+ const structFields = mapGatewayStructFieldsToIr(dataType);
193
+ if (!structFields) return undefined;
194
+ return {
195
+ type: "struct",
196
+ struct: {
197
+ structFieldTypes: structFields
198
+ }
199
+ };
200
+ }
201
+ case "vector":
202
+ consola.warn("Skipping vector parameter type: no maker equivalent");
203
+ return undefined;
204
+ case "objectType":
205
+ return "objectTypeReference";
206
+ default:
207
+ consola.warn(`Skipping unknown parameter type: ${dataType.type}`);
208
+ return undefined;
209
+ }
210
+ }
211
+ //# sourceMappingURL=mapActionParameterType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapActionParameterType.js","names":["consola","SIMPLE_PARAM_TYPES","string","integer","boolean","double","long","date","timestamp","attachment","marking","geohash","geoshape","mediaReference","decimal","LIST_VARIANT_MAP","STRUCT_FIELD_IR_TYPES","mapGatewayStructFieldsToIr","dataType","fields","structFieldTypes","warn","undefined","field","fieldType","type","irType","apiName","objectTypeApiName","objectReference","objectTypeId","mapActionParameterType","simpleType","objectSetRid","interfaceApiName","interfaceReference","interfaceTypeRid","subType","listVariant","objectReferenceList","interfaceReferenceList","structFields","structList","struct"],"sources":["mapActionParameterType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\n\n// ActionParameterType from maker is not exported, so we use structural typing.\n// The generated JSON will have the correct shape at runtime.\ntype ActionParameterType = string | { type: string; [key: string]: unknown };\n\nconst SIMPLE_PARAM_TYPES: Record<string, ActionParameterType> = {\n string: \"string\",\n integer: \"integer\",\n boolean: \"boolean\",\n double: \"double\",\n long: \"long\",\n date: \"date\",\n timestamp: \"timestamp\",\n attachment: \"attachment\",\n marking: \"marking\",\n geohash: \"geohash\",\n geoshape: \"geoshape\",\n mediaReference: \"mediaReference\",\n decimal: \"decimal\",\n};\n\nconst LIST_VARIANT_MAP: Record<string, ActionParameterType> = {\n string: \"stringList\",\n integer: \"integerList\",\n boolean: \"booleanList\",\n double: \"doubleList\",\n long: \"longList\",\n date: \"dateList\",\n timestamp: \"timestampList\",\n attachment: \"attachmentList\",\n marking: \"markingList\",\n geohash: \"geohashList\",\n geoshape: \"geoshapeList\",\n mediaReference: \"mediaReferenceList\",\n decimal: \"decimalList\",\n};\n\n// Maps gateway struct field types to OntologyIrStructFieldBaseParameterType format\nconst STRUCT_FIELD_IR_TYPES: Record<string, string> = {\n boolean: \"boolean\",\n integer: \"integer\",\n long: \"long\",\n double: \"double\",\n string: \"string\",\n geohash: \"geohash\",\n geoshape: \"geoshape\",\n timestamp: \"timestamp\",\n date: \"date\",\n};\n\n/**\n * Converts gateway struct field types to the IR structFieldTypes record.\n * Returns undefined if structFieldTypes is missing.\n */\nfunction mapGatewayStructFieldsToIr(\n dataType: { type: string; [key: string]: unknown },\n): Record<string, { type: string; [key: string]: unknown }> | undefined {\n const fields = (dataType as {\n structFieldTypes?: Array<{\n apiName: string;\n dataType: { type: string; [key: string]: unknown };\n }>;\n }).structFieldTypes;\n if (!fields) {\n consola.warn(\"Struct parameter type missing structFieldTypes, skipping\");\n return undefined;\n }\n const structFieldTypes: Record<\n string,\n { type: string; [key: string]: unknown }\n > = {};\n for (const field of fields) {\n const fieldType = field.dataType.type;\n const irType = STRUCT_FIELD_IR_TYPES[fieldType];\n if (irType) {\n structFieldTypes[field.apiName] = { type: irType, [irType]: {} };\n } else if (fieldType === \"object\") {\n const objectTypeApiName =\n (field.dataType as { objectTypeApiName?: string }).objectTypeApiName\n ?? \"\";\n structFieldTypes[field.apiName] = {\n type: \"objectReference\",\n objectReference: { objectTypeId: objectTypeApiName },\n };\n } else {\n consola.warn(\n `Skipping struct param field \"${field.apiName}\": unsupported type \"${fieldType}\"`,\n );\n }\n }\n return structFieldTypes;\n}\n\n/**\n * Maps a gateway ActionParameterType (discriminated union from OntologyFullMetadata)\n * to a maker ActionParameterType (string primitives or complex objects).\n *\n * Returns undefined for unsupported types (with a warning).\n */\nexport function mapActionParameterType(\n dataType: { type: string; [key: string]: unknown },\n): ActionParameterType | undefined {\n const simpleType = SIMPLE_PARAM_TYPES[dataType.type];\n if (simpleType !== undefined) {\n return simpleType;\n }\n\n switch (dataType.type) {\n case \"object\": {\n const objectTypeApiName =\n (dataType as { objectTypeApiName?: string }).objectTypeApiName ?? \"\";\n return {\n type: \"objectReference\",\n objectReference: { objectTypeId: objectTypeApiName },\n };\n }\n case \"objectSet\": {\n const objectTypeApiName =\n (dataType as { objectTypeApiName?: string }).objectTypeApiName ?? \"\";\n return {\n type: \"objectSetRid\",\n objectSetRid: { objectTypeId: objectTypeApiName },\n };\n }\n case \"interfaceObject\": {\n const interfaceApiName =\n (dataType as { interfaceApiName?: string }).interfaceApiName ?? \"\";\n return {\n type: \"interfaceReference\",\n interfaceReference: { interfaceTypeRid: interfaceApiName },\n };\n }\n case \"array\": {\n const subType = (dataType as { subType?: { type: string } }).subType;\n if (!subType) {\n consola.warn(\"Array parameter type missing subType, skipping\");\n return undefined;\n }\n\n // For simple types, use the list variant\n const listVariant = LIST_VARIANT_MAP[subType.type];\n if (listVariant !== undefined) {\n return listVariant;\n }\n\n // For object references, use objectReferenceList\n if (subType.type === \"object\") {\n const objectTypeApiName =\n (subType as { objectTypeApiName?: string }).objectTypeApiName ?? \"\";\n return {\n type: \"objectReferenceList\",\n objectReferenceList: { objectTypeId: objectTypeApiName },\n };\n }\n\n // For interface references, use interfaceReferenceList\n if (subType.type === \"interfaceObject\") {\n const interfaceApiName =\n (subType as { interfaceApiName?: string }).interfaceApiName ?? \"\";\n return {\n type: \"interfaceReferenceList\",\n interfaceReferenceList: { interfaceTypeRid: interfaceApiName },\n };\n }\n\n if (subType.type === \"struct\") {\n const structFields = mapGatewayStructFieldsToIr(\n subType as { type: string; [key: string]: unknown },\n );\n if (!structFields) return undefined;\n return {\n type: \"structList\",\n structList: { structFieldTypes: structFields },\n };\n }\n\n consola.warn(\n `Skipping array parameter with unsupported subType: ${subType.type}`,\n );\n return undefined;\n }\n case \"struct\": {\n const structFields = mapGatewayStructFieldsToIr(dataType);\n if (!structFields) return undefined;\n return {\n type: \"struct\",\n struct: { structFieldTypes: structFields },\n };\n }\n case \"vector\":\n consola.warn(\"Skipping vector parameter type: no maker equivalent\");\n return undefined;\n case \"objectType\":\n return \"objectTypeReference\";\n default:\n consola.warn(`Skipping unknown parameter type: ${dataType.type}`);\n return undefined;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;;AAEjC;AACA;;AAGA,MAAMC,kBAAuD,GAAG;EAC9DC,MAAM,EAAE,QAAQ;EAChBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,SAAS,EAAE,WAAW;EACtBC,UAAU,EAAE,YAAY;EACxBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,UAAU;EACpBC,cAAc,EAAE,gBAAgB;EAChCC,OAAO,EAAE;AACX,CAAC;AAED,MAAMC,gBAAqD,GAAG;EAC5Db,MAAM,EAAE,YAAY;EACpBC,OAAO,EAAE,aAAa;EACt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