@osdk/generator-converters 2.6.1 → 2.7.0-beta.10

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +37 -46
  2. package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +3 -1
  3. package/build/browser/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -1
  4. package/build/browser/valueFormatting/commonValueFormattingUtils.js +33 -0
  5. package/build/browser/valueFormatting/commonValueFormattingUtils.js.map +1 -0
  6. package/build/browser/valueFormatting/convertBooleanValueFormattingRule.js +24 -0
  7. package/build/browser/valueFormatting/convertBooleanValueFormattingRule.js.map +1 -0
  8. package/build/browser/valueFormatting/convertDateAndTimestampValueFormattingRule.js +62 -0
  9. package/build/browser/valueFormatting/convertDateAndTimestampValueFormattingRule.js.map +1 -0
  10. package/build/browser/valueFormatting/convertKnownTypeValueFormattingRule.js +39 -0
  11. package/build/browser/valueFormatting/convertKnownTypeValueFormattingRule.js.map +1 -0
  12. package/build/browser/valueFormatting/convertNumberValueFormattingRule.js +133 -0
  13. package/build/browser/valueFormatting/convertNumberValueFormattingRule.js.map +1 -0
  14. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js +14 -1
  15. package/build/browser/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -1
  16. package/build/browser/wirePropertyFormattingToSdkFormatting.js +49 -0
  17. package/build/browser/wirePropertyFormattingToSdkFormatting.js.map +1 -0
  18. package/build/browser/wirePropertyFormattingToSdkFormatting.test.js +344 -0
  19. package/build/browser/wirePropertyFormattingToSdkFormatting.test.js.map +1 -0
  20. package/build/browser/wirePropertyV2ToSdkPropertyDefinition.js +5 -2
  21. package/build/browser/wirePropertyV2ToSdkPropertyDefinition.js.map +1 -1
  22. package/build/cjs/index.cjs +253 -4
  23. package/build/cjs/index.cjs.map +1 -1
  24. package/build/cjs/index.d.cts +2 -2
  25. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js +3 -1
  26. package/build/esm/__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition.js.map +1 -1
  27. package/build/esm/valueFormatting/commonValueFormattingUtils.js +33 -0
  28. package/build/esm/valueFormatting/commonValueFormattingUtils.js.map +1 -0
  29. package/build/esm/valueFormatting/convertBooleanValueFormattingRule.js +24 -0
  30. package/build/esm/valueFormatting/convertBooleanValueFormattingRule.js.map +1 -0
  31. package/build/esm/valueFormatting/convertDateAndTimestampValueFormattingRule.js +62 -0
  32. package/build/esm/valueFormatting/convertDateAndTimestampValueFormattingRule.js.map +1 -0
  33. package/build/esm/valueFormatting/convertKnownTypeValueFormattingRule.js +39 -0
  34. package/build/esm/valueFormatting/convertKnownTypeValueFormattingRule.js.map +1 -0
  35. package/build/esm/valueFormatting/convertNumberValueFormattingRule.js +133 -0
  36. package/build/esm/valueFormatting/convertNumberValueFormattingRule.js.map +1 -0
  37. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js +14 -1
  38. package/build/esm/wireObjectTypeFullMetadataToSdkObjectMetadata.js.map +1 -1
  39. package/build/esm/wirePropertyFormattingToSdkFormatting.js +49 -0
  40. package/build/esm/wirePropertyFormattingToSdkFormatting.js.map +1 -0
  41. package/build/esm/wirePropertyFormattingToSdkFormatting.test.js +344 -0
  42. package/build/esm/wirePropertyFormattingToSdkFormatting.test.js.map +1 -0
  43. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.js +5 -2
  44. package/build/esm/wirePropertyV2ToSdkPropertyDefinition.js.map +1 -1
  45. package/build/types/valueFormatting/commonValueFormattingUtils.d.ts +3 -0
  46. package/build/types/valueFormatting/commonValueFormattingUtils.d.ts.map +1 -0
  47. package/build/types/valueFormatting/convertBooleanValueFormattingRule.d.ts +3 -0
  48. package/build/types/valueFormatting/convertBooleanValueFormattingRule.d.ts.map +1 -0
  49. package/build/types/valueFormatting/convertDateAndTimestampValueFormattingRule.d.ts +4 -0
  50. package/build/types/valueFormatting/convertDateAndTimestampValueFormattingRule.d.ts.map +1 -0
  51. package/build/types/valueFormatting/convertKnownTypeValueFormattingRule.d.ts +3 -0
  52. package/build/types/valueFormatting/convertKnownTypeValueFormattingRule.d.ts.map +1 -0
  53. package/build/types/valueFormatting/convertNumberValueFormattingRule.d.ts +3 -0
  54. package/build/types/valueFormatting/convertNumberValueFormattingRule.d.ts.map +1 -0
  55. package/build/types/wireObjectTypeFullMetadataToSdkObjectMetadata.d.ts.map +1 -1
  56. package/build/types/wirePropertyFormattingToSdkFormatting.d.ts +8 -0
  57. package/build/types/wirePropertyFormattingToSdkFormatting.d.ts.map +1 -0
  58. package/build/types/wirePropertyFormattingToSdkFormatting.test.d.ts +1 -0
  59. package/build/types/wirePropertyFormattingToSdkFormatting.test.d.ts.map +1 -0
  60. package/build/types/wirePropertyV2ToSdkPropertyDefinition.d.ts +2 -2
  61. package/build/types/wirePropertyV2ToSdkPropertyDefinition.d.ts.map +1 -1
  62. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirePropertyFormattingToSdkFormatting.js","names":["convertBooleanFormattingRule","convertDateFormattingRule","convertTimestampFormattingRule","convertKnownTypeFormattingRule","convertNumberFormattingRule","wirePropertyFormattingToSdkFormatting","wireFormatting","log","convertPropertyFormattingInternal","error","info","undefined","type","Error"],"sources":["wirePropertyFormattingToSdkFormatting.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PropertyValueFormattingRule } from \"@osdk/api\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { convertBooleanFormattingRule } from \"./valueFormatting/convertBooleanValueFormattingRule.js\";\nimport {\n convertDateFormattingRule,\n convertTimestampFormattingRule,\n} from \"./valueFormatting/convertDateAndTimestampValueFormattingRule.js\";\nimport { convertKnownTypeFormattingRule } from \"./valueFormatting/convertKnownTypeValueFormattingRule.js\";\nimport { convertNumberFormattingRule } from \"./valueFormatting/convertNumberValueFormattingRule.js\";\n\n/**\n * Converts a PropertyValueFormattingRule from the ontologies format to the SDK format\n */\nexport function wirePropertyFormattingToSdkFormatting(\n wireFormatting: Ontologies.PropertyValueFormattingRule,\n log?: { info: (msg: string) => void },\n): PropertyValueFormattingRule | undefined {\n try {\n return convertPropertyFormattingInternal(wireFormatting);\n } catch (error) {\n log?.info(`Failed to convert property formatting rule: ${error}`);\n return undefined;\n }\n}\n\nfunction convertPropertyFormattingInternal(\n wireFormatting: Ontologies.PropertyValueFormattingRule,\n): PropertyValueFormattingRule | undefined {\n switch (wireFormatting.type) {\n case \"date\":\n return convertDateFormattingRule(wireFormatting);\n\n case \"timestamp\":\n return convertTimestampFormattingRule(wireFormatting);\n\n case \"boolean\":\n return convertBooleanFormattingRule(wireFormatting);\n\n case \"knownType\":\n return convertKnownTypeFormattingRule(wireFormatting);\n\n case \"number\":\n return convertNumberFormattingRule(wireFormatting);\n\n default:\n wireFormatting satisfies never;\n throw new Error(\n `Unknown formatting type: ${(wireFormatting as any).type}`,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,4BAA4B,QAAQ,wDAAwD;AACrG,SACEC,yBAAyB,EACzBC,8BAA8B,QACzB,iEAAiE;AACxE,SAASC,8BAA8B,QAAQ,0DAA0D;AACzG,SAASC,2BAA2B,QAAQ,uDAAuD;;AAEnG;AACA;AACA;AACA,OAAO,SAASC,qCAAqCA,CACnDC,cAAsD,EACtDC,GAAqC,EACI;EACzC,IAAI;IACF,OAAOC,iCAAiC,CAACF,cAAc,CAAC;EAC1D,CAAC,CAAC,OAAOG,KAAK,EAAE;IACdF,GAAG,EAAEG,IAAI,CAAC,+CAA+CD,KAAK,EAAE,CAAC;IACjE,OAAOE,SAAS;EAClB;AACF;AAEA,SAASH,iCAAiCA,CACxCF,cAAsD,EACb;EACzC,QAAQA,cAAc,CAACM,IAAI;IACzB,KAAK,MAAM;MACT,OAAOX,yBAAyB,CAACK,cAAc,CAAC;IAElD,KAAK,WAAW;MACd,OAAOJ,8BAA8B,CAACI,cAAc,CAAC;IAEvD,KAAK,SAAS;MACZ,OAAON,4BAA4B,CAACM,cAAc,CAAC;IAErD,KAAK,WAAW;MACd,OAAOH,8BAA8B,CAACG,cAAc,CAAC;IAEvD,KAAK,QAAQ;MACX,OAAOF,2BAA2B,CAACE,cAAc,CAAC;IAEpD;MAEE,MAAM,IAAIO,KAAK,CACb,4BAA6BP,cAAc,CAASM,IAAI,EAC1D,CAAC;EACL;AACF","ignoreList":[]}
