@zitadel/api 0.4.0 → 0.5.0

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 (715) hide show
  1. package/README.md +1 -1
  2. package/dist/{api-factory-C5b1Gqwv.mjs → api-factory-32Zz3s86.mjs} +8 -6
  3. package/dist/api-factory-32Zz3s86.mjs.map +1 -0
  4. package/dist/{api-factory-Dt5lUjyu.d.mts → api-factory-DbVEEqxe.d.mts} +8 -3
  5. package/dist/{api-factory-Dt5lUjyu.d.mts.map → api-factory-DbVEEqxe.d.mts.map} +1 -1
  6. package/dist/{fetch-B-lgjlrf.d.mts → fetch-BzLvdm6C.d.mts} +14 -1
  7. package/dist/fetch-BzLvdm6C.d.mts.map +1 -0
  8. package/dist/generated/endpoints/zitadelNextGen.d.mts +1 -1
  9. package/dist/generated/endpoints/zitadelNextGen.mjs +984 -625
  10. package/dist/generated/endpoints/zitadelNextGen.mjs.map +1 -1
  11. package/dist/generated/endpoints/zitadelNextGen.msw.d.mts +1 -1
  12. package/dist/generated/endpoints/zitadelNextGen.msw.mjs +9 -9
  13. package/dist/generated/endpoints/zitadelNextGen.msw.mjs.map +1 -1
  14. package/dist/generated/endpoints/zitadelNextGen.zod.d.mts +1024 -659
  15. package/dist/generated/endpoints/zitadelNextGen.zod.d.mts.map +1 -1
  16. package/dist/generated/endpoints/zitadelNextGen.zod.mjs +4797 -4436
  17. package/dist/generated/endpoints/zitadelNextGen.zod.mjs.map +1 -1
  18. package/dist/generated/model/index.d.mts +1 -1
  19. package/dist/generated/model/index.mjs.map +1 -1
  20. package/dist/generated/operations.d.mts +9 -0
  21. package/dist/generated/operations.d.mts.map +1 -1
  22. package/dist/generated/operations.mjs +266 -153
  23. package/dist/generated/operations.mjs.map +1 -1
  24. package/dist/{index-DGQY1rfH.d.mts → index-BX80Kl-8.d.mts} +9071 -7707
  25. package/dist/{index-DGQY1rfH.d.mts.map → index-BX80Kl-8.d.mts.map} +1 -1
  26. package/dist/runtime/api-factory.d.mts +1 -1
  27. package/dist/runtime/api-factory.mjs +1 -1
  28. package/dist/runtime/config.d.mts +1 -1
  29. package/dist/runtime/config.mjs +1 -1
  30. package/dist/runtime/fetch.d.mts +1 -1
  31. package/dist/runtime/fetch.mjs +1 -0
  32. package/dist/runtime/fetch.mjs.map +1 -1
  33. package/dist/runtime/paging.d.mts +106 -23
  34. package/dist/runtime/paging.d.mts.map +1 -1
  35. package/dist/runtime/paging.mjs +132 -32
  36. package/dist/runtime/paging.mjs.map +1 -1
  37. package/dist/zitadelNextGen-CFrFhq_h.d.mts +1726 -0
  38. package/dist/zitadelNextGen-CFrFhq_h.d.mts.map +1 -0
  39. package/package.json +3 -3
  40. package/src/generated/endpoints/zitadelNextGen.faker.ts +3 -3
  41. package/src/generated/endpoints/zitadelNextGen.ts +1009 -650
  42. package/src/generated/endpoints/zitadelNextGen.zod.ts +4812 -4443
  43. package/src/generated/model/addOrigin201.ts +5 -0
  44. package/src/generated/model/addOrigin201Kind.ts +3 -0
  45. package/src/generated/model/addOriginBody.ts +17 -5
  46. package/src/generated/model/addOriginBodyKind.ts +4 -0
  47. package/src/generated/model/beginUserPasskeyRegistration201.ts +3 -3
  48. package/src/generated/model/beginUserPasskeyRegistrationBody.ts +6 -6
  49. package/src/generated/model/buildRelease200.ts +15 -15
  50. package/src/generated/model/buildRelease200Metadata.ts +8 -8
  51. package/src/generated/model/buildRelease200PointersItem.ts +13 -12
  52. package/src/generated/model/buildRelease200PointersItemKind.ts +3 -3
  53. package/src/generated/model/buildRelease201.ts +15 -15
  54. package/src/generated/model/buildRelease201Metadata.ts +8 -8
  55. package/src/generated/model/buildRelease201PointersItem.ts +13 -12
  56. package/src/generated/model/buildRelease201PointersItemKind.ts +3 -3
  57. package/src/generated/model/buildRelease400.ts +1 -3
  58. package/src/generated/model/buildRelease400DetailsResourcesItem.ts +3 -3
  59. package/src/generated/model/buildRelease400DetailsResourcesItemKind.ts +3 -3
  60. package/src/generated/model/buildReleaseBody.ts +19 -16
  61. package/src/generated/model/buildReleaseBodyBundle.ts +31 -28
  62. package/src/generated/model/buildReleaseBodyBundleBranding.ts +24 -22
  63. package/src/generated/model/buildReleaseBodyBundleBrandingLayout.ts +8 -7
  64. package/src/generated/model/buildReleaseBodyBundleBrandingShape.ts +1 -1
  65. package/src/generated/model/buildReleaseBodyBundleBrandingTheme.ts +5 -7
  66. package/src/generated/model/buildReleaseBodyBundleBrandingThemeDark.ts +7 -7
  67. package/src/generated/model/buildReleaseBodyBundleBrandingThemeDarkPalette.ts +63 -62
  68. package/src/generated/model/buildReleaseBodyBundleBrandingThemeLight.ts +7 -7
  69. package/src/generated/model/buildReleaseBodyBundleBrandingThemeLightPalette.ts +63 -62
  70. package/src/generated/model/buildReleaseBodyBundleBrandingTypography.ts +4 -4
  71. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItem.ts +47 -26
  72. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemAudience.ts +1 -1
  73. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStatus.ts +2 -2
  74. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItem.ts +46 -28
  75. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemActionsItem.ts +9 -7
  76. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemActionsItemKind.ts +2 -2
  77. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemGates.ts +11 -10
  78. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemGatesConfig.ts +1 -1
  79. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemGatesKind.ts +4 -3
  80. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemTransitions.ts +40 -20
  81. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemTransitionsAction.ts +8 -5
  82. package/src/generated/model/buildReleaseBodyBundleFlowDefinitionsItemStepsItemTransitionsPurpose.ts +7 -8
  83. package/src/generated/model/buildReleaseBodyBundleIdpsItem.ts +7 -7
  84. package/src/generated/model/buildReleaseBodyBundleIdpsItemClaimMapping.ts +1 -1
  85. package/src/generated/model/buildReleaseBodyBundleIdpsItemOidc.ts +7 -7
  86. package/src/generated/model/buildReleaseBodyBundleIdpsItemOidcStaticAuthorizeParameters.ts +1 -1
  87. package/src/generated/model/buildReleaseBodyBundleIdpsItemProvisioning.ts +1 -1
  88. package/src/generated/model/buildReleaseBodyBundleIdpsItemVerifiedClaims.ts +1 -1
  89. package/src/generated/model/buildReleaseBodyBundlePoliciesItem.ts +3 -3
  90. package/src/generated/model/buildReleaseBodyBundleSchemasItem.ts +23 -22
  91. package/src/generated/model/buildReleaseParams.ts +3 -1
  92. package/src/generated/model/completeClaim409.ts +2 -2
  93. package/src/generated/model/completeClaimBody.ts +1 -1
  94. package/src/generated/model/createAuthAttempt201.ts +23 -22
  95. package/src/generated/model/createAuthAttempt201ChallengesItem.ts +9 -7
  96. package/src/generated/model/createAuthAttempt201ChallengesItemState.ts +1 -1
  97. package/src/generated/model/createAuthAttempt201CompletedFactorsItem.ts +2 -2
  98. package/src/generated/model/createAuthAttempt201CompletedFactorsItemPayload.ts +5 -5
  99. package/src/generated/model/createAuthAttempt201State.ts +2 -2
  100. package/src/generated/model/createAuthAttemptBody.ts +3 -3
  101. package/src/generated/model/createAuthAttemptDefault.ts +63 -0
  102. package/src/generated/model/createBranding201.ts +10 -10
  103. package/src/generated/model/createBranding201Branding.ts +24 -22
  104. package/src/generated/model/createBranding201BrandingLayout.ts +8 -7
  105. package/src/generated/model/createBranding201BrandingShape.ts +1 -1
  106. package/src/generated/model/createBranding201BrandingTheme.ts +5 -7
  107. package/src/generated/model/createBranding201BrandingThemeDark.ts +7 -7
  108. package/src/generated/model/createBranding201BrandingThemeDarkPalette.ts +63 -62
  109. package/src/generated/model/createBranding201BrandingThemeLight.ts +7 -7
  110. package/src/generated/model/createBranding201BrandingThemeLightPalette.ts +63 -62
  111. package/src/generated/model/createBranding201BrandingTypography.ts +4 -4
  112. package/src/generated/model/createBrandingBody.ts +24 -22
  113. package/src/generated/model/createBrandingBodyLayout.ts +8 -7
  114. package/src/generated/model/createBrandingBodyShape.ts +1 -1
  115. package/src/generated/model/createBrandingBodyTheme.ts +5 -7
  116. package/src/generated/model/createBrandingBodyThemeDark.ts +7 -7
  117. package/src/generated/model/createBrandingBodyThemeDarkPalette.ts +63 -62
  118. package/src/generated/model/createBrandingBodyThemeLight.ts +7 -7
  119. package/src/generated/model/createBrandingBodyThemeLightPalette.ts +63 -62
  120. package/src/generated/model/createBrandingBodyTypography.ts +4 -4
  121. package/src/generated/model/createBrandingParams.ts +3 -1
  122. package/src/generated/model/createDeployment200.ts +16 -14
  123. package/src/generated/model/createDeployment200Metadata.ts +1 -1
  124. package/src/generated/model/createDeployment200Release.ts +15 -15
  125. package/src/generated/model/createDeployment200ReleaseMetadata.ts +8 -8
  126. package/src/generated/model/createDeployment200ReleasePointersItem.ts +13 -12
  127. package/src/generated/model/createDeployment200ReleasePointersItemKind.ts +3 -3
  128. package/src/generated/model/createDeployment200Status.ts +3 -3
  129. package/src/generated/model/createDeployment201.ts +16 -14
  130. package/src/generated/model/createDeployment201Metadata.ts +1 -1
  131. package/src/generated/model/createDeployment201Release.ts +15 -15
  132. package/src/generated/model/createDeployment201ReleaseMetadata.ts +8 -8
  133. package/src/generated/model/createDeployment201ReleasePointersItem.ts +13 -12
  134. package/src/generated/model/createDeployment201ReleasePointersItemKind.ts +3 -3
  135. package/src/generated/model/createDeployment201Status.ts +3 -3
  136. package/src/generated/model/createDeployment409.ts +41 -40
  137. package/src/generated/model/createDeploymentBody.ts +4 -10
  138. package/src/generated/model/createDeploymentParams.ts +3 -1
  139. package/src/generated/model/createFlow201.ts +16 -12
  140. package/src/generated/model/createFlow201Branding.ts +24 -22
  141. package/src/generated/model/createFlow201BrandingLayout.ts +8 -7
  142. package/src/generated/model/createFlow201BrandingShape.ts +1 -1
  143. package/src/generated/model/createFlow201BrandingTheme.ts +5 -7
  144. package/src/generated/model/createFlow201BrandingThemeDark.ts +7 -7
  145. package/src/generated/model/createFlow201BrandingThemeDarkPalette.ts +63 -62
  146. package/src/generated/model/createFlow201BrandingThemeLight.ts +7 -7
  147. package/src/generated/model/createFlow201BrandingThemeLightPalette.ts +63 -62
  148. package/src/generated/model/createFlow201BrandingTypography.ts +4 -4
  149. package/src/generated/model/createFlow201Step.ts +36 -31
  150. package/src/generated/model/createFlow201StepActionsItem.ts +3 -3
  151. package/src/generated/model/createFlow201StepActionsItemKind.ts +1 -1
  152. package/src/generated/model/createFlow201StepChallenge.ts +4 -3
  153. package/src/generated/model/createFlow201StepComplete.ts +1 -1
  154. package/src/generated/model/createFlow201StepFieldsItem.ts +14 -13
  155. package/src/generated/model/createFlow201StepFieldsItemType.ts +1 -1
  156. package/src/generated/model/createFlow201StepFieldsItemValidation.ts +2 -2
  157. package/src/generated/model/createFlow201StepFieldsItemValidationFormat.ts +1 -1
  158. package/src/generated/model/createFlow201StepGates.ts +10 -8
  159. package/src/generated/model/createFlow201StepGatesConfig.ts +1 -1
  160. package/src/generated/model/createFlow201StepGatesKind.ts +4 -3
  161. package/src/generated/model/createFlow201StepIdentifier.ts +6 -6
  162. package/src/generated/model/createFlow201StepSsoProvidersItem.ts +1 -1
  163. package/src/generated/model/createFlow201StepTexts.ts +1 -1
  164. package/src/generated/model/createFlowBody.ts +7 -2
  165. package/src/generated/model/createFlowBodyHint.ts +4 -1
  166. package/src/generated/model/createFlowBodyPurpose.ts +3 -0
  167. package/src/generated/model/createFlowDefault.ts +9 -0
  168. package/src/generated/model/createFlowDefinition201.ts +22 -10
  169. package/src/generated/model/createFlowDefinition201FlowDefinition.ts +47 -26
  170. package/src/generated/model/createFlowDefinition201FlowDefinitionAudience.ts +1 -1
  171. package/src/generated/model/createFlowDefinition201FlowDefinitionStatus.ts +2 -2
  172. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItem.ts +46 -28
  173. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemActionsItem.ts +9 -7
  174. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemActionsItemKind.ts +2 -2
  175. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemGates.ts +11 -10
  176. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemGatesConfig.ts +1 -1
  177. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemGatesKind.ts +4 -3
  178. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemTransitions.ts +40 -20
  179. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemTransitionsAction.ts +8 -5
  180. package/src/generated/model/createFlowDefinition201FlowDefinitionStepsItemTransitionsPurpose.ts +7 -8
  181. package/src/generated/model/createFlowDefinition201UserSchema.ts +2 -2
  182. package/src/generated/model/createFlowDefinition201UserSchemaMetadata.ts +2 -1
  183. package/src/generated/model/createFlowDefinition201UserSchemaSchema.ts +21 -20
  184. package/src/generated/model/createFlowDefinitionBody.ts +22 -12
  185. package/src/generated/model/createFlowDefinitionBodyFlowDefinition.ts +47 -26
  186. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionAudience.ts +1 -1
  187. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStatus.ts +2 -2
  188. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItem.ts +46 -28
  189. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemActionsItem.ts +9 -7
  190. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemActionsItemKind.ts +2 -2
  191. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemGates.ts +11 -10
  192. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemGatesConfig.ts +1 -1
  193. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemGatesKind.ts +4 -3
  194. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemTransitions.ts +40 -20
  195. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemTransitionsAction.ts +8 -5
  196. package/src/generated/model/createFlowDefinitionBodyFlowDefinitionStepsItemTransitionsPurpose.ts +7 -8
  197. package/src/generated/model/createGrant201.ts +14 -14
  198. package/src/generated/model/createGrant201ObjectType.ts +1 -1
  199. package/src/generated/model/createGrant201Relation.ts +1 -1
  200. package/src/generated/model/createGrant201Team.ts +7 -7
  201. package/src/generated/model/createGrant201TeamStatus.ts +2 -2
  202. package/src/generated/model/createGrant201User.ts +5 -5
  203. package/src/generated/model/createGrant201UserMetadata.ts +10 -11
  204. package/src/generated/model/createGrant201UserMetadataLifecycleOwnerTeam.ts +11 -12
  205. package/src/generated/model/createGrant201UserMetadataLifecycleOwnerTeamStatus.ts +2 -2
  206. package/src/generated/model/createGrantBody.ts +12 -12
  207. package/src/generated/model/createGrantBodyRelation.ts +1 -1
  208. package/src/generated/model/createGrantBodyTeam.ts +3 -3
  209. package/src/generated/model/createGrantBodyUser.ts +5 -5
  210. package/src/generated/model/createGrantDefault.ts +9 -0
  211. package/src/generated/model/createGrantParams.ts +3 -1
  212. package/src/generated/model/createHandoff200.ts +9 -10
  213. package/src/generated/model/createIdp200.ts +10 -9
  214. package/src/generated/model/createIdp200Definition.ts +7 -7
  215. package/src/generated/model/createIdp200DefinitionClaimMapping.ts +1 -1
  216. package/src/generated/model/createIdp200DefinitionOidc.ts +7 -7
  217. package/src/generated/model/createIdp200DefinitionOidcStaticAuthorizeParameters.ts +1 -1
  218. package/src/generated/model/createIdp200DefinitionProvisioning.ts +1 -1
  219. package/src/generated/model/createIdp200DefinitionVerifiedClaims.ts +1 -1
  220. package/src/generated/model/createIdp201.ts +10 -9
  221. package/src/generated/model/createIdp201Definition.ts +7 -7
  222. package/src/generated/model/createIdp201DefinitionClaimMapping.ts +1 -1
  223. package/src/generated/model/createIdp201DefinitionOidc.ts +7 -7
  224. package/src/generated/model/createIdp201DefinitionOidcStaticAuthorizeParameters.ts +1 -1
  225. package/src/generated/model/createIdp201DefinitionProvisioning.ts +1 -1
  226. package/src/generated/model/createIdp201DefinitionVerifiedClaims.ts +1 -1
  227. package/src/generated/model/createIdpBody.ts +1 -1
  228. package/src/generated/model/createIdpBodyIdp.ts +7 -7
  229. package/src/generated/model/createIdpBodyIdpClaimMapping.ts +1 -1
  230. package/src/generated/model/createIdpBodyIdpOidc.ts +7 -7
  231. package/src/generated/model/createIdpBodyIdpOidcStaticAuthorizeParameters.ts +1 -1
  232. package/src/generated/model/createIdpBodyIdpProvisioning.ts +1 -1
  233. package/src/generated/model/createIdpBodyIdpVerifiedClaims.ts +1 -1
  234. package/src/generated/model/createIdpParams.ts +3 -1
  235. package/src/generated/model/createProject201.ts +10 -5
  236. package/src/generated/model/createProject201OriginsItem.ts +17 -5
  237. package/src/generated/model/createProject201OriginsItemKind.ts +4 -0
  238. package/src/generated/model/createProjectBody.ts +5 -6
  239. package/src/generated/model/createProjectBodyOriginsItem.ts +17 -5
  240. package/src/generated/model/createProjectBodyOriginsItemKind.ts +4 -0
  241. package/src/generated/model/createRelease200.ts +15 -15
  242. package/src/generated/model/createRelease200Metadata.ts +8 -8
  243. package/src/generated/model/createRelease200PointersItem.ts +13 -12
  244. package/src/generated/model/createRelease200PointersItemKind.ts +3 -3
  245. package/src/generated/model/createRelease201.ts +15 -15
  246. package/src/generated/model/createRelease201Metadata.ts +8 -8
  247. package/src/generated/model/createRelease201PointersItem.ts +13 -12
  248. package/src/generated/model/createRelease201PointersItemKind.ts +3 -3
  249. package/src/generated/model/createReleaseBody.ts +7 -11
  250. package/src/generated/model/createReleaseBodyPointersItem.ts +8 -8
  251. package/src/generated/model/createReleaseBodyPointersItemKind.ts +3 -3
  252. package/src/generated/model/createReleaseParams.ts +3 -1
  253. package/src/generated/model/createSchema201.ts +1 -1
  254. package/src/generated/model/createSchemaBody.ts +23 -22
  255. package/src/generated/model/createSchemaParams.ts +4 -2
  256. package/src/generated/model/createSession201.ts +8 -8
  257. package/src/generated/model/createSession201Session.ts +16 -16
  258. package/src/generated/model/createSession201SessionFactorsItem.ts +2 -2
  259. package/src/generated/model/createSession201SessionFactorsItemPayload.ts +5 -5
  260. package/src/generated/model/createSession201SessionState.ts +1 -1
  261. package/src/generated/model/createSession201SessionUser.ts +5 -5
  262. package/src/generated/model/createSessionBody.ts +1 -1
  263. package/src/generated/model/createTeam201.ts +2 -2
  264. package/src/generated/model/createTeam201Status.ts +2 -2
  265. package/src/generated/model/createTeamBody.ts +1 -1
  266. package/src/generated/model/createTeamParams.ts +3 -1
  267. package/src/generated/model/createUser201.ts +28 -29
  268. package/src/generated/model/createUser201Metadata.ts +10 -11
  269. package/src/generated/model/createUser201MetadataLifecycleOwnerTeam.ts +11 -12
  270. package/src/generated/model/createUser201MetadataLifecycleOwnerTeamStatus.ts +2 -2
  271. package/src/generated/model/createUser201TeamsItem.ts +4 -4
  272. package/src/generated/model/createUserBody.ts +9 -8
  273. package/src/generated/model/createUserParams.ts +4 -2
  274. package/src/generated/model/deleteGrantParams.ts +3 -1
  275. package/src/generated/model/deleteVariableParams.ts +3 -1
  276. package/src/generated/model/evaluatePolicy200.ts +5 -4
  277. package/src/generated/model/evaluatePolicy200Violations.ts +4 -3
  278. package/src/generated/model/evaluatePolicyBody.ts +8 -9
  279. package/src/generated/model/evaluatePolicyParams.ts +3 -1
  280. package/src/generated/model/exchangeHandoff200.ts +8 -8
  281. package/src/generated/model/exchangeHandoff200Session.ts +16 -16
  282. package/src/generated/model/exchangeHandoff200SessionFactorsItem.ts +2 -2
  283. package/src/generated/model/exchangeHandoff200SessionFactorsItemPayload.ts +5 -5
  284. package/src/generated/model/exchangeHandoff200SessionState.ts +1 -1
  285. package/src/generated/model/exchangeHandoff200SessionUser.ts +5 -5
  286. package/src/generated/model/exchangeHandoffBody.ts +7 -5
  287. package/src/generated/model/exchangeHandoffParams.ts +3 -1
  288. package/src/generated/model/finishUserPasskeyRegistrationBody.ts +1 -1
  289. package/src/generated/model/getAuthAttempt200.ts +23 -22
  290. package/src/generated/model/getAuthAttempt200ChallengesItem.ts +9 -7
  291. package/src/generated/model/getAuthAttempt200ChallengesItemState.ts +1 -1
  292. package/src/generated/model/getAuthAttempt200CompletedFactorsItem.ts +2 -2
  293. package/src/generated/model/getAuthAttempt200CompletedFactorsItemPayload.ts +5 -5
  294. package/src/generated/model/getAuthAttempt200State.ts +2 -2
  295. package/src/generated/model/getBrandingById200.ts +10 -10
  296. package/src/generated/model/getBrandingById200Branding.ts +24 -22
  297. package/src/generated/model/getBrandingById200BrandingLayout.ts +8 -7
  298. package/src/generated/model/getBrandingById200BrandingShape.ts +1 -1
  299. package/src/generated/model/getBrandingById200BrandingTheme.ts +5 -7
  300. package/src/generated/model/getBrandingById200BrandingThemeDark.ts +7 -7
  301. package/src/generated/model/getBrandingById200BrandingThemeDarkPalette.ts +63 -62
  302. package/src/generated/model/getBrandingById200BrandingThemeLight.ts +7 -7
  303. package/src/generated/model/getBrandingById200BrandingThemeLightPalette.ts +63 -62
  304. package/src/generated/model/getBrandingById200BrandingTypography.ts +4 -4
  305. package/src/generated/model/getClaimStatus200.ts +4 -5
  306. package/src/generated/model/getClaimStatusParams.ts +1 -1
  307. package/src/generated/model/getClaimWindow200.ts +6 -6
  308. package/src/generated/model/getClaimWindowParams.ts +1 -1
  309. package/src/generated/model/getDeploymentById200.ts +16 -14
  310. package/src/generated/model/getDeploymentById200Metadata.ts +1 -1
  311. package/src/generated/model/getDeploymentById200Release.ts +15 -15
  312. package/src/generated/model/getDeploymentById200ReleaseMetadata.ts +8 -8
  313. package/src/generated/model/getDeploymentById200ReleasePointersItem.ts +13 -12
  314. package/src/generated/model/getDeploymentById200ReleasePointersItemKind.ts +3 -3
  315. package/src/generated/model/getDeploymentById200Status.ts +3 -3
  316. package/src/generated/model/getDeploymentByIdParams.ts +3 -1
  317. package/src/generated/model/getDeploymentVariablesParams.ts +3 -1
  318. package/src/generated/model/getEvent200.ts +1574 -1323
  319. package/src/generated/model/getEventParams.ts +3 -1
  320. package/src/generated/model/getFlowDefinition200.ts +22 -10
  321. package/src/generated/model/getFlowDefinition200FlowDefinition.ts +47 -26
  322. package/src/generated/model/getFlowDefinition200FlowDefinitionAudience.ts +1 -1
  323. package/src/generated/model/getFlowDefinition200FlowDefinitionStatus.ts +2 -2
  324. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItem.ts +46 -28
  325. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemActionsItem.ts +9 -7
  326. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemActionsItemKind.ts +2 -2
  327. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemGates.ts +11 -10
  328. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemGatesConfig.ts +1 -1
  329. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemGatesKind.ts +4 -3
  330. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemTransitions.ts +40 -20
  331. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemTransitionsAction.ts +8 -5
  332. package/src/generated/model/getFlowDefinition200FlowDefinitionStepsItemTransitionsPurpose.ts +7 -8
  333. package/src/generated/model/getFlowDefinition200UserSchema.ts +2 -2
  334. package/src/generated/model/getFlowDefinition200UserSchemaMetadata.ts +2 -1
  335. package/src/generated/model/getFlowDefinition200UserSchemaSchema.ts +21 -20
  336. package/src/generated/model/getFlowStep200.ts +16 -12
  337. package/src/generated/model/getFlowStep200Branding.ts +24 -22
  338. package/src/generated/model/getFlowStep200BrandingLayout.ts +8 -7
  339. package/src/generated/model/getFlowStep200BrandingShape.ts +1 -1
  340. package/src/generated/model/getFlowStep200BrandingTheme.ts +5 -7
  341. package/src/generated/model/getFlowStep200BrandingThemeDark.ts +7 -7
  342. package/src/generated/model/getFlowStep200BrandingThemeDarkPalette.ts +63 -62
  343. package/src/generated/model/getFlowStep200BrandingThemeLight.ts +7 -7
  344. package/src/generated/model/getFlowStep200BrandingThemeLightPalette.ts +63 -62
  345. package/src/generated/model/getFlowStep200BrandingTypography.ts +4 -4
  346. package/src/generated/model/getFlowStep200Step.ts +36 -31
  347. package/src/generated/model/getFlowStep200StepActionsItem.ts +3 -3
  348. package/src/generated/model/getFlowStep200StepActionsItemKind.ts +1 -1
  349. package/src/generated/model/getFlowStep200StepChallenge.ts +4 -3
  350. package/src/generated/model/getFlowStep200StepComplete.ts +1 -1
  351. package/src/generated/model/getFlowStep200StepFieldsItem.ts +14 -13
  352. package/src/generated/model/getFlowStep200StepFieldsItemType.ts +1 -1
  353. package/src/generated/model/getFlowStep200StepFieldsItemValidation.ts +2 -2
  354. package/src/generated/model/getFlowStep200StepFieldsItemValidationFormat.ts +1 -1
  355. package/src/generated/model/getFlowStep200StepGates.ts +10 -8
  356. package/src/generated/model/getFlowStep200StepGatesConfig.ts +1 -1
  357. package/src/generated/model/getFlowStep200StepGatesKind.ts +4 -3
  358. package/src/generated/model/getFlowStep200StepIdentifier.ts +6 -6
  359. package/src/generated/model/getFlowStep200StepSsoProvidersItem.ts +1 -1
  360. package/src/generated/model/getFlowStep200StepTexts.ts +1 -1
  361. package/src/generated/model/getFlowStepDefault.ts +18 -0
  362. package/src/generated/model/getGrant200.ts +14 -14
  363. package/src/generated/model/getGrant200ObjectType.ts +1 -1
  364. package/src/generated/model/getGrant200Relation.ts +1 -1
  365. package/src/generated/model/getGrant200Team.ts +7 -7
  366. package/src/generated/model/getGrant200TeamStatus.ts +2 -2
  367. package/src/generated/model/getGrant200User.ts +5 -5
  368. package/src/generated/model/getGrant200UserMetadata.ts +10 -11
  369. package/src/generated/model/getGrant200UserMetadataLifecycleOwnerTeam.ts +11 -12
  370. package/src/generated/model/getGrant200UserMetadataLifecycleOwnerTeamStatus.ts +2 -2
  371. package/src/generated/model/getGrantDefault.ts +0 -9
  372. package/src/generated/model/getGrantExpandItem.ts +8 -5
  373. package/src/generated/model/getGrantParams.ts +6 -3
  374. package/src/generated/model/getIdpById200.ts +10 -9
  375. package/src/generated/model/getIdpById200Definition.ts +7 -7
  376. package/src/generated/model/getIdpById200DefinitionClaimMapping.ts +1 -1
  377. package/src/generated/model/getIdpById200DefinitionOidc.ts +7 -7
  378. package/src/generated/model/getIdpById200DefinitionOidcStaticAuthorizeParameters.ts +1 -1
  379. package/src/generated/model/getIdpById200DefinitionProvisioning.ts +1 -1
  380. package/src/generated/model/getIdpById200DefinitionVerifiedClaims.ts +1 -1
  381. package/src/generated/model/getIdpByIdParams.ts +3 -1
  382. package/src/generated/model/getIdpRevisionById200.ts +10 -9
  383. package/src/generated/model/getIdpRevisionById200Definition.ts +7 -7
  384. package/src/generated/model/getIdpRevisionById200DefinitionClaimMapping.ts +1 -1
  385. package/src/generated/model/getIdpRevisionById200DefinitionOidc.ts +7 -7
  386. package/src/generated/model/getIdpRevisionById200DefinitionOidcStaticAuthorizeParameters.ts +1 -1
  387. package/src/generated/model/getIdpRevisionById200DefinitionProvisioning.ts +1 -1
  388. package/src/generated/model/getIdpRevisionById200DefinitionVerifiedClaims.ts +1 -1
  389. package/src/generated/model/getIdpRevisionByIdParams.ts +3 -1
  390. package/src/generated/model/getMyPasswordState200.ts +2 -2
  391. package/src/generated/model/getMySession200.ts +16 -16
  392. package/src/generated/model/getMySession200FactorsItem.ts +2 -2
  393. package/src/generated/model/getMySession200FactorsItemPayload.ts +5 -5
  394. package/src/generated/model/getMySession200State.ts +1 -1
  395. package/src/generated/model/getMySession200User.ts +5 -5
  396. package/src/generated/model/getMySessionCsrfToken200.ts +1 -1
  397. package/src/generated/model/getMyUser200.ts +28 -29
  398. package/src/generated/model/getMyUser200Metadata.ts +10 -11
  399. package/src/generated/model/getMyUser200MetadataLifecycleOwnerTeam.ts +11 -12
  400. package/src/generated/model/getMyUser200MetadataLifecycleOwnerTeamStatus.ts +2 -2
  401. package/src/generated/model/getMyUser200TeamsItem.ts +4 -4
  402. package/src/generated/model/getMyUserSchema200.ts +4 -4
  403. package/src/generated/model/getMyUserSchema200Metadata.ts +2 -1
  404. package/src/generated/model/getMyUserSchema200Schema.ts +21 -20
  405. package/src/generated/model/getPolicy200.ts +3 -3
  406. package/src/generated/model/getPolicyParams.ts +3 -1
  407. package/src/generated/model/getPolicyRevision200.ts +3 -3
  408. package/src/generated/model/getPolicyRevisionParams.ts +3 -1
  409. package/src/generated/model/getProject200.ts +34 -30
  410. package/src/generated/model/getReleaseById200.ts +15 -15
  411. package/src/generated/model/getReleaseById200Metadata.ts +8 -8
  412. package/src/generated/model/getReleaseById200PointersItem.ts +13 -12
  413. package/src/generated/model/getReleaseById200PointersItemKind.ts +3 -3
  414. package/src/generated/model/getReleaseByIdParams.ts +3 -1
  415. package/src/generated/model/getSchemaById200.ts +4 -4
  416. package/src/generated/model/getSchemaById200Metadata.ts +2 -1
  417. package/src/generated/model/getSchemaById200Schema.ts +21 -20
  418. package/src/generated/model/getSchemaByIdParams.ts +3 -3
  419. package/src/generated/model/getSession200.ts +16 -16
  420. package/src/generated/model/getSession200FactorsItem.ts +2 -2
  421. package/src/generated/model/getSession200FactorsItemPayload.ts +5 -5
  422. package/src/generated/model/getSession200State.ts +1 -1
  423. package/src/generated/model/getSession200User.ts +5 -5
  424. package/src/generated/model/getTeam200.ts +2 -2
  425. package/src/generated/model/getTeam200Status.ts +2 -2
  426. package/src/generated/model/getUserByID200.ts +28 -29
  427. package/src/generated/model/getUserByID200Metadata.ts +10 -11
  428. package/src/generated/model/getUserByID200MetadataLifecycleOwnerTeam.ts +11 -12
  429. package/src/generated/model/getUserByID200MetadataLifecycleOwnerTeamStatus.ts +2 -2
  430. package/src/generated/model/getUserByID200TeamsItem.ts +4 -4
  431. package/src/generated/model/getUserByIDParams.ts +4 -3
  432. package/src/generated/model/getUserPasswordState200.ts +2 -2
  433. package/src/generated/model/getVariable200.ts +4 -4
  434. package/src/generated/model/getVariable200Preview.ts +2 -2
  435. package/src/generated/model/getVariable200Primary.ts +2 -2
  436. package/src/generated/model/getVariableParams.ts +3 -1
  437. package/src/generated/model/getVariables200.ts +4 -4
  438. package/src/generated/model/getVariables200Preview.ts +2 -2
  439. package/src/generated/model/getVariables200Primary.ts +2 -2
  440. package/src/generated/model/getVariablesParams.ts +3 -1
  441. package/src/generated/model/initClaim201.ts +3 -3
  442. package/src/generated/model/initClaim409.ts +2 -2
  443. package/src/generated/model/issueChallenge201.ts +9 -7
  444. package/src/generated/model/issueChallenge201State.ts +1 -1
  445. package/src/generated/model/issueChallengeBody.ts +2 -2
  446. package/src/generated/model/listBrandingParams.ts +3 -1
  447. package/src/generated/model/listDeployments200DeploymentsItem.ts +16 -14
  448. package/src/generated/model/listDeployments200DeploymentsItemMetadata.ts +1 -1
  449. package/src/generated/model/listDeployments200DeploymentsItemRelease.ts +15 -15
  450. package/src/generated/model/listDeployments200DeploymentsItemReleaseMetadata.ts +8 -8
  451. package/src/generated/model/listDeployments200DeploymentsItemReleasePointersItem.ts +13 -12
  452. package/src/generated/model/listDeployments200DeploymentsItemReleasePointersItemKind.ts +3 -3
  453. package/src/generated/model/listDeployments200DeploymentsItemStatus.ts +3 -3
  454. package/src/generated/model/listDeploymentsExpandItem.ts +4 -4
  455. package/src/generated/model/listDeploymentsParams.ts +3 -1
  456. package/src/generated/model/listEvents200.ts +1 -1
  457. package/src/generated/model/listEvents200DataItem.ts +1574 -1323
  458. package/src/generated/model/listEventsParams.ts +34 -6
  459. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItem.ts +22 -10
  460. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinition.ts +47 -26
  461. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionAudience.ts +1 -1
  462. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStatus.ts +2 -2
  463. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItem.ts +46 -28
  464. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemActionsItem.ts +9 -7
  465. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemActionsItemKind.ts +2 -2
  466. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemGates.ts +11 -10
  467. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemGatesConfig.ts +1 -1
  468. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemGatesKind.ts +4 -3
  469. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemTransitions.ts +40 -20
  470. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemTransitionsAction.ts +8 -5
  471. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemFlowDefinitionStepsItemTransitionsPurpose.ts +7 -8
  472. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemUserSchema.ts +2 -2
  473. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemUserSchemaMetadata.ts +2 -1
  474. package/src/generated/model/listFlowDefinitions200FlowDefinitionsItemUserSchemaSchema.ts +21 -20
  475. package/src/generated/model/listFlowDefinitionsExpandItem.ts +2 -2
  476. package/src/generated/model/listFlowDefinitionsParams.ts +8 -6
  477. package/src/generated/model/listIdpRevisions200.ts +1 -2
  478. package/src/generated/model/listIdpRevisions200RevisionsItem.ts +10 -9
  479. package/src/generated/model/listIdpRevisions200RevisionsItemDefinition.ts +7 -7
  480. package/src/generated/model/listIdpRevisions200RevisionsItemDefinitionClaimMapping.ts +1 -1
  481. package/src/generated/model/listIdpRevisions200RevisionsItemDefinitionOidc.ts +7 -7
  482. package/src/generated/model/listIdpRevisions200RevisionsItemDefinitionOidcStaticAuthorizeParameters.ts +1 -1
  483. package/src/generated/model/listIdpRevisions200RevisionsItemDefinitionProvisioning.ts +1 -1
  484. package/src/generated/model/listIdpRevisions200RevisionsItemDefinitionVerifiedClaims.ts +1 -1
  485. package/src/generated/model/listIdpRevisionsParams.ts +3 -1
  486. package/src/generated/model/listMyIdentityLinks200IdentityLinksItem.ts +2 -2
  487. package/src/generated/model/listMyProjects200.ts +1 -1
  488. package/src/generated/model/listMyProjects200ProjectsItem.ts +2 -3
  489. package/src/generated/model/listMyProjects200ProjectsItemOriginsItem.ts +17 -5
  490. package/src/generated/model/listMyProjects200ProjectsItemOriginsItemKind.ts +4 -0
  491. package/src/generated/model/listMyProjects200ProjectsItemPasswordHash.ts +12 -15
  492. package/src/generated/model/listMyProjects200ProjectsItemPasswordHashAlgorithm.ts +1 -1
  493. package/src/generated/model/listMyProjects200ProjectsItemPasswordHashParams.ts +15 -18
  494. package/src/generated/model/listMyProjects200ProjectsItemPasswordHashParamsHash.ts +4 -4
  495. package/src/generated/model/listMyTeams200TeamsItem.ts +4 -4
  496. package/src/generated/model/listPolicies200.ts +2 -2
  497. package/src/generated/model/listPolicies200PoliciesItem.ts +3 -3
  498. package/src/generated/model/listPoliciesParams.ts +3 -1
  499. package/src/generated/model/listPolicyRevisions200.ts +1 -1
  500. package/src/generated/model/listPolicyRevisions200RevisionsItem.ts +3 -3
  501. package/src/generated/model/listPolicyRevisionsParams.ts +3 -1
  502. package/src/generated/model/listPreviews200PreviewsItem.ts +4 -5
  503. package/src/generated/model/listProjectAdmins200AdminsItem.ts +3 -3
  504. package/src/generated/model/listProjectAdmins200AdminsItemSourcesItem.ts +13 -15
  505. package/src/generated/model/listProjectAdmins200AdminsItemUser.ts +5 -5
  506. package/src/generated/model/listReleases200.ts +1 -1
  507. package/src/generated/model/listReleases200ReleasesItem.ts +4 -4
  508. package/src/generated/model/listReleases200ReleasesItemMetadata.ts +8 -8
  509. package/src/generated/model/listReleasesParams.ts +4 -2
  510. package/src/generated/model/listSchemas200.ts +1 -1
  511. package/src/generated/model/listSchemas200SchemasItem.ts +4 -4
  512. package/src/generated/model/listSchemas200SchemasItemMetadata.ts +2 -1
  513. package/src/generated/model/listSchemas200SchemasItemSchema.ts +21 -20
  514. package/src/generated/model/listSchemasExpandItem.ts +2 -2
  515. package/src/generated/model/listSchemasParams.ts +7 -5
  516. package/src/generated/model/listUserIdentityLinks200IdentityLinksItem.ts +2 -2
  517. package/src/generated/model/listUserTeams200TeamsItem.ts +4 -4
  518. package/src/generated/model/patchMyUser200.ts +28 -29
  519. package/src/generated/model/patchMyUser200Metadata.ts +10 -11
  520. package/src/generated/model/patchMyUser200MetadataLifecycleOwnerTeam.ts +11 -12
  521. package/src/generated/model/patchMyUser200MetadataLifecycleOwnerTeamStatus.ts +2 -2
  522. package/src/generated/model/patchMyUser200TeamsItem.ts +4 -4
  523. package/src/generated/model/patchMyUserBody.ts +2 -2
  524. package/src/generated/model/patchProject200.ts +34 -30
  525. package/src/generated/model/patchProjectBody.ts +3 -3
  526. package/src/generated/model/patchProjectBodyPasswordHash.ts +15 -18
  527. package/src/generated/model/patchProjectBodyPasswordHashAlgorithm.ts +1 -1
  528. package/src/generated/model/patchProjectBodyPasswordHashParams.ts +15 -18
  529. package/src/generated/model/patchProjectBodyPasswordHashParamsHash.ts +4 -4
  530. package/src/generated/model/patchUserByID200.ts +28 -29
  531. package/src/generated/model/patchUserByID200Metadata.ts +10 -11
  532. package/src/generated/model/patchUserByID200MetadataLifecycleOwnerTeam.ts +11 -12
  533. package/src/generated/model/patchUserByID200MetadataLifecycleOwnerTeamStatus.ts +2 -2
  534. package/src/generated/model/patchUserByID200TeamsItem.ts +4 -4
  535. package/src/generated/model/patchUserByIDBody.ts +21 -13
  536. package/src/generated/model/publishPolicy201.ts +3 -3
  537. package/src/generated/model/publishPolicyBody.ts +3 -3
  538. package/src/generated/model/publishPolicyParams.ts +3 -1
  539. package/src/generated/model/queryGrants200GrantsItem.ts +14 -14
  540. package/src/generated/model/queryGrants200GrantsItemObjectType.ts +1 -1
  541. package/src/generated/model/queryGrants200GrantsItemRelation.ts +1 -1
  542. package/src/generated/model/queryGrants200GrantsItemTeam.ts +7 -7
  543. package/src/generated/model/queryGrants200GrantsItemTeamStatus.ts +2 -2
  544. package/src/generated/model/queryGrants200GrantsItemUser.ts +5 -5
  545. package/src/generated/model/queryGrants200GrantsItemUserMetadata.ts +10 -11
  546. package/src/generated/model/queryGrants200GrantsItemUserMetadataLifecycleOwnerTeam.ts +11 -12
  547. package/src/generated/model/queryGrants200GrantsItemUserMetadataLifecycleOwnerTeamStatus.ts +2 -2
  548. package/src/generated/model/queryGrantsBody.ts +2 -3
  549. package/src/generated/model/queryGrantsBodyExpandItem.ts +8 -5
  550. package/src/generated/model/queryGrantsBodyFilterItem.ts +3 -5
  551. package/src/generated/model/queryGrantsBodyFilterItemOperation.ts +1 -2
  552. package/src/generated/model/queryGrantsDefault.ts +0 -9
  553. package/src/generated/model/queryGrantsParams.ts +3 -1
  554. package/src/generated/model/queryIdps200.ts +1 -1
  555. package/src/generated/model/queryIdps200IdpsItem.ts +10 -9
  556. package/src/generated/model/queryIdps200IdpsItemDefinition.ts +7 -7
  557. package/src/generated/model/queryIdps200IdpsItemDefinitionClaimMapping.ts +1 -1
  558. package/src/generated/model/queryIdps200IdpsItemDefinitionOidc.ts +7 -7
  559. package/src/generated/model/queryIdps200IdpsItemDefinitionOidcStaticAuthorizeParameters.ts +1 -1
  560. package/src/generated/model/queryIdps200IdpsItemDefinitionProvisioning.ts +1 -1
  561. package/src/generated/model/queryIdps200IdpsItemDefinitionVerifiedClaims.ts +1 -1
  562. package/src/generated/model/queryIdpsBody.ts +2 -2
  563. package/src/generated/model/queryIdpsBodyFilterItem.ts +5 -7
  564. package/src/generated/model/queryIdpsBodyFilterItemField.ts +2 -2
  565. package/src/generated/model/queryIdpsBodyFilterItemOperation.ts +1 -2
  566. package/src/generated/model/queryIdpsBodySorting.ts +2 -2
  567. package/src/generated/model/queryIdpsBodySortingField.ts +2 -2
  568. package/src/generated/model/queryIdpsParams.ts +3 -1
  569. package/src/generated/model/queryProjects200ProjectsItem.ts +2 -3
  570. package/src/generated/model/queryProjects200ProjectsItemOriginsItem.ts +17 -5
  571. package/src/generated/model/queryProjects200ProjectsItemOriginsItemKind.ts +4 -0
  572. package/src/generated/model/queryProjects200ProjectsItemPasswordHash.ts +12 -15
  573. package/src/generated/model/queryProjects200ProjectsItemPasswordHashAlgorithm.ts +1 -1
  574. package/src/generated/model/queryProjects200ProjectsItemPasswordHashParams.ts +15 -18
  575. package/src/generated/model/queryProjects200ProjectsItemPasswordHashParamsHash.ts +4 -4
  576. package/src/generated/model/queryProjectsBodyFilterItem.ts +3 -5
  577. package/src/generated/model/queryProjectsBodyFilterItemOperation.ts +1 -2
  578. package/src/generated/model/querySessions200SessionsItem.ts +16 -16
  579. package/src/generated/model/querySessions200SessionsItemFactorsItem.ts +2 -2
  580. package/src/generated/model/querySessions200SessionsItemFactorsItemPayload.ts +5 -5
  581. package/src/generated/model/querySessions200SessionsItemState.ts +1 -1
  582. package/src/generated/model/querySessions200SessionsItemUser.ts +5 -5
  583. package/src/generated/model/querySessionsBodyFilterItem.ts +4 -6
  584. package/src/generated/model/querySessionsBodyFilterItemField.ts +1 -1
  585. package/src/generated/model/querySessionsBodyFilterItemOperation.ts +1 -2
  586. package/src/generated/model/querySessionsBodySorting.ts +2 -3
  587. package/src/generated/model/querySessionsBodySortingField.ts +2 -3
  588. package/src/generated/model/querySessionsParams.ts +3 -1
  589. package/src/generated/model/queryTeams200TeamsItem.ts +2 -2
  590. package/src/generated/model/queryTeams200TeamsItemStatus.ts +2 -2
  591. package/src/generated/model/queryTeamsBodyFilterItem.ts +3 -5
  592. package/src/generated/model/queryTeamsBodyFilterItemOperation.ts +1 -2
  593. package/src/generated/model/queryTeamsParams.ts +2 -2
  594. package/src/generated/model/queryUsers200UsersItem.ts +28 -29
  595. package/src/generated/model/queryUsers200UsersItemMetadata.ts +10 -11
  596. package/src/generated/model/queryUsers200UsersItemMetadataLifecycleOwnerTeam.ts +11 -12
  597. package/src/generated/model/queryUsers200UsersItemMetadataLifecycleOwnerTeamStatus.ts +2 -2
  598. package/src/generated/model/queryUsers200UsersItemTeamsItem.ts +4 -4
  599. package/src/generated/model/queryUsersBody.ts +2 -2
  600. package/src/generated/model/queryUsersBodyExpandItem.ts +8 -8
  601. package/src/generated/model/queryUsersBodyFilterItem.ts +13 -16
  602. package/src/generated/model/queryUsersBodyFilterItemField.ts +10 -11
  603. package/src/generated/model/queryUsersBodyFilterItemOperation.ts +1 -2
  604. package/src/generated/model/queryUsersBodySorting.ts +4 -5
  605. package/src/generated/model/queryUsersBodySortingField.ts +4 -5
  606. package/src/generated/model/queryUsersParams.ts +2 -2
  607. package/src/generated/model/removeOriginBody.ts +2 -2
  608. package/src/generated/model/revokeRelease200.ts +15 -15
  609. package/src/generated/model/revokeRelease200Metadata.ts +8 -8
  610. package/src/generated/model/revokeRelease200PointersItem.ts +13 -12
  611. package/src/generated/model/revokeRelease200PointersItemKind.ts +3 -3
  612. package/src/generated/model/revokeReleaseParams.ts +3 -1
  613. package/src/generated/model/rollbackDeployment200.ts +16 -14
  614. package/src/generated/model/rollbackDeployment200Metadata.ts +1 -1
  615. package/src/generated/model/rollbackDeployment200Release.ts +15 -15
  616. package/src/generated/model/rollbackDeployment200ReleaseMetadata.ts +8 -8
  617. package/src/generated/model/rollbackDeployment200ReleasePointersItem.ts +13 -12
  618. package/src/generated/model/rollbackDeployment200ReleasePointersItemKind.ts +3 -3
  619. package/src/generated/model/rollbackDeployment200Status.ts +3 -3
  620. package/src/generated/model/rollbackDeployment201.ts +16 -14
  621. package/src/generated/model/rollbackDeployment201Metadata.ts +1 -1
  622. package/src/generated/model/rollbackDeployment201Release.ts +15 -15
  623. package/src/generated/model/rollbackDeployment201ReleaseMetadata.ts +8 -8
  624. package/src/generated/model/rollbackDeployment201ReleasePointersItem.ts +13 -12
  625. package/src/generated/model/rollbackDeployment201ReleasePointersItemKind.ts +3 -3
  626. package/src/generated/model/rollbackDeployment201Status.ts +3 -3
  627. package/src/generated/model/rollbackDeployment409.ts +41 -40
  628. package/src/generated/model/rollbackDeploymentParams.ts +3 -1
  629. package/src/generated/model/setUserPasswordBody.ts +1 -1
  630. package/src/generated/model/setUserPasswordDefault.ts +63 -0
  631. package/src/generated/model/submitFlowStep200.ts +16 -12
  632. package/src/generated/model/submitFlowStep200Branding.ts +24 -22
  633. package/src/generated/model/submitFlowStep200BrandingLayout.ts +8 -7
  634. package/src/generated/model/submitFlowStep200BrandingShape.ts +1 -1
  635. package/src/generated/model/submitFlowStep200BrandingTheme.ts +5 -7
  636. package/src/generated/model/submitFlowStep200BrandingThemeDark.ts +7 -7
  637. package/src/generated/model/submitFlowStep200BrandingThemeDarkPalette.ts +63 -62
  638. package/src/generated/model/submitFlowStep200BrandingThemeLight.ts +7 -7
  639. package/src/generated/model/submitFlowStep200BrandingThemeLightPalette.ts +63 -62
  640. package/src/generated/model/submitFlowStep200BrandingTypography.ts +4 -4
  641. package/src/generated/model/submitFlowStep200Step.ts +36 -31
  642. package/src/generated/model/submitFlowStep200StepActionsItem.ts +3 -3
  643. package/src/generated/model/submitFlowStep200StepActionsItemKind.ts +1 -1
  644. package/src/generated/model/submitFlowStep200StepChallenge.ts +4 -3
  645. package/src/generated/model/submitFlowStep200StepComplete.ts +1 -1
  646. package/src/generated/model/submitFlowStep200StepFieldsItem.ts +14 -13
  647. package/src/generated/model/submitFlowStep200StepFieldsItemType.ts +1 -1
  648. package/src/generated/model/submitFlowStep200StepFieldsItemValidation.ts +2 -2
  649. package/src/generated/model/submitFlowStep200StepFieldsItemValidationFormat.ts +1 -1
  650. package/src/generated/model/submitFlowStep200StepGates.ts +10 -8
  651. package/src/generated/model/submitFlowStep200StepGatesConfig.ts +1 -1
  652. package/src/generated/model/submitFlowStep200StepGatesKind.ts +4 -3
  653. package/src/generated/model/submitFlowStep200StepIdentifier.ts +6 -6
  654. package/src/generated/model/submitFlowStep200StepSsoProvidersItem.ts +1 -1
  655. package/src/generated/model/submitFlowStep200StepTexts.ts +1 -1
  656. package/src/generated/model/submitFlowStep400.ts +16 -12
  657. package/src/generated/model/submitFlowStep400Branding.ts +24 -22
  658. package/src/generated/model/submitFlowStep400BrandingLayout.ts +8 -7
  659. package/src/generated/model/submitFlowStep400BrandingShape.ts +1 -1
  660. package/src/generated/model/submitFlowStep400BrandingTheme.ts +5 -7
  661. package/src/generated/model/submitFlowStep400BrandingThemeDark.ts +7 -7
  662. package/src/generated/model/submitFlowStep400BrandingThemeDarkPalette.ts +63 -62
  663. package/src/generated/model/submitFlowStep400BrandingThemeLight.ts +7 -7
  664. package/src/generated/model/submitFlowStep400BrandingThemeLightPalette.ts +63 -62
  665. package/src/generated/model/submitFlowStep400BrandingTypography.ts +4 -4
  666. package/src/generated/model/submitFlowStep400Step.ts +36 -31
  667. package/src/generated/model/submitFlowStep400StepActionsItem.ts +3 -3
  668. package/src/generated/model/submitFlowStep400StepActionsItemKind.ts +1 -1
  669. package/src/generated/model/submitFlowStep400StepChallenge.ts +4 -3
  670. package/src/generated/model/submitFlowStep400StepComplete.ts +1 -1
  671. package/src/generated/model/submitFlowStep400StepFieldsItem.ts +14 -13
  672. package/src/generated/model/submitFlowStep400StepFieldsItemType.ts +1 -1
  673. package/src/generated/model/submitFlowStep400StepFieldsItemValidation.ts +2 -2
  674. package/src/generated/model/submitFlowStep400StepFieldsItemValidationFormat.ts +1 -1
  675. package/src/generated/model/submitFlowStep400StepGates.ts +10 -8
  676. package/src/generated/model/submitFlowStep400StepGatesConfig.ts +1 -1
  677. package/src/generated/model/submitFlowStep400StepGatesKind.ts +4 -3
  678. package/src/generated/model/submitFlowStep400StepIdentifier.ts +6 -6
  679. package/src/generated/model/submitFlowStep400StepSsoProvidersItem.ts +1 -1
  680. package/src/generated/model/submitFlowStep400StepTexts.ts +1 -1
  681. package/src/generated/model/submitFlowStepBody.ts +10 -7
  682. package/src/generated/model/submitFlowStepBodyChallengeResponse.ts +2 -2
  683. package/src/generated/model/submitFlowStepBodyGateProofs.ts +1 -1
  684. package/src/generated/model/submitFlowStepDefault.ts +18 -0
  685. package/src/generated/model/updateTeam200.ts +2 -2
  686. package/src/generated/model/updateTeam200Status.ts +2 -2
  687. package/src/generated/model/updateTeamBody.ts +1 -1
  688. package/src/generated/model/updateVariables200.ts +4 -4
  689. package/src/generated/model/updateVariables200Preview.ts +2 -2
  690. package/src/generated/model/updateVariables200Primary.ts +2 -2
  691. package/src/generated/model/updateVariablesBody.ts +14 -14
  692. package/src/generated/model/updateVariablesParams.ts +3 -1
  693. package/src/generated/model/userProperty.ts +5 -8
  694. package/src/generated/model/userPropertyProperties.ts +2 -2
  695. package/src/generated/model/userPropertyXUnique.ts +1 -1
  696. package/src/generated/model/verifyChallengeProof200.ts +23 -22
  697. package/src/generated/model/verifyChallengeProof200ChallengesItem.ts +9 -7
  698. package/src/generated/model/verifyChallengeProof200ChallengesItemState.ts +1 -1
  699. package/src/generated/model/verifyChallengeProof200CompletedFactorsItem.ts +2 -2
  700. package/src/generated/model/verifyChallengeProof200CompletedFactorsItemPayload.ts +5 -5
  701. package/src/generated/model/verifyChallengeProof200State.ts +2 -2
  702. package/src/generated/model/verifyChallengeProofBody.ts +2 -2
  703. package/src/generated/operations.ts +277 -152
  704. package/src/runtime/api-factory.spec.ts +50 -0
  705. package/src/runtime/api-factory.ts +11 -2
  706. package/src/runtime/base-url.spec.ts +1 -1
  707. package/src/runtime/fetch.ts +16 -0
  708. package/src/runtime/paged.spec.ts +11 -0
  709. package/src/runtime/paged.ts +9 -8
  710. package/src/runtime/paging.spec.ts +164 -39
  711. package/src/runtime/paging.ts +162 -43
  712. package/dist/api-factory-C5b1Gqwv.mjs.map +0 -1
  713. package/dist/fetch-B-lgjlrf.d.mts.map +0 -1
  714. package/dist/zitadelNextGen-BVO4sdKD.d.mts +0 -1367
  715. package/dist/zitadelNextGen-BVO4sdKD.d.mts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { a as ZitadelApi, c as createApi, i as PagedOperation, l as createZitadelClient, n as PageOf, o as ZitadelClient, r as Paged, s as ZitadelClientOptions, t as ItemOf, u as paging } from "../api-factory-Dt5lUjyu.mjs";
1
+ import { a as ZitadelApi, c as createApi, i as PagedOperation, l as createZitadelClient, n as PageOf, o as ZitadelClient, r as Paged, s as ZitadelClientOptions, t as ItemOf, u as paging } from "../api-factory-DbVEEqxe.mjs";
2
2
  export { ItemOf, PageOf, Paged, PagedOperation, ZitadelApi, ZitadelClient, ZitadelClientOptions, createApi, createZitadelClient, paging as pagedFunctions };
@@ -1,3 +1,3 @@
1
1
  import "./base-url.mjs";
2
- import { n as createZitadelClient, r as paging, t as createApi } from "../api-factory-C5b1Gqwv.mjs";
2
+ import { n as createZitadelClient, r as paging, t as createApi } from "../api-factory-32Zz3s86.mjs";
3
3
  export { createApi, createZitadelClient, paging as pagedFunctions };
@@ -1,4 +1,4 @@
1
- import { a as ZitadelApi } from "../api-factory-Dt5lUjyu.mjs";
1
+ import { a as ZitadelApi } from "../api-factory-DbVEEqxe.mjs";
2
2
  //#region src/runtime/config.d.ts
3
3
  /**
4
4
  * Input options for {@link configureZitadel}.
@@ -1,5 +1,5 @@
1
1
  import { setProxyPath } from "./base-url.mjs";
2
- import { n as createZitadelClient } from "../api-factory-C5b1Gqwv.mjs";
2
+ import { n as createZitadelClient } from "../api-factory-32Zz3s86.mjs";
3
3
  //#region src/runtime/config.ts
4
4
  /**
5
5
  * Slot for the configured project, stored on `globalThis` under a
@@ -1,2 +1,2 @@
1
- import { a as RequestPolicy, c as customFetch, i as NetworkErrorReason, l as request, n as CSRF_HEADER, o as apiErrorCode, r as NetworkError, s as apiErrorMessage, t as ApiError, u as setRequestPolicy } from "../fetch-B-lgjlrf.mjs";
1
+ import { a as RequestPolicy, c as customFetch, i as NetworkErrorReason, l as request, n as CSRF_HEADER, o as apiErrorCode, r as NetworkError, s as apiErrorMessage, t as ApiError, u as setRequestPolicy } from "../fetch-BzLvdm6C.mjs";
2
2
  export { ApiError, CSRF_HEADER, NetworkError, NetworkErrorReason, RequestPolicy, apiErrorCode, apiErrorMessage, customFetch, request, setRequestPolicy };
@@ -99,6 +99,7 @@ async function customFetch(url, options) {
99
99
  const policy = requestPolicy;
100
100
  const token = getApiAuthToken();
101
101
  const headers = new Headers(options.headers);
102
+ if (policy.userAgent !== void 0) headers.set("user-agent", policy.userAgent);
102
103
  if (token && !headers.has("authorization")) headers.set("authorization", `Bearer ${token}`);
103
104
  const method = (options.method ?? "GET").toUpperCase();
104
105
  const unsafe = !SAFE_METHODS.has(method) && !headers.has("X-Zitadel-CSRF");
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.mjs","names":[],"sources":["../../src/runtime/fetch.ts"],"sourcesContent":["import { apiCsrfRejectionHandlerFor, apiCsrfTokenFor, getApiAuthToken } from \"./auth\";\nimport { API_PREFIX } from \"./base-url\";\n\n/** The header the session-bound CSRF token travels in (ADR 053 §5). */\nexport const CSRF_HEADER = \"X-Zitadel-CSRF\";\n\n// Mirrors the server's list (`httputil.IsSafeMethod` in `internal/httputil`).\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** The code the server answers a refused CSRF check with. */\nconst CSRF_INVALID = \"auth.csrf_invalid\";\n\n/** The code the server answers a path no operation of its version has with (ADR 076). */\nconst ROUTE_NOT_FOUND = \"req.not_found\";\n\n/**\n * Framework-neutral failure type the orval-generated client throws on\n * any non-2xx response. Carries the HTTP status, the parsed error body\n * (the spec's `{code, message, details?}` envelope when the server\n * returned one), and the request URL — enough for callers to map to\n * their own error taxonomy without re-implementing the fetch layer.\n *\n * Callers that don't care about the distinction can catch `ApiError`\n * generically; callers that do (the CLI's `toZitadelError`) read\n * `status` and decide.\n */\nexport class ApiError extends Error {\n readonly status: number;\n readonly url: string;\n readonly body: unknown;\n /**\n * The server's ID for the request, from its `X-Request-Id` header: the\n * reference that finds the request in the server's logs, to show beside the\n * error. `undefined` when the response carried none, as from a proxy.\n */\n readonly requestId: string | undefined;\n\n constructor(status: number, url: string, body: unknown, message: string, requestId?: string) {\n super(message);\n this.name = \"ApiError\";\n this.status = status;\n this.url = url;\n this.body = body;\n this.requestId = requestId;\n }\n}\n\n/**\n * Thrown when a request got no usable response: the connection was refused or\n * reset, the host did not resolve, the server accepted the connection but did\n * not answer in time, or it answered with a body that could not be read. The\n * counterpart to {@link ApiError}, which is a response that came back with a\n * failing status.\n *\n * `fetch` only rejects when no response arrived, and reading the body only\n * when the body broke off or could not be decoded, so this is decided by which\n * of the two rejected, never by how a runtime words the failure. The runtime's\n * own error stays on `cause` for debugging.\n */\nexport class NetworkError extends Error {\n readonly url: string;\n /**\n * `timeout` when a deadline cut the request off, `unreadable` when a response\n * arrived but its body could not be read (a proxy that labels a decoded body\n * as compressed, say), `unreachable` otherwise.\n */\n readonly reason: NetworkErrorReason;\n\n constructor(url: string, reason: NetworkErrorReason, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n this.url = url;\n this.reason = reason;\n }\n}\n\n/** Why a {@link NetworkError} got no usable response. */\nexport type NetworkErrorReason = \"unreachable\" | \"unreadable\" | \"timeout\";\n\n/**\n * What every request a client makes is bound by. Set per call by\n * `createZitadelClient`, the same way as the base URL and token, and read at\n * the top of {@link customFetch} before its first `await`.\n */\nexport type RequestPolicy = {\n /** Aborts every request made while it is set; its reason is rethrown as is. */\n signal?: AbortSignal;\n /** Per-request deadline, covering the response body as well as the headers. */\n timeoutMs?: number;\n};\n\nlet requestPolicy: RequestPolicy = {};\n\nexport function setRequestPolicy(policy: RequestPolicy): void {\n requestPolicy = policy;\n}\n\n/**\n * The orval `mutator` for the fetch client. Every generated operation\n * routes its request through this function instead of the global\n * `fetch`. We pin three concerns here so generated call sites stay\n * focused on the shape of one HTTP call:\n *\n * - bearer auth — read from `runtime/auth.ts` and attached automatically;\n * - the CSRF header — the session-bound token from `runtime/auth.ts`, on\n * unsafe methods to the origin it was issued for, when a first-party surface\n * has set one; an unsafe request to that origin refused with\n * `403 auth.csrf_invalid` asks the registered rejection handler for a fresh\n * token and is retried once with it, only if the handler returns one (the\n * session still belongs to the same person);\n * - non-2xx → throw — orval's stock client parses the body regardless\n * of status, so callers would have to inspect every response. Throw\n * `ApiError` on `!res.ok` so failures interrupt control flow;\n * - body parsing — return the parsed JSON typed as `T` (the operation's\n * return type, threaded through by orval), or `undefined` for the\n * spec's `204`/`205`/`304` no-body responses;\n * - no response → throw {@link NetworkError}, or the abort reason when the\n * caller cancelled (see {@link request}).\n */\nexport async function customFetch<T>(url: string, options: RequestInit): Promise<T> {\n // The client sets the policy per call, so it is read before the first await;\n // the retry below runs under the same policy as the first attempt.\n const policy = requestPolicy;\n const token = getApiAuthToken();\n const headers = new Headers(options.headers);\n if (token && !headers.has(\"authorization\")) {\n headers.set(\"authorization\", `Bearer ${token}`);\n }\n const method = (options.method ?? \"GET\").toUpperCase();\n const unsafe = !SAFE_METHODS.has(method) && !headers.has(CSRF_HEADER);\n // The token and the rejection handler belong to one server: a request to\n // any other origin gets neither.\n const target = originOf(url);\n const csrfToken = apiCsrfTokenFor(target);\n if (unsafe && csrfToken) {\n headers.set(CSRF_HEADER, csrfToken);\n }\n\n let { res, rawBody: parsed } = await request(url, { ...options, headers }, policy, readBody);\n\n // The token was stale (the session cookie changed under this page) or never\n // loaded. The app re-checks the session and hands back a fresh token only if\n // it still belongs to the same person; then the request is retried once. A\n // body that can be read only once cannot be sent again, so it is not retried.\n const onRejected = apiCsrfRejectionHandlerFor(target);\n if (\n unsafe &&\n onRejected &&\n res.status === 403 &&\n apiErrorCode(parsed) === CSRF_INVALID &&\n !isStream(options.body)\n ) {\n const fresh = await onRejected().catch(() => undefined);\n if (fresh && fresh !== csrfToken) {\n headers.set(CSRF_HEADER, fresh);\n ({ res, rawBody: parsed } = await request(url, { ...options, headers }, policy, readBody));\n }\n }\n\n if (!res.ok) {\n // Every operation this client calls is one the spec has, so a server that\n // knows no such path is another version, most likely one from before the\n // API moved under its prefix.\n const message =\n res.status === 404 && apiErrorCode(parsed) === ROUTE_NOT_FOUND\n ? `${options.method ?? \"GET\"} ${url} returned 404 (${ROUTE_NOT_FOUND}): the server has no such operation; a server older than this client does not serve the API under ${API_PREFIX}`\n : `${options.method ?? \"GET\"} ${url} returned ${res.status}`;\n throw new ApiError(\n res.status,\n url,\n parsed,\n message,\n res.headers.get(\"x-request-id\") || undefined,\n );\n }\n\n // The body is trusted to have the shape the generated types promise; no\n // response is checked here or by the paged functions. Should that change,\n // check it here, against the generated Zod response schemas, so every call\n // is covered.\n return parsed as T;\n}\n\n/** The parsed body, or `undefined` for the spec's no-body responses. */\nasync function readBody(res: Response): Promise<unknown> {\n if ([204, 205, 304].includes(res.status)) return undefined;\n const rawBody = await res.text();\n return rawBody ? (safeJsonParse(rawBody) as unknown) : undefined;\n}\n\n/** The request's origin, resolved against the page for a relative URL. */\nfunction originOf(url: string): string | undefined {\n try {\n return new URL(url, (globalThis as { location?: { href?: string } }).location?.href).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction isStream(body: RequestInit[\"body\"]): boolean {\n return typeof ReadableStream !== \"undefined\" && body instanceof ReadableStream;\n}\n\n/**\n * `fetch` bound by a {@link RequestPolicy}, with its failures typed.\n *\n * The policy's signal, its deadline and any signal on `init` are combined, and\n * `read` runs under them too, so a server that sends headers and then stalls\n * mid-body is cut off as well. When the request does not complete:\n *\n * - a deadline fired → {@link NetworkError} with reason `timeout`;\n * - any other abort → the signal's own reason, rethrown untouched, because a\n * cancellation is the caller's decision and the caller knows what it means;\n * - a response arrived but `read` failed → {@link NetworkError} with reason\n * `unreadable`, naming the status that did come back;\n * - anything else → {@link NetworkError} with reason `unreachable`.\n *\n * Exported for the few callers that need the raw {@link Response} (a\n * `Set-Cookie` header the generated client does not expose).\n */\nexport async function request<R = undefined>(\n url: string,\n init: RequestInit,\n policy: RequestPolicy = {},\n read?: (res: Response) => Promise<R>,\n): Promise<{ res: Response; rawBody: R }> {\n const signals = [init.signal, policy.signal].filter((signal) => signal != null);\n if (policy.timeoutMs !== undefined) {\n signals.push(AbortSignal.timeout(policy.timeoutMs));\n }\n const signal = signals.length > 0 ? AbortSignal.any(signals) : undefined;\n const method = init.method ?? \"GET\";\n let res: Response;\n try {\n res = await fetch(url, { ...init, signal });\n } catch (error) {\n throw failure(error, signal, method, url, \"unreachable\", \"got no response\");\n }\n try {\n return { res, rawBody: (read ? await read(res) : undefined) as R };\n } catch (error) {\n const what = `answered ${res.status}, but its body could not be read`;\n throw failure(error, signal, method, url, \"unreadable\", what);\n }\n}\n\n/**\n * What {@link request} rejects with when `fetch` or `read` failed: the abort\n * as {@link request} describes it, or else a {@link NetworkError} of `reason`\n * saying `what` happened to the request.\n */\nfunction failure(\n error: unknown,\n signal: AbortSignal | undefined,\n method: string,\n url: string,\n reason: \"unreachable\" | \"unreadable\",\n what: string,\n): unknown {\n if (signal?.aborted) {\n const abort: unknown = signal.reason;\n if (abort instanceof DOMException && abort.name === \"TimeoutError\") {\n return new NetworkError(url, \"timeout\", `${method} ${url} timed out`, { cause: abort });\n }\n return abort;\n }\n const code = errnoOf(error);\n return new NetworkError(url, reason, `${method} ${url} ${what}${code ? ` (${code})` : \"\"}`, {\n cause: error,\n });\n}\n\n/**\n * The errno a runtime attached to a failed request, if any, for the message.\n * Undici nests it on `cause`, inside an `AggregateError` when it tried more\n * than one address. Only ever used to describe the failure, never to decide\n * that it was one.\n */\nfunction errnoOf(error: unknown): string | undefined {\n let node: unknown = error;\n for (let depth = 0; depth < 4 && typeof node === \"object\" && node !== null; depth += 1) {\n const { code, errors } = node as { code?: unknown; errors?: unknown };\n if (typeof code === \"string\") {\n return code;\n }\n node = Array.isArray(errors) ? errors[0] : (node as { cause?: unknown }).cause;\n }\n return undefined;\n}\n\n/**\n * `JSON.parse` wrapped so a non-JSON body (e.g. an HTML 502 from a\n * proxy) becomes `{ raw: \"<text>\" }` instead of throwing inside\n * `customFetch`. The thrown `ApiError` then carries something useful\n * for the user to see.\n */\nfunction safeJsonParse(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return { raw: text };\n }\n}\n\n/**\n * The `code` of the server's `{code, message, details}` error envelope: from an\n * {@link ApiError}, or from a parsed response body. `undefined` when there is\n * none, e.g. an HTML error page from a proxy.\n */\nexport function apiErrorCode(errorOrBody: unknown): string | undefined {\n const body = errorOrBody instanceof ApiError ? errorOrBody.body : errorOrBody;\n return isRecord(body) && typeof body.code === \"string\" ? body.code : undefined;\n}\n\n/**\n * Extracts the server's `{code, message, details}` envelope from an\n * {@link ApiError} into a display string. Falls back to the fetch layer's\n * `\"METHOD url returned N\"` when the body isn't shaped like an envelope, so\n * transport-level failures (HTML from a proxy, empty 5xx) still say\n * something.\n */\nexport function apiErrorMessage(error: ApiError): string {\n const body = error.body;\n if (!isRecord(body)) {\n return error.message;\n }\n const serverMessage = typeof body.message === \"string\" ? body.message : undefined;\n const detail = pickDetailString(body.details);\n if (!serverMessage) {\n return error.message;\n }\n return detail ? `${serverMessage}: ${detail}` : serverMessage;\n}\n\n/**\n * Reads the innermost human-readable string out of the spec's error\n * `details` field. Handles both `details: \"...\"` and the nested\n * `details: { details: \"...\" }` shape the platform emits for validation\n * failures.\n */\nfunction pickDetailString(details: unknown): string | undefined {\n if (typeof details === \"string\") {\n return details;\n }\n if (isRecord(details)) {\n if (typeof details.details === \"string\") {\n return details.details;\n }\n if (typeof details.message === \"string\") {\n return details.message;\n }\n }\n return undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;;;AAIA,MAAa,cAAc;AAG3B,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAS,CAAC;;AAGvD,MAAM,eAAe;;AAGrB,MAAM,kBAAkB;;;;;;;;;;;;AAaxB,IAAa,WAAb,cAA8B,MAAM;CAClC;CACA;CACA;;;;;;CAMA;CAEA,YAAY,QAAgB,KAAa,MAAe,SAAiB,WAAoB;EAC3F,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,MAAM;EACX,KAAK,OAAO;EACZ,KAAK,YAAY;CACnB;AACF;;;;;;;;;;;;;AAcA,IAAa,eAAb,cAAkC,MAAM;CACtC;;;;;;CAMA;CAEA,YAAY,KAAa,QAA4B,SAAiB,SAAwB;EAC5F,MAAM,SAAS,OAAO;EACtB,KAAK,OA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eACH,OAAO,MAAM;CAEf,OAAO,SAAS,GAAG,cAAc,IAAI,WAAW;AAClD;;;;;;;AAQA,SAAS,iBAAiB,SAAsC;CAC9D,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,SAAS,OAAO,GAAG;EACrB,IAAI,OAAO,QAAQ,YAAY,UAC7B,OAAO,QAAQ;EAEjB,IAAI,OAAO,QAAQ,YAAY,UAC7B,OAAO,QAAQ;CAEnB;AAEF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E"}
1
+ {"version":3,"file":"fetch.mjs","names":[],"sources":["../../src/runtime/fetch.ts"],"sourcesContent":["import { apiCsrfRejectionHandlerFor, apiCsrfTokenFor, getApiAuthToken } from \"./auth\";\nimport { API_PREFIX } from \"./base-url\";\n\n/** The header the session-bound CSRF token travels in (ADR 053 §5). */\nexport const CSRF_HEADER = \"X-Zitadel-CSRF\";\n\n// Mirrors the server's list (`httputil.IsSafeMethod` in `internal/httputil`).\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/** The code the server answers a refused CSRF check with. */\nconst CSRF_INVALID = \"auth.csrf_invalid\";\n\n/** The code the server answers a path no operation of its version has with (ADR 076). */\nconst ROUTE_NOT_FOUND = \"req.not_found\";\n\n/**\n * Framework-neutral failure type the orval-generated client throws on\n * any non-2xx response. Carries the HTTP status, the parsed error body\n * (the spec's `{code, message, details?}` envelope when the server\n * returned one), and the request URL — enough for callers to map to\n * their own error taxonomy without re-implementing the fetch layer.\n *\n * Callers that don't care about the distinction can catch `ApiError`\n * generically; callers that do (the CLI's `toZitadelError`) read\n * `status` and decide.\n */\nexport class ApiError extends Error {\n readonly status: number;\n readonly url: string;\n readonly body: unknown;\n /**\n * The server's ID for the request, from its `X-Request-Id` header: the\n * reference that finds the request in the server's logs, to show beside the\n * error. `undefined` when the response carried none, as from a proxy.\n */\n readonly requestId: string | undefined;\n\n constructor(status: number, url: string, body: unknown, message: string, requestId?: string) {\n super(message);\n this.name = \"ApiError\";\n this.status = status;\n this.url = url;\n this.body = body;\n this.requestId = requestId;\n }\n}\n\n/**\n * Thrown when a request got no usable response: the connection was refused or\n * reset, the host did not resolve, the server accepted the connection but did\n * not answer in time, or it answered with a body that could not be read. The\n * counterpart to {@link ApiError}, which is a response that came back with a\n * failing status.\n *\n * `fetch` only rejects when no response arrived, and reading the body only\n * when the body broke off or could not be decoded, so this is decided by which\n * of the two rejected, never by how a runtime words the failure. The runtime's\n * own error stays on `cause` for debugging.\n */\nexport class NetworkError extends Error {\n readonly url: string;\n /**\n * `timeout` when a deadline cut the request off, `unreadable` when a response\n * arrived but its body could not be read (a proxy that labels a decoded body\n * as compressed, say), `unreachable` otherwise.\n */\n readonly reason: NetworkErrorReason;\n\n constructor(url: string, reason: NetworkErrorReason, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n this.url = url;\n this.reason = reason;\n }\n}\n\n/** Why a {@link NetworkError} got no usable response. */\nexport type NetworkErrorReason = \"unreachable\" | \"unreadable\" | \"timeout\";\n\n/**\n * What every request a client makes is bound by. Set per call by\n * `createZitadelClient`, the same way as the base URL and token, and read at\n * the top of {@link customFetch} before its first `await`.\n */\nexport type RequestPolicy = {\n /** Aborts every request made while it is set; its reason is rethrown as is. */\n signal?: AbortSignal;\n /** Per-request deadline, covering the response body as well as the headers. */\n timeoutMs?: number;\n /**\n * Sent as the `User-Agent` of every request made while it is set.\n *\n * @remarks\n * This is one slot for the whole process, and a client identifies itself\n * through it, so two clients that identify differently share it. What keeps\n * them apart is that the slot is written immediately before a call and read\n * synchronously at the top of {@link customFetch}, before its first `await`:\n * no other client can run in between, and the retry below holds the copy it\n * read. Anything that writes the policy and then awaits before dispatching\n * would send one client's agent on another client's request.\n */\n userAgent?: string;\n};\n\nlet requestPolicy: RequestPolicy = {};\n\nexport function setRequestPolicy(policy: RequestPolicy): void {\n requestPolicy = policy;\n}\n\n/**\n * The orval `mutator` for the fetch client. Every generated operation\n * routes its request through this function instead of the global\n * `fetch`. We pin three concerns here so generated call sites stay\n * focused on the shape of one HTTP call:\n *\n * - bearer auth — read from `runtime/auth.ts` and attached automatically;\n * - the CSRF header — the session-bound token from `runtime/auth.ts`, on\n * unsafe methods to the origin it was issued for, when a first-party surface\n * has set one; an unsafe request to that origin refused with\n * `403 auth.csrf_invalid` asks the registered rejection handler for a fresh\n * token and is retried once with it, only if the handler returns one (the\n * session still belongs to the same person);\n * - non-2xx → throw — orval's stock client parses the body regardless\n * of status, so callers would have to inspect every response. Throw\n * `ApiError` on `!res.ok` so failures interrupt control flow;\n * - body parsing — return the parsed JSON typed as `T` (the operation's\n * return type, threaded through by orval), or `undefined` for the\n * spec's `204`/`205`/`304` no-body responses;\n * - no response → throw {@link NetworkError}, or the abort reason when the\n * caller cancelled (see {@link request}).\n */\nexport async function customFetch<T>(url: string, options: RequestInit): Promise<T> {\n // The client sets the policy per call, so it is read before the first await;\n // the retry below runs under the same policy as the first attempt.\n const policy = requestPolicy;\n const token = getApiAuthToken();\n const headers = new Headers(options.headers);\n if (policy.userAgent !== undefined) {\n headers.set(\"user-agent\", policy.userAgent);\n }\n if (token && !headers.has(\"authorization\")) {\n headers.set(\"authorization\", `Bearer ${token}`);\n }\n const method = (options.method ?? \"GET\").toUpperCase();\n const unsafe = !SAFE_METHODS.has(method) && !headers.has(CSRF_HEADER);\n // The token and the rejection handler belong to one server: a request to\n // any other origin gets neither.\n const target = originOf(url);\n const csrfToken = apiCsrfTokenFor(target);\n if (unsafe && csrfToken) {\n headers.set(CSRF_HEADER, csrfToken);\n }\n\n let { res, rawBody: parsed } = await request(url, { ...options, headers }, policy, readBody);\n\n // The token was stale (the session cookie changed under this page) or never\n // loaded. The app re-checks the session and hands back a fresh token only if\n // it still belongs to the same person; then the request is retried once. A\n // body that can be read only once cannot be sent again, so it is not retried.\n const onRejected = apiCsrfRejectionHandlerFor(target);\n if (\n unsafe &&\n onRejected &&\n res.status === 403 &&\n apiErrorCode(parsed) === CSRF_INVALID &&\n !isStream(options.body)\n ) {\n const fresh = await onRejected().catch(() => undefined);\n if (fresh && fresh !== csrfToken) {\n headers.set(CSRF_HEADER, fresh);\n ({ res, rawBody: parsed } = await request(url, { ...options, headers }, policy, readBody));\n }\n }\n\n if (!res.ok) {\n // Every operation this client calls is one the spec has, so a server that\n // knows no such path is another version, most likely one from before the\n // API moved under its prefix.\n const message =\n res.status === 404 && apiErrorCode(parsed) === ROUTE_NOT_FOUND\n ? `${options.method ?? \"GET\"} ${url} returned 404 (${ROUTE_NOT_FOUND}): the server has no such operation; a server older than this client does not serve the API under ${API_PREFIX}`\n : `${options.method ?? \"GET\"} ${url} returned ${res.status}`;\n throw new ApiError(\n res.status,\n url,\n parsed,\n message,\n res.headers.get(\"x-request-id\") || undefined,\n );\n }\n\n // The body is trusted to have the shape the generated types promise; no\n // response is checked here or by the paged functions. Should that change,\n // check it here, against the generated Zod response schemas, so every call\n // is covered.\n return parsed as T;\n}\n\n/** The parsed body, or `undefined` for the spec's no-body responses. */\nasync function readBody(res: Response): Promise<unknown> {\n if ([204, 205, 304].includes(res.status)) return undefined;\n const rawBody = await res.text();\n return rawBody ? (safeJsonParse(rawBody) as unknown) : undefined;\n}\n\n/** The request's origin, resolved against the page for a relative URL. */\nfunction originOf(url: string): string | undefined {\n try {\n return new URL(url, (globalThis as { location?: { href?: string } }).location?.href).origin;\n } catch {\n return undefined;\n }\n}\n\nfunction isStream(body: RequestInit[\"body\"]): boolean {\n return typeof ReadableStream !== \"undefined\" && body instanceof ReadableStream;\n}\n\n/**\n * `fetch` bound by a {@link RequestPolicy}, with its failures typed.\n *\n * The policy's signal, its deadline and any signal on `init` are combined, and\n * `read` runs under them too, so a server that sends headers and then stalls\n * mid-body is cut off as well. When the request does not complete:\n *\n * - a deadline fired → {@link NetworkError} with reason `timeout`;\n * - any other abort → the signal's own reason, rethrown untouched, because a\n * cancellation is the caller's decision and the caller knows what it means;\n * - a response arrived but `read` failed → {@link NetworkError} with reason\n * `unreadable`, naming the status that did come back;\n * - anything else → {@link NetworkError} with reason `unreachable`.\n *\n * Exported for the few callers that need the raw {@link Response} (a\n * `Set-Cookie` header the generated client does not expose).\n */\nexport async function request<R = undefined>(\n url: string,\n init: RequestInit,\n policy: RequestPolicy = {},\n read?: (res: Response) => Promise<R>,\n): Promise<{ res: Response; rawBody: R }> {\n const signals = [init.signal, policy.signal].filter((signal) => signal != null);\n if (policy.timeoutMs !== undefined) {\n signals.push(AbortSignal.timeout(policy.timeoutMs));\n }\n const signal = signals.length > 0 ? AbortSignal.any(signals) : undefined;\n const method = init.method ?? \"GET\";\n let res: Response;\n try {\n res = await fetch(url, { ...init, signal });\n } catch (error) {\n throw failure(error, signal, method, url, \"unreachable\", \"got no response\");\n }\n try {\n return { res, rawBody: (read ? await read(res) : undefined) as R };\n } catch (error) {\n const what = `answered ${res.status}, but its body could not be read`;\n throw failure(error, signal, method, url, \"unreadable\", what);\n }\n}\n\n/**\n * What {@link request} rejects with when `fetch` or `read` failed: the abort\n * as {@link request} describes it, or else a {@link NetworkError} of `reason`\n * saying `what` happened to the request.\n */\nfunction failure(\n error: unknown,\n signal: AbortSignal | undefined,\n method: string,\n url: string,\n reason: \"unreachable\" | \"unreadable\",\n what: string,\n): unknown {\n if (signal?.aborted) {\n const abort: unknown = signal.reason;\n if (abort instanceof DOMException && abort.name === \"TimeoutError\") {\n return new NetworkError(url, \"timeout\", `${method} ${url} timed out`, { cause: abort });\n }\n return abort;\n }\n const code = errnoOf(error);\n return new NetworkError(url, reason, `${method} ${url} ${what}${code ? ` (${code})` : \"\"}`, {\n cause: error,\n });\n}\n\n/**\n * The errno a runtime attached to a failed request, if any, for the message.\n * Undici nests it on `cause`, inside an `AggregateError` when it tried more\n * than one address. Only ever used to describe the failure, never to decide\n * that it was one.\n */\nfunction errnoOf(error: unknown): string | undefined {\n let node: unknown = error;\n for (let depth = 0; depth < 4 && typeof node === \"object\" && node !== null; depth += 1) {\n const { code, errors } = node as { code?: unknown; errors?: unknown };\n if (typeof code === \"string\") {\n return code;\n }\n node = Array.isArray(errors) ? errors[0] : (node as { cause?: unknown }).cause;\n }\n return undefined;\n}\n\n/**\n * `JSON.parse` wrapped so a non-JSON body (e.g. an HTML 502 from a\n * proxy) becomes `{ raw: \"<text>\" }` instead of throwing inside\n * `customFetch`. The thrown `ApiError` then carries something useful\n * for the user to see.\n */\nfunction safeJsonParse(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return { raw: text };\n }\n}\n\n/**\n * The `code` of the server's `{code, message, details}` error envelope: from an\n * {@link ApiError}, or from a parsed response body. `undefined` when there is\n * none, e.g. an HTML error page from a proxy.\n */\nexport function apiErrorCode(errorOrBody: unknown): string | undefined {\n const body = errorOrBody instanceof ApiError ? errorOrBody.body : errorOrBody;\n return isRecord(body) && typeof body.code === \"string\" ? body.code : undefined;\n}\n\n/**\n * Extracts the server's `{code, message, details}` envelope from an\n * {@link ApiError} into a display string. Falls back to the fetch layer's\n * `\"METHOD url returned N\"` when the body isn't shaped like an envelope, so\n * transport-level failures (HTML from a proxy, empty 5xx) still say\n * something.\n */\nexport function apiErrorMessage(error: ApiError): string {\n const body = error.body;\n if (!isRecord(body)) {\n return error.message;\n }\n const serverMessage = typeof body.message === \"string\" ? body.message : undefined;\n const detail = pickDetailString(body.details);\n if (!serverMessage) {\n return error.message;\n }\n return detail ? `${serverMessage}: ${detail}` : serverMessage;\n}\n\n/**\n * Reads the innermost human-readable string out of the spec's error\n * `details` field. Handles both `details: \"...\"` and the nested\n * `details: { details: \"...\" }` shape the platform emits for validation\n * failures.\n */\nfunction pickDetailString(details: unknown): string | undefined {\n if (typeof details === \"string\") {\n return details;\n }\n if (isRecord(details)) {\n if (typeof details.details === \"string\") {\n return details.details;\n }\n if (typeof details.message === \"string\") {\n return details.message;\n }\n }\n return undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null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,OAAO,SAAS,UAClB,OAAO;EAET,OAAO,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAM,KAA6B;CAC3E;AAEF;;;;;;;AAQA,SAAS,cAAc,MAAuB;CAC5C,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO,EAAE,KAAK,KAAK;CACrB;AACF;;;;;;AAOA,SAAgB,aAAa,aAA0C;CACrE,MAAM,OAAO,uBAAuB,WAAW,YAAY,OAAO;CAClE,OAAO,SAAS,IAAI,KAAK,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO,KAAA;AACvE;;;;;;;;AASA,SAAgB,gBAAgB,OAAyB;CACvD,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,SAAS,IAAI,GAChB,OAAO,MAAM;CAEf,MAAM,gBAAgB,OAAO,KAAK,YAAY,WAAW,KAAK,UAAU,KAAA;CACxE,MAAM,SAAS,iBAAiB,KAAK,OAAO;CAC5C,IAAI,CAAC,eACH,OAAO,MAAM;CAEf,OAAO,SAAS,GAAG,cAAc,IAAI,WAAW;AAClD;;;;;;;AAQA,SAAS,iBAAiB,SAAsC;CAC9D,IAAI,OAAO,YAAY,UACrB,OAAO;CAET,IAAI,SAAS,OAAO,GAAG;EACrB,IAAI,OAAO,QAAQ,YAAY,UAC7B,OAAO,QAAQ;EAEjB,IAAI,OAAO,QAAQ,YAAY,UAC7B,OAAO,QAAQ;CAEnB;AAEF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E"}
@@ -1,35 +1,118 @@
1
1
  //#region src/runtime/paging.d.ts
2
2
  /**
3
- * Cursor paging (ADR 027): a page carries `next_page_token` while more remain,
4
- * and the next request sends it back as `page_token`.
3
+ * Fetches the page a cursor names.
5
4
  *
6
- * The walk trusts that contract. A server that repeats a cursor, skips one or
7
- * answers a page in a different shape is an upstream bug to fix in the server,
8
- * not something the client detects or works around; do not add guards for it.
9
- * Typed callers read a page's list straight off it; only {@link itemsOf}, for
10
- * a caller that knows the list by name alone, checks it is there.
5
+ * @param token - The cursor of the page to fetch, or `undefined` for the first page.
6
+ * @param number - How many pages have been asked for, counting this one, from 1.
11
7
  */
12
- /** Fetches the page a cursor names; `undefined` asks for the first page. */
13
- export type FetchPage<P> = (token: string | undefined) => Promise<P>;
8
+ export type FetchPage<P> = (token: string | undefined, number: number) => Promise<P>;
14
9
  /**
15
- * The cursor to the page after `page`, or `undefined` on the last one. `field`
16
- * names it, for an API that calls it other than `next_page_token`.
10
+ * How to read one page of a list.
17
11
  */
18
- export declare function nextToken(page: unknown, field?: string): string | undefined;
12
+ export type PageReaders<P, T> = {
13
+ /** The items on `page`. */
14
+ readonly items: (page: P) => readonly T[];
15
+ /** The cursor to the page after `page`; none, `null` or an empty string when it is the last. */
16
+ readonly next: (page: P) => string | null | undefined;
17
+ };
19
18
  /**
20
- * The array `field` names on a page, for a caller that learns the field only
21
- * at runtime (an operation picked from a table); a page without one is not a
22
- * page of that list.
19
+ * What {@link Paging.collect} gathers from a walk.
23
20
  */
24
- export declare function itemsOf(page: unknown, field: string): readonly unknown[];
21
+ export type Collected<P, T> = {
22
+ /** The items of every page it read, in order. */
23
+ readonly items: readonly T[];
24
+ /** The cursor to the page after the last one it read, or `null` when none remains. */
25
+ readonly next: string | null;
26
+ /** The last page it read, or `undefined` when the walk yielded none. */
27
+ readonly last: P | undefined;
28
+ };
25
29
  /**
26
- * Every page, fetched only when the loop asks for the next one, so a caller
27
- * that stops early never reads the rest. The first page is the one
28
- * `fetchPage(undefined)` answers; `next` reads a page's cursor, and an empty
29
- * one ends the walk like none.
30
+ * A cursor-paged list (ADR 027): a page carries a cursor while more remain,
31
+ * and the request for the next page sends it back.
32
+ *
33
+ * A `Paging` knows how to read a page of one list, and from that how to walk
34
+ * the pages and how to gather them. Build one from readers when the page is
35
+ * typed, or from field names with {@link Paging.byField} when the list is only
36
+ * known at run time.
37
+ *
38
+ * The walk trusts the contract. A server that repeats a cursor, skips one or
39
+ * answers a page in a different shape is an upstream bug to fix in the server,
40
+ * not something the client detects or works around; do not add guards for it.
41
+ *
42
+ * @example
43
+ * const users = new Paging({
44
+ * items: (page: UsersPage) => page.users,
45
+ * next: (page) => page.next_page_token,
46
+ * });
47
+ * const { items } = await users.collect(users.walk(fetchUsers), { all: true });
30
48
  */
31
- export declare function pages<P>(fetchPage: FetchPage<P>, { next }?: {
32
- next?: (page: P) => string | undefined;
33
- }): AsyncGenerator<P, void, undefined>;
49
+ export declare class Paging<P, T = unknown> {
50
+ private readonly readers;
51
+ /**
52
+ * @param readers - How to read a page's items and its cursor.
53
+ */
54
+ constructor(readers: PageReaders<P, T>);
55
+ /**
56
+ * A paging for a list whose fields are known only by name, such as an
57
+ * operation picked from a table at run time. A page without the items
58
+ * field is not a page of that list.
59
+ *
60
+ * @param items - The name of the field holding a page's items.
61
+ * @param cursor - The name of the field holding the next cursor.
62
+ * @throws TypeError from {@link Paging.items} when the page has no such list.
63
+ * @example
64
+ * Paging.byField("users").items({ users: ["a", "b"] }); // ["a", "b"]
65
+ * Paging.byField("users").next({ next_page_token: "t1" }); // "t1"
66
+ */
67
+ static byField(items: string, cursor?: string): Paging<unknown>;
68
+ /**
69
+ * The items on `page`.
70
+ *
71
+ * @param page - A page of this list.
72
+ */
73
+ items(page: P): readonly T[];
74
+ /**
75
+ * The cursor to the page after `page`.
76
+ *
77
+ * @param page - A page of this list.
78
+ * @returns The cursor, or `undefined` when `page` is the last: no cursor,
79
+ * `null` and an empty string all mean the same.
80
+ */
81
+ next(page: P): string | undefined;
82
+ /**
83
+ * Every page, fetched only when the loop asks for the next one, so a caller
84
+ * that stops early never reads the rest. The first page is the one
85
+ * `fetchPage(undefined, 1)` answers.
86
+ *
87
+ * A page's cursor is read before the page is handed out, so a loop that
88
+ * changes the page cannot change where the walk goes.
89
+ *
90
+ * @param fetchPage - Fetches the page a cursor names, and is told which page
91
+ * of the walk it is.
92
+ */
93
+ walk(fetchPage: FetchPage<P>): AsyncGenerator<P, void, undefined>;
94
+ /**
95
+ * The first page of `pages`, or with `all` every page in order, as one list
96
+ * of their items, with the cursor to the page after the last one read and
97
+ * that last page itself.
98
+ *
99
+ * Without `all` the walk is left after its first page, so no second one is
100
+ * fetched. When the walk ends on a page that still names a next page, that
101
+ * cursor is reported rather than dropped, so a caller can resume from it.
102
+ *
103
+ * The items are gathered into one array rather than concatenated page by
104
+ * page: these lists are unbounded, and a wide drain would otherwise copy
105
+ * every record once per remaining page.
106
+ *
107
+ * @param pages - A walk of this list's pages, from {@link Paging.walk} or a
108
+ * client function's `.pages()`.
109
+ * @param options - `all` reads every page; otherwise only the first.
110
+ */
111
+ collect(pages: AsyncIterable<P>, { all }: {
112
+ readonly all: boolean;
113
+ }): Promise<Collected<P, T>>;
114
+ private static cursorIn;
115
+ private static listIn;
116
+ }
34
117
  //#endregion
35
118
  //# sourceMappingURL=paging.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paging.d.mts","names":[],"sources":["../../src/runtime/paging.ts"],"mappings":";;;;;;;;;;;;YAYY,UAAU,MAAM,8BAA8B,QAAQ;;;;;wBAMlD,UAAU,eAAe;;;;;;wBAUzB,QAAQ,eAAe;;;;;;;wBAchB,MAAM,GAC3B,WAAW,UAAU,MACnB;EAAsB,QAAQ,MAAM;IACrC,eAAe"}
1
+ {"version":3,"file":"paging.d.mts","names":[],"sources":["../../src/runtime/paging.ts"],"mappings":";;;;;;;YAMY,UAAU,MAAM,2BAA2B,mBAAmB,QAAQ;;;;YAKtE,YAAY,GAAG;;WAEhB,QAAQ,MAAM,eAAe;;WAE7B,OAAO,MAAM;;;;;YAMZ,UAAU,GAAG;;WAEd,gBAAgB;;WAEhB;;WAEA,MAAM;;;;;;;;;;;;;;;;;;;;;;qBAuBJ,OAAO,GAAG;mBACJ;;;;EAKL,YAAA,SAAS,YAAY,GAAG;;;;;;;;;;;;;SAgB7B,QAAQ,eAAe,kBAA6B;;;;;;EAgB3D,MAAM,MAAM,aAAa;;;;;;;;EAWzB,KAAK,MAAM;;;;;;;;;;;;EAeJ,KAAK,WAAW,UAAU,KAAK,eAAe;;;;;;;;;;;;;;;;;;EA6B/C,QACJ,OAAO,cAAc,MACnB;aAAkB;MACnB,QAAQ,UAAU,GAAG;iBAeT;iBAQA"}
@@ -1,38 +1,138 @@
1
1
  //#region src/runtime/paging.ts
2
2
  /**
3
- * The cursor to the page after `page`, or `undefined` on the last one. `field`
4
- * names it, for an API that calls it other than `next_page_token`.
3
+ * A cursor-paged list (ADR 027): a page carries a cursor while more remain,
4
+ * and the request for the next page sends it back.
5
+ *
6
+ * A `Paging` knows how to read a page of one list, and from that how to walk
7
+ * the pages and how to gather them. Build one from readers when the page is
8
+ * typed, or from field names with {@link Paging.byField} when the list is only
9
+ * known at run time.
10
+ *
11
+ * The walk trusts the contract. A server that repeats a cursor, skips one or
12
+ * answers a page in a different shape is an upstream bug to fix in the server,
13
+ * not something the client detects or works around; do not add guards for it.
14
+ *
15
+ * @example
16
+ * const users = new Paging({
17
+ * items: (page: UsersPage) => page.users,
18
+ * next: (page) => page.next_page_token,
19
+ * });
20
+ * const { items } = await users.collect(users.walk(fetchUsers), { all: true });
5
21
  */
6
- function nextToken(page, field = "next_page_token") {
7
- const token = page?.[field];
8
- return typeof token === "string" && token !== "" ? token : void 0;
9
- }
10
- /**
11
- * The array `field` names on a page, for a caller that learns the field only
12
- * at runtime (an operation picked from a table); a page without one is not a
13
- * page of that list.
14
- */
15
- function itemsOf(page, field) {
16
- const list = page?.[field];
17
- if (!Array.isArray(list)) throw new TypeError(`Unexpected list response: missing "${field}" array`);
18
- return list;
19
- }
20
- /**
21
- * Every page, fetched only when the loop asks for the next one, so a caller
22
- * that stops early never reads the rest. The first page is the one
23
- * `fetchPage(undefined)` answers; `next` reads a page's cursor, and an empty
24
- * one ends the walk like none.
25
- */
26
- async function* pages(fetchPage, { next = nextToken } = {}) {
27
- let token;
28
- for (;;) {
29
- const page = await fetchPage(token);
30
- token = next(page) || void 0;
31
- yield page;
32
- if (token === void 0) return;
33
- }
34
- }
22
+ var Paging = class Paging {
23
+ readers;
24
+ /**
25
+ * @param readers - How to read a page's items and its cursor.
26
+ */
27
+ constructor(readers) {
28
+ this.readers = readers;
29
+ }
30
+ /**
31
+ * A paging for a list whose fields are known only by name, such as an
32
+ * operation picked from a table at run time. A page without the items
33
+ * field is not a page of that list.
34
+ *
35
+ * @param items - The name of the field holding a page's items.
36
+ * @param cursor - The name of the field holding the next cursor.
37
+ * @throws TypeError from {@link Paging.items} when the page has no such list.
38
+ * @example
39
+ * Paging.byField("users").items({ users: ["a", "b"] }); // ["a", "b"]
40
+ * Paging.byField("users").next({ next_page_token: "t1" }); // "t1"
41
+ */
42
+ static byField(items, cursor = "next_page_token") {
43
+ return new Paging({
44
+ items: (page) => {
45
+ return Paging.listIn(page, items);
46
+ },
47
+ next: (page) => {
48
+ return Paging.cursorIn(page, cursor);
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * The items on `page`.
54
+ *
55
+ * @param page - A page of this list.
56
+ */
57
+ items(page) {
58
+ return this.readers.items(page);
59
+ }
60
+ /**
61
+ * The cursor to the page after `page`.
62
+ *
63
+ * @param page - A page of this list.
64
+ * @returns The cursor, or `undefined` when `page` is the last: no cursor,
65
+ * `null` and an empty string all mean the same.
66
+ */
67
+ next(page) {
68
+ return this.readers.next(page) || void 0;
69
+ }
70
+ /**
71
+ * Every page, fetched only when the loop asks for the next one, so a caller
72
+ * that stops early never reads the rest. The first page is the one
73
+ * `fetchPage(undefined, 1)` answers.
74
+ *
75
+ * A page's cursor is read before the page is handed out, so a loop that
76
+ * changes the page cannot change where the walk goes.
77
+ *
78
+ * @param fetchPage - Fetches the page a cursor names, and is told which page
79
+ * of the walk it is.
80
+ */
81
+ async *walk(fetchPage) {
82
+ let token;
83
+ for (let number = 1;; number += 1) {
84
+ const page = await fetchPage(token, number);
85
+ token = this.next(page);
86
+ yield page;
87
+ if (token === void 0) return;
88
+ }
89
+ }
90
+ /**
91
+ * The first page of `pages`, or with `all` every page in order, as one list
92
+ * of their items, with the cursor to the page after the last one read and
93
+ * that last page itself.
94
+ *
95
+ * Without `all` the walk is left after its first page, so no second one is
96
+ * fetched. When the walk ends on a page that still names a next page, that
97
+ * cursor is reported rather than dropped, so a caller can resume from it.
98
+ *
99
+ * The items are gathered into one array rather than concatenated page by
100
+ * page: these lists are unbounded, and a wide drain would otherwise copy
101
+ * every record once per remaining page.
102
+ *
103
+ * @param pages - A walk of this list's pages, from {@link Paging.walk} or a
104
+ * client function's `.pages()`.
105
+ * @param options - `all` reads every page; otherwise only the first.
106
+ */
107
+ async collect(pages, { all }) {
108
+ const items = [];
109
+ let last;
110
+ for await (const page of pages) {
111
+ for (const item of this.items(page)) items.push(item);
112
+ last = page;
113
+ if (!all) return {
114
+ items,
115
+ next: this.next(page) ?? null,
116
+ last
117
+ };
118
+ }
119
+ return {
120
+ items,
121
+ next: last === void 0 ? null : this.next(last) ?? null,
122
+ last
123
+ };
124
+ }
125
+ static cursorIn(page, field) {
126
+ const cursor = page?.[field];
127
+ if (typeof cursor === "string" && cursor !== "") return cursor;
128
+ }
129
+ static listIn(page, field) {
130
+ const list = page?.[field];
131
+ if (!Array.isArray(list)) throw new TypeError(`Unexpected list response: missing "${field}" array`);
132
+ return list;
133
+ }
134
+ };
35
135
  //#endregion
36
- export { itemsOf, nextToken, pages };
136
+ export { Paging };
37
137
 
38
138
  //# sourceMappingURL=paging.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"paging.mjs","names":[],"sources":["../../src/runtime/paging.ts"],"sourcesContent":["/**\n * Cursor paging (ADR 027): a page carries `next_page_token` while more remain,\n * and the next request sends it back as `page_token`.\n *\n * The walk trusts that contract. A server that repeats a cursor, skips one or\n * answers a page in a different shape is an upstream bug to fix in the server,\n * not something the client detects or works around; do not add guards for it.\n * Typed callers read a page's list straight off it; only {@link itemsOf}, for\n * a caller that knows the list by name alone, checks it is there.\n */\n\n/** Fetches the page a cursor names; `undefined` asks for the first page. */\nexport type FetchPage<P> = (token: string | undefined) => Promise<P>;\n\n/**\n * The cursor to the page after `page`, or `undefined` on the last one. `field`\n * names it, for an API that calls it other than `next_page_token`.\n */\nexport function nextToken(page: unknown, field = \"next_page_token\"): string | undefined {\n const token = (page as Record<string, unknown> | null)?.[field];\n return typeof token === \"string\" && token !== \"\" ? token : undefined;\n}\n\n/**\n * The array `field` names on a page, for a caller that learns the field only\n * at runtime (an operation picked from a table); a page without one is not a\n * page of that list.\n */\nexport function itemsOf(page: unknown, field: string): readonly unknown[] {\n const list = (page as Record<string, unknown> | null)?.[field];\n if (!Array.isArray(list)) {\n throw new TypeError(`Unexpected list response: missing \"${field}\" array`);\n }\n return list;\n}\n\n/**\n * Every page, fetched only when the loop asks for the next one, so a caller\n * that stops early never reads the rest. The first page is the one\n * `fetchPage(undefined)` answers; `next` reads a page's cursor, and an empty\n * one ends the walk like none.\n */\nexport async function* pages<P>(\n fetchPage: FetchPage<P>,\n { next = nextToken }: { next?: (page: P) => string | undefined } = {},\n): AsyncGenerator<P, void, undefined> {\n let token: string | undefined;\n for (;;) {\n const page = await fetchPage(token);\n // Read before the page is handed out, so a loop that changes the page\n // cannot change where the walk goes.\n token = next(page) || undefined;\n yield page;\n if (token === undefined) {\n return;\n }\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,UAAU,MAAe,QAAQ,mBAAuC;CACtF,MAAM,QAAS,OAA0C;CACzD,OAAO,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ,KAAA;AAC7D;;;;;;AAOA,SAAgB,QAAQ,MAAe,OAAmC;CACxE,MAAM,OAAQ,OAA0C;CACxD,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,MAAM,IAAI,UAAU,sCAAsC,MAAM,QAAQ;CAE1E,OAAO;AACT;;;;;;;AAQA,gBAAuB,MACrB,WACA,EAAE,OAAO,cAA0D,CAAC,GAChC;CACpC,IAAI;CACJ,SAAS;EACP,MAAM,OAAO,MAAM,UAAU,KAAK;EAGlC,QAAQ,KAAK,IAAI,KAAK,KAAA;EACtB,MAAM;EACN,IAAI,UAAU,KAAA,GACZ;CAEJ;AACF"}
1
+ {"version":3,"file":"paging.mjs","names":[],"sources":["../../src/runtime/paging.ts"],"sourcesContent":["/**\n * Fetches the page a cursor names.\n *\n * @param token - The cursor of the page to fetch, or `undefined` for the first page.\n * @param number - How many pages have been asked for, counting this one, from 1.\n */\nexport type FetchPage<P> = (token: string | undefined, number: number) => Promise<P>;\n\n/**\n * How to read one page of a list.\n */\nexport type PageReaders<P, T> = {\n /** The items on `page`. */\n readonly items: (page: P) => readonly T[];\n /** The cursor to the page after `page`; none, `null` or an empty string when it is the last. */\n readonly next: (page: P) => string | null | undefined;\n};\n\n/**\n * What {@link Paging.collect} gathers from a walk.\n */\nexport type Collected<P, T> = {\n /** The items of every page it read, in order. */\n readonly items: readonly T[];\n /** The cursor to the page after the last one it read, or `null` when none remains. */\n readonly next: string | null;\n /** The last page it read, or `undefined` when the walk yielded none. */\n readonly last: P | undefined;\n};\n\n/**\n * A cursor-paged list (ADR 027): a page carries a cursor while more remain,\n * and the request for the next page sends it back.\n *\n * A `Paging` knows how to read a page of one list, and from that how to walk\n * the pages and how to gather them. Build one from readers when the page is\n * typed, or from field names with {@link Paging.byField} when the list is only\n * known at run time.\n *\n * The walk trusts the contract. A server that repeats a cursor, skips one or\n * answers a page in a different shape is an upstream bug to fix in the server,\n * not something the client detects or works around; do not add guards for it.\n *\n * @example\n * const users = new Paging({\n * items: (page: UsersPage) => page.users,\n * next: (page) => page.next_page_token,\n * });\n * const { items } = await users.collect(users.walk(fetchUsers), { all: true });\n */\nexport class Paging<P, T = unknown> {\n private readonly readers: PageReaders<P, T>;\n\n /**\n * @param readers - How to read a page's items and its cursor.\n */\n constructor(readers: PageReaders<P, T>) {\n this.readers = readers;\n }\n\n /**\n * A paging for a list whose fields are known only by name, such as an\n * operation picked from a table at run time. A page without the items\n * field is not a page of that list.\n *\n * @param items - The name of the field holding a page's items.\n * @param cursor - The name of the field holding the next cursor.\n * @throws TypeError from {@link Paging.items} when the page has no such list.\n * @example\n * Paging.byField(\"users\").items({ users: [\"a\", \"b\"] }); // [\"a\", \"b\"]\n * Paging.byField(\"users\").next({ next_page_token: \"t1\" }); // \"t1\"\n */\n static byField(items: string, cursor = \"next_page_token\"): Paging<unknown> {\n return new Paging<unknown>({\n items: (page) => {\n return Paging.listIn(page, items);\n },\n next: (page) => {\n return Paging.cursorIn(page, cursor);\n },\n });\n }\n\n /**\n * The items on `page`.\n *\n * @param page - A page of this list.\n */\n items(page: P): readonly T[] {\n return this.readers.items(page);\n }\n\n /**\n * The cursor to the page after `page`.\n *\n * @param page - A page of this list.\n * @returns The cursor, or `undefined` when `page` is the last: no cursor,\n * `null` and an empty string all mean the same.\n */\n next(page: P): string | undefined {\n return this.readers.next(page) || undefined;\n }\n\n /**\n * Every page, fetched only when the loop asks for the next one, so a caller\n * that stops early never reads the rest. The first page is the one\n * `fetchPage(undefined, 1)` answers.\n *\n * A page's cursor is read before the page is handed out, so a loop that\n * changes the page cannot change where the walk goes.\n *\n * @param fetchPage - Fetches the page a cursor names, and is told which page\n * of the walk it is.\n */\n async *walk(fetchPage: FetchPage<P>): AsyncGenerator<P, void, undefined> {\n let token: string | undefined;\n for (let number = 1; ; number += 1) {\n const page = await fetchPage(token, number);\n token = this.next(page);\n yield page;\n if (token === undefined) {\n return;\n }\n }\n }\n\n /**\n * The first page of `pages`, or with `all` every page in order, as one list\n * of their items, with the cursor to the page after the last one read and\n * that last page itself.\n *\n * Without `all` the walk is left after its first page, so no second one is\n * fetched. When the walk ends on a page that still names a next page, that\n * cursor is reported rather than dropped, so a caller can resume from it.\n *\n * The items are gathered into one array rather than concatenated page by\n * page: these lists are unbounded, and a wide drain would otherwise copy\n * every record once per remaining page.\n *\n * @param pages - A walk of this list's pages, from {@link Paging.walk} or a\n * client function's `.pages()`.\n * @param options - `all` reads every page; otherwise only the first.\n */\n async collect(\n pages: AsyncIterable<P>,\n { all }: { readonly all: boolean },\n ): Promise<Collected<P, T>> {\n const items: T[] = [];\n let last: P | undefined;\n for await (const page of pages) {\n for (const item of this.items(page)) {\n items.push(item);\n }\n last = page;\n if (!all) {\n return { items, next: this.next(page) ?? null, last };\n }\n }\n return { items, next: last === undefined ? null : (this.next(last) ?? null), last };\n }\n\n private static cursorIn(page: unknown, field: string): string | undefined {\n const cursor = (page as Record<string, unknown> | null)?.[field];\n if (typeof cursor === \"string\" && cursor !== \"\") {\n return cursor;\n }\n return undefined;\n }\n\n private static listIn(page: unknown, field: string): readonly unknown[] {\n const list = (page as Record<string, unknown> | null)?.[field];\n if (!Array.isArray(list)) {\n throw new TypeError(`Unexpected list response: missing \"${field}\" array`);\n }\n return list;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkDA,IAAa,SAAb,MAAa,OAAuB;CAClC;;;;CAKA,YAAY,SAA4B;EACtC,KAAK,UAAU;CACjB;;;;;;;;;;;;;CAcA,OAAO,QAAQ,OAAe,SAAS,mBAAoC;EACzE,OAAO,IAAI,OAAgB;GACzB,QAAQ,SAAS;IACf,OAAO,OAAO,OAAO,MAAM,KAAK;GAClC;GACA,OAAO,SAAS;IACd,OAAO,OAAO,SAAS,MAAM,MAAM;GACrC;EACF,CAAC;CACH;;;;;;CAOA,MAAM,MAAuB;EAC3B,OAAO,KAAK,QAAQ,MAAM,IAAI;CAChC;;;;;;;;CASA,KAAK,MAA6B;EAChC,OAAO,KAAK,QAAQ,KAAK,IAAI,KAAK,KAAA;CACpC;;;;;;;;;;;;CAaA,OAAO,KAAK,WAA6D;EACvE,IAAI;EACJ,KAAK,IAAI,SAAS,IAAK,UAAU,GAAG;GAClC,MAAM,OAAO,MAAM,UAAU,OAAO,MAAM;GAC1C,QAAQ,KAAK,KAAK,IAAI;GACtB,MAAM;GACN,IAAI,UAAU,KAAA,GACZ;EAEJ;CACF;;;;;;;;;;;;;;;;;;CAmBA,MAAM,QACJ,OACA,EAAE,OAC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