@osdk/maker 0.16.0-beta.5 → 0.16.0-beta.7
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 +24 -0
- package/README.md +4 -1
- package/build/browser/api/defineAction.js +6 -0
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineFunction.js +61 -0
- package/build/browser/api/defineFunction.js.map +1 -0
- package/build/browser/api/defineOntology.js +29 -0
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/test/objects.test.js +11 -2
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +28 -0
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +145 -2
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +7 -5
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/index.js +5 -2
- package/build/browser/index.js.map +1 -1
- package/build/cjs/defineFunction-7ORD7HD4.cjs +72 -0
- package/build/cjs/defineFunction-7ORD7HD4.cjs.map +1 -0
- package/build/cjs/index.cjs +198 -7
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +186 -153
- package/build/esm/api/defineAction.js +6 -0
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineFunction.js +61 -0
- package/build/esm/api/defineFunction.js.map +1 -0
- package/build/esm/api/defineOntology.js +29 -0
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/test/objects.test.js +11 -2
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +28 -0
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +145 -2
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +7 -5
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/index.js +5 -2
- package/build/esm/index.js.map +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineFunction.d.ts +19 -0
- package/build/types/api/defineFunction.d.ts.map +1 -0
- package/build/types/api/defineOntology.d.ts +5 -0
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +4 -2
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/index.d.ts +14 -6
- package/build/types/index.d.ts.map +1 -1
- package/package.json +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertDatasourceDefinition.js","names":["invariant","convertDatasourceDefinition","objectType","properties","baseDatasource","datasources","find","ds","includes","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","direct","directSourceRid","convertPropertySecurityGroups","primaryKeyPropertyApiName","some","objectSecurityPolicy","datasetV3","branchId","groups","rid","security","granular","viewPolicy","granularPolicyCondition","and","conditions","additionalMandatory","markings","assumedMarkings","primaryKey","validPropertyNames","Set","usedProperties","forEach","psg","propertyName","has","process","env","NODE_ENV","name","add","objectSecurityPolicyGroup","convertGranularPolicy","granularPolicy","additionalMandatoryMarkings","filter","property","convertSecurityCondition","condition","c","or","comparison","operator","left","userProperty","groupIds","right","constant","strings","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 {\n MarkingType,\n OntologyIrObjectTypeDatasourceDefinition,\n OntologyIrPropertySecurityGroup,\n OntologyIrPropertySecurityGroups,\n OntologyIrSecurityGroupGranularCondition,\n OntologyIrSecurityGroupGranularSecurityDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type {\n ObjectTypeDatasourceDefinition_dataset,\n ObjectTypeDatasourceDefinition_direct,\n} from \"../../api/object/ObjectTypeDatasourceDefinition.js\";\nimport type { SecurityConditionDefinition } from \"../../api/object/SecurityCondition.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n const baseDatasource = objectType.datasources?.find(ds =>\n [\"dataset\", \"stream\", \"restrictedView\", \"direct\"].includes(ds.type)\n );\n switch (baseDatasource?.type) {\n case \"stream\":\n const window = baseDatasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"derived\":\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"direct\":\n return {\n type: \"direct\",\n direct: {\n directSourceRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n case \"dataset\":\n default:\n if (\n objectType.properties?.some(prop =>\n typeof prop.type === \"object\" && prop.type.type === \"marking\"\n )\n || baseDatasource?.objectSecurityPolicy\n || baseDatasource?.propertySecurityGroups\n ) {\n return {\n type: \"datasetV3\",\n datasetV3: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n branchId: \"master\",\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n }\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction convertPropertySecurityGroups(\n ds:\n | ObjectTypeDatasourceDefinition_dataset\n | ObjectTypeDatasourceDefinition_direct\n | undefined,\n properties: ObjectPropertyType[],\n primaryKeyPropertyApiName: string,\n): OntologyIrPropertySecurityGroups {\n if (\n !ds\n || (!(\"objectSecurityPolicy\" in ds) && !(\"propertySecurityGroups\" in ds))\n ) {\n return {\n groups: [\n {\n properties: properties.map(prop => prop.apiName),\n rid: \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: {\n viewPolicy: {\n granularPolicyCondition: {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: {},\n assumedMarkings: [],\n },\n },\n },\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n },\n ],\n };\n }\n\n const validPropertyNames = new Set(properties.map(prop => prop.apiName));\n const usedProperties = new Set();\n\n ds.propertySecurityGroups?.forEach(psg => {\n psg.properties.forEach(propertyName => {\n invariant(\n validPropertyNames.has(propertyName),\n `Property \"${propertyName}\" in property security group ${psg.name} does not exist in the properties list`,\n );\n invariant(\n !usedProperties.has(propertyName),\n `Property \"${propertyName}\" is used in multiple property security groups`,\n );\n invariant(\n propertyName !== primaryKeyPropertyApiName,\n `Property \"${propertyName}\" in property security group ${psg.name} cannot be the primary key`,\n );\n usedProperties.add(propertyName);\n });\n });\n\n const objectSecurityPolicyGroup: OntologyIrPropertySecurityGroup = {\n rid: ds.objectSecurityPolicy?.name || \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: convertGranularPolicy(\n ds.objectSecurityPolicy?.granularPolicy,\n ds.objectSecurityPolicy?.additionalMandatoryMarkings,\n ),\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n properties: properties\n .filter(prop => !usedProperties.has(prop.apiName))\n .map(prop => prop.apiName),\n };\n\n return {\n groups: [\n objectSecurityPolicyGroup,\n ...(ds.propertySecurityGroups?.map(psg => ({\n rid: psg.name,\n security: {\n type: \"granular\" as const,\n granular: convertGranularPolicy(\n psg.granularPolicy,\n psg.additionalMandatoryMarkings,\n ),\n },\n type: {\n type: \"property\" as const,\n property: {\n name: psg.name,\n },\n },\n properties: psg.properties ?? [],\n })) ?? []),\n ],\n };\n}\n\nfunction convertGranularPolicy(\n granularPolicy?: SecurityConditionDefinition,\n additionalMandatoryMarkings?: Record<string, MarkingType>,\n): OntologyIrSecurityGroupGranularSecurityDefinition {\n return {\n viewPolicy: {\n granularPolicyCondition: granularPolicy\n ? convertSecurityCondition(granularPolicy)\n : {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: additionalMandatoryMarkings ?? {},\n assumedMarkings: [],\n },\n },\n };\n}\n\nfunction convertSecurityCondition(\n condition: SecurityConditionDefinition,\n): OntologyIrSecurityGroupGranularCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"markingProperty\":\n return {\n type: \"markings\",\n markings: {\n property: condition.property,\n },\n };\n case \"groupProperty\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"property\",\n property: condition.property,\n },\n },\n };\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"constant\",\n constant: {\n type: \"strings\",\n strings: [\n condition.name,\n ],\n },\n },\n },\n };\n\n default:\n return condition;\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAStC,OAAO,SAASC,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,MAAMC,cAAc,GAAGF,UAAU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,CAAC;IACtC;IACA;IACA,OAAO,CAAC9D,IAAI,CAACC,OAAO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAE0E,MAAM,EAAEhE,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"convertDatasourceDefinition.js","names":["invariant","convertDatasourceDefinition","objectType","properties","baseDatasource","datasources","find","ds","includes","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","direct","directSourceRid","convertPropertySecurityGroups","primaryKeyPropertyApiName","some","objectSecurityPolicy","datasetV3","branchId","groups","rid","security","granular","viewPolicy","granularPolicyCondition","and","conditions","additionalMandatory","markings","assumedMarkingsV2","assumedMarkings","primaryKey","validPropertyNames","Set","usedProperties","forEach","psg","propertyName","has","process","env","NODE_ENV","name","add","objectSecurityPolicyGroup","convertGranularPolicy","granularPolicy","appliedMarkings","filter","property","convertSecurityCondition","condition","c","or","comparison","operator","left","userProperty","groupIds","right","constant","strings","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 {\n MarkingType,\n OntologyIrObjectTypeDatasourceDefinition,\n OntologyIrPropertySecurityGroup,\n OntologyIrPropertySecurityGroups,\n OntologyIrSecurityGroupGranularCondition,\n OntologyIrSecurityGroupGranularSecurityDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type {\n ObjectTypeDatasourceDefinition_dataset,\n ObjectTypeDatasourceDefinition_direct,\n} from \"../../api/object/ObjectTypeDatasourceDefinition.js\";\nimport type { SecurityConditionDefinition } from \"../../api/object/SecurityCondition.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n const baseDatasource = objectType.datasources?.find(ds =>\n [\"dataset\", \"stream\", \"restrictedView\", \"direct\"].includes(ds.type)\n );\n switch (baseDatasource?.type) {\n case \"stream\":\n const window = baseDatasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"derived\":\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"direct\":\n return {\n type: \"direct\",\n direct: {\n directSourceRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n case \"dataset\":\n default:\n if (\n objectType.properties?.some(prop =>\n typeof prop.type === \"object\" && prop.type.type === \"marking\"\n )\n || baseDatasource?.objectSecurityPolicy\n || baseDatasource?.propertySecurityGroups\n ) {\n return {\n type: \"datasetV3\",\n datasetV3: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n branchId: \"master\",\n propertySecurityGroups: convertPropertySecurityGroups(\n baseDatasource,\n properties,\n objectType.primaryKeyPropertyApiName,\n ),\n },\n };\n }\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction convertPropertySecurityGroups(\n ds:\n | ObjectTypeDatasourceDefinition_dataset\n | ObjectTypeDatasourceDefinition_direct\n | undefined,\n properties: ObjectPropertyType[],\n primaryKeyPropertyApiName: string,\n): OntologyIrPropertySecurityGroups {\n if (\n !ds\n || (!(\"objectSecurityPolicy\" in ds) && !(\"propertySecurityGroups\" in ds))\n ) {\n return {\n groups: [\n {\n properties: properties.map(prop => prop.apiName),\n rid: \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: {\n viewPolicy: {\n granularPolicyCondition: {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: {},\n assumedMarkingsV2: {},\n assumedMarkings: [],\n },\n },\n },\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n },\n ],\n };\n }\n\n const validPropertyNames = new Set(properties.map(prop => prop.apiName));\n const usedProperties = new Set();\n\n ds.propertySecurityGroups?.forEach(psg => {\n psg.properties.forEach(propertyName => {\n invariant(\n validPropertyNames.has(propertyName),\n `Property \"${propertyName}\" in property security group ${psg.name} does not exist in the properties list`,\n );\n invariant(\n !usedProperties.has(propertyName),\n `Property \"${propertyName}\" is used in multiple property security groups`,\n );\n invariant(\n propertyName !== primaryKeyPropertyApiName,\n `Property \"${propertyName}\" in property security group ${psg.name} cannot be the primary key`,\n );\n usedProperties.add(propertyName);\n });\n });\n\n const objectSecurityPolicyGroup: OntologyIrPropertySecurityGroup = {\n rid: ds.objectSecurityPolicy?.name || \"defaultObjectSecurityPolicy\",\n security: {\n type: \"granular\",\n granular: convertGranularPolicy(\n ds.objectSecurityPolicy?.granularPolicy,\n ds.objectSecurityPolicy?.appliedMarkings,\n ds.objectSecurityPolicy?.assumedMarkings,\n ),\n },\n type: {\n type: \"primaryKey\",\n primaryKey: {},\n },\n properties: properties\n .filter(prop => !usedProperties.has(prop.apiName))\n .map(prop => prop.apiName),\n };\n\n return {\n groups: [\n objectSecurityPolicyGroup,\n ...(ds.propertySecurityGroups?.map(psg => ({\n rid: psg.name,\n security: {\n type: \"granular\" as const,\n granular: convertGranularPolicy(\n psg.granularPolicy,\n psg.appliedMarkings,\n psg.assumedMarkings,\n ),\n },\n type: {\n type: \"property\" as const,\n property: {\n name: psg.name,\n },\n },\n properties: psg.properties ?? [],\n })) ?? []),\n ],\n };\n}\n\nfunction convertGranularPolicy(\n granularPolicy?: SecurityConditionDefinition,\n appliedMarkings?: Record<string, MarkingType>,\n assumedMarkings?: Record<string, MarkingType>,\n): OntologyIrSecurityGroupGranularSecurityDefinition {\n return {\n viewPolicy: {\n granularPolicyCondition: granularPolicy\n ? convertSecurityCondition(granularPolicy)\n : {\n type: \"and\",\n and: {\n conditions: [],\n },\n },\n additionalMandatory: {\n markings: appliedMarkings ?? {},\n assumedMarkings: [],\n assumedMarkingsV2: assumedMarkings ?? {},\n },\n },\n };\n}\n\nfunction convertSecurityCondition(\n condition: SecurityConditionDefinition,\n): OntologyIrSecurityGroupGranularCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertSecurityCondition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"markingProperty\":\n return {\n type: \"markings\",\n markings: {\n property: condition.property,\n },\n };\n case \"groupProperty\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"property\",\n property: condition.property,\n },\n },\n };\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n right: {\n type: \"constant\",\n constant: {\n type: \"strings\",\n strings: [\n condition.name,\n ],\n },\n },\n },\n };\n\n default:\n return condition;\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AAStC,OAAO,SAASC,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,MAAMC,cAAc,GAAGF,UAAU,CAACG,WAAW,EAAEC,IAAI,CAACC,EAAE,IACpD,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAACD,EAAE,CAACE,IAAI,CACpE,CAAC;EACD,QAAQL,cAAc,EAAEK,IAAI;IAC1B,KAAK,QAAQ;MAC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AO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAE2E,MAAM,EAAEjE,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
package/build/browser/index.js
CHANGED
|
@@ -28,12 +28,15 @@ export { defineInterfaceLinkConstraint } from "./api/defineInterfaceLinkConstrai
|
|
|
28
28
|
export { defineLink } from "./api/defineLink.js";
|
|
29
29
|
export { defineModifyInterfaceObjectAction } from "./api/defineModifyInterfaceObjectAction.js";
|
|
30
30
|
export { defineModifyObjectAction } from "./api/defineModifyObjectAction.js";
|
|
31
|
-
export { convertToPluralDisplayName, defineObject, uppercaseFirstLetter as convertToDisplayName } from "./api/defineObject.js";
|
|
32
|
-
export { addNamespaceIfNone, defineOntology, dumpOntologyFullMetadata } from "./api/defineOntology.js";
|
|
31
|
+
export { convertToPluralDisplayName, defineObject, uppercaseFirstLetter, uppercaseFirstLetter as convertToDisplayName } from "./api/defineObject.js";
|
|
32
|
+
export { addNamespaceIfNone, cleanAndValidateLinkTypeId, convertObjectStatus, defineOntology, dumpOntologyFullMetadata, extractNamespace, getImportedTypes, getNamespace, getOntologyDefinition, initializeOntologyState, withoutNamespace } from "./api/defineOntology.js";
|
|
33
33
|
export { defineSharedPropertyType } from "./api/defineSpt.js";
|
|
34
34
|
export { defineValueType } from "./api/defineValueType.js";
|
|
35
35
|
export { importOntologyEntity } from "./api/importOntologyEntity.js";
|
|
36
36
|
export { importSharedPropertyType } from "./api/importSharedPropertyType.js";
|
|
37
|
+
export { isInterfaceSharedPropertyType } from "./api/interface/InterfacePropertyType.js";
|
|
38
|
+
export { isExotic } from "./api/properties/PropertyTypeType.js";
|
|
39
|
+
export { defaultTypeClasses, getPropertyTypeName, hasRenderHints, shouldBeIndexedForSearch, shouldNotHaveRenderHints } from "./api/propertyConversionUtils.js";
|
|
37
40
|
export { wrapWithProxy } from "./api/wrapWithProxy.js";
|
|
38
41
|
export { propertyTypeTypeToOntologyIrType as convertType } from "./conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js";
|
|
39
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","addDependency","OntologyEntityTypeEnum","CREATE_INTERFACE_OBJECT_PARAMETER","CREATE_OR_MODIFY_OBJECT_PARAMETER","defineAction","DELETE_OBJECT_PARAMETER","MODIFY_INTERFACE_OBJECT_PARAMETER","MODIFY_OBJECT_PARAMETER","defineCreateInterfaceObjectAction","defineCreateObjectAction","defineCreateOrModifyObjectAction","defineDeleteInterfaceObjectAction","defineDeleteObjectAction","defineInterface","defineInterfaceLinkConstraint","defineLink","defineModifyInterfaceObjectAction","defineModifyObjectAction","convertToPluralDisplayName","defineObject","uppercaseFirstLetter","convertToDisplayName","addNamespaceIfNone","defineOntology","dumpOntologyFullMetadata","defineSharedPropertyType","defineValueType","importOntologyEntity","importSharedPropertyType","wrapWithProxy","propertyTypeTypeToOntologyIrType","convertType"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { default as default } from \"./cli/main.js\";\n\nexport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","addDependency","OntologyEntityTypeEnum","CREATE_INTERFACE_OBJECT_PARAMETER","CREATE_OR_MODIFY_OBJECT_PARAMETER","defineAction","DELETE_OBJECT_PARAMETER","MODIFY_INTERFACE_OBJECT_PARAMETER","MODIFY_OBJECT_PARAMETER","defineCreateInterfaceObjectAction","defineCreateObjectAction","defineCreateOrModifyObjectAction","defineDeleteInterfaceObjectAction","defineDeleteObjectAction","defineInterface","defineInterfaceLinkConstraint","defineLink","defineModifyInterfaceObjectAction","defineModifyObjectAction","convertToPluralDisplayName","defineObject","uppercaseFirstLetter","convertToDisplayName","addNamespaceIfNone","cleanAndValidateLinkTypeId","convertObjectStatus","defineOntology","dumpOntologyFullMetadata","extractNamespace","getImportedTypes","getNamespace","getOntologyDefinition","initializeOntologyState","withoutNamespace","defineSharedPropertyType","defineValueType","importOntologyEntity","importSharedPropertyType","isInterfaceSharedPropertyType","isExotic","defaultTypeClasses","getPropertyTypeName","hasRenderHints","shouldBeIndexedForSearch","shouldNotHaveRenderHints","wrapWithProxy","propertyTypeTypeToOntologyIrType","convertType"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { default as default } from \"./cli/main.js\";\n\nexport type {\n ActionParameter,\n ActionParameterValidation,\n} from \"./api/action/ActionParameter.js\";\nexport type {\n ActionParameterAllowedValues,\n} from \"./api/action/ActionParameterAllowedValues.js\";\nexport type { ActionParameterConditionalOverride } from \"./api/action/ActionParameterConditionalOverride.js\";\nexport type {\n ActionParameterConfiguration,\n ActionParameterRequirementConstraint,\n} from \"./api/action/ActionParameterConfiguration.js\";\nexport type { ActionSection } from \"./api/action/ActionSection.js\";\nexport type { ActionType } from \"./api/action/ActionType.js\";\nexport type { ConditionDefinition } from \"./api/action/ConditionDefinition.js\";\nexport type {\n CurrentTimeMappingValue,\n CurrentUserMappingValue,\n CustomMapping,\n MappingValue,\n UuidMappingValue,\n} from \"./api/action/MappingValue.js\";\nexport type { SectionConditionalOverride } from \"./api/action/SectionConditionalOverride.js\";\nexport type { SubmissionMetadata } from \"./api/action/SubmissionMetadata.js\";\nexport { addDependency } from \"./api/addDependency.js\";\nexport type { OntologyDefinition } from \"./api/common/OntologyDefinition.js\";\nexport { OntologyEntityTypeEnum } from \"./api/common/OntologyEntityTypeEnum.js\";\nexport {\n CREATE_INTERFACE_OBJECT_PARAMETER,\n CREATE_OR_MODIFY_OBJECT_PARAMETER,\n defineAction,\n DELETE_OBJECT_PARAMETER,\n MODIFY_INTERFACE_OBJECT_PARAMETER,\n MODIFY_OBJECT_PARAMETER,\n} from \"./api/defineAction.js\";\nexport { defineCreateInterfaceObjectAction } from \"./api/defineCreateInterfaceObjectAction.js\";\nexport { defineCreateObjectAction } from \"./api/defineCreateObjectAction.js\";\nexport { defineCreateOrModifyObjectAction } from \"./api/defineCreateOrModifyObjectAction.js\";\nexport { defineDeleteInterfaceObjectAction } from \"./api/defineDeleteInterfaceObjectAction.js\";\nexport { defineDeleteObjectAction } from \"./api/defineDeleteObjectAction.js\";\nexport { defineInterface } from \"./api/defineInterface.js\";\nexport { defineInterfaceLinkConstraint } from \"./api/defineInterfaceLinkConstraint.js\";\nexport { defineLink } from \"./api/defineLink.js\";\nexport { defineModifyInterfaceObjectAction } from \"./api/defineModifyInterfaceObjectAction.js\";\nexport { defineModifyObjectAction } from \"./api/defineModifyObjectAction.js\";\nexport {\n convertToPluralDisplayName,\n defineObject,\n uppercaseFirstLetter,\n uppercaseFirstLetter as convertToDisplayName,\n} from \"./api/defineObject.js\";\nexport {\n addNamespaceIfNone,\n cleanAndValidateLinkTypeId,\n convertObjectStatus,\n defineOntology,\n dumpOntologyFullMetadata,\n extractNamespace,\n getImportedTypes,\n getNamespace,\n getOntologyDefinition,\n initializeOntologyState,\n withoutNamespace,\n} from \"./api/defineOntology.js\";\nexport { defineSharedPropertyType } from \"./api/defineSpt.js\";\nexport { defineValueType } from \"./api/defineValueType.js\";\nexport { importOntologyEntity } from \"./api/importOntologyEntity.js\";\nexport { importSharedPropertyType } from \"./api/importSharedPropertyType.js\";\nexport type {\n InterfaceDefinedProperty,\n InterfacePropertyType,\n} from \"./api/interface/InterfacePropertyType.js\";\nexport { isInterfaceSharedPropertyType } from \"./api/interface/InterfacePropertyType.js\";\nexport type { InterfaceType } from \"./api/interface/InterfaceType.js\";\nexport type {\n LinkType,\n OneToManyLinkTypeDefinition,\n UserLinkTypeStatus,\n} from \"./api/links/LinkType.js\";\nexport type { ObjectPropertyType } from \"./api/object/ObjectPropertyType.js\";\nexport type { ObjectType } from \"./api/object/ObjectType.js\";\nexport type {\n DerivedPropertyAggregation,\n ObjectTypeDatasourceDefinition_dataset,\n ObjectTypeDatasourceDefinition_derived,\n ObjectTypeDatasourceDefinition_direct,\n} from \"./api/object/ObjectTypeDatasourceDefinition.js\";\nexport type { ObjectTypeDefinition } from \"./api/object/ObjectTypeDefinition.js\";\nexport type { SecurityConditionDefinition } from \"./api/object/SecurityCondition.js\";\nexport type { Nullability } from \"./api/properties/Nullability.js\";\nexport type { PropertyTypeType } from \"./api/properties/PropertyTypeType.js\";\nexport { isExotic } from \"./api/properties/PropertyTypeType.js\";\nexport type { SharedPropertyType } from \"./api/properties/SharedPropertyType.js\";\nexport {\n defaultTypeClasses,\n getPropertyTypeName,\n hasRenderHints,\n shouldBeIndexedForSearch,\n shouldNotHaveRenderHints,\n} from \"./api/propertyConversionUtils.js\";\nexport type { ValueTypeDefinitionVersion } from \"./api/values/ValueTypeDefinitionVersion.js\";\nexport { wrapWithProxy } from \"./api/wrapWithProxy.js\";\nexport { propertyTypeTypeToOntologyIrType as convertType } from \"./conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAkB,QAAQ,eAAe;AA0BlD,SAASC,aAAa,QAAQ,wBAAwB;AAEtD,SA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+
'use strict';
|
|
2
|
+
|
|
3
|
+
var generatorConverters_ontologyir = require('@osdk/generator-converters.ontologyir');
|
|
4
|
+
var consola = require('consola');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
26
|
+
|
|
27
|
+
// src/api/defineFunction.ts
|
|
28
|
+
var cachedFunctionDiscoverer = null;
|
|
29
|
+
async function loadFunctionDiscoverer() {
|
|
30
|
+
if (cachedFunctionDiscoverer != null) {
|
|
31
|
+
return cachedFunctionDiscoverer;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const modulePath = "@foundry/functions-typescript-osdk-discovery";
|
|
35
|
+
const module = await import(
|
|
36
|
+
/* @vite-ignore */
|
|
37
|
+
modulePath
|
|
38
|
+
);
|
|
39
|
+
cachedFunctionDiscoverer = module.FunctionDiscoverer;
|
|
40
|
+
return cachedFunctionDiscoverer;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
consola.consola.warn("Failed to load @foundry/functions-typescript-osdk-discovery:", e instanceof Error ? e.message : e);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function extractFunctionEntries(discoveredFunctions) {
|
|
47
|
+
return discoveredFunctions.map((fn) => {
|
|
48
|
+
if (fn.locator.type !== "typescriptOsdk") {
|
|
49
|
+
throw new Error(`OAC functions must be TypeScript, got type: ${fn.locator.type}`);
|
|
50
|
+
}
|
|
51
|
+
const locator = fn.locator;
|
|
52
|
+
return [locator.typescriptOsdk.functionName, fn];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function generateFunctionsIr(rootDir, configPath, entityMappings) {
|
|
56
|
+
const functionsDiscoverer = await loadFunctionDiscoverer();
|
|
57
|
+
if (!functionsDiscoverer) {
|
|
58
|
+
throw new Error("Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed");
|
|
59
|
+
}
|
|
60
|
+
const tsConfigPath = configPath ?? path__namespace.join(rootDir, "tsconfig.json");
|
|
61
|
+
const program = generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, rootDir);
|
|
62
|
+
const functionsDir = path__namespace.join(rootDir, "functions");
|
|
63
|
+
const fd = new functionsDiscoverer(program, rootDir, functionsDir, entityMappings);
|
|
64
|
+
const functions = fd.discover();
|
|
65
|
+
return {
|
|
66
|
+
functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.generateFunctionsIr = generateFunctionsIr;
|
|
71
|
+
//# sourceMappingURL=defineFunction-7ORD7HD4.cjs.map
|
|
72
|
+
//# sourceMappingURL=defineFunction-7ORD7HD4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/api/defineFunction.ts"],"names":["consola","path","OntologyIrToFullMetadataConverter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAI,wBAA2B,GAAA,IAAA;AAC/B,eAAe,sBAAyB,GAAA;AACtC,EAAA,IAAI,4BAA4B,IAAM,EAAA;AACpC,IAAO,OAAA,wBAAA;AAAA;AAET,EAAI,IAAA;AACF,IAAA,MAAM,UAAa,GAAA,8CAAA;AACnB,IAAA,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AAc,CAAA;AACjF,EAAM,MAAA,SAAA,GAAY,GAAG,QAAS,EAAA;AAC9B,EAAO,OAAA;AAAA,IACL,sBAAsB,MAAO,CAAA,WAAA,CAAY,sBAAuB,CAAA,SAAA,CAAU,mBAAmB,CAAC;AAAA,GAChG;AACF","file":"defineFunction-7ORD7HD4.cjs","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 { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport * as path from \"node:path\";\n\n// Type definitions for optional function discovery dependencies\n\n// Lazy-loaded function discovery module\nlet cachedFunctionDiscoverer = null;\nasync function loadFunctionDiscoverer() {\n if (cachedFunctionDiscoverer != null) {\n return cachedFunctionDiscoverer;\n }\n try {\n const modulePath = \"@foundry/functions-typescript-osdk-discovery\";\n const module = await import(/* @vite-ignore */modulePath);\n cachedFunctionDiscoverer = module.FunctionDiscoverer;\n return cachedFunctionDiscoverer;\n } catch (e) {\n consola.warn(\"Failed to load @foundry/functions-typescript-osdk-discovery:\", e instanceof Error ? e.message : e);\n return null;\n }\n}\nfunction extractFunctionEntries(discoveredFunctions) {\n return discoveredFunctions.map(fn => {\n if (fn.locator.type !== \"typescriptOsdk\") {\n throw new Error(`OAC functions must be TypeScript, got type: ${fn.locator.type}`);\n }\n const locator = fn.locator;\n return [locator.typescriptOsdk.functionName, fn];\n });\n}\nexport async function generateFunctionsIr(rootDir, configPath, entityMappings) {\n const functionsDiscoverer = await loadFunctionDiscoverer();\n if (!functionsDiscoverer) {\n throw new Error(\"Function discovery requires @foundry/functions-typescript-osdk-discovery to be installed\");\n }\n const tsConfigPath = configPath ?? path.join(rootDir, \"tsconfig.json\");\n const program = OntologyIrToFullMetadataConverter.createProgram(tsConfigPath, rootDir);\n const functionsDir = path.join(rootDir, \"functions\");\n const fd = new functionsDiscoverer(program, rootDir, functionsDir, entityMappings);\n const functions = fd.discover();\n return {\n functionsBlockDataV1: Object.fromEntries(extractFunctionEntries(functions.discoveredFunctions))\n };\n}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var generatorConverters_ontologyir = require('@osdk/generator-converters.ontologyir');
|
|
5
6
|
var consola = require('consola');
|
|
7
|
+
var execa = require('execa');
|
|
8
|
+
var jiti = require('jiti');
|
|
6
9
|
var fs3 = require('fs/promises');
|
|
7
10
|
var path3 = require('path');
|
|
8
11
|
var invariant9 = require('tiny-invariant');
|
|
@@ -13,6 +16,7 @@ var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
|
13
16
|
var Mustache = require('mustache');
|
|
14
17
|
var crypto = require('crypto');
|
|
15
18
|
|
|
19
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
16
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
21
|
|
|
18
22
|
function _interopNamespace(e) {
|
|
@@ -1402,6 +1406,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1402
1406
|
},
|
|
1403
1407
|
additionalMandatory: {
|
|
1404
1408
|
markings: {},
|
|
1409
|
+
assumedMarkingsV2: {},
|
|
1405
1410
|
assumedMarkings: []
|
|
1406
1411
|
}
|
|
1407
1412
|
}
|
|
@@ -1428,7 +1433,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1428
1433
|
rid: ds.objectSecurityPolicy?.name || "defaultObjectSecurityPolicy",
|
|
1429
1434
|
security: {
|
|
1430
1435
|
type: "granular",
|
|
1431
|
-
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.
|
|
1436
|
+
granular: convertGranularPolicy(ds.objectSecurityPolicy?.granularPolicy, ds.objectSecurityPolicy?.appliedMarkings, ds.objectSecurityPolicy?.assumedMarkings)
|
|
1432
1437
|
},
|
|
1433
1438
|
type: {
|
|
1434
1439
|
type: "primaryKey",
|
|
@@ -1441,7 +1446,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1441
1446
|
rid: psg.name,
|
|
1442
1447
|
security: {
|
|
1443
1448
|
type: "granular",
|
|
1444
|
-
granular: convertGranularPolicy(psg.granularPolicy, psg.
|
|
1449
|
+
granular: convertGranularPolicy(psg.granularPolicy, psg.appliedMarkings, psg.assumedMarkings)
|
|
1445
1450
|
},
|
|
1446
1451
|
type: {
|
|
1447
1452
|
type: "property",
|
|
@@ -1453,7 +1458,7 @@ function convertPropertySecurityGroups(ds, properties, primaryKeyPropertyApiName
|
|
|
1453
1458
|
})) ?? []]
|
|
1454
1459
|
};
|
|
1455
1460
|
}
|
|
1456
|
-
function convertGranularPolicy(granularPolicy,
|
|
1461
|
+
function convertGranularPolicy(granularPolicy, appliedMarkings, assumedMarkings) {
|
|
1457
1462
|
return {
|
|
1458
1463
|
viewPolicy: {
|
|
1459
1464
|
granularPolicyCondition: granularPolicy ? convertSecurityCondition(granularPolicy) : {
|
|
@@ -1463,8 +1468,9 @@ function convertGranularPolicy(granularPolicy, additionalMandatoryMarkings) {
|
|
|
1463
1468
|
}
|
|
1464
1469
|
},
|
|
1465
1470
|
additionalMandatory: {
|
|
1466
|
-
markings:
|
|
1467
|
-
assumedMarkings: []
|
|
1471
|
+
markings: appliedMarkings ?? {},
|
|
1472
|
+
assumedMarkings: [],
|
|
1473
|
+
assumedMarkingsV2: assumedMarkings ?? {}
|
|
1468
1474
|
}
|
|
1469
1475
|
}
|
|
1470
1476
|
};
|
|
@@ -2579,6 +2585,9 @@ function renderHintFromBaseType(parameter, validation) {
|
|
|
2579
2585
|
throw new Error(`Unknown type ${type}`);
|
|
2580
2586
|
}
|
|
2581
2587
|
}
|
|
2588
|
+
function extractNamespace(apiName) {
|
|
2589
|
+
return apiName.substring(0, apiName.lastIndexOf(".") + 1);
|
|
2590
|
+
}
|
|
2582
2591
|
function withoutNamespace(apiName) {
|
|
2583
2592
|
const lastDot = apiName.lastIndexOf(".");
|
|
2584
2593
|
if (lastDot === -1) {
|
|
@@ -2617,12 +2626,52 @@ addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
|
2617
2626
|
function addNamespaceIfNone(apiName) {
|
|
2618
2627
|
return apiName.includes(".") ? apiName : namespace + apiName;
|
|
2619
2628
|
}
|
|
2629
|
+
function initializeOntologyState(ns) {
|
|
2630
|
+
namespace = ns;
|
|
2631
|
+
dependencies = {};
|
|
2632
|
+
ontologyDefinition = {
|
|
2633
|
+
OBJECT_TYPE: {},
|
|
2634
|
+
ACTION_TYPE: {},
|
|
2635
|
+
LINK_TYPE: {},
|
|
2636
|
+
INTERFACE_TYPE: {},
|
|
2637
|
+
SHARED_PROPERTY_TYPE: {},
|
|
2638
|
+
VALUE_TYPE: {}
|
|
2639
|
+
};
|
|
2640
|
+
importedTypes = {
|
|
2641
|
+
SHARED_PROPERTY_TYPE: {},
|
|
2642
|
+
OBJECT_TYPE: {},
|
|
2643
|
+
ACTION_TYPE: {},
|
|
2644
|
+
LINK_TYPE: {},
|
|
2645
|
+
INTERFACE_TYPE: {},
|
|
2646
|
+
VALUE_TYPE: {}
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
function getOntologyDefinition() {
|
|
2650
|
+
return ontologyDefinition;
|
|
2651
|
+
}
|
|
2652
|
+
function getImportedTypes() {
|
|
2653
|
+
return importedTypes;
|
|
2654
|
+
}
|
|
2655
|
+
function getNamespace() {
|
|
2656
|
+
return namespace;
|
|
2657
|
+
}
|
|
2620
2658
|
|
|
2621
2659
|
// src/cli/main.ts
|
|
2660
|
+
var generateFunctionsIr;
|
|
2661
|
+
async function loadFunctionDiscoveryDeps() {
|
|
2662
|
+
try {
|
|
2663
|
+
const defineFunctionModule = await import('./defineFunction-7ORD7HD4.cjs');
|
|
2664
|
+
generateFunctionsIr = defineFunctionModule.generateFunctionsIr;
|
|
2665
|
+
return true;
|
|
2666
|
+
} catch (e) {
|
|
2667
|
+
consola.consola.warn("Failed to load function discovery dependencies:", e instanceof Error ? e.message : e);
|
|
2668
|
+
return false;
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2622
2671
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2623
2672
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2624
2673
|
async function main(args = process.argv) {
|
|
2625
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.
|
|
2674
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.16.0-beta.7").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2626
2675
|
input: {
|
|
2627
2676
|
alias: "i",
|
|
2628
2677
|
describe: "Input file",
|
|
@@ -2686,6 +2735,41 @@ async function main(args = process.argv) {
|
|
|
2686
2735
|
describe: "Value used to assure uniqueness of entities",
|
|
2687
2736
|
type: "string",
|
|
2688
2737
|
coerce: path3__namespace.resolve
|
|
2738
|
+
},
|
|
2739
|
+
generateFunctionsOsdk: {
|
|
2740
|
+
describe: "Output folder for generated OSDK for functions",
|
|
2741
|
+
type: "string",
|
|
2742
|
+
coerce: path3__namespace.resolve
|
|
2743
|
+
},
|
|
2744
|
+
functionsRootDir: {
|
|
2745
|
+
describe: "Root folder containing function definitions",
|
|
2746
|
+
type: "string",
|
|
2747
|
+
coerce: path3__namespace.resolve
|
|
2748
|
+
},
|
|
2749
|
+
functionsOutput: {
|
|
2750
|
+
describe: "Output folder for function IR",
|
|
2751
|
+
type: "string",
|
|
2752
|
+
coerce: path3__namespace.resolve
|
|
2753
|
+
},
|
|
2754
|
+
configPath: {
|
|
2755
|
+
describe: "Path to the TypeScript config file",
|
|
2756
|
+
type: "string",
|
|
2757
|
+
coerce: path3__namespace.resolve
|
|
2758
|
+
},
|
|
2759
|
+
pythonFunctionsDir: {
|
|
2760
|
+
describe: "Path to Python functions source directory (enables Python function discovery)",
|
|
2761
|
+
type: "string",
|
|
2762
|
+
coerce: path3__namespace.resolve
|
|
2763
|
+
},
|
|
2764
|
+
pythonBinary: {
|
|
2765
|
+
describe: "Path to Python binary (required when using --pythonFunctionsDir)",
|
|
2766
|
+
type: "string",
|
|
2767
|
+
coerce: path3__namespace.resolve
|
|
2768
|
+
},
|
|
2769
|
+
pythonRootProjectDir: {
|
|
2770
|
+
describe: "Root project directory for Python functions (defaults to parent of pythonFunctionsDir)",
|
|
2771
|
+
type: "string",
|
|
2772
|
+
coerce: path3__namespace.resolve
|
|
2689
2773
|
}
|
|
2690
2774
|
}).parseAsync();
|
|
2691
2775
|
let apiNamespace = "";
|
|
@@ -2707,11 +2791,96 @@ async function main(args = process.argv) {
|
|
|
2707
2791
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
2708
2792
|
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
2709
2793
|
}
|
|
2794
|
+
if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {
|
|
2795
|
+
consola.consola.error("--pythonBinary is required when using --pythonFunctionsDir");
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
if (commandLineOpts.functionsOutput !== void 0 && commandLineOpts.functionsRootDir !== void 0) {
|
|
2799
|
+
const hasFunctionDeps = await loadFunctionDiscoveryDeps();
|
|
2800
|
+
if (!hasFunctionDeps || !generateFunctionsIr) {
|
|
2801
|
+
consola.consola.error("Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.");
|
|
2802
|
+
return;
|
|
2803
|
+
}
|
|
2804
|
+
consola.consola.info(`Loading function IR`);
|
|
2805
|
+
const functionsIr = await generateFunctionsIr(commandLineOpts.functionsRootDir, commandLineOpts.configPath, createEntityMappings(ontologyIr));
|
|
2806
|
+
await fs3__namespace.writeFile(commandLineOpts.functionsOutput, JSON.stringify(functionsIr, null, 2));
|
|
2807
|
+
return;
|
|
2808
|
+
}
|
|
2809
|
+
if (commandLineOpts.generateFunctionsOsdk !== void 0) {
|
|
2810
|
+
const fullMetadata = generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ontologyIr.ontology);
|
|
2811
|
+
if (commandLineOpts.pythonFunctionsDir) {
|
|
2812
|
+
const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir ?? path3__namespace.dirname(commandLineOpts.pythonFunctionsDir);
|
|
2813
|
+
const queryTypes = await generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getOsdkQueryTypes(commandLineOpts.pythonBinary, void 0, void 0, commandLineOpts.pythonFunctionsDir, effectivePythonRootDir);
|
|
2814
|
+
const functionNames = Object.keys(queryTypes);
|
|
2815
|
+
if (functionNames.length > 0) {
|
|
2816
|
+
fullMetadata.queryTypes = queryTypes;
|
|
2817
|
+
consola.consola.info(`Discovered ${functionNames.length} Python function(s): ${functionNames.join(", ")}`);
|
|
2818
|
+
} else {
|
|
2819
|
+
consola.consola.info("No Python functions discovered.");
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
consola.consola.info(`Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`);
|
|
2823
|
+
await fs3__namespace.writeFile(path3__namespace.join(commandLineOpts.generateFunctionsOsdk, ".ontology.json"), JSON.stringify(fullMetadata, null, 2));
|
|
2824
|
+
await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);
|
|
2825
|
+
}
|
|
2710
2826
|
}
|
|
2711
2827
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2712
|
-
const q = await defineOntology(apiNamespace, async () =>
|
|
2828
|
+
const q = await defineOntology(apiNamespace, async () => {
|
|
2829
|
+
const jiti$1 = jiti.createJiti(undefined, {
|
|
2830
|
+
moduleCache: true,
|
|
2831
|
+
debug: false,
|
|
2832
|
+
importMeta: ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })
|
|
2833
|
+
});
|
|
2834
|
+
await jiti$1.import(input);
|
|
2835
|
+
}, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
2713
2836
|
return q;
|
|
2714
2837
|
}
|
|
2838
|
+
async function fullMetadataToOsdk(workDir) {
|
|
2839
|
+
const functionOsdkDir = path3__namespace.join(workDir, "generated");
|
|
2840
|
+
await fs3__namespace.rm(functionOsdkDir, {
|
|
2841
|
+
recursive: true,
|
|
2842
|
+
force: true
|
|
2843
|
+
});
|
|
2844
|
+
await fs3__namespace.mkdir(functionOsdkDir, {
|
|
2845
|
+
recursive: true
|
|
2846
|
+
});
|
|
2847
|
+
try {
|
|
2848
|
+
await execa.execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", functionOsdkDir, "--ontologyPath", path3__namespace.join(workDir, ".ontology.json"), "--beta", "true", "--packageType", "module", "--version", "dev"]);
|
|
2849
|
+
} catch (error) {
|
|
2850
|
+
await fs3__namespace.rm(functionOsdkDir, {
|
|
2851
|
+
recursive: true,
|
|
2852
|
+
force: true
|
|
2853
|
+
});
|
|
2854
|
+
throw error;
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
function createEntityMappings(ontologyIr) {
|
|
2858
|
+
const entityMappings = {
|
|
2859
|
+
ontologies: {}
|
|
2860
|
+
};
|
|
2861
|
+
const ontologyRid = "ontology";
|
|
2862
|
+
entityMappings.ontologies[ontologyRid] = {
|
|
2863
|
+
objectTypes: {},
|
|
2864
|
+
interfaceTypes: {}
|
|
2865
|
+
};
|
|
2866
|
+
for (const [apiName, blockData] of Object.entries(ontologyIr.ontology.objectTypes)) {
|
|
2867
|
+
const propertyTypesMap = {};
|
|
2868
|
+
Object.keys(blockData.objectType.propertyTypes).forEach((propertyName) => {
|
|
2869
|
+
propertyTypesMap[propertyName] = {
|
|
2870
|
+
propertyId: propertyName
|
|
2871
|
+
};
|
|
2872
|
+
});
|
|
2873
|
+
entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {
|
|
2874
|
+
objectTypeId: apiName,
|
|
2875
|
+
primaryKey: {
|
|
2876
|
+
propertyId: blockData.objectType.primaryKeys[0]
|
|
2877
|
+
},
|
|
2878
|
+
propertyTypes: propertyTypesMap,
|
|
2879
|
+
linkTypes: {}
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
return entityMappings;
|
|
2883
|
+
}
|
|
2715
2884
|
var MAX_SEARCH_DEPTH = 5;
|
|
2716
2885
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
2717
2886
|
let dir = path3__namespace.dirname(fileInPackage);
|
|
@@ -3252,6 +3421,10 @@ function extractAllowedValuesFromPropertyType(type) {
|
|
|
3252
3421
|
};
|
|
3253
3422
|
default:
|
|
3254
3423
|
switch (type.type) {
|
|
3424
|
+
case "decimal":
|
|
3425
|
+
return {
|
|
3426
|
+
type: "range"
|
|
3427
|
+
};
|
|
3255
3428
|
case "marking":
|
|
3256
3429
|
return type.markingType === "CBAC" ? {
|
|
3257
3430
|
type: "cbacMarking"
|
|
@@ -3273,6 +3446,8 @@ function extractActionParameterType(pt) {
|
|
|
3273
3446
|
const typeType = pt.type;
|
|
3274
3447
|
if (typeof typeType === "object") {
|
|
3275
3448
|
switch (typeType.type) {
|
|
3449
|
+
case "decimal":
|
|
3450
|
+
return maybeAddList("decimal", pt);
|
|
3276
3451
|
case "marking":
|
|
3277
3452
|
return maybeAddList("marking", pt);
|
|
3278
3453
|
case "string":
|
|
@@ -4334,10 +4509,13 @@ exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
|
4334
4509
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
4335
4510
|
exports.addDependency = addDependency;
|
|
4336
4511
|
exports.addNamespaceIfNone = addNamespaceIfNone;
|
|
4512
|
+
exports.cleanAndValidateLinkTypeId = cleanAndValidateLinkTypeId;
|
|
4513
|
+
exports.convertObjectStatus = convertObjectStatus;
|
|
4337
4514
|
exports.convertToDisplayName = uppercaseFirstLetter;
|
|
4338
4515
|
exports.convertToPluralDisplayName = convertToPluralDisplayName;
|
|
4339
4516
|
exports.convertType = propertyTypeTypeToOntologyIrType;
|
|
4340
4517
|
exports.default = main;
|
|
4518
|
+
exports.defaultTypeClasses = defaultTypeClasses;
|
|
4341
4519
|
exports.defineAction = defineAction;
|
|
4342
4520
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
4343
4521
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
@@ -4354,8 +4532,21 @@ exports.defineOntology = defineOntology;
|
|
|
4354
4532
|
exports.defineSharedPropertyType = defineSharedPropertyType;
|
|
4355
4533
|
exports.defineValueType = defineValueType;
|
|
4356
4534
|
exports.dumpOntologyFullMetadata = dumpOntologyFullMetadata;
|
|
4535
|
+
exports.extractNamespace = extractNamespace;
|
|
4536
|
+
exports.getImportedTypes = getImportedTypes;
|
|
4537
|
+
exports.getNamespace = getNamespace;
|
|
4538
|
+
exports.getOntologyDefinition = getOntologyDefinition;
|
|
4539
|
+
exports.getPropertyTypeName = getPropertyTypeName;
|
|
4540
|
+
exports.hasRenderHints = hasRenderHints;
|
|
4357
4541
|
exports.importOntologyEntity = importOntologyEntity;
|
|
4358
4542
|
exports.importSharedPropertyType = importSharedPropertyType;
|
|
4543
|
+
exports.initializeOntologyState = initializeOntologyState;
|
|
4544
|
+
exports.isExotic = isExotic;
|
|
4545
|
+
exports.isInterfaceSharedPropertyType = isInterfaceSharedPropertyType;
|
|
4546
|
+
exports.shouldBeIndexedForSearch = shouldBeIndexedForSearch;
|
|
4547
|
+
exports.shouldNotHaveRenderHints = shouldNotHaveRenderHints;
|
|
4548
|
+
exports.uppercaseFirstLetter = uppercaseFirstLetter;
|
|
4549
|
+
exports.withoutNamespace = withoutNamespace;
|
|
4359
4550
|
exports.wrapWithProxy = wrapWithProxy;
|
|
4360
4551
|
//# sourceMappingURL=index.cjs.map
|
|
4361
4552
|
//# sourceMappingURL=index.cjs.map
|