@osdk/maker 0.8.0-beta.4 → 0.8.0-beta.6
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
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @osdk/maker
|
|
2
2
|
|
|
3
|
+
## 0.8.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1252d94: ESM Only
|
|
8
|
+
- 465660b: Fix double namespacing bug.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [dc25fb4]
|
|
13
|
+
- Updated dependencies [dc25fb4]
|
|
14
|
+
- Updated dependencies [1252d94]
|
|
15
|
+
- Updated dependencies [56df85a]
|
|
16
|
+
- @osdk/api@2.0.0-beta.10
|
|
17
|
+
|
|
18
|
+
## 0.8.0-beta.5
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [b946e00]
|
|
23
|
+
- @osdk/api@2.0.0-beta.9
|
|
24
|
+
|
|
3
25
|
## 0.8.0-beta.4
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/build/browser/index.js
CHANGED
|
@@ -141,6 +141,8 @@ function defineSharedPropertyType(opts) {
|
|
|
141
141
|
return ontologyDefinition.sharedPropertyTypes[apiName] = {
|
|
142
142
|
...opts,
|
|
143
143
|
apiName,
|
|
144
|
+
displayName: opts.displayName ?? opts.apiName,
|
|
145
|
+
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
144
146
|
typeClasses: opts.typeClasses ?? defaultTypeClasses
|
|
145
147
|
};
|
|
146
148
|
}
|
|
@@ -188,7 +190,7 @@ function defineInterface(opts) {
|
|
|
188
190
|
active: {}
|
|
189
191
|
}
|
|
190
192
|
};
|
|
191
|
-
return ontologyDefinition.interfaceTypes[
|
|
193
|
+
return ontologyDefinition.interfaceTypes[apiName] = a;
|
|
192
194
|
}
|
|
193
195
|
function isSimpleType(v) {
|
|
194
196
|
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
@@ -197,7 +199,7 @@ function isSimpleType(v) {
|
|
|
197
199
|
// src/cli/main.ts
|
|
198
200
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
199
201
|
async function main(args = process.argv) {
|
|
200
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.8.0-beta.
|
|
202
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.8.0-beta.6").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
201
203
|
input: {
|
|
202
204
|
alias: "i",
|
|
203
205
|
describe: "Input file",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/defineOntology.ts","../../src/api/defineSpt.ts","../../src/api/defineInterface.ts","../../src/cli/main.ts","../../src/api/defineInterfaceLinkConstraint.ts"],"names":["invariant","apiName"],"mappings":";;;;;;;;;;AAiBO,IAAI,kBAAA,CAAA;AAGJ,IAAI,SAAA,CAAA;AACX,eAAsB,cAAA,CAAe,IAAI,IAAM,EAAA;AAC7C,EAAY,SAAA,GAAA,EAAA,CAAA;AACZ,EAAqB,kBAAA,GAAA;AAAA,IACnB,aAAa,EAAC;AAAA,IACd,aAAa,EAAC;AAAA,IACd,YAAY,EAAC;AAAA,IACb,gBAAgB,EAAC;AAAA,IACjB,qBAAqB,EAAC;AAAA,GACxB,CAAA;AACA,EAAI,IAAA;AACF,IAAA,MAAM,IAAK,EAAA,CAAA;AAAA,WACJ,CAAG,EAAA;AAEV,IAAQ,OAAA,CAAA,KAAA,CAAM,8DAA8D,CAAC,CAAA,CAAA;AAC7E,IAAM,MAAA,CAAA,CAAA;AAAA,GACR;AACA,EAAA,OAAO,sBAAsB,kBAAk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AAe,WAAe,IAAA,OAAA;AAAA,GAC7C,CAAA;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport let ontologyDefinition;\n\n/** @internal */\nexport let namespace;\nexport async function defineOntology(ns, body) {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {}\n };\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected error while processing the body of the ontology\", e);\n throw e;\n }\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertToWireOntology(ontology) {\n return {\n sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {\n sharedPropertyType: convertSpt(spt)\n }])),\n interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType)\n }];\n })),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {}\n }\n };\n}\nfunction convertInterface(interfaceType) {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: []\n };\n}\nexport function dumpOntologyFullMetadata() {\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertSpt({\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses\n}) {\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description\n },\n type: array ? {\n type: \"array\",\n array: {\n subtype: convertType(type)\n }\n } : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: undefined,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: undefined\n };\n}\nfunction convertType(type) {\n switch (type) {\n case \"marking\":\n return {\n type,\n [type]: {\n markingType: \"MANDATORY\"\n }\n };\n case \"geopoint\":\n return {\n type: \"geohash\",\n geohash: {}\n };\n case \"decimal\":\n return {\n type,\n [type]: {\n precision: undefined,\n scale: undefined\n }\n };\n case \"string\":\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true\n }\n };\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper(type) {\n return {\n type,\n [type]: {}\n }; // any cast to match conditional return type\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\"\n}, {\n kind: \"render_hint\",\n name: \"SORTABLE\"\n}];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n typeClasses: opts.typeClasses ?? defaultTypeClasses\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n !isSimpleType(type) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false\n });\n return [apiName, spt];\n } else {\n !(namespace + apiName === type.apiName) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({\n key: apiName,\n apiName: type.apiName\n })}`) : invariant(false) : void 0;\n return [apiName, type];\n }\n }));\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined ? {\n type: \"blueprint\",\n blueprint: {\n color: opts.icon.color,\n locator: opts.icon.locator\n }\n } : undefined\n },\n extendsInterfaces: [],\n links: [],\n properties,\n status: {\n type: \"active\",\n active: {}\n }\n };\n return ontologyDefinition.interfaceTypes[namespace + apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\" || v === \"date\" || v === \"decimal\" || v === \"double\" || v === \"float\" || v === \"geopoint\" || v === \"geoshape\" || v === \"integer\" || v === \"long\" || v === \"marking\" || v === \"short\" || v === \"string\" || v === \"timestamp\";\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineInterface } from \"../api/defineInterface.js\";\nimport { defineLink } from \"../api/defineLink.js\";\nimport { defineObject } from \"../api/defineObject.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { defineSharedPropertyType } from \"../api/defineSpt.js\";\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nexport default async function main(args = process.argv) {\n const commandLineOpts = await yargs(hideBin(args)).version(process.env.PACKAGE_VERSION ?? \"\").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\"\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve\n }\n }).parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== \".\" ? commandLineOpts.apiNamespace + \".\" : commandLineOpts.apiNamespace;\n !(apiNamespace.length < 1024) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is too long.\") : invariant(false) : void 0;\n !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\") : invariant(false) : void 0;\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n const ontology = await loadOntology(commandLineOpts.input, apiNamespace);\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));\n}\nasync function loadOntologyViaJiti(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const jiti_ = await import(\"jiti\");\n const jiti = jiti_.default(process.cwd(), {\n debug: true\n });\n return defineOntology(\"\", async () => await jiti(input));\n}\nasync function loadOntologyViaTsNode(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const tsNode = await import(\"ts-node\");\n const tsNodeService = tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n target: \"esnext\"\n },\n esm: true\n });\n tsNodeService.enabled(true);\n const q = await import(input);\n return q;\n}\nasync function loadOntology(input, apiNamespace) {\n // Object.assign(globalThis, {\n // defineInterface,\n // defineLink,\n // defineObject,\n // defineSharedPropertyType,\n // });\n\n const q = await defineOntology(apiNamespace, async () => await import(input));\n return q;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n !(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\" ? withDefaults({\n apiName: namespace + meta\n }) : withDefaults(meta);\n}\nfunction withDefaults({\n apiName,\n description,\n displayName\n}) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName\n };\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/defineOntology.ts","../../src/api/defineSpt.ts","../../src/api/defineInterface.ts","../../src/cli/main.ts","../../src/api/defineInterfaceLinkConstraint.ts"],"names":["invariant","apiName"],"mappings":";;;;;;;;;;AAiBO,IAAI,kBAAA,CAAA;AAGJ,IAAI,SAAA,CAAA;AACX,eAAsB,cA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AAAA,IACN,aAAe,EAAA,OAAO,CAAM,KAAA,QAAA,GAAW,IAAI,CAAE,CAAA,OAAA;AAAA,GAC/C,CAAA;AACF,CAAA;AACA,SAAS,YAAY,IAAM,EAAA;AACzB,EAAO,OAAA,OAAO,IAAS,KAAA,QAAA,GAAW,YAAa,CAAA;AAAA,IAC7C,SAAS,SAAY,GAAA,IAAA;AAAA,GACtB,CAAI,GAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AACxB,CAAA;AACA,SAAS,YAAa,CAAA;AAAA,EACpB,OAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AACF,CAAG,EAAA;AACD,EAAO,OAAA;AAAA,IACL,SAAS,SAAY,GAAA,OAAA;AAAA,IACrB,aAAa,WAAe,IAAA,OAAA;AAAA,IAC5B,WAAA,EAAa,eAAe,WAAe,IAAA,OAAA;AAAA,GAC7C,CAAA;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport let ontologyDefinition;\n\n/** @internal */\nexport let namespace;\nexport async function defineOntology(ns, body) {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {}\n };\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected error while processing the body of the ontology\", e);\n throw e;\n }\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertToWireOntology(ontology) {\n return {\n sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {\n sharedPropertyType: convertSpt(spt)\n }])),\n interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType)\n }];\n })),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {}\n }\n };\n}\nfunction convertInterface(interfaceType) {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: []\n };\n}\nexport function dumpOntologyFullMetadata() {\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertSpt({\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses\n}) {\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description\n },\n type: array ? {\n type: \"array\",\n array: {\n subtype: convertType(type)\n }\n } : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: undefined,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: undefined\n };\n}\nfunction convertType(type) {\n switch (type) {\n case \"marking\":\n return {\n type,\n [type]: {\n markingType: \"MANDATORY\"\n }\n };\n case \"geopoint\":\n return {\n type: \"geohash\",\n geohash: {}\n };\n case \"decimal\":\n return {\n type,\n [type]: {\n precision: undefined,\n scale: undefined\n }\n };\n case \"string\":\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true\n }\n };\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper(type) {\n return {\n type,\n [type]: {}\n }; // any cast to match conditional return type\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\"\n}, {\n kind: \"render_hint\",\n name: \"SORTABLE\"\n}];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n displayName: opts.displayName ?? opts.apiName,\n // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: opts.typeClasses ?? defaultTypeClasses\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n !isSimpleType(type) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false\n });\n return [apiName, spt];\n } else {\n !(namespace + apiName === type.apiName) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({\n key: apiName,\n apiName: type.apiName\n })}`) : invariant(false) : void 0;\n return [apiName, type];\n }\n }));\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined ? {\n type: \"blueprint\",\n blueprint: {\n color: opts.icon.color,\n locator: opts.icon.locator\n }\n } : undefined\n },\n extendsInterfaces: [],\n links: [],\n properties,\n status: {\n type: \"active\",\n active: {}\n }\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\" || v === \"date\" || v === \"decimal\" || v === \"double\" || v === \"float\" || v === \"geopoint\" || v === \"geoshape\" || v === \"integer\" || v === \"long\" || v === \"marking\" || v === \"short\" || v === \"string\" || v === \"timestamp\";\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineInterface } from \"../api/defineInterface.js\";\nimport { defineLink } from \"../api/defineLink.js\";\nimport { defineObject } from \"../api/defineObject.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { defineSharedPropertyType } from \"../api/defineSpt.js\";\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nexport default async function main(args = process.argv) {\n const commandLineOpts = await yargs(hideBin(args)).version(process.env.PACKAGE_VERSION ?? \"\").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\"\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve\n }\n }).parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== \".\" ? commandLineOpts.apiNamespace + \".\" : commandLineOpts.apiNamespace;\n !(apiNamespace.length < 1024) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is too long.\") : invariant(false) : void 0;\n !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\") : invariant(false) : void 0;\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n const ontology = await loadOntology(commandLineOpts.input, apiNamespace);\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));\n}\nasync function loadOntologyViaJiti(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const jiti_ = await import(\"jiti\");\n const jiti = jiti_.default(process.cwd(), {\n debug: true\n });\n return defineOntology(\"\", async () => await jiti(input));\n}\nasync function loadOntologyViaTsNode(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const tsNode = await import(\"ts-node\");\n const tsNodeService = tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n target: \"esnext\"\n },\n esm: true\n });\n tsNodeService.enabled(true);\n const q = await import(input);\n return q;\n}\nasync function loadOntology(input, apiNamespace) {\n // Object.assign(globalThis, {\n // defineInterface,\n // defineLink,\n // defineObject,\n // defineSharedPropertyType,\n // });\n\n const q = await defineOntology(apiNamespace, async () => await import(input));\n return q;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n !(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\" ? withDefaults({\n apiName: namespace + meta\n }) : withDefaults(meta);\n}\nfunction withDefaults({\n apiName,\n description,\n displayName\n}) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName\n };\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineSpt.d.ts","sourceRoot":"","sources":["../../../src/api/defineSpt.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOvE,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,+BAA+B,CAAC;CACjD,GACA,kBAAkB,
|
|
1
|
+
{"version":3,"file":"defineSpt.d.ts","sourceRoot":"","sources":["../../../src/api/defineSpt.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOvE,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,+BAA+B,CAAC;CACjD,GACA,kBAAkB,CAapB"}
|
package/build/esm/index.js
CHANGED
|
@@ -141,6 +141,8 @@ function defineSharedPropertyType(opts) {
|
|
|
141
141
|
return ontologyDefinition.sharedPropertyTypes[apiName] = {
|
|
142
142
|
...opts,
|
|
143
143
|
apiName,
|
|
144
|
+
displayName: opts.displayName ?? opts.apiName,
|
|
145
|
+
// This way the non-namespaced api name is the display name (maybe not ideal)
|
|
144
146
|
typeClasses: opts.typeClasses ?? defaultTypeClasses
|
|
145
147
|
};
|
|
146
148
|
}
|
|
@@ -188,7 +190,7 @@ function defineInterface(opts) {
|
|
|
188
190
|
active: {}
|
|
189
191
|
}
|
|
190
192
|
};
|
|
191
|
-
return ontologyDefinition.interfaceTypes[
|
|
193
|
+
return ontologyDefinition.interfaceTypes[apiName] = a;
|
|
192
194
|
}
|
|
193
195
|
function isSimpleType(v) {
|
|
194
196
|
return v === "boolean" || v === "byte" || v === "date" || v === "decimal" || v === "double" || v === "float" || v === "geopoint" || v === "geoshape" || v === "integer" || v === "long" || v === "marking" || v === "short" || v === "string" || v === "timestamp";
|
|
@@ -197,7 +199,7 @@ function isSimpleType(v) {
|
|
|
197
199
|
// src/cli/main.ts
|
|
198
200
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
199
201
|
async function main(args = process.argv) {
|
|
200
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.8.0-beta.
|
|
202
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.8.0-beta.6").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
201
203
|
input: {
|
|
202
204
|
alias: "i",
|
|
203
205
|
describe: "Input file",
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/defineOntology.ts","../../src/api/defineSpt.ts","../../src/api/defineInterface.ts","../../src/cli/main.ts","../../src/api/defineInterfaceLinkConstraint.ts"],"names":["invariant","apiName"],"mappings":";;;;;;;;;;AAiBO,IAAI,kBAAA,CAAA;AAGJ,IAAI,SAAA,CAAA;AACX,eAAsB,cAAA,CAAe,IAAI,IAAM,EAAA;AAC7C,EAAY,SAAA,GAAA,EAAA,CAAA;AACZ,EAAqB,kBAAA,GAAA;AAAA,IACnB,aAAa,EAAC;AAAA,IACd,aAAa,EAAC;AAAA,IACd,YAAY,EAAC;AAAA,IACb,gBAAgB,EAAC;AAAA,IACjB,qBAAqB,EAAC;AAAA,GACxB,CAAA;AACA,EAAI,IAAA;AACF,IAAA,MAAM,IAAK,EAAA,CAAA;AAAA,WACJ,CAAG,EAAA;AAEV,IAAQ,OAAA,CAAA,KAAA,CAAM,8DAA8D,CAAC,CAAA,CAAA;AAC7E,IAAM,MAAA,CAAA,CAAA;AAAA,GACR;AACA,EAAA,OAAO,sBAAsB,kBAAkB,CAAA,CAAA;AACjD,CAAA;AACA,SAAS,sBAAsB,QAAU,EAAA;AACvC,EAAO,OAAA;AAAA,IACL,mBAAqB,EAAA,MAAA,CAAO,WAAY,CAAA,MAAA,CAAO,QAAQ,QAAS,CAAA,mBAAmB,CAAE,CAAA,GAAA,CAAI,CAAC,CAAC,OAAA,EAAS,GAAG,CAAA,KAAM,CAAC,OAAS,EAAA;AAAA,MACrH,kBAAA,EAAoB,WAAW,GAAG,CAAA;AAAA,KACnC,CAAC,CAAC,CAAA;AAAA,IACH,cAAgB,EAAA,MAAA,CAAO,WAAY,CAAA,MAAA,CAAO,OAAQ,CAAA,QAAA,CAAS,cAAc,CAAA,CAAE,GAAI,CAAA,CAAC,CAAC,OAAA,EAAS,aAAa,CAAM,KAAA;AAC3G,MAAA,OAAO,CAAC,OAAS,EAA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AAA,MAAA,IAAU,QAAQ,KAAK,CAAA;AAAA,IACjE,QAAU,EAAA,YAAA;AAAA,IACV,QAAU,EAAA,IAAA;AAAA;AAAA,GACX,CAAA,CAAA;AACH,CAAA;AACA,SAAS,cAAc,CAAG,EAAA;AACxB,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,eAAA;AAAA,IACN,aAAe,EAAA,OAAO,CAAM,KAAA,QAAA,GAAW,IAAI,CAAE,CAAA,OAAA;AAAA,GAC/C,CAAA;AACF,CAAA;AACA,SAAS,YAAY,IAAM,EAAA;AACzB,EAAO,OAAA,OAAO,IAAS,KAAA,QAAA,GAAW,YAAa,CAAA;AAAA,IAC7C,SAAS,SAAY,GAAA,IAAA;AAAA,GACtB,CAAI,GAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AACxB,CAAA;AACA,SAAS,YAAa,CAAA;AAAA,EACpB,OAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AACF,CAAG,EAAA;AACD,EAAO,OAAA;AAAA,IACL,SAAS,SAAY,GAAA,OAAA;AAAA,IACrB,aAAa,WAAe,IAAA,OAAA;AAAA,IAC5B,WAAA,EAAa,eAAe,WAAe,IAAA,OAAA;AAAA,GAC7C,CAAA;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport let ontologyDefinition;\n\n/** @internal */\nexport let namespace;\nexport async function defineOntology(ns, body) {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {}\n };\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected error while processing the body of the ontology\", e);\n throw e;\n }\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertToWireOntology(ontology) {\n return {\n sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {\n sharedPropertyType: convertSpt(spt)\n }])),\n interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType)\n }];\n })),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {}\n }\n };\n}\nfunction convertInterface(interfaceType) {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: []\n };\n}\nexport function dumpOntologyFullMetadata() {\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertSpt({\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses\n}) {\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description\n },\n type: array ? {\n type: \"array\",\n array: {\n subtype: convertType(type)\n }\n } : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: undefined,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: undefined\n };\n}\nfunction convertType(type) {\n switch (type) {\n case \"marking\":\n return {\n type,\n [type]: {\n markingType: \"MANDATORY\"\n }\n };\n case \"geopoint\":\n return {\n type: \"geohash\",\n geohash: {}\n };\n case \"decimal\":\n return {\n type,\n [type]: {\n precision: undefined,\n scale: undefined\n }\n };\n case \"string\":\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true\n }\n };\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper(type) {\n return {\n type,\n [type]: {}\n }; // any cast to match conditional return type\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\"\n}, {\n kind: \"render_hint\",\n name: \"SORTABLE\"\n}];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n typeClasses: opts.typeClasses ?? defaultTypeClasses\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n !isSimpleType(type) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false\n });\n return [apiName, spt];\n } else {\n !(namespace + apiName === type.apiName) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({\n key: apiName,\n apiName: type.apiName\n })}`) : invariant(false) : void 0;\n return [apiName, type];\n }\n }));\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined ? {\n type: \"blueprint\",\n blueprint: {\n color: opts.icon.color,\n locator: opts.icon.locator\n }\n } : undefined\n },\n extendsInterfaces: [],\n links: [],\n properties,\n status: {\n type: \"active\",\n active: {}\n }\n };\n return ontologyDefinition.interfaceTypes[namespace + apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\" || v === \"date\" || v === \"decimal\" || v === \"double\" || v === \"float\" || v === \"geopoint\" || v === \"geoshape\" || v === \"integer\" || v === \"long\" || v === \"marking\" || v === \"short\" || v === \"string\" || v === \"timestamp\";\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineInterface } from \"../api/defineInterface.js\";\nimport { defineLink } from \"../api/defineLink.js\";\nimport { defineObject } from \"../api/defineObject.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { defineSharedPropertyType } from \"../api/defineSpt.js\";\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nexport default async function main(args = process.argv) {\n const commandLineOpts = await yargs(hideBin(args)).version(process.env.PACKAGE_VERSION ?? \"\").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\"\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve\n }\n }).parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== \".\" ? commandLineOpts.apiNamespace + \".\" : commandLineOpts.apiNamespace;\n !(apiNamespace.length < 1024) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is too long.\") : invariant(false) : void 0;\n !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\") : invariant(false) : void 0;\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n const ontology = await loadOntology(commandLineOpts.input, apiNamespace);\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));\n}\nasync function loadOntologyViaJiti(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const jiti_ = await import(\"jiti\");\n const jiti = jiti_.default(process.cwd(), {\n debug: true\n });\n return defineOntology(\"\", async () => await jiti(input));\n}\nasync function loadOntologyViaTsNode(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const tsNode = await import(\"ts-node\");\n const tsNodeService = tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n target: \"esnext\"\n },\n esm: true\n });\n tsNodeService.enabled(true);\n const q = await import(input);\n return q;\n}\nasync function loadOntology(input, apiNamespace) {\n // Object.assign(globalThis, {\n // defineInterface,\n // defineLink,\n // defineObject,\n // defineSharedPropertyType,\n // });\n\n const q = await defineOntology(apiNamespace, async () => await import(input));\n return q;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n !(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\" ? withDefaults({\n apiName: namespace + meta\n }) : withDefaults(meta);\n}\nfunction withDefaults({\n apiName,\n description,\n displayName\n}) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName\n };\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/defineOntology.ts","../../src/api/defineSpt.ts","../../src/api/defineInterface.ts","../../src/cli/main.ts","../../src/api/defineInterfaceLinkConstraint.ts"],"names":["invariant","apiName"],"mappings":";;;;;;;;;;AAiBO,IAAI,kBAAA,CAAA;AAGJ,IAAI,SAAA,CAAA;AACX,eAAsB,cAAA,CAAe,IAAI,IAAM,EAAA;AAC7C,EAAY,SAAA,GAAA,EAAA,CAAA;AACZ,EAAqB,kBAAA,GAAA;AAAA,IACnB,aAAa,EAAC;AAAA,IACd,aAAa,EAAC;AAAA,IACd,YAAY,EAAC;AAAA,IACb,gBAAgB,EAAC;AAAA,IACjB,qBAAqB,EAAC;AAAA,GACxB,CAAA;AACA,EAAI,IAAA;AACF,IAAA,MAAM,IAAK,EAAA,CAAA;AAAA,WACJ,CAAG,EAAA;AAEV,IAAQ,OAAA,CAAA,KAAA,CAAM,8DAA8D,CAAC,CAAA,CAAA;AAC7E,IAAM,MAAA,CAAA,CAAA;AAAA,GACR;AACA,EAAA,OAAO,sBAAsB,kBAAkB,CAAA,CAAA;AACjD,CAAA;AACA,SAAS,sBAAsB,QAAU,EAAA;AACvC,EAAO,OA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IAAA,OAAA;AAAA,GAC7C,CAAA;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @internal */\nexport let ontologyDefinition;\n\n/** @internal */\nexport let namespace;\nexport async function defineOntology(ns, body) {\n namespace = ns;\n ontologyDefinition = {\n actionTypes: {},\n objectTypes: {},\n queryTypes: {},\n interfaceTypes: {},\n sharedPropertyTypes: {}\n };\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\"Unexpected error while processing the body of the ontology\", e);\n throw e;\n }\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertToWireOntology(ontology) {\n return {\n sharedPropertyTypes: Object.fromEntries(Object.entries(ontology.sharedPropertyTypes).map(([apiName, spt]) => [apiName, {\n sharedPropertyType: convertSpt(spt)\n }])),\n interfaceTypes: Object.fromEntries(Object.entries(ontology.interfaceTypes).map(([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType)\n }];\n })),\n blockPermissionInformation: {\n actionTypes: {},\n linkTypes: {},\n objectTypes: {}\n }\n };\n}\nfunction convertInterface(interfaceType) {\n return {\n ...interfaceType,\n properties: Object.values(interfaceType.properties).map(spt => convertSpt(spt)),\n // these are omitted from our internal types but we need to re-add them for the final json\n allExtendsInterfaces: [],\n allLinks: [],\n allProperties: []\n };\n}\nexport function dumpOntologyFullMetadata() {\n return convertToWireOntology(ontologyDefinition);\n}\nfunction convertSpt({\n type,\n array,\n description,\n apiName,\n displayName,\n gothamMapping,\n typeClasses\n}) {\n return {\n apiName,\n displayMetadata: {\n displayName: displayName ?? apiName,\n visibility: \"NORMAL\",\n description\n },\n type: array ? {\n type: \"array\",\n array: {\n subtype: convertType(type)\n }\n } : convertType(type),\n aliases: [],\n baseFormatter: undefined,\n dataConstraints: undefined,\n gothamMapping: gothamMapping,\n indexedForSearch: true,\n provenance: undefined,\n typeClasses: typeClasses ?? [],\n valueType: undefined\n };\n}\nfunction convertType(type) {\n switch (type) {\n case \"marking\":\n return {\n type,\n [type]: {\n markingType: \"MANDATORY\"\n }\n };\n case \"geopoint\":\n return {\n type: \"geohash\",\n geohash: {}\n };\n case \"decimal\":\n return {\n type,\n [type]: {\n precision: undefined,\n scale: undefined\n }\n };\n case \"string\":\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsExactMatching: true\n }\n };\n default:\n // use helper function to distribute `type` properly\n return distributeTypeHelper(type);\n }\n}\n\n/**\n * Helper function to avoid duplication. Makes the types match properly with the correct\n * behavior without needing to switch on type.\n * @param type\n * @returns\n */\nfunction distributeTypeHelper(type) {\n return {\n type,\n [type]: {}\n }; // any cast to match conditional return type\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nconst defaultTypeClasses = [{\n kind: \"render_hint\",\n name: \"SELECTABLE\"\n}, {\n kind: \"render_hint\",\n name: \"SORTABLE\"\n}];\nexport function defineSharedPropertyType(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.sharedPropertyTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Shared property type ${apiName} already exists`) : invariant(false) : void 0;\n return ontologyDefinition.sharedPropertyTypes[apiName] = {\n ...opts,\n apiName,\n displayName: opts.displayName ?? opts.apiName,\n // This way the non-namespaced api name is the display name (maybe not ideal)\n typeClasses: opts.typeClasses ?? defaultTypeClasses\n };\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace, ontologyDefinition } from \"./defineOntology.js\";\nimport { defineSharedPropertyType } from \"./defineSpt.js\";\nexport function defineInterface(opts) {\n const apiName = namespace + opts.apiName;\n !(ontologyDefinition.interfaceTypes[apiName] === undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Interface ${apiName} already exists`) : invariant(false) : void 0;\n const properties = Object.fromEntries(Object.entries(opts.properties ?? {}).map(([apiName, type]) => {\n if (typeof type === \"string\") {\n !isSimpleType(type) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Invalid data type ${type} for property ${apiName} on InterfaceType ${apiName}`) : invariant(false) : void 0;\n const spt = defineSharedPropertyType({\n apiName,\n displayName: apiName,\n type,\n array: false\n });\n return [apiName, spt];\n } else {\n !(namespace + apiName === type.apiName) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `property key and it's apiName must be identical. ${JSON.stringify({\n key: apiName,\n apiName: type.apiName\n })}`) : invariant(false) : void 0;\n return [apiName, type];\n }\n }));\n const a = {\n apiName,\n displayMetadata: {\n displayName: opts.displayName ?? opts.apiName,\n description: opts.description ?? opts.displayName ?? opts.apiName,\n icon: opts.icon !== undefined ? {\n type: \"blueprint\",\n blueprint: {\n color: opts.icon.color,\n locator: opts.icon.locator\n }\n } : undefined\n },\n extendsInterfaces: [],\n links: [],\n properties,\n status: {\n type: \"active\",\n active: {}\n }\n };\n return ontologyDefinition.interfaceTypes[apiName] = a;\n}\nfunction isSimpleType(v) {\n return v === \"boolean\" || v === \"byte\" || v === \"date\" || v === \"decimal\" || v === \"double\" || v === \"float\" || v === \"geopoint\" || v === \"geoshape\" || v === \"integer\" || v === \"long\" || v === \"marking\" || v === \"short\" || v === \"string\" || v === \"timestamp\";\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineInterface } from \"../api/defineInterface.js\";\nimport { defineLink } from \"../api/defineLink.js\";\nimport { defineObject } from \"../api/defineObject.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { defineSharedPropertyType } from \"../api/defineSpt.js\";\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nexport default async function main(args = process.argv) {\n const commandLineOpts = await yargs(hideBin(args)).version(process.env.PACKAGE_VERSION ?? \"\").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\"\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve\n }\n }).parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== \".\" ? commandLineOpts.apiNamespace + \".\" : commandLineOpts.apiNamespace;\n !(apiNamespace.length < 1024) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is too long.\") : invariant(false) : void 0;\n !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\") : invariant(false) : void 0;\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n const ontology = await loadOntology(commandLineOpts.input, apiNamespace);\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(commandLineOpts.output, JSON.stringify(ontology, null, 2));\n}\nasync function loadOntologyViaJiti(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const jiti_ = await import(\"jiti\");\n const jiti = jiti_.default(process.cwd(), {\n debug: true\n });\n return defineOntology(\"\", async () => await jiti(input));\n}\nasync function loadOntologyViaTsNode(input) {\n Object.assign(globalThis, {\n defineInterface,\n defineLink,\n defineObject,\n defineSharedPropertyType\n });\n const tsNode = await import(\"ts-node\");\n const tsNodeService = tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n target: \"esnext\"\n },\n esm: true\n });\n tsNodeService.enabled(true);\n const q = await import(input);\n return q;\n}\nasync function loadOntology(input, apiNamespace) {\n // Object.assign(globalThis, {\n // defineInterface,\n // defineLink,\n // defineObject,\n // defineSharedPropertyType,\n // });\n\n const q = await defineOntology(apiNamespace, async () => await import(input));\n return q;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { namespace } from \"./defineOntology.js\";\nexport function defineInterfaceLinkConstraint(linkDef) {\n const fromLinkMeta = getLinkMeta(linkDef);\n !(linkDef.from.links.find(a => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant(false) : void 0;\n linkDef.from.links.push({\n cardinality: linkDef.toMany ? \"MANY\" : \"SINGLE\",\n linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),\n metadata: fromLinkMeta,\n required: true // TODO: expose this?\n });\n}\nfunction getLinkedType(t) {\n return {\n type: \"interfaceType\",\n interfaceType: typeof t === \"string\" ? t : t.apiName\n };\n}\nfunction getLinkMeta(meta) {\n return typeof meta === \"string\" ? withDefaults({\n apiName: namespace + meta\n }) : withDefaults(meta);\n}\nfunction withDefaults({\n apiName,\n description,\n displayName\n}) {\n return {\n apiName: namespace + apiName,\n displayName: displayName ?? apiName,\n description: description ?? displayName ?? apiName\n };\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/maker",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"tiny-invariant": "^1.3.3",
|
|
23
23
|
"ts-node": "^10.9.2",
|
|
24
24
|
"yargs": "^17.7.2",
|
|
25
|
-
"@osdk/api": "~2.0.0-beta.
|
|
25
|
+
"@osdk/api": "~2.0.0-beta.10"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/yargs": "^17.0.32",
|
|
29
29
|
"typescript": "^5.5.4",
|
|
30
30
|
"vitest": "^2.0.4",
|
|
31
|
-
"@osdk/internal.foundry.core": "~0.2.0-beta.
|
|
32
|
-
"@osdk/
|
|
33
|
-
"@osdk/
|
|
31
|
+
"@osdk/internal.foundry.core": "~0.2.0-beta.7",
|
|
32
|
+
"@osdk/monorepo.api-extractor": "~0.0.0",
|
|
33
|
+
"@osdk/client.unstable": "~2.0.0-beta.10",
|
|
34
34
|
"@osdk/monorepo.tsconfig": "~0.0.0",
|
|
35
|
-
"@osdk/monorepo.
|
|
35
|
+
"@osdk/monorepo.tsup": "~0.0.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"templates",
|
|
48
48
|
"*.d.ts"
|
|
49
49
|
],
|
|
50
|
-
"main": "./build/js/index.cjs",
|
|
51
50
|
"module": "./build/esm/index.js",
|
|
52
51
|
"types": "./build/esm/index.d.ts",
|
|
53
52
|
"type": "module",
|