@party-stack/foundry-ontology 0.18.0 → 0.18.1

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 (253) hide show
  1. package/lib/adapter/convertLoadSubsetOptions.d.ts +2 -0
  2. package/lib/adapter/convertLoadSubsetOptions.d.ts.map +1 -1
  3. package/lib/adapter/convertLoadSubsetOptions.js +158 -191
  4. package/lib/adapter/convertLoadSubsetOptions.js.map +1 -1
  5. package/lib/adapter/createFoundryOntologyBackendAdapter.d.ts +17 -15
  6. package/lib/adapter/createFoundryOntologyBackendAdapter.d.ts.map +1 -1
  7. package/lib/adapter/createFoundryOntologyBackendAdapter.js +288 -400
  8. package/lib/adapter/createFoundryOntologyBackendAdapter.js.map +1 -1
  9. package/lib/adapter/foundryActionValidation.d.ts +17 -15
  10. package/lib/adapter/foundryActionValidation.d.ts.map +1 -1
  11. package/lib/adapter/foundryActionValidation.js +206 -305
  12. package/lib/adapter/foundryActionValidation.js.map +1 -1
  13. package/lib/adapter/foundryCodec.d.ts +10 -9
  14. package/lib/adapter/foundryCodec.d.ts.map +1 -1
  15. package/lib/adapter/foundryCodec.js +180 -287
  16. package/lib/adapter/foundryCodec.js.map +1 -1
  17. package/lib/adapter/foundryMediaId.d.ts +6 -4
  18. package/lib/adapter/foundryMediaId.d.ts.map +1 -1
  19. package/lib/adapter/foundryMediaId.js +31 -32
  20. package/lib/adapter/foundryMediaId.js.map +1 -1
  21. package/lib/adapter/index.d.ts +4 -4
  22. package/lib/adapter/index.js +4 -4
  23. package/lib/adapter/objectCollectionOptions.d.ts +17 -18
  24. package/lib/adapter/objectCollectionOptions.d.ts.map +1 -1
  25. package/lib/adapter/objectCollectionOptions.js +417 -538
  26. package/lib/adapter/objectCollectionOptions.js.map +1 -1
  27. package/lib/config/applyAttachmentConstraintOverrides.d.ts +6 -4
  28. package/lib/config/applyAttachmentConstraintOverrides.d.ts.map +1 -1
  29. package/lib/config/applyAttachmentConstraintOverrides.js +45 -49
  30. package/lib/config/applyAttachmentConstraintOverrides.js.map +1 -1
  31. package/lib/config/index.d.ts +17 -15
  32. package/lib/config/index.d.ts.map +1 -1
  33. package/lib/config/index.js +56 -81
  34. package/lib/config/index.js.map +1 -1
  35. package/lib/connection.d.ts +28 -26
  36. package/lib/connection.d.ts.map +1 -1
  37. package/lib/connection.js +183 -215
  38. package/lib/connection.js.map +1 -1
  39. package/lib/index.d.ts +9 -5
  40. package/lib/index.js +9 -5
  41. package/lib/installation/createFoundryBackendInstallation.d.ts +21 -20
  42. package/lib/installation/createFoundryBackendInstallation.d.ts.map +1 -1
  43. package/lib/installation/createFoundryBackendInstallation.js +52 -62
  44. package/lib/installation/createFoundryBackendInstallation.js.map +1 -1
  45. package/lib/installation/index.d.ts +2 -2
  46. package/lib/installation/index.js +2 -2
  47. package/lib/meta/actionTypeCollectionOptions.d.ts +8 -6
  48. package/lib/meta/actionTypeCollectionOptions.d.ts.map +1 -1
  49. package/lib/meta/actionTypeCollectionOptions.js +49 -49
  50. package/lib/meta/actionTypeCollectionOptions.js.map +1 -1
  51. package/lib/meta/convertActionTypeLoadSubsetOptions.d.ts +3 -1
  52. package/lib/meta/convertActionTypeLoadSubsetOptions.d.ts.map +1 -1
  53. package/lib/meta/convertActionTypeLoadSubsetOptions.js +69 -75
  54. package/lib/meta/convertActionTypeLoadSubsetOptions.js.map +1 -1
  55. package/lib/meta/convertMetaActionType.d.ts +7 -5
  56. package/lib/meta/convertMetaActionType.d.ts.map +1 -1
  57. package/lib/meta/convertMetaActionType.js +458 -581
  58. package/lib/meta/convertMetaActionType.js.map +1 -1
  59. package/lib/meta/convertMetaLinkType.d.ts +4 -2
  60. package/lib/meta/convertMetaLinkType.d.ts.map +1 -1
  61. package/lib/meta/convertMetaLinkType.js +37 -43
  62. package/lib/meta/convertMetaLinkType.js.map +1 -1
  63. package/lib/meta/convertMetaObjectType.d.ts +4 -2
  64. package/lib/meta/convertMetaObjectType.d.ts.map +1 -1
  65. package/lib/meta/convertMetaObjectType.js +34 -35
  66. package/lib/meta/convertMetaObjectType.js.map +1 -1
  67. package/lib/meta/convertMetaQueryFunctionType.d.ts +4 -2
  68. package/lib/meta/convertMetaQueryFunctionType.d.ts.map +1 -1
  69. package/lib/meta/convertMetaQueryFunctionType.js +113 -94
  70. package/lib/meta/convertMetaQueryFunctionType.js.map +1 -1
  71. package/lib/meta/convertMetaTypeDef.d.ts +4 -2
  72. package/lib/meta/convertMetaTypeDef.d.ts.map +1 -1
  73. package/lib/meta/convertMetaTypeDef.js +178 -176
  74. package/lib/meta/convertMetaTypeDef.js.map +1 -1
  75. package/lib/meta/convertMetaValueType.d.ts +4 -2
  76. package/lib/meta/convertMetaValueType.d.ts.map +1 -1
  77. package/lib/meta/convertMetaValueType.js +11 -7
  78. package/lib/meta/convertMetaValueType.js.map +1 -1
  79. package/lib/meta/convertOmsActionParameterMetadata.d.ts +4 -2
  80. package/lib/meta/convertOmsActionParameterMetadata.d.ts.map +1 -1
  81. package/lib/meta/convertOmsActionParameterMetadata.js +107 -163
  82. package/lib/meta/convertOmsActionParameterMetadata.js.map +1 -1
  83. package/lib/meta/createFoundryMetaOntologyBackendAdapter.d.ts +7 -5
  84. package/lib/meta/createFoundryMetaOntologyBackendAdapter.d.ts.map +1 -1
  85. package/lib/meta/createFoundryMetaOntologyBackendAdapter.js +39 -41
  86. package/lib/meta/createFoundryMetaOntologyBackendAdapter.js.map +1 -1
  87. package/lib/meta/entityCollectionOptions.d.ts +12 -11
  88. package/lib/meta/entityCollectionOptions.d.ts.map +1 -1
  89. package/lib/meta/entityCollectionOptions.js +59 -62
  90. package/lib/meta/entityCollectionOptions.js.map +1 -1
  91. package/lib/meta/foundryAttachmentMetadata.d.ts +2 -0
  92. package/lib/meta/foundryAttachmentMetadata.d.ts.map +1 -1
  93. package/lib/meta/foundryAttachmentMetadata.js +13 -14
  94. package/lib/meta/foundryAttachmentMetadata.js.map +1 -1
  95. package/lib/meta/index.d.ts +5 -5
  96. package/lib/meta/index.js +5 -5
  97. package/lib/meta/loadActionTypeOmsMetadata.d.ts +5 -4
  98. package/lib/meta/loadActionTypeOmsMetadata.d.ts.map +1 -1
  99. package/lib/meta/loadActionTypeOmsMetadata.js +102 -139
  100. package/lib/meta/loadActionTypeOmsMetadata.js.map +1 -1
  101. package/lib/meta/queryFunctionTypeCollectionOptions.d.ts +7 -5
  102. package/lib/meta/queryFunctionTypeCollectionOptions.d.ts.map +1 -1
  103. package/lib/meta/queryFunctionTypeCollectionOptions.js +47 -49
  104. package/lib/meta/queryFunctionTypeCollectionOptions.js.map +1 -1
  105. package/lib/stagedWrites.d.ts +26 -24
  106. package/lib/stagedWrites.d.ts.map +1 -1
  107. package/lib/stagedWrites.js +55 -66
  108. package/lib/stagedWrites.js.map +1 -1
  109. package/lib/users/createFoundryAdminOntologyRoute.d.ts +47 -17366
  110. package/lib/users/createFoundryAdminOntologyRoute.d.ts.map +1 -1
  111. package/lib/users/createFoundryAdminOntologyRoute.js +29 -37
  112. package/lib/users/createFoundryAdminOntologyRoute.js.map +1 -1
  113. package/lib/users/createFoundryUsersIntegration.d.ts +6 -4
  114. package/lib/users/createFoundryUsersIntegration.d.ts.map +1 -1
  115. package/lib/users/createFoundryUsersIntegration.js +28 -30
  116. package/lib/users/createFoundryUsersIntegration.js.map +1 -1
  117. package/lib/users/foundryUser.d.ts +4 -2
  118. package/lib/users/foundryUser.d.ts.map +1 -1
  119. package/lib/users/foundryUser.js +69 -74
  120. package/lib/users/foundryUser.js.map +1 -1
  121. package/lib/users/index.d.ts +5 -5
  122. package/lib/users/index.js +5 -5
  123. package/lib/users/userCollectionOptions.d.ts +13 -12
  124. package/lib/users/userCollectionOptions.d.ts.map +1 -1
  125. package/lib/users/userCollectionOptions.js +82 -100
  126. package/lib/users/userCollectionOptions.js.map +1 -1
  127. package/lib/utils/AsyncIterable.d.ts +2 -0
  128. package/lib/utils/AsyncIterable.d.ts.map +1 -1
  129. package/lib/utils/AsyncIterable.js +26 -34
  130. package/lib/utils/AsyncIterable.js.map +1 -1
  131. package/lib/utils/actionTypeName.d.ts +2 -0
  132. package/lib/utils/actionTypeName.d.ts.map +1 -1
  133. package/lib/utils/actionTypeName.js +9 -7
  134. package/lib/utils/actionTypeName.js.map +1 -1
  135. package/lib/utils/chunk.d.ts +2 -0
  136. package/lib/utils/chunk.d.ts.map +1 -1
  137. package/lib/utils/chunk.js +8 -6
  138. package/lib/utils/chunk.js.map +1 -1
  139. package/package.json +17 -23
  140. package/lib/adapter/convertLoadSubsetOptions.test.d.ts +0 -2
  141. package/lib/adapter/convertLoadSubsetOptions.test.d.ts.map +0 -1
  142. package/lib/adapter/convertLoadSubsetOptions.test.js +0 -213
  143. package/lib/adapter/convertLoadSubsetOptions.test.js.map +0 -1
  144. package/lib/adapter/createFoundryOntologyBackendAdapter.test.d.ts +0 -2
  145. package/lib/adapter/createFoundryOntologyBackendAdapter.test.d.ts.map +0 -1
  146. package/lib/adapter/createFoundryOntologyBackendAdapter.test.js +0 -628
  147. package/lib/adapter/createFoundryOntologyBackendAdapter.test.js.map +0 -1
  148. package/lib/adapter/foundryActionValidation.test.d.ts +0 -2
  149. package/lib/adapter/foundryActionValidation.test.d.ts.map +0 -1
  150. package/lib/adapter/foundryActionValidation.test.js +0 -243
  151. package/lib/adapter/foundryActionValidation.test.js.map +0 -1
  152. package/lib/adapter/foundryCodec.test.d.ts +0 -2
  153. package/lib/adapter/foundryCodec.test.d.ts.map +0 -1
  154. package/lib/adapter/foundryCodec.test.js +0 -137
  155. package/lib/adapter/foundryCodec.test.js.map +0 -1
  156. package/lib/adapter/foundryMediaId.test.d.ts +0 -2
  157. package/lib/adapter/foundryMediaId.test.d.ts.map +0 -1
  158. package/lib/adapter/foundryMediaId.test.js +0 -23
  159. package/lib/adapter/foundryMediaId.test.js.map +0 -1
  160. package/lib/adapter/index.d.ts.map +0 -1
  161. package/lib/adapter/index.js.map +0 -1
  162. package/lib/adapter/objectCollectionOptions.test.d.ts +0 -2
  163. package/lib/adapter/objectCollectionOptions.test.d.ts.map +0 -1
  164. package/lib/adapter/objectCollectionOptions.test.js +0 -1290
  165. package/lib/adapter/objectCollectionOptions.test.js.map +0 -1
  166. package/lib/config/connectionPull.test.d.ts +0 -2
  167. package/lib/config/connectionPull.test.d.ts.map +0 -1
  168. package/lib/config/connectionPull.test.js +0 -151
  169. package/lib/config/connectionPull.test.js.map +0 -1
  170. package/lib/config/index.test.d.ts +0 -2
  171. package/lib/config/index.test.d.ts.map +0 -1
  172. package/lib/config/index.test.js +0 -182
  173. package/lib/config/index.test.js.map +0 -1
  174. package/lib/connection.test.d.ts +0 -2
  175. package/lib/connection.test.d.ts.map +0 -1
  176. package/lib/connection.test.js +0 -162
  177. package/lib/connection.test.js.map +0 -1
  178. package/lib/index.d.ts.map +0 -1
  179. package/lib/index.js.map +0 -1
  180. package/lib/installation/createFoundryBackendInstallation.test.d.ts +0 -2
  181. package/lib/installation/createFoundryBackendInstallation.test.d.ts.map +0 -1
  182. package/lib/installation/createFoundryBackendInstallation.test.js +0 -83
  183. package/lib/installation/createFoundryBackendInstallation.test.js.map +0 -1
  184. package/lib/installation/index.d.ts.map +0 -1
  185. package/lib/installation/index.js.map +0 -1
  186. package/lib/meta/actionTypeCollectionOptions.test.d.ts +0 -2
  187. package/lib/meta/actionTypeCollectionOptions.test.d.ts.map +0 -1
  188. package/lib/meta/actionTypeCollectionOptions.test.js +0 -24
  189. package/lib/meta/actionTypeCollectionOptions.test.js.map +0 -1
  190. package/lib/meta/actionTypeIdQuery.test.d.ts +0 -2
  191. package/lib/meta/actionTypeIdQuery.test.d.ts.map +0 -1
  192. package/lib/meta/actionTypeIdQuery.test.js +0 -131
  193. package/lib/meta/actionTypeIdQuery.test.js.map +0 -1
  194. package/lib/meta/convertActionTypeLoadSubsetOptions.test.d.ts +0 -2
  195. package/lib/meta/convertActionTypeLoadSubsetOptions.test.d.ts.map +0 -1
  196. package/lib/meta/convertActionTypeLoadSubsetOptions.test.js +0 -138
  197. package/lib/meta/convertActionTypeLoadSubsetOptions.test.js.map +0 -1
  198. package/lib/meta/convertMetaActionType.test.d.ts +0 -2
  199. package/lib/meta/convertMetaActionType.test.d.ts.map +0 -1
  200. package/lib/meta/convertMetaActionType.test.js +0 -1565
  201. package/lib/meta/convertMetaActionType.test.js.map +0 -1
  202. package/lib/meta/convertMetaLinkType.test.d.ts +0 -2
  203. package/lib/meta/convertMetaLinkType.test.d.ts.map +0 -1
  204. package/lib/meta/convertMetaLinkType.test.js +0 -110
  205. package/lib/meta/convertMetaLinkType.test.js.map +0 -1
  206. package/lib/meta/convertMetaObjectType.test.d.ts +0 -2
  207. package/lib/meta/convertMetaObjectType.test.d.ts.map +0 -1
  208. package/lib/meta/convertMetaObjectType.test.js +0 -250
  209. package/lib/meta/convertMetaObjectType.test.js.map +0 -1
  210. package/lib/meta/convertMetaQueryFunctionType.test.d.ts +0 -2
  211. package/lib/meta/convertMetaQueryFunctionType.test.d.ts.map +0 -1
  212. package/lib/meta/convertMetaQueryFunctionType.test.js +0 -134
  213. package/lib/meta/convertMetaQueryFunctionType.test.js.map +0 -1
  214. package/lib/meta/createFoundryMetaOntologyBackendAdapter.test.d.ts +0 -2
  215. package/lib/meta/createFoundryMetaOntologyBackendAdapter.test.d.ts.map +0 -1
  216. package/lib/meta/createFoundryMetaOntologyBackendAdapter.test.js +0 -49
  217. package/lib/meta/createFoundryMetaOntologyBackendAdapter.test.js.map +0 -1
  218. package/lib/meta/entityCollectionOptions.test.d.ts +0 -2
  219. package/lib/meta/entityCollectionOptions.test.d.ts.map +0 -1
  220. package/lib/meta/entityCollectionOptions.test.js +0 -98
  221. package/lib/meta/entityCollectionOptions.test.js.map +0 -1
  222. package/lib/meta/index.d.ts.map +0 -1
  223. package/lib/meta/index.js.map +0 -1
  224. package/lib/meta/loadActionTypeOmsMetadata.test.d.ts +0 -2
  225. package/lib/meta/loadActionTypeOmsMetadata.test.d.ts.map +0 -1
  226. package/lib/meta/loadActionTypeOmsMetadata.test.js +0 -218
  227. package/lib/meta/loadActionTypeOmsMetadata.test.js.map +0 -1
  228. package/lib/stagedWrites.test.d.ts +0 -2
  229. package/lib/stagedWrites.test.d.ts.map +0 -1
  230. package/lib/stagedWrites.test.js +0 -71
  231. package/lib/stagedWrites.test.js.map +0 -1
  232. package/lib/users/createFoundryUsersIntegration.test.d.ts +0 -2
  233. package/lib/users/createFoundryUsersIntegration.test.d.ts.map +0 -1
  234. package/lib/users/createFoundryUsersIntegration.test.js +0 -32
  235. package/lib/users/createFoundryUsersIntegration.test.js.map +0 -1
  236. package/lib/users/foundryUser.test.d.ts +0 -2
  237. package/lib/users/foundryUser.test.d.ts.map +0 -1
  238. package/lib/users/foundryUser.test.js +0 -45
  239. package/lib/users/foundryUser.test.js.map +0 -1
  240. package/lib/users/index.d.ts.map +0 -1
  241. package/lib/users/index.js.map +0 -1
  242. package/lib/users/userCollectionOptions.test.d.ts +0 -2
  243. package/lib/users/userCollectionOptions.test.d.ts.map +0 -1
  244. package/lib/users/userCollectionOptions.test.js +0 -18
  245. package/lib/users/userCollectionOptions.test.js.map +0 -1
  246. package/lib/utils/AsyncIterable.test.d.ts +0 -2
  247. package/lib/utils/AsyncIterable.test.d.ts.map +0 -1
  248. package/lib/utils/AsyncIterable.test.js +0 -17
  249. package/lib/utils/AsyncIterable.test.js.map +0 -1
  250. package/lib/utils/actionTypeName.test.d.ts +0 -2
  251. package/lib/utils/actionTypeName.test.d.ts.map +0 -1
  252. package/lib/utils/actionTypeName.test.js +0 -30
  253. package/lib/utils/actionTypeName.test.js.map +0 -1
