@osdk/maker 0.13.0 → 0.14.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 (222) hide show
  1. package/CHANGELOG.md +102 -36
  2. package/README.md +86 -22
  3. package/build/browser/api/action/DefaultFormat.js +2 -0
  4. package/build/browser/api/action/DefaultFormat.js.map +1 -0
  5. package/build/browser/api/action/TableConfiguration.js +2 -0
  6. package/build/browser/api/action/TableConfiguration.js.map +1 -0
  7. package/build/browser/api/code-snippets/createCodeSnippets.js +91 -0
  8. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
  9. package/build/browser/api/code-snippets/snippetTypes.js +60 -0
  10. package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
  11. package/build/browser/api/defineAction.js +131 -414
  12. package/build/browser/api/defineAction.js.map +1 -1
  13. package/build/browser/api/defineCreateInterfaceObjectAction.js +85 -0
  14. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
  15. package/build/browser/api/defineCreateObjectAction.js +80 -0
  16. package/build/browser/api/defineCreateObjectAction.js.map +1 -0
  17. package/build/browser/api/defineCreateOrModifyObjectAction.js +95 -0
  18. package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
  19. package/build/browser/api/defineDeleteInterfaceObjectAction.js +53 -0
  20. package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -0
  21. package/build/browser/api/defineDeleteObjectAction.js +56 -0
  22. package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
  23. package/build/browser/api/defineLink.js +5 -13
  24. package/build/browser/api/defineLink.js.map +1 -1
  25. package/build/browser/api/defineModifyInterfaceObjectAction.js +84 -0
  26. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
  27. package/build/browser/api/defineModifyObjectAction.js +93 -0
  28. package/build/browser/api/defineModifyObjectAction.js.map +1 -0
  29. package/build/browser/api/defineObject.js +94 -3
  30. package/build/browser/api/defineObject.js.map +1 -1
  31. package/build/browser/api/defineOntology.js +6 -1
  32. package/build/browser/api/defineOntology.js.map +1 -1
  33. package/build/browser/api/links/LinkType.js.map +1 -1
  34. package/build/browser/api/object/ObjectType.js.map +1 -1
  35. package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
  36. package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
  37. package/build/browser/api/test/actions.test.js +12034 -0
  38. package/build/browser/api/test/actions.test.js.map +1 -0
  39. package/build/browser/api/test/interfaces.test.js +924 -0
  40. package/build/browser/api/test/interfaces.test.js.map +1 -0
  41. package/build/browser/api/test/links.test.js +1974 -0
  42. package/build/browser/api/test/links.test.js.map +1 -0
  43. package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  44. package/build/browser/api/test/markingconstraint.test.js.map +1 -0
  45. package/build/browser/api/test/misc.test.js +1058 -0
  46. package/build/browser/api/test/misc.test.js.map +1 -0
  47. package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  48. package/build/browser/api/test/objectStatus.test.js.map +1 -0
  49. package/build/browser/api/test/objects.test.js +2591 -0
  50. package/build/browser/api/test/objects.test.js.map +1 -0
  51. package/build/browser/api/test/spt.test.js +387 -0
  52. package/build/browser/api/test/spt.test.js.map +1 -0
  53. package/build/browser/api/test/valueTypes.test.js +156 -0
  54. package/build/browser/api/test/valueTypes.test.js.map +1 -0
  55. package/build/browser/cli/main.js +25 -6
  56. package/build/browser/cli/main.js.map +1 -1
  57. package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
  58. package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
  59. package/build/browser/conversion/toMarketplace/convertActionValidation.js +2 -2
  60. package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
  61. package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +5 -3
  62. package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
  63. package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
  64. package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
  65. package/build/browser/conversion/toMarketplace/convertLink.js +109 -24
  66. package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
  67. package/build/browser/conversion/toMarketplace/convertObject.js +81 -4
  68. package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
  69. package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
  70. package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
  71. package/build/browser/index.js +8 -1
  72. package/build/browser/index.js.map +1 -1
  73. package/build/cjs/index.cjs +1716 -797
  74. package/build/cjs/index.cjs.map +1 -1
  75. package/build/cjs/index.d.cts +184 -115
  76. package/build/esm/api/action/DefaultFormat.js +2 -0
  77. package/build/esm/api/action/DefaultFormat.js.map +1 -0
  78. package/build/esm/api/action/TableConfiguration.js +2 -0
  79. package/build/esm/api/action/TableConfiguration.js.map +1 -0
  80. package/build/esm/api/code-snippets/createCodeSnippets.js +91 -0
  81. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
  82. package/build/esm/api/code-snippets/snippetTypes.js +60 -0
  83. package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
  84. package/build/esm/api/defineAction.js +131 -414
  85. package/build/esm/api/defineAction.js.map +1 -1
  86. package/build/esm/api/defineCreateInterfaceObjectAction.js +85 -0
  87. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
  88. package/build/esm/api/defineCreateObjectAction.js +80 -0
  89. package/build/esm/api/defineCreateObjectAction.js.map +1 -0
  90. package/build/esm/api/defineCreateOrModifyObjectAction.js +95 -0
  91. package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
  92. package/build/esm/api/defineDeleteInterfaceObjectAction.js +53 -0
  93. package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -0
  94. package/build/esm/api/defineDeleteObjectAction.js +56 -0
  95. package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
  96. package/build/esm/api/defineLink.js +5 -13
  97. package/build/esm/api/defineLink.js.map +1 -1
  98. package/build/esm/api/defineModifyInterfaceObjectAction.js +84 -0
  99. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
  100. package/build/esm/api/defineModifyObjectAction.js +93 -0
  101. package/build/esm/api/defineModifyObjectAction.js.map +1 -0
  102. package/build/esm/api/defineObject.js +94 -3
  103. package/build/esm/api/defineObject.js.map +1 -1
  104. package/build/esm/api/defineOntology.js +6 -1
  105. package/build/esm/api/defineOntology.js.map +1 -1
  106. package/build/esm/api/links/LinkType.js.map +1 -1
  107. package/build/esm/api/object/ObjectType.js.map +1 -1
  108. package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
  109. package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
  110. package/build/esm/api/test/actions.test.js +12034 -0
  111. package/build/esm/api/test/actions.test.js.map +1 -0
  112. package/build/esm/api/test/interfaces.test.js +924 -0
  113. package/build/esm/api/test/interfaces.test.js.map +1 -0
  114. package/build/esm/api/test/links.test.js +1974 -0
  115. package/build/esm/api/test/links.test.js.map +1 -0
  116. package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  117. package/build/esm/api/test/markingconstraint.test.js.map +1 -0
  118. package/build/esm/api/test/misc.test.js +1058 -0
  119. package/build/esm/api/test/misc.test.js.map +1 -0
  120. package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  121. package/build/esm/api/test/objectStatus.test.js.map +1 -0
  122. package/build/esm/api/test/objects.test.js +2591 -0
  123. package/build/esm/api/test/objects.test.js.map +1 -0
  124. package/build/esm/api/test/spt.test.js +387 -0
  125. package/build/esm/api/test/spt.test.js.map +1 -0
  126. package/build/esm/api/test/valueTypes.test.js +156 -0
  127. package/build/esm/api/test/valueTypes.test.js.map +1 -0
  128. package/build/esm/cli/main.js +25 -6
  129. package/build/esm/cli/main.js.map +1 -1
  130. package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
  131. package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
  132. package/build/esm/conversion/toMarketplace/convertActionValidation.js +2 -2
  133. package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
  134. package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +5 -3
  135. package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
  136. package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
  137. package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
  138. package/build/esm/conversion/toMarketplace/convertLink.js +109 -24
  139. package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
  140. package/build/esm/conversion/toMarketplace/convertObject.js +81 -4
  141. package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
  142. package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
  143. package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
  144. package/build/esm/index.js +8 -1
  145. package/build/esm/index.js.map +1 -1
  146. package/build/types/api/action/DefaultFormat.d.ts +1 -0
  147. package/build/types/api/action/DefaultFormat.d.ts.map +1 -0
  148. package/build/types/api/action/TableConfiguration.d.ts +8 -0
  149. package/build/types/api/action/TableConfiguration.d.ts.map +1 -0
  150. package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
  151. package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
  152. package/build/types/api/code-snippets/snippetTypes.d.ts +23 -0
  153. package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
  154. package/build/types/api/defineAction.d.ts +34 -10
  155. package/build/types/api/defineAction.d.ts.map +1 -1
  156. package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
  157. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
  158. package/build/types/api/defineCreateObjectAction.d.ts +3 -0
  159. package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
  160. package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
  161. package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
  162. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +3 -0
  163. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -0
  164. package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
  165. package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
  166. package/build/types/api/defineLink.d.ts.map +1 -1
  167. package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
  168. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
  169. package/build/types/api/defineModifyObjectAction.d.ts +3 -0
  170. package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
  171. package/build/types/api/defineObject.d.ts.map +1 -1
  172. package/build/types/api/defineOntology.d.ts +1 -1
  173. package/build/types/api/defineOntology.d.ts.map +1 -1
  174. package/build/types/api/links/LinkType.d.ts +7 -7
  175. package/build/types/api/object/ObjectType.d.ts +1 -1
  176. package/build/types/api/object/ObjectType.d.ts.map +1 -1
  177. package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +41 -1
  178. package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
  179. package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -1
  180. package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
  181. package/build/types/api/test/actions.test.d.ts.map +1 -0
  182. package/build/types/api/test/interfaces.test.d.ts.map +1 -0
  183. package/build/types/api/test/links.test.d.ts.map +1 -0
  184. package/build/types/api/test/markingconstraint.test.d.ts +1 -0
  185. package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
  186. package/build/types/api/test/misc.test.d.ts +1 -0
  187. package/build/types/api/test/misc.test.d.ts.map +1 -0
  188. package/build/types/api/test/objectStatus.test.d.ts +1 -0
  189. package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
  190. package/build/types/api/test/objects.test.d.ts +1 -0
  191. package/build/types/api/test/objects.test.d.ts.map +1 -0
  192. package/build/types/api/test/spt.test.d.ts +1 -0
  193. package/build/types/api/test/spt.test.d.ts.map +1 -0
  194. package/build/types/api/test/valueTypes.test.d.ts +1 -0
  195. package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
  196. package/build/types/cli/main.d.ts.map +1 -1
  197. package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +2 -2
  198. package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -1
  199. package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +2 -1
  200. package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -1
  201. package/build/types/conversion/toMarketplace/convertLink.d.ts +6 -0
  202. package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
  203. package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
  204. package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +2 -1
  205. package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -1
  206. package/build/types/index.d.ts +8 -1
  207. package/build/types/index.d.ts.map +1 -1
  208. package/package.json +6 -6
  209. package/build/browser/api/markingconstraint.test.js.map +0 -1
  210. package/build/browser/api/objectStatus.test.js.map +0 -1
  211. package/build/browser/api/overall.test.js +0 -13998
  212. package/build/browser/api/overall.test.js.map +0 -1
  213. package/build/esm/api/markingconstraint.test.js.map +0 -1
  214. package/build/esm/api/objectStatus.test.js.map +0 -1
  215. package/build/esm/api/overall.test.js +0 -13998
  216. package/build/esm/api/overall.test.js.map +0 -1
  217. package/build/types/api/markingconstraint.test.d.ts.map +0 -1
  218. package/build/types/api/objectStatus.test.d.ts.map +0 -1
  219. package/build/types/api/overall.test.d.ts.map +0 -1
  220. /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
  221. /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
  222. /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
@@ -0,0 +1,387 @@
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 { beforeEach, describe, expect, it } from "vitest";
18
+ import { defineInterface } from "../defineInterface.js";
19
+ import { defineOntology, dumpOntologyFullMetadata } from "../defineOntology.js";
20
+ import { defineSharedPropertyType } from "../defineSpt.js";
21
+ describe("SPTs", () => {
22
+ beforeEach(async () => {
23
+ await defineOntology("com.palantir.", () => {}, "/tmp/");
24
+ });
25
+ it("doesn't let you create the same spt twice", () => {
26
+ defineSharedPropertyType({
27
+ apiName: "foo",
28
+ type: "string"
29
+ });
30
+ expect(() => {
31
+ defineSharedPropertyType({
32
+ apiName: "foo",
33
+ type: "string"
34
+ });
35
+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);
36
+ });
37
+ it("uses a predefined spt", () => {
38
+ const fooSpt = defineSharedPropertyType({
39
+ apiName: "fooSpt",
40
+ type: "string"
41
+ });
42
+ defineInterface({
43
+ apiName: "FooInterface",
44
+ displayName: "Foo Interface",
45
+ properties: {
46
+ fooSpt
47
+ },
48
+ icon: {
49
+ color: "#00000",
50
+ locator: "airplane"
51
+ }
52
+ });
53
+ expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
54
+ {
55
+ "actionTypes": {},
56
+ "blockPermissionInformation": {
57
+ "actionTypes": {},
58
+ "linkTypes": {},
59
+ "objectTypes": {},
60
+ },
61
+ "interfaceTypes": {
62
+ "com.palantir.FooInterface": {
63
+ "interfaceType": {
64
+ "apiName": "com.palantir.FooInterface",
65
+ "displayMetadata": {
66
+ "description": "Foo Interface",
67
+ "displayName": "Foo Interface",
68
+ "icon": {
69
+ "blueprint": {
70
+ "color": "#00000",
71
+ "locator": "airplane",
72
+ },
73
+ "type": "blueprint",
74
+ },
75
+ },
76
+ "extendsInterfaces": [],
77
+ "links": [],
78
+ "properties": [],
79
+ "propertiesV2": {
80
+ "com.palantir.fooSpt": {
81
+ "required": true,
82
+ "sharedPropertyType": {
83
+ "aliases": [],
84
+ "apiName": "com.palantir.fooSpt",
85
+ "baseFormatter": undefined,
86
+ "dataConstraints": undefined,
87
+ "displayMetadata": {
88
+ "description": undefined,
89
+ "displayName": "fooSpt",
90
+ "visibility": "NORMAL",
91
+ },
92
+ "gothamMapping": undefined,
93
+ "indexedForSearch": true,
94
+ "type": {
95
+ "string": {
96
+ "analyzerOverride": undefined,
97
+ "enableAsciiFolding": undefined,
98
+ "isLongText": false,
99
+ "supportsEfficientLeadingWildcard": false,
100
+ "supportsExactMatching": true,
101
+ },
102
+ "type": "string",
103
+ },
104
+ "typeClasses": [
105
+ {
106
+ "kind": "render_hint",
107
+ "name": "SELECTABLE",
108
+ },
109
+ {
110
+ "kind": "render_hint",
111
+ "name": "SORTABLE",
112
+ },
113
+ ],
114
+ "valueType": undefined,
115
+ },
116
+ },
117
+ },
118
+ "propertiesV3": {},
119
+ "searchable": true,
120
+ "status": {
121
+ "active": {},
122
+ "type": "active",
123
+ },
124
+ },
125
+ },
126
+ },
127
+ "linkTypes": {},
128
+ "objectTypes": {},
129
+ "sharedPropertyTypes": {
130
+ "com.palantir.fooSpt": {
131
+ "sharedPropertyType": {
132
+ "aliases": [],
133
+ "apiName": "com.palantir.fooSpt",
134
+ "baseFormatter": undefined,
135
+ "dataConstraints": undefined,
136
+ "displayMetadata": {
137
+ "description": undefined,
138
+ "displayName": "fooSpt",
139
+ "visibility": "NORMAL",
140
+ },
141
+ "gothamMapping": undefined,
142
+ "indexedForSearch": true,
143
+ "type": {
144
+ "string": {
145
+ "analyzerOverride": undefined,
146
+ "enableAsciiFolding": undefined,
147
+ "isLongText": false,
148
+ "supportsEfficientLeadingWildcard": false,
149
+ "supportsExactMatching": true,
150
+ },
151
+ "type": "string",
152
+ },
153
+ "typeClasses": [
154
+ {
155
+ "kind": "render_hint",
156
+ "name": "SELECTABLE",
157
+ },
158
+ {
159
+ "kind": "render_hint",
160
+ "name": "SORTABLE",
161
+ },
162
+ ],
163
+ "valueType": undefined,
164
+ },
165
+ },
166
+ },
167
+ }
168
+ `);
169
+ });
170
+ it("properly serializes both types of struct SPTs", () => {
171
+ defineSharedPropertyType({
172
+ apiName: "fooSpt",
173
+ type: {
174
+ type: "struct",
175
+ structDefinition: {
176
+ "simpleProperty": "boolean",
177
+ "complexProperty": {
178
+ fieldType: "date",
179
+ displayMetadata: {
180
+ displayName: "complex property",
181
+ description: undefined
182
+ }
183
+ }
184
+ }
185
+ }
186
+ });
187
+ expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
188
+ {
189
+ "actionTypes": {},
190
+ "blockPermissionInformation": {
191
+ "actionTypes": {},
192
+ "linkTypes": {},
193
+ "objectTypes": {},
194
+ },
195
+ "interfaceTypes": {},
196
+ "linkTypes": {},
197
+ "objectTypes": {},
198
+ "sharedPropertyTypes": {
199
+ "com.palantir.fooSpt": {
200
+ "sharedPropertyType": {
201
+ "aliases": [],
202
+ "apiName": "com.palantir.fooSpt",
203
+ "baseFormatter": undefined,
204
+ "dataConstraints": undefined,
205
+ "displayMetadata": {
206
+ "description": undefined,
207
+ "displayName": "fooSpt",
208
+ "visibility": "NORMAL",
209
+ },
210
+ "gothamMapping": undefined,
211
+ "indexedForSearch": true,
212
+ "type": {
213
+ "struct": {
214
+ "structFields": [
215
+ {
216
+ "aliases": [],
217
+ "apiName": "simpleProperty",
218
+ "displayMetadata": {
219
+ "description": undefined,
220
+ "displayName": "simpleProperty",
221
+ },
222
+ "fieldType": {
223
+ "boolean": {},
224
+ "type": "boolean",
225
+ },
226
+ "typeClasses": [],
227
+ },
228
+ {
229
+ "aliases": [],
230
+ "apiName": "complexProperty",
231
+ "displayMetadata": {
232
+ "description": undefined,
233
+ "displayName": "complex property",
234
+ },
235
+ "fieldType": {
236
+ "date": {},
237
+ "type": "date",
238
+ },
239
+ "typeClasses": [],
240
+ },
241
+ ],
242
+ },
243
+ "type": "struct",
244
+ },
245
+ "typeClasses": [],
246
+ "valueType": undefined,
247
+ },
248
+ },
249
+ },
250
+ }
251
+ `);
252
+ });
253
+ it("Custom string fields properly set", () => {
254
+ const spt = defineSharedPropertyType({
255
+ apiName: "foo",
256
+ type: {
257
+ type: "string",
258
+ isLongText: true,
259
+ supportsEfficientLeadingWildcard: true,
260
+ supportsExactMatching: false
261
+ }
262
+ });
263
+ defineInterface({
264
+ apiName: "interface",
265
+ properties: {
266
+ foo: spt
267
+ }
268
+ });
269
+ expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
270
+ {
271
+ "actionTypes": {},
272
+ "blockPermissionInformation": {
273
+ "actionTypes": {},
274
+ "linkTypes": {},
275
+ "objectTypes": {},
276
+ },
277
+ "interfaceTypes": {
278
+ "com.palantir.interface": {
279
+ "interfaceType": {
280
+ "apiName": "com.palantir.interface",
281
+ "displayMetadata": {
282
+ "description": "interface",
283
+ "displayName": "interface",
284
+ "icon": {
285
+ "blueprint": {
286
+ "color": "#4C90F0",
287
+ "locator": "layout-hierarchy",
288
+ },
289
+ "type": "blueprint",
290
+ },
291
+ },
292
+ "extendsInterfaces": [],
293
+ "links": [],
294
+ "properties": [],
295
+ "propertiesV2": {
296
+ "com.palantir.foo": {
297
+ "required": true,
298
+ "sharedPropertyType": {
299
+ "aliases": [],
300
+ "apiName": "com.palantir.foo",
301
+ "baseFormatter": undefined,
302
+ "dataConstraints": undefined,
303
+ "displayMetadata": {
304
+ "description": undefined,
305
+ "displayName": "foo",
306
+ "visibility": "NORMAL",
307
+ },
308
+ "gothamMapping": undefined,
309
+ "indexedForSearch": true,
310
+ "type": {
311
+ "string": {
312
+ "analyzerOverride": undefined,
313
+ "enableAsciiFolding": undefined,
314
+ "isLongText": true,
315
+ "supportsEfficientLeadingWildcard": true,
316
+ "supportsExactMatching": false,
317
+ },
318
+ "type": "string",
319
+ },
320
+ "typeClasses": [
321
+ {
322
+ "kind": "render_hint",
323
+ "name": "SELECTABLE",
324
+ },
325
+ {
326
+ "kind": "render_hint",
327
+ "name": "SORTABLE",
328
+ },
329
+ ],
330
+ "valueType": undefined,
331
+ },
332
+ },
333
+ },
334
+ "propertiesV3": {},
335
+ "searchable": true,
336
+ "status": {
337
+ "active": {},
338
+ "type": "active",
339
+ },
340
+ },
341
+ },
342
+ },
343
+ "linkTypes": {},
344
+ "objectTypes": {},
345
+ "sharedPropertyTypes": {
346
+ "com.palantir.foo": {
347
+ "sharedPropertyType": {
348
+ "aliases": [],
349
+ "apiName": "com.palantir.foo",
350
+ "baseFormatter": undefined,
351
+ "dataConstraints": undefined,
352
+ "displayMetadata": {
353
+ "description": undefined,
354
+ "displayName": "foo",
355
+ "visibility": "NORMAL",
356
+ },
357
+ "gothamMapping": undefined,
358
+ "indexedForSearch": true,
359
+ "type": {
360
+ "string": {
361
+ "analyzerOverride": undefined,
362
+ "enableAsciiFolding": undefined,
363
+ "isLongText": true,
364
+ "supportsEfficientLeadingWildcard": true,
365
+ "supportsExactMatching": false,
366
+ },
367
+ "type": "string",
368
+ },
369
+ "typeClasses": [
370
+ {
371
+ "kind": "render_hint",
372
+ "name": "SELECTABLE",
373
+ },
374
+ {
375
+ "kind": "render_hint",
376
+ "name": "SORTABLE",
377
+ },
378
+ ],
379
+ "valueType": undefined,
380
+ },
381
+ },
382
+ },
383
+ }
384
+ `);
385
+ });
386
+ });
387
+ //# sourceMappingURL=spt.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spt.test.js","names":["beforeEach","describe","expect","it","defineInterface","defineOntology","dumpOntologyFullMetadata","defineSharedPropertyType","apiName","type","toThrowErrorMatchingInlineSnapshot","fooSpt","displayName","properties","icon","color","locator","ontology","toMatchInlineSnapshot","structDefinition","fieldType","displayMetadata","description","undefined","spt","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","foo"],"sources":["spt.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 { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineInterface } from \"../defineInterface.js\";\nimport { defineOntology, dumpOntologyFullMetadata } from \"../defineOntology.js\";\nimport { defineSharedPropertyType } from \"../defineSpt.js\";\ndescribe(\"SPTs\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"doesn't let you create the same spt twice\", () => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n\n expect(() => {\n defineSharedPropertyType({\n apiName: \"foo\",\n type: \"string\",\n });\n }).toThrowErrorMatchingInlineSnapshot(\n `[Error: Invariant failed: Shared property type com.palantir.foo already exists]`,\n );\n });\n\n it(\"uses a predefined spt\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: \"string\",\n });\n\n const FooInterface = defineInterface({\n apiName: \"FooInterface\",\n displayName: \"Foo Interface\",\n properties: {\n fooSpt,\n },\n icon: { color: \"#00000\", locator: \"airplane\" },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.FooInterface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.FooInterface\",\n \"displayMetadata\": {\n \"description\": \"Foo Interface\",\n \"displayName\": \"Foo Interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#00000\",\n \"locator\": \"airplane\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.fooSpt\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": false,\n \"supportsEfficientLeadingWildcard\": false,\n \"supportsExactMatching\": true,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"properly serializes both types of struct SPTs\", () => {\n const fooSpt = defineSharedPropertyType({\n apiName: \"fooSpt\",\n type: {\n type: \"struct\",\n structDefinition: {\n \"simpleProperty\": \"boolean\",\n \"complexProperty\": {\n fieldType: \"date\",\n displayMetadata: {\n displayName: \"complex property\",\n description: undefined,\n },\n },\n },\n },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.fooSpt\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.fooSpt\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"fooSpt\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"struct\": {\n \"structFields\": [\n {\n \"aliases\": [],\n \"apiName\": \"simpleProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"simpleProperty\",\n },\n \"fieldType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"typeClasses\": [],\n },\n {\n \"aliases\": [],\n \"apiName\": \"complexProperty\",\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"complex property\",\n },\n \"fieldType\": {\n \"date\": {},\n \"type\": \"date\",\n },\n \"typeClasses\": [],\n },\n ],\n },\n \"type\": \"struct\",\n },\n \"typeClasses\": [],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n\n it(\"Custom string fields properly set\", () => {\n const spt = defineSharedPropertyType({\n apiName: \"foo\",\n type: {\n type: \"string\",\n isLongText: true,\n supportsEfficientLeadingWildcard: true,\n supportsExactMatching: false,\n },\n });\n\n defineInterface({\n apiName: \"interface\",\n properties: { foo: spt },\n });\n\n expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`\n {\n \"actionTypes\": {},\n \"blockPermissionInformation\": {\n \"actionTypes\": {},\n \"linkTypes\": {},\n \"objectTypes\": {},\n },\n \"interfaceTypes\": {\n \"com.palantir.interface\": {\n \"interfaceType\": {\n \"apiName\": \"com.palantir.interface\",\n \"displayMetadata\": {\n \"description\": \"interface\",\n \"displayName\": \"interface\",\n \"icon\": {\n \"blueprint\": {\n \"color\": \"#4C90F0\",\n \"locator\": \"layout-hierarchy\",\n },\n \"type\": \"blueprint\",\n },\n },\n \"extendsInterfaces\": [],\n \"links\": [],\n \"properties\": [],\n \"propertiesV2\": {\n \"com.palantir.foo\": {\n \"required\": true,\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n \"propertiesV3\": {},\n \"searchable\": true,\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n },\n },\n \"linkTypes\": {},\n \"objectTypes\": {},\n \"sharedPropertyTypes\": {\n \"com.palantir.foo\": {\n \"sharedPropertyType\": {\n \"aliases\": [],\n \"apiName\": \"com.palantir.foo\",\n \"baseFormatter\": undefined,\n \"dataConstraints\": undefined,\n \"displayMetadata\": {\n \"description\": undefined,\n \"displayName\": \"foo\",\n \"visibility\": \"NORMAL\",\n },\n \"gothamMapping\": undefined,\n \"indexedForSearch\": true,\n \"type\": {\n \"string\": {\n \"analyzerOverride\": undefined,\n \"enableAsciiFolding\": undefined,\n \"isLongText\": true,\n \"supportsEfficientLeadingWildcard\": true,\n \"supportsExactMatching\": false,\n },\n \"type\": \"string\",\n },\n \"typeClasses\": [\n {\n \"kind\": \"render_hint\",\n \"name\": \"SELECTABLE\",\n },\n {\n \"kind\": \"render_hint\",\n \"name\": \"SORTABLE\",\n },\n ],\n \"valueType\": undefined,\n },\n },\n },\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,cAAc,EAAEC,wBAAwB,QAAQ,sBAAsB;AAC/E,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1DN,QAAQ,CAAC,MAAM,EAAE,MAAM;EACrBD,UAAU,CAAC,YAAY;IACrB,MAAMK,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFF,EAAE,CAAC,2CAA2C,EAAE,MAAM;IACpDI,wBAAwB,CAAC;MACvBC,OAAO,EAAE,KAAK;MACdC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFP,MAAM,CAAC,MAAM;MACXK,wBAAwB,CAAC;QACvBC,OAAO,EAAE,KAAK;QACdC,IAAI,EAAE;MACR,CAAC,CAAC;IACJ,CAAC,CAAC,CAACC,kCAAkC,CACnC,iFACF,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAChC,MAAMQ,MAAM,GAAGJ,wBAAwB,CAAC;MACtCC,OAAO,EAAE,QAAQ;MACjBC,IAAI,EAAE;IACR,CAAC,CAAC;IAEmBL,eAAe,CAAC;MACnCI,OAAO,EAAE,cAAc;MACvBI,WAAW,EAAE,eAAe;MAC5BC,UAAU,EAAE;QACVF;MACF,CAAC;MACDG,IAAI,EAAE;QAAEC,KAAK,EAAE,QAAQ;QAAEC,OAAO,EAAE;MAAW;IAC/C,CAAC,CAAC;IAEFd,MAAM,CAACI,wBAAwB,CAAC,CAAC,CAACW,QAAQ,CAAC,CAACC,qBAAqB,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;EACR,CAAC,CAAC;EAEFf,EAAE,CAA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,CAAC;EACR,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,156 @@
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 { beforeEach, describe, expect, it } from "vitest";
18
+ import { defineObject } from "../defineObject.js";
19
+ import { defineOntology, dumpOntologyFullMetadata, dumpValueTypeWireType } from "../defineOntology.js";
20
+ import { defineValueType } from "../defineValueType.js";
21
+ describe("Value Types", () => {
22
+ beforeEach(async () => {
23
+ await defineOntology("com.palantir.", () => {}, "/tmp/");
24
+ });
25
+ it("Fails to define value type with incorrect semver", () => {
26
+ expect(() => defineValueType({
27
+ apiName: "apiName",
28
+ displayName: "displayName",
29
+ type: {
30
+ "type": "boolean",
31
+ constraints: [{
32
+ constraint: {
33
+ "allowedValues": ["TRUE_VALUE"]
34
+ }
35
+ }]
36
+ },
37
+ version: "not a version"
38
+ })).toThrowErrorMatchingInlineSnapshot("[Error: Invariant failed: Version is not a valid semver]");
39
+ });
40
+ it("Tests convertProperty function with valueType constraints for string", () => {
41
+ const testStringValueType = defineValueType({
42
+ apiName: "stringWithConstraints",
43
+ displayName: "String With Constraints",
44
+ description: "A string type with additional constraints",
45
+ type: {
46
+ "type": "string",
47
+ constraints: [{
48
+ constraint: {
49
+ type: "length",
50
+ length: {
51
+ minSize: 5,
52
+ maxSize: 20
53
+ }
54
+ },
55
+ failureMessage: {
56
+ message: "String must be between 5 and 20 characters"
57
+ }
58
+ }]
59
+ },
60
+ version: "1.0.0"
61
+ });
62
+ defineObject({
63
+ titlePropertyApiName: "constrainedString",
64
+ displayName: "Test Object",
65
+ pluralDisplayName: "Test Objects",
66
+ apiName: "testObject",
67
+ primaryKeyPropertyApiName: "constrainedString",
68
+ properties: {
69
+ "constrainedString": {
70
+ type: "string",
71
+ displayName: "Constrained String",
72
+ valueType: testStringValueType
73
+ }
74
+ }
75
+ });
76
+ const ontology = dumpOntologyFullMetadata();
77
+ const objectPropertyType = ontology.ontology.objectTypes["com.palantir.testObject"].objectType.propertyTypes["constrainedString"];
78
+ expect(objectPropertyType.valueType).toEqual({
79
+ apiName: "stringWithConstraints",
80
+ version: "1.0.0",
81
+ packageNamespace: "com.palantir",
82
+ displayMetadata: {
83
+ displayName: "String With Constraints",
84
+ description: "A string type with additional constraints"
85
+ }
86
+ });
87
+ expect(objectPropertyType.dataConstraints).toBeDefined();
88
+ expect(objectPropertyType.dataConstraints?.propertyTypeConstraints).toHaveLength(1);
89
+ const constraintWrapper = objectPropertyType.dataConstraints?.propertyTypeConstraints[0];
90
+ expect(constraintWrapper?.constraints?.type).toBe("string");
91
+ expect((constraintWrapper?.constraints).string.length.minSize).toBe(5);
92
+ expect((constraintWrapper?.constraints).string.length.maxSize).toBe(20);
93
+ expect(constraintWrapper?.failureMessage?.message).toBe("String must be between 5 and 20 characters");
94
+ });
95
+ it("Correctly serializes a value type", () => {
96
+ defineValueType({
97
+ apiName: "apiName",
98
+ displayName: "displayName",
99
+ type: {
100
+ "type": "boolean",
101
+ constraints: [{
102
+ constraint: {
103
+ "allowedValues": ["TRUE_VALUE"]
104
+ }
105
+ }]
106
+ },
107
+ version: "0.1.0"
108
+ });
109
+ expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`
110
+ {
111
+ "valueTypes": [
112
+ {
113
+ "metadata": {
114
+ "apiName": "apiName",
115
+ "displayMetadata": {
116
+ "description": "",
117
+ "displayName": "displayName",
118
+ },
119
+ "packageNamespace": "com.palantir",
120
+ "status": {
121
+ "active": {},
122
+ "type": "active",
123
+ },
124
+ },
125
+ "versions": [
126
+ {
127
+ "baseType": {
128
+ "boolean": {},
129
+ "type": "boolean",
130
+ },
131
+ "constraints": [
132
+ {
133
+ "constraint": {
134
+ "constraint": {
135
+ "boolean": {
136
+ "allowedValues": [
137
+ "TRUE_VALUE",
138
+ ],
139
+ },
140
+ "type": "boolean",
141
+ },
142
+ "failureMessage": undefined,
143
+ },
144
+ },
145
+ ],
146
+ "exampleValues": [],
147
+ "version": "0.1.0",
148
+ },
149
+ ],
150
+ },
151
+ ],
152
+ }
153
+ `);
154
+ });
155
+ });
156
+ //# sourceMappingURL=valueTypes.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueTypes.test.js","names":["beforeEach","describe","expect","it","defineObject","defineOntology","dumpOntologyFullMetadata","dumpValueTypeWireType","defineValueType","apiName","displayName","type","constraints","constraint","version","toThrowErrorMatchingInlineSnapshot","testStringValueType","description","length","minSize","maxSize","failureMessage","message","titlePropertyApiName","pluralDisplayName","primaryKeyPropertyApiName","properties","valueType","ontology","objectPropertyType","objectTypes","objectType","propertyTypes","toEqual","packageNamespace","displayMetadata","dataConstraints","toBeDefined","propertyTypeConstraints","toHaveLength","constraintWrapper","toBe","string","toMatchInlineSnapshot"],"sources":["valueTypes.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 { beforeEach, describe, expect, it } from \"vitest\";\nimport { defineObject } from \"../defineObject.js\";\nimport {\n defineOntology,\n dumpOntologyFullMetadata,\n dumpValueTypeWireType,\n} from \"../defineOntology.js\";\nimport { defineValueType } from \"../defineValueType.js\";\n\ndescribe(\"Value Types\", () => {\n beforeEach(async () => {\n await defineOntology(\"com.palantir.\", () => {}, \"/tmp/\");\n });\n\n it(\"Fails to define value type with incorrect semver\", () => {\n expect(() =>\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n type: {\n \"type\": \"boolean\",\n constraints: [{ constraint: { \"allowedValues\": [\"TRUE_VALUE\"] } }],\n },\n version: \"not a version\",\n })\n ).toThrowErrorMatchingInlineSnapshot(\n \"[Error: Invariant failed: Version is not a valid semver]\",\n );\n });\n\n it(\"Tests convertProperty function with valueType constraints for string\", () => {\n const testStringValueType = defineValueType({\n apiName: \"stringWithConstraints\",\n displayName: \"String With Constraints\",\n description: \"A string type with additional constraints\",\n type: {\n \"type\": \"string\",\n constraints: [\n {\n constraint: {\n type: \"length\",\n length: {\n minSize: 5,\n maxSize: 20,\n },\n },\n failureMessage: {\n message: \"String must be between 5 and 20 characters\",\n },\n },\n ],\n },\n version: \"1.0.0\",\n });\n\n const object = defineObject({\n titlePropertyApiName: \"constrainedString\",\n displayName: \"Test Object\",\n pluralDisplayName: \"Test Objects\",\n apiName: \"testObject\",\n primaryKeyPropertyApiName: \"constrainedString\",\n properties: {\n \"constrainedString\": {\n type: \"string\",\n displayName: \"Constrained String\",\n valueType: testStringValueType,\n },\n },\n });\n\n const ontology = dumpOntologyFullMetadata();\n const objectPropertyType =\n ontology.ontology.objectTypes[\"com.palantir.testObject\"]\n .objectType.propertyTypes[\"constrainedString\"];\n\n expect(objectPropertyType.valueType).toEqual({\n apiName: \"stringWithConstraints\",\n version: \"1.0.0\",\n packageNamespace: \"com.palantir\",\n displayMetadata: {\n displayName: \"String With Constraints\",\n description: \"A string type with additional constraints\",\n },\n });\n\n expect(objectPropertyType.dataConstraints).toBeDefined();\n expect(objectPropertyType.dataConstraints?.propertyTypeConstraints)\n .toHaveLength(1);\n\n const constraintWrapper = objectPropertyType.dataConstraints\n ?.propertyTypeConstraints[0];\n expect(constraintWrapper?.constraints?.type).toBe(\"string\");\n expect(\n (constraintWrapper?.constraints as {\n type: \"string\";\n string: { length: { minSize: number; maxSize: number } };\n }).string.length.minSize,\n ).toBe(5);\n expect(\n (constraintWrapper?.constraints as {\n type: \"string\";\n string: { length: { minSize: number; maxSize: number } };\n }).string.length.maxSize,\n ).toBe(20);\n expect(constraintWrapper?.failureMessage?.message).toBe(\n \"String must be between 5 and 20 characters\",\n );\n });\n\n it(\"Correctly serializes a value type\", () => {\n defineValueType({\n apiName: \"apiName\",\n displayName: \"displayName\",\n type: {\n \"type\": \"boolean\",\n constraints: [{ constraint: { \"allowedValues\": [\"TRUE_VALUE\"] } }],\n },\n version: \"0.1.0\",\n });\n expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`\n {\n \"valueTypes\": [\n {\n \"metadata\": {\n \"apiName\": \"apiName\",\n \"displayMetadata\": {\n \"description\": \"\",\n \"displayName\": \"displayName\",\n },\n \"packageNamespace\": \"com.palantir\",\n \"status\": {\n \"active\": {},\n \"type\": \"active\",\n },\n },\n \"versions\": [\n {\n \"baseType\": {\n \"boolean\": {},\n \"type\": \"boolean\",\n },\n \"constraints\": [\n {\n \"constraint\": {\n \"constraint\": {\n \"boolean\": {\n \"allowedValues\": [\n \"TRUE_VALUE\",\n ],\n },\n \"type\": \"boolean\",\n },\n \"failureMessage\": undefined,\n },\n },\n ],\n \"exampleValues\": [],\n \"version\": \"0.1.0\",\n },\n ],\n },\n ],\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SACEC,cAAc,EACdC,wBAAwB,EACxBC,qBAAqB,QAChB,sBAAsB;AAC7B,SAASC,eAAe,QAAQ,uBAAuB;AAEvDP,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC5BD,UAAU,CAAC,YAAY;IACrB,MAAMK,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC;EAC1D,CAAC,CAAC;EAEFF,EAAE,CAAC,kDAAkD,EAAE,MAAM;IAC3DD,MAAM,CAAC,MACLM,eAAe,CAAC;MACdC,OAAO,EAAE,SAAS;MAClBC,WAAW,EAAE,aAAa;MAC1BC,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS;QACjBC,WAAW,EAAE,CAAC;UAAEC,UAAU,EAAE;YAAE,eAAe,EAAE,CAAC,YAAY;UAAE;QAAE,CAAC;MACnE,CAAC;MACDC,OAAO,EAAE;IACX,CAAC,CACH,CAAC,CAACC,kCAAkC,CAClC,0DACF,CAAC;EACH,CAAC,CAAC;EAEFZ,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC/E,MAAMa,mBAAmB,GAAGR,eAAe,CAAC;MAC1CC,OAAO,EAAE,uBAAuB;MAChCC,WAAW,EAAE,yBAAyB;MACtCO,WAAW,EAAE,2CAA2C;MACxDN,IAAI,EAAE;QACJ,MAAM,EAAE,QAAQ;QACh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