@osdk/generator 2.2.0-beta.21 → 2.2.0-beta.23
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 +124 -0
- package/build/browser/GenerateContext/GenerateContext.js.map +1 -1
- package/build/browser/util/test/TodoWireOntology.js +2 -2
- package/build/browser/util/test/TodoWireOntology.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js +3 -2
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js +396 -12
- package/build/browser/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.js +6 -8
- package/build/browser/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js +16 -8
- package/build/browser/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/cjs/index.cjs +9 -5
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -1
- package/build/esm/GenerateContext/GenerateContext.js.map +1 -1
- package/build/esm/util/test/TodoWireOntology.js +2 -2
- package/build/esm/util/test/TodoWireOntology.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js +3 -2
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.js.map +1 -1
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js +396 -12
- package/build/esm/v2.0/generateClientSdkVersionTwoPointZero.test.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.js +6 -8
- package/build/esm/v2.0/generatePerQueryDataFiles.js.map +1 -1
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js +16 -8
- package/build/esm/v2.0/generatePerQueryDataFiles.test.js.map +1 -1
- package/build/types/GenerateContext/GenerateContext.d.ts +1 -0
- package/build/types/GenerateContext/GenerateContext.d.ts.map +1 -1
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts +1 -1
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts.map +1 -1
- package/build/types/v2.0/generatePerQueryDataFiles.d.ts +1 -1
- package/build/types/v2.0/generatePerQueryDataFiles.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -26,6 +26,7 @@ export async function generatePerQueryDataFilesV2({
|
|
|
26
26
|
fs,
|
|
27
27
|
outDir: rootOutDir,
|
|
28
28
|
ontology,
|
|
29
|
+
fixedVersionQueryTypes,
|
|
29
30
|
importExt = "",
|
|
30
31
|
forInternalUse = false
|
|
31
32
|
}) {
|
|
@@ -35,21 +36,21 @@ export async function generatePerQueryDataFilesV2({
|
|
|
35
36
|
recursive: true
|
|
36
37
|
});
|
|
37
38
|
await Promise.all(Object.values(ontology.queryTypes).map(async query => {
|
|
38
|
-
await generateV2QueryFile(fs, outDir, relOutDir, query, importExt, ontology, forInternalUse);
|
|
39
|
+
await generateV2QueryFile(fs, outDir, relOutDir, query, importExt, ontology, forInternalUse, fixedVersionQueryTypes);
|
|
39
40
|
}));
|
|
40
41
|
await fs.writeFile(`${outDir}.ts`, await formatTs(`
|
|
41
42
|
${Object.values(ontology.queryTypes).map(query => `export {${query.shortApiName}} from "${query.getImportPathRelTo(relOutDir)}";`).join("\n")}
|
|
42
43
|
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
43
44
|
`));
|
|
44
45
|
}
|
|
45
|
-
async function generateV2QueryFile(fs, outDir, relOutDir, query, importExt, ontology, forInternalUse) {
|
|
46
|
+
async function generateV2QueryFile(fs, outDir, relOutDir, query, importExt, ontology, forInternalUse, fixedVersionQueryTypes) {
|
|
46
47
|
const relFilePath = path.join(relOutDir, `${query.shortApiName}.ts`);
|
|
47
48
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
48
49
|
const objectTypeObjects = new Set(objectTypes.map(o => ontology.requireObjectType(o)));
|
|
49
50
|
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
50
51
|
const baseProps = deleteUndefineds(wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
51
52
|
const outputBase = deleteUndefineds(wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
52
|
-
|
|
53
|
+
const isUsingFixedVersion = fixedVersionQueryTypes.includes(query.fullApiName);
|
|
53
54
|
await fs.writeFile(path.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
54
55
|
import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound} from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
55
56
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
@@ -93,6 +94,7 @@ async function generateV2QueryFile(fs, outDir, relOutDir, query, importExt, onto
|
|
|
93
94
|
>, VersionBound<$ExpectedClientVersion>{
|
|
94
95
|
__DefinitionMetadata?: {
|
|
95
96
|
${stringify(baseProps)}
|
|
97
|
+
isFixedVersion: ${isUsingFixedVersion};
|
|
96
98
|
parameters: {
|
|
97
99
|
${parameterDefsForType(ontology, query)}
|
|
98
100
|
};
|
|
@@ -117,15 +119,11 @@ async function generateV2QueryFile(fs, outDir, relOutDir, query, importExt, onto
|
|
|
117
119
|
"displayName": () => undefined,
|
|
118
120
|
"rid": () => undefined
|
|
119
121
|
})},
|
|
122
|
+
isFixedVersion: ${isUsingFixedVersion},
|
|
120
123
|
osdkMetadata: $osdkMetadata
|
|
121
124
|
};
|
|
122
125
|
`));
|
|
123
126
|
}
|
|
124
|
-
function parametersForConst(query) {
|
|
125
|
-
return stringify(query.parameters, {
|
|
126
|
-
"*": (parameter, formatter) => formatter(deleteUndefineds(paramToDef(parameter)))
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
127
|
function parameterDefsForType(ontology, query) {
|
|
130
128
|
return stringify(query.parameters, {
|
|
131
129
|
"*": (parameter, valueFormatter, apiName) => [`${queryParamJsDoc(paramToDef(parameter), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePerQueryDataFiles.js","names":["wireQueryDataTypeToQueryDataTypeDefinition","wireQueryParameterV2ToQueryParameterDefinition","paramToDef","wireQueryTypeV2ToSdkQueryDefinitionNoParams","path","getObjectImports","getObjectTypeApiNamesFromQuery","deleteUndefineds","stringify","formatTs","getDescriptionIfPresent","generatePerQueryDataFilesV2","fs","outDir","rootOutDir","ontology","importExt","forInternalUse","relOutDir","join","mkdir","recursive","Promise","all","Object","values","queryTypes","map","query","generateV2QueryFile","writeFile","shortApiName","getImportPathRelTo","keys","length","relFilePath","objectTypes","objectTypeObjects","Set","o","requireObjectType","importObjects","baseProps","raw","outputBase","output","apiNameObj","description","parameters","paramsIdentifier","*","parameter","formatter","apiName","q","queryParamJsDoc","nullable","getQueryParamType","type","dataType","parameterDefsForType","getLineFor__OsdkTargetType","undefined","displayName","rid","definitionIdentifier","parametersForConst","valueFormatter","qdt","objectTypeApiName","getImportedDefinitionIdentifier","param","ret","enhancedOntology","input","isMapKey","inner","JSON","struct","p","twoDimensionalAggregation","keyType","keySubtype","valueType","threeDimensionalAggregation","object","objectSet","set","union","u","multiplicity"],"sources":["generatePerQueryDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QueryParameterDefinition } from \"@osdk/api\";\nimport type { QueryDataType } from \"@osdk/foundry.ontologies\";\nimport {\n wireQueryDataTypeToQueryDataTypeDefinition,\n wireQueryParameterV2ToQueryParameterDefinition as paramToDef,\n wireQueryTypeV2ToSdkQueryDefinitionNoParams,\n} from \"@osdk/generator-converters\";\nimport path from \"node:path\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport type { EnhancedQuery } from \"../GenerateContext/EnhancedQuery.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport type { MinimalFs } from \"../MinimalFs.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { getObjectTypeApiNamesFromQuery } from \"../shared/getObjectTypeApiNamesFromQuery.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { getDescriptionIfPresent } from \"./getDescriptionIfPresent.js\";\n\nexport async function generatePerQueryDataFilesV2(\n {\n fs,\n outDir: rootOutDir,\n ontology,\n importExt = \"\",\n forInternalUse = false,\n }: Pick<\n GenerateContext,\n | \"fs\"\n | \"outDir\"\n | \"importExt\"\n | \"ontology\"\n | \"forInternalUse\"\n >,\n v2: boolean,\n): Promise<void> {\n const relOutDir = path.join(\".\", \"ontology\", \"queries\");\n const outDir = path.join(rootOutDir, \"ontology\", \"queries\");\n await fs.mkdir(outDir, { recursive: true });\n await Promise.all(\n Object.values(ontology.queryTypes).map(async query => {\n await generateV2QueryFile(\n fs,\n outDir,\n relOutDir,\n query,\n importExt,\n ontology,\n forInternalUse,\n );\n }),\n );\n\n const indexFilePath = `${outDir}.ts`;\n await fs.writeFile(\n indexFilePath,\n await formatTs(`\n ${\n Object.values(ontology.queryTypes).map(query =>\n `export {${query.shortApiName}} from \"${\n query.getImportPathRelTo(relOutDir)\n }\";`\n )\n .join(\"\\n\")\n }\n ${Object.keys(ontology.queryTypes).length === 0 ? \"export {};\" : \"\"}\n `),\n );\n}\n\nasync function generateV2QueryFile(\n fs: MinimalFs,\n outDir: string,\n relOutDir: string,\n query: EnhancedQuery,\n importExt: string,\n ontology: EnhancedOntologyDefinition,\n forInternalUse: boolean,\n) {\n const relFilePath = path.join(relOutDir, `${query.shortApiName}.ts`);\n const objectTypes = getObjectTypeApiNamesFromQuery(query);\n const objectTypeObjects = new Set(\n objectTypes.map(o => ontology.requireObjectType(o)),\n );\n const importObjects = getObjectImports(\n objectTypeObjects,\n \"\",\n relFilePath,\n true,\n );\n\n const baseProps = deleteUndefineds(\n wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw),\n );\n\n const outputBase = deleteUndefineds(\n wireQueryDataTypeToQueryDataTypeDefinition(query.output),\n );\n\n const referencedObjectTypes = objectTypes.length > 0\n ? objectTypes.map(apiNameObj => `\"${apiNameObj}\"`).join(\"|\")\n : \"never\";\n\n await fs.writeFile(\n path.join(outDir, `${query.shortApiName}.ts`),\n await formatTs(`\n import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound} from \"${\n forInternalUse ? \"@osdk/api\" : \"@osdk/client\"\n }\";\n import type { $ExpectedClientVersion } from \"../../OntologyMetadata${importExt}\";\n import { $osdkMetadata} from \"../../OntologyMetadata${importExt}\";\n ${importObjects}\n\n export namespace ${query.shortApiName} {\n export interface Signature {\n ${getDescriptionIfPresent(query.description)}\n (${\n Object.keys(query.parameters).length > 0\n ? `query: ${query.paramsIdentifier}`\n : \"\"\n }): Promise<${query.shortApiName}.ReturnType>\n }\n\n ${\n Object.keys(query.parameters).length > 0\n ? `\n export interface Parameters {\n ${\n stringify(query.parameters, {\n \"*\": (parameter, formatter, apiName) => {\n const q = paramToDef(parameter);\n return [\n `\n ${\n queryParamJsDoc(paramToDef(parameter), { apiName })\n }readonly \"${apiName}\"${q.nullable ? \"?\" : \"\"}`,\n getQueryParamType(ontology, q, \"Param\"),\n ];\n },\n })\n }\n }`\n : \"\"\n }\n\n ${\n query.output.type === \"struct\"\n ? `\n export interface ReturnType \n ${\n getQueryParamType(\n ontology,\n paramToDef({ dataType: query.output }),\n \"Result\",\n )\n }\n `\n : `\n export type ReturnType = ${\n getQueryParamType(\n ontology,\n paramToDef({ dataType: query.output }),\n \"Result\",\n )\n }\n `\n }\n }\n \n \n export interface ${query.shortApiName} extends QueryDefinition<\n ${query.shortApiName}.Signature\n >, VersionBound<$ExpectedClientVersion>{\n __DefinitionMetadata?: {\n ${stringify(baseProps)}\n parameters: {\n ${parameterDefsForType(ontology, query)}\n };\n output: {\n ${stringify(outputBase)},\n ${getLineFor__OsdkTargetType(ontology, query.output)}\n };\n signature: ${query.shortApiName}.Signature;\n }, \n ${\n stringify(baseProps, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"rid\": () => undefined,\n })\n }, \n osdkMetadata: typeof $osdkMetadata;\n }\n\n\n export const ${query.shortApiName}: ${query.definitionIdentifier} = {\n ${\n stringify(baseProps, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"rid\": () => undefined,\n })\n },\n osdkMetadata: $osdkMetadata\n };\n `),\n );\n}\n\nfunction parametersForConst(query: EnhancedQuery) {\n return stringify(query.parameters, {\n \"*\": (parameter, formatter) =>\n formatter(deleteUndefineds(paramToDef(parameter))),\n });\n}\n\nfunction parameterDefsForType(\n ontology: EnhancedOntologyDefinition,\n query: EnhancedQuery,\n) {\n return stringify(query.parameters, {\n \"*\": (parameter, valueFormatter, apiName) => [\n `${queryParamJsDoc(paramToDef(parameter), { apiName })} ${apiName}`,\n ` {\n ${stringify(deleteUndefineds(paramToDef(parameter)))},\n ${getLineFor__OsdkTargetType(ontology, parameter.dataType)}\n }`,\n ],\n });\n}\n\nfunction getLineFor__OsdkTargetType(\n ontology: EnhancedOntologyDefinition,\n qdt: QueryDataType,\n) {\n if (qdt.type === \"object\" || qdt.type === \"objectSet\") {\n return `__OsdkTargetType?: ${\n ontology.requireObjectType(\n qdt.objectTypeApiName!,\n ).getImportedDefinitionIdentifier(true)\n }`;\n }\n return \"\";\n}\n\nexport function queryParamJsDoc(\n param: QueryParameterDefinition<any>,\n { apiName }: { apiName: string },\n): string {\n let ret = `/**\\n`;\n\n if (param.description) {\n if (param.description) {\n ret += ` * description: ${param.description}\\n`;\n }\n } else {\n ret += ` * (no ontology metadata)\\n`;\n }\n\n ret += ` */\\n`;\n return ret;\n}\n\nexport function getQueryParamType(\n enhancedOntology: EnhancedOntologyDefinition,\n input: QueryParameterDefinition,\n type: \"Param\" | \"Result\",\n isMapKey = false,\n): string {\n let inner = `unknown /* ${input.type} */`;\n\n switch (input.type) {\n case \"date\":\n inner = `Query${type}.PrimitiveType<${JSON.stringify(\"datetime\")}>`;\n break;\n\n case \"attachment\":\n case \"boolean\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"string\":\n case \"timestamp\":\n inner = `Query${type}.PrimitiveType<${JSON.stringify(input.type)}>`;\n break;\n case \"struct\":\n inner = `{\n ${\n stringify(input.struct, {\n \"*\": (p, formatter, apiName) => {\n return [\n `\n ${type === \"Param\" ? \"readonly \" : \"\"}\"${apiName}\"${\n p.nullable ? \"?\" : \"\"\n }`,\n getQueryParamType(enhancedOntology, p, type),\n ];\n },\n })\n }\n }`;\n break;\n case \"twoDimensionalAggregation\":\n inner = `Query${type}.TwoDimensionalAggregationType<${\n input.twoDimensionalAggregation.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.twoDimensionalAggregation.keySubtype}\">`\n : `\"${input.twoDimensionalAggregation.keyType}\"`\n }, \"${input.twoDimensionalAggregation.valueType}\">`;\n break;\n\n case \"threeDimensionalAggregation\":\n inner = `Query${type}.ThreeDimensionalAggregationType<${\n input.threeDimensionalAggregation.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.threeDimensionalAggregation.keySubtype}\">`\n : `\"${input.threeDimensionalAggregation.keyType}\"`\n },${\n input.threeDimensionalAggregation.valueType.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.threeDimensionalAggregation.valueType.keySubtype}\">`\n : `\"${input.threeDimensionalAggregation.valueType.keyType}\"`\n }, \n \"${input.threeDimensionalAggregation.valueType.valueType}\">`;\n break;\n case \"object\":\n if (isMapKey) {\n inner = `ObjectSpecifier<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n }\n inner = `Query${type}.ObjectType<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n\n case \"objectSet\":\n inner = `Query${type}.ObjectSetType<${\n enhancedOntology.requireObjectType(input.objectSet)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n\n case \"set\":\n inner = `${type === \"Param\" ? \"Readonly\" : \"\"}Set<${\n getQueryParamType(enhancedOntology, input.set, type)\n }>`;\n break;\n\n case \"union\":\n inner = input.union.map((u) =>\n getQueryParamType(enhancedOntology, u, type)\n ).join(\" | \");\n break;\n\n case \"map\":\n inner = `Partial<Record<${\n getQueryParamType(enhancedOntology, input.keyType, type, true)\n }, ${getQueryParamType(enhancedOntology, input.valueType, type)}>>`;\n }\n\n if (input.multiplicity && type === \"Param\") {\n return `ReadonlyArray<${inner}>`;\n } else if (input.multiplicity) {\n return `Array<${inner}>`;\n }\n return inner;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SACEA,0CAA0C,EAC1CC,8CAA8C,IAAIC,UAAU,EAC5DC,2CAA2C,QACtC,4BAA4B;AACnC,OAAOC,IAAI,MAAM,WAAW;AAK5B,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,8BAA8B,QAAQ,6CAA6C;AAC5F,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,eAAeC,2BAA2BA,CAC/C;EACEC,EAAE;EACFC,MAAM,EAAEC,UAAU;EAClBC,QAAQ;EACRC,SAAS,GAAG,EAAE;EACdC,cAAc,GAAG;AAQnB,CAAC,EAEc;EACf,MAAMC,SAAS,GAAGd,IAAI,CAACe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C,IAAI,CAAC,GACvC;MACH;IAEF,KAAK,WAAW;MACdM,KAAK,GAAG,QAAQlB,IAAI,kBAClBe,gBAAgB,CAACjC,iBAAiB,CAACkC,KAAK,CAACY,SAAS,CAAC,CAChDhB,+BAA+B,CAAC,IAAI,CAAC,GACvC;MACH;IAEF,KAAK,KAAK;MACRM,KAAK,GAAG,GAAGlB,IAAI,KAAK,OAAO,GAAG,UAAU,GAAG,EAAE,OAC3CD,iBAAiB,CAACgB,gBAAgB,EAAEC,KAAK,CAACa,GAAG,EAAE7B,IAAI,CAAC,GACnD;MACH;IAEF,KAAK,OAAO;MACVkB,KAAK,GAAGF,KAAK,CAACc,KAAK,CAAC7D,GAAG,CAAE8D,CAAC,IACxBhC,iBAAiB,CAACgB,gBAAgB,EAAEgB,CAAC,EAAE/B,IAAI,CAC7C,CAAC,CAACvC,IAAI,CAAC,KAAK,CAAC;MACb;IAEF,KAAK,KAAK;MACRyD,KAAK,GAAG,kBACNnB,iBAAiB,CAACgB,gBAAgB,EAAEC,KAAK,CAACO,OAAO,EAAEvB,IAAI,EAAE,IAAI,CAAC,KAC3DD,iBAAiB,CAACgB,gBAAgB,EAAEC,KAAK,CAACS,SAAS,EAAEzB,IAAI,CAAC,IAAI;EACvE;EAEA,IAAIgB,KAAK,CAACgB,YAAY,IAAIhC,IAAI,KAAK,OAAO,EAAE;IAC1C,OAAO,iBAAiBkB,KAAK,GAAG;EAClC,CAAC,MAAM,IAAIF,KAAK,CAACgB,YAAY,EAAE;IAC7B,OAAO,SAASd,KAAK,GAAG;EAC1B;EACA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generatePerQueryDataFiles.js","names":["wireQueryDataTypeToQueryDataTypeDefinition","wireQueryParameterV2ToQueryParameterDefinition","paramToDef","wireQueryTypeV2ToSdkQueryDefinitionNoParams","path","getObjectImports","getObjectTypeApiNamesFromQuery","deleteUndefineds","stringify","formatTs","getDescriptionIfPresent","generatePerQueryDataFilesV2","fs","outDir","rootOutDir","ontology","fixedVersionQueryTypes","importExt","forInternalUse","relOutDir","join","mkdir","recursive","Promise","all","Object","values","queryTypes","map","query","generateV2QueryFile","writeFile","shortApiName","getImportPathRelTo","keys","length","relFilePath","objectTypes","objectTypeObjects","Set","o","requireObjectType","importObjects","baseProps","raw","outputBase","output","isUsingFixedVersion","includes","fullApiName","description","parameters","paramsIdentifier","*","parameter","formatter","apiName","q","queryParamJsDoc","nullable","getQueryParamType","type","dataType","parameterDefsForType","getLineFor__OsdkTargetType","undefined","displayName","rid","definitionIdentifier","valueFormatter","qdt","objectTypeApiName","getImportedDefinitionIdentifier","param","ret","enhancedOntology","input","isMapKey","inner","JSON","struct","p","twoDimensionalAggregation","keyType","keySubtype","valueType","threeDimensionalAggregation","object","objectSet","set","union","u","multiplicity"],"sources":["generatePerQueryDataFiles.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { QueryParameterDefinition } from \"@osdk/api\";\nimport type { QueryDataType } from \"@osdk/foundry.ontologies\";\nimport {\n wireQueryDataTypeToQueryDataTypeDefinition,\n wireQueryParameterV2ToQueryParameterDefinition as paramToDef,\n wireQueryTypeV2ToSdkQueryDefinitionNoParams,\n} from \"@osdk/generator-converters\";\nimport path from \"node:path\";\nimport type { EnhancedOntologyDefinition } from \"../GenerateContext/EnhancedOntologyDefinition.js\";\nimport type { EnhancedQuery } from \"../GenerateContext/EnhancedQuery.js\";\nimport type { GenerateContext } from \"../GenerateContext/GenerateContext.js\";\nimport type { MinimalFs } from \"../MinimalFs.js\";\nimport { getObjectImports } from \"../shared/getObjectImports.js\";\nimport { getObjectTypeApiNamesFromQuery } from \"../shared/getObjectTypeApiNamesFromQuery.js\";\nimport { deleteUndefineds } from \"../util/deleteUndefineds.js\";\nimport { stringify } from \"../util/stringify.js\";\nimport { formatTs } from \"../util/test/formatTs.js\";\nimport { getDescriptionIfPresent } from \"./getDescriptionIfPresent.js\";\n\nexport async function generatePerQueryDataFilesV2(\n {\n fs,\n outDir: rootOutDir,\n ontology,\n fixedVersionQueryTypes,\n importExt = \"\",\n forInternalUse = false,\n }: Pick<\n GenerateContext,\n | \"fs\"\n | \"outDir\"\n | \"importExt\"\n | \"ontology\"\n | \"forInternalUse\"\n | \"fixedVersionQueryTypes\"\n >,\n v2: boolean,\n): Promise<void> {\n const relOutDir = path.join(\".\", \"ontology\", \"queries\");\n const outDir = path.join(rootOutDir, \"ontology\", \"queries\");\n await fs.mkdir(outDir, { recursive: true });\n await Promise.all(\n Object.values(ontology.queryTypes).map(async query => {\n await generateV2QueryFile(\n fs,\n outDir,\n relOutDir,\n query,\n importExt,\n ontology,\n forInternalUse,\n fixedVersionQueryTypes,\n );\n }),\n );\n\n const indexFilePath = `${outDir}.ts`;\n await fs.writeFile(\n indexFilePath,\n await formatTs(`\n ${\n Object.values(ontology.queryTypes).map(query =>\n `export {${query.shortApiName}} from \"${\n query.getImportPathRelTo(relOutDir)\n }\";`\n )\n .join(\"\\n\")\n }\n ${Object.keys(ontology.queryTypes).length === 0 ? \"export {};\" : \"\"}\n `),\n );\n}\n\nasync function generateV2QueryFile(\n fs: MinimalFs,\n outDir: string,\n relOutDir: string,\n query: EnhancedQuery,\n importExt: string,\n ontology: EnhancedOntologyDefinition,\n forInternalUse: boolean,\n fixedVersionQueryTypes: string[],\n) {\n const relFilePath = path.join(relOutDir, `${query.shortApiName}.ts`);\n const objectTypes = getObjectTypeApiNamesFromQuery(query);\n const objectTypeObjects = new Set(\n objectTypes.map(o => ontology.requireObjectType(o)),\n );\n const importObjects = getObjectImports(\n objectTypeObjects,\n \"\",\n relFilePath,\n true,\n );\n\n const baseProps = deleteUndefineds(\n wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw),\n );\n\n const outputBase = deleteUndefineds(\n wireQueryDataTypeToQueryDataTypeDefinition(query.output),\n );\n\n const isUsingFixedVersion = fixedVersionQueryTypes.includes(\n query.fullApiName,\n );\n\n await fs.writeFile(\n path.join(outDir, `${query.shortApiName}.ts`),\n await formatTs(`\n import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound} from \"${\n forInternalUse ? \"@osdk/api\" : \"@osdk/client\"\n }\";\n import type { $ExpectedClientVersion } from \"../../OntologyMetadata${importExt}\";\n import { $osdkMetadata} from \"../../OntologyMetadata${importExt}\";\n ${importObjects}\n\n export namespace ${query.shortApiName} {\n export interface Signature {\n ${getDescriptionIfPresent(query.description)}\n (${\n Object.keys(query.parameters).length > 0\n ? `query: ${query.paramsIdentifier}`\n : \"\"\n }): Promise<${query.shortApiName}.ReturnType>\n }\n\n ${\n Object.keys(query.parameters).length > 0\n ? `\n export interface Parameters {\n ${\n stringify(query.parameters, {\n \"*\": (parameter, formatter, apiName) => {\n const q = paramToDef(parameter);\n return [\n `\n ${\n queryParamJsDoc(paramToDef(parameter), { apiName })\n }readonly \"${apiName}\"${q.nullable ? \"?\" : \"\"}`,\n getQueryParamType(ontology, q, \"Param\"),\n ];\n },\n })\n }\n }`\n : \"\"\n }\n\n ${\n query.output.type === \"struct\"\n ? `\n export interface ReturnType \n ${\n getQueryParamType(\n ontology,\n paramToDef({ dataType: query.output }),\n \"Result\",\n )\n }\n `\n : `\n export type ReturnType = ${\n getQueryParamType(\n ontology,\n paramToDef({ dataType: query.output }),\n \"Result\",\n )\n }\n `\n }\n }\n \n \n export interface ${query.shortApiName} extends QueryDefinition<\n ${query.shortApiName}.Signature\n >, VersionBound<$ExpectedClientVersion>{\n __DefinitionMetadata?: {\n ${stringify(baseProps)}\n isFixedVersion: ${isUsingFixedVersion};\n parameters: {\n ${parameterDefsForType(ontology, query)}\n };\n output: {\n ${stringify(outputBase)},\n ${getLineFor__OsdkTargetType(ontology, query.output)}\n };\n signature: ${query.shortApiName}.Signature;\n }, \n ${\n stringify(baseProps, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"rid\": () => undefined,\n })\n }, \n osdkMetadata: typeof $osdkMetadata;\n }\n\n\n export const ${query.shortApiName}: ${query.definitionIdentifier} = {\n ${\n stringify(baseProps, {\n \"description\": () => undefined,\n \"displayName\": () => undefined,\n \"rid\": () => undefined,\n })\n },\n isFixedVersion: ${isUsingFixedVersion},\n osdkMetadata: $osdkMetadata\n };\n `),\n );\n}\n\nfunction parameterDefsForType(\n ontology: EnhancedOntologyDefinition,\n query: EnhancedQuery,\n) {\n return stringify(query.parameters, {\n \"*\": (parameter, valueFormatter, apiName) => [\n `${queryParamJsDoc(paramToDef(parameter), { apiName })} ${apiName}`,\n ` {\n ${stringify(deleteUndefineds(paramToDef(parameter)))},\n ${getLineFor__OsdkTargetType(ontology, parameter.dataType)}\n }`,\n ],\n });\n}\n\nfunction getLineFor__OsdkTargetType(\n ontology: EnhancedOntologyDefinition,\n qdt: QueryDataType,\n) {\n if (qdt.type === \"object\" || qdt.type === \"objectSet\") {\n return `__OsdkTargetType?: ${\n ontology.requireObjectType(\n qdt.objectTypeApiName!,\n ).getImportedDefinitionIdentifier(true)\n }`;\n }\n return \"\";\n}\n\nexport function queryParamJsDoc(\n param: QueryParameterDefinition<any>,\n { apiName }: { apiName: string },\n): string {\n let ret = `/**\\n`;\n\n if (param.description) {\n if (param.description) {\n ret += ` * description: ${param.description}\\n`;\n }\n } else {\n ret += ` * (no ontology metadata)\\n`;\n }\n\n ret += ` */\\n`;\n return ret;\n}\n\nexport function getQueryParamType(\n enhancedOntology: EnhancedOntologyDefinition,\n input: QueryParameterDefinition,\n type: \"Param\" | \"Result\",\n isMapKey = false,\n): string {\n let inner = `unknown /* ${input.type} */`;\n\n switch (input.type) {\n case \"date\":\n inner = `Query${type}.PrimitiveType<${JSON.stringify(\"datetime\")}>`;\n break;\n\n case \"attachment\":\n case \"boolean\":\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"string\":\n case \"timestamp\":\n inner = `Query${type}.PrimitiveType<${JSON.stringify(input.type)}>`;\n break;\n case \"struct\":\n inner = `{\n ${\n stringify(input.struct, {\n \"*\": (p, formatter, apiName) => {\n return [\n `\n ${type === \"Param\" ? \"readonly \" : \"\"}\"${apiName}\"${\n p.nullable ? \"?\" : \"\"\n }`,\n getQueryParamType(enhancedOntology, p, type),\n ];\n },\n })\n }\n }`;\n break;\n case \"twoDimensionalAggregation\":\n inner = `Query${type}.TwoDimensionalAggregationType<${\n input.twoDimensionalAggregation.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.twoDimensionalAggregation.keySubtype}\">`\n : `\"${input.twoDimensionalAggregation.keyType}\"`\n }, \"${input.twoDimensionalAggregation.valueType}\">`;\n break;\n\n case \"threeDimensionalAggregation\":\n inner = `Query${type}.ThreeDimensionalAggregationType<${\n input.threeDimensionalAggregation.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.threeDimensionalAggregation.keySubtype}\">`\n : `\"${input.threeDimensionalAggregation.keyType}\"`\n },${\n input.threeDimensionalAggregation.valueType.keyType === \"range\"\n ? `Query${type}.RangeKey<\"${input.threeDimensionalAggregation.valueType.keySubtype}\">`\n : `\"${input.threeDimensionalAggregation.valueType.keyType}\"`\n }, \n \"${input.threeDimensionalAggregation.valueType.valueType}\">`;\n break;\n case \"object\":\n if (isMapKey) {\n inner = `ObjectSpecifier<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n }\n inner = `Query${type}.ObjectType<${\n enhancedOntology.requireObjectType(input.object)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n\n case \"objectSet\":\n inner = `Query${type}.ObjectSetType<${\n enhancedOntology.requireObjectType(input.objectSet)\n .getImportedDefinitionIdentifier(true)\n }>`;\n break;\n\n case \"set\":\n inner = `${type === \"Param\" ? \"Readonly\" : \"\"}Set<${\n getQueryParamType(enhancedOntology, input.set, type)\n }>`;\n break;\n\n case \"union\":\n inner = input.union.map((u) =>\n getQueryParamType(enhancedOntology, u, type)\n ).join(\" | \");\n break;\n\n case \"map\":\n inner = `Partial<Record<${\n getQueryParamType(enhancedOntology, input.keyType, type, true)\n }, ${getQueryParamType(enhancedOntology, input.valueType, type)}>>`;\n }\n\n if (input.multiplicity && type === \"Param\") {\n return `ReadonlyArray<${inner}>`;\n } else if (input.multiplicity) {\n return `Array<${inner}>`;\n }\n return inner;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SACEA,0CAA0C,EAC1CC,8CAA8C,IAAIC,UAAU,EAC5DC,2CAA2C,QACtC,4BAA4B;AACnC,OAAOC,IAAI,MAAM,WAAW;AAK5B,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,8BAA8B,QAAQ,6CAA6C;AAC5F,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,uBAAuB,QAAQ,8BAA8B;AAEtE,OAAO,eAAeC,2BAA2BA,CAC/C;EACEC,EAAE;EACFC,MAAM,EAAEC,UAAU;EAClBC,QAAQ;EACRC,sBAAsB;EACtBC,SAAS,GAAG,EAAE;EACdC,cAAc,GAAG;AASnB,CAAC,EAEc;EACf,MAAMC,SAAS,GAAGf,IAAI,CAACgB,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,CAAC;EACvD,MAAMP,MAAM,GAAGT,IAAI,CAACgB,IAAI,CAACN,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC;EAC3D,MAAMF,EAAE,CAACS,KAAK,CAACR,MAAM,EAAE;IAAES,SAAS,EAAE;EAAK,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,IACxB/B,iBAAiB,CAACe,gBAAgB,EAAEgB,CAAC,EAAE9B,IAAI,CAC7C,CAAC,CAACzC,IAAI,CAAC,KAAK,CAAC;MACb;IAEF,KAAK,KAAK;MACR0D,KAAK,GAAG,kBACNlB,iBAAiB,CAACe,gBAAgB,EAAEC,KAAK,CAACO,OAAO,EAAEtB,IAAI,EAAE,IAAI,CAAC,KAC3DD,iBAAiB,CAACe,gBAAgB,EAAEC,KAAK,CAACS,SAAS,EAAExB,IAAI,CAAC,IAAI;EACvE;EAEA,IAAIe,KAAK,CAACgB,YAAY,IAAI/B,IAAI,KAAK,OAAO,EAAE;IAC1C,OAAO,iBAAiBiB,KAAK,GAAG;EAClC,CAAC,MAAM,IAAIF,KAAK,CAACgB,YAAY,EAAE;IAC7B,OAAO,SAASd,KAAK,GAAG;EAC1B;EACA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
@@ -34,7 +34,8 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
34
34
|
}),
|
|
35
35
|
outDir: "/foo",
|
|
36
36
|
importExt: ".js",
|
|
37
|
-
forInternalUse: true
|
|
37
|
+
forInternalUse: true,
|
|
38
|
+
fixedVersionQueryTypes: []
|
|
38
39
|
}, true);
|
|
39
40
|
expect(helper.getFiles()).toMatchInlineSnapshot(`
|
|
40
41
|
{
|
|
@@ -65,7 +66,8 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
65
66
|
apiName: 'getCount';
|
|
66
67
|
rid: 'rid.query.1';
|
|
67
68
|
type: 'query';
|
|
68
|
-
version: '0';
|
|
69
|
+
version: '1.1.0';
|
|
70
|
+
isFixedVersion: false;
|
|
69
71
|
parameters: {
|
|
70
72
|
/**
|
|
71
73
|
* (no ontology metadata)
|
|
@@ -83,14 +85,15 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
83
85
|
};
|
|
84
86
|
apiName: 'getCount';
|
|
85
87
|
type: 'query';
|
|
86
|
-
version: '0';
|
|
88
|
+
version: '1.1.0';
|
|
87
89
|
osdkMetadata: typeof $osdkMetadata;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
export const getCount: getCount = {
|
|
91
93
|
apiName: 'getCount',
|
|
92
94
|
type: 'query',
|
|
93
|
-
version: '0',
|
|
95
|
+
version: '1.1.0',
|
|
96
|
+
isFixedVersion: false,
|
|
94
97
|
osdkMetadata: $osdkMetadata,
|
|
95
98
|
};
|
|
96
99
|
",
|
|
@@ -119,7 +122,8 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
119
122
|
apiName: 'returnsTodo';
|
|
120
123
|
rid: 'rid.query.2';
|
|
121
124
|
type: 'query';
|
|
122
|
-
version: '0';
|
|
125
|
+
version: '3.2.0';
|
|
126
|
+
isFixedVersion: false;
|
|
123
127
|
parameters: {
|
|
124
128
|
/**
|
|
125
129
|
* description: Random desc so we test jsdoc
|
|
@@ -142,14 +146,15 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
142
146
|
};
|
|
143
147
|
apiName: 'returnsTodo';
|
|
144
148
|
type: 'query';
|
|
145
|
-
version: '0';
|
|
149
|
+
version: '3.2.0';
|
|
146
150
|
osdkMetadata: typeof $osdkMetadata;
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
export const returnsTodo: returnsTodo = {
|
|
150
154
|
apiName: 'returnsTodo',
|
|
151
155
|
type: 'query',
|
|
152
|
-
version: '0',
|
|
156
|
+
version: '3.2.0',
|
|
157
|
+
isFixedVersion: false,
|
|
153
158
|
osdkMetadata: $osdkMetadata,
|
|
154
159
|
};
|
|
155
160
|
",
|
|
@@ -307,7 +312,8 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
307
312
|
}),
|
|
308
313
|
outDir: "/foo",
|
|
309
314
|
importExt: ".js",
|
|
310
|
-
forInternalUse: true
|
|
315
|
+
forInternalUse: true,
|
|
316
|
+
fixedVersionQueryTypes: []
|
|
311
317
|
}, true);
|
|
312
318
|
expect(helper.getFiles()["/foo/ontology/queries/doThing.ts"]).toMatchInlineSnapshot(`
|
|
313
319
|
"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';
|
|
@@ -362,6 +368,7 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
362
368
|
rid: 'rid.query.1';
|
|
363
369
|
type: 'query';
|
|
364
370
|
version: '0';
|
|
371
|
+
isFixedVersion: false;
|
|
365
372
|
parameters: {
|
|
366
373
|
/**
|
|
367
374
|
* (no ontology metadata)
|
|
@@ -446,6 +453,7 @@ describe("generatePerQueryDataFiles", () => {
|
|
|
446
453
|
apiName: 'doThing',
|
|
447
454
|
type: 'query',
|
|
448
455
|
version: '0',
|
|
456
|
+
isFixedVersion: false,
|
|
449
457
|
osdkMetadata: $osdkMetadata,
|
|
450
458
|
};
|
|
451
459
|
"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePerQueryDataFiles.test.js","names":["ts","describe","expect","it","enhanceOntology","createMockMinimalFiles","TodoWireOntology","generatePerQueryDataFilesV2","helper","fs","minimalFiles","ontology","sanitized","importExt","externalObjects","Map","externalInterfaces","externalSpts","outDir","forInternalUse","getFiles","toMatchInlineSnapshot","writeFile","rootFileNames","Object","keys","console","log","files","forEach","fileName","version","servicesHost","getScriptFileNames","getScriptVersion","toString","getScriptSnapshot","undefined","ScriptSnapshot","fromString","getCurrentDirectory","getCompilationSettings","getDefaultLibFileName","options","getDefaultLibFilePath","fileExists","path","readFile","readDirectory","extensions","exclude","include","depth","sys","directoryExists","getDirectories","langServices","createLanguageService","q","getDocCommentTemplateAtPosition","createDocumentRegistry","actionTypes","interfaceTypes","objectTypes","apiName","description","displayName","rid","queryTypes","doThing","parameters","foo","dataType","type","paramStruct","fields","name","fieldType","output","sharedPropertyTypes"],"sources":["generatePerQueryDataFiles.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as ts from \"typescript\";\nimport { describe, expect, it } from \"vitest\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { createMockMinimalFiles } from \"../util/test/createMockMinimalFiles.js\";\nimport { TodoWireOntology } from \"../util/test/TodoWireOntology.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\n\ndescribe(\"generatePerQueryDataFiles\", () => {\n it(\"is stable v2\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n\n await generatePerQueryDataFilesV2(\n {\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: TodoWireOntology,\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n },\n true,\n );\n\n expect(helper.getFiles()).toMatchInlineSnapshot(`\n {\n \"/foo/ontology/queries.ts\": \"export { getCount } from './queries/getCount.js';\n export { returnsTodo } from './queries/returnsTodo.js';\n \",\n \"/foo/ontology/queries/getCount.ts\": \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace getCount {\n export interface Signature {\n (query: getCount.Parameters): Promise<getCount.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly completed: QueryParam.PrimitiveType<'boolean'>;\n }\n\n export type ReturnType = QueryResult.PrimitiveType<'integer'>;\n }\n\n export interface getCount extends QueryDefinition<getCount.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'getCount';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * (no ontology metadata)\n */\n completed: {\n nullable: false;\n type: 'boolean';\n };\n };\n output: {\n nullable: false;\n type: 'integer';\n };\n signature: getCount.Signature;\n };\n apiName: 'getCount';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const getCount: getCount = {\n apiName: 'getCount',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n \"/foo/ontology/queries/returnsTodo.ts\": \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n import type { Todo } from '../objects/Todo.js';\n\n export namespace returnsTodo {\n export interface Signature {\n (query: returnsTodo.Parameters): Promise<returnsTodo.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * description: Random desc so we test jsdoc\n */\n readonly someTodo: QueryParam.ObjectType<Todo>;\n }\n\n export type ReturnType = QueryResult.ObjectType<Todo>;\n }\n\n export interface returnsTodo extends QueryDefinition<returnsTodo.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'returnsTodo';\n rid: 'rid.query.2';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * description: Random desc so we test jsdoc\n */\n someTodo: {\n description: 'Random desc so we test jsdoc';\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n };\n output: {\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n signature: returnsTodo.Signature;\n };\n apiName: 'returnsTodo';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const returnsTodo: returnsTodo = {\n apiName: 'returnsTodo',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \",\n }\n `);\n\n await helper.minimalFiles.writeFile(\n \"/bar/test.ts\",\n `\n import {returnsTodo} from \"/foo/ontology/queries/returnsTodo.ts\";\n\n returnsTodo({someTodo:/*marker*/})\n `,\n );\n\n const rootFileNames = Object.keys(helper.getFiles());\n console.log(rootFileNames);\n\n const files: ts.MapLike<{ version: number }> = {};\n\n // initialize the list of files\n rootFileNames.forEach(fileName => {\n files[fileName] = { version: 0 };\n });\n\n const servicesHost: ts.LanguageServiceHost = {\n getScriptFileNames: () => Object.keys(helper.getFiles()),\n getScriptVersion: fileName =>\n files[fileName] && files[fileName].version.toString(),\n getScriptSnapshot: fileName => {\n if (!helper.getFiles()[fileName]) {\n return undefined;\n }\n\n return ts.ScriptSnapshot.fromString(\n helper.getFiles()[fileName],\n );\n },\n getCurrentDirectory: () => \"/bar\",\n getCompilationSettings: () => ({}),\n getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),\n fileExists: (path: string) => {\n console.log(path);\n return helper.getFiles()[path] !== undefined;\n },\n readFile: (path: string) => {\n console.log(\"readFile: \", path);\n return helper.getFiles()[path];\n },\n readDirectory: (path, extensions, exclude, include, depth) => {\n console.log(\"readDirectory\", path);\n return ts.sys.readDirectory(path, extensions, exclude, include, depth);\n },\n directoryExists: ts.sys.directoryExists,\n getDirectories: ts.sys.getDirectories,\n };\n\n const langServices = ts.createLanguageService(servicesHost);\n\n const q = langServices.getDocCommentTemplateAtPosition(\"/bar/test.ts\", 1);\n console.log(q);\n ts.createDocumentRegistry();\n });\n\n it(\"generates structs for queries\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n\n await generatePerQueryDataFilesV2(\n {\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: {\n actionTypes: {},\n interfaceTypes: {},\n objectTypes: {},\n ontology: {\n apiName: \"foo\",\n description: \"foo\",\n displayName: \"foo\",\n rid: \"ri.foo\",\n },\n queryTypes: {\n doThing: {\n rid: \"rid.query.1\",\n version: \"0\",\n apiName: \"doThing\",\n parameters: {\n foo: {\n dataType: { type: \"string\" },\n },\n paramStruct: {\n dataType: {\n type: \"struct\",\n fields: [\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n output: {\n type: \"struct\",\n fields: [\n {\n name: \"aString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"anInteger\",\n fieldType: { type: \"integer\" },\n },\n {\n name: \"aLong\",\n fieldType: { type: \"long\" },\n },\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n sharedPropertyTypes: {},\n },\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n },\n true,\n );\n expect(helper.getFiles()[\"/foo/ontology/queries/doThing.ts\"])\n .toMatchInlineSnapshot(`\n \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace doThing {\n export interface Signature {\n (query: doThing.Parameters): Promise<doThing.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly foo: QueryParam.PrimitiveType<'string'>;\n\n /**\n * (no ontology metadata)\n */\n readonly paramStruct: {\n readonly aDate: QueryParam.PrimitiveType<'datetime'>;\n\n readonly nestedStruct: {\n readonly nestedInteger: QueryParam.PrimitiveType<'integer'>;\n\n readonly nestedString: QueryParam.PrimitiveType<'string'>;\n };\n };\n }\n\n export interface ReturnType {\n aDate: QueryResult.PrimitiveType<'datetime'>;\n\n aLong: QueryResult.PrimitiveType<'long'>;\n\n anInteger: QueryResult.PrimitiveType<'integer'>;\n\n aString: QueryResult.PrimitiveType<'string'>;\n\n nestedStruct: {\n nestedInteger: QueryResult.PrimitiveType<'integer'>;\n\n nestedString: QueryResult.PrimitiveType<'string'>;\n };\n }\n }\n\n export interface doThing extends QueryDefinition<doThing.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'doThing';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n parameters: {\n /**\n * (no ontology metadata)\n */\n foo: {\n nullable: false;\n type: 'string';\n };\n /**\n * (no ontology metadata)\n */\n paramStruct: {\n nullable: false;\n struct: {\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n };\n output: {\n nullable: false;\n struct: {\n aString: {\n type: 'string';\n nullable: false;\n };\n anInteger: {\n type: 'integer';\n nullable: false;\n };\n aLong: {\n type: 'long';\n nullable: false;\n };\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n signature: doThing.Signature;\n };\n apiName: 'doThing';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const doThing: doThing = {\n apiName: 'doThing',\n type: 'query',\n version: '0',\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generatePerQueryDataFiles.test.js","names":["ts","describe","expect","it","enhanceOntology","createMockMinimalFiles","TodoWireOntology","generatePerQueryDataFilesV2","helper","fs","minimalFiles","ontology","sanitized","importExt","externalObjects","Map","externalInterfaces","externalSpts","outDir","forInternalUse","fixedVersionQueryTypes","getFiles","toMatchInlineSnapshot","writeFile","rootFileNames","Object","keys","console","log","files","forEach","fileName","version","servicesHost","getScriptFileNames","getScriptVersion","toString","getScriptSnapshot","undefined","ScriptSnapshot","fromString","getCurrentDirectory","getCompilationSettings","getDefaultLibFileName","options","getDefaultLibFilePath","fileExists","path","readFile","readDirectory","extensions","exclude","include","depth","sys","directoryExists","getDirectories","langServices","createLanguageService","q","getDocCommentTemplateAtPosition","createDocumentRegistry","actionTypes","interfaceTypes","objectTypes","apiName","description","displayName","rid","queryTypes","doThing","parameters","foo","dataType","type","paramStruct","fields","name","fieldType","output","sharedPropertyTypes"],"sources":["generatePerQueryDataFiles.test.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as ts from \"typescript\";\nimport { describe, expect, it } from \"vitest\";\nimport { enhanceOntology } from \"../GenerateContext/enhanceOntology.js\";\nimport { createMockMinimalFiles } from \"../util/test/createMockMinimalFiles.js\";\nimport { TodoWireOntology } from \"../util/test/TodoWireOntology.js\";\nimport { generatePerQueryDataFilesV2 } from \"./generatePerQueryDataFiles.js\";\n\ndescribe(\"generatePerQueryDataFiles\", () => {\n it(\"is stable v2\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n\n await generatePerQueryDataFilesV2(\n {\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: TodoWireOntology,\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n fixedVersionQueryTypes: [],\n },\n true,\n );\n\n expect(helper.getFiles()).toMatchInlineSnapshot(`\n {\n \"/foo/ontology/queries.ts\": \"export { getCount } from './queries/getCount.js';\n export { returnsTodo } from './queries/returnsTodo.js';\n \",\n \"/foo/ontology/queries/getCount.ts\": \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace getCount {\n export interface Signature {\n (query: getCount.Parameters): Promise<getCount.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly completed: QueryParam.PrimitiveType<'boolean'>;\n }\n\n export type ReturnType = QueryResult.PrimitiveType<'integer'>;\n }\n\n export interface getCount extends QueryDefinition<getCount.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'getCount';\n rid: 'rid.query.1';\n type: 'query';\n version: '1.1.0';\n isFixedVersion: false;\n parameters: {\n /**\n * (no ontology metadata)\n */\n completed: {\n nullable: false;\n type: 'boolean';\n };\n };\n output: {\n nullable: false;\n type: 'integer';\n };\n signature: getCount.Signature;\n };\n apiName: 'getCount';\n type: 'query';\n version: '1.1.0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const getCount: getCount = {\n apiName: 'getCount',\n type: 'query',\n version: '1.1.0',\n isFixedVersion: false,\n osdkMetadata: $osdkMetadata,\n };\n \",\n \"/foo/ontology/queries/returnsTodo.ts\": \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n import type { Todo } from '../objects/Todo.js';\n\n export namespace returnsTodo {\n export interface Signature {\n (query: returnsTodo.Parameters): Promise<returnsTodo.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * description: Random desc so we test jsdoc\n */\n readonly someTodo: QueryParam.ObjectType<Todo>;\n }\n\n export type ReturnType = QueryResult.ObjectType<Todo>;\n }\n\n export interface returnsTodo extends QueryDefinition<returnsTodo.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'returnsTodo';\n rid: 'rid.query.2';\n type: 'query';\n version: '3.2.0';\n isFixedVersion: false;\n parameters: {\n /**\n * description: Random desc so we test jsdoc\n */\n someTodo: {\n description: 'Random desc so we test jsdoc';\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n };\n output: {\n nullable: false;\n object: 'Todo';\n type: 'object';\n __OsdkTargetType?: Todo;\n };\n signature: returnsTodo.Signature;\n };\n apiName: 'returnsTodo';\n type: 'query';\n version: '3.2.0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const returnsTodo: returnsTodo = {\n apiName: 'returnsTodo',\n type: 'query',\n version: '3.2.0',\n isFixedVersion: false,\n osdkMetadata: $osdkMetadata,\n };\n \",\n }\n `);\n\n await helper.minimalFiles.writeFile(\n \"/bar/test.ts\",\n `\n import {returnsTodo} from \"/foo/ontology/queries/returnsTodo.ts\";\n\n returnsTodo({someTodo:/*marker*/})\n `,\n );\n\n const rootFileNames = Object.keys(helper.getFiles());\n console.log(rootFileNames);\n\n const files: ts.MapLike<{ version: number }> = {};\n\n // initialize the list of files\n rootFileNames.forEach(fileName => {\n files[fileName] = { version: 0 };\n });\n\n const servicesHost: ts.LanguageServiceHost = {\n getScriptFileNames: () => Object.keys(helper.getFiles()),\n getScriptVersion: fileName =>\n files[fileName] && files[fileName].version.toString(),\n getScriptSnapshot: fileName => {\n if (!helper.getFiles()[fileName]) {\n return undefined;\n }\n\n return ts.ScriptSnapshot.fromString(\n helper.getFiles()[fileName],\n );\n },\n getCurrentDirectory: () => \"/bar\",\n getCompilationSettings: () => ({}),\n getDefaultLibFileName: options => ts.getDefaultLibFilePath(options),\n fileExists: (path: string) => {\n console.log(path);\n return helper.getFiles()[path] !== undefined;\n },\n readFile: (path: string) => {\n console.log(\"readFile: \", path);\n return helper.getFiles()[path];\n },\n readDirectory: (path, extensions, exclude, include, depth) => {\n console.log(\"readDirectory\", path);\n return ts.sys.readDirectory(path, extensions, exclude, include, depth);\n },\n directoryExists: ts.sys.directoryExists,\n getDirectories: ts.sys.getDirectories,\n };\n\n const langServices = ts.createLanguageService(servicesHost);\n\n const q = langServices.getDocCommentTemplateAtPosition(\"/bar/test.ts\", 1);\n console.log(q);\n ts.createDocumentRegistry();\n });\n\n it(\"generates structs for queries\", async () => {\n const helper = createMockMinimalFiles();\n const BASE_PATH = \"/foo\";\n\n await generatePerQueryDataFilesV2(\n {\n fs: helper.minimalFiles,\n ontology: enhanceOntology({\n sanitized: {\n actionTypes: {},\n interfaceTypes: {},\n objectTypes: {},\n ontology: {\n apiName: \"foo\",\n description: \"foo\",\n displayName: \"foo\",\n rid: \"ri.foo\",\n },\n queryTypes: {\n doThing: {\n rid: \"rid.query.1\",\n version: \"0\",\n apiName: \"doThing\",\n parameters: {\n foo: {\n dataType: { type: \"string\" },\n },\n paramStruct: {\n dataType: {\n type: \"struct\",\n fields: [\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n output: {\n type: \"struct\",\n fields: [\n {\n name: \"aString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"anInteger\",\n fieldType: { type: \"integer\" },\n },\n {\n name: \"aLong\",\n fieldType: { type: \"long\" },\n },\n {\n name: \"aDate\",\n fieldType: { type: \"date\" },\n },\n {\n name: \"nestedStruct\",\n fieldType: {\n type: \"struct\",\n fields: [\n {\n name: \"nestedString\",\n fieldType: { type: \"string\" },\n },\n {\n name: \"nestedInteger\",\n fieldType: { type: \"integer\" },\n },\n ],\n },\n },\n ],\n },\n },\n },\n sharedPropertyTypes: {},\n },\n importExt: \".js\",\n externalObjects: new Map(),\n externalInterfaces: new Map(),\n externalSpts: new Map(),\n }),\n outDir: BASE_PATH,\n importExt: \".js\",\n forInternalUse: true,\n fixedVersionQueryTypes: [],\n },\n true,\n );\n expect(helper.getFiles()[\"/foo/ontology/queries/doThing.ts\"])\n .toMatchInlineSnapshot(`\n \"import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound } from '@osdk/api';\n import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';\n import { $osdkMetadata } from '../../OntologyMetadata.js';\n\n export namespace doThing {\n export interface Signature {\n (query: doThing.Parameters): Promise<doThing.ReturnType>;\n }\n\n export interface Parameters {\n /**\n * (no ontology metadata)\n */\n readonly foo: QueryParam.PrimitiveType<'string'>;\n\n /**\n * (no ontology metadata)\n */\n readonly paramStruct: {\n readonly aDate: QueryParam.PrimitiveType<'datetime'>;\n\n readonly nestedStruct: {\n readonly nestedInteger: QueryParam.PrimitiveType<'integer'>;\n\n readonly nestedString: QueryParam.PrimitiveType<'string'>;\n };\n };\n }\n\n export interface ReturnType {\n aDate: QueryResult.PrimitiveType<'datetime'>;\n\n aLong: QueryResult.PrimitiveType<'long'>;\n\n anInteger: QueryResult.PrimitiveType<'integer'>;\n\n aString: QueryResult.PrimitiveType<'string'>;\n\n nestedStruct: {\n nestedInteger: QueryResult.PrimitiveType<'integer'>;\n\n nestedString: QueryResult.PrimitiveType<'string'>;\n };\n }\n }\n\n export interface doThing extends QueryDefinition<doThing.Signature>, VersionBound<$ExpectedClientVersion> {\n __DefinitionMetadata?: {\n apiName: 'doThing';\n rid: 'rid.query.1';\n type: 'query';\n version: '0';\n isFixedVersion: false;\n parameters: {\n /**\n * (no ontology metadata)\n */\n foo: {\n nullable: false;\n type: 'string';\n };\n /**\n * (no ontology metadata)\n */\n paramStruct: {\n nullable: false;\n struct: {\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n };\n output: {\n nullable: false;\n struct: {\n aString: {\n type: 'string';\n nullable: false;\n };\n anInteger: {\n type: 'integer';\n nullable: false;\n };\n aLong: {\n type: 'long';\n nullable: false;\n };\n aDate: {\n type: 'date';\n nullable: false;\n };\n nestedStruct: {\n type: 'struct';\n struct: {\n nestedString: {\n type: 'string';\n nullable: false;\n };\n nestedInteger: {\n type: 'integer';\n nullable: false;\n };\n };\n nullable: false;\n };\n };\n type: 'struct';\n };\n signature: doThing.Signature;\n };\n apiName: 'doThing';\n type: 'query';\n version: '0';\n osdkMetadata: typeof $osdkMetadata;\n }\n\n export const doThing: doThing = {\n apiName: 'doThing',\n type: 'query',\n version: '0',\n isFixedVersion: false,\n osdkMetadata: $osdkMetadata,\n };\n \"\n `);\n });\n});\n"],"mappings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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1046,6 +1046,7 @@ async function generatePerQueryDataFilesV2({
|
|
|
1046
1046
|
fs: fs2,
|
|
1047
1047
|
outDir: rootOutDir,
|
|
1048
1048
|
ontology,
|
|
1049
|
+
fixedVersionQueryTypes,
|
|
1049
1050
|
importExt = "",
|
|
1050
1051
|
forInternalUse = false
|
|
1051
1052
|
}, v2) {
|
|
@@ -1055,7 +1056,7 @@ async function generatePerQueryDataFilesV2({
|
|
|
1055
1056
|
recursive: true
|
|
1056
1057
|
});
|
|
1057
1058
|
await Promise.all(Object.values(ontology.queryTypes).map(async (query) => {
|
|
1058
|
-
await generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse);
|
|
1059
|
+
await generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse, fixedVersionQueryTypes);
|
|
1059
1060
|
}));
|
|
1060
1061
|
const indexFilePath = `${outDir}.ts`;
|
|
1061
1062
|
await fs2.writeFile(indexFilePath, await formatTs(`
|
|
@@ -1063,14 +1064,14 @@ async function generatePerQueryDataFilesV2({
|
|
|
1063
1064
|
${Object.keys(ontology.queryTypes).length === 0 ? "export {};" : ""}
|
|
1064
1065
|
`));
|
|
1065
1066
|
}
|
|
1066
|
-
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse) {
|
|
1067
|
+
async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ontology, forInternalUse, fixedVersionQueryTypes) {
|
|
1067
1068
|
const relFilePath = path8__namespace.default.join(relOutDir, `${query.shortApiName}.ts`);
|
|
1068
1069
|
const objectTypes = getObjectTypeApiNamesFromQuery(query);
|
|
1069
1070
|
const objectTypeObjects = new Set(objectTypes.map((o) => ontology.requireObjectType(o)));
|
|
1070
1071
|
const importObjects = getObjectImports(objectTypeObjects, "", relFilePath, true);
|
|
1071
1072
|
const baseProps = deleteUndefineds(generatorConverters.wireQueryTypeV2ToSdkQueryDefinitionNoParams(query.raw));
|
|
1072
1073
|
const outputBase = deleteUndefineds(generatorConverters.wireQueryDataTypeToQueryDataTypeDefinition(query.output));
|
|
1073
|
-
|
|
1074
|
+
const isUsingFixedVersion = fixedVersionQueryTypes.includes(query.fullApiName);
|
|
1074
1075
|
await fs2.writeFile(path8__namespace.default.join(outDir, `${query.shortApiName}.ts`), await formatTs(`
|
|
1075
1076
|
import type { ObjectSpecifier, QueryDefinition, QueryParam, QueryResult, VersionBound} from "${forInternalUse ? "@osdk/api" : "@osdk/client"}";
|
|
1076
1077
|
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
|
|
@@ -1114,6 +1115,7 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
1114
1115
|
>, VersionBound<$ExpectedClientVersion>{
|
|
1115
1116
|
__DefinitionMetadata?: {
|
|
1116
1117
|
${stringify(baseProps)}
|
|
1118
|
+
isFixedVersion: ${isUsingFixedVersion};
|
|
1117
1119
|
parameters: {
|
|
1118
1120
|
${parameterDefsForType(ontology, query)}
|
|
1119
1121
|
};
|
|
@@ -1138,6 +1140,7 @@ async function generateV2QueryFile(fs2, outDir, relOutDir, query, importExt, ont
|
|
|
1138
1140
|
"displayName": () => void 0,
|
|
1139
1141
|
"rid": () => void 0
|
|
1140
1142
|
})},
|
|
1143
|
+
isFixedVersion: ${isUsingFixedVersion},
|
|
1141
1144
|
osdkMetadata: $osdkMetadata
|
|
1142
1145
|
};
|
|
1143
1146
|
`));
|
|
@@ -1259,7 +1262,7 @@ function helper(x) {
|
|
|
1259
1262
|
}
|
|
1260
1263
|
|
|
1261
1264
|
// src/v2.0/generateClientSdkVersionTwoPointZero.ts
|
|
1262
|
-
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs", externalObjects = /* @__PURE__ */ new Map(), externalInterfaces = /* @__PURE__ */ new Map(), externalSpts = /* @__PURE__ */ new Map(), forInternalUse = false) {
|
|
1265
|
+
async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, outDir, packageType = "commonjs", externalObjects = /* @__PURE__ */ new Map(), externalInterfaces = /* @__PURE__ */ new Map(), externalSpts = /* @__PURE__ */ new Map(), forInternalUse = false, fixedVersionQueryTypes = []) {
|
|
1263
1266
|
const importExt = ".js";
|
|
1264
1267
|
await verifyOutDir(outDir, fs2);
|
|
1265
1268
|
const sanitizedOntology = sanitizeMetadata(ontology);
|
|
@@ -1279,7 +1282,8 @@ async function generateClientSdkVersionTwoPointZero(ontology, userAgent, fs2, ou
|
|
|
1279
1282
|
importExt,
|
|
1280
1283
|
fs: fs2,
|
|
1281
1284
|
outDir,
|
|
1282
|
-
forInternalUse
|
|
1285
|
+
forInternalUse,
|
|
1286
|
+
fixedVersionQueryTypes
|
|
1283
1287
|
};
|
|
1284
1288
|
await generateRootIndexTsFile(ctx);
|
|
1285
1289
|
await generateOntologyMetadataFile(ctx, userAgent);
|