@@ -1,653 +1,530 @@
1
- import { fromBlueprintIconName } from "@party-stack/icons-blueprint";
2
- import { Temporal } from "temporal-polyfill";
3
1
  import { toOntologyActionTypeName } from "../utils/actionTypeName.js";
4
- import { convertOmsActionParameterDefaults, convertOmsActionParameterStringConstraint, convertOmsActionParameterStringSuggestions, } from "./convertOmsActionParameterMetadata.js";
2
+ import { convertOmsActionParameterDefaults, convertOmsActionParameterStringConstraint, convertOmsActionParameterStringSuggestions } from "./convertOmsActionParameterMetadata.js";
5
3
  import { foundryAttachmentMeta } from "./foundryAttachmentMetadata.js";
4
+ import { Temporal } from "temporal-polyfill";
5
+ import { fromBlueprintIconName } from "@party-stack/icons-blueprint";
6
+ //#region src/meta/convertMetaActionType.ts
6
7
  const FOUNDRY_CURRENT_USER_CONTEXT_PATH = ["user"];
7
8
  const FOUNDRY_UUID_PARAMETER_PREFIX = "__uuid_";
8
9
  const FOUNDRY_NOW_PARAMETER_NAME = "__now";
9
10
  const FOUNDRY_LIST_ITEM_BINDING = "item";
10
11
  function maybeOptional(type, required) {
11
- return required ? type : { kind: "optional", value: { type } };
12
+ return required ? type : {
13
+ kind: "optional",
14
+ value: { type }
15
+ };
12
16
  }
13
17
  function stringType(constraint, suggestions) {
14
- return {
15
- kind: "string",
16
- value: {
17
- constraint,
18
- suggestions,
19
- },
20
- };
18
+ return {
19
+ kind: "string",
20
+ value: {
21
+ constraint,
22
+ suggestions
23
+ }
24
+ };
21
25
  }
22
26
  function applyStringConstraintFallback(type, constraint) {
23
- if (!constraint)
24
- return type;
25
- switch (type.kind) {
26
- case "string":
27
- return type.value.constraint
28
- ? type
29
- : {
30
- ...type,
31
- value: {
32
- ...type.value,
33
- constraint,
34
- },
35
- };
36
- case "optional":
37
- return {
38
- ...type,
39
- value: {
40
- ...type.value,
41
- type: applyStringConstraintFallback(type.value.type, constraint),
42
- },
43
- };
44
- case "list":
45
- return {
46
- ...type,
47
- value: {
48
- ...type.value,
49
- elementType: applyStringConstraintFallback(type.value.elementType, constraint),
50
- },
51
- };
52
- default:
53
- return type;
54
- }
27
+ if (!constraint) return type;
28
+ switch (type.kind) {
29
+ case "string": return type.value.constraint ? type : {
30
+ ...type,
31
+ value: {
32
+ ...type.value,
33
+ constraint
34
+ }
35
+ };
36
+ case "optional": return {
37
+ ...type,
38
+ value: {
39
+ ...type.value,
40
+ type: applyStringConstraintFallback(type.value.type, constraint)
41
+ }
42
+ };
43
+ case "list": return {
44
+ ...type,
45
+ value: {
46
+ ...type.value,
47
+ elementType: applyStringConstraintFallback(type.value.elementType, constraint)
48
+ }
49
+ };
50
+ default: return type;
51
+ }
55
52
  }
56
53
  function applyStringSuggestionsFallback(type, suggestions) {
57
- if (!suggestions)
58
- return type;
59
- switch (type.kind) {
60
- case "string":
61
- return type.value.suggestions
62
- ? type
63
- : {
64
- ...type,
65
- value: {
66
- ...type.value,
67
- suggestions,
68
- },
69
- };
70
- case "optional":
71
- return {
72
- ...type,
73
- value: {
74
- ...type.value,
75
- type: applyStringSuggestionsFallback(type.value.type, suggestions),
76
- },
77
- };
78
- case "list":
79
- return {
80
- ...type,
81
- value: {
82
- ...type.value,
83
- elementType: applyStringSuggestionsFallback(type.value.elementType, suggestions),
84
- },
85
- };
86
- default:
87
- return type;
88
- }
54
+ if (!suggestions) return type;
55
+ switch (type.kind) {
56
+ case "string": return type.value.suggestions ? type : {
57
+ ...type,
58
+ value: {
59
+ ...type.value,
60
+ suggestions
61
+ }
62
+ };
63
+ case "optional": return {
64
+ ...type,
65
+ value: {
66
+ ...type.value,
67
+ type: applyStringSuggestionsFallback(type.value.type, suggestions)
68
+ }
69
+ };
70
+ case "list": return {
71
+ ...type,
72
+ value: {
73
+ ...type.value,
74
+ elementType: applyStringSuggestionsFallback(type.value.elementType, suggestions)
75
+ }
76
+ };
77
+ default: return type;
78
+ }
89
79
  }
90
80
  function applyOmsStructFieldValidation(type, omsMetadata, parameterName) {
91
- if (!omsMetadata)
92
- return type;
93
- switch (type.kind) {
94
- case "optional":
95
- return {
96
- ...type,
97
- value: {
98
- ...type.value,
99
- type: applyOmsStructFieldValidation(type.value.type, omsMetadata, parameterName),
100
- },
101
- };
102
- case "list":
103
- return {
104
- ...type,
105
- value: {
106
- ...type.value,
107
- elementType: applyOmsStructFieldValidation(type.value.elementType, omsMetadata, parameterName),
108
- },
109
- };
110
- case "struct":
111
- return {
112
- ...type,
113
- value: {
114
- ...type.value,
115
- fields: type.value.fields.map((field) => ({
116
- ...field,
117
- type: applyStringSuggestionsFallback(applyStringConstraintFallback(field.type, convertOmsActionParameterStringConstraint(omsMetadata, parameterName, field.name)), convertOmsActionParameterStringSuggestions(omsMetadata, parameterName, field.name)),
118
- })),
119
- },
120
- };
121
- default:
122
- return type;
123
- }
81
+ if (!omsMetadata) return type;
82
+ switch (type.kind) {
83
+ case "optional": return {
84
+ ...type,
85
+ value: {
86
+ ...type.value,
87
+ type: applyOmsStructFieldValidation(type.value.type, omsMetadata, parameterName)
88
+ }
89
+ };
90
+ case "list": return {
91
+ ...type,
92
+ value: {
93
+ ...type.value,
94
+ elementType: applyOmsStructFieldValidation(type.value.elementType, omsMetadata, parameterName)
95
+ }
96
+ };
97
+ case "struct": return {
98
+ ...type,
99
+ value: {
100
+ ...type.value,
101
+ fields: type.value.fields.map((field) => ({
102
+ ...field,
103
+ type: applyStringSuggestionsFallback(applyStringConstraintFallback(field.type, convertOmsActionParameterStringConstraint(omsMetadata, parameterName, field.name)), convertOmsActionParameterStringSuggestions(omsMetadata, parameterName, field.name))
104
+ }))
105
+ }
106
+ };
107
+ default: return type;
108
+ }
124
109
  }
125
110
  function booleanType() {
126
- return { kind: "boolean", value: {} };
111
+ return {
112
+ kind: "boolean",
113
+ value: {}
114
+ };
127
115
  }
128
116
  function integerType() {
129
- return { kind: "integer", value: {} };
117
+ return {
118
+ kind: "integer",
119
+ value: {}
120
+ };
130
121
  }
131
122
  function floatType() {
132
- return { kind: "float", value: {} };
123
+ return {
124
+ kind: "float",
125
+ value: {}
126
+ };
133
127
  }
134
128
  function doubleType() {
135
- return { kind: "double", value: {} };
129
+ return {
130
+ kind: "double",
131
+ value: {}
132
+ };
136
133
  }
137
134
  function dateType() {
138
- return { kind: "date", value: {} };
135
+ return {
136
+ kind: "date",
137
+ value: {}
138
+ };
139
139
  }
140
140
  function timestampType() {
141
- return { kind: "timestamp", value: {} };
141
+ return {
142
+ kind: "timestamp",
143
+ value: {}
144
+ };
142
145
  }
143
146
  function geopointType() {
144
- return { kind: "geopoint", value: {} };
147
+ return {
148
+ kind: "geopoint",
149
+ value: {}
150
+ };
145
151
  }
146
152
  function attachmentType(type) {
147
- return {
148
- kind: "attachment",
149
- value: { meta: foundryAttachmentMeta(type) },
150
- };
153
+ return {
154
+ kind: "attachment",
155
+ value: { meta: foundryAttachmentMeta(type) }
156
+ };
151
157
  }
152
158
  function createUniqueIdentifierParameterName(linkId) {
153
- return `${FOUNDRY_UUID_PARAMETER_PREFIX}${encodeURIComponent(linkId)}`;
159
+ return `${FOUNDRY_UUID_PARAMETER_PREFIX}${encodeURIComponent(linkId)}`;
154
160
  }
155
161
  function getUniqueIdentifierLinkIdFromParameterName(parameterName) {
156
- if (!parameterName.startsWith(FOUNDRY_UUID_PARAMETER_PREFIX)) {
157
- return undefined;
158
- }
159
- return decodeURIComponent(parameterName.slice(FOUNDRY_UUID_PARAMETER_PREFIX.length));
162
+ if (!parameterName.startsWith(FOUNDRY_UUID_PARAMETER_PREFIX)) return;
163
+ return decodeURIComponent(parameterName.slice(7));
160
164
  }
161
165
  function convertActionParameterType(type, required = true, validation) {
162
- const allowedValues = validation?.defaultValidation.allowedValues;
163
- if (allowedValues?.type === "valueType") {
164
- return maybeOptional({
165
- kind: "ref",
166
- value: { name: allowedValues.apiName },
167
- }, required);
168
- }
169
- const baseType = (() => {
170
- switch (type.type) {
171
- case "string":
172
- // TODO: Convert Foundry "user input" parameters to a principal
173
- // reference once Ontologies V2 exposes that setting in action
174
- // metadata. It currently returns an unconstrained string.
175
- // https://valinor-enterprises.slack.com/archives/C08549X3VDM/p1787718253341589
176
- return stringType(convertActionParameterStringConstraint(validation), convertActionParameterStringSuggestions(validation));
177
- case "boolean":
178
- return booleanType();
179
- case "integer":
180
- case "long":
181
- return integerType();
182
- case "double":
183
- return doubleType();
184
- case "decimal":
185
- // Preserve the exact value until Party Stack has a decimal
186
- // type with explicit precision and scale.
187
- return stringType();
188
- case "date":
189
- return dateType();
190
- case "timestamp":
191
- return timestampType();
192
- case "attachment":
193
- return attachmentType("attachment");
194
- case "mediaReference":
195
- return attachmentType("media");
196
- case "geohash":
197
- return geopointType();
198
- case "geoshape":
199
- case "marking":
200
- return stringType();
201
- case "vector":
202
- return {
203
- kind: "list",
204
- value: { elementType: doubleType() },
205
- };
206
- case "array":
207
- return {
208
- kind: "list",
209
- value: { elementType: convertActionParameterType(type.subType) },
210
- };
211
- case "struct":
212
- return {
213
- kind: "struct",
214
- value: {
215
- fields: type.fields.map((field, index) => ({
216
- name: field.name ?? `field${index + 1}`,
217
- displayName: field.name ?? `Field ${index + 1}`,
218
- type: convertOntologyDataType(field.fieldType, field.required),
219
- })),
220
- },
221
- };
222
- case "object":
223
- return {
224
- kind: "objectReference",
225
- value: { objectType: type.objectTypeApiName },
226
- };
227
- case "objectType":
228
- case "interfaceObject":
229
- case "objectSet":
230
- case "scenarioReference":
231
- return stringType();
232
- default: {
233
- const unsupported = type;
234
- return unsupported;
235
- }
236
- }
237
- })();
238
- return maybeOptional(baseType, required);
166
+ const allowedValues = validation?.defaultValidation.allowedValues;
167
+ if (allowedValues?.type === "valueType") return maybeOptional({
168
+ kind: "ref",
169
+ value: { name: allowedValues.apiName }
170
+ }, required);
171
+ return maybeOptional((() => {
172
+ switch (type.type) {
173
+ case "string": return stringType(convertActionParameterStringConstraint(validation), convertActionParameterStringSuggestions(validation));
174
+ case "boolean": return booleanType();
175
+ case "integer":
176
+ case "long": return integerType();
177
+ case "double": return doubleType();
178
+ case "decimal": return stringType();
179
+ case "date": return dateType();
180
+ case "timestamp": return timestampType();
181
+ case "attachment": return attachmentType("attachment");
182
+ case "mediaReference": return attachmentType("media");
183
+ case "geohash": return geopointType();
184
+ case "geoshape":
185
+ case "marking": return stringType();
186
+ case "vector": return {
187
+ kind: "list",
188
+ value: { elementType: doubleType() }
189
+ };
190
+ case "array": return {
191
+ kind: "list",
192
+ value: { elementType: convertActionParameterType(type.subType) }
193
+ };
194
+ case "struct": return {
195
+ kind: "struct",
196
+ value: { fields: type.fields.map((field, index) => ({
197
+ name: field.name ?? `field${index + 1}`,
198
+ displayName: field.name ?? `Field ${index + 1}`,
199
+ type: convertOntologyDataType(field.fieldType, field.required)
200
+ })) }
201
+ };
202
+ case "object": return {
203
+ kind: "objectReference",
204
+ value: { objectType: type.objectTypeApiName }
205
+ };
206
+ case "objectType":
207
+ case "interfaceObject":
208
+ case "objectSet":
209
+ case "scenarioReference": return stringType();
210
+ default: return type;
211
+ }
212
+ })(), required);
239
213
  }
240
214
  function convertActionParameterStringConstraint(validation) {
241
- const allowedValues = validation?.defaultValidation.allowedValues;
242
- if (allowedValues?.type === "oneOf" && !allowedValues.otherValuesAllowed) {
243
- const options = allowedValues.options.flatMap((option) => {
244
- const value = option.value;
245
- return typeof value === "string" ? [{ value, label: option.displayName }] : [];
246
- });
247
- return options.length > 0
248
- ? {
249
- kind: "enum",
250
- value: { options },
251
- }
252
- : undefined;
253
- }
254
- if (allowedValues?.type === "text" && allowedValues.regex) {
255
- return {
256
- kind: "regex",
257
- value: { regex: allowedValues.regex },
258
- };
259
- }
260
- return undefined;
215
+ const allowedValues = validation?.defaultValidation.allowedValues;
216
+ if (allowedValues?.type === "oneOf" && !allowedValues.otherValuesAllowed) {
217
+ const options = allowedValues.options.flatMap((option) => {
218
+ const value = option.value;
219
+ return typeof value === "string" ? [{
220
+ value,
221
+ label: option.displayName
222
+ }] : [];
223
+ });
224
+ return options.length > 0 ? {
225
+ kind: "enum",
226
+ value: { options }
227
+ } : void 0;
228
+ }
229
+ if (allowedValues?.type === "text" && allowedValues.regex) return {
230
+ kind: "regex",
231
+ value: { regex: allowedValues.regex }
232
+ };
261
233
  }
262
234
  function convertActionParameterStringSuggestions(validation) {
263
- const allowedValues = validation?.defaultValidation.allowedValues;
264
- if (allowedValues?.type !== "oneOf" || !allowedValues.otherValuesAllowed) {
265
- return undefined;
266
- }
267
- const suggestions = allowedValues.options.flatMap((option) => {
268
- const value = option.value;
269
- return typeof value === "string"
270
- ? [
271
- {
272
- value,
273
- label: option.displayName,
274
- },
275
- ]
276
- : [];
277
- });
278
- return suggestions.length > 0 ? suggestions : undefined;
235
+ const allowedValues = validation?.defaultValidation.allowedValues;
236
+ if (allowedValues?.type !== "oneOf" || !allowedValues.otherValuesAllowed) return;
237
+ const suggestions = allowedValues.options.flatMap((option) => {
238
+ const value = option.value;
239
+ return typeof value === "string" ? [{
240
+ value,
241
+ label: option.displayName
242
+ }] : [];
243
+ });
244
+ return suggestions.length > 0 ? suggestions : void 0;
279
245
  }
280
246
  function convertOntologyDataType(type, required = true) {
281
- const baseType = (() => {
282
- switch (type.type) {
283
- case "string":
284
- return stringType();
285
- case "boolean":
286
- return booleanType();
287
- case "byte":
288
- case "short":
289
- case "integer":
290
- case "long":
291
- return integerType();
292
- case "float":
293
- return floatType();
294
- case "double":
295
- case "decimal":
296
- return doubleType();
297
- case "date":
298
- return dateType();
299
- case "timestamp":
300
- return timestampType();
301
- case "binary":
302
- return attachmentType("attachment");
303
- case "mediaReference":
304
- return attachmentType("media");
305
- case "array":
306
- case "set":
307
- return {
308
- kind: "list",
309
- value: { elementType: convertOntologyDataType(type.itemType) },
310
- };
311
- case "struct":
312
- return {
313
- kind: "struct",
314
- value: {
315
- fields: type.fields.map((field, index) => ({
316
- name: field.name ?? `field${index + 1}`,
317
- displayName: field.name ?? `Field ${index + 1}`,
318
- type: convertOntologyDataType(field.fieldType, field.required),
319
- })),
320
- },
321
- };
322
- case "object":
323
- return {
324
- kind: "objectReference",
325
- value: { objectType: type.objectTypeApiName },
326
- };
327
- default:
328
- return stringType();
329
- }
330
- })();
331
- return maybeOptional(baseType, required);
247
+ return maybeOptional((() => {
248
+ switch (type.type) {
249
+ case "string": return stringType();
250
+ case "boolean": return booleanType();
251
+ case "byte":
252
+ case "short":
253
+ case "integer":
254
+ case "long": return integerType();
255
+ case "float": return floatType();
256
+ case "double":
257
+ case "decimal": return doubleType();
258
+ case "date": return dateType();
259
+ case "timestamp": return timestampType();
260
+ case "binary": return attachmentType("attachment");
261
+ case "mediaReference": return attachmentType("media");
262
+ case "array":
263
+ case "set": return {
264
+ kind: "list",
265
+ value: { elementType: convertOntologyDataType(type.itemType) }
266
+ };
267
+ case "struct": return {
268
+ kind: "struct",
269
+ value: { fields: type.fields.map((field, index) => ({
270
+ name: field.name ?? `field${index + 1}`,
271
+ displayName: field.name ?? `Field ${index + 1}`,
272
+ type: convertOntologyDataType(field.fieldType, field.required)
273
+ })) }
274
+ };
275
+ case "object": return {
276
+ kind: "objectReference",
277
+ value: { objectType: type.objectTypeApiName }
278
+ };
279
+ default: return stringType();
280
+ }
281
+ })(), required);
332
282
  }
333
283
  function collectRuleArguments(rule) {
334
- switch (rule.type) {
335
- case "createObject":
336
- case "modifyObject":
337
- return [
338
- ...Object.values(rule.propertyArguments),
339
- ...Object.values(rule.structPropertyArguments).flatMap((fields) => Object.values(fields)),
340
- ];
341
- default:
342
- return [];
343
- }
284
+ switch (rule.type) {
285
+ case "createObject":
286
+ case "modifyObject": return [...Object.values(rule.propertyArguments), ...Object.values(rule.structPropertyArguments).flatMap((fields) => Object.values(fields))];
287
+ default: return [];
288
+ }
344
289
  }
345
290
  function collectMutationTargetParameterNames(rules) {
346
- const parameterNames = new Set();
347
- for (const rule of rules) {
348
- switch (rule.type) {
349
- case "modifyObject":
350
- parameterNames.add(rule.objectToModify);
351
- break;
352
- case "deleteObject":
353
- parameterNames.add(rule.objectToDelete);
354
- break;
355
- }
356
- }
357
- return parameterNames;
291
+ const parameterNames = /* @__PURE__ */ new Set();
292
+ for (const rule of rules) switch (rule.type) {
293
+ case "modifyObject":
294
+ parameterNames.add(rule.objectToModify);
295
+ break;
296
+ case "deleteObject": parameterNames.add(rule.objectToDelete);
297
+ }
298
+ return parameterNames;
358
299
  }
359
300
  function requireObjectReferenceMutationTarget(type, isMutationTarget) {
360
- return isMutationTarget && type.kind === "optional" && type.value.type.kind === "objectReference"
361
- ? type.value.type
362
- : type;
301
+ return isMutationTarget && type.kind === "optional" && type.value.type.kind === "objectReference" ? type.value.type : type;
363
302
  }
364
303
  function createSyntheticParameters(actionType) {
365
- const uniqueIdentifierParametersByLinkId = new Map();
366
- let nowParameterName;
367
- for (const rule of actionType.fullLogicRules) {
368
- for (const argument of collectRuleArguments(rule)) {
369
- if (argument.type === "uniqueIdentifier" && argument.linkId) {
370
- if (!uniqueIdentifierParametersByLinkId.has(argument.linkId)) {
371
- uniqueIdentifierParametersByLinkId.set(argument.linkId, createUniqueIdentifierParameterName(argument.linkId));
372
- }
373
- }
374
- if (argument.type === "currentTime" && !nowParameterName) {
375
- nowParameterName = FOUNDRY_NOW_PARAMETER_NAME;
376
- }
377
- }
378
- }
379
- const parameters = Array.from(uniqueIdentifierParametersByLinkId.values()).map((name, index) => ({
380
- name,
381
- displayName: `Generated UUID ${index + 1}`,
382
- type: { kind: "string", value: {} },
383
- defaultValue: {
384
- kind: "uuid",
385
- value: {},
386
- },
387
- }));
388
- if (nowParameterName) {
389
- parameters.push({
390
- name: nowParameterName,
391
- displayName: "Current time",
392
- type: { kind: "timestamp", value: {} },
393
- defaultValue: {
394
- kind: "now",
395
- value: {},
396
- },
397
- });
398
- }
399
- return { parameters, uniqueIdentifierParametersByLinkId, nowParameterName };
400
- }
401
- export function getFoundryActionOverrideParameterMapping(actionType) {
402
- const uuidByParameterName = new Map();
403
- let nowParameterName;
404
- for (const parameter of actionType.parameters) {
405
- if (parameter.defaultValue?.kind !== "uuid" && parameter.defaultValue?.kind !== "now") {
406
- continue;
407
- }
408
- switch (parameter.defaultValue.kind) {
409
- case "uuid": {
410
- const linkId = getUniqueIdentifierLinkIdFromParameterName(parameter.name);
411
- if (linkId) {
412
- uuidByParameterName.set(parameter.name, linkId);
413
- }
414
- break;
415
- }
416
- case "now":
417
- nowParameterName ??= parameter.name;
418
- break;
419
- }
420
- }
421
- return { uuidByParameterName, nowParameterName };
304
+ const uniqueIdentifierParametersByLinkId = /* @__PURE__ */ new Map();
305
+ let nowParameterName;
306
+ for (const rule of actionType.fullLogicRules) for (const argument of collectRuleArguments(rule)) {
307
+ if (argument.type === "uniqueIdentifier" && argument.linkId) {
308
+ if (!uniqueIdentifierParametersByLinkId.has(argument.linkId)) uniqueIdentifierParametersByLinkId.set(argument.linkId, createUniqueIdentifierParameterName(argument.linkId));
309
+ }
310
+ if (argument.type === "currentTime" && !nowParameterName) nowParameterName = FOUNDRY_NOW_PARAMETER_NAME;
311
+ }
312
+ const parameters = Array.from(uniqueIdentifierParametersByLinkId.values()).map((name, index) => ({
313
+ name,
314
+ displayName: `Generated UUID ${index + 1}`,
315
+ type: {
316
+ kind: "string",
317
+ value: {}
318
+ },
319
+ defaultValue: {
320
+ kind: "uuid",
321
+ value: {}
322
+ }
323
+ }));
324
+ if (nowParameterName) parameters.push({
325
+ name: nowParameterName,
326
+ displayName: "Current time",
327
+ type: {
328
+ kind: "timestamp",
329
+ value: {}
330
+ },
331
+ defaultValue: {
332
+ kind: "now",
333
+ value: {}
334
+ }
335
+ });
336
+ return {
337
+ parameters,
338
+ uniqueIdentifierParametersByLinkId,
339
+ nowParameterName
340
+ };
341
+ }
342
+ function getFoundryActionOverrideParameterMapping(actionType) {
343
+ const uuidByParameterName = /* @__PURE__ */ new Map();
344
+ let nowParameterName;
345
+ for (const parameter of actionType.parameters) {
346
+ if (parameter.defaultValue?.kind !== "uuid" && parameter.defaultValue?.kind !== "now") continue;
347
+ switch (parameter.defaultValue.kind) {
348
+ case "uuid": {
349
+ const linkId = getUniqueIdentifierLinkIdFromParameterName(parameter.name);
350
+ if (linkId) uuidByParameterName.set(parameter.name, linkId);
351
+ break;
352
+ }
353
+ case "now": nowParameterName ??= parameter.name;
354
+ }
355
+ }
356
+ return {
357
+ uuidByParameterName,
358
+ nowParameterName
359
+ };
422
360
  }
423
361
  function inputReference(name) {
424
- return {
425
- kind: "inputReference",
426
- value: { name },
427
- };
362
+ return {
363
+ kind: "inputReference",
364
+ value: { name }
365
+ };
428
366
  }
429
367
  function getAtExpression(source, path) {
430
- return {
431
- kind: "getAt",
432
- value: { source, path },
433
- };
368
+ return {
369
+ kind: "getAt",
370
+ value: {
371
+ source,
372
+ path
373
+ }
374
+ };
434
375
  }
435
376
  function objectField(parameterName, path) {
436
- return getAtExpression({
437
- kind: "objectLookup",
438
- value: {
439
- reference: inputReference(parameterName),
440
- },
441
- }, path);
442
- }
443
- // TODO: This uses regex heuristics to infer the type of static literal values without
444
- // knowing the target property type. We should eventually resolve the target property's
445
- // TypeDef from the object type definition so we decode accurately instead of guessing
446
- // from the string format.
377
+ return getAtExpression({
378
+ kind: "objectLookup",
379
+ value: { reference: inputReference(parameterName) }
380
+ }, path);
381
+ }
447
382
  const ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
448
383
  const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
449
384
  const GEO_POINT_RE = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
450
385
  function decodeLiteralValue(value) {
451
- if (typeof value !== "string") {
452
- return value;
453
- }
454
- if (ISO_TIMESTAMP_RE.test(value)) {
455
- try {
456
- return Temporal.Instant.from(value);
457
- }
458
- catch {
459
- return value;
460
- }
461
- }
462
- if (ISO_DATE_RE.test(value)) {
463
- try {
464
- return Temporal.PlainDate.from(value);
465
- }
466
- catch {
467
- return value;
468
- }
469
- }
470
- const geoMatch = GEO_POINT_RE.exec(value);
471
- if (geoMatch) {
472
- return { lat: Number(geoMatch[1]), lon: Number(geoMatch[2]) };
473
- }
474
- return value;
386
+ if (typeof value !== "string") return value;
387
+ if (ISO_TIMESTAMP_RE.test(value)) try {
388
+ return Temporal.Instant.from(value);
389
+ } catch {
390
+ return value;
391
+ }
392
+ if (ISO_DATE_RE.test(value)) try {
393
+ return Temporal.PlainDate.from(value);
394
+ } catch {
395
+ return value;
396
+ }
397
+ const geoMatch = GEO_POINT_RE.exec(value);
398
+ if (geoMatch) return {
399
+ lat: Number(geoMatch[1]),
400
+ lon: Number(geoMatch[2])
401
+ };
402
+ return value;
475
403
  }
476
404
  function convertLogicRuleArgument(argument, syntheticParameters) {
477
- switch (argument.type) {
478
- case "parameterId":
479
- return inputReference(argument.parameterId);
480
- case "objectParameterPropertyValue":
481
- return objectField(argument.parameterId, [argument.propertyTypeApiName]);
482
- case "structParameterFieldValue":
483
- return getAtExpression(inputReference(argument.parameterId), [
484
- argument.structParameterFieldApiName,
485
- ]);
486
- case "structListParameterFieldValue":
487
- throw new Error("Foundry list-of-struct field arguments must be converted as a list mapping.");
488
- case "uniqueIdentifier": {
489
- const parameterName = argument.linkId
490
- ? syntheticParameters.uniqueIdentifierParametersByLinkId.get(argument.linkId)
491
- : undefined;
492
- return parameterName
493
- ? inputReference(parameterName)
494
- : {
495
- kind: "uuid",
496
- value: {},
497
- };
498
- }
499
- case "currentTime":
500
- return syntheticParameters.nowParameterName
501
- ? inputReference(syntheticParameters.nowParameterName)
502
- : {
503
- kind: "now",
504
- value: {},
505
- };
506
- case "staticValue":
507
- return {
508
- kind: "literal",
509
- value: { value: decodeLiteralValue(argument.value) },
510
- };
511
- case "currentUser":
512
- return {
513
- kind: "contextReference",
514
- value: { name: FOUNDRY_CURRENT_USER_CONTEXT_PATH[0] },
515
- };
516
- default:
517
- throw new Error(`Unsupported Foundry action argument "${argument.type}".`);
518
- }
405
+ switch (argument.type) {
406
+ case "parameterId": return inputReference(argument.parameterId);
407
+ case "objectParameterPropertyValue": return objectField(argument.parameterId, [argument.propertyTypeApiName]);
408
+ case "structParameterFieldValue": return getAtExpression(inputReference(argument.parameterId), [argument.structParameterFieldApiName]);
409
+ case "structListParameterFieldValue": throw new Error("Foundry list-of-struct field arguments must be converted as a list mapping.");
410
+ case "uniqueIdentifier": {
411
+ const parameterName = argument.linkId ? syntheticParameters.uniqueIdentifierParametersByLinkId.get(argument.linkId) : void 0;
412
+ return parameterName ? inputReference(parameterName) : {
413
+ kind: "uuid",
414
+ value: {}
415
+ };
416
+ }
417
+ case "currentTime": return syntheticParameters.nowParameterName ? inputReference(syntheticParameters.nowParameterName) : {
418
+ kind: "now",
419
+ value: {}
420
+ };
421
+ case "staticValue": return {
422
+ kind: "literal",
423
+ value: { value: decodeLiteralValue(argument.value) }
424
+ };
425
+ case "currentUser": return {
426
+ kind: "contextReference",
427
+ value: { name: FOUNDRY_CURRENT_USER_CONTEXT_PATH[0] }
428
+ };
429
+ default: throw new Error(`Unsupported Foundry action argument "${argument.type}".`);
430
+ }
519
431
  }
520
432
  function convertAssignments(rule, parameters, syntheticParameters) {
521
- return [
522
- ...Object.entries(rule.propertyArguments).map(([property, argument]) => ({
523
- property: [property],
524
- value: convertLogicRuleArgument(argument, syntheticParameters),
525
- })),
526
- ...Object.entries(rule.structPropertyArguments).flatMap(([property, fields]) => convertStructPropertyAssignments(property, fields, parameters, syntheticParameters)),
527
- ];
433
+ return [...Object.entries(rule.propertyArguments).map(([property, argument]) => ({
434
+ property: [property],
435
+ value: convertLogicRuleArgument(argument, syntheticParameters)
436
+ })), ...Object.entries(rule.structPropertyArguments).flatMap(([property, fields]) => convertStructPropertyAssignments(property, fields, parameters, syntheticParameters))];
528
437
  }
529
438
  function unsupportedListStructAssignment(property, reason) {
530
- throw new Error(`Unsupported Foundry list-of-struct assignment for property "${property}": ${reason}. ` +
531
- "Party Stack only supports mappings driven by one list-of-struct parameter.");
439
+ throw new Error(`Unsupported Foundry list-of-struct assignment for property "${property}": ${reason}. Party Stack only supports mappings driven by one list-of-struct parameter.`);
532
440
  }
533
441
  function convertStructPropertyAssignments(property, fields, parameters, syntheticParameters) {
534
- const entries = Object.entries(fields);
535
- const listEntries = entries.filter((entry) => entry[1].type === "structListParameterFieldValue");
536
- if (listEntries.length === 0) {
537
- return entries.map(([field, argument]) => ({
538
- property: [property, field],
539
- value: convertLogicRuleArgument(argument, syntheticParameters),
540
- }));
541
- }
542
- if (listEntries.length !== entries.length) {
543
- return unsupportedListStructAssignment(property, "list fields are mixed with non-list struct field arguments");
544
- }
545
- const parameterIds = new Set(listEntries.map(([, argument]) => argument.parameterId));
546
- if (parameterIds.size !== 1) {
547
- return unsupportedListStructAssignment(property, "fields are mapped from multiple list parameters");
548
- }
549
- const parameterId = listEntries[0][1].parameterId;
550
- const parameter = parameters[parameterId];
551
- if (parameter?.dataType.type !== "array" || parameter.dataType.subType.type !== "struct") {
552
- return unsupportedListStructAssignment(property, `source parameter "${parameterId}" is not a list of structs`);
553
- }
554
- return [
555
- {
556
- property: [property],
557
- value: {
558
- kind: "map",
559
- value: {
560
- source: inputReference(parameterId),
561
- binding: FOUNDRY_LIST_ITEM_BINDING,
562
- body: {
563
- kind: "struct",
564
- value: {
565
- fields: entries.map(([field, argument]) => ({
566
- name: field,
567
- value: argument.type === "structListParameterFieldValue"
568
- ? getAtExpression({
569
- kind: "localReference",
570
- value: {
571
- name: FOUNDRY_LIST_ITEM_BINDING,
572
- },
573
- }, [argument.structParameterFieldApiName])
574
- : convertLogicRuleArgument(argument, syntheticParameters),
575
- })),
576
- },
577
- },
578
- },
579
- },
580
- },
581
- ];
442
+ const entries = Object.entries(fields);
443
+ const listEntries = entries.filter((entry) => entry[1].type === "structListParameterFieldValue");
444
+ if (listEntries.length === 0) return entries.map(([field, argument]) => ({
445
+ property: [property, field],
446
+ value: convertLogicRuleArgument(argument, syntheticParameters)
447
+ }));
448
+ if (listEntries.length !== entries.length) return unsupportedListStructAssignment(property, "list fields are mixed with non-list struct field arguments");
449
+ if (new Set(listEntries.map(([, argument]) => argument.parameterId)).size !== 1) return unsupportedListStructAssignment(property, "fields are mapped from multiple list parameters");
450
+ const parameterId = listEntries[0][1].parameterId;
451
+ const parameter = parameters[parameterId];
452
+ if (parameter?.dataType.type !== "array" || parameter.dataType.subType.type !== "struct") return unsupportedListStructAssignment(property, `source parameter "${parameterId}" is not a list of structs`);
453
+ return [{
454
+ property: [property],
455
+ value: {
456
+ kind: "map",
457
+ value: {
458
+ source: inputReference(parameterId),
459
+ binding: FOUNDRY_LIST_ITEM_BINDING,
460
+ body: {
461
+ kind: "struct",
462
+ value: { fields: entries.map(([field, argument]) => ({
463
+ name: field,
464
+ value: argument.type === "structListParameterFieldValue" ? getAtExpression({
465
+ kind: "localReference",
466
+ value: { name: FOUNDRY_LIST_ITEM_BINDING }
467
+ }, [argument.structParameterFieldApiName]) : convertLogicRuleArgument(argument, syntheticParameters)
468
+ })) }
469
+ }
470
+ }
471
+ }
472
+ }];
582
473
  }
583
474
  function convertLogicStep(rule, parameters, syntheticParameters) {
584
- switch (rule.type) {
585
- case "createObject":
586
- return {
587
- kind: "createObject",
588
- value: {
589
- objectType: rule.objectTypeApiName,
590
- values: convertAssignments(rule, parameters, syntheticParameters),
591
- },
592
- };
593
- case "modifyObject":
594
- return {
595
- kind: "updateObject",
596
- value: {
597
- object: {
598
- name: rule.objectToModify,
599
- },
600
- values: convertAssignments(rule, parameters, syntheticParameters),
601
- },
602
- };
603
- case "deleteObject":
604
- return {
605
- kind: "deleteObject",
606
- value: {
607
- object: {
608
- name: rule.objectToDelete,
609
- },
610
- },
611
- };
612
- default:
613
- return null;
614
- }
615
- }
616
- export function convertFoundryMetaActionType(actionType, omsMetadata) {
617
- const syntheticParameters = createSyntheticParameters(actionType);
618
- const mutationTargetParameterNames = collectMutationTargetParameterNames(actionType.fullLogicRules);
619
- const fullLogicRules = actionType.fullLogicRules
620
- .map((rule) => convertLogicStep(rule, actionType.actionType.parameters, syntheticParameters))
621
- .filter((rule) => rule !== null);
622
- const parameters = Object.entries(actionType.actionType.parameters).map(([name, parameter]) => {
623
- const type = requireObjectReferenceMutationTarget(convertActionParameterType(parameter.dataType, parameter.required, parameter.validation), mutationTargetParameterNames.has(name));
624
- return {
625
- name,
626
- displayName: parameter.displayName ?? name,
627
- type: applyStringSuggestionsFallback(applyStringConstraintFallback(applyOmsStructFieldValidation(type, omsMetadata, name), convertOmsActionParameterStringConstraint(omsMetadata, name)), convertOmsActionParameterStringSuggestions(omsMetadata, name)),
628
- description: parameter.description,
629
- };
630
- });
631
- const defaultsByParameter = convertOmsActionParameterDefaults(omsMetadata, parameters);
632
- const foundryIcon = omsMetadata?.actionType.metadata?.displayMetadata?.icon;
633
- return {
634
- id: actionType.actionType.rid,
635
- name: toOntologyActionTypeName(actionType.actionType.apiName),
636
- displayName: actionType.actionType.displayName ?? actionType.actionType.apiName,
637
- description: actionType.actionType.description,
638
- icon: foundryIcon?.type === "blueprint"
639
- ? fromBlueprintIconName(foundryIcon.blueprint.locator)
640
- : undefined,
641
- color: foundryIcon?.type === "blueprint" ? foundryIcon.blueprint.color : undefined,
642
- deprecated: actionType.actionType.status === "DEPRECATED" ? { message: "Deprecated in Foundry." } : undefined,
643
- parameters: [
644
- ...parameters.map((parameter) => ({
645
- ...parameter,
646
- defaultValue: defaultsByParameter.get(parameter.name),
647
- })),
648
- ...syntheticParameters.parameters,
649
- ],
650
- logic: fullLogicRules,
651
- };
652
- }
475
+ switch (rule.type) {
476
+ case "createObject": return {
477
+ kind: "createObject",
478
+ value: {
479
+ objectType: rule.objectTypeApiName,
480
+ values: convertAssignments(rule, parameters, syntheticParameters)
481
+ }
482
+ };
483
+ case "modifyObject": return {
484
+ kind: "updateObject",
485
+ value: {
486
+ object: { name: rule.objectToModify },
487
+ values: convertAssignments(rule, parameters, syntheticParameters)
488
+ }
489
+ };
490
+ case "deleteObject": return {
491
+ kind: "deleteObject",
492
+ value: { object: { name: rule.objectToDelete } }
493
+ };
494
+ default: return null;
495
+ }
496
+ }
497
+ function convertFoundryMetaActionType(actionType, omsMetadata) {
498
+ const syntheticParameters = createSyntheticParameters(actionType);
499
+ const mutationTargetParameterNames = collectMutationTargetParameterNames(actionType.fullLogicRules);
500
+ const fullLogicRules = actionType.fullLogicRules.map((rule) => convertLogicStep(rule, actionType.actionType.parameters, syntheticParameters)).filter((rule) => rule !== null);
501
+ const parameters = Object.entries(actionType.actionType.parameters).map(([name, parameter]) => {
502
+ const type = requireObjectReferenceMutationTarget(convertActionParameterType(parameter.dataType, parameter.required, parameter.validation), mutationTargetParameterNames.has(name));
503
+ return {
504
+ name,
505
+ displayName: parameter.displayName ?? name,
506
+ type: applyStringSuggestionsFallback(applyStringConstraintFallback(applyOmsStructFieldValidation(type, omsMetadata, name), convertOmsActionParameterStringConstraint(omsMetadata, name)), convertOmsActionParameterStringSuggestions(omsMetadata, name)),
507
+ description: parameter.description
508
+ };
509
+ });
510
+ const defaultsByParameter = convertOmsActionParameterDefaults(omsMetadata, parameters);
511
+ const foundryIcon = omsMetadata?.actionType.metadata?.displayMetadata?.icon;
512
+ return {
513
+ id: actionType.actionType.rid,
514
+ name: toOntologyActionTypeName(actionType.actionType.apiName),
515
+ displayName: actionType.actionType.displayName ?? actionType.actionType.apiName,
516
+ description: actionType.actionType.description,
517
+ icon: foundryIcon?.type === "blueprint" ? fromBlueprintIconName(foundryIcon.blueprint.locator) : void 0,
518
+ color: foundryIcon?.type === "blueprint" ? foundryIcon.blueprint.color : void 0,
519
+ deprecated: actionType.actionType.status === "DEPRECATED" ? { message: "Deprecated in Foundry." } : void 0,
520
+ parameters: [...parameters.map((parameter) => ({
521
+ ...parameter,
522
+ defaultValue: defaultsByParameter.get(parameter.name)
523
+ })), ...syntheticParameters.parameters],
524
+ logic: fullLogicRules
525
+ };
526
+ }
527
+ //#endregion
528
+ export { convertFoundryMetaActionType, getFoundryActionOverrideParameterMapping };
529
+
653
530
  //# sourceMappingURL=convertMetaActionType.js.map