@@ -0,0 +1,344 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { describe, expect, it } from "vitest";
18
+ import { wirePropertyFormattingToSdkFormatting } from "./wirePropertyFormattingToSdkFormatting.js";
19
+ describe(wirePropertyFormattingToSdkFormatting, () => {
20
+ describe("number formatting", () => {
21
+ it("converts standard number format", () => {
22
+ const result = wirePropertyFormattingToSdkFormatting({
23
+ type: "number",
24
+ numberType: {
25
+ type: "standard",
26
+ baseFormatOptions: {
27
+ useGrouping: true,
28
+ minimumFractionDigits: 2,
29
+ maximumFractionDigits: 4,
30
+ notation: "COMPACT"
31
+ }
32
+ }
33
+ });
34
+ expect(result).toEqual({
35
+ type: "number",
36
+ numberType: {
37
+ type: "standard",
38
+ baseFormatOptions: {
39
+ useGrouping: true,
40
+ minimumFractionDigits: 2,
41
+ maximumFractionDigits: 4,
42
+ notation: "COMPACT"
43
+ }
44
+ }
45
+ });
46
+ });
47
+ it("converts currency format with property reference", () => {
48
+ const result = wirePropertyFormattingToSdkFormatting({
49
+ type: "number",
50
+ numberType: {
51
+ type: "currency",
52
+ baseFormatOptions: {
53
+ minimumFractionDigits: 2,
54
+ maximumFractionDigits: 2
55
+ },
56
+ style: "STANDARD",
57
+ currencyCode: {
58
+ type: "propertyType",
59
+ propertyApiName: "currencyField"
60
+ }
61
+ }
62
+ });
63
+ expect(result).toEqual({
64
+ type: "number",
65
+ numberType: {
66
+ type: "currency",
67
+ baseFormatOptions: {
68
+ minimumFractionDigits: 2,
69
+ maximumFractionDigits: 2
70
+ },
71
+ style: "STANDARD",
72
+ currencyCode: {
73
+ type: "propertyType",
74
+ propertyApiName: "currencyField"
75
+ }
76
+ }
77
+ });
78
+ });
79
+ it("converts duration format with human readable style", () => {
80
+ const result = wirePropertyFormattingToSdkFormatting({
81
+ type: "number",
82
+ numberType: {
83
+ type: "duration",
84
+ formatStyle: {
85
+ type: "humanReadable",
86
+ showFullUnits: true
87
+ },
88
+ precision: "MINUTES",
89
+ baseValue: "SECONDS"
90
+ }
91
+ });
92
+ expect(result).toEqual({
93
+ type: "number",
94
+ numberType: {
95
+ type: "duration",
96
+ formatStyle: {
97
+ type: "humanReadable",
98
+ showFullUnits: true
99
+ },
100
+ precision: "MINUTES",
101
+ baseValue: "SECONDS"
102
+ }
103
+ });
104
+ });
105
+ it("converts ratio format for percentage", () => {
106
+ const result = wirePropertyFormattingToSdkFormatting({
107
+ type: "number",
108
+ numberType: {
109
+ type: "ratio",
110
+ ratioType: "PERCENTAGE",
111
+ baseFormatOptions: {
112
+ minimumFractionDigits: 1,
113
+ maximumFractionDigits: 2
114
+ }
115
+ }
116
+ });
117
+ expect(result).toEqual({
118
+ type: "number",
119
+ numberType: {
120
+ type: "ratio",
121
+ ratioType: "PERCENTAGE",
122
+ baseFormatOptions: {
123
+ minimumFractionDigits: 1,
124
+ maximumFractionDigits: 2
125
+ }
126
+ }
127
+ });
128
+ });
129
+ it("returns undefined for unknown number format type", () => {
130
+ const result = wirePropertyFormattingToSdkFormatting({
131
+ type: "number",
132
+ numberType: {
133
+ type: "INVALID_FORMAT_TYPE",
134
+ someUnknownField: "value"
135
+ }
136
+ });
137
+ expect(result).toBeUndefined();
138
+ });
139
+ });
140
+ describe("date/timestamp formatting", () => {
141
+ it("converts date format with string pattern", () => {
142
+ const result = wirePropertyFormattingToSdkFormatting({
143
+ type: "date",
144
+ format: {
145
+ type: "stringFormat",
146
+ pattern: "yyyy-MM-dd"
147
+ }
148
+ });
149
+ expect(result).toEqual({
150
+ type: "date",
151
+ format: {
152
+ type: "stringFormat",
153
+ pattern: "yyyy-MM-dd"
154
+ }
155
+ });
156
+ });
157
+ it("converts timestamp format with localized format and static timezone", () => {
158
+ const result = wirePropertyFormattingToSdkFormatting({
159
+ type: "timestamp",
160
+ format: {
161
+ type: "localizedFormat",
162
+ format: "DATE_FORMAT_DATE_TIME"
163
+ },
164
+ displayTimezone: {
165
+ type: "static",
166
+ zoneId: {
167
+ type: "constant",
168
+ value: "America/New_York"
169
+ }
170
+ }
171
+ });
172
+ expect(result).toEqual({
173
+ type: "timestamp",
174
+ format: {
175
+ type: "localizedFormat",
176
+ format: "DATE_FORMAT_DATE_TIME"
177
+ },
178
+ displayTimezone: {
179
+ type: "static",
180
+ zoneId: {
181
+ type: "constant",
182
+ value: "America/New_York"
183
+ }
184
+ }
185
+ });
186
+ });
187
+ it("returns undefined for unknown datetime format type", () => {
188
+ const result = wirePropertyFormattingToSdkFormatting({
189
+ type: "date",
190
+ format: {
191
+ type: "UNKNOWN_FORMAT_TYPE"
192
+ }
193
+ });
194
+ expect(result).toBeUndefined();
195
+ });
196
+ });
197
+ describe("boolean formatting", () => {
198
+ it("converts boolean format", () => {
199
+ const result = wirePropertyFormattingToSdkFormatting({
200
+ type: "boolean",
201
+ valueIfTrue: "Yes",
202
+ valueIfFalse: "No"
203
+ });
204
+ expect(result).toEqual({
205
+ type: "boolean",
206
+ valueIfTrue: "Yes",
207
+ valueIfFalse: "No"
208
+ });
209
+ });
210
+ });
211
+ describe("known type formatting", () => {
212
+ it("converts valid known types", () => {
213
+ const testCases = [{
214
+ input: "USER_OR_GROUP_ID",
215
+ expected: "USER_OR_GROUP_ID"
216
+ }, {
217
+ input: "RESOURCE_RID",
218
+ expected: "RESOURCE_RID"
219
+ }, {
220
+ input: "ARTIFACT_GID",
221
+ expected: "ARTIFACT_GID"
222
+ }];
223
+ for (const {
224
+ input,
225
+ expected
226
+ } of testCases) {
227
+ const result = wirePropertyFormattingToSdkFormatting({
228
+ type: "knownType",
229
+ knownType: input
230
+ });
231
+ expect(result).toEqual({
232
+ type: "knownType",
233
+ knownType: expected
234
+ });
235
+ }
236
+ });
237
+ it("returns undefined for invalid known type", () => {
238
+ const result = wirePropertyFormattingToSdkFormatting({
239
+ type: "knownType",
240
+ knownType: "INVALID_KNOWN_TYPE"
241
+ });
242
+ expect(result).toBeUndefined();
243
+ });
244
+ });
245
+ describe("unknown formatting types", () => {
246
+ it("returns undefined for completely unknown formatting type", () => {
247
+ const result = wirePropertyFormattingToSdkFormatting({
248
+ type: "UNKNOWN_FORMAT_TYPE",
249
+ someField: "value"
250
+ });
251
+ expect(result).toBeUndefined();
252
+ });
253
+ describe("affix formatting", () => {
254
+ it("converts affix format with prefix and postfix", () => {
255
+ const result = wirePropertyFormattingToSdkFormatting({
256
+ type: "number",
257
+ numberType: {
258
+ type: "affix",
259
+ baseFormatOptions: {
260
+ useGrouping: true
261
+ },
262
+ affix: {
263
+ prefix: {
264
+ type: "constant",
265
+ value: "$"
266
+ },
267
+ postfix: {
268
+ type: "propertyType",
269
+ propertyApiName: "unitField"
270
+ }
271
+ }
272
+ }
273
+ });
274
+ expect(result).toEqual({
275
+ type: "number",
276
+ numberType: {
277
+ type: "affix",
278
+ baseFormatOptions: {
279
+ useGrouping: true
280
+ },
281
+ affix: {
282
+ prefix: {
283
+ type: "constant",
284
+ value: "$"
285
+ },
286
+ postfix: {
287
+ type: "propertyType",
288
+ propertyApiName: "unitField"
289
+ }
290
+ }
291
+ }
292
+ });
293
+ });
294
+ it("handles affix with missing prefix/postfix", () => {
295
+ const result = wirePropertyFormattingToSdkFormatting({
296
+ type: "number",
297
+ numberType: {
298
+ type: "affix",
299
+ baseFormatOptions: {},
300
+ affix: {}
301
+ }
302
+ });
303
+ expect(result).toEqual({
304
+ type: "number",
305
+ numberType: {
306
+ type: "affix",
307
+ baseFormatOptions: {},
308
+ affix: {
309
+ prefix: undefined,
310
+ postfix: undefined
311
+ }
312
+ }
313
+ });
314
+ });
315
+ });
316
+ describe("fixed values formatting", () => {
317
+ it("converts fixed values format", () => {
318
+ const result = wirePropertyFormattingToSdkFormatting({
319
+ type: "number",
320
+ numberType: {
321
+ type: "fixedValues",
322
+ values: {
323
+ 1: "First",
324
+ 2: "Second",
325
+ 3: "Third"
326
+ }
327
+ }
328
+ });
329
+ expect(result).toEqual({
330
+ type: "number",
331
+ numberType: {
332
+ type: "fixedValues",
333
+ values: {
334
+ 1: "First",
335
+ 2: "Second",
336
+ 3: "Third"
337
+ }
338
+ }
339
+ });
340
+ });
341
+ });
342
+ });
343
+ });
344
+ //# sourceMappingURL=wirePropertyFormattingToSdkFormatting.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wirePropertyFormattingToSdkFormatting.test.js","names":["describe","expect","it","wirePropertyFormattingToSdkFormatting","result","type","numberType","baseFormatOptions","useGrouping","minimumFractionDigits","maximumFractionDigits","notation","toEqual","style","currencyCode","propertyApiName","formatStyle","showFullUnits","precision","baseValue","ratioType","someUnknownField","toBeUndefined","format","pattern","displayTimezone","zoneId","value","valueIfTrue","valueIfFalse","testCases","input","expected","knownType","someField","affix","prefix","postfix","undefined","values"],"sources":["wirePropertyFormattingToSdkFormatting.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { KnownType } from \"@osdk/api\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { wirePropertyFormattingToSdkFormatting } from \"./wirePropertyFormattingToSdkFormatting.js\";\n\ndescribe(wirePropertyFormattingToSdkFormatting, () => {\n describe(\"number formatting\", () => {\n it(\"converts standard number format\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"standard\",\n baseFormatOptions: {\n useGrouping: true,\n minimumFractionDigits: 2,\n maximumFractionDigits: 4,\n notation: \"COMPACT\",\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"standard\",\n baseFormatOptions: {\n useGrouping: true,\n minimumFractionDigits: 2,\n maximumFractionDigits: 4,\n notation: \"COMPACT\",\n },\n },\n });\n });\n\n it(\"converts currency format with property reference\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"currency\",\n baseFormatOptions: {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n },\n style: \"STANDARD\",\n currencyCode: {\n type: \"propertyType\",\n propertyApiName: \"currencyField\",\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"currency\",\n baseFormatOptions: {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n },\n style: \"STANDARD\",\n currencyCode: {\n type: \"propertyType\",\n propertyApiName: \"currencyField\",\n },\n },\n });\n });\n\n it(\"converts duration format with human readable style\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"duration\",\n formatStyle: {\n type: \"humanReadable\",\n showFullUnits: true,\n },\n precision: \"MINUTES\",\n baseValue: \"SECONDS\",\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"duration\",\n formatStyle: {\n type: \"humanReadable\",\n showFullUnits: true,\n },\n precision: \"MINUTES\",\n baseValue: \"SECONDS\",\n },\n });\n });\n\n it(\"converts ratio format for percentage\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"ratio\",\n ratioType: \"PERCENTAGE\",\n baseFormatOptions: {\n minimumFractionDigits: 1,\n maximumFractionDigits: 2,\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"ratio\",\n ratioType: \"PERCENTAGE\",\n baseFormatOptions: {\n minimumFractionDigits: 1,\n maximumFractionDigits: 2,\n },\n },\n });\n });\n\n it(\"returns undefined for unknown number format type\", () => {\n const wireFormat = {\n type: \"number\",\n numberType: {\n type: \"INVALID_FORMAT_TYPE\",\n someUnknownField: \"value\",\n },\n } as any;\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toBeUndefined();\n });\n });\n\n describe(\"date/timestamp formatting\", () => {\n it(\"converts date format with string pattern\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"date\",\n format: {\n type: \"stringFormat\",\n pattern: \"yyyy-MM-dd\",\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"date\",\n format: {\n type: \"stringFormat\",\n pattern: \"yyyy-MM-dd\",\n },\n });\n });\n\n it(\"converts timestamp format with localized format and static timezone\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"timestamp\",\n format: {\n type: \"localizedFormat\",\n format: \"DATE_FORMAT_DATE_TIME\",\n },\n displayTimezone: {\n type: \"static\",\n zoneId: {\n type: \"constant\",\n value: \"America/New_York\",\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"timestamp\",\n format: {\n type: \"localizedFormat\",\n format: \"DATE_FORMAT_DATE_TIME\",\n },\n displayTimezone: {\n type: \"static\",\n zoneId: {\n type: \"constant\",\n value: \"America/New_York\",\n },\n },\n });\n });\n\n it(\"returns undefined for unknown datetime format type\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"date\",\n format: {\n type: \"UNKNOWN_FORMAT_TYPE\",\n } as any,\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toBeUndefined();\n });\n });\n\n describe(\"boolean formatting\", () => {\n it(\"converts boolean format\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"boolean\",\n valueIfTrue: \"Yes\",\n valueIfFalse: \"No\",\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"boolean\",\n valueIfTrue: \"Yes\",\n valueIfFalse: \"No\",\n });\n });\n });\n\n describe(\"known type formatting\", () => {\n it(\"converts valid known types\", () => {\n const testCases: Array<{\n input: Ontologies.KnownType;\n expected: KnownType;\n }> = [\n { input: \"USER_OR_GROUP_ID\", expected: \"USER_OR_GROUP_ID\" },\n { input: \"RESOURCE_RID\", expected: \"RESOURCE_RID\" },\n { input: \"ARTIFACT_GID\", expected: \"ARTIFACT_GID\" },\n ];\n\n for (const { input, expected } of testCases) {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"knownType\",\n knownType: input,\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"knownType\",\n knownType: expected,\n });\n }\n });\n\n it(\"returns undefined for invalid known type\", () => {\n const wireFormat = {\n type: \"knownType\",\n knownType: \"INVALID_KNOWN_TYPE\",\n } as any;\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toBeUndefined();\n });\n });\n\n describe(\"unknown formatting types\", () => {\n it(\"returns undefined for completely unknown formatting type\", () => {\n const wireFormat = {\n type: \"UNKNOWN_FORMAT_TYPE\",\n someField: \"value\",\n } as any;\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toBeUndefined();\n });\n\n describe(\"affix formatting\", () => {\n it(\"converts affix format with prefix and postfix\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"affix\",\n baseFormatOptions: {\n useGrouping: true,\n },\n affix: {\n prefix: {\n type: \"constant\",\n value: \"$\",\n },\n postfix: {\n type: \"propertyType\",\n propertyApiName: \"unitField\",\n },\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"affix\",\n baseFormatOptions: {\n useGrouping: true,\n },\n affix: {\n prefix: {\n type: \"constant\",\n value: \"$\",\n },\n postfix: {\n type: \"propertyType\",\n propertyApiName: \"unitField\",\n },\n },\n },\n });\n });\n\n it(\"handles affix with missing prefix/postfix\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"affix\",\n baseFormatOptions: {},\n affix: {},\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"affix\",\n baseFormatOptions: {},\n affix: {\n prefix: undefined,\n postfix: undefined,\n },\n },\n });\n });\n });\n\n describe(\"fixed values formatting\", () => {\n it(\"converts fixed values format\", () => {\n const wireFormat: Ontologies.PropertyValueFormattingRule = {\n type: \"number\",\n numberType: {\n type: \"fixedValues\",\n values: {\n 1: \"First\",\n 2: \"Second\",\n 3: \"Third\",\n },\n },\n };\n\n const result = wirePropertyFormattingToSdkFormatting(wireFormat);\n\n expect(result).toEqual({\n type: \"number\",\n numberType: {\n type: \"fixedValues\",\n values: {\n 1: \"First\",\n 2: \"Second\",\n 3: \"Third\",\n },\n },\n });\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,qCAAqC,QAAQ,4CAA4C;AAElGH,QAAQ,CAACG,qCAAqC,EAAE,MAAM;EACpDH,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAClCE,EAAE,CAAC,iCAAiC,EAAE,MAAM;MAc1C,MAAME,MAAM,GAAGD,qCAAqC,CAbO;QACzDE,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE;UACVD,IAAI,EAAE,UAAU;UAChBE,iBAAiB,EAAE;YACjBC,WAAW,EAAE,IAAI;YACjBC,qBAAqB,EAAE,CAAC;YACxBC,qBAAqB,EAAE,CAAC;YACxBC,QAAQ,EAAE;UACZ;QACF;MACF,CAE+D,CAAC;MAEhEV,MAAM,CAACG,MAAM,CAAC,CAACQ,OAAO,CAAC;QACrBP,IAAI,EAAE,QAAQ;QACdC,UAAU,EAAE;UACVD,IAAI,EAAE,UAAU;UAChBE,iBAAiB,EAAE;YACjBC,WAAW,EAAE,IAAI;YACjBC,qBAAqB,EAAE,CAAC;YACxBC,qBAAqB,EAAE,CAAC;YACxBC,QAAQ,EAAE;U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AAC;YACrB4B,KAAK,EAAE;cACLC,MAAM,EAAEE,SAAS;cACjBD,OAAO,EAAEC;YACX;UACF;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;IAEFtC,QAAQ,CAAC,yBAAyB,EAAE,MAAM;MACxCE,EAAE,CAAC,8BAA8B,EAAE,MAAM;QAavC,MAAME,MAAM,GAAGD,qCAAqC,CAZO;UACzDE,IAAI,EAAE,QAAQ;UACdC,UAAU,EAAE;YACVD,IAAI,EAAE,aAAa;YACnBkC,MAAM,EAAE;cACN,CAAC,EAAE,OAAO;cACV,CAAC,EAAE,QAAQ;cACX,CAAC,EAAE;YACL;UACF;QACF,CAE+D,CAAC;QAEhEtC,MAAM,CAACG,MAAM,CAAC,CAACQ,OAAO,CAAC;UACrBP,IAAI,EAAE,QAAQ;UACdC,UAAU,EAAE;YACVD,IAAI,EAAE,aAAa;YACnBkC,MAAM,EAAE;cACN,CAAC,EAAE,OAAO;cACV,CAAC,EAAE,QAAQ;cACX,CAAC,EAAE;YACL;UACF;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { wirePropertyFormattingToSdkFormatting } from "./wirePropertyFormattingToSdkFormatting.js";
17
18
  export function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true, log) {
18
19
  const sdkPropDefinition = objectPropertyTypeToSdkPropertyDefinition(input.dataType, log);
19
20
  if (sdkPropDefinition == null) {
@@ -46,7 +47,8 @@ export function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true,
46
47
  description: input.description,
47
48
  type: sdkPropDefinition,
48
49
  nullable: input.nullable == null ? isNullable : input.nullable,
49
- valueTypeApiName: input.valueTypeApiName
50
+ valueTypeApiName: input.valueTypeApiName,
51
+ valueFormatting: input.valueFormatting != null ? wirePropertyFormattingToSdkFormatting(input.valueFormatting, log) : undefined
50
52
  };
51
53
  case "array":
52
54
  {
@@ -56,7 +58,8 @@ export function wirePropertyV2ToSdkPropertyDefinition(input, isNullable = true,
56
58
  description: input.description,
57
59
  type: sdkPropDefinition,
58
60
  nullable: true,
59
- valueTypeApiName: input.valueTypeApiName
61
+ valueTypeApiName: input.valueTypeApiName,
62
+ valueFormatting: input.valueFormatting != null ? wirePropertyFormattingToSdkFormatting(input.valueFormatting, log) : undefined
60
63
  };
61
64
  }
62
65
  case "cipherText":
@@ -1 +1 @@
1
- {"version":3,"file":"wirePropertyV2ToSdkPropertyDefinition.js","names":["wirePropertyV2ToSdkPropertyDefinition","input","isNullable","log","sdkPropDefinition","objectPropertyTypeToSdkPropertyDefinition","dataType","undefined","type","displayName","multiplicity","description","nullable","valueTypeApiName","info","JSON","stringify","propertyType","subType","itemType","structFieldTypes","reduce","structMap","structField","apiName"],"sources":["wirePropertyV2ToSdkPropertyDefinition.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n BaseWirePropertyTypes,\n ObjectMetadata,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport type {\n ObjectPropertyType,\n PropertyV2,\n SharedPropertyType,\n} from \"@osdk/foundry.ontologies\";\n\nexport function wirePropertyV2ToSdkPropertyDefinition(\n input: (PropertyV2 | SharedPropertyType) & { nullable?: boolean },\n isNullable: boolean = true,\n log?: { info: (msg: string) => void },\n): ObjectMetadata.Property | undefined {\n const sdkPropDefinition = objectPropertyTypeToSdkPropertyDefinition(\n input.dataType,\n log,\n );\n if (sdkPropDefinition == null) {\n return undefined;\n }\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 \"mediaReference\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n case \"timeseries\":\n case \"marking\":\n case \"geotimeSeriesReference\":\n case \"struct\":\n case \"vector\":\n return {\n displayName: input.displayName,\n multiplicity: false,\n description: input.description,\n type: sdkPropDefinition,\n nullable: input.nullable == null ? isNullable : input.nullable,\n valueTypeApiName: input.valueTypeApiName,\n };\n case \"array\": {\n return {\n displayName: input.displayName,\n multiplicity: true,\n description: input.description,\n type: sdkPropDefinition,\n nullable: true,\n valueTypeApiName: input.valueTypeApiName,\n };\n }\n case \"cipherText\": {\n log?.info(\n `${JSON.stringify(input.dataType.type)} is not a supported dataType`,\n );\n\n return undefined;\n }\n\n default:\n const _: never = input.dataType;\n log?.info(\n `${JSON.stringify(input.dataType)} is not a supported dataType`,\n );\n\n return undefined;\n }\n}\n\nfunction objectPropertyTypeToSdkPropertyDefinition(\n propertyType: ObjectPropertyType,\n log?: { info: (msg: string) => void },\n): WirePropertyTypes | undefined {\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 case \"marking\":\n case \"geotimeSeriesReference\":\n case \"mediaReference\":\n case \"vector\":\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 } else if (propertyType.itemType?.type === \"double\") {\n return \"numericTimeseries\";\n } else return \"sensorTimeseries\";\n case \"struct\": {\n return propertyType.structFieldTypes.reduce(\n (structMap: Record<string, BaseWirePropertyTypes>, structField) => {\n structMap[structField.apiName] =\n objectPropertyTypeToSdkPropertyDefinition(\n structField.dataType,\n ) as BaseWirePropertyTypes;\n return structMap;\n },\n {},\n );\n }\n case \"cipherText\": {\n log?.info(\n `${JSON.stringify(propertyType.type)} is not a supported propertyType`,\n );\n\n return undefined;\n }\n default: {\n const _: never = propertyType;\n log?.info(\n `${JSON.stringify(propertyType)} is not a supported propertyType`,\n );\n\n return undefined;\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAO,SAASA,qCAAqCA,CACnDC,KAAiE,EACjEC,UAAmB,GAAG,IAAI,EAC1BC,GAAqC,EACA;EACrC,MAAMC,iBAAiB,GAAGC,yCAAyC,CACjEJ,KAAK,CAACK,QAAQ,EACdH,GACF,CAAC;EACD,IAAIC,iBAAiB,IAAI,IAAI,EAAE;IAC7B,OAAOG,SAAS;EAClB;EACA,QAAQN,KAAK,CAACK,QAAQ,CAACE,IAAI;IACzB,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,MAAM;IACX,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,OAAO;IACZ,KAAK,MAAM;IACX,KAAK,OAAO;IACZ,KAAK,SAAS;IACd,KAAK,MAAM;IACX,KAAK,YAAY;IACjB,KAAK,gBAAgB;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,WAAW;IAChB,KAAK,YAAY;IACjB,KAAK,SAAS;IACd,KAAK,wBAAwB;IAC7B,KAAK,QAAQ;IACb,KAAK,QAAQ;MACX,OAAO;QACLC,WAAW,EAAER,KAAK,CAACQ,WAAW;QAC9BC,YAAY,EAAE,KAAK;QACnBC,WAAW,EAAEV,KAAK,CAACU,WAAW;QAC9BH,IAAI,EAAEJ,iBAAiB;QACvBQ,QAAQ,EAAEX,KAAK,CAACW,QAAQ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,YAAY,CAACE,QAAQ,EAAEX,IAAI,KAAK,QAAQ,EAAE;QAC5C,OAAO,kBAAkB;MAC3B,CAAC,MAAM,IAAIS,YAAY,CAACE,QAAQ,EAAEX,IAAI,KAAK,QAAQ,EAAE;QACnD,OAAO,mBAAmB;MAC5B,CAAC,MAAM,OAAO,kBAAkB;IAClC,KAAK,QAAQ;MAAE;QACb,OAAOS,YAAY,CAACG,gBAAgB,CAACC,MAAM,CACzC,CAACC,SAAgD,EAAEC,WAAW,KAAK;UACjED,SAAS,CAACC,WAAW,CAACC,OAAO,CAAC,GAC5BnB,yCAAyC,CACvCkB,WAAW,CAACjB,QACd,CAA0B;UAC5B,OAAOgB,SAAS;QAClB,CAAC,EACD,CAAC,CACH,CAAC;MACH;IACA,KAAK,YAAY;MAAE;QACjBnB,GAAG,EAAEW,IAAI,CACP,GAAGC,IAAI,CAACC,SAAS,CAACC,YAAY,CAACT,IAAI,CAAC,kCACtC,CAAC;QAED,OAAOD,SAAS;MAClB;IACA;MAAS;QAEPJ,GAAG,EAAEW,IAAI,CACP,GAAGC,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,kCACjC,CAAC;QAED,OAAOV,SAAS;MAClB;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"wirePropertyV2ToSdkPropertyDefinition.js","names":["wirePropertyFormattingToSdkFormatting","wirePropertyV2ToSdkPropertyDefinition","input","isNullable","log","sdkPropDefinition","objectPropertyTypeToSdkPropertyDefinition","dataType","undefined","type","displayName","multiplicity","description","nullable","valueTypeApiName","valueFormatting","info","JSON","stringify","propertyType","subType","itemType","structFieldTypes","reduce","structMap","structField","apiName"],"sources":["wirePropertyV2ToSdkPropertyDefinition.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n BaseWirePropertyTypes,\n ObjectMetadata,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport type {\n ObjectPropertyType,\n PropertyV2,\n ResolvedInterfacePropertyType,\n SharedPropertyType,\n} from \"@osdk/foundry.ontologies\";\nimport { wirePropertyFormattingToSdkFormatting } from \"./wirePropertyFormattingToSdkFormatting.js\";\n\nexport function wirePropertyV2ToSdkPropertyDefinition(\n input: (PropertyV2 | SharedPropertyType | ResolvedInterfacePropertyType) & {\n nullable?: boolean;\n },\n isNullable: boolean = true,\n log?: { info: (msg: string) => void },\n): ObjectMetadata.Property | undefined {\n const sdkPropDefinition = objectPropertyTypeToSdkPropertyDefinition(\n input.dataType,\n log,\n );\n if (sdkPropDefinition == null) {\n return undefined;\n }\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 \"mediaReference\":\n case \"geopoint\":\n case \"geoshape\":\n case \"timestamp\":\n case \"timeseries\":\n case \"marking\":\n case \"geotimeSeriesReference\":\n case \"struct\":\n case \"vector\":\n return {\n displayName: input.displayName,\n multiplicity: false,\n description: input.description,\n type: sdkPropDefinition,\n nullable: input.nullable == null ? isNullable : input.nullable,\n valueTypeApiName: input.valueTypeApiName,\n valueFormatting: input.valueFormatting != null\n ? wirePropertyFormattingToSdkFormatting(input.valueFormatting, log)\n : undefined,\n };\n case \"array\": {\n return {\n displayName: input.displayName,\n multiplicity: true,\n description: input.description,\n type: sdkPropDefinition,\n nullable: true,\n valueTypeApiName: input.valueTypeApiName,\n valueFormatting: input.valueFormatting != null\n ? wirePropertyFormattingToSdkFormatting(input.valueFormatting, log)\n : undefined,\n };\n }\n case \"cipherText\": {\n log?.info(\n `${JSON.stringify(input.dataType.type)} is not a supported dataType`,\n );\n\n return undefined;\n }\n\n default:\n const _: never = input.dataType;\n log?.info(\n `${JSON.stringify(input.dataType)} is not a supported dataType`,\n );\n\n return undefined;\n }\n}\n\nfunction objectPropertyTypeToSdkPropertyDefinition(\n propertyType: ObjectPropertyType,\n log?: { info: (msg: string) => void },\n): WirePropertyTypes | undefined {\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 case \"marking\":\n case \"geotimeSeriesReference\":\n case \"mediaReference\":\n case \"vector\":\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 } else if (propertyType.itemType?.type === \"double\") {\n return \"numericTimeseries\";\n } else return \"sensorTimeseries\";\n case \"struct\": {\n return propertyType.structFieldTypes.reduce(\n (structMap: Record<string, BaseWirePropertyTypes>, structField) => {\n structMap[structField.apiName] =\n objectPropertyTypeToSdkPropertyDefinition(\n structField.dataType,\n ) as BaseWirePropertyTypes;\n return structMap;\n },\n {},\n );\n }\n case \"cipherText\": {\n log?.info(\n `${JSON.stringify(propertyType.type)} is not a supported propertyType`,\n );\n\n return undefined;\n }\n default: {\n const _: never = propertyType;\n log?.info(\n `${JSON.stringify(propertyType)} is not a supported propertyType`,\n );\n\n return undefined;\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,qCAAqC,QAAQ,4CAA4C;AAElG,OAAO,SAASC,qCAAqCA,CACnDC,KAEC,EACDC,UAAmB,GAAG,IAAI,EAC1BC,GAAq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