@osdk/generator 0.0.1 → 0.0.3
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 +17 -0
- package/build/js/index.js +251 -19
- package/build/js/index.js.map +1 -1
- package/build/js/index.mjs +237 -5
- package/build/js/index.mjs.map +1 -1
- package/build/types/MinimalFs.d.ts +7 -0
- package/build/types/WireOntologyDefinition.d.ts +12 -0
- package/build/types/index.d.ts +2 -15
- package/build/types/shared/generateMetadata.d.ts +3 -0
- package/build/types/shared/getEditedEntities.d.ts +6 -0
- package/build/types/shared/index.d.ts +3 -0
- package/build/types/shared/isNullableQueryDataType.d.ts +2 -0
- package/build/types/shared/sanitizeMetadata.d.ts +2 -0
- package/build/types/shared/wireActionTypeV2ToSdkActionDefinition.d.ts +3 -0
- package/build/types/shared/wireObjectTypeV2ToSdkObjectDefinition.d.ts +3 -0
- package/build/types/shared/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.d.ts +3 -0
- package/build/types/shared/wirePropertyV2ToSdkPropertyDefinition.d.ts +3 -0
- package/build/types/shared/wireQueryDataTypeToQueryDataTypeDefinition.d.ts +3 -0
- package/build/types/shared/wireQueryTypeV2ToSdkQueryDefinition.d.ts +3 -0
- package/build/types/util/InMemoryFs.d.ts +6 -0
- package/build/types/util/commaSeparatedIdentifiers.d.ts +1 -0
- package/build/types/util/test/TodoWireOntology.d.ts +102 -0
- package/build/types/util/test/compileThis.d.ts +2 -0
- package/build/types/util/test/createMockMinimalFiles.d.ts +11 -0
- package/build/types/util/test/formatTs.d.ts +1 -0
- package/build/types/v1.1/generateActions.d.ts +3 -0
- package/build/types/v1.1/generateActions.test.d.ts +1 -0
- package/build/types/v1.1/generateClientSdkVersionOneDotOne.d.ts +3 -0
- package/build/types/v1.1/generateClientSdkVersionOneDotOne.test.d.ts +1 -0
- package/build/types/v1.1/generateFoundryClientFile.d.ts +2 -0
- package/build/types/v1.1/generateFoundryClientFile.test.d.ts +1 -0
- package/build/types/v1.1/generateIndexFile.d.ts +2 -0
- package/build/types/v1.1/generateMetadataFile.d.ts +3 -0
- package/build/types/v1.1/generateMetadataFile.test.d.ts +1 -0
- package/build/types/v1.1/generateObjectsInterfaceFile.d.ts +3 -0
- package/build/types/v1.1/generateObjectsInterfaceFile.test.d.ts +1 -0
- package/build/types/v1.1/generatePerActionDataFiles.d.ts +3 -0
- package/build/types/v1.1/generatePerActionDataFiles.test.d.ts +1 -0
- package/build/types/v1.1/generatePerObjectInterfaceAndDataFiles.d.ts +3 -0
- package/build/types/v1.1/generatePerObjectInterfaceAndDataFiles.test.d.ts +1 -0
- package/build/types/v1.1/generatePerQueryDataFiles.d.ts +3 -0
- package/build/types/v1.1/generatePerQueryDataFiles.test.d.ts +1 -0
- package/build/types/v1.1/generateQueries.d.ts +3 -0
- package/build/types/v1.1/generateQueries.test.d.ts +1 -0
- package/build/types/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.d.ts +2 -0
- package/build/types/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.test.d.ts +1 -0
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.d.ts +3 -0
- package/build/types/v2.0/generateClientSdkVersionTwoPointZero.test.d.ts +1 -0
- package/build/types/v2.0/wireObjectTypeV2ToObjectDefinitionInterfaceString.d.ts +2 -0
- package/build/types/validateWireOntologyAssumptions.d.ts +2 -0
- package/package.json +7 -2
- /package/build/types/{index.test.d.ts → shared/sanitizeMetadata.test.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @osdk/generator
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a2b7874: Addin TimeSeries support and fixing issues during code-gen time with Queries
|
|
8
|
+
- Updated dependencies [a2b7874]
|
|
9
|
+
- @osdk/api@0.0.7
|
|
10
|
+
|
|
11
|
+
## 0.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 90cc3ae: Adding Object, Object Set, Attachments, and Actions implementations for OSDK V1.1
|
|
16
|
+
- Updated dependencies [90cc3ae]
|
|
17
|
+
- @osdk/api@0.0.6
|
|
18
|
+
- @osdk/gateway@0.0.2
|
|
19
|
+
|
|
3
20
|
## 0.0.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/build/js/index.js
CHANGED
|
@@ -1,31 +1,263 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var w = require('path');
|
|
4
|
+
var prettier = require('prettier');
|
|
4
5
|
|
|
5
6
|
function _interopNamespace(e) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
}
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
17
16
|
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var w__namespace = /*#__PURE__*/_interopNamespace(w);
|
|
25
|
+
|
|
26
|
+
function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:H(r.apiName)}))}}function H(e){return e.replace(/-./g,r=>r[1].toUpperCase())}function j(e){let r=new Set,a=new Set;for(let t of e.operations)switch(t.type){case"createObject":r.add(t.objectTypeApiName);break;case"modifyObject":a.add(t.objectTypeApiName);break;}return {addedObjects:r,modifiedObjects:a}}function s(e){return prettier.format(e,{parser:"typescript",singleQuote:!0,trailingComma:"all",plugins:["prettier-plugin-organize-imports"],tabWidth:2,printWidth:120})}async function D(e,r,a){let t=new Set,o=[];for(let i of e.actionTypes){let n=Object.entries(i.parameters),d=j(i),m=Array.from(d.addedObjects),g=Array.from(d.modifiedObjects);m.forEach(t.add,t),g.forEach(t.add,t);let y=["/**"];i.description&&y.push(`* ${i.description}`);let c="";if(n.length>0){c=`params: {
|
|
27
|
+
`;for(let[b,T]of n){c+=`"${b}"`,c+=T.required?": ":"?: ";let k=E(T.dataType,t);c+=`${k};
|
|
28
|
+
`,y.push(`* @param {${k}} params.${b}`);}c+="}, ";}y.push("*/"),o.push(`
|
|
29
|
+
${y.join(`
|
|
30
|
+
`)}
|
|
31
|
+
${i.apiName}<O extends ActionExecutionOptions>(${c}options?: O):
|
|
32
|
+
Promise<Result<ActionResponseFromOptions<O, Edits<${m.length>0?m.join(" | "):"void"}, ${g.length>0?g.join(" | "):"void"}>>, ActionError>>;`);}await r.writeFile(w__namespace.default.join(a,"ontologyActions.ts"),await s(`
|
|
33
|
+
import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from "@osdk/legacy-client";
|
|
34
|
+
${Array.from(t).map(i=>`import type { ${i} } from "./objects/${i}";`).join(`
|
|
35
|
+
`)}
|
|
36
|
+
export interface Actions {
|
|
37
|
+
${o.join(`
|
|
38
|
+
`)}
|
|
39
|
+
}
|
|
40
|
+
`));}function E(e,r){switch(e.type){case"objectSet":{let t=e.objectTypeApiName;return r.add(t),`ObjectSet<${t}>`}case"object":{let t=e.objectTypeApiName;return r.add(t),`${t}`}case"array":return `Array<${E(e.subType,r)}>`;case"string":return "string";case"boolean":return "boolean";case"attachment":return "Attachment";case"date":return "LocalDate";case"double":case"integer":case"long":return "number";case"timestamp":return "Timestamp";default:throw new Error(`Unsupported action parameter type: ${e}`)}}async function F(e,r){await e.writeFile(w__namespace.default.join(r,"FoundryClient.ts"),await s(`
|
|
41
|
+
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
42
|
+
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
43
|
+
import { Ontology } from "./Ontology";
|
|
44
|
+
|
|
45
|
+
export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {
|
|
46
|
+
constructor(options: FoundryClientOptions<TAuth>) {
|
|
47
|
+
super(options, Ontology);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get ontology(): Ontology {
|
|
51
|
+
return this.ontology;
|
|
52
|
+
}
|
|
53
|
+
}`));}async function P(e,r){await e.mkdir(r,{recursive:!0}),await e.writeFile(w__namespace.join(r,"index.ts"),await s(`
|
|
54
|
+
export {
|
|
55
|
+
ActionExecutionMode,
|
|
56
|
+
ActionResponse,
|
|
57
|
+
ActionValidationResult,
|
|
58
|
+
ArrayType,
|
|
59
|
+
AttachmentType,
|
|
60
|
+
BooleanType,
|
|
61
|
+
ByteType,
|
|
62
|
+
DateType,
|
|
63
|
+
DecimalType,
|
|
64
|
+
DoubleType,
|
|
65
|
+
FloatType,
|
|
66
|
+
FoundryApiError,
|
|
67
|
+
GeoPoint,
|
|
68
|
+
GeoPointType,
|
|
69
|
+
GeoShape,
|
|
70
|
+
GeoShapeType,
|
|
71
|
+
IntegerType,
|
|
72
|
+
isErr,
|
|
73
|
+
isOk,
|
|
74
|
+
LocalDate,
|
|
75
|
+
LongType,
|
|
76
|
+
ObjectType,
|
|
77
|
+
Op,
|
|
78
|
+
Polygon,
|
|
79
|
+
ReturnEditsMode,
|
|
80
|
+
SetType,
|
|
81
|
+
ShortType,
|
|
82
|
+
StringType,
|
|
83
|
+
StructField,
|
|
84
|
+
StructType,
|
|
85
|
+
TimeSeriesType,
|
|
86
|
+
Timestamp,
|
|
87
|
+
TimestampType,
|
|
88
|
+
visitError,
|
|
89
|
+
} from '@osdk/legacy-client';
|
|
90
|
+
export type {
|
|
91
|
+
ActionError,
|
|
92
|
+
AggregateObjectsError,
|
|
93
|
+
AggregationGroup,
|
|
94
|
+
AggregationResult,
|
|
95
|
+
Attachment,
|
|
96
|
+
AttachmentMetadata,
|
|
97
|
+
AttachmentsError,
|
|
98
|
+
Edits,
|
|
99
|
+
ErrorVisitor,
|
|
100
|
+
GetLinkedObjectError,
|
|
101
|
+
GetObjectError,
|
|
102
|
+
ListLinkedObjectsError,
|
|
103
|
+
ListObjectsError,
|
|
104
|
+
LoadObjectSetError,
|
|
105
|
+
Page,
|
|
106
|
+
PermissionDenied,
|
|
107
|
+
QueryError,
|
|
108
|
+
QueryResponse,
|
|
109
|
+
Result,
|
|
110
|
+
SearchObjectsError,
|
|
111
|
+
TimeSeries,
|
|
112
|
+
TimeSeriesError,
|
|
113
|
+
TimeSeriesPoint,
|
|
114
|
+
Unauthorized,
|
|
115
|
+
UnknownError,
|
|
116
|
+
} from '@osdk/legacy-client';
|
|
117
|
+
export { Ontology } from "./Ontology";
|
|
118
|
+
export { FoundryClient } from "./FoundryClient";
|
|
119
|
+
`));}function l(e){return e.join(",")}async function V(e,r,a){let t=Object.keys(e.objectTypes),o=e.actionTypes.map(n=>n.apiName),i=e.queryTypes.map(n=>n.apiName);await r.writeFile(w__namespace.default.join(a,"Ontology.ts"),await s(`
|
|
120
|
+
import type { OntologyDefinition } from "@osdk/api";
|
|
121
|
+
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
122
|
+
import type { Objects } from "./ontologyObjects";
|
|
123
|
+
import type { Actions } from "./ontologyActions";
|
|
124
|
+
import type { Queries } from "./ontologyQueries";
|
|
125
|
+
${t.map(n=>`import {${n}} from "./objects/${n}";`).join(`
|
|
126
|
+
`)}
|
|
127
|
+
${o.map(n=>`import {${n}} from "./actions/${n}";`).join(`
|
|
128
|
+
`)}
|
|
129
|
+
${i.map(n=>`import {${n}} from "./queries/${n}";`).join(`
|
|
130
|
+
`)}
|
|
131
|
+
|
|
132
|
+
export const Ontology = {
|
|
133
|
+
metadata: {
|
|
134
|
+
ontologyRid: "${e.rid}",
|
|
135
|
+
ontologyApiName: "${e.apiName}",
|
|
136
|
+
userAgent: "foundry-typescript-osdk/0.0.1",
|
|
137
|
+
},
|
|
138
|
+
objects: {
|
|
139
|
+
${l(t)}
|
|
140
|
+
},
|
|
141
|
+
actions: {
|
|
142
|
+
${l(o)}
|
|
143
|
+
},
|
|
144
|
+
queries: {
|
|
145
|
+
${l(i)}
|
|
18
146
|
}
|
|
19
|
-
|
|
20
|
-
|
|
147
|
+
} satisfies OntologyDefinition<${t.map(n=>`"${n}"`).join("|")}, ${e.actionTypes.map(n=>`"${n.apiName}"`).join("|")}, ${e.queryTypes.map(n=>`"${n.apiName}"`).join("|")}>;
|
|
148
|
+
|
|
149
|
+
export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
150
|
+
objects: Objects;
|
|
151
|
+
actions: Actions;
|
|
152
|
+
queries: Queries;
|
|
153
|
+
}`));}async function L(e,r,a){await r.writeFile(w__namespace.default.join(a,"ontologyObjects.ts"),await s(`
|
|
154
|
+
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
155
|
+
import { ${l(Object.keys(e.objectTypes))} } from "./objects";
|
|
156
|
+
|
|
157
|
+
export interface Objects {
|
|
158
|
+
${Object.keys(e.objectTypes).map(t=>`${t} : BaseObjectSet<${t}>;`).join(`
|
|
159
|
+
`)}
|
|
160
|
+
}
|
|
161
|
+
;`));}function R(e){let r=j(e);return {apiName:e.apiName,parameters:Object.fromEntries(Object.entries(e.parameters).map(([a,t])=>[a,oe(t)])),displayName:e.displayName,description:e.description,modifiedEntities:ie(r.addedObjects,r.modifiedObjects)}}function oe(e){switch(e.dataType.type){case"string":case"boolean":case"object":case"attachment":case"date":case"double":case"integer":case"long":case"objectSet":case"timestamp":return {multiplicity:!1,type:O(e.dataType),nullable:!e.required,description:e.description};case"array":return {multiplicity:!0,type:O(e.dataType),nullable:!e.required,description:e.description}}}function O(e){switch(e.type){case"string":case"boolean":case"attachment":case"double":case"integer":case"long":case"timestamp":return e.type;case"date":return "datetime";case"objectSet":return {type:"objectSet",objectSet:e.objectTypeApiName};case"object":return {type:"object",object:e.objectTypeApiName};case"array":return O(e.subType)}}function ie(e,r){let a={};for(let t of e)a[t]={created:!0,modified:!1};for(let t of r)a[t]?a[t].modified=!0:a[t]={created:!1,modified:!0};return a}async function M(e,r,a){await r.mkdir(a,{recursive:!0}),await Promise.all(e.actionTypes.map(async t=>{let o=new Set(ne(t));await r.writeFile(w__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
162
|
+
import { ActionDefinition } from "@osdk/api";
|
|
163
|
+
|
|
164
|
+
export const ${t.apiName} = ${JSON.stringify(R(t),null,2)} satisfies ActionDefinition<"${t.apiName}", ${o.size>0?[...o].map(i=>`"${i}"`).join("|"):"never"}>;`));})),await r.writeFile(w__namespace.default.join(a,"index.ts"),await s(`
|
|
165
|
+
${e.actionTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
166
|
+
`)}
|
|
167
|
+
`));}function ne(e){let r=Object.values(e.parameters).flatMap(({dataType:t})=>{let o=I(t);return o?[o]:[]});return [...e.operations.flatMap(t=>{switch(t.type){case"createObject":return [t.objectTypeApiName];case"modifyObject":return [t.objectTypeApiName];case"deleteObject":case"createLink":case"deleteLink":return []}}),...r]}function I(e){switch(e.type){case"objectSet":case"object":return e.objectTypeApiName;case"array":return I(e.subType);case"string":case"boolean":case"attachment":case"date":case"double":case"integer":case"long":case"timestamp":return}}function q(e){switch(e.dataType.type){case"integer":case"double":case"string":case"boolean":case"attachment":case"byte":case"decimal":case"float":case"geopoint":case"geoshape":case"long":case"short":return e.dataType.type;case"date":return "datetime";case"timestamp":return "timestamp";case"timeseries":case"array":throw new Error(`Type not supported for primaryKey: ${e.dataType.type}`);default:e.dataType;throw new Error(`Unknown type encountered for primaryKey: ${e.dataType}`)}}function _(e){switch(e.dataType.type){case"integer":case"string":case"byte":case"decimal":case"double":case"float":case"long":case"short":case"boolean":case"date":case"attachment":case"geopoint":case"geoshape":case"timestamp":case"timeseries":return {multiplicity:!1,type:h(e.dataType),nullable:!0};case"array":return {multiplicity:!0,type:h(e.dataType),nullable:!0};default:e.dataType;throw new Error(`Unexpected data type ${JSON.stringify(e.dataType)}`)}}function h(e){switch(e.type){case"integer":case"string":case"byte":case"decimal":case"double":case"float":case"long":case"short":case"boolean":case"attachment":case"geopoint":case"geoshape":case"timestamp":return e.type;case"date":return "datetime";case"array":return h(e.subType);case"timeseries":return e.itemType.type==="string"?"stringTimeseries":"numericTimeseries";default:throw new Error(`Unexecpected data type ${e}`)}}function $(e,r=[]){return {apiName:e.apiName,primaryKeyType:q(e.properties[e.primaryKey]),links:Object.fromEntries(r.map(a=>[a.apiName,{multiplicity:a.cardinality==="MANY",targetType:a.objectTypeApiName}])),properties:Object.fromEntries(Object.entries(e.properties).map(([a,t])=>[a,_(t)]))}}function v(e,r=[]){let a=new Set(r.map(t=>t.objectTypeApiName).filter(t=>t!==e.apiName));return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink } from "@osdk/legacy-client";
|
|
168
|
+
${Array.from(a).map(t=>`import type { ${t} } from "./${t}";`).join(`
|
|
169
|
+
`)}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* ${e.description}
|
|
173
|
+
*/
|
|
174
|
+
export interface ${e.apiName} extends OntologyObject {
|
|
175
|
+
readonly __apiName: "${e.apiName}";
|
|
176
|
+
readonly __primaryKey: ${A(e.properties[e.primaryKey].dataType)};
|
|
177
|
+
${Object.entries(e.properties).map(([t,o])=>`${se(o.description)}readonly ${t}: ${A(o.dataType)} | undefined`).join(`;
|
|
178
|
+
`)}
|
|
179
|
+
${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleLink"}<${t.objectTypeApiName}>;`).join(`;
|
|
180
|
+
`)}
|
|
21
181
|
}
|
|
182
|
+
`}function A(e){switch(e.type){case"string":return "string";case"boolean":return "boolean";case"array":return A(e.subType)+"[]";case"integer":return "number";case"attachment":return "Attachment";case"byte":return "number";case"date":return "LocalDate";case"decimal":return "number";case"double":return "number";case"float":return "number";case"geopoint":return "GeoPoint";case"geoshape":return "GeoShape";case"long":return "number";case"short":return "number";case"timestamp":return "Timestamp";case"timeseries":return e.itemType.type==="string"?"TimeSeries<string>":"TimeSeries<number>";default:throw new Error(`Unknown property type ${e}`)}}function se(e){return e?`/**
|
|
183
|
+
* ${e}
|
|
184
|
+
*/
|
|
185
|
+
`:""}async function G(e,r,a){await r.mkdir(a,{recursive:!0}),await Promise.all(Object.values(e.objectTypes).map(async t=>{let o=e.linkTypes[t.apiName],i=new Set(o?.map(n=>n.objectTypeApiName));await r.writeFile(w__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
186
|
+
import { ObjectDefinition } from "@osdk/api";
|
|
187
|
+
${v(t,o)}
|
|
188
|
+
|
|
189
|
+
export const ${t.apiName} = ${JSON.stringify($(t,o),null,2)} satisfies ObjectDefinition<"${t.apiName}", ${i.size>0?[...i].map(n=>`"${n}"`).join("|"):"never"}>;`));})),await r.writeFile(w__namespace.default.join(a,"index.ts"),await s(`
|
|
190
|
+
${Object.keys(e.objectTypes).map(t=>`export * from "./${t}";`).join(`
|
|
191
|
+
`)}
|
|
192
|
+
`));}function u(e){return e.type==="null"?!0:e.type==="union"?e.unionTypes.some(r=>u(r)):!1}function p(e){switch(e.type){case"double":case"float":case"integer":case"long":case"attachment":case"boolean":case"date":case"string":case"timestamp":return {type:e.type,nullable:!1};case"object":return {type:{type:"object",object:e.objectTypeApiName},nullable:!1};case"objectSet":return {type:{type:"objectSet",objectSet:e.objectTypeApiName},nullable:!1};case"array":return {...p(e.subType),multiplicity:!0};case"set":return {type:{type:"set",set:p(e.subType)},nullable:!1};case"union":let r=u(e);if(r&&e.unionTypes.length===2){let t=e.unionTypes.find(o=>o.type!==null);if(t)return {...p(t),nullable:!0}}return {type:{type:"union",union:e.unionTypes.reduce((t,o)=>(o.type==="null"||t.push(p(o)),t),[])},nullable:r};case"struct":return {type:{type:"struct",struct:e.fields.map(t=>({name:t.name,fieldType:p(t.fieldType)}))},nullable:!1};case"twoDimensionalAggregation":return {type:{type:"twoDimensionalAggregation",twoDimensionalAggregation:N(e)}};case"threeDimensionalAggregation":return {type:{type:"threeDimensionalAggregation",threeDimensionalAggregation:ce(e)}};case"null":case"unsupported":throw new Error(`Accidentally tried to handle QueryDataType.type ${e.type}`);default:throw new Error(`Unsupported QueryDataType.type ${e.type}`)}}function N(e){return e.keyType.type==="range"?{keyType:e.keyType.type,keySubtype:e.keyType.subType.type,valueType:e.valueType.type}:{keyType:e.keyType.type,valueType:e.valueType.type}}function ce(e){return e.keyType.type==="range"?{keyType:e.keyType.type,keySubtype:e.keyType.subType.type,valueType:N(e.valueType)}:{keyType:e.keyType.type,valueType:N(e.valueType)}}function z(e){return {apiName:e.apiName,description:e.description,displayName:e.displayName,rid:e.rid,version:e.version,parameters:Object.fromEntries(Object.entries(e.parameters).map(([r,a])=>[r,pe(a)])),output:p(e.output)}}function pe(e){return {description:e.description,dataType:p(e.dataType)}}async function K(e,r,a){await r.mkdir(a,{recursive:!0}),await Promise.all(e.queryTypes.map(async t=>{await r.writeFile(w__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
193
|
+
import { QueryDefinition } from "@osdk/api";
|
|
194
|
+
|
|
195
|
+
export const ${t.apiName} = ${JSON.stringify(z(t))} satisfies QueryDefinition<"${t.apiName}">;`));})),await r.writeFile(w__namespace.default.join(a,"index.ts"),await s(`
|
|
196
|
+
${e.queryTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
197
|
+
`)}
|
|
198
|
+
`));}async function Y(e,r,a){let t=new Set,o=[];for(let i of e.queryTypes){let n=["/**"];i.description&&n.push(`* ${i.description}`);let d=f(i.output,t),m=[];for(let[y,c]of Object.entries(i.parameters)){let b=u(c.dataType),T=f(c.dataType,t);m.push(`"${y}"${b?"?":""}: ${T}`),n.push(`* @param {${W(T)}} params.${y}${c.description?` - ${c.description}`:""}`);}let g=m.length===0?"":`params: { ${m.join("; ")} }`;n.push(`* @returns ${W(d)}`,"*/"),o.push(`
|
|
199
|
+
${n.join(`
|
|
200
|
+
`)}
|
|
201
|
+
${i.apiName}(${g}): Promise<Result<QueryResponse<${d}>, QueryError>>;
|
|
202
|
+
`);}await r.writeFile(`${a}/ontologyQueries.ts`,await s(`
|
|
203
|
+
import type { QueryResponse, QueryError, Result, Timestamp, LocalDate, Range, Attachment, ObjectSet, TwoDimensionalAggregation, ThreeDimensionalAggregation } from "@osdk/legacy-client";
|
|
204
|
+
${Array.from(t).map(i=>`import type { ${i} } from "./objects/${i}";`).join(`
|
|
205
|
+
`)}
|
|
206
|
+
|
|
207
|
+
export interface Queries {
|
|
208
|
+
${o.join(`
|
|
209
|
+
`)}
|
|
210
|
+
}
|
|
211
|
+
`));}function f(e,r){switch(e.type){case"boolean":return "boolean";case"string":return "string";case"double":case"float":case"integer":case"long":return "number";case"date":return "LocalDate";case"timestamp":return "Timestamp";case"attachment":return "Attachment";case"array":return `Array<${f(e.subType,r)}>`;case"object":{let o=e.objectTypeApiName;return r.add(o),o}case"objectSet":{let o=e.objectTypeApiName;return r.add(o),`ObjectSet<${o}>`}case"set":return `Set<${f(e.subType,r)}>`;case"struct":return `{ ${e.fields.map(o=>{let i=u(o.fieldType);return `${o.name}${i?"?":""}: ${f(o.fieldType,r)}`}).join(`,
|
|
212
|
+
`)} }`;case"union":return e.unionTypes.map(o=>f(o,r)).join("|");case"twoDimensionalAggregation":return e.valueType,`TwoDimensionalAggregation<
|
|
213
|
+
${S(e.keyType)},
|
|
214
|
+
${J(e.valueType)}
|
|
215
|
+
>`;case"threeDimensionalAggregation":return `ThreeDimensionalAggregation<
|
|
216
|
+
${S(e.keyType)},
|
|
217
|
+
${S(e.valueType.keyType)},
|
|
218
|
+
${J(e.valueType.valueType)}
|
|
219
|
+
>`;case"null":return "null";case"unsupported":throw new Error("Cannot generate queries for unsupported type");default:throw new Error(`Cannot generate queries for type ${e.type}`)}}function S(e){switch(e.type){case"boolean":return "boolean";case"double":case"integer":return "number";case"string":return "string";case"date":return "LocalDate";case"timestamp":return "Timestamp";case"range":return `Range<${me(e.subType)}>`;default:throw new Error(`Unknown TwoDimensionalAggregation keyType ${e.type}`)}}function me(e){switch(e.type){case"date":return "LocalDate";case"double":case"integer":return "number";case"timestamp":return "Timestamp";default:throw new Error(`Unsupported QueryAggregationRangeSubType ${e.type}`)}}function J(e){switch(e.type){case"date":return "LocalDate";case"double":return "number";case"timestamp":return "Timestamp";default:throw new Error(`Unsupported QueryAggregationValueType ${e.type}`)}}function W(e){return e.replace(/\s/g,"")}async function ye(e,r,a){let t=x(e);await F(r,a),await V(t,r,a),await L(t,r,a),await G(t,r,w__namespace.join(a,"objects")),await D(t,r,a),await M(t,r,w__namespace.join(a,"actions")),await Y(t,r,a),await K(t,r,w__namespace.join(a,"queries")),await P(r,a);}function Z(e){return `
|
|
220
|
+
export interface ${e.apiName} extends ObjectDefinition<"${e.apiName}", "${e.apiName}">{
|
|
221
|
+
apiName: "${e.apiName}";
|
|
222
|
+
properties: {
|
|
223
|
+
${Object.entries(e.properties).map(([r,a])=>`
|
|
224
|
+
/**
|
|
225
|
+
* ${a.description??""}
|
|
226
|
+
**/
|
|
227
|
+
${r}: {
|
|
228
|
+
type: "${a.dataType.type}";
|
|
229
|
+
displayName: "${a.displayName??r}";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
`)}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
`}async function le(e,r,a){r.writeFile(`${a}/index.ts`,await s(`
|
|
236
|
+
export { Ontology } from "./Ontology";
|
|
237
|
+
`));let t=Object.keys(e.objectTypes);r.writeFile(`${a}/Ontology.ts`,await s(`
|
|
238
|
+
import type { OntologyDefinition } from "@osdk/api";
|
|
239
|
+
${t.map(o=>`import {${o}} from "./objects/${o}";`).join(`
|
|
240
|
+
`)}
|
|
241
|
+
|
|
242
|
+
import { OntologyMetadata } from "./OntologyMetadata";
|
|
243
|
+
|
|
244
|
+
export const Ontology = {
|
|
245
|
+
metadata: OntologyMetadata,
|
|
246
|
+
objects: {
|
|
247
|
+
${t.map(o=>`${o}: ${o},`).join(`
|
|
248
|
+
`)}
|
|
249
|
+
},
|
|
250
|
+
} satisfies OntologyDefinition<${t.map(o=>`"${o}"`).join("|")}>;
|
|
251
|
+
`));for(let o of t){let i=e.objectTypes[o];r.writeFile(`${a}/objects/${o}.ts`,await s(`
|
|
252
|
+
|
|
253
|
+
import type { ObjectDefinition } from "@osdk/api";
|
|
22
254
|
|
|
23
|
-
|
|
255
|
+
export const ${o} = ${JSON.stringify($(i),null,2)} satisfies ${o};
|
|
24
256
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`);}
|
|
257
|
+
${Z(i)}
|
|
258
|
+
`));}}
|
|
28
259
|
|
|
29
|
-
exports.generateClientSdkVersionOneDotOne =
|
|
260
|
+
exports.generateClientSdkVersionOneDotOne = ye;
|
|
261
|
+
exports.generateClientSdkVersionTwoPointZero = le;
|
|
30
262
|
//# sourceMappingURL=out.js.map
|
|
31
263
|
//# sourceMappingURL=index.js.map
|
package/build/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["path","generateClientSdkVersionOneDotOne","ontology","fs","outDir","rid","apiName","description","objectTypes","actionTypes","queryTypes","q"],"mappings":"AAgBA,UAAYA,MAAU,OACtB,eAAsBC,EAAkCC,EAExDC,EAAIC,EAAQ,CACV,GAAM,CACJ,IAAAC,EACA,QAAAC,EACA,YAAAC,EACA,YAAAC,EACA,YAAAC,EACA,WAAAC,CACF,EAAIR,EACES,EAAI,MAAMR,EAAG,UAAe,OAAKC,EAAQ,UAAU,EAAG,YAAiB,OAAKA,EAAQ,UAAU,CAAC;AAAA,kCACrEC,CAAG;AAAA,KAChC,CACL","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 path from \"node:path\";\nexport async function generateClientSdkVersionOneDotOne(ontology,\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nfs, outDir) {\n const {\n rid,\n apiName,\n description,\n objectTypes,\n actionTypes,\n queryTypes\n } = ontology;\n const q = await fs.writeFile(path.join(outDir, \"index.ts\"), `// Path: ${path.join(outDir, \"index.ts\")}\n export const ontologyRid = \"${rid}\";\n `);\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/v1.1/generateClientSdkVersionOneDotOne.ts","../../src/shared/sanitizeMetadata.ts","../../src/v1.1/generateActions.ts","../../src/shared/getEditedEntities.ts","../../src/util/test/formatTs.ts","../../src/v1.1/generateFoundryClientFile.ts","../../src/v1.1/generateIndexFile.ts","../../src/v1.1/generateMetadataFile.ts","../../src/util/commaSeparatedIdentifiers.ts","../../src/v1.1/generateObjectsInterfaceFile.ts","../../src/v1.1/generatePerActionDataFiles.ts","../../src/shared/wireActionTypeV2ToSdkActionDefinition.ts","../../src/v1.1/generatePerObjectInterfaceAndDataFiles.ts","../../src/shared/wirePropertyV2ToSdkPrimaryKeyTypeDefinition.ts","../../src/shared/wirePropertyV2ToSdkPropertyDefinition.ts","../../src/shared/wireObjectTypeV2ToSdkObjectDefinition.ts","../../src/v1.1/wireObjectTypeV2ToV1ObjectInterfaceString.ts","../../src/v1.1/generatePerQueryDataFiles.ts","../../src/shared/isNullableQueryDataType.ts","../../src/shared/wireQueryDataTypeToQueryDataTypeDefinition.ts","../../src/shared/wireQueryTypeV2ToSdkQueryDefinition.ts","../../src/v1.1/generateQueries.ts","../../src/v2.0/wireObjectTypeV2ToObjectDefinitionInterfaceString.ts","../../src/v2.0/generateClientSdkVersionTwoPointZero.ts"],"names":["path","sanitizeMetadata","ontology","actionType","camelize","name","segment","getModifiedEntityTypes","action","addedObjects","modifiedObjects","operation","_","format","formatTs","contents","generateActions","fs","outDir","importedObjects","actionSignatures","entries","modifiedEntityTypes","jsDocBlock","parameterBlock","parameterName","parameterData","typeScriptType","getTypeScriptTypeFromDataType","importedObject","actionParameter","objectType","generateFoundryClientFile","generateIndexFile","commaSeparatedIdentifiers","identifiers","generateMetadataFile","objectNames","actionNames","queryNames","query","queryType","generateObjectsInterfaceFile","apiName","wireActionTypeV2ToSdkActionDefinition","input","key","value","wireActionParameterV2ToSdkParameterDefinition","createModifiedEntities","actionPropertyToSdkPropertyDefinition","parameterType","entities","generatePerActionDataFiles","uniqueApiNames","extractReferencedObjectsFromAction","referencedObjectsInParameters","dataType","objectTypeReference","extractReferencedObjectsFromActionParameter","wirePropertyV2ToSdkPrimaryKeyTypeDefinition","wirePropertyV2ToSdkPropertyDefinition","objectPropertyTypeToSdkPropertyDefinition","propertyType","wireObjectTypeV2ToSdkObjectDefinition","linkTypes","linkType","wireObjectTypeV2ToObjectInterfaceStringV1","uniqueLinkTargets","a","linkTarget","wirePropertyTypeV2ToTypeScriptType","propertyName","propertyDefinition","getDescriptionIfPresent","property","description","generatePerObjectInterfaceAndDataFiles","object","links","isNullableQueryDataType","t","wireQueryDataTypeToQueryDataTypeDefinition","allowNulls","nonnull","acc","f","get2DQueryAggregationProps","get3DQueryAggregationProps","wireQueryTypeV2ToSdkQueryDefinition","parameter","wireQueryParameterV2ToQueryParameterDefinition","generatePerQueryDataFiles","generateQueries","signatures","outputType","handleQueryDataType","paramEntries","nullable","type","sanitizeDocTypeName","param","field","isNullable","aggregationKeyToTypescriptType","aggregationValueToTypescriptType","keyType","aggregationRangeToTypescriptType","subType","valueType","generateClientSdkVersionOneDotOne","sanitizedOntology","wireObjectTypeV2ToObjectDefinitionInterfaceString","generateClientSdkVersionTwoPointZero","n","obj"],"mappings":"AAgBA,UAAYA,MAAU,OCAf,SAASC,EAAiBC,EAAU,CACzC,MAAO,CACL,GAAGA,EACH,YAAaA,EAAS,YAAY,IAAIC,IAC7B,CACL,GAAGA,EACH,QAASC,EAASD,EAAW,OAAO,CACtC,EACD,CACH,CACF,CACA,SAASC,EAASC,EAAM,CACtB,OAAOA,EAAK,QAAQ,MAAOC,GAAWA,EAAQ,CAAC,EAAE,YAAY,CAAC,CAChE,CCbA,OAAON,OAAU,OCAV,SAASO,EAAuBC,EAAQ,CAC7C,IAAMC,EAAe,IAAI,IACnBC,EAAkB,IAAI,IAC5B,QAAWC,KAAaH,EAAO,WAC7B,OAAQG,EAAU,KAAM,CACtB,IAAK,eACHF,EAAa,IAAIE,EAAU,iBAAiB,EAC5C,MACF,IAAK,eACHD,EAAgB,IAAIC,EAAU,iBAAiB,EAC/C,MACF,IAAK,eACL,IAAK,aACL,IAAK,aACH,MACF,QACE,IAAMC,EAAID,CACd,CAEF,MAAO,CACL,aAAAF,EACA,gBAAAC,CACF,CACF,CCvBA,OAAS,UAAAG,MAAc,WAChB,SAASC,EAASC,EAAU,CACjC,OAAOF,EAAOE,EAAU,CACtB,OAAQ,aACR,YAAa,GACb,cAAe,MACf,QAAS,CAAC,kCAAkC,EAC5C,SAAU,EACV,WAAY,GACd,CAAC,CACH,CFPA,eAAsBC,EAAgBd,EAAUe,EAAIC,EAAQ,CAC1D,IAAMC,EAAkB,IAAI,IACxBC,EAAmB,CAAC,EACxB,QAAWZ,KAAUN,EAAS,YAAa,CACzC,IAAMmB,EAAU,OAAO,QAAQb,EAAO,UAAU,EAC1Cc,EAAsBf,EAAuBC,CAAM,EACnDC,EAAe,MAAM,KAAKa,EAAoB,YAAY,EAC1DZ,EAAkB,MAAM,KAAKY,EAAoB,eAAe,EACtEb,EAAa,QAAQU,EAAgB,IAAKA,CAAe,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e,EAAE;AAAA;AAAA,QAE1BD,CAAG;AAAA,mBACQC,EAAM,SAAS,IAAI;AAAA,0BACZA,EAAM,aAAeD,CAAG;AAAA;AAAA;AAAA,SAGzC,CAAC;AAAA;AAAA;AAAA,GAIV,CCfA,eAAsBmE,GAAqC/G,EAAUe,EAAIC,EAAQ,CAC/ED,EAAG,UAAU,GAAGC,CAAM,YAAa,MAAMJ,EAAS;AAAA;AAAA,KAE/C,CAAC,EACJ,IAAMuB,EAAc,OAAO,KAAKnC,EAAS,WAAW,EACpDe,EAAG,UAAU,GAAGC,CAAM,eAAgB,MAAMJ,EAAS;AAAA;AAAA,QAE/CuB,EAAY,IAAIhC,GAAQ,WAAWA,CAAI,qBAAqBA,CAAI,IAAI,EAAE,KAAK;AAAA,CAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAO5EgC,EAAY,IAAIhC,GAAQ,GAAGA,CAAI,KAAKA,CAAI,GAAG,EAAE,KAAK;AAAA,CAAI,CAAC;AAAA;AAAA,uCAE5BgC,EAAY,IAAI6E,GAAK,IAAIA,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC;AAAA,KAC1E,CAAC,EACJ,QAAW7G,KAAQgC,EAAa,CAC9B,IAAM8E,EAAMjH,EAAS,YAAYG,CAAI,EACrCY,EAAG,UAAU,GAAGC,CAAM,YAAYb,CAAI,MAAO,MAAMS,EAAS;AAAA;AAAA;AAAA;AAAA,qBAI3CT,CAAI,OAAO,KAAK,UAAU2D,EAAsCmD,CAAG,EAAG,KAAM,CAAC,CAAC,cAAc9G,CAAI;AAAA;AAAA,QAE7G2G,EAAkDG,CAAG,CAAC;AAAA,KACzD,CAAC,CACJ,CACF","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 path from \"node:path\";\nimport { sanitizeMetadata } from \"../shared/sanitizeMetadata\";\nimport { generateActions } from \"./generateActions\";\nimport { generateFoundryClientFile } from \"./generateFoundryClientFile\";\nimport { generateIndexFile } from \"./generateIndexFile\";\nimport { generateMetadataFile } from \"./generateMetadataFile\";\nimport { generateObjectsInterfaceFile } from \"./generateObjectsInterfaceFile\";\nimport { generatePerActionDataFiles } from \"./generatePerActionDataFiles\";\nimport { generatePerObjectInterfaceAndDataFiles } from \"./generatePerObjectInterfaceAndDataFiles\";\nimport { generatePerQueryDataFiles } from \"./generatePerQueryDataFiles\";\nimport { generateQueries } from \"./generateQueries\";\nexport async function generateClientSdkVersionOneDotOne(ontology, fs, outDir) {\n const sanitizedOntology = sanitizeMetadata(ontology);\n await generateFoundryClientFile(fs, outDir);\n await generateMetadataFile(sanitizedOntology, fs, outDir);\n await generateObjectsInterfaceFile(sanitizedOntology, fs, outDir);\n await generatePerObjectInterfaceAndDataFiles(sanitizedOntology, fs, path.join(outDir, \"objects\"));\n await generateActions(sanitizedOntology, fs, outDir);\n await generatePerActionDataFiles(sanitizedOntology, fs, path.join(outDir, \"actions\"));\n await generateQueries(sanitizedOntology, fs, outDir);\n await generatePerQueryDataFiles(sanitizedOntology, fs, path.join(outDir, \"queries\"));\n await generateIndexFile(fs, outDir);\n}","/*\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\nexport function sanitizeMetadata(ontology) {\n return {\n ...ontology,\n actionTypes: ontology.actionTypes.map(actionType => {\n return {\n ...actionType,\n apiName: camelize(actionType.apiName)\n };\n })\n };\n}\nfunction camelize(name) {\n return name.replace(/-./g, segment => segment[1].toUpperCase());\n}","/*\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 path from \"path\";\nimport { getModifiedEntityTypes } from \"../shared/getEditedEntities\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateActions(ontology, fs, outDir) {\n const importedObjects = new Set();\n let actionSignatures = [];\n for (const action of ontology.actionTypes) {\n const entries = Object.entries(action.parameters);\n const modifiedEntityTypes = getModifiedEntityTypes(action);\n const addedObjects = Array.from(modifiedEntityTypes.addedObjects);\n const modifiedObjects = Array.from(modifiedEntityTypes.modifiedObjects);\n addedObjects.forEach(importedObjects.add, importedObjects);\n modifiedObjects.forEach(importedObjects.add, importedObjects);\n let jsDocBlock = [\"/**\"];\n if (action.description) {\n jsDocBlock.push(`* ${action.description}`);\n }\n let parameterBlock = \"\";\n if (entries.length > 0) {\n parameterBlock = `params: { \\n`;\n for (const [parameterName, parameterData] of entries) {\n parameterBlock += `\"${parameterName}\"`;\n parameterBlock += parameterData.required ? \": \" : \"?: \";\n const typeScriptType = getTypeScriptTypeFromDataType(parameterData.dataType, importedObjects);\n parameterBlock += `${typeScriptType};\\n`;\n jsDocBlock.push(`* @param {${typeScriptType}} params.${parameterName}`);\n }\n parameterBlock += \"}, \";\n }\n jsDocBlock.push(`*/`);\n actionSignatures.push(`\n ${jsDocBlock.join(\"\\n\")}\n ${action.apiName}<O extends ActionExecutionOptions>(${parameterBlock}options?: O): \n Promise<Result<ActionResponseFromOptions<O, Edits<${addedObjects.length > 0 ? addedObjects.join(\" | \") : \"void\"}, ${modifiedObjects.length > 0 ? modifiedObjects.join(\" | \") : \"void\"}>>, ActionError>>;`);\n }\n await fs.writeFile(path.join(outDir, `ontologyActions.ts`), await formatTs(`\n import type { ObjectSet, LocalDate, Timestamp, Attachment, Edits, ActionExecutionOptions, ActionError, Result, ActionResponseFromOptions } from \"@osdk/legacy-client\";\n ${Array.from(importedObjects).map(importedObject => `import type { ${importedObject} } from \"./objects/${importedObject}\";`).join(\"\\n\")}\n export interface Actions {\n ${actionSignatures.join(\"\\n\")}\n }\n `));\n}\nfunction getTypeScriptTypeFromDataType(actionParameter, importedObjects) {\n switch (actionParameter.type) {\n case \"objectSet\":\n {\n const objectType = actionParameter.objectTypeApiName;\n importedObjects.add(objectType);\n return `ObjectSet<${objectType}>`;\n }\n case \"object\":\n {\n const objectType = actionParameter.objectTypeApiName;\n importedObjects.add(objectType);\n return `${objectType}`;\n }\n case \"array\":\n return `Array<${getTypeScriptTypeFromDataType(actionParameter.subType, importedObjects)}>`;\n case \"string\":\n return `string`;\n case \"boolean\":\n return `boolean`;\n case \"attachment\":\n return `Attachment`;\n case \"date\":\n return `LocalDate`;\n case \"double\":\n case \"integer\":\n case \"long\":\n return `number`;\n case \"timestamp\":\n return `Timestamp`;\n default:\n const _ = actionParameter;\n throw new Error(`Unsupported action parameter type: ${actionParameter}`);\n }\n}","/*\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\nexport function getModifiedEntityTypes(action) {\n const addedObjects = new Set();\n const modifiedObjects = new Set();\n for (const operation of action.operations) {\n switch (operation.type) {\n case \"createObject\":\n addedObjects.add(operation.objectTypeApiName);\n break;\n case \"modifyObject\":\n modifiedObjects.add(operation.objectTypeApiName);\n break;\n case \"deleteObject\":\n case \"createLink\":\n case \"deleteLink\":\n break;\n default:\n const _ = operation;\n }\n }\n return {\n addedObjects,\n modifiedObjects\n };\n}","/*\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 { format } from \"prettier\";\nexport function formatTs(contents) {\n return format(contents, {\n parser: \"typescript\",\n singleQuote: true,\n trailingComma: \"all\",\n plugins: [\"prettier-plugin-organize-imports\"],\n tabWidth: 2,\n printWidth: 120\n });\n}","/*\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 path from \"node:path\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateFoundryClientFile(fs, outDir) {\n await fs.writeFile(path.join(outDir, \"FoundryClient.ts\"), await formatTs(`\n import { BaseFoundryClient } from \"@osdk/legacy-client\";\n import type { Auth, FoundryClientOptions } from \"@osdk/legacy-client\";\n import { Ontology } from \"./Ontology\";\n\n export class FoundryClient<TAuth extends Auth = Auth> extends BaseFoundryClient<typeof Ontology, TAuth> {\n constructor(options: FoundryClientOptions<TAuth>) {\n super(options, Ontology);\n }\n\n get ontology(): Ontology {\n return this.ontology;\n }\n }`));\n}","/*\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 path from \"node:path\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateIndexFile(fs, outDir) {\n await fs.mkdir(outDir, {\n recursive: true\n });\n await fs.writeFile(path.join(outDir, \"index.ts\"), await formatTs(`\n export {\n ActionExecutionMode,\n ActionResponse,\n ActionValidationResult, \n ArrayType,\n AttachmentType,\n BooleanType,\n ByteType,\n DateType,\n DecimalType,\n DoubleType,\n FloatType,\n FoundryApiError, \n GeoPoint,\n GeoPointType,\n GeoShape,\n GeoShapeType,\n IntegerType,\n isErr,\n isOk, \n LocalDate,\n LongType,\n ObjectType,\n Op, \n Polygon,\n ReturnEditsMode, \n SetType,\n ShortType,\n StringType,\n StructField,\n StructType,\n TimeSeriesType,\n Timestamp,\n TimestampType,\n visitError, \n } from '@osdk/legacy-client';\n export type {\n ActionError,\n AggregateObjectsError,\n AggregationGroup,\n AggregationResult, \n Attachment,\n AttachmentMetadata, \n AttachmentsError,\n Edits,\n ErrorVisitor,\n GetLinkedObjectError,\n GetObjectError,\n ListLinkedObjectsError,\n ListObjectsError,\n LoadObjectSetError,\n Page,\n PermissionDenied,\n QueryError,\n QueryResponse, \n Result,\n SearchObjectsError,\n TimeSeries,\n TimeSeriesError,\n TimeSeriesPoint, \n Unauthorized,\n UnknownError, \n } from '@osdk/legacy-client';\n export { Ontology } from \"./Ontology\";\n export { FoundryClient } from \"./FoundryClient\";\n `));\n}","/*\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 path from \"node:path\";\nimport { commaSeparatedIdentifiers } from \"../util/commaSeparatedIdentifiers\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateMetadataFile(ontology, fs, outDir) {\n const objectNames = Object.keys(ontology.objectTypes);\n const actionNames = ontology.actionTypes.map(action => action.apiName);\n const queryNames = ontology.queryTypes.map(query => query.apiName);\n await fs.writeFile(path.join(outDir, \"Ontology.ts\"), await formatTs(`\n import type { OntologyDefinition } from \"@osdk/api\";\n import type { Ontology as ClientOntology } from \"@osdk/legacy-client\";\n import type { Objects } from \"./ontologyObjects\";\n import type { Actions } from \"./ontologyActions\";\n import type { Queries } from \"./ontologyQueries\";\n ${objectNames.map(name => `import {${name}} from \"./objects/${name}\";`).join(\"\\n\")}\n ${actionNames.map(name => `import {${name}} from \"./actions/${name}\";`).join(\"\\n\")}\n ${queryNames.map(name => `import {${name}} from \"./queries/${name}\";`).join(\"\\n\")}\n\n export const Ontology = {\n metadata: {\n ontologyRid: \"${ontology.rid}\",\n ontologyApiName: \"${ontology.apiName}\",\n userAgent: \"foundry-typescript-osdk/0.0.1\",\n },\n objects: {\n ${commaSeparatedIdentifiers(objectNames)}\n },\n actions: {\n ${commaSeparatedIdentifiers(actionNames)}\n },\n queries: {\n ${commaSeparatedIdentifiers(queryNames)}\n }\n } satisfies OntologyDefinition<${objectNames.map(n => `\"${n}\"`).join(\"|\")}, ${ontology.actionTypes.map(actionType => `\"${actionType.apiName}\"`).join(\"|\")}, ${ontology.queryTypes.map(queryType => `\"${queryType.apiName}\"`).join(\"|\")}>;\n \nexport interface Ontology extends ClientOntology<typeof Ontology> {\n objects: Objects;\n actions: Actions;\n queries: Queries;\n}`));\n}","/*\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\nexport function commaSeparatedIdentifiers(identifiers) {\n return identifiers.join(\",\");\n}","/*\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 path from \"node:path\";\nimport { commaSeparatedIdentifiers } from \"../util/commaSeparatedIdentifiers\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateObjectsInterfaceFile(ontology, fs, outDir) {\n await fs.writeFile(path.join(outDir, \"ontologyObjects.ts\"), await formatTs(`\n import { BaseObjectSet } from \"@osdk/legacy-client\";\n import { ${commaSeparatedIdentifiers(Object.keys(ontology.objectTypes))} } from \"./objects\";\n \n export interface Objects {\n ${Object.keys(ontology.objectTypes).map(apiName => `${apiName} : BaseObjectSet<${apiName}>;`).join(\"\\n\")}\n }\n ;`));\n}","/*\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 path from \"path\";\nimport { wireActionTypeV2ToSdkActionDefinition } from \"../shared/wireActionTypeV2ToSdkActionDefinition\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generatePerActionDataFiles(ontology, fs, outDir) {\n await fs.mkdir(outDir, {\n recursive: true\n });\n await Promise.all(ontology.actionTypes.map(async action => {\n const uniqueApiNames = new Set(extractReferencedObjectsFromAction(action));\n await fs.writeFile(path.join(outDir, `${action.apiName}.ts`), await formatTs(`\n import { ActionDefinition } from \"@osdk/api\";\n \n export const ${action.apiName} = ${JSON.stringify(wireActionTypeV2ToSdkActionDefinition(action), null, 2)} satisfies ActionDefinition<\"${action.apiName}\", ${uniqueApiNames.size > 0 ? [...uniqueApiNames].map(apiName => `\"${apiName}\"`).join(\"|\") : \"never\"}>;`));\n }));\n await fs.writeFile(path.join(outDir, `index.ts`), await formatTs(`\n ${ontology.actionTypes.map(action => `export * from \"./${action.apiName}\";`).join(\"\\n\")}\n `));\n}\nfunction extractReferencedObjectsFromAction(actionType) {\n const referencedObjectsInParameters = Object.values(actionType.parameters).flatMap(({\n dataType\n }) => {\n const objectTypeReference = extractReferencedObjectsFromActionParameter(dataType);\n return objectTypeReference ? [objectTypeReference] : [];\n });\n const referenceObjectsInEdits = actionType.operations.flatMap(value => {\n switch (value.type) {\n case \"createObject\":\n return [value.objectTypeApiName];\n case \"modifyObject\":\n return [value.objectTypeApiName];\n case \"deleteObject\":\n case \"createLink\":\n case \"deleteLink\":\n return [];\n }\n });\n return [...referenceObjectsInEdits, ...referencedObjectsInParameters];\n}\nfunction extractReferencedObjectsFromActionParameter(actionParameter) {\n switch (actionParameter.type) {\n case \"objectSet\":\n case \"object\":\n return actionParameter.objectTypeApiName;\n case \"array\":\n return extractReferencedObjectsFromActionParameter(actionParameter.subType);\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"date\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"timestamp\":\n return undefined;\n }\n}","/*\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 { getModifiedEntityTypes } from \"./getEditedEntities\";\nexport function wireActionTypeV2ToSdkActionDefinition(input) {\n const modifiedEntityTypes = getModifiedEntityTypes(input);\n return {\n apiName: input.apiName,\n parameters: Object.fromEntries(Object.entries(input.parameters).map(([key, value]) => [key, wireActionParameterV2ToSdkParameterDefinition(value)])),\n displayName: input.displayName,\n description: input.description,\n modifiedEntities: createModifiedEntities(modifiedEntityTypes.addedObjects, modifiedEntityTypes.modifiedObjects)\n };\n}\nfunction wireActionParameterV2ToSdkParameterDefinition(value) {\n switch (value.dataType.type) {\n case \"string\":\n case \"boolean\":\n case \"object\":\n case \"attachment\":\n case \"date\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"objectSet\":\n case \"timestamp\":\n return {\n multiplicity: false,\n type: actionPropertyToSdkPropertyDefinition(value.dataType),\n nullable: value.required ? false : true,\n description: value.description\n };\n case \"array\":\n return {\n multiplicity: true,\n type: actionPropertyToSdkPropertyDefinition(value.dataType),\n nullable: value.required ? false : true,\n description: value.description\n };\n }\n}\nfunction actionPropertyToSdkPropertyDefinition(parameterType) {\n switch (parameterType.type) {\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"double\":\n case \"integer\":\n case \"long\":\n case \"timestamp\":\n return parameterType.type;\n case \"date\":\n return \"datetime\";\n case \"objectSet\":\n return {\n type: \"objectSet\",\n objectSet: parameterType.objectTypeApiName\n };\n case \"object\":\n return {\n type: \"object\",\n object: parameterType.objectTypeApiName\n };\n case \"array\":\n return actionPropertyToSdkPropertyDefinition(parameterType.subType);\n }\n}\nfunction createModifiedEntities(addedObjects, modifiedObjects) {\n let entities = {};\n for (const key of addedObjects) {\n entities[key] = {\n created: true,\n modified: false\n };\n }\n for (const key of modifiedObjects) {\n if (entities[key]) {\n entities[key].modified = true;\n } else {\n entities[key] = {\n created: false,\n modified: true\n };\n }\n }\n return entities;\n}","/*\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 path from \"path\";\nimport { wireObjectTypeV2ToSdkObjectDefinition } from \"../shared/wireObjectTypeV2ToSdkObjectDefinition\";\nimport { formatTs } from \"../util/test/formatTs\";\nimport { wireObjectTypeV2ToObjectInterfaceStringV1 } from \"./wireObjectTypeV2ToV1ObjectInterfaceString\";\nexport async function generatePerObjectInterfaceAndDataFiles(ontology, fs, outDir) {\n await fs.mkdir(outDir, {\n recursive: true\n });\n await Promise.all(Object.values(ontology.objectTypes).map(async object => {\n const links = ontology.linkTypes[object.apiName];\n const uniqueApiNames = new Set(links?.map(a => a.objectTypeApiName));\n await fs.writeFile(path.join(outDir, `${object.apiName}.ts`), await formatTs(`\n import { ObjectDefinition } from \"@osdk/api\";\n ${wireObjectTypeV2ToObjectInterfaceStringV1(object, links)}\n\n export const ${object.apiName} = ${JSON.stringify(wireObjectTypeV2ToSdkObjectDefinition(object, links), null, 2)} satisfies ObjectDefinition<\"${object.apiName}\", ${uniqueApiNames.size > 0 ? [...uniqueApiNames].map(apiName => `\"${apiName}\"`).join(\"|\") : \"never\"}>;`));\n }));\n await fs.writeFile(path.join(outDir, \"index.ts\"), await formatTs(`\n ${Object.keys(ontology.objectTypes).map(apiName => `export * from \"./${apiName}\";`).join(\"\\n\")}\n `));\n}","/*\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\nexport function wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input) {\n switch (input.dataType.type) {\n case \"integer\":\n case \"double\":\n case \"string\":\n case \"boolean\":\n case \"attachment\":\n case \"byte\":\n case \"decimal\":\n case \"float\":\n case \"geopoint\":\n case \"geoshape\":\n case \"long\":\n case \"short\":\n {\n return input.dataType.type;\n }\n case \"date\":\n {\n return \"datetime\";\n }\n case \"timestamp\":\n {\n return \"timestamp\";\n }\n case \"timeseries\":\n case \"array\":\n throw new Error(`Type not supported for primaryKey: ${input.dataType.type}`);\n default:\n const _ = input.dataType;\n throw new Error(`Unknown type encountered for primaryKey: ${input.dataType}`);\n }\n}","/*\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\nexport function wirePropertyV2ToSdkPropertyDefinition(input) {\n switch (input.dataType.type) {\n case \"integer\":\n case \"string\":\n case \"byte\":\n case \"decimal\":\n case \"double\":\n case \"float\":\n case \"long\":\n case \"short\":\n case \"boolean\":\n case \"date\":\n case \"attachment\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n case \"timeseries\":\n return {\n multiplicity: false,\n type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),\n nullable: true\n };\n case \"array\":\n {\n return {\n multiplicity: true,\n type: objectPropertyTypeToSdkPropertyDefinition(input.dataType),\n nullable: true\n };\n }\n default:\n const _ = input.dataType;\n throw new Error(`Unexpected data type ${JSON.stringify(input.dataType)}`);\n }\n}\nfunction objectPropertyTypeToSdkPropertyDefinition(propertyType) {\n switch (propertyType.type) {\n case \"integer\":\n case \"string\":\n case \"byte\":\n case \"decimal\":\n case \"double\":\n case \"float\":\n case \"long\":\n case \"short\":\n case \"boolean\":\n case \"attachment\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n return propertyType.type;\n case \"date\":\n return \"datetime\";\n case \"array\":\n return objectPropertyTypeToSdkPropertyDefinition(propertyType.subType);\n case \"timeseries\":\n if (propertyType.itemType.type === \"string\") {\n return \"stringTimeseries\";\n }\n return \"numericTimeseries\";\n default:\n const _ = propertyType;\n throw new Error(`Unexecpected data type ${propertyType}`);\n }\n}","/*\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 { wirePropertyV2ToSdkPrimaryKeyTypeDefinition } from \"./wirePropertyV2ToSdkPrimaryKeyTypeDefinition\";\nimport { wirePropertyV2ToSdkPropertyDefinition } from \"./wirePropertyV2ToSdkPropertyDefinition\";\nexport function wireObjectTypeV2ToSdkObjectDefinition(input, linkTypes = []) {\n return {\n apiName: input.apiName,\n primaryKeyType: wirePropertyV2ToSdkPrimaryKeyTypeDefinition(input.properties[input.primaryKey]),\n links: Object.fromEntries(linkTypes.map(linkType => {\n return [linkType.apiName, {\n multiplicity: linkType.cardinality === \"MANY\",\n targetType: linkType.objectTypeApiName\n }];\n })),\n properties: Object.fromEntries(Object.entries(input.properties).map(([key, value]) => [key, wirePropertyV2ToSdkPropertyDefinition(value)]))\n };\n}","/*\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\nexport function wireObjectTypeV2ToObjectInterfaceStringV1(input, linkTypes = []) {\n const uniqueLinkTargets = new Set(linkTypes.map(a => a.objectTypeApiName).filter(a => a !== input.apiName));\n return `import type { OntologyObject, LocalDate, Timestamp, GeoShape, GeoPoint, Attachment, TimeSeries, MultiLink, SingleLink } from \"@osdk/legacy-client\";\n${Array.from(uniqueLinkTargets).map(linkTarget => `import type { ${linkTarget} } from \"./${linkTarget}\";`).join(\"\\n\")}\n\n/**\n * ${input.description}\n */\nexport interface ${input.apiName} extends OntologyObject {\n readonly __apiName: \"${input.apiName}\";\n readonly __primaryKey: ${wirePropertyTypeV2ToTypeScriptType(input.properties[input.primaryKey].dataType)};\n${Object.entries(input.properties).map(([propertyName, propertyDefinition]) => `${getDescriptionIfPresent(propertyDefinition.description)}readonly ${propertyName}: ${wirePropertyTypeV2ToTypeScriptType(propertyDefinition.dataType)} | undefined`).join(\";\\n\")}\n${linkTypes.map(linkType => `readonly ${linkType.apiName}: ${linkType.cardinality === \"MANY\" ? \"MultiLink\" : \"SingleLink\"}<${linkType.objectTypeApiName}>;`).join(\";\\n\")}\n}\n `;\n}\nfunction wirePropertyTypeV2ToTypeScriptType(property) {\n switch (property.type) {\n case \"string\":\n return \"string\";\n case \"boolean\":\n return \"boolean\";\n case \"array\":\n return wirePropertyTypeV2ToTypeScriptType(property.subType) + \"[]\";\n case \"integer\":\n return \"number\";\n case \"attachment\":\n return \"Attachment\";\n case \"byte\":\n return \"number\";\n case \"date\":\n return \"LocalDate\";\n case \"decimal\":\n return \"number\";\n case \"double\":\n return \"number\";\n case \"float\":\n return \"number\";\n case \"geopoint\":\n return \"GeoPoint\";\n case \"geoshape\":\n return \"GeoShape\";\n case \"long\":\n return \"number\";\n case \"short\":\n return \"number\";\n case \"timestamp\":\n return \"Timestamp\";\n case \"timeseries\":\n return property.itemType.type === \"string\" ? `TimeSeries<string>` : `TimeSeries<number>`;\n default:\n const _ = property;\n throw new Error(`Unknown property type ${property}`);\n }\n}\nfunction getDescriptionIfPresent(description) {\n if (description) {\n return `/**\n * ${description}\n */\\n`;\n }\n return \"\";\n}","/*\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 path from \"path\";\nimport { wireQueryTypeV2ToSdkQueryDefinition } from \"../shared/wireQueryTypeV2ToSdkQueryDefinition\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generatePerQueryDataFiles(ontology, fs, outDir) {\n await fs.mkdir(outDir, {\n recursive: true\n });\n await Promise.all(ontology.queryTypes.map(async query => {\n await fs.writeFile(path.join(outDir, `${query.apiName}.ts`), await formatTs(`\n import { QueryDefinition } from \"@osdk/api\";\n\n export const ${query.apiName} = ${JSON.stringify(wireQueryTypeV2ToSdkQueryDefinition(query))} satisfies QueryDefinition<\"${query.apiName}\">;`));\n }));\n await fs.writeFile(path.join(outDir, \"index.ts\"), await formatTs(`\n ${ontology.queryTypes.map(query => `export * from \"./${query.apiName}\";`).join(\"\\n\")}\n `));\n}","/*\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\nexport function isNullableQueryDataType(input) {\n if (input.type === \"null\") {\n return true;\n }\n if (input.type === \"union\") {\n return input.unionTypes.some(t => isNullableQueryDataType(t));\n }\n return false;\n}","/*\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 { isNullableQueryDataType } from \"./isNullableQueryDataType\";\nexport function wireQueryDataTypeToQueryDataTypeDefinition(input) {\n switch (input.type) {\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n case \"attachment\":\n case \"boolean\":\n case \"date\":\n case \"string\":\n case \"timestamp\":\n return {\n type: input.type,\n nullable: false\n };\n case \"object\":\n return {\n type: {\n type: \"object\",\n object: input.objectTypeApiName\n },\n nullable: false\n };\n case \"objectSet\":\n return {\n type: {\n type: \"objectSet\",\n objectSet: input.objectTypeApiName\n },\n nullable: false\n };\n case \"array\":\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(input.subType),\n multiplicity: true\n };\n case \"set\":\n return {\n type: {\n type: \"set\",\n set: wireQueryDataTypeToQueryDataTypeDefinition(input.subType)\n },\n nullable: false\n };\n case \"union\":\n const allowNulls = isNullableQueryDataType(input);\n\n // special case for a union where one half is nullable to skip the union step and just allow nulls directly\n if (allowNulls && input.unionTypes.length === 2) {\n const nonnull = input.unionTypes.find(t => t.type !== null);\n if (nonnull) {\n return {\n ...wireQueryDataTypeToQueryDataTypeDefinition(nonnull),\n nullable: true\n };\n }\n }\n return {\n type: {\n type: \"union\",\n union: input.unionTypes.reduce((acc, t) => {\n if (t.type === \"null\") {\n return acc;\n }\n acc.push(wireQueryDataTypeToQueryDataTypeDefinition(t));\n return acc;\n }, [])\n },\n nullable: allowNulls\n };\n case \"struct\":\n return {\n type: {\n type: \"struct\",\n struct: input.fields.map(f => ({\n name: f.name,\n fieldType: wireQueryDataTypeToQueryDataTypeDefinition(f.fieldType)\n }))\n },\n nullable: false\n };\n case \"twoDimensionalAggregation\":\n return {\n type: {\n type: \"twoDimensionalAggregation\",\n twoDimensionalAggregation: get2DQueryAggregationProps(input)\n }\n };\n case \"threeDimensionalAggregation\":\n return {\n type: {\n type: \"threeDimensionalAggregation\",\n threeDimensionalAggregation: get3DQueryAggregationProps(input)\n }\n };\n case \"null\":\n case \"unsupported\":\n throw new Error(`Accidentally tried to handle QueryDataType.type ${input.type}`);\n default:\n const _ = input;\n throw new Error(`Unsupported QueryDataType.type ${input.type}`);\n }\n}\nfunction get2DQueryAggregationProps(input) {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: input.valueType.type\n };\n } else {\n return {\n keyType: input.keyType.type,\n valueType: input.valueType.type\n };\n }\n}\nfunction get3DQueryAggregationProps(input) {\n if (input.keyType.type === \"range\") {\n return {\n keyType: input.keyType.type,\n keySubtype: input.keyType.subType.type,\n valueType: get2DQueryAggregationProps(input.valueType)\n };\n } else {\n return {\n keyType: input.keyType.type,\n valueType: get2DQueryAggregationProps(input.valueType)\n };\n }\n}","/*\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 { wireQueryDataTypeToQueryDataTypeDefinition } from \"./wireQueryDataTypeToQueryDataTypeDefinition\";\nexport function wireQueryTypeV2ToSdkQueryDefinition(input) {\n return {\n apiName: input.apiName,\n description: input.description,\n displayName: input.displayName,\n rid: input.rid,\n version: input.version,\n parameters: Object.fromEntries(Object.entries(input.parameters).map(([name, parameter]) => [name, wireQueryParameterV2ToQueryParameterDefinition(parameter)])),\n output: wireQueryDataTypeToQueryDataTypeDefinition(input.output)\n };\n}\nfunction wireQueryParameterV2ToQueryParameterDefinition(parameter) {\n return {\n description: parameter.description,\n dataType: wireQueryDataTypeToQueryDataTypeDefinition(parameter.dataType)\n };\n}","/*\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 { isNullableQueryDataType } from \"../shared/isNullableQueryDataType\";\nimport { formatTs } from \"../util/test/formatTs\";\nexport async function generateQueries(ontology, fs, outDir) {\n const importedObjects = new Set();\n const signatures = [];\n for (const query of ontology.queryTypes) {\n const jsDocBlock = [\"/**\"];\n if (query.description) {\n jsDocBlock.push(`* ${query.description}`);\n }\n const outputType = handleQueryDataType(query.output, importedObjects);\n const paramEntries = [];\n for (const [name, parameter] of Object.entries(query.parameters)) {\n const nullable = isNullableQueryDataType(parameter.dataType);\n const type = handleQueryDataType(parameter.dataType, importedObjects);\n paramEntries.push(`\"${name}\"${nullable ? \"?\" : \"\"}: ${type}`);\n jsDocBlock.push(`* @param {${sanitizeDocTypeName(type)}} params.${name}${parameter.description ? ` - ${parameter.description}` : \"\"}`);\n }\n const param = paramEntries.length === 0 ? \"\" : `params: { ${paramEntries.join(\"; \")} }`;\n jsDocBlock.push(`* @returns ${sanitizeDocTypeName(outputType)}`, \"*/\");\n signatures.push(`\n ${jsDocBlock.join(\"\\n\")}\n ${query.apiName}(${param}): Promise<Result<QueryResponse<${outputType}>, QueryError>>;\n `);\n }\n await fs.writeFile(`${outDir}/ontologyQueries.ts`, await formatTs(`\n import type { QueryResponse, QueryError, Result, Timestamp, LocalDate, Range, Attachment, ObjectSet, TwoDimensionalAggregation, ThreeDimensionalAggregation } from \"@osdk/legacy-client\";\n ${Array.from(importedObjects).map(importedObject => `import type { ${importedObject} } from \"./objects/${importedObject}\";`).join(\"\\n\")}\n\n export interface Queries {\n ${signatures.join(\"\\n\")}\n }\n `));\n}\nfunction handleQueryDataType(dataType, importedObjects) {\n switch (dataType.type) {\n case \"boolean\":\n return \"boolean\";\n case \"string\":\n return \"string\";\n case \"double\":\n case \"float\":\n case \"integer\":\n case \"long\":\n return \"number\";\n case \"date\":\n return \"LocalDate\";\n case \"timestamp\":\n return \"Timestamp\";\n case \"attachment\":\n return \"Attachment\";\n case \"array\":\n return `Array<${handleQueryDataType(dataType.subType, importedObjects)}>`;\n case \"object\":\n {\n const objectType = dataType.objectTypeApiName;\n importedObjects.add(objectType);\n return objectType;\n }\n case \"objectSet\":\n {\n const objectType = dataType.objectTypeApiName;\n importedObjects.add(objectType);\n return `ObjectSet<${objectType}>`;\n }\n case \"set\":\n return `Set<${handleQueryDataType(dataType.subType, importedObjects)}>`;\n case \"struct\":\n const properties = dataType.fields.map(field => {\n const isNullable = isNullableQueryDataType(field.fieldType);\n return `${field.name}${isNullable ? \"?\" : \"\"}: ${handleQueryDataType(field.fieldType, importedObjects)}`;\n });\n return `{ ${properties.join(\",\\n\")} }`;\n case \"union\":\n return dataType.unionTypes.map(type => handleQueryDataType(type, importedObjects)).join(\"|\");\n case \"twoDimensionalAggregation\":\n dataType.valueType;\n return `TwoDimensionalAggregation<\n ${aggregationKeyToTypescriptType(dataType.keyType)},\n ${aggregationValueToTypescriptType(dataType.valueType)}\n >`;\n case \"threeDimensionalAggregation\":\n return `ThreeDimensionalAggregation<\n ${aggregationKeyToTypescriptType(dataType.keyType)},\n ${aggregationKeyToTypescriptType(dataType.valueType.keyType)},\n ${aggregationValueToTypescriptType(dataType.valueType.valueType)}\n >`;\n case \"null\":\n return \"null\";\n case \"unsupported\":\n throw new Error(\"Cannot generate queries for unsupported type\");\n default:\n const _ = dataType;\n throw new Error(`Cannot generate queries for type ${dataType.type}`);\n }\n}\nfunction aggregationKeyToTypescriptType(keyType) {\n switch (keyType.type) {\n case \"boolean\":\n return \"boolean\";\n case \"double\":\n case \"integer\":\n return \"number\";\n case \"string\":\n return \"string\";\n case \"date\":\n return \"LocalDate\";\n case \"timestamp\":\n return \"Timestamp\";\n case \"range\":\n return `Range<${aggregationRangeToTypescriptType(keyType.subType)}>`;\n default:\n const _ = keyType;\n throw new Error(`Unknown TwoDimensionalAggregation keyType ${keyType.type}`);\n }\n}\nfunction aggregationRangeToTypescriptType(subType) {\n switch (subType.type) {\n case \"date\":\n return \"LocalDate\";\n case \"double\":\n case \"integer\":\n return \"number\";\n case \"timestamp\":\n return \"Timestamp\";\n default:\n const _ = subType;\n throw new Error(`Unsupported QueryAggregationRangeSubType ${subType.type}`);\n }\n}\nfunction aggregationValueToTypescriptType(valueType) {\n switch (valueType.type) {\n case \"date\":\n return \"LocalDate\";\n case \"double\":\n return \"number\";\n case \"timestamp\":\n return \"Timestamp\";\n default:\n const _ = valueType;\n throw new Error(`Unsupported QueryAggregationValueType ${valueType.type}`);\n }\n}\nfunction sanitizeDocTypeName(type) {\n return type.replace(/\\s/g, \"\");\n}","/*\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\nexport function wireObjectTypeV2ToObjectDefinitionInterfaceString(input) {\n return `\n export interface ${input.apiName} extends ObjectDefinition<\"${input.apiName}\", \"${input.apiName}\">{\n apiName: \"${input.apiName}\";\n properties: {\n ${Object.entries(input.properties).map(([key, value]) => `\n /**\n * ${value.description ?? \"\"}\n **/\n ${key}: {\n type: \"${value.dataType.type}\";\n displayName: \"${value.displayName ?? key}\";\n }\n \n `)}\n }\n }\n `;\n}","/*\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 { wireObjectTypeV2ToSdkObjectDefinition } from \"../shared/wireObjectTypeV2ToSdkObjectDefinition\";\nimport { formatTs } from \"../util/test/formatTs\";\nimport { wireObjectTypeV2ToObjectDefinitionInterfaceString } from \"./wireObjectTypeV2ToObjectDefinitionInterfaceString\";\nexport async function generateClientSdkVersionTwoPointZero(ontology, fs, outDir) {\n fs.writeFile(`${outDir}/index.ts`, await formatTs(`\n export { Ontology } from \"./Ontology\";\n `));\n const objectNames = Object.keys(ontology.objectTypes);\n fs.writeFile(`${outDir}/Ontology.ts`, await formatTs(`\n import type { OntologyDefinition } from \"@osdk/api\";\n ${objectNames.map(name => `import {${name}} from \"./objects/${name}\";`).join(\"\\n\")}\n ${/* FIXME: Generate this file */\"\"}\n import { OntologyMetadata } from \"./OntologyMetadata\";\n \n export const Ontology = {\n metadata: OntologyMetadata,\n objects: {\n ${objectNames.map(name => `${name}: ${name},`).join(\"\\n\")}\n },\n } satisfies OntologyDefinition<${objectNames.map(n => `\"${n}\"`).join(\"|\")}>;\n `));\n for (const name of objectNames) {\n const obj = ontology.objectTypes[name];\n fs.writeFile(`${outDir}/objects/${name}.ts`, await formatTs(`\n \n import type { ObjectDefinition } from \"@osdk/api\";\n\n export const ${name} = ${JSON.stringify(wireObjectTypeV2ToSdkObjectDefinition(obj), null, 2)} satisfies ${name};\n\n ${wireObjectTypeV2ToObjectDefinitionInterfaceString(obj)}\n `));\n }\n}"]}
|