@osdk/client 2.6.0-beta.1 → 2.6.0-beta.2
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 +19 -0
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/fetchMetadata.test.js +11 -0
- package/build/browser/fetchMetadata.test.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +15 -0
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/formatting/applyPropertyFormatter.js +52 -0
- package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js +423 -0
- package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/browser/object/formatting/formatBoolean.js +23 -0
- package/build/browser/object/formatting/formatBoolean.js.map +1 -0
- package/build/browser/object/formatting/formatNumber.js +242 -0
- package/build/browser/object/formatting/formatNumber.js.map +1 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/browser/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/browser/util/UserAgent.js +2 -2
- package/build/cjs/{chunk-DCEFUXFS.cjs → chunk-6L3MX4LH.cjs} +35 -15
- package/build/cjs/chunk-6L3MX4LH.cjs.map +1 -0
- package/build/cjs/{chunk-BP7BR5FZ.cjs → chunk-X7WMWKLM.cjs} +298 -54
- package/build/cjs/chunk-X7WMWKLM.cjs.map +1 -0
- package/build/cjs/index.cjs +8 -8
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +31 -31
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/fetchMetadata.test.js +11 -0
- package/build/esm/fetchMetadata.test.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +15 -0
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +12 -0
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/formatting/applyPropertyFormatter.js +52 -0
- package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js +423 -0
- package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -0
- package/build/esm/object/formatting/formatBoolean.js +23 -0
- package/build/esm/object/formatting/formatBoolean.js.map +1 -0
- package/build/esm/object/formatting/formatNumber.js +242 -0
- package/build/esm/object/formatting/formatNumber.js.map +1 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js +39 -0
- package/build/esm/object/formatting/propertyFormattingUtils.js.map +1 -0
- package/build/esm/util/UserAgent.js +2 -2
- package/build/types/Client.d.ts +1 -1
- package/build/types/object/formatting/applyPropertyFormatter.d.ts +18 -0
- package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts +1 -0
- package/build/types/object/formatting/applyPropertyFormatter.test.d.ts.map +1 -0
- package/build/types/object/formatting/formatBoolean.d.ts +5 -0
- package/build/types/object/formatting/formatBoolean.d.ts.map +1 -0
- package/build/types/object/formatting/formatNumber.d.ts +15 -0
- package/build/types/object/formatting/formatNumber.d.ts.map +1 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts +10 -0
- package/build/types/object/formatting/propertyFormattingUtils.d.ts.map +1 -0
- package/package.json +7 -7
- package/build/cjs/chunk-BP7BR5FZ.cjs.map +0 -1
- package/build/cjs/chunk-DCEFUXFS.cjs.map +0 -1
|
@@ -0,0 +1,242 @@
|
|
|
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 { resolvePropertyReference } from "./propertyFormattingUtils.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Extended NumberFormatOptions that includes rounding mode support
|
|
21
|
+
* which is available in modern browsers but not yet in TypeScript types.
|
|
22
|
+
* Only includes modes that are actually supported by Intl.NumberFormat and used in our API.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Formats a number value according to the specified formatting rule
|
|
27
|
+
*/
|
|
28
|
+
export function formatNumber(value, numberType, objectData, locale) {
|
|
29
|
+
switch (numberType.type) {
|
|
30
|
+
case "standard":
|
|
31
|
+
return formatStandardNumber(value, numberType.baseFormatOptions, locale);
|
|
32
|
+
case "fixedValues":
|
|
33
|
+
return numberType.values[value];
|
|
34
|
+
case "currency":
|
|
35
|
+
return formatCurrency(value, numberType, objectData, locale);
|
|
36
|
+
case "standardUnit":
|
|
37
|
+
return formatStandardUnit(value, numberType, objectData, locale);
|
|
38
|
+
case "customUnit":
|
|
39
|
+
return formatCustomUnit(value, numberType, objectData, locale);
|
|
40
|
+
case "affix":
|
|
41
|
+
return formatAffix(value, numberType, objectData, locale);
|
|
42
|
+
case "duration":
|
|
43
|
+
// TODO (duration is a bit more complex)
|
|
44
|
+
return undefined;
|
|
45
|
+
case "scale":
|
|
46
|
+
return formatScale(value, numberType, locale);
|
|
47
|
+
case "ratio":
|
|
48
|
+
return formatRatio(value, numberType, locale);
|
|
49
|
+
default:
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function formatStandardNumber(value, options, locale) {
|
|
54
|
+
return formatNumberWithAffixes(value, options, locale);
|
|
55
|
+
}
|
|
56
|
+
function formatCurrency(value, rule, objectData, locale) {
|
|
57
|
+
const currencyCode = resolvePropertyReference(rule.currencyCode, objectData);
|
|
58
|
+
if (currencyCode == null) {
|
|
59
|
+
return formatStandardNumber(value, rule.baseFormatOptions, locale);
|
|
60
|
+
}
|
|
61
|
+
const options = {
|
|
62
|
+
...convertToIntlOptions(rule.baseFormatOptions),
|
|
63
|
+
style: "currency",
|
|
64
|
+
currency: currencyCode,
|
|
65
|
+
currencyDisplay: rule.style === "COMPACT" ? "narrowSymbol" : "symbol"
|
|
66
|
+
};
|
|
67
|
+
return formatWithIntl(value, options, locale);
|
|
68
|
+
}
|
|
69
|
+
function formatStandardUnit(value, rule, objectData, locale) {
|
|
70
|
+
const unit = resolvePropertyReference(rule.unit, objectData);
|
|
71
|
+
if (unit == null) {
|
|
72
|
+
return formatStandardNumber(value, rule.baseFormatOptions, locale);
|
|
73
|
+
}
|
|
74
|
+
const options = {
|
|
75
|
+
...convertToIntlOptions(rule.baseFormatOptions),
|
|
76
|
+
style: "unit",
|
|
77
|
+
unit: unit
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
return formatWithIntl(value, options, locale);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return formatNumberWithAffixes(value, rule.baseFormatOptions, locale, "", ` ${unit}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function formatCustomUnit(value, rule, objectData, locale) {
|
|
86
|
+
const unit = resolvePropertyReference(rule.unit, objectData);
|
|
87
|
+
const suffix = unit != null ? ` ${unit}` : "";
|
|
88
|
+
return formatNumberWithAffixes(value, rule.baseFormatOptions, locale, "", suffix);
|
|
89
|
+
}
|
|
90
|
+
function formatAffix(value, rule, objectData, locale) {
|
|
91
|
+
const prefix = rule.affix.prefix != null ? resolvePropertyReference(rule.affix.prefix, objectData) ?? "" : "";
|
|
92
|
+
const suffix = rule.affix.postfix != null ? resolvePropertyReference(rule.affix.postfix, objectData) ?? "" : "";
|
|
93
|
+
return formatNumberWithAffixes(value, rule.baseFormatOptions, locale, prefix, suffix);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Gets the scale divisor for a given scale type
|
|
98
|
+
*/
|
|
99
|
+
function getScaleDivisor(scaleType) {
|
|
100
|
+
switch (scaleType) {
|
|
101
|
+
case "THOUSANDS":
|
|
102
|
+
return 1e3;
|
|
103
|
+
case "MILLIONS":
|
|
104
|
+
return 1e6;
|
|
105
|
+
case "BILLIONS":
|
|
106
|
+
return 1e9;
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`Unknown scale type: ${scaleType}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Extracts the localized compact suffix for a given scale.
|
|
114
|
+
* Uses Intl.NumberFormat with compact notation to get the proper i18n suffix.
|
|
115
|
+
*/
|
|
116
|
+
function getLocalizedCompactSuffix(scaleDivisor, locale) {
|
|
117
|
+
const compactFormatter = new Intl.NumberFormat(locale, {
|
|
118
|
+
notation: "compact",
|
|
119
|
+
compactDisplay: "short"
|
|
120
|
+
});
|
|
121
|
+
const parts = compactFormatter.formatToParts(scaleDivisor);
|
|
122
|
+
const compactPart = parts.find(p => p.type === "compact");
|
|
123
|
+
return compactPart?.value ?? "";
|
|
124
|
+
}
|
|
125
|
+
function formatScale(value, rule, locale) {
|
|
126
|
+
const scaleDivisor = getScaleDivisor(rule.scaleType);
|
|
127
|
+
const suffix = getLocalizedCompactSuffix(scaleDivisor, locale);
|
|
128
|
+
return formatNumberWithAffixes(value / scaleDivisor, rule.baseFormatOptions, locale, "", suffix);
|
|
129
|
+
}
|
|
130
|
+
function getRatioScaledValue(value, ratioType) {
|
|
131
|
+
switch (ratioType) {
|
|
132
|
+
case "PERCENTAGE":
|
|
133
|
+
return value * 100;
|
|
134
|
+
case "PER_MILLE":
|
|
135
|
+
return value * 1000;
|
|
136
|
+
case "BASIS_POINTS":
|
|
137
|
+
return value * 10000;
|
|
138
|
+
default:
|
|
139
|
+
throw new Error(`Unknown ratio type: ${ratioType}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function formatRatio(value, rule, locale) {
|
|
143
|
+
// Special case: PERCENTAGE uses Intl's native percent style
|
|
144
|
+
if (rule.ratioType === "PERCENTAGE") {
|
|
145
|
+
const options = {
|
|
146
|
+
...convertToIntlOptions(rule.baseFormatOptions),
|
|
147
|
+
style: "percent"
|
|
148
|
+
};
|
|
149
|
+
return formatWithIntl(value, options, locale);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Other ratio types: scale and add suffix
|
|
153
|
+
const scaledValue = getRatioScaledValue(value, rule.ratioType);
|
|
154
|
+
let suffix;
|
|
155
|
+
switch (rule.ratioType) {
|
|
156
|
+
case "PER_MILLE":
|
|
157
|
+
suffix = "‰";
|
|
158
|
+
break;
|
|
159
|
+
case "BASIS_POINTS":
|
|
160
|
+
suffix = " bps";
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
rule.ratioType;
|
|
164
|
+
throw new Error(`Unknown ratio type: ${rule.ratioType}`);
|
|
165
|
+
}
|
|
166
|
+
return formatNumberWithAffixes(scaledValue, rule.baseFormatOptions, locale, "", suffix);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Maps notation from OSDK format to Intl format
|
|
171
|
+
*/
|
|
172
|
+
function mapNotation(notation) {
|
|
173
|
+
switch (notation) {
|
|
174
|
+
case "STANDARD":
|
|
175
|
+
return "standard";
|
|
176
|
+
case "SCIENTIFIC":
|
|
177
|
+
return "scientific";
|
|
178
|
+
case "ENGINEERING":
|
|
179
|
+
return "engineering";
|
|
180
|
+
case "COMPACT":
|
|
181
|
+
return "compact";
|
|
182
|
+
default:
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Maps rounding mode from OSDK format to Intl format
|
|
188
|
+
*/
|
|
189
|
+
function mapRoundingMode(mode) {
|
|
190
|
+
switch (mode) {
|
|
191
|
+
case "CEIL":
|
|
192
|
+
return "ceil";
|
|
193
|
+
case "FLOOR":
|
|
194
|
+
return "floor";
|
|
195
|
+
case "ROUND_CLOSEST":
|
|
196
|
+
return "halfExpand";
|
|
197
|
+
default:
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function convertToIntlOptions(options) {
|
|
202
|
+
return {
|
|
203
|
+
useGrouping: options.useGrouping,
|
|
204
|
+
minimumIntegerDigits: options.minimumIntegerDigits,
|
|
205
|
+
minimumFractionDigits: options.minimumFractionDigits,
|
|
206
|
+
maximumFractionDigits: options.maximumFractionDigits,
|
|
207
|
+
minimumSignificantDigits: options.minimumSignificantDigits,
|
|
208
|
+
maximumSignificantDigits: options.maximumSignificantDigits,
|
|
209
|
+
notation: options.notation ? mapNotation(options.notation) : undefined,
|
|
210
|
+
roundingMode: options.roundingMode ? mapRoundingMode(options.roundingMode) : undefined,
|
|
211
|
+
convertNegativeToParenthesis: options.convertNegativeToParenthesis
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Applies negative-to-parenthesis conversion if requested
|
|
217
|
+
*/
|
|
218
|
+
function maybeConvertNegativeToParenthesis(formatted, value, shouldConvert) {
|
|
219
|
+
if (shouldConvert && value < 0) {
|
|
220
|
+
return formatted.replace(/^-/, "(") + ")";
|
|
221
|
+
}
|
|
222
|
+
return formatted;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Formats a number using Intl.NumberFormat with the given options
|
|
227
|
+
*/
|
|
228
|
+
function formatWithIntl(value, options, locale) {
|
|
229
|
+
const formatter = new Intl.NumberFormat(locale, options);
|
|
230
|
+
const formatted = formatter.format(value);
|
|
231
|
+
return maybeConvertNegativeToParenthesis(formatted, value, options.convertNegativeToParenthesis ?? false);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Formats a number and optionally adds prefix/suffix
|
|
236
|
+
*/
|
|
237
|
+
function formatNumberWithAffixes(value, baseOptions, locale, prefix, suffix) {
|
|
238
|
+
const intlOptions = convertToIntlOptions(baseOptions);
|
|
239
|
+
const formatted = formatWithIntl(value, intlOptions, locale);
|
|
240
|
+
return `${prefix || ""}${formatted}${suffix || ""}`;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=formatNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatNumber.js","names":["resolvePropertyReference","formatNumber","value","numberType","objectData","locale","type","formatStandardNumber","baseFormatOptions","values","formatCurrency","formatStandardUnit","formatCustomUnit","formatAffix","undefined","formatScale","formatRatio","options","formatNumberWithAffixes","rule","currencyCode","convertToIntlOptions","style","currency","currencyDisplay","formatWithIntl","unit","error","suffix","prefix","affix","postfix","getScaleDivisor","scaleType","Error","getLocalizedCompactSuffix","scaleDivisor","compactFormatter","Intl","NumberFormat","notation","compactDisplay","parts","formatToParts","compactPart","find","p","getRatioScaledValue","ratioType","scaledValue","mapNotation","mapRoundingMode","mode","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","roundingMode","convertNegativeToParenthesis","maybeConvertNegativeToParenthesis","formatted","shouldConvert","replace","formatter","format","baseOptions","intlOptions"],"sources":["formatNumber.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 {\n NumberFormatAffix,\n NumberFormatCurrency,\n NumberFormatCustomUnit,\n NumberFormatOptions,\n NumberFormatRatio,\n NumberFormatScale,\n NumberFormatStandardUnit,\n NumberRatioType,\n NumberScaleType,\n PropertyNumberFormattingRuleType,\n} from \"@osdk/api\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\nimport { resolvePropertyReference } from \"./propertyFormattingUtils.js\";\n\n/**\n * Extended NumberFormatOptions that includes rounding mode support\n * which is available in modern browsers but not yet in TypeScript types.\n * Only includes modes that are actually supported by Intl.NumberFormat and used in our API.\n */\nexport interface ExtendedNumberFormatOptions extends Intl.NumberFormatOptions {\n roundingMode?: \"ceil\" | \"floor\" | \"halfExpand\";\n convertNegativeToParenthesis?: boolean;\n}\n\n/**\n * Formats a number value according to the specified formatting rule\n */\nexport function formatNumber(\n value: number,\n numberType: PropertyNumberFormattingRuleType,\n objectData: SimpleOsdkProperties,\n locale: string,\n): string | undefined {\n switch (numberType.type) {\n case \"standard\":\n return formatStandardNumber(\n value,\n numberType.baseFormatOptions,\n locale,\n );\n\n case \"fixedValues\":\n return numberType.values[value];\n\n case \"currency\":\n return formatCurrency(value, numberType, objectData, locale);\n\n case \"standardUnit\":\n return formatStandardUnit(value, numberType, objectData, locale);\n\n case \"customUnit\":\n return formatCustomUnit(value, numberType, objectData, locale);\n\n case \"affix\":\n return formatAffix(value, numberType, objectData, locale);\n\n case \"duration\":\n // TODO (duration is a bit more complex)\n return undefined;\n\n case \"scale\":\n return formatScale(value, numberType, locale);\n\n case \"ratio\":\n return formatRatio(value, numberType, locale);\n\n default:\n numberType satisfies never;\n return undefined;\n }\n}\n\nfunction formatStandardNumber(\n value: number,\n options: NumberFormatOptions,\n locale: string,\n): string {\n return formatNumberWithAffixes(value, options, locale);\n}\n\nfunction formatCurrency(\n value: number,\n rule: NumberFormatCurrency,\n objectData: SimpleOsdkProperties,\n locale: string,\n): string {\n const currencyCode = resolvePropertyReference(rule.currencyCode, objectData);\n if (currencyCode == null) {\n return formatStandardNumber(value, rule.baseFormatOptions, locale);\n }\n\n const options: ExtendedNumberFormatOptions = {\n ...convertToIntlOptions(rule.baseFormatOptions),\n style: \"currency\",\n currency: currencyCode,\n currencyDisplay: rule.style === \"COMPACT\" ? \"narrowSymbol\" : \"symbol\",\n };\n\n return formatWithIntl(value, options, locale);\n}\n\nfunction formatStandardUnit(\n value: number,\n rule: NumberFormatStandardUnit,\n objectData: SimpleOsdkProperties,\n locale: string,\n): string {\n const unit = resolvePropertyReference(rule.unit, objectData);\n if (unit == null) {\n return formatStandardNumber(value, rule.baseFormatOptions, locale);\n }\n\n const options: ExtendedNumberFormatOptions = {\n ...convertToIntlOptions(rule.baseFormatOptions),\n style: \"unit\",\n unit: unit,\n };\n\n try {\n return formatWithIntl(value, options, locale);\n } catch (error) {\n const suffix = ` ${unit}`;\n return formatNumberWithAffixes(\n value,\n rule.baseFormatOptions,\n locale,\n \"\",\n suffix,\n );\n }\n}\n\nfunction formatCustomUnit(\n value: number,\n rule: NumberFormatCustomUnit,\n objectData: SimpleOsdkProperties,\n locale: string,\n): string {\n const unit = resolvePropertyReference(rule.unit, objectData);\n const suffix = unit != null ? ` ${unit}` : \"\";\n return formatNumberWithAffixes(\n value,\n rule.baseFormatOptions,\n locale,\n \"\",\n suffix,\n );\n}\n\nfunction formatAffix(\n value: number,\n rule: NumberFormatAffix,\n objectData: SimpleOsdkProperties,\n locale: string,\n): string {\n const prefix = rule.affix.prefix != null\n ? resolvePropertyReference(rule.affix.prefix, objectData) ?? \"\"\n : \"\";\n const suffix = rule.affix.postfix != null\n ? resolvePropertyReference(rule.affix.postfix, objectData) ?? \"\"\n : \"\";\n return formatNumberWithAffixes(\n value,\n rule.baseFormatOptions,\n locale,\n prefix,\n suffix,\n );\n}\n\n/**\n * Gets the scale divisor for a given scale type\n */\nfunction getScaleDivisor(scaleType: NumberScaleType): number {\n switch (scaleType) {\n case \"THOUSANDS\":\n return 1e3;\n case \"MILLIONS\":\n return 1e6;\n case \"BILLIONS\":\n return 1e9;\n default:\n scaleType satisfies never;\n throw new Error(`Unknown scale type: ${scaleType}`);\n }\n}\n\n/**\n * Extracts the localized compact suffix for a given scale.\n * Uses Intl.NumberFormat with compact notation to get the proper i18n suffix.\n */\nfunction getLocalizedCompactSuffix(\n scaleDivisor: number,\n locale: string,\n): string {\n const compactFormatter = new Intl.NumberFormat(locale, {\n notation: \"compact\",\n compactDisplay: \"short\",\n });\n\n const parts = compactFormatter.formatToParts(scaleDivisor);\n const compactPart = parts.find(p => p.type === \"compact\");\n return compactPart?.value ?? \"\";\n}\n\nfunction formatScale(\n value: number,\n rule: NumberFormatScale,\n locale: string,\n): string {\n const scaleDivisor = getScaleDivisor(rule.scaleType);\n const scaledValue = value / scaleDivisor;\n const suffix = getLocalizedCompactSuffix(scaleDivisor, locale);\n\n return formatNumberWithAffixes(\n scaledValue,\n rule.baseFormatOptions,\n locale,\n \"\",\n suffix,\n );\n}\n\nfunction getRatioScaledValue(\n value: number,\n ratioType: NumberRatioType,\n): number {\n switch (ratioType) {\n case \"PERCENTAGE\":\n return value * 100;\n case \"PER_MILLE\":\n return value * 1000;\n case \"BASIS_POINTS\":\n return value * 10000;\n default:\n ratioType satisfies never;\n throw new Error(`Unknown ratio type: ${ratioType}`);\n }\n}\n\nfunction formatRatio(\n value: number,\n rule: NumberFormatRatio,\n locale: string,\n): string {\n // Special case: PERCENTAGE uses Intl's native percent style\n if (rule.ratioType === \"PERCENTAGE\") {\n const options: ExtendedNumberFormatOptions = {\n ...convertToIntlOptions(rule.baseFormatOptions),\n style: \"percent\",\n };\n return formatWithIntl(value, options, locale);\n }\n\n // Other ratio types: scale and add suffix\n const scaledValue = getRatioScaledValue(value, rule.ratioType);\n\n let suffix: string;\n switch (rule.ratioType) {\n case \"PER_MILLE\":\n suffix = \"‰\";\n break;\n case \"BASIS_POINTS\":\n suffix = \" bps\";\n break;\n default:\n rule.ratioType satisfies never;\n throw new Error(`Unknown ratio type: ${rule.ratioType}`);\n }\n\n return formatNumberWithAffixes(\n scaledValue,\n rule.baseFormatOptions,\n locale,\n \"\",\n suffix,\n );\n}\n\n/**\n * Maps notation from OSDK format to Intl format\n */\nfunction mapNotation(\n notation: \"STANDARD\" | \"SCIENTIFIC\" | \"ENGINEERING\" | \"COMPACT\",\n): Intl.NumberFormatOptions[\"notation\"] {\n switch (notation) {\n case \"STANDARD\":\n return \"standard\";\n case \"SCIENTIFIC\":\n return \"scientific\";\n case \"ENGINEERING\":\n return \"engineering\";\n case \"COMPACT\":\n return \"compact\";\n default:\n notation satisfies never;\n }\n}\n\n/**\n * Maps rounding mode from OSDK format to Intl format\n */\nfunction mapRoundingMode(\n mode: \"CEIL\" | \"FLOOR\" | \"ROUND_CLOSEST\",\n): ExtendedNumberFormatOptions[\"roundingMode\"] {\n switch (mode) {\n case \"CEIL\":\n return \"ceil\";\n case \"FLOOR\":\n return \"floor\";\n case \"ROUND_CLOSEST\":\n return \"halfExpand\";\n default:\n mode satisfies never;\n return undefined;\n }\n}\n\nfunction convertToIntlOptions(\n options: NumberFormatOptions,\n): ExtendedNumberFormatOptions {\n return {\n useGrouping: options.useGrouping,\n minimumIntegerDigits: options.minimumIntegerDigits,\n minimumFractionDigits: options.minimumFractionDigits,\n maximumFractionDigits: options.maximumFractionDigits,\n minimumSignificantDigits: options.minimumSignificantDigits,\n maximumSignificantDigits: options.maximumSignificantDigits,\n notation: options.notation ? mapNotation(options.notation) : undefined,\n roundingMode: options.roundingMode\n ? mapRoundingMode(options.roundingMode)\n : undefined,\n convertNegativeToParenthesis: options.convertNegativeToParenthesis,\n };\n}\n\n/**\n * Applies negative-to-parenthesis conversion if requested\n */\nfunction maybeConvertNegativeToParenthesis(\n formatted: string,\n value: number,\n shouldConvert: boolean,\n): string {\n if (shouldConvert && value < 0) {\n return formatted.replace(/^-/, \"(\") + \")\";\n }\n return formatted;\n}\n\n/**\n * Formats a number using Intl.NumberFormat with the given options\n */\nfunction formatWithIntl(\n value: number,\n options: ExtendedNumberFormatOptions,\n locale: string,\n): string {\n const formatter = new Intl.NumberFormat(locale, options);\n const formatted = formatter.format(value);\n return maybeConvertNegativeToParenthesis(\n formatted,\n value,\n options.convertNegativeToParenthesis ?? false,\n );\n}\n\n/**\n * Formats a number and optionally adds prefix/suffix\n */\nfunction formatNumberWithAffixes(\n value: number,\n baseOptions: NumberFormatOptions,\n locale: string,\n prefix?: string,\n suffix?: string,\n): string {\n const intlOptions = convertToIntlOptions(baseOptions);\n const formatted = formatWithIntl(value, intlOptions, locale);\n return `${prefix || \"\"}${formatted}${suffix || \"\"}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,SAASA,wBAAwB,QAAQ,8BAA8B;;AAEvE;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1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EAAE1C,OAAO,CAAC0C,YAAY,GAC9BR,eAAe,CAAClC,OAAO,CAAC0C,YAAY,CAAC,GACrC7C,SAAS;IACb8C,4BAA4B,EAAE3C,OAAO,CAAC2C;EACxC,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASC,iCAAiCA,CACxCC,SAAiB,EACjB5D,KAAa,EACb6D,aAAsB,EACd;EACR,IAAIA,aAAa,IAAI7D,KAAK,GAAG,CAAC,EAAE;IAC9B,OAAO4D,SAAS,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG;EAC3C;EACA,OAAOF,SAAS;AAClB;;AAEA;AACA;AACA;AACA,SAASrC,cAAcA,CACrBvB,KAAa,EACbe,OAAoC,EACpCZ,MAAc,EACN;EACR,MAAM4D,SAAS,GAAG,IAAI3B,IAAI,CAACC,YAAY,CAAClC,MAAM,EAAEY,OAAO,CAAC;EACxD,MAAM6C,SAAS,GAAGG,SAAS,CAACC,MAAM,CAAChE,KAAK,CAAC;EACzC,OAAO2D,iCAAiC,CACtCC,SAAS,EACT5D,KAAK,EACLe,OAAO,CAAC2C,4BAA4B,IAAI,KAC1C,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAAS1C,uBAAuBA,CAC9BhB,KAAa,EACbiE,WAAgC,EAChC9D,MAAc,EACdwB,MAAe,EACfD,MAAe,EACP;EACR,MAAMwC,WAAW,GAAG/C,oBAAoB,CAAC8C,WAAW,CAAC;EACrD,MAAML,SAAS,GAAGrC,cAAc,CAACvB,KAAK,EAAEkE,WAAW,EAAE/D,MAAM,CAAC;EAC5D,OAAO,GAAGwB,MAAM,IAAI,EAAE,GAAGiC,SAAS,GAAGlC,MAAM,IAAI,EAAE,EAAE;AACrD","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Resolves a property reference or string constant to its actual value
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function resolvePropertyReference(ref, objectData) {
|
|
22
|
+
if (ref.type === "constant") {
|
|
23
|
+
return ref.value;
|
|
24
|
+
} else if (ref.type === "propertyType") {
|
|
25
|
+
const value = objectData[ref.propertyApiName];
|
|
26
|
+
return value != null ? String(value) : undefined;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the browser's current locale
|
|
32
|
+
*/
|
|
33
|
+
export function getBrowserLocale() {
|
|
34
|
+
if (typeof navigator !== "undefined" && navigator.language != null) {
|
|
35
|
+
return navigator.language;
|
|
36
|
+
}
|
|
37
|
+
return "en-US";
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=propertyFormattingUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertyFormattingUtils.js","names":["resolvePropertyReference","ref","objectData","type","value","propertyApiName","String","undefined","getBrowserLocale","navigator","language"],"sources":["propertyFormattingUtils.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 { PropertyTypeReferenceOrStringConstant } from \"@osdk/api\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\n\n/**\n * Resolves a property reference or string constant to its actual value\n */\n\nexport function resolvePropertyReference(\n ref: PropertyTypeReferenceOrStringConstant,\n objectData: SimpleOsdkProperties,\n): string | undefined {\n if (ref.type === \"constant\") {\n return ref.value;\n } else if (ref.type === \"propertyType\") {\n const value = objectData[ref.propertyApiName];\n return value != null ? String(value) : undefined;\n }\n return undefined;\n}\n/**\n * Gets the browser's current locale\n */\nexport function getBrowserLocale(): string {\n if (typeof navigator !== \"undefined\" && navigator.language != null) {\n return navigator.language;\n }\n return \"en-US\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AAEA,OAAO,SAASA,wBAAwBA,CACtCC,GAA0C,EAC1CC,UAAgC,EACZ;EACpB,IAAID,GAAG,CAACE,IAAI,KAAK,UAAU,EAAE;IAC3B,OAAOF,GAAG,CAACG,KAAK;EAClB,CAAC,MAAM,IAAIH,GAAG,CAACE,IAAI,KAAK,cAAc,EAAE;IACtC,MAAMC,KAAK,GAAGF,UAAU,CAACD,GAAG,CAACI,eAAe,CAAC;IAC7C,OAAOD,KAAK,IAAI,IAAI,GAAGE,MAAM,CAACF,KAAK,CAAC,GAAGG,SAAS;EAClD;EACA,OAAOA,SAAS;AAClB;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAW;EACzC,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,QAAQ,IAAI,IAAI,EAAE;IAClE,OAAOD,SAAS,CAACC,QAAQ;EAC3B;EACA,OAAO,OAAO;AAChB","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.6.0-beta.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.6.0-beta.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.6.0-beta.2"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.6.0-beta.2"}`;
|
|
19
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -12,7 +12,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
var invariant5__default = /*#__PURE__*/_interopDefault(invariant5);
|
|
13
13
|
var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
|
|
14
14
|
|
|
15
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
15
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/Action.js
|
|
16
16
|
var Action_exports = {};
|
|
17
17
|
chunkQ7SFCCGT_cjs.__export(Action_exports, {
|
|
18
18
|
apply: () => apply,
|
|
@@ -68,7 +68,7 @@ async function apiFetch(clientCtx, method, endpointPath, data, queryArguments, h
|
|
|
68
68
|
if (!response.ok) {
|
|
69
69
|
try {
|
|
70
70
|
const convertedError = await response.json();
|
|
71
|
-
return new shared_net_errors.PalantirApiError(convertedError.message, convertedError.errorName, convertedError.errorCode, response.status, convertedError.errorInstanceId, convertedError.parameters);
|
|
71
|
+
return new shared_net_errors.PalantirApiError(convertedError.message, convertedError.errorName, convertedError.errorCode, convertedError.errorDescription, response.status, convertedError.errorInstanceId, convertedError.parameters);
|
|
72
72
|
} catch (e) {
|
|
73
73
|
if (e instanceof Error) {
|
|
74
74
|
return new shared_net_errors.UnknownError(e.message, "UNKNOWN");
|
|
@@ -89,7 +89,7 @@ function parseUrl(baseUrl, endpointPath) {
|
|
|
89
89
|
return new URL(`api${endpointPath}`, baseUrl);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
92
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/Action.js
|
|
93
93
|
var _apply = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];
|
|
94
94
|
function apply($ctx, ...args) {
|
|
95
95
|
return foundryPlatformFetch($ctx, _apply, ...args);
|
|
@@ -103,7 +103,7 @@ function applyBatch($ctx, ...args) {
|
|
|
103
103
|
return foundryPlatformFetch($ctx, _applyBatch, ...args);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
106
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/ActionTypeV2.js
|
|
107
107
|
var ActionTypeV2_exports = {};
|
|
108
108
|
chunkQ7SFCCGT_cjs.__export(ActionTypeV2_exports, {
|
|
109
109
|
get: () => get,
|
|
@@ -123,7 +123,7 @@ function getByRid($ctx, ...args) {
|
|
|
123
123
|
return foundryPlatformFetch($ctx, _getByRid, ...args);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
126
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/Attachment.js
|
|
127
127
|
var Attachment_exports = {};
|
|
128
128
|
chunkQ7SFCCGT_cjs.__export(Attachment_exports, {
|
|
129
129
|
get: () => get2,
|
|
@@ -148,7 +148,7 @@ function get2($ctx, ...args) {
|
|
|
148
148
|
return foundryPlatformFetch($ctx, _get2, ...args);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
151
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/MediaReferenceProperty.js
|
|
152
152
|
var MediaReferenceProperty_exports = {};
|
|
153
153
|
chunkQ7SFCCGT_cjs.__export(MediaReferenceProperty_exports, {
|
|
154
154
|
getMediaContent: () => getMediaContent,
|
|
@@ -173,7 +173,7 @@ function uploadMedia($ctx, ...args) {
|
|
|
173
173
|
return foundryPlatformFetch($ctx, _uploadMedia, ...args);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
176
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/ObjectTypeV2.js
|
|
177
177
|
var ObjectTypeV2_exports = {};
|
|
178
178
|
chunkQ7SFCCGT_cjs.__export(ObjectTypeV2_exports, {
|
|
179
179
|
get: () => get3,
|
|
@@ -203,13 +203,14 @@ function getOutgoingLinkType($ctx, ...args) {
|
|
|
203
203
|
return foundryPlatformFetch($ctx, _getOutgoingLinkType, ...args);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
206
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyInterface.js
|
|
207
207
|
var OntologyInterface_exports = {};
|
|
208
208
|
chunkQ7SFCCGT_cjs.__export(OntologyInterface_exports, {
|
|
209
209
|
aggregate: () => aggregate,
|
|
210
210
|
get: () => get4,
|
|
211
211
|
getOutgoingInterfaceLinkType: () => getOutgoingInterfaceLinkType,
|
|
212
212
|
list: () => list3,
|
|
213
|
+
listInterfaceLinkedObjects: () => listInterfaceLinkedObjects,
|
|
213
214
|
listObjectsForInterface: () => listObjectsForInterface,
|
|
214
215
|
listOutgoingInterfaceLinkTypes: () => listOutgoingInterfaceLinkTypes,
|
|
215
216
|
search: () => search
|
|
@@ -242,8 +243,12 @@ var _getOutgoingInterfaceLinkType = [0, "/v2/ontologies/{0}/interfaceTypes/{1}/o
|
|
|
242
243
|
function getOutgoingInterfaceLinkType($ctx, ...args) {
|
|
243
244
|
return foundryPlatformFetch($ctx, _getOutgoingInterfaceLinkType, ...args);
|
|
244
245
|
}
|
|
246
|
+
var _listInterfaceLinkedObjects = [0, "/v2/ontologies/{0}/interfaces/{1}/{2}/{3}/links/{4}", 2];
|
|
247
|
+
function listInterfaceLinkedObjects($ctx, ...args) {
|
|
248
|
+
return foundryPlatformFetch($ctx, _listInterfaceLinkedObjects, ...args);
|
|
249
|
+
}
|
|
245
250
|
|
|
246
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
251
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/OntologyObjectSet.js
|
|
247
252
|
var OntologyObjectSet_exports = {};
|
|
248
253
|
chunkQ7SFCCGT_cjs.__export(OntologyObjectSet_exports, {
|
|
249
254
|
aggregate: () => aggregate2,
|
|
@@ -278,7 +283,7 @@ function aggregate2($ctx, ...args) {
|
|
|
278
283
|
return foundryPlatformFetch($ctx, _aggregate2, ...args);
|
|
279
284
|
}
|
|
280
285
|
|
|
281
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
286
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/Query.js
|
|
282
287
|
var Query_exports = {};
|
|
283
288
|
chunkQ7SFCCGT_cjs.__export(Query_exports, {
|
|
284
289
|
execute: () => execute
|
|
@@ -288,7 +293,7 @@ function execute($ctx, ...args) {
|
|
|
288
293
|
return foundryPlatformFetch($ctx, _execute, ...args);
|
|
289
294
|
}
|
|
290
295
|
|
|
291
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
296
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/QueryType.js
|
|
292
297
|
var QueryType_exports = {};
|
|
293
298
|
chunkQ7SFCCGT_cjs.__export(QueryType_exports, {
|
|
294
299
|
get: () => get6,
|
|
@@ -303,7 +308,7 @@ function get6($ctx, ...args) {
|
|
|
303
308
|
return foundryPlatformFetch($ctx, _get6, ...args);
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
311
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/TimeSeriesPropertyV2.js
|
|
307
312
|
var TimeSeriesPropertyV2_exports = {};
|
|
308
313
|
chunkQ7SFCCGT_cjs.__export(TimeSeriesPropertyV2_exports, {
|
|
309
314
|
getFirstPoint: () => getFirstPoint,
|
|
@@ -323,7 +328,7 @@ function streamPoints($ctx, ...args) {
|
|
|
323
328
|
return foundryPlatformFetch($ctx, _streamPoints, ...args);
|
|
324
329
|
}
|
|
325
330
|
|
|
326
|
-
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.
|
|
331
|
+
// ../../node_modules/.pnpm/@osdk+foundry.ontologies@2.35.0/node_modules/@osdk/foundry.ontologies/build/esm/public/TimeSeriesValueBankProperty.js
|
|
327
332
|
var TimeSeriesValueBankProperty_exports = {};
|
|
328
333
|
chunkQ7SFCCGT_cjs.__export(TimeSeriesValueBankProperty_exports, {
|
|
329
334
|
getLatestValue: () => getLatestValue,
|
|
@@ -501,6 +506,21 @@ function handleWherePair([fieldName, filter], objectOrInterface, structFieldSele
|
|
|
501
506
|
fuzzy: typeof filter[firstKey] === "string" ? false : filter[firstKey]["fuzzySearch"] ?? false
|
|
502
507
|
};
|
|
503
508
|
}
|
|
509
|
+
if (firstKey === "$contains" && filter[firstKey] instanceof Object) {
|
|
510
|
+
const structFilter = Object.entries(filter[firstKey]);
|
|
511
|
+
!(structFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Cannot filter on more than one struct field in the same clause, need to use an and clause") : invariant5__default.default(false) : void 0;
|
|
512
|
+
const structFieldApiName = structFilter[0][0];
|
|
513
|
+
!(structFilter[0][1] != null && Object.keys(structFilter[0][1]).length === 1 && "$eq" in structFilter[0][1]) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Cannot filter on a struct field in an array with anything other than a single $eq") : invariant5__default.default(false) : void 0;
|
|
514
|
+
return {
|
|
515
|
+
type: "contains",
|
|
516
|
+
propertyIdentifier: {
|
|
517
|
+
type: "structField",
|
|
518
|
+
propertyApiName: fieldName,
|
|
519
|
+
structFieldApiName
|
|
520
|
+
},
|
|
521
|
+
value: structFilter[0][1]["$eq"]
|
|
522
|
+
};
|
|
523
|
+
}
|
|
504
524
|
return {
|
|
505
525
|
type: firstKey.substring(1),
|
|
506
526
|
...propertyIdentifier != null && {
|
|
@@ -2068,5 +2088,5 @@ exports.hydrateAttachmentFromRidInternal = hydrateAttachmentFromRidInternal;
|
|
|
2068
2088
|
exports.isObjectSet = isObjectSet;
|
|
2069
2089
|
exports.isWireObjectSet = isWireObjectSet;
|
|
2070
2090
|
exports.symbolClientContext = symbolClientContext;
|
|
2071
|
-
//# sourceMappingURL=chunk-
|
|
2072
|
-
//# sourceMappingURL=chunk-
|
|
2091
|
+
//# sourceMappingURL=chunk-6L3MX4LH.cjs.map
|
|
2092
|
+
//# sourceMappingURL=chunk-6L3MX4LH.cjs.map
|