@osdk/maker-import 0.3.0 → 0.3.1-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/build/browser/cli/main.js +1 -1
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/generate/convertActionType.js +0 -5
- package/build/browser/generate/convertActionType.js.map +1 -1
- package/build/browser/generate/convertInterfaceType.js +28 -15
- package/build/browser/generate/convertInterfaceType.js.map +1 -1
- package/build/browser/generate/convertObjectType.js +1 -0
- package/build/browser/generate/convertObjectType.js.map +1 -1
- package/build/browser/generate/convertSharedPropertyType.js.map +1 -1
- package/build/browser/generate/mapActionParameterType.js +72 -75
- package/build/browser/generate/mapActionParameterType.js.map +1 -1
- package/build/browser/generate/mapPropertyType.js.map +1 -1
- package/build/browser/generate/writeImportedOntology.js.map +1 -1
- package/build/cjs/index.cjs +86 -58
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +3 -77
- package/build/esm/cli/main.js +1 -1
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/generate/convertActionType.js +0 -5
- package/build/esm/generate/convertActionType.js.map +1 -1
- package/build/esm/generate/convertInterfaceType.js +28 -15
- package/build/esm/generate/convertInterfaceType.js.map +1 -1
- package/build/esm/generate/convertObjectType.js +1 -0
- package/build/esm/generate/convertObjectType.js.map +1 -1
- package/build/esm/generate/convertSharedPropertyType.js.map +1 -1
- package/build/esm/generate/mapActionParameterType.js +72 -75
- package/build/esm/generate/mapActionParameterType.js.map +1 -1
- package/build/esm/generate/mapPropertyType.js.map +1 -1
- package/build/esm/generate/writeImportedOntology.js.map +1 -1
- package/build/types/generate/convertActionType.d.ts +3 -41
- package/build/types/generate/convertActionType.d.ts.map +1 -1
- package/build/types/generate/convertInterfaceType.d.ts +2 -28
- package/build/types/generate/convertInterfaceType.d.ts.map +1 -1
- package/build/types/generate/convertObjectType.d.ts +2 -22
- package/build/types/generate/convertObjectType.d.ts.map +1 -1
- package/build/types/generate/convertSharedPropertyType.d.ts +2 -11
- package/build/types/generate/convertSharedPropertyType.d.ts.map +1 -1
- package/build/types/generate/mapActionParameterType.d.ts +3 -9
- package/build/types/generate/mapActionParameterType.d.ts.map +1 -1
- package/build/types/generate/mapPropertyType.d.ts +2 -4
- package/build/types/generate/mapPropertyType.d.ts.map +1 -1
- package/build/types/generate/writeImportedOntology.d.ts +2 -78
- package/build/types/generate/writeImportedOntology.d.ts.map +1 -1
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @osdk/maker-import
|
|
2
2
|
|
|
3
|
+
## 0.3.1-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [56c2c9f]
|
|
8
|
+
- @osdk/maker@0.28.1-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
9
|
+
- @osdk/client.unstable@2.23.0-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c
|
|
10
|
+
|
|
3
11
|
## 0.3.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -21,7 +21,7 @@ import yargs from "yargs";
|
|
|
21
21
|
import { hideBin } from "yargs/helpers";
|
|
22
22
|
import { writeImportedOntology } from "../generate/writeImportedOntology.js";
|
|
23
23
|
export default async function main(args = process.argv) {
|
|
24
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.3.
|
|
24
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.3.1-main-9fb5afb7955ddffd2b9a89d03d6c2ca3528e371c" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
25
25
|
input: {
|
|
26
26
|
alias: "i",
|
|
27
27
|
describe: "Path to OntologyFullMetadata JSON file",
|
|
@@ -1 +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,
|
|
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,yDAA+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":[]}
|
|
@@ -18,11 +18,6 @@ import { OntologyEntityTypeEnum } from "@osdk/maker";
|
|
|
18
18
|
import { consola } from "consola";
|
|
19
19
|
import { mapActionParameterType } from "./mapActionParameterType.js";
|
|
20
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
21
|
export function convertActionType(action) {
|
|
27
22
|
const parameters = [];
|
|
28
23
|
for (const [paramId, paramV2] of Object.entries(action.parameters)) {
|
|
@@ -1 +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
|
|
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 type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport type { ActionParameter, ActionType } from \"@osdk/maker\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { mapActionParameterType } from \"./mapActionParameterType.js\";\nimport { withoutNamespace } from \"./utils.js\";\n\nexport function convertActionType(\n action: Ontologies.ActionTypeV2,\n): ActionType {\n const parameters: Array<ActionParameter> = [];\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;;AAIA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,SAASC,iBAAiBA,CAC/BC,MAA+B,EACnB;EACZ,MAAMC,UAAkC,GAAG,EAAE;EAE7C,KAAK,MAAM,CAACC,OAAO,EAAEC,OAAO,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,MAAM,CAACC,UAAU,CAAC,EAAE;IAClE,MAAMK,UAAU,GAAGT,sBAAsB,CAACM,OAAO,CAACI,QAAQ,CAAC;IAC3D,IAAI,CAACD,UAAU,EAAE;MACfV,OAAO,CAACY,IAAI,CACV,uBAAuBN,OAAO,gBAAgBF,MAAM,CAACS,OAAO,wBAAwBN,OAAO,CAACI,QAAQ,CAACG,IAAI,GAC3G,CAAC;MACD;IACF;IAEAT,UAAU,CAACU,IAAI,CAAC;MACdC,EAAE,EAAEV,OAAO;MACXW,WAAW,EAAEV,OAAO,CAACU,WAAW,IAAIX,OAAO;MAC3CQ,IAAI,EAAEJ,UAAU;MAChBQ,UAAU,EAAE;QACVC,QAAQ,EAAEZ,OAAO,CAACY;MACpB;IACF,CAAC,CAAC;EACJ;EAEA,MAAMC,SAAS,GAAGlB,gBAAgB,CAACE,MAAM,CAACS,OAAO,CAAC;EAElD,OAAO;IACLQ,MAAM,EAAEtB,sBAAsB,CAACuB,WAAW;IAC1CT,OAAO,EAAET,MAAM,CAACS,OAAO;IACvBI,WAAW,EAAEb,MAAM,CAACa,WAAW,IAAIG,SAAS;IAC5CG,MAAM,EAAEC,eAAe,CAACpB,MAAM,CAACmB,MAAM,CAAC;IACtCE,KAAK,EAAE,EAAE;IACTpB;EACF,CAAC;AACH;AAEA,SAASmB,eAAeA,CACtBD,MAAc,EACyB;EACvC,QAAQA,MAAM;IACZ,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,cAAc;MACjB,OAAO,cAAc;IACvB;MACE,OAAO,QAAQ;EACnB;AACF","ignoreList":[]}
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { OntologyEntityTypeEnum } from "@osdk/maker";
|
|
18
|
+
import { consola } from "consola";
|
|
18
19
|
import { convertSharedPropertyType } from "./convertSharedPropertyType.js";
|
|
20
|
+
import { mapPropertyType } from "./mapPropertyType.js";
|
|
19
21
|
import { withoutNamespace } from "./utils.js";
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* Converts a gateway InterfaceType to a maker InterfaceType.
|
|
22
25
|
*
|
|
@@ -25,23 +28,33 @@ import { withoutNamespace } from "./utils.js";
|
|
|
25
28
|
export function convertInterfaceType(iface, allInterfaces) {
|
|
26
29
|
const shortName = withoutNamespace(iface.apiName);
|
|
27
30
|
|
|
28
|
-
//
|
|
31
|
+
// propertiesV2 is SPT-only; propertiesV3 also carries inline-defined properties.
|
|
29
32
|
const propertiesV2 = {};
|
|
30
33
|
const propertiesV3 = {};
|
|
31
|
-
for (const [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
for (const [_propApiName, prop] of Object.entries(iface.propertiesV2)) {
|
|
35
|
+
if (prop.type === "interfaceSharedPropertyType") {
|
|
36
|
+
const converted = convertSharedPropertyType(prop);
|
|
37
|
+
if (converted) {
|
|
38
|
+
const entry = {
|
|
39
|
+
sharedPropertyType: converted,
|
|
40
|
+
required: true
|
|
41
|
+
};
|
|
42
|
+
propertiesV2[prop.apiName] = entry;
|
|
43
|
+
propertiesV3[withoutNamespace(prop.apiName)] = entry;
|
|
44
|
+
}
|
|
45
|
+
} else if (prop.type === "interfaceDefinedPropertyType") {
|
|
46
|
+
const mapped = mapPropertyType(prop.dataType);
|
|
47
|
+
if (mapped) {
|
|
48
|
+
propertiesV3[withoutNamespace(prop.apiName)] = {
|
|
49
|
+
type: mapped.type,
|
|
50
|
+
array: mapped.array,
|
|
51
|
+
displayName: prop.displayName,
|
|
52
|
+
description: prop.description,
|
|
53
|
+
required: prop.requireImplementation
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
consola.warn(`Skipping interface-defined property "${prop.apiName}": unsupported type "${prop.dataType.type}"`);
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertInterfaceType.js","names":["OntologyEntityTypeEnum","convertSharedPropertyType","withoutNamespace","convertInterfaceType","iface","allInterfaces","shortName","apiName","propertiesV2","propertiesV3","
|
|
1
|
+
{"version":3,"file":"convertInterfaceType.js","names":["OntologyEntityTypeEnum","consola","convertSharedPropertyType","mapPropertyType","withoutNamespace","convertInterfaceType","iface","allInterfaces","shortName","apiName","propertiesV2","propertiesV3","_propApiName","prop","Object","entries","type","converted","entry","sharedPropertyType","required","mapped","dataType","array","displayName","description","requireImplementation","warn","extendsInterfaces","extApiName","extIface","push","__type","INTERFACE_TYPE","displayMetadata","links","status","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 * as Ontologies from \"@osdk/foundry.ontologies\";\nimport type {\n InterfacePropertyType,\n InterfaceType,\n SharedPropertyType,\n} from \"@osdk/maker\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { convertSharedPropertyType } from \"./convertSharedPropertyType.js\";\nimport { mapPropertyType } from \"./mapPropertyType.js\";\nimport { withoutNamespace } from \"./utils.js\";\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: Ontologies.InterfaceType,\n allInterfaces: Record<string, Ontologies.InterfaceType>,\n): InterfaceType {\n const shortName = withoutNamespace(iface.apiName);\n\n // propertiesV2 is SPT-only; propertiesV3 also carries inline-defined properties.\n const propertiesV2: Record<\n string,\n { sharedPropertyType: SharedPropertyType; required: boolean }\n > = {};\n const propertiesV3: Record<string, InterfacePropertyType> = {};\n\n for (const [_propApiName, prop] of Object.entries(iface.propertiesV2)) {\n if (prop.type === \"interfaceSharedPropertyType\") {\n const converted = convertSharedPropertyType(prop);\n if (converted) {\n const entry = { sharedPropertyType: converted, required: true };\n propertiesV2[prop.apiName] = entry;\n propertiesV3[withoutNamespace(prop.apiName)] = entry;\n }\n } else if (prop.type === \"interfaceDefinedPropertyType\") {\n const mapped = mapPropertyType(prop.dataType);\n if (mapped) {\n propertiesV3[withoutNamespace(prop.apiName)] = {\n type: mapped.type,\n array: mapped.array,\n displayName: prop.displayName,\n description: prop.description,\n required: prop.requireImplementation,\n };\n } else {\n consola.warn(\n `Skipping interface-defined property \"${prop.apiName}\": unsupported type \"${prop.dataType.type}\"`,\n );\n }\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 };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,yBAAyB,QAAQ,gCAAgC;AAC1E,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,YAAY;;AAE7C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,KAA+B,EAC/BC,aAAuD,EACxC;EACf,MAAMC,SAAS,GAAGJ,gBAAgB,CAACE,KAAK,CAACG,OAAO,CAAC;;EAEjD;EACA,MAAMC,YAGL,GAAG,CAAC,CAAC;EACN,MAAMC,YAAmD,GAAG,CAAC,CAAC;EAE9D,KAAK,MAAM,CAACC,YAAY,EAAEC,IAAI,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,KAAK,CAACI,YAAY,CAAC,EAAE;IACrE,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hC,sBAAsB,CAACiC,cAAc;IAC7CxB,OAAO,EAAEH,KAAK,CAACG,OAAO;IACtByB,eAAe,EAAE;MACfV,WAAW,EAAElB,KAAK,CAACkB,WAAW,IAAIhB,SAAS;MAC3CiB,WAAW,EAAEnB,KAAK,CAACmB,WAAW,IAAIjB;IACpC,CAAC;IACDoB,iBAAiB;IACjBO,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;MAAEpB,IAAI,EAAE,QAAQ;MAAEqB,MAAM,EAAE,CAAC;IAAE,CAAC;IACtC3B,YAAY;IACZC,YAAY;IACZ2B,UAAU,EAAE;EACd,CAAC;AACH","ignoreList":[]}
|
|
@@ -40,6 +40,7 @@ export function convertObjectType(fullMetadata) {
|
|
|
40
40
|
const shortName = withoutNamespace(obj.apiName);
|
|
41
41
|
return {
|
|
42
42
|
__type: OntologyEntityTypeEnum.OBJECT_TYPE,
|
|
43
|
+
ridHint: obj.rid,
|
|
43
44
|
apiName: obj.apiName,
|
|
44
45
|
displayName: obj.displayName ?? shortName,
|
|
45
46
|
pluralDisplayName: (obj.displayName ?? shortName) + "s",
|
|
@@ -1 +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\
|
|
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","ridHint","rid","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 * as Ontologies from \"@osdk/foundry.ontologies\";\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\nexport function convertObjectType(\n fullMetadata: Ontologies.ObjectTypeFullMetadata,\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 ridHint: obj.rid,\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;;AAIA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,SAASC,iBAAiBA,CAC/BC,YAA+C,EACnC;EACZ,MAAMC,GAAG,GAAGD,YAAY,CAACE,UAAU;EACnC,MAAMC,UAAqC,GAAG,EAAE;EAEhD,KAAK,MAAM,CAACC,WAAW,EAAEC,MAAM,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,GAAG,CAACE,UAAU,CAAC,EAAE;IAClE,MAAMK,MAAM,GAAGX,eAAe,CAACQ,MAAM,CAACI,QAAQ,CAAC;IAC/C,IAAI,CAACD,MAAM,EAAE;MACXZ,OAAO,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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\
|
|
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 * as Ontologies from \"@osdk/foundry.ontologies\";\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\nexport function convertSharedPropertyType(\n spt: Ontologies.SharedPropertyType,\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;;AAIA,SAASA,sBAAsB,QAAQ,aAAa;AACpD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,SAASC,yBAAyBA,CACvCC,GAAkC,EACF;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":[]}
|
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
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
18
|
const SIMPLE_PARAM_TYPES = {
|
|
23
19
|
string: "string",
|
|
24
20
|
integer: "integer",
|
|
@@ -49,49 +45,67 @@ const LIST_VARIANT_MAP = {
|
|
|
49
45
|
mediaReference: "mediaReferenceList",
|
|
50
46
|
decimal: "decimalList"
|
|
51
47
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
48
|
+
function mapStructFieldType(fieldType) {
|
|
49
|
+
switch (fieldType.type) {
|
|
50
|
+
case "boolean":
|
|
51
|
+
return {
|
|
52
|
+
type: "boolean",
|
|
53
|
+
boolean: {}
|
|
54
|
+
};
|
|
55
|
+
case "integer":
|
|
56
|
+
return {
|
|
57
|
+
type: "integer",
|
|
58
|
+
integer: {}
|
|
59
|
+
};
|
|
60
|
+
case "long":
|
|
61
|
+
return {
|
|
62
|
+
type: "long",
|
|
63
|
+
long: {}
|
|
64
|
+
};
|
|
65
|
+
case "double":
|
|
66
|
+
return {
|
|
67
|
+
type: "double",
|
|
68
|
+
double: {}
|
|
69
|
+
};
|
|
70
|
+
case "string":
|
|
71
|
+
return {
|
|
72
|
+
type: "string",
|
|
73
|
+
string: {}
|
|
74
|
+
};
|
|
75
|
+
case "timestamp":
|
|
76
|
+
return {
|
|
77
|
+
type: "timestamp",
|
|
78
|
+
timestamp: {}
|
|
79
|
+
};
|
|
80
|
+
case "date":
|
|
81
|
+
return {
|
|
82
|
+
type: "date",
|
|
83
|
+
date: {}
|
|
84
|
+
};
|
|
85
|
+
case "object":
|
|
86
|
+
return {
|
|
87
|
+
type: "objectReference",
|
|
88
|
+
objectReference: {
|
|
89
|
+
objectTypeId: fieldType.objectTypeApiName
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
default:
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
70
96
|
function mapGatewayStructFieldsToIr(dataType) {
|
|
71
|
-
const fields = dataType.
|
|
97
|
+
const fields = dataType.fields;
|
|
72
98
|
if (!fields) {
|
|
73
99
|
consola.warn("Struct parameter type missing structFieldTypes, skipping");
|
|
74
100
|
return undefined;
|
|
75
101
|
}
|
|
76
102
|
const structFieldTypes = {};
|
|
77
103
|
for (const field of fields) {
|
|
78
|
-
const
|
|
79
|
-
const irType = STRUCT_FIELD_IR_TYPES[fieldType];
|
|
104
|
+
const irType = mapStructFieldType(field.fieldType);
|
|
80
105
|
if (irType) {
|
|
81
|
-
structFieldTypes[field.
|
|
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
|
-
};
|
|
106
|
+
structFieldTypes[field.name] = irType;
|
|
93
107
|
} else {
|
|
94
|
-
consola.warn(`Skipping struct param field "${field.
|
|
108
|
+
consola.warn(`Skipping struct param field "${field.name}": unsupported type "${field.fieldType.type}"`);
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
111
|
return structFieldTypes;
|
|
@@ -110,35 +124,26 @@ export function mapActionParameterType(dataType) {
|
|
|
110
124
|
}
|
|
111
125
|
switch (dataType.type) {
|
|
112
126
|
case "object":
|
|
113
|
-
{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
127
|
+
return {
|
|
128
|
+
type: "objectReference",
|
|
129
|
+
objectReference: {
|
|
130
|
+
objectTypeId: dataType.objectTypeApiName
|
|
131
|
+
}
|
|
132
|
+
};
|
|
122
133
|
case "objectSet":
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
134
|
+
return {
|
|
135
|
+
type: "objectSetRid",
|
|
136
|
+
objectSetRid: {
|
|
137
|
+
objectTypeId: dataType.objectTypeApiName ?? ""
|
|
138
|
+
}
|
|
139
|
+
};
|
|
132
140
|
case "interfaceObject":
|
|
133
|
-
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
141
|
+
return {
|
|
142
|
+
type: "interfaceReference",
|
|
143
|
+
interfaceReference: {
|
|
144
|
+
interfaceTypeRid: dataType.interfaceTypeApiName ?? ""
|
|
145
|
+
}
|
|
146
|
+
};
|
|
142
147
|
case "array":
|
|
143
148
|
{
|
|
144
149
|
const subType = dataType.subType;
|
|
@@ -146,31 +151,23 @@ export function mapActionParameterType(dataType) {
|
|
|
146
151
|
consola.warn("Array parameter type missing subType, skipping");
|
|
147
152
|
return undefined;
|
|
148
153
|
}
|
|
149
|
-
|
|
150
|
-
// For simple types, use the list variant
|
|
151
154
|
const listVariant = LIST_VARIANT_MAP[subType.type];
|
|
152
155
|
if (listVariant !== undefined) {
|
|
153
156
|
return listVariant;
|
|
154
157
|
}
|
|
155
|
-
|
|
156
|
-
// For object references, use objectReferenceList
|
|
157
158
|
if (subType.type === "object") {
|
|
158
|
-
const objectTypeApiName = subType.objectTypeApiName ?? "";
|
|
159
159
|
return {
|
|
160
160
|
type: "objectReferenceList",
|
|
161
161
|
objectReferenceList: {
|
|
162
|
-
objectTypeId: objectTypeApiName
|
|
162
|
+
objectTypeId: subType.objectTypeApiName
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
// For interface references, use interfaceReferenceList
|
|
168
166
|
if (subType.type === "interfaceObject") {
|
|
169
|
-
const interfaceApiName = subType.interfaceApiName ?? "";
|
|
170
167
|
return {
|
|
171
168
|
type: "interfaceReferenceList",
|
|
172
169
|
interfaceReferenceList: {
|
|
173
|
-
interfaceTypeRid:
|
|
170
|
+
interfaceTypeRid: subType.interfaceTypeApiName ?? ""
|
|
174
171
|
}
|
|
175
172
|
};
|
|
176
173
|
}
|
|
@@ -1 +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,MA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AAM,EAAE;YAAEvB,gBAAgB,EAAEqB;UAAa;QAC3C,CAAC;MACH;IACA,KAAK,QAAQ;MACXzC,OAAO,CAACqB,IAAI,CAAC,qDAAqD,CAAC;MACnE,OAAOC,SAAS;IAClB,KAAK,YAAY;MACf,OAAO,qBAAqB;IAC9B;MACEtB,OAAO,CAACqB,IAAI,CAAC,oCAAoCH,QAAQ,CAACO,IAAI,EAAE,CAAC;MACjE,OAAOH,SAAS;EACpB;AACF","ignoreList":[]}
|
|
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","mapStructFieldType","fieldType","type","objectReference","objectTypeId","objectTypeApiName","undefined","mapGatewayStructFieldsToIr","dataType","fields","warn","structFieldTypes","field","irType","name","mapActionParameterType","simpleType","objectSetRid","interfaceReference","interfaceTypeRid","interfaceTypeApiName","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 type { OntologyIrStructFieldBaseParameterType } from \"@osdk/client.unstable\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport type { ActionParameter, ActionParameterType } from \"@osdk/maker\";\nimport { consola } from \"consola\";\n\nconst SIMPLE_PARAM_TYPES: Record<string, ActionParameter[\"type\"]> = {\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, ActionParameter[\"type\"]> = {\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\nfunction mapStructFieldType(\n fieldType: Ontologies.OntologyDataType,\n): OntologyIrStructFieldBaseParameterType | undefined {\n switch (fieldType.type) {\n case \"boolean\":\n return { type: \"boolean\", boolean: {} };\n case \"integer\":\n return { type: \"integer\", integer: {} };\n case \"long\":\n return { type: \"long\", long: {} };\n case \"double\":\n return { type: \"double\", double: {} };\n case \"string\":\n return { type: \"string\", string: {} };\n case \"timestamp\":\n return { type: \"timestamp\", timestamp: {} };\n case \"date\":\n return { type: \"date\", date: {} };\n case \"object\":\n return {\n type: \"objectReference\",\n objectReference: { objectTypeId: fieldType.objectTypeApiName },\n };\n default:\n return undefined;\n }\n}\n\nfunction mapGatewayStructFieldsToIr(\n dataType: Ontologies.OntologyStructType,\n): Record<string, OntologyIrStructFieldBaseParameterType> | undefined {\n const fields = dataType.fields;\n if (!fields) {\n consola.warn(\"Struct parameter type missing structFieldTypes, skipping\");\n return undefined;\n }\n const structFieldTypes: Record<\n string,\n OntologyIrStructFieldBaseParameterType\n > = {};\n for (const field of fields) {\n const irType = mapStructFieldType(field.fieldType);\n if (irType) {\n structFieldTypes[field.name] = irType;\n } else {\n consola.warn(\n `Skipping struct param field \"${field.name}\": unsupported type \"${field.fieldType.type}\"`,\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: Ontologies.ActionParameterType,\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 return {\n type: \"objectReference\",\n objectReference: { objectTypeId: dataType.objectTypeApiName },\n };\n case \"objectSet\":\n return {\n type: \"objectSetRid\",\n objectSetRid: { objectTypeId: dataType.objectTypeApiName ?? \"\" },\n };\n case \"interfaceObject\":\n return {\n type: \"interfaceReference\",\n interfaceReference: {\n interfaceTypeRid: dataType.interfaceTypeApiName ?? \"\",\n },\n };\n case \"array\": {\n const subType = dataType.subType;\n if (!subType) {\n consola.warn(\"Array parameter type missing subType, skipping\");\n return undefined;\n }\n\n const listVariant = LIST_VARIANT_MAP[subType.type];\n if (listVariant !== undefined) {\n return listVariant;\n }\n\n if (subType.type === \"object\") {\n return {\n type: \"objectReferenceList\",\n objectReferenceList: { objectTypeId: subType.objectTypeApiName },\n };\n }\n\n if (subType.type === \"interfaceObject\") {\n return {\n type: \"interfaceReferenceList\",\n interfaceReferenceList: {\n interfaceTypeRid: subType.interfaceTypeApiName ?? \"\",\n },\n };\n }\n\n if (subType.type === \"struct\") {\n const structFields = mapGatewayStructFieldsToIr(subType);\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}\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AAK,QAAQ,EAAE;UAC7B,MAAMuB,YAAY,GAAGlB,0BAA0B,CAACc,OAAO,CAAC;UACxD,IAAI,CAACI,YAAY,EAAE,OAAOnB,SAAS;UACnC,OAAO;YACLJ,IAAI,EAAE,YAAY;YAClBwB,UAAU,EAAE;cAAEf,gBAAgB,EAAEc;YAAa;UAC/C,CAAC;QACH;QAEAzC,OAAO,CAAC0B,IAAI,CACV,sDAAsDW,OAAO,CAACnB,IAAI,EACpE,CAAC;QACD,OAAOI,SAAS;MAClB;IACA,KAAK,QAAQ;MAAE;QACb,MAAMmB,YAAY,GAAGlB,0BAA0B,CAACC,QAAQ,CAAC;QACzD,IAAI,CAACiB,YAAY,EAAE,OAAOnB,SAAS;QACnC,OAAO;UACLJ,IAAI,EAAE,QAAQ;UACdyB,MAAM,EAAE;YAAEhB,gBAAgB,EAAEc;UAAa;QAC3C,CAAC;MACH;IACA,KAAK,QAAQ;MACXzC,OAAO,CAAC0B,IAAI,CAAC,qDAAqD,CAAC;MACnE,OAAOJ,SAAS;IAClB,KAAK,YAAY;MACf,OAAO,qBAAqB;IAC9B;MACEtB,OAAO,CAAC0B,IAAI,CAAC,oCAAoCF,QAAQ,CAACN,IAAI,EAAE,CAAC;MACjE,OAAOI,SAAS;EACpB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapPropertyType.js","names":["consola","mapPropertyType","dataType","type","subType","warn","undefined","inner","array"],"sources":["mapPropertyType.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 { PropertyTypeType } from \"@osdk/maker\";\nimport { consola } from \"consola\";\n\n/**\n * Result of mapping a gateway ObjectPropertyType to a maker PropertyTypeType.\n * `array` is true when the gateway type was {type: \"array\", subType: X}.\n */\nexport interface MappedPropertyType {\n type: PropertyTypeType;\n array?: boolean;\n}\n\n/**\n * Maps a gateway ObjectPropertyType (discriminated union with {type: string})\n * to a maker PropertyTypeType.\n *\n * Returns undefined for unsupported types (with a warning).\n */\nexport function mapPropertyType(\n dataType:
|
|
1
|
+
{"version":3,"file":"mapPropertyType.js","names":["consola","mapPropertyType","dataType","type","subType","warn","undefined","inner","array"],"sources":["mapPropertyType.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 } from \"@osdk/foundry.ontologies\";\nimport type { PropertyTypeType } from \"@osdk/maker\";\nimport { consola } from \"consola\";\n\n/**\n * Result of mapping a gateway ObjectPropertyType to a maker PropertyTypeType.\n * `array` is true when the gateway type was {type: \"array\", subType: X}.\n */\nexport interface MappedPropertyType {\n type: PropertyTypeType;\n array?: boolean;\n}\n\n/**\n * Maps a gateway ObjectPropertyType (discriminated union with {type: string})\n * to a maker PropertyTypeType.\n *\n * Returns undefined for unsupported types (with a warning).\n */\nexport function mapPropertyType(\n dataType: ObjectPropertyType,\n): MappedPropertyType | undefined {\n switch (dataType.type) {\n case \"string\":\n return { type: \"string\" };\n case \"integer\":\n return { type: \"integer\" };\n case \"boolean\":\n return { type: \"boolean\" };\n case \"double\":\n return { type: \"double\" };\n case \"float\":\n return { type: \"float\" };\n case \"long\":\n return { type: \"long\" };\n case \"short\":\n return { type: \"short\" };\n case \"byte\":\n return { type: \"byte\" };\n case \"date\":\n return { type: \"date\" };\n case \"timestamp\":\n return { type: \"timestamp\" };\n case \"decimal\":\n return { type: \"decimal\" };\n case \"attachment\":\n return { type: \"attachment\" };\n case \"geopoint\":\n return { type: \"geopoint\" };\n case \"geoshape\":\n return { type: \"geoshape\" };\n case \"mediaReference\":\n return { type: \"mediaReference\" };\n case \"geotimeSeriesReference\":\n return { type: \"geotimeSeries\" };\n case \"array\": {\n const subType = dataType.subType;\n if (!subType) {\n consola.warn(\"Array type missing subType, skipping\");\n return undefined;\n }\n const inner = mapPropertyType(subType);\n if (!inner) {\n return undefined;\n }\n return { type: inner.type, array: true };\n }\n // We don't support structs or markings here. It should have no influence on importing functionality\n default:\n return undefined;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,OAAO,QAAQ,SAAS;;AAEjC;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,QAA4B,EACI;EAChC,QAAQA,QAAQ,CAACC,IAAI;IACnB,KAAK,QAAQ;MACX,OAAO;QAAEA,IAAI,EAAE;MAAS,CAAC;IAC3B,KAAK,SAAS;MACZ,OAAO;QAAEA,IAAI,EAAE;MAAU,CAAC;IAC5B,KAAK,SAAS;MACZ,OAAO;QAAEA,IAAI,EAAE;MAAU,CAAC;IAC5B,KAAK,QAAQ;MACX,OAAO;QAAEA,IAAI,EAAE;MAAS,CAAC;IAC3B,KAAK,OAAO;MACV,OAAO;QAAEA,IAAI,EAAE;MAAQ,CAAC;IAC1B,KAAK,MAAM;MACT,OAAO;QAAEA,IAAI,EAAE;MAAO,CAAC;IACzB,KAAK,OAAO;MACV,OAAO;QAAEA,IAAI,EAAE;MAAQ,CAAC;IAC1B,KAAK,MAAM;MACT,OAAO;QAAEA,IAAI,EAAE;MAAO,CAAC;IACzB,KAAK,MAAM;MACT,OAAO;QAAEA,IAAI,EAAE;MAAO,CAAC;IACzB,KAAK,WAAW;MACd,OAAO;QAAEA,IAAI,EAAE;MAAY,CAAC;IAC9B,KAAK,SAAS;MACZ,OAAO;QAAEA,IAAI,EAAE;MAAU,CAAC;IAC5B,KAAK,YAAY;MACf,OAAO;QAAEA,IAAI,EAAE;MAAa,CAAC;IAC/B,KAAK,UAAU;MACb,OAAO;QAAEA,IAAI,EAAE;MAAW,CAAC;IAC7B,KAAK,UAAU;MACb,OAAO;QAAEA,IAAI,EAAE;MAAW,CAAC;IAC7B,KAAK,gBAAgB;MACnB,OAAO;QAAEA,IAAI,EAAE;MAAiB,CAAC;IACnC,KAAK,wBAAwB;MAC3B,OAAO;QAAEA,IAAI,EAAE;MAAgB,CAAC;IAClC,KAAK,OAAO;MAAE;QACZ,MAAMC,OAAO,GAAGF,QAAQ,CAACE,OAAO;QAChC,IAAI,CAACA,OAAO,EAAE;UACZJ,OAAO,CAACK,IAAI,CAAC,sCAAsC,CAAC;UACpD,OAAOC,SAAS;QAClB;QACA,MAAMC,KAAK,GAAGN,eAAe,CAACG,OAAO,CAAC;QACtC,IAAI,CAACG,KAAK,EAAE;UACV,OAAOD,SAAS;QAClB;QACA,OAAO;UAAEH,IAAI,EAAEI,KAAK,CAACJ,IAAI;UAAEK,KAAK,EAAE;QAAK,CAAC;MAC1C;IACA;IACA;MACE,OAAOF,SAAS;EACpB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeImportedOntology.js","names":["OntologyEntityTypeEnum","fs","path","convertActionType","convertInterfaceType","convertObjectType","convertSharedPropertyType","camel","fullCamel","withoutNamespace","TYPE_NAME_MAP","OBJECT_TYPE","ACTION_TYPE","INTERFACE_TYPE","SHARED_PROPERTY_TYPE","DIR_NAME_MAP","resolveVarNames","apiNames","shortNames","map","n","counts","Map","name","set","get","resolved","apiName","i","finalNames","used","count","push","writeImportedOntology","metadata","outputDir","codegenDir","resolve","dirName","Object","values","dirPath","join","existsSync","rmSync","recursive","force","mkdirSync","entries","_apiName","spt","sharedPropertyTypes","converted","entityType","entity","iface","interfaceTypes","objFull","objectTypes","action","actionTypes","varNames","e","topLevelExports","length","writeEntityFile","indexContent","indexPath","writeFileSync","flag","varName","typeName","entityJSON","JSON","stringify","replace","_","prefix","value","filePath"],"sources":["writeImportedOntology.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 * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { convertActionType } from \"./convertActionType.js\";\nimport { convertInterfaceType } from \"./convertInterfaceType.js\";\nimport { convertObjectType } from \"./convertObjectType.js\";\nimport { convertSharedPropertyType } from \"./convertSharedPropertyType.js\";\nimport { camel, fullCamel, withoutNamespace } from \"./utils.js\";\n\ninterface OntologyFullMetadata {\n objectTypes: Record<string, {\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 actionTypes: Record<string, {\n apiName: string;\n displayName?: string;\n description?: string;\n status: string;\n parameters: Record<string, {\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n required: boolean;\n }>;\n operations: Array<{ type: string; [key: string]: unknown }>;\n }>;\n interfaceTypes: Record<string, {\n apiName: string;\n displayName?: string;\n description?: string;\n extendsInterfaces: ReadonlyArray<string>;\n properties: Record<string, {\n apiName: string;\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n }>;\n links: Record<string, {\n apiName: string;\n displayName?: string;\n description?: string;\n cardinality: string;\n required: boolean;\n linkedEntityApiName: { type: string; apiName?: string };\n }>;\n }>;\n sharedPropertyTypes: Record<string, {\n apiName: string;\n displayName?: string;\n description?: string;\n dataType: { type: string; [key: string]: unknown };\n }>;\n}\n\nconst TYPE_NAME_MAP: Record<string, string> = {\n [OntologyEntityTypeEnum.OBJECT_TYPE]: \"ObjectType\",\n [OntologyEntityTypeEnum.ACTION_TYPE]: \"ActionType\",\n [OntologyEntityTypeEnum.INTERFACE_TYPE]: \"InterfaceType\",\n [OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: \"SharedPropertyType\",\n};\n\nconst DIR_NAME_MAP: Record<string, string> = {\n [OntologyEntityTypeEnum.OBJECT_TYPE]: \"object-types\",\n [OntologyEntityTypeEnum.ACTION_TYPE]: \"action-types\",\n [OntologyEntityTypeEnum.INTERFACE_TYPE]: \"interface-types\",\n [OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: \"shared-property-types\",\n};\n\ninterface EntityEntry {\n apiName: string;\n entityType: OntologyEntityTypeEnum;\n entity: unknown;\n}\n\n/**\n * Resolves unique variable/file names for a list of apiNames.\n *\n * First tries the short name (namespace stripped, camelCase).\n * If that collides, all colliding entries are escalated to the full\n * camelCase name (namespace included). Any remaining duplicates get\n * a numeric suffix.\n */\nexport function resolveVarNames(apiNames: string[]): string[] {\n const shortNames = apiNames.map(n => camel(withoutNamespace(n)));\n\n // Find which short names appear more than once\n const counts = new Map<string, number>();\n for (const name of shortNames) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n\n // Escalate conflicting names to fullCamel\n const resolved = apiNames.map((apiName, i) => {\n if (counts.get(shortNames[i])! > 1) {\n return fullCamel(apiName);\n }\n return shortNames[i];\n });\n\n // Handle any remaining duplicates with numeric suffixes\n const finalNames: string[] = [];\n const used = new Map<string, number>();\n for (const name of resolved) {\n const count = used.get(name) ?? 0;\n finalNames.push(count === 0 ? name : `${name}${count}`);\n used.set(name, count + 1);\n }\n\n return finalNames;\n}\n\n/**\n * Generates TypeScript files from OntologyFullMetadata, replicating\n * the pattern from maker's writeStaticObjects().\n *\n * Each entity gets its own file with wrapWithProxy, plus an index.ts\n * that re-exports everything.\n */\nexport function writeImportedOntology(\n metadata: OntologyFullMetadata,\n outputDir: string,\n): void {\n const codegenDir = path.resolve(outputDir, \"codegen\");\n\n // Clean and create directories\n for (const dirName of Object.values(DIR_NAME_MAP)) {\n const dirPath = path.join(codegenDir, dirName);\n if (fs.existsSync(dirPath)) {\n fs.rmSync(dirPath, { recursive: true, force: true });\n }\n fs.mkdirSync(dirPath, { recursive: true });\n }\n\n // Pass 1: Convert all entities\n const entries: EntityEntry[] = [];\n\n for (const [_apiName, spt] of Object.entries(metadata.sharedPropertyTypes)) {\n const converted = convertSharedPropertyType(spt);\n if (converted) {\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n entity: converted,\n });\n }\n }\n\n for (const [_apiName, iface] of Object.entries(metadata.interfaceTypes)) {\n const converted = convertInterfaceType(iface, metadata.interfaceTypes);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.INTERFACE_TYPE,\n entity: converted,\n });\n }\n\n for (const [_apiName, objFull] of Object.entries(metadata.objectTypes)) {\n const converted = convertObjectType(objFull);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.OBJECT_TYPE,\n entity: converted,\n });\n }\n\n for (const [_apiName, action] of Object.entries(metadata.actionTypes)) {\n const converted = convertActionType(action);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.ACTION_TYPE,\n entity: converted,\n });\n }\n\n // Pass 2: Resolve unique variable names across all entities\n const varNames = resolveVarNames(entries.map(e => e.apiName));\n\n // Pass 3: Write files with resolved names\n const topLevelExports: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n writeEntityFile(\n codegenDir,\n entries[i].entityType,\n entries[i].entity,\n varNames[i],\n topLevelExports,\n );\n }\n\n // Write index.ts\n if (topLevelExports.length > 0) {\n const indexContent = topLevelExports.join(\"\\n\") + \"\\n\";\n const indexPath = path.join(outputDir, \"index.ts\");\n fs.writeFileSync(indexPath, indexContent, { flag: \"w\" });\n }\n}\n\nfunction writeEntityFile(\n codegenDir: string,\n entityType: OntologyEntityTypeEnum,\n entity: unknown,\n varName: string,\n topLevelExports: string[],\n): void {\n const typeName = TYPE_NAME_MAP[entityType];\n const dirName = DIR_NAME_MAP[entityType];\n\n const entityJSON = JSON.stringify(entity, null, 2).replace(\n /(\"__type\"\\s*:\\s*)\"([^\"]*)\"/g,\n (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`,\n );\n\n const content =\n `import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';\nimport type { ${typeName} } from '@osdk/maker';\n\n/** @type {import('@osdk/maker').${typeName}} */\nconst ${varName}_base: ${typeName} = ${entityJSON} as unknown as ${typeName};\n\nexport const ${varName}: ${typeName} = wrapWithProxy(${varName}_base);\n`;\n\n const filePath = path.join(codegenDir, dirName, `${varName}.ts`);\n fs.writeFileSync(filePath, content, { flag: \"w\" });\n\n topLevelExports.push(\n `export { ${varName} } from \"./codegen/${dirName}/${varName}.js\";`,\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,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,oBAAoB,QAAQ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MAAMC,QAAQ,GAAG7E,IAAI,CAACwC,IAAI,CAACN,UAAU,EAAEE,OAAO,EAAE,GAAGgC,OAAO,KAAK,CAAC;EAChErE,EAAE,CAACmE,aAAa,CAACW,QAAQ,EAVvB;AACJ,gBAAgBR,QAAQ;AACxB;AACA,mCAAmCA,QAAQ;AAC3C,QAAQD,OAAO,UAAUC,QAAQ,MAAMC,UAAU,kBAAkBD,QAAQ;AAC3E;AACA,eAAeD,OAAO,KAAKC,QAAQ,oBAAoBD,OAAO;AAC9D,CAAC,EAGqC;IAAED,IAAI,EAAE;EAAI,CAAC,CAAC;EAElDN,eAAe,CAAC/B,IAAI,CAClB,YAAYsC,OAAO,sBAAsBhC,OAAO,IAAIgC,OAAO,OAC7D,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"writeImportedOntology.js","names":["OntologyEntityTypeEnum","fs","path","convertActionType","convertInterfaceType","convertObjectType","convertSharedPropertyType","camel","fullCamel","withoutNamespace","TYPE_NAME_MAP","OBJECT_TYPE","ACTION_TYPE","INTERFACE_TYPE","SHARED_PROPERTY_TYPE","DIR_NAME_MAP","resolveVarNames","apiNames","shortNames","map","n","counts","Map","name","set","get","resolved","apiName","i","finalNames","used","count","push","writeImportedOntology","metadata","outputDir","codegenDir","resolve","dirName","Object","values","dirPath","join","existsSync","rmSync","recursive","force","mkdirSync","entries","_apiName","spt","sharedPropertyTypes","converted","entityType","entity","iface","interfaceTypes","objFull","objectTypes","action","actionTypes","varNames","e","topLevelExports","length","writeEntityFile","indexContent","indexPath","writeFileSync","flag","varName","typeName","entityJSON","JSON","stringify","replace","_","prefix","value","filePath"],"sources":["writeImportedOntology.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 * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { OntologyEntityTypeEnum } from \"@osdk/maker\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { convertActionType } from \"./convertActionType.js\";\nimport { convertInterfaceType } from \"./convertInterfaceType.js\";\nimport { convertObjectType } from \"./convertObjectType.js\";\nimport { convertSharedPropertyType } from \"./convertSharedPropertyType.js\";\nimport { camel, fullCamel, withoutNamespace } from \"./utils.js\";\n\nconst TYPE_NAME_MAP: Record<string, string> = {\n [OntologyEntityTypeEnum.OBJECT_TYPE]: \"ObjectType\",\n [OntologyEntityTypeEnum.ACTION_TYPE]: \"ActionType\",\n [OntologyEntityTypeEnum.INTERFACE_TYPE]: \"InterfaceType\",\n [OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: \"SharedPropertyType\",\n};\n\nconst DIR_NAME_MAP: Record<string, string> = {\n [OntologyEntityTypeEnum.OBJECT_TYPE]: \"object-types\",\n [OntologyEntityTypeEnum.ACTION_TYPE]: \"action-types\",\n [OntologyEntityTypeEnum.INTERFACE_TYPE]: \"interface-types\",\n [OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: \"shared-property-types\",\n};\n\ninterface EntityEntry {\n apiName: string;\n entityType: OntologyEntityTypeEnum;\n entity: unknown;\n}\n\n/**\n * Resolves unique variable/file names for a list of apiNames.\n *\n * First tries the short name (namespace stripped, camelCase).\n * If that collides, all colliding entries are escalated to the full\n * camelCase name (namespace included). Any remaining duplicates get\n * a numeric suffix.\n */\nexport function resolveVarNames(apiNames: string[]): string[] {\n const shortNames = apiNames.map(n => camel(withoutNamespace(n)));\n\n // Find which short names appear more than once\n const counts = new Map<string, number>();\n for (const name of shortNames) {\n counts.set(name, (counts.get(name) ?? 0) + 1);\n }\n\n // Escalate conflicting names to fullCamel\n const resolved = apiNames.map((apiName, i) => {\n if (counts.get(shortNames[i])! > 1) {\n return fullCamel(apiName);\n }\n return shortNames[i];\n });\n\n // Handle any remaining duplicates with numeric suffixes\n const finalNames: string[] = [];\n const used = new Map<string, number>();\n for (const name of resolved) {\n const count = used.get(name) ?? 0;\n finalNames.push(count === 0 ? name : `${name}${count}`);\n used.set(name, count + 1);\n }\n\n return finalNames;\n}\n\n/**\n * Generates TypeScript files from OntologyFullMetadata, replicating\n * the pattern from maker's writeStaticObjects().\n *\n * Each entity gets its own file with wrapWithProxy, plus an index.ts\n * that re-exports everything.\n */\nexport function writeImportedOntology(\n metadata: Ontologies.OntologyFullMetadata,\n outputDir: string,\n): void {\n const codegenDir = path.resolve(outputDir, \"codegen\");\n\n // Clean and create directories\n for (const dirName of Object.values(DIR_NAME_MAP)) {\n const dirPath = path.join(codegenDir, dirName);\n if (fs.existsSync(dirPath)) {\n fs.rmSync(dirPath, { recursive: true, force: true });\n }\n fs.mkdirSync(dirPath, { recursive: true });\n }\n\n // Pass 1: Convert all entities\n const entries: EntityEntry[] = [];\n\n for (const [_apiName, spt] of Object.entries(metadata.sharedPropertyTypes)) {\n const converted = convertSharedPropertyType(spt);\n if (converted) {\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n entity: converted,\n });\n }\n }\n\n for (const [_apiName, iface] of Object.entries(metadata.interfaceTypes)) {\n const converted = convertInterfaceType(iface, metadata.interfaceTypes);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.INTERFACE_TYPE,\n entity: converted,\n });\n }\n\n for (const [_apiName, objFull] of Object.entries(metadata.objectTypes)) {\n const converted = convertObjectType(objFull);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.OBJECT_TYPE,\n entity: converted,\n });\n }\n\n for (const [_apiName, action] of Object.entries(metadata.actionTypes)) {\n const converted = convertActionType(action);\n entries.push({\n apiName: converted.apiName,\n entityType: OntologyEntityTypeEnum.ACTION_TYPE,\n entity: converted,\n });\n }\n\n // Pass 2: Resolve unique variable names across all entities\n const varNames = resolveVarNames(entries.map(e => e.apiName));\n\n // Pass 3: Write files with resolved names\n const topLevelExports: string[] = [];\n for (let i = 0; i < entries.length; i++) {\n writeEntityFile(\n codegenDir,\n entries[i].entityType,\n entries[i].entity,\n varNames[i],\n topLevelExports,\n );\n }\n\n // Write index.ts\n if (topLevelExports.length > 0) {\n const indexContent = topLevelExports.join(\"\\n\") + \"\\n\";\n const indexPath = path.join(outputDir, \"index.ts\");\n fs.writeFileSync(indexPath, indexContent, { flag: \"w\" });\n }\n}\n\nfunction writeEntityFile(\n codegenDir: string,\n entityType: OntologyEntityTypeEnum,\n entity: unknown,\n varName: string,\n topLevelExports: string[],\n): void {\n const typeName = TYPE_NAME_MAP[entityType];\n const dirName = DIR_NAME_MAP[entityType];\n\n const entityJSON = JSON.stringify(entity, null, 2).replace(\n /(\"__type\"\\s*:\\s*)\"([^\"]*)\"/g,\n (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`,\n );\n\n const content =\n `import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';\nimport type { ${typeName} } from '@osdk/maker';\n\n/** @type {import('@osdk/maker').${typeName}} */\nconst ${varName}_base: ${typeName} = ${entityJSON} as unknown as ${typeName};\n\nexport const ${varName}: ${typeName} = wrapWithProxy(${varName}_base);\n`;\n\n const filePath = path.join(codegenDir, dirName, `${varName}.ts`);\n fs.writeFileSync(filePath, content, { flag: \"w\" });\n\n topLevelExports.push(\n `export { ${varName} } from \"./codegen/${dirName}/${varName}.js\";`,\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,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC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