@osdk/generator 0.0.4 → 0.0.5
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 +6 -0
- package/build/js/index.js +61 -44
- package/build/js/index.js.map +1 -1
- package/build/js/index.mjs +60 -43
- package/build/js/index.mjs.map +1 -1
- package/build/types/util/commaSeparatedTypeIdentifiers.d.ts +1 -0
- package/build/types/util/reservedKeywords.d.ts +1 -0
- package/package.json +1 -1
package/build/js/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import * as O from 'path';
|
|
|
2
2
|
import O__default from 'path';
|
|
3
3
|
import { format } from 'prettier';
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
`;for(let[j,b]of i){c+=`"${j}"`,c+=b.required?": ":"?: ";let
|
|
7
|
-
`,y.push(`* @param {${
|
|
5
|
+
function F(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ae(r.apiName)}))}}function ae(e){return e.replace(/-./g,r=>r[1].toUpperCase())}function $(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 format(e,{parser:"typescript",singleQuote:!0,trailingComma:"all",plugins:["prettier-plugin-organize-imports"],tabWidth:2,printWidth:120})}async function Q(e,r,a){let t=new Set,o=[];for(let n of e.actionTypes){let i=Object.entries(n.parameters),d=$(n),m=Array.from(d.addedObjects),g=Array.from(d.modifiedObjects);m.forEach(t.add,t),g.forEach(t.add,t);let y=["/**"];n.description&&y.push(`* ${n.description}`);let c="";if(i.length>0){c=`params: {
|
|
6
|
+
`;for(let[j,b]of i){c+=`"${j}"`,c+=b.required?": ":"?: ";let E=P(b.dataType,t);c+=`${E};
|
|
7
|
+
`,y.push(`* @param {${E}} params.${j}`);}c+="}, ";}y.push("*/"),o.push(`
|
|
8
8
|
${y.join(`
|
|
9
9
|
`)}
|
|
10
10
|
${n.apiName}<O extends ActionExecutionOptions>(${c}options?: O):
|
|
@@ -16,7 +16,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
16
16
|
${o.join(`
|
|
17
17
|
`)}
|
|
18
18
|
}
|
|
19
|
-
`));}function
|
|
19
|
+
`));}function P(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<${P(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 V(e,r){await e.writeFile(O__default.join(r,"FoundryClient.ts"),await s(`
|
|
20
20
|
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
21
21
|
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
22
22
|
import { Ontology } from "./Ontology";
|
|
@@ -29,7 +29,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
29
29
|
get ontology(): Ontology {
|
|
30
30
|
return super.ontology;
|
|
31
31
|
}
|
|
32
|
-
}`));}async function
|
|
32
|
+
}`));}async function C(e,r){await e.mkdir(r,{recursive:!0}),await e.writeFile(O.join(r,"index.ts"),await s(`
|
|
33
33
|
export {
|
|
34
34
|
ActionExecutionMode,
|
|
35
35
|
ActionResponse,
|
|
@@ -42,7 +42,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
42
42
|
DecimalType,
|
|
43
43
|
DoubleType,
|
|
44
44
|
FloatType,
|
|
45
|
-
FoundryApiError,
|
|
45
|
+
FoundryApiError,
|
|
46
46
|
GeoPoint,
|
|
47
47
|
GeoPointType,
|
|
48
48
|
GeoShape,
|
|
@@ -53,9 +53,9 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
53
53
|
LocalDate,
|
|
54
54
|
LongType,
|
|
55
55
|
ObjectType,
|
|
56
|
-
Op,
|
|
56
|
+
Op,
|
|
57
57
|
Polygon,
|
|
58
|
-
ReturnEditsMode,
|
|
58
|
+
ReturnEditsMode,
|
|
59
59
|
SetType,
|
|
60
60
|
ShortType,
|
|
61
61
|
StringType,
|
|
@@ -64,7 +64,10 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
64
64
|
TimeSeriesType,
|
|
65
65
|
Timestamp,
|
|
66
66
|
TimestampType,
|
|
67
|
-
visitError,
|
|
67
|
+
visitError,
|
|
68
|
+
PublicClientAuth,
|
|
69
|
+
ConfidentialClientAuth,
|
|
70
|
+
UserTokenAuth
|
|
68
71
|
} from '@osdk/legacy-client';
|
|
69
72
|
export type {
|
|
70
73
|
ActionError,
|
|
@@ -95,7 +98,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
95
98
|
} from '@osdk/legacy-client';
|
|
96
99
|
export { Ontology } from "./Ontology";
|
|
97
100
|
export { FoundryClient } from "./FoundryClient";
|
|
98
|
-
`));}function u(e){return e.join(",")}async function
|
|
101
|
+
`));}function u(e){return e.join(",")}function w(e){return e.map(r=>`${r}: typeof ${r}`).join(",")}async function R(e,r,a){let t=Object.keys(e.objectTypes),o=e.actionTypes.map(i=>i.apiName),n=e.queryTypes.map(i=>i.apiName);await r.writeFile(O__default.join(a,"Ontology.ts"),await s(`
|
|
99
102
|
import type { OntologyDefinition } from "@osdk/api";
|
|
100
103
|
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
101
104
|
import type { Objects } from "./ontologyObjects";
|
|
@@ -108,11 +111,26 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
108
111
|
${n.map(i=>`import {${i}} from "./queries/${i}";`).join(`
|
|
109
112
|
`)}
|
|
110
113
|
|
|
111
|
-
export const Ontology
|
|
114
|
+
export const Ontology : {
|
|
112
115
|
metadata: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
ontologyRid: "${e.rid}",
|
|
117
|
+
ontologyApiName: "${e.apiName}",
|
|
118
|
+
userAgent: "foundry-typescript-osdk/0.0.1",
|
|
119
|
+
},
|
|
120
|
+
objects: {
|
|
121
|
+
${w(t)}
|
|
122
|
+
},
|
|
123
|
+
actions: {
|
|
124
|
+
${w(o)}
|
|
125
|
+
},
|
|
126
|
+
queries: {
|
|
127
|
+
${w(n)}
|
|
128
|
+
},
|
|
129
|
+
} = {
|
|
130
|
+
metadata: {
|
|
131
|
+
ontologyRid: "${e.rid}" as const,
|
|
132
|
+
ontologyApiName: "${e.apiName}" as const,
|
|
133
|
+
userAgent: "foundry-typescript-osdk/0.0.1" as const,
|
|
116
134
|
},
|
|
117
135
|
objects: {
|
|
118
136
|
${u(t)}
|
|
@@ -129,7 +147,7 @@ export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
|
129
147
|
objects: Objects;
|
|
130
148
|
actions: Actions;
|
|
131
149
|
queries: Queries;
|
|
132
|
-
}`));}async function
|
|
150
|
+
}`));}async function v(e,r,a){await r.writeFile(O__default.join(a,"ontologyObjects.ts"),await s(`
|
|
133
151
|
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
134
152
|
import { ${u(Object.keys(e.objectTypes))} } from "./objects";
|
|
135
153
|
|
|
@@ -137,44 +155,43 @@ export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
|
137
155
|
${Object.keys(e.objectTypes).map(t=>`${t} : BaseObjectSet<${t}>;`).join(`
|
|
138
156
|
`)}
|
|
139
157
|
}
|
|
140
|
-
;`));}function
|
|
158
|
+
;`));}function M(e){let r=$(e);return {apiName:e.apiName,parameters:Object.fromEntries(Object.entries(e.parameters).map(([a,t])=>[a,pe(t)])),displayName:e.displayName,description:e.description,modifiedEntities:me(r.addedObjects,r.modifiedObjects)}}function pe(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:A(e.dataType),nullable:!e.required,description:e.description};case"array":return {multiplicity:!0,type:A(e.dataType),nullable:!e.required,description:e.description}}}function A(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 A(e.subType)}}function me(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 _(e,r,a){await r.mkdir(a,{recursive:!0}),await Promise.all(e.actionTypes.map(async t=>{let o=new Set(ye(t));await r.writeFile(O__default.join(a,`${t.apiName}.ts`),await s(`
|
|
141
159
|
import { ActionDefinition } from "@osdk/api";
|
|
142
160
|
|
|
143
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
161
|
+
export const ${t.apiName} = ${JSON.stringify(M(t),null,2)} satisfies ActionDefinition<"${t.apiName}", ${o.size>0?[...o].map(n=>`"${n}"`).join("|"):"never"}>;`));})),await r.writeFile(O__default.join(a,"index.ts"),await s(`
|
|
144
162
|
${e.actionTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
145
163
|
`)}
|
|
146
|
-
`));}function
|
|
164
|
+
`));}function ye(e){let r=Object.values(e.parameters).flatMap(({dataType:t})=>{let o=q(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 q(e){switch(e.type){case"objectSet":case"object":return e.objectTypeApiName;case"array":return q(e.subType);case"string":case"boolean":case"attachment":case"date":case"double":case"integer":case"long":case"timestamp":return}}function K(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 U(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,description:e.description,type:N(e.dataType),nullable:!0};case"array":return {multiplicity:!0,description:e.description,type:N(e.dataType),nullable:!0};default:e.dataType;throw new Error(`Unexpected data type ${JSON.stringify(e.dataType)}`)}}function N(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 N(e.subType);case"timeseries":return e.itemType.type==="string"?"stringTimeseries":"numericTimeseries";default:throw new Error(`Unexecpected data type ${e}`)}}function h(e,r=[]){return {apiName:e.apiName,description:e.description,primaryKeyType:K(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,U(t)]))}}var ue=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","implements","interface","let","package","private","protected","public","static","yield"]);function S(e){return ue.has(e)}function z(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";
|
|
147
165
|
${Array.from(a).map(t=>`import type { ${t} } from "./${t}";`).join(`
|
|
148
166
|
`)}
|
|
149
167
|
|
|
150
|
-
|
|
151
|
-
* ${e.description}
|
|
152
|
-
*/
|
|
153
|
-
export interface ${e.apiName} extends OntologyObject {
|
|
168
|
+
${G(e.description)}export interface ${e.apiName} extends OntologyObject {
|
|
154
169
|
readonly __apiName: "${e.apiName}";
|
|
155
|
-
readonly __primaryKey: ${
|
|
156
|
-
${Object.entries(e.properties).
|
|
170
|
+
readonly __primaryKey: ${k(e.properties[e.primaryKey].dataType)};
|
|
171
|
+
${Object.entries(e.properties).flatMap(([t,o])=>{let n=k(o.dataType),i=[`${G(o.description)}readonly ${t}: ${n} | undefined`];return S(t)&&i.push(`/** @deprecated please migrate to '${t}' instead */
|
|
172
|
+
readonly ${t}_: ${n} | undefined`),i}).join(`;
|
|
157
173
|
`)}
|
|
158
|
-
${r.
|
|
174
|
+
${r.flatMap(t=>{let o=[`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleLink"}<${t.objectTypeApiName}>`];return S(t.apiName)&&o.push(`/** @deprecated please migrate to '${t.apiName}' instead */
|
|
175
|
+
readonly ${t.apiName}_: ${t.cardinality==="MANY"?"MultiLink":"SingleLink"}<${t.objectTypeApiName}>`),o}).join(`;
|
|
159
176
|
`)}
|
|
160
177
|
}
|
|
161
|
-
`}function
|
|
178
|
+
`}function k(e){switch(e.type){case"string":return "string";case"boolean":return "boolean";case"array":return k(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 G(e){return e?`/**
|
|
162
179
|
* ${e}
|
|
163
180
|
*/
|
|
164
|
-
`:""}async function
|
|
181
|
+
`:""}async function J(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],n=new Set(o?.map(i=>i.objectTypeApiName));await r.writeFile(O__default.join(a,`${t.apiName}.ts`),await s(`
|
|
165
182
|
import { ObjectDefinition } from "@osdk/api";
|
|
166
|
-
${
|
|
183
|
+
${z(t,o)}
|
|
167
184
|
|
|
168
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
185
|
+
export const ${t.apiName} = ${JSON.stringify(h(t,o),null,2)} satisfies ObjectDefinition<"${t.apiName}", ${n.size>0?[...n].map(i=>`"${i}"`).join("|"):"never"}>;`));})),await r.writeFile(O__default.join(a,"index.ts"),await s(`
|
|
169
186
|
${Object.keys(e.objectTypes).map(t=>`export * from "./${t}";`).join(`
|
|
170
187
|
`)}
|
|
171
|
-
`));}function l(e){return e.type==="null"?!0:e.type==="union"?e.unionTypes.some(r=>l(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=l(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:Object.fromEntries(e.fields.map(t=>[t.name,p(t.fieldType)]))},nullable:!1};case"twoDimensionalAggregation":return {type:{type:"twoDimensionalAggregation",twoDimensionalAggregation:
|
|
188
|
+
`));}function l(e){return e.type==="null"?!0:e.type==="union"?e.unionTypes.some(r=>l(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=l(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:Object.fromEntries(e.fields.map(t=>[t.name,p(t.fieldType)]))},nullable:!1};case"twoDimensionalAggregation":return {type:{type:"twoDimensionalAggregation",twoDimensionalAggregation:D(e)}};case"threeDimensionalAggregation":return {type:{type:"threeDimensionalAggregation",threeDimensionalAggregation:le(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 D(e){if(e.keyType.type==="range")return {keyType:e.keyType.type,keySubtype:e.keyType.subType.type,valueType:e.valueType.type};if(Y(e.keyType))return {keyType:e.keyType.type,valueType:e.valueType.type};throw new Error(`Cannot create 2D aggregation with ${e.keyType.type} as its type`)}function le(e){if(e.keyType.type==="range")return {keyType:e.keyType.type,keySubtype:e.keyType.subType.type,valueType:D(e.valueType)};if(Y(e.keyType))return {keyType:e.keyType.type,valueType:D(e.valueType)};throw new Error(`Cannot create 3D aggregation with ${e.keyType.type} as its type`)}function Y(e){return e.type==="string"||e.type==="boolean"}function W(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,fe(a)])),output:p(e.output)}}function fe(e){return {description:e.description,dataType:p(e.dataType)}}async function H(e,r,a){await r.mkdir(a,{recursive:!0}),await Promise.all(e.queryTypes.map(async t=>{let o=de(t);await r.writeFile(O__default.join(a,`${t.apiName}.ts`),await s(`
|
|
172
189
|
import { QueryDefinition } from "@osdk/api";
|
|
173
190
|
|
|
174
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
191
|
+
export const ${t.apiName} = ${JSON.stringify(W(t))} satisfies QueryDefinition<"${t.apiName}", ${o.length>0?o.map(n=>`"${n}"`).join("|"):"never"}>;`));})),await r.writeFile(O__default.join(a,"index.ts"),await s(`
|
|
175
192
|
${e.queryTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
176
193
|
`)}
|
|
177
|
-
`));}function
|
|
194
|
+
`));}function de(e){let r=new Set;for(let{dataType:a}of Object.values(e.parameters))T(a,r);return T(e.output,r),Array.from(r)}function T(e,r){switch(e.type){case"array":case"set":T(e.subType,r);return;case"object":r.add(e.objectTypeApiName);return;case"objectSet":r.add(e.objectTypeApiName);return;case"struct":for(let t of Object.values(e.fields))T(t.fieldType,r);return;case"union":for(let t of e.unionTypes)T(t,r);return;case"attachment":case"boolean":case"date":case"double":case"float":case"integer":case"long":case"null":case"string":case"threeDimensionalAggregation":case"timestamp":case"twoDimensionalAggregation":case"unsupported":return;default:throw new Error(`Cannot find object types from unsupported QueryDataType ${e.type}`)}}async function te(e,r,a){let t=new Set,o=[];for(let n of e.queryTypes){let i=["/**"];n.description&&i.push(`* ${n.description}`);let d=f(n.output,t),m=[];for(let[y,c]of Object.entries(n.parameters)){let j=l(c.dataType),b=f(c.dataType,t);m.push(`"${y}"${j?"?":""}: ${b}`),i.push(`* @param {${ee(b)}} params.${y}${c.description?` - ${c.description}`:""}`);}let g=m.length===0?"":`params: { ${m.join("; ")} }`;i.push(`* @returns ${ee(d)}`,"*/"),o.push(`
|
|
178
195
|
${i.join(`
|
|
179
196
|
`)}
|
|
180
197
|
${n.apiName}(${g}): Promise<Result<QueryResponse<${d}>, QueryError>>;
|
|
@@ -188,14 +205,14 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
188
205
|
`)}
|
|
189
206
|
}
|
|
190
207
|
`));}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 n=l(o.fieldType);return `${o.name}${n?"?":""}: ${f(o.fieldType,r)}`}).join(`,
|
|
191
|
-
`)} }`;case"union":return e.unionTypes.map(o=>f(o,r)).join("|");case"twoDimensionalAggregation":return e.valueType,`TwoDimensionalAggregation<
|
|
192
|
-
${
|
|
193
|
-
${
|
|
208
|
+
`)} }`;case"union":return e.unionTypes.map(o=>f(o,r)).filter(o=>o!=="null").join("|");case"twoDimensionalAggregation":return e.valueType,`TwoDimensionalAggregation<
|
|
209
|
+
${x(e.keyType)},
|
|
210
|
+
${X(e.valueType)}
|
|
194
211
|
>`;case"threeDimensionalAggregation":return `ThreeDimensionalAggregation<
|
|
195
|
-
${
|
|
196
|
-
${
|
|
197
|
-
${
|
|
198
|
-
>`;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
|
|
212
|
+
${x(e.keyType)},
|
|
213
|
+
${x(e.valueType.keyType)},
|
|
214
|
+
${X(e.valueType.valueType)}
|
|
215
|
+
>`;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 x(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<${ge(e.subType)}>`;default:throw new Error(`Unknown TwoDimensionalAggregation keyType ${e.type}`)}}function ge(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 X(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 ee(e){return e.replace(/\s/g,"")}async function be(e,r,a){let t=F(e);await V(r,a),await R(t,r,a),await v(t,r,a),await J(t,r,O.join(a,"objects")),await Q(t,r,a),await _(t,r,O.join(a,"actions")),await te(t,r,a),await H(t,r,O.join(a,"queries")),await C(r,a);}function re(e){return `
|
|
199
216
|
export interface ${e.apiName} extends ObjectDefinition<"${e.apiName}", "${e.apiName}">{
|
|
200
217
|
apiName: "${e.apiName}";
|
|
201
218
|
properties: {
|
|
@@ -211,7 +228,7 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
211
228
|
`)}
|
|
212
229
|
}
|
|
213
230
|
}
|
|
214
|
-
`}async function
|
|
231
|
+
`}async function Te(e,r,a){r.writeFile(`${a}/index.ts`,await s(`
|
|
215
232
|
export { Ontology } from "./Ontology";
|
|
216
233
|
`));let t=Object.keys(e.objectTypes);r.writeFile(`${a}/Ontology.ts`,await s(`
|
|
217
234
|
import type { OntologyDefinition } from "@osdk/api";
|
|
@@ -231,11 +248,11 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
231
248
|
|
|
232
249
|
import type { ObjectDefinition } from "@osdk/api";
|
|
233
250
|
|
|
234
|
-
export const ${o} = ${JSON.stringify(
|
|
251
|
+
export const ${o} = ${JSON.stringify(h(n),null,2)} satisfies ${o};
|
|
235
252
|
|
|
236
|
-
${
|
|
253
|
+
${re(n)}
|
|
237
254
|
`));}}
|
|
238
255
|
|
|
239
|
-
export {
|
|
256
|
+
export { be as generateClientSdkVersionOneDotOne, Te as generateClientSdkVersionTwoPointZero };
|
|
240
257
|
//# sourceMappingURL=out.js.map
|
|
241
258
|
//# sourceMappingURL=index.mjs.map
|