@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/CHANGELOG.md
CHANGED
package/build/js/index.js
CHANGED
|
@@ -23,9 +23,9 @@ function _interopNamespace(e) {
|
|
|
23
23
|
|
|
24
24
|
var O__namespace = /*#__PURE__*/_interopNamespace(O);
|
|
25
25
|
|
|
26
|
-
function
|
|
27
|
-
`;for(let[j,b]of i){c+=`"${j}"`,c+=b.required?": ":"?: ";let
|
|
28
|
-
`,y.push(`* @param {${
|
|
26
|
+
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 prettier.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: {
|
|
27
|
+
`;for(let[j,b]of i){c+=`"${j}"`,c+=b.required?": ":"?: ";let E=P(b.dataType,t);c+=`${E};
|
|
28
|
+
`,y.push(`* @param {${E}} params.${j}`);}c+="}, ";}y.push("*/"),o.push(`
|
|
29
29
|
${y.join(`
|
|
30
30
|
`)}
|
|
31
31
|
${n.apiName}<O extends ActionExecutionOptions>(${c}options?: O):
|
|
@@ -37,7 +37,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
37
37
|
${o.join(`
|
|
38
38
|
`)}
|
|
39
39
|
}
|
|
40
|
-
`));}function
|
|
40
|
+
`));}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__namespace.default.join(r,"FoundryClient.ts"),await s(`
|
|
41
41
|
import { BaseFoundryClient } from "@osdk/legacy-client";
|
|
42
42
|
import type { Auth, FoundryClientOptions } from "@osdk/legacy-client";
|
|
43
43
|
import { Ontology } from "./Ontology";
|
|
@@ -50,7 +50,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
50
50
|
get ontology(): Ontology {
|
|
51
51
|
return super.ontology;
|
|
52
52
|
}
|
|
53
|
-
}`));}async function
|
|
53
|
+
}`));}async function C(e,r){await e.mkdir(r,{recursive:!0}),await e.writeFile(O__namespace.join(r,"index.ts"),await s(`
|
|
54
54
|
export {
|
|
55
55
|
ActionExecutionMode,
|
|
56
56
|
ActionResponse,
|
|
@@ -63,7 +63,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
63
63
|
DecimalType,
|
|
64
64
|
DoubleType,
|
|
65
65
|
FloatType,
|
|
66
|
-
FoundryApiError,
|
|
66
|
+
FoundryApiError,
|
|
67
67
|
GeoPoint,
|
|
68
68
|
GeoPointType,
|
|
69
69
|
GeoShape,
|
|
@@ -74,9 +74,9 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
74
74
|
LocalDate,
|
|
75
75
|
LongType,
|
|
76
76
|
ObjectType,
|
|
77
|
-
Op,
|
|
77
|
+
Op,
|
|
78
78
|
Polygon,
|
|
79
|
-
ReturnEditsMode,
|
|
79
|
+
ReturnEditsMode,
|
|
80
80
|
SetType,
|
|
81
81
|
ShortType,
|
|
82
82
|
StringType,
|
|
@@ -85,7 +85,10 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
85
85
|
TimeSeriesType,
|
|
86
86
|
Timestamp,
|
|
87
87
|
TimestampType,
|
|
88
|
-
visitError,
|
|
88
|
+
visitError,
|
|
89
|
+
PublicClientAuth,
|
|
90
|
+
ConfidentialClientAuth,
|
|
91
|
+
UserTokenAuth
|
|
89
92
|
} from '@osdk/legacy-client';
|
|
90
93
|
export type {
|
|
91
94
|
ActionError,
|
|
@@ -116,7 +119,7 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
116
119
|
} from '@osdk/legacy-client';
|
|
117
120
|
export { Ontology } from "./Ontology";
|
|
118
121
|
export { FoundryClient } from "./FoundryClient";
|
|
119
|
-
`));}function u(e){return e.join(",")}async function
|
|
122
|
+
`));}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__namespace.default.join(a,"Ontology.ts"),await s(`
|
|
120
123
|
import type { OntologyDefinition } from "@osdk/api";
|
|
121
124
|
import type { Ontology as ClientOntology } from "@osdk/legacy-client";
|
|
122
125
|
import type { Objects } from "./ontologyObjects";
|
|
@@ -129,11 +132,26 @@ function x(e){return {...e,actionTypes:e.actionTypes.map(r=>({...r,apiName:ee(r.
|
|
|
129
132
|
${n.map(i=>`import {${i}} from "./queries/${i}";`).join(`
|
|
130
133
|
`)}
|
|
131
134
|
|
|
132
|
-
export const Ontology
|
|
135
|
+
export const Ontology : {
|
|
133
136
|
metadata: {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
ontologyRid: "${e.rid}",
|
|
138
|
+
ontologyApiName: "${e.apiName}",
|
|
139
|
+
userAgent: "foundry-typescript-osdk/0.0.1",
|
|
140
|
+
},
|
|
141
|
+
objects: {
|
|
142
|
+
${w(t)}
|
|
143
|
+
},
|
|
144
|
+
actions: {
|
|
145
|
+
${w(o)}
|
|
146
|
+
},
|
|
147
|
+
queries: {
|
|
148
|
+
${w(n)}
|
|
149
|
+
},
|
|
150
|
+
} = {
|
|
151
|
+
metadata: {
|
|
152
|
+
ontologyRid: "${e.rid}" as const,
|
|
153
|
+
ontologyApiName: "${e.apiName}" as const,
|
|
154
|
+
userAgent: "foundry-typescript-osdk/0.0.1" as const,
|
|
137
155
|
},
|
|
138
156
|
objects: {
|
|
139
157
|
${u(t)}
|
|
@@ -150,7 +168,7 @@ export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
|
150
168
|
objects: Objects;
|
|
151
169
|
actions: Actions;
|
|
152
170
|
queries: Queries;
|
|
153
|
-
}`));}async function
|
|
171
|
+
}`));}async function v(e,r,a){await r.writeFile(O__namespace.default.join(a,"ontologyObjects.ts"),await s(`
|
|
154
172
|
import { BaseObjectSet } from "@osdk/legacy-client";
|
|
155
173
|
import { ${u(Object.keys(e.objectTypes))} } from "./objects";
|
|
156
174
|
|
|
@@ -158,44 +176,43 @@ export interface Ontology extends ClientOntology<typeof Ontology> {
|
|
|
158
176
|
${Object.keys(e.objectTypes).map(t=>`${t} : BaseObjectSet<${t}>;`).join(`
|
|
159
177
|
`)}
|
|
160
178
|
}
|
|
161
|
-
;`));}function
|
|
179
|
+
;`));}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__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
162
180
|
import { ActionDefinition } from "@osdk/api";
|
|
163
181
|
|
|
164
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
182
|
+
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__namespace.default.join(a,"index.ts"),await s(`
|
|
165
183
|
${e.actionTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
166
184
|
`)}
|
|
167
|
-
`));}function
|
|
185
|
+
`));}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";
|
|
168
186
|
${Array.from(a).map(t=>`import type { ${t} } from "./${t}";`).join(`
|
|
169
187
|
`)}
|
|
170
188
|
|
|
171
|
-
|
|
172
|
-
* ${e.description}
|
|
173
|
-
*/
|
|
174
|
-
export interface ${e.apiName} extends OntologyObject {
|
|
189
|
+
${G(e.description)}export interface ${e.apiName} extends OntologyObject {
|
|
175
190
|
readonly __apiName: "${e.apiName}";
|
|
176
|
-
readonly __primaryKey: ${
|
|
177
|
-
${Object.entries(e.properties).
|
|
191
|
+
readonly __primaryKey: ${k(e.properties[e.primaryKey].dataType)};
|
|
192
|
+
${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 */
|
|
193
|
+
readonly ${t}_: ${n} | undefined`),i}).join(`;
|
|
178
194
|
`)}
|
|
179
|
-
${r.
|
|
195
|
+
${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 */
|
|
196
|
+
readonly ${t.apiName}_: ${t.cardinality==="MANY"?"MultiLink":"SingleLink"}<${t.objectTypeApiName}>`),o}).join(`;
|
|
180
197
|
`)}
|
|
181
198
|
}
|
|
182
|
-
`}function
|
|
199
|
+
`}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?`/**
|
|
183
200
|
* ${e}
|
|
184
201
|
*/
|
|
185
|
-
`:""}async function
|
|
202
|
+
`:""}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__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
186
203
|
import { ObjectDefinition } from "@osdk/api";
|
|
187
|
-
${
|
|
204
|
+
${z(t,o)}
|
|
188
205
|
|
|
189
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
206
|
+
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__namespace.default.join(a,"index.ts"),await s(`
|
|
190
207
|
${Object.keys(e.objectTypes).map(t=>`export * from "./${t}";`).join(`
|
|
191
208
|
`)}
|
|
192
|
-
`));}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:
|
|
209
|
+
`));}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__namespace.default.join(a,`${t.apiName}.ts`),await s(`
|
|
193
210
|
import { QueryDefinition } from "@osdk/api";
|
|
194
211
|
|
|
195
|
-
export const ${t.apiName} = ${JSON.stringify(
|
|
212
|
+
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__namespace.default.join(a,"index.ts"),await s(`
|
|
196
213
|
${e.queryTypes.map(t=>`export * from "./${t.apiName}";`).join(`
|
|
197
214
|
`)}
|
|
198
|
-
`));}function
|
|
215
|
+
`));}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(`
|
|
199
216
|
${i.join(`
|
|
200
217
|
`)}
|
|
201
218
|
${n.apiName}(${g}): Promise<Result<QueryResponse<${d}>, QueryError>>;
|
|
@@ -209,14 +226,14 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
209
226
|
`)}
|
|
210
227
|
}
|
|
211
228
|
`));}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(`,
|
|
212
|
-
`)} }`;case"union":return e.unionTypes.map(o=>f(o,r)).join("|");case"twoDimensionalAggregation":return e.valueType,`TwoDimensionalAggregation<
|
|
213
|
-
${
|
|
214
|
-
${
|
|
229
|
+
`)} }`;case"union":return e.unionTypes.map(o=>f(o,r)).filter(o=>o!=="null").join("|");case"twoDimensionalAggregation":return e.valueType,`TwoDimensionalAggregation<
|
|
230
|
+
${x(e.keyType)},
|
|
231
|
+
${X(e.valueType)}
|
|
215
232
|
>`;case"threeDimensionalAggregation":return `ThreeDimensionalAggregation<
|
|
216
|
-
${
|
|
217
|
-
${
|
|
218
|
-
${
|
|
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
|
|
233
|
+
${x(e.keyType)},
|
|
234
|
+
${x(e.valueType.keyType)},
|
|
235
|
+
${X(e.valueType.valueType)}
|
|
236
|
+
>`;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__namespace.join(a,"objects")),await Q(t,r,a),await _(t,r,O__namespace.join(a,"actions")),await te(t,r,a),await H(t,r,O__namespace.join(a,"queries")),await C(r,a);}function re(e){return `
|
|
220
237
|
export interface ${e.apiName} extends ObjectDefinition<"${e.apiName}", "${e.apiName}">{
|
|
221
238
|
apiName: "${e.apiName}";
|
|
222
239
|
properties: {
|
|
@@ -232,7 +249,7 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
232
249
|
`)}
|
|
233
250
|
}
|
|
234
251
|
}
|
|
235
|
-
`}async function
|
|
252
|
+
`}async function Te(e,r,a){r.writeFile(`${a}/index.ts`,await s(`
|
|
236
253
|
export { Ontology } from "./Ontology";
|
|
237
254
|
`));let t=Object.keys(e.objectTypes);r.writeFile(`${a}/Ontology.ts`,await s(`
|
|
238
255
|
import type { OntologyDefinition } from "@osdk/api";
|
|
@@ -252,12 +269,12 @@ ${r.map(t=>`readonly ${t.apiName}: ${t.cardinality==="MANY"?"MultiLink":"SingleL
|
|
|
252
269
|
|
|
253
270
|
import type { ObjectDefinition } from "@osdk/api";
|
|
254
271
|
|
|
255
|
-
export const ${o} = ${JSON.stringify(
|
|
272
|
+
export const ${o} = ${JSON.stringify(h(n),null,2)} satisfies ${o};
|
|
256
273
|
|
|
257
|
-
${
|
|
274
|
+
${re(n)}
|
|
258
275
|
`));}}
|
|
259
276
|
|
|
260
|
-
exports.generateClientSdkVersionOneDotOne =
|
|
261
|
-
exports.generateClientSdkVersionTwoPointZero =
|
|
277
|
+
exports.generateClientSdkVersionOneDotOne = be;
|
|
278
|
+
exports.generateClientSdkVersionTwoPointZero = Te;
|
|
262
279
|
//# sourceMappingURL=out.js.map
|
|
263
280
|
//# sourceMappingURL=index.js.map
|