@aws-amplify/data-schema 0.15.0 → 0.16.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 (375) hide show
  1. package/{lib-esm/src → dist/cjs}/Authorization.js +149 -31
  2. package/dist/cjs/Authorization.js.map +1 -0
  3. package/{lib-esm/src → dist/cjs}/ClientSchema.js +3 -1
  4. package/dist/cjs/ClientSchema.js.map +1 -0
  5. package/{lib-esm/src → dist/cjs}/CombineSchema.js +3 -2
  6. package/dist/cjs/CombineSchema.js.map +1 -0
  7. package/{lib-esm/src → dist/cjs}/CustomOperation.js +7 -3
  8. package/dist/cjs/CustomOperation.js.map +1 -0
  9. package/{lib-esm/src → dist/cjs}/CustomType.js +3 -1
  10. package/dist/cjs/CustomType.js.map +1 -0
  11. package/{lib-esm/src → dist/cjs}/EnumType.js +3 -1
  12. package/dist/cjs/EnumType.js.map +1 -0
  13. package/{lib-esm/src → dist/cjs}/Handler.js +3 -1
  14. package/dist/cjs/Handler.js.map +1 -0
  15. package/{lib-esm/src → dist/cjs}/MappedTypes/CustomOperations.js +3 -1
  16. package/dist/cjs/MappedTypes/CustomOperations.js.map +1 -0
  17. package/dist/cjs/MappedTypes/ExtractNonModelTypes.js +4 -0
  18. package/dist/cjs/MappedTypes/ExtractNonModelTypes.js.map +1 -0
  19. package/dist/cjs/MappedTypes/ImplicitFieldInjector.js +4 -0
  20. package/dist/cjs/MappedTypes/ImplicitFieldInjector.js.map +1 -0
  21. package/{lib-esm/src → dist/cjs}/MappedTypes/MapSecondaryIndexes.js +3 -1
  22. package/dist/cjs/MappedTypes/MapSecondaryIndexes.js.map +1 -0
  23. package/{lib-esm/src → dist/cjs}/MappedTypes/ModelMetadata.js +3 -1
  24. package/dist/cjs/MappedTypes/ModelMetadata.js.map +1 -0
  25. package/dist/cjs/MappedTypes/ResolveFieldProperties.js +4 -0
  26. package/dist/cjs/MappedTypes/ResolveFieldProperties.js.map +1 -0
  27. package/{lib-esm/src → dist/cjs}/MappedTypes/ResolveSchema.js +3 -1
  28. package/dist/cjs/MappedTypes/ResolveSchema.js.map +1 -0
  29. package/{lib-esm/src → dist/cjs}/ModelField.js +8 -3
  30. package/dist/cjs/ModelField.js.map +1 -0
  31. package/{lib-esm/src → dist/cjs}/ModelIndex.js +3 -1
  32. package/dist/cjs/ModelIndex.js.map +1 -0
  33. package/{lib-esm/src → dist/cjs}/ModelRelationalField.js +7 -10
  34. package/dist/cjs/ModelRelationalField.js.map +1 -0
  35. package/{lib-esm/src → dist/cjs}/ModelSchema.js +10 -5
  36. package/dist/cjs/ModelSchema.js.map +1 -0
  37. package/{lib-esm/src → dist/cjs}/ModelType.js +8 -3
  38. package/dist/cjs/ModelType.js.map +1 -0
  39. package/{lib-esm/src → dist/cjs}/RefType.js +8 -5
  40. package/dist/cjs/RefType.js.map +1 -0
  41. package/{lib-esm/src → dist/cjs}/SchemaProcessor.js +15 -61
  42. package/dist/cjs/SchemaProcessor.js.map +1 -0
  43. package/{lib-esm/src/index.js → dist/cjs/a.js} +4 -4
  44. package/dist/cjs/a.js.map +1 -0
  45. package/dist/cjs/index.js +8 -0
  46. package/dist/cjs/index.js.map +1 -0
  47. package/{lib-esm/src → dist/cjs}/internals/index.js +3 -1
  48. package/dist/cjs/internals/index.js.map +1 -0
  49. package/dist/cjs/runtime/addSchemaToClient.js +17 -0
  50. package/dist/cjs/runtime/addSchemaToClient.js.map +1 -0
  51. package/dist/cjs/runtime/addSchemaToClientWithInstance.js +22 -0
  52. package/dist/cjs/runtime/addSchemaToClientWithInstance.js.map +1 -0
  53. package/dist/cjs/runtime/bridge-types.js +15 -0
  54. package/dist/cjs/runtime/bridge-types.js.map +1 -0
  55. package/dist/cjs/runtime/client/index.js +17 -0
  56. package/dist/cjs/runtime/client/index.js.map +1 -0
  57. package/dist/cjs/runtime/client/index.v3.js +7 -0
  58. package/dist/cjs/runtime/client/index.v3.js.map +1 -0
  59. package/dist/cjs/runtime/index.js +13 -0
  60. package/dist/cjs/runtime/index.js.map +1 -0
  61. package/dist/cjs/runtime/index.v3.js +13 -0
  62. package/dist/cjs/runtime/index.v3.js.map +1 -0
  63. package/dist/cjs/runtime/internals/APIClient.js +740 -0
  64. package/dist/cjs/runtime/internals/APIClient.js.map +1 -0
  65. package/dist/cjs/runtime/internals/clientUtils.js +29 -0
  66. package/dist/cjs/runtime/internals/clientUtils.js.map +1 -0
  67. package/dist/cjs/runtime/internals/generateCustomOperationsProperty.js +49 -0
  68. package/dist/cjs/runtime/internals/generateCustomOperationsProperty.js.map +1 -0
  69. package/dist/cjs/runtime/internals/index.js +21 -0
  70. package/dist/cjs/runtime/internals/index.js.map +1 -0
  71. package/dist/cjs/runtime/internals/operations/custom.js +356 -0
  72. package/dist/cjs/runtime/internals/operations/custom.js.map +1 -0
  73. package/dist/cjs/runtime/internals/operations/get.js +62 -0
  74. package/dist/cjs/runtime/internals/operations/get.js.map +1 -0
  75. package/dist/cjs/runtime/internals/operations/indexQuery.js +75 -0
  76. package/dist/cjs/runtime/internals/operations/indexQuery.js.map +1 -0
  77. package/dist/cjs/runtime/internals/operations/list.js +74 -0
  78. package/dist/cjs/runtime/internals/operations/list.js.map +1 -0
  79. package/dist/cjs/runtime/internals/operations/observeQuery.js +121 -0
  80. package/dist/cjs/runtime/internals/operations/observeQuery.js.map +1 -0
  81. package/dist/cjs/runtime/internals/operations/subscription.js +31 -0
  82. package/dist/cjs/runtime/internals/operations/subscription.js.map +1 -0
  83. package/dist/cjs/runtime/internals/server/generateModelsProperty.js +53 -0
  84. package/dist/cjs/runtime/internals/server/generateModelsProperty.js.map +1 -0
  85. package/dist/cjs/runtime/internals/server/index.js +8 -0
  86. package/dist/cjs/runtime/internals/server/index.js.map +1 -0
  87. package/dist/cjs/runtime/internals/utils/clientProperties/generateEnumsProperty.js +21 -0
  88. package/dist/cjs/runtime/internals/utils/clientProperties/generateEnumsProperty.js.map +1 -0
  89. package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js +45 -0
  90. package/dist/cjs/runtime/internals/utils/clientProperties/generateModelsProperty.js.map +1 -0
  91. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js +11 -0
  92. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.js.map +1 -0
  93. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js +11 -0
  94. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.js.map +1 -0
  95. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js +15 -0
  96. package/dist/cjs/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.js.map +1 -0
  97. package/dist/cjs/runtime/utils/findIndexByFields.js +25 -0
  98. package/dist/cjs/runtime/utils/findIndexByFields.js.map +1 -0
  99. package/dist/cjs/runtime/utils/index.js +11 -0
  100. package/dist/cjs/runtime/utils/index.js.map +1 -0
  101. package/dist/cjs/runtime/utils/resolveOwnerFields.js +48 -0
  102. package/dist/cjs/runtime/utils/resolveOwnerFields.js.map +1 -0
  103. package/dist/cjs/runtime/utils/resolvePKFields.js +17 -0
  104. package/dist/cjs/runtime/utils/resolvePKFields.js.map +1 -0
  105. package/{lib-esm/src → dist/cjs}/util/Brand.js +3 -1
  106. package/dist/cjs/util/Brand.js.map +1 -0
  107. package/{lib-esm/src → dist/cjs}/util/IndexLimit.js +3 -1
  108. package/dist/cjs/util/IndexLimit.js.map +1 -0
  109. package/{lib-esm/src → dist/cjs}/util/SpreadTuple.js +3 -1
  110. package/dist/cjs/util/SpreadTuple.js.map +1 -0
  111. package/{lib-esm/src → dist/cjs}/util/index.js +3 -1
  112. package/dist/cjs/util/index.js.map +1 -0
  113. package/{lib-esm/src → dist/esm}/Authorization.d.ts +105 -31
  114. package/dist/esm/Authorization.mjs +446 -0
  115. package/dist/esm/Authorization.mjs.map +1 -0
  116. package/{lib-esm/src → dist/esm}/ClientSchema.d.ts +1 -2
  117. package/dist/esm/ClientSchema.mjs +2 -0
  118. package/dist/esm/ClientSchema.mjs.map +1 -0
  119. package/{lib-esm/src → dist/esm}/CombineSchema.d.ts +0 -1
  120. package/dist/esm/CombineSchema.mjs +39 -0
  121. package/dist/esm/CombineSchema.mjs.map +1 -0
  122. package/{lib-esm/src → dist/esm}/CustomOperation.d.ts +2 -3
  123. package/dist/esm/CustomOperation.mjs +67 -0
  124. package/dist/esm/CustomOperation.mjs.map +1 -0
  125. package/{lib-esm/src → dist/esm}/CustomType.d.ts +0 -1
  126. package/dist/esm/CustomType.mjs +13 -0
  127. package/dist/esm/CustomType.mjs.map +1 -0
  128. package/{lib-esm/src → dist/esm}/EnumType.d.ts +0 -1
  129. package/dist/esm/EnumType.mjs +16 -0
  130. package/dist/esm/EnumType.mjs.map +1 -0
  131. package/{lib-esm/src → dist/esm}/Handler.d.ts +0 -1
  132. package/dist/esm/Handler.mjs +48 -0
  133. package/dist/esm/Handler.mjs.map +1 -0
  134. package/{lib-esm/src → dist/esm}/MappedTypes/CustomOperations.d.ts +0 -1
  135. package/dist/esm/MappedTypes/CustomOperations.mjs +2 -0
  136. package/dist/esm/MappedTypes/CustomOperations.mjs.map +1 -0
  137. package/{lib-esm/src → dist/esm}/MappedTypes/ExtractNonModelTypes.d.ts +0 -1
  138. package/dist/esm/MappedTypes/ExtractNonModelTypes.mjs +2 -0
  139. package/dist/esm/MappedTypes/ExtractNonModelTypes.mjs.map +1 -0
  140. package/{lib-esm/src → dist/esm}/MappedTypes/ImplicitFieldInjector.d.ts +0 -1
  141. package/dist/esm/MappedTypes/ImplicitFieldInjector.mjs +2 -0
  142. package/dist/esm/MappedTypes/ImplicitFieldInjector.mjs.map +1 -0
  143. package/{lib-esm/src → dist/esm}/MappedTypes/MapSecondaryIndexes.d.ts +0 -1
  144. package/dist/esm/MappedTypes/MapSecondaryIndexes.mjs +2 -0
  145. package/dist/esm/MappedTypes/MapSecondaryIndexes.mjs.map +1 -0
  146. package/{lib-esm/src → dist/esm}/MappedTypes/ModelMetadata.d.ts +0 -1
  147. package/dist/esm/MappedTypes/ModelMetadata.mjs +2 -0
  148. package/dist/esm/MappedTypes/ModelMetadata.mjs.map +1 -0
  149. package/{lib-esm/src → dist/esm}/MappedTypes/ResolveFieldProperties.d.ts +0 -1
  150. package/dist/esm/MappedTypes/ResolveFieldProperties.mjs +2 -0
  151. package/dist/esm/MappedTypes/ResolveFieldProperties.mjs.map +1 -0
  152. package/{lib-esm/src → dist/esm}/MappedTypes/ResolveSchema.d.ts +0 -1
  153. package/dist/esm/MappedTypes/ResolveSchema.mjs +2 -0
  154. package/dist/esm/MappedTypes/ResolveSchema.mjs.map +1 -0
  155. package/{lib-esm/src → dist/esm}/ModelField.d.ts +2 -3
  156. package/dist/esm/ModelField.mjs +199 -0
  157. package/dist/esm/ModelField.mjs.map +1 -0
  158. package/{lib-esm/src → dist/esm}/ModelIndex.d.ts +0 -1
  159. package/dist/esm/ModelIndex.mjs +33 -0
  160. package/dist/esm/ModelIndex.mjs.map +1 -0
  161. package/{lib-esm/src → dist/esm}/ModelRelationalField.d.ts +3 -4
  162. package/dist/esm/ModelRelationalField.mjs +88 -0
  163. package/dist/esm/ModelRelationalField.mjs.map +1 -0
  164. package/{lib-esm/src → dist/esm}/ModelSchema.d.ts +3 -4
  165. package/dist/esm/ModelSchema.mjs +163 -0
  166. package/dist/esm/ModelSchema.mjs.map +1 -0
  167. package/{lib-esm/src → dist/esm}/ModelType.d.ts +2 -3
  168. package/dist/esm/ModelType.mjs +66 -0
  169. package/dist/esm/ModelType.mjs.map +1 -0
  170. package/{lib-esm/src → dist/esm}/RefType.d.ts +2 -3
  171. package/dist/esm/RefType.mjs +48 -0
  172. package/dist/esm/RefType.mjs.map +1 -0
  173. package/{lib-esm/src → dist/esm}/SchemaProcessor.d.ts +0 -1
  174. package/dist/esm/SchemaProcessor.mjs +926 -0
  175. package/dist/esm/SchemaProcessor.mjs.map +1 -0
  176. package/{lib-esm/src/index.d.ts → dist/esm/a.d.ts} +1 -3
  177. package/dist/esm/a.mjs +11 -0
  178. package/dist/esm/a.mjs.map +1 -0
  179. package/dist/esm/index.d.ts +4 -0
  180. package/dist/esm/index.mjs +3 -0
  181. package/dist/esm/index.mjs.map +1 -0
  182. package/dist/esm/internals/index.d.ts +2 -0
  183. package/dist/esm/internals/index.mjs +2 -0
  184. package/dist/esm/internals/index.mjs.map +1 -0
  185. package/dist/esm/runtime/addSchemaToClient.d.ts +3 -0
  186. package/dist/esm/runtime/addSchemaToClient.mjs +17 -0
  187. package/dist/esm/runtime/addSchemaToClient.mjs.map +1 -0
  188. package/dist/esm/runtime/addSchemaToClientWithInstance.d.ts +3 -0
  189. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs +22 -0
  190. package/dist/esm/runtime/addSchemaToClientWithInstance.mjs.map +1 -0
  191. package/dist/esm/runtime/bridge-types.d.ts +281 -0
  192. package/dist/esm/runtime/bridge-types.mjs +13 -0
  193. package/dist/esm/runtime/bridge-types.mjs.map +1 -0
  194. package/dist/esm/runtime/client/index.d.ts +571 -0
  195. package/dist/esm/runtime/client/index.mjs +2 -0
  196. package/dist/esm/runtime/client/index.mjs.map +1 -0
  197. package/dist/esm/runtime/client/index.v3.d.ts +15 -0
  198. package/dist/esm/runtime/client/index.v3.mjs +2 -0
  199. package/dist/esm/runtime/client/index.v3.mjs.map +1 -0
  200. package/dist/esm/runtime/index.d.ts +4 -0
  201. package/dist/esm/runtime/index.mjs +4 -0
  202. package/dist/esm/runtime/index.mjs.map +1 -0
  203. package/dist/esm/runtime/index.v3.d.ts +4 -0
  204. package/dist/esm/runtime/index.v3.mjs +4 -0
  205. package/dist/esm/runtime/index.v3.mjs.map +1 -0
  206. package/dist/esm/runtime/internals/APIClient.d.ts +125 -0
  207. package/dist/esm/runtime/internals/APIClient.mjs +728 -0
  208. package/dist/esm/runtime/internals/APIClient.mjs.map +1 -0
  209. package/dist/esm/runtime/internals/clientUtils.d.ts +6 -0
  210. package/dist/esm/runtime/internals/clientUtils.mjs +26 -0
  211. package/dist/esm/runtime/internals/clientUtils.mjs.map +1 -0
  212. package/dist/esm/runtime/internals/generateCustomOperationsProperty.d.ts +8 -0
  213. package/dist/esm/runtime/internals/generateCustomOperationsProperty.mjs +44 -0
  214. package/dist/esm/runtime/internals/generateCustomOperationsProperty.mjs.map +1 -0
  215. package/dist/esm/runtime/internals/index.d.ts +6 -0
  216. package/dist/esm/runtime/internals/index.mjs +7 -0
  217. package/dist/esm/runtime/internals/index.mjs.map +1 -0
  218. package/dist/esm/runtime/internals/operations/custom.d.ts +61 -0
  219. package/dist/esm/runtime/internals/operations/custom.mjs +354 -0
  220. package/dist/esm/runtime/internals/operations/custom.mjs.map +1 -0
  221. package/dist/esm/runtime/internals/operations/get.d.ts +3 -0
  222. package/dist/esm/runtime/internals/operations/get.mjs +60 -0
  223. package/dist/esm/runtime/internals/operations/get.mjs.map +1 -0
  224. package/dist/esm/runtime/internals/operations/indexQuery.d.ts +7 -0
  225. package/dist/esm/runtime/internals/operations/indexQuery.mjs +73 -0
  226. package/dist/esm/runtime/internals/operations/indexQuery.mjs.map +1 -0
  227. package/dist/esm/runtime/internals/operations/list.d.ts +2 -0
  228. package/dist/esm/runtime/internals/operations/list.mjs +72 -0
  229. package/dist/esm/runtime/internals/operations/list.mjs.map +1 -0
  230. package/dist/esm/runtime/internals/operations/observeQuery.d.ts +3 -0
  231. package/dist/esm/runtime/internals/operations/observeQuery.mjs +120 -0
  232. package/dist/esm/runtime/internals/operations/observeQuery.mjs.map +1 -0
  233. package/dist/esm/runtime/internals/operations/subscription.d.ts +3 -0
  234. package/dist/esm/runtime/internals/operations/subscription.mjs +29 -0
  235. package/dist/esm/runtime/internals/operations/subscription.mjs.map +1 -0
  236. package/dist/esm/runtime/internals/server/generateModelsProperty.d.ts +3 -0
  237. package/dist/esm/runtime/internals/server/generateModelsProperty.mjs +51 -0
  238. package/dist/esm/runtime/internals/server/generateModelsProperty.mjs.map +1 -0
  239. package/dist/esm/runtime/internals/server/index.d.ts +1 -0
  240. package/dist/esm/runtime/internals/server/index.mjs +2 -0
  241. package/dist/esm/runtime/internals/server/index.mjs.map +1 -0
  242. package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.d.ts +3 -0
  243. package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.mjs +18 -0
  244. package/dist/esm/runtime/internals/utils/clientProperties/generateEnumsProperty.mjs.map +1 -0
  245. package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.d.ts +3 -0
  246. package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs +43 -0
  247. package/dist/esm/runtime/internals/utils/clientProperties/generateModelsProperty.mjs.map +1 -0
  248. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.d.ts +2 -0
  249. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs +8 -0
  250. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.mjs.map +1 -0
  251. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.d.ts +8 -0
  252. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs +8 -0
  253. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.mjs.map +1 -0
  254. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.d.ts +2 -0
  255. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs +12 -0
  256. package/dist/esm/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.mjs.map +1 -0
  257. package/dist/esm/runtime/utils/findIndexByFields.d.ts +9 -0
  258. package/dist/esm/runtime/utils/findIndexByFields.mjs +22 -0
  259. package/dist/esm/runtime/utils/findIndexByFields.mjs.map +1 -0
  260. package/dist/esm/runtime/utils/index.d.ts +2 -0
  261. package/dist/esm/runtime/utils/index.mjs +3 -0
  262. package/dist/esm/runtime/utils/index.mjs.map +1 -0
  263. package/dist/esm/runtime/utils/resolveOwnerFields.d.ts +12 -0
  264. package/dist/esm/runtime/utils/resolveOwnerFields.mjs +45 -0
  265. package/dist/esm/runtime/utils/resolveOwnerFields.mjs.map +1 -0
  266. package/dist/esm/runtime/utils/resolvePKFields.d.ts +13 -0
  267. package/dist/esm/runtime/utils/resolvePKFields.mjs +14 -0
  268. package/dist/esm/runtime/utils/resolvePKFields.mjs.map +1 -0
  269. package/{lib-esm/src → dist/esm}/util/Brand.d.ts +0 -1
  270. package/dist/esm/util/Brand.mjs +30 -0
  271. package/dist/esm/util/Brand.mjs.map +1 -0
  272. package/{lib-esm/src → dist/esm}/util/IndexLimit.d.ts +0 -1
  273. package/dist/esm/util/IndexLimit.mjs +2 -0
  274. package/dist/esm/util/IndexLimit.mjs.map +1 -0
  275. package/{lib-esm/src → dist/esm}/util/SpreadTuple.d.ts +0 -1
  276. package/dist/esm/util/SpreadTuple.mjs +2 -0
  277. package/dist/esm/util/SpreadTuple.mjs.map +1 -0
  278. package/{lib-esm/src → dist/esm}/util/index.d.ts +0 -1
  279. package/dist/esm/util/index.mjs +2 -0
  280. package/dist/esm/util/index.mjs.map +1 -0
  281. package/dist/meta/cjs.tsbuildinfo +1 -0
  282. package/internals/package.json +7 -5
  283. package/package.json +31 -14
  284. package/runtime/package.json +8 -0
  285. package/src/Authorization.ts +684 -0
  286. package/src/ClientSchema.ts +118 -0
  287. package/src/CombineSchema.ts +58 -0
  288. package/src/CustomOperation.ts +286 -0
  289. package/src/CustomType.ts +67 -0
  290. package/src/EnumType.ts +36 -0
  291. package/src/Handler.ts +127 -0
  292. package/src/MappedTypes/CustomOperations.ts +256 -0
  293. package/src/MappedTypes/ExtractNonModelTypes.ts +154 -0
  294. package/src/MappedTypes/ImplicitFieldInjector.ts +69 -0
  295. package/src/MappedTypes/MapSecondaryIndexes.ts +100 -0
  296. package/src/MappedTypes/ModelMetadata.ts +87 -0
  297. package/src/MappedTypes/ResolveFieldProperties.ts +254 -0
  298. package/src/MappedTypes/ResolveSchema.ts +148 -0
  299. package/src/ModelField.ts +304 -0
  300. package/src/ModelIndex.ts +91 -0
  301. package/src/ModelRelationalField.ts +263 -0
  302. package/src/ModelSchema.ts +437 -0
  303. package/src/ModelType.ts +345 -0
  304. package/src/RefType.ts +139 -0
  305. package/src/SchemaProcessor.ts +1516 -0
  306. package/src/a.ts +58 -0
  307. package/src/index.ts +6 -0
  308. package/src/internals/index.ts +2 -0
  309. package/src/runtime/addSchemaToClient.ts +45 -0
  310. package/src/runtime/addSchemaToClientWithInstance.ts +46 -0
  311. package/src/runtime/bridge-types.ts +382 -0
  312. package/src/runtime/client/index.ts +923 -0
  313. package/src/runtime/client/index.v3.ts +52 -0
  314. package/src/runtime/index.ts +7 -0
  315. package/src/runtime/index.v3.ts +7 -0
  316. package/src/runtime/internals/APIClient.ts +1082 -0
  317. package/src/runtime/internals/clientUtils.ts +37 -0
  318. package/src/runtime/internals/generateCustomOperationsProperty.ts +116 -0
  319. package/src/runtime/internals/index.ts +12 -0
  320. package/src/runtime/internals/operations/custom.ts +497 -0
  321. package/src/runtime/internals/operations/get.ts +150 -0
  322. package/src/runtime/internals/operations/indexQuery.ts +178 -0
  323. package/src/runtime/internals/operations/list.ts +143 -0
  324. package/src/runtime/internals/operations/observeQuery.ts +146 -0
  325. package/src/runtime/internals/operations/subscription.ts +78 -0
  326. package/src/runtime/internals/server/generateModelsProperty.ts +94 -0
  327. package/src/runtime/internals/server/index.ts +4 -0
  328. package/src/runtime/internals/utils/clientProperties/generateEnumsProperty.ts +34 -0
  329. package/src/runtime/internals/utils/clientProperties/generateModelsProperty.ts +88 -0
  330. package/src/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.ts +10 -0
  331. package/src/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.ts +13 -0
  332. package/src/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts +15 -0
  333. package/src/runtime/utils/findIndexByFields.ts +31 -0
  334. package/src/runtime/utils/index.ts +5 -0
  335. package/src/runtime/utils/resolveOwnerFields.ts +77 -0
  336. package/src/runtime/utils/resolvePKFields.ts +23 -0
  337. package/src/util/Brand.ts +45 -0
  338. package/src/util/IndexLimit.ts +12 -0
  339. package/src/util/SpreadTuple.ts +10 -0
  340. package/src/util/index.ts +3 -0
  341. package/lib-esm/index.d.ts +0 -5
  342. package/lib-esm/index.d.ts.map +0 -1
  343. package/lib-esm/index.js +0 -28
  344. package/lib-esm/src/Authorization.d.ts.map +0 -1
  345. package/lib-esm/src/ClientSchema.d.ts.map +0 -1
  346. package/lib-esm/src/CombineSchema.d.ts.map +0 -1
  347. package/lib-esm/src/CustomOperation.d.ts.map +0 -1
  348. package/lib-esm/src/CustomType.d.ts.map +0 -1
  349. package/lib-esm/src/EnumType.d.ts.map +0 -1
  350. package/lib-esm/src/Handler.d.ts.map +0 -1
  351. package/lib-esm/src/MappedTypes/CustomOperations.d.ts.map +0 -1
  352. package/lib-esm/src/MappedTypes/ExtractNonModelTypes.d.ts.map +0 -1
  353. package/lib-esm/src/MappedTypes/ExtractNonModelTypes.js +0 -2
  354. package/lib-esm/src/MappedTypes/ImplicitFieldInjector.d.ts.map +0 -1
  355. package/lib-esm/src/MappedTypes/ImplicitFieldInjector.js +0 -2
  356. package/lib-esm/src/MappedTypes/MapSecondaryIndexes.d.ts.map +0 -1
  357. package/lib-esm/src/MappedTypes/ModelMetadata.d.ts.map +0 -1
  358. package/lib-esm/src/MappedTypes/ResolveFieldProperties.d.ts.map +0 -1
  359. package/lib-esm/src/MappedTypes/ResolveFieldProperties.js +0 -2
  360. package/lib-esm/src/MappedTypes/ResolveSchema.d.ts.map +0 -1
  361. package/lib-esm/src/ModelField.d.ts.map +0 -1
  362. package/lib-esm/src/ModelIndex.d.ts.map +0 -1
  363. package/lib-esm/src/ModelRelationalField.d.ts.map +0 -1
  364. package/lib-esm/src/ModelSchema.d.ts.map +0 -1
  365. package/lib-esm/src/ModelType.d.ts.map +0 -1
  366. package/lib-esm/src/RefType.d.ts.map +0 -1
  367. package/lib-esm/src/SchemaProcessor.d.ts.map +0 -1
  368. package/lib-esm/src/index.d.ts.map +0 -1
  369. package/lib-esm/src/internals/index.d.ts +0 -2
  370. package/lib-esm/src/internals/index.d.ts.map +0 -1
  371. package/lib-esm/src/util/Brand.d.ts.map +0 -1
  372. package/lib-esm/src/util/IndexLimit.d.ts.map +0 -1
  373. package/lib-esm/src/util/SpreadTuple.d.ts.map +0 -1
  374. package/lib-esm/src/util/index.d.ts.map +0 -1
  375. package/lib-esm/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.generateModelsProperty = void 0;
5
+ const APIClient_1 = require("../../APIClient");
6
+ const list_1 = require("../../operations/list");
7
+ const indexQuery_1 = require("../../operations/indexQuery");
8
+ const get_1 = require("../../operations/get");
9
+ const subscription_1 = require("../../operations/subscription");
10
+ const observeQuery_1 = require("../../operations/observeQuery");
11
+ const clientUtils_1 = require("../../clientUtils");
12
+ function generateModelsProperty(client, apiGraphQLConfig, getInternals) {
13
+ const models = {};
14
+ const modelIntrospection = apiGraphQLConfig.modelIntrospection;
15
+ if (!modelIntrospection) {
16
+ return {};
17
+ }
18
+ const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];
19
+ for (const model of Object.values(modelIntrospection.models)) {
20
+ const { name } = model;
21
+ models[name] = {};
22
+ Object.entries(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {
23
+ const operation = key;
24
+ if (operation === 'LIST') {
25
+ models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model, getInternals);
26
+ }
27
+ else if (SUBSCRIPTION_OPS.includes(operation)) {
28
+ models[name][operationPrefix] = (0, subscription_1.subscriptionFactory)(client, modelIntrospection, model, operation, getInternals);
29
+ }
30
+ else if (operation === 'OBSERVE_QUERY') {
31
+ models[name][operationPrefix] = (0, observeQuery_1.observeQueryFactory)(models, model);
32
+ }
33
+ else {
34
+ models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, getInternals);
35
+ }
36
+ });
37
+ const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);
38
+ for (const idx of secondaryIdxs) {
39
+ models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx, getInternals);
40
+ }
41
+ }
42
+ return models;
43
+ }
44
+ exports.generateModelsProperty = generateModelsProperty;
45
+ //# sourceMappingURL=generateModelsProperty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateModelsProperty.js","sources":["../../../../../../src/runtime/internals/utils/clientProperties/generateModelsProperty.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateModelsProperty = void 0;\nconst APIClient_1 = require(\"../../APIClient\");\nconst list_1 = require(\"../../operations/list\");\nconst indexQuery_1 = require(\"../../operations/indexQuery\");\nconst get_1 = require(\"../../operations/get\");\nconst subscription_1 = require(\"../../operations/subscription\");\nconst observeQuery_1 = require(\"../../operations/observeQuery\");\nconst clientUtils_1 = require(\"../../clientUtils\");\nfunction generateModelsProperty(client, apiGraphQLConfig, getInternals) {\n const models = {};\n const modelIntrospection = apiGraphQLConfig.modelIntrospection;\n if (!modelIntrospection) {\n return {};\n }\n const SUBSCRIPTION_OPS = ['ONCREATE', 'ONUPDATE', 'ONDELETE'];\n for (const model of Object.values(modelIntrospection.models)) {\n const { name } = model;\n models[name] = {};\n Object.entries(APIClient_1.graphQLOperationsInfo).forEach(([key, { operationPrefix }]) => {\n const operation = key;\n if (operation === 'LIST') {\n models[name][operationPrefix] = (0, list_1.listFactory)(client, modelIntrospection, model, getInternals);\n }\n else if (SUBSCRIPTION_OPS.includes(operation)) {\n models[name][operationPrefix] = (0, subscription_1.subscriptionFactory)(client, modelIntrospection, model, operation, getInternals);\n }\n else if (operation === 'OBSERVE_QUERY') {\n models[name][operationPrefix] = (0, observeQuery_1.observeQueryFactory)(models, model);\n }\n else {\n models[name][operationPrefix] = (0, get_1.getFactory)(client, modelIntrospection, model, operation, getInternals);\n }\n });\n const secondaryIdxs = (0, clientUtils_1.getSecondaryIndexesFromSchemaModel)(model);\n for (const idx of secondaryIdxs) {\n models[name][idx.queryField] = (0, indexQuery_1.indexQueryFactory)(client, modelIntrospection, model, idx, getInternals);\n }\n }\n return models;\n}\nexports.generateModelsProperty = generateModelsProperty;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAChD,MAAM,YAAY,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAChE,MAAM,cAAc,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAChE,MAAM,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACnD,SAAS,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE;AACxE,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC;AACnE,IAAI,IAAI,CAAC,kBAAkB,EAAE;AAC7B,QAAQ,OAAO,EAAE,CAAC;AAClB,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAClE,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;AAClE,QAAQ,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;AAC/B,QAAQ,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK;AAClG,YAAY,MAAM,SAAS,GAAG,GAAG,CAAC;AAClC,YAAY,IAAI,SAAS,KAAK,MAAM,EAAE;AACtC,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AACzH,aAAa;AACb,iBAAiB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC3D,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AACpJ,aAAa;AACb,iBAAiB,IAAI,SAAS,KAAK,eAAe,EAAE;AACpD,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,mBAAmB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACvG,aAAa;AACb,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAClI,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AAC3F,QAAQ,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AACzC,YAAY,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;AACrI,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isApiGraphQLConfig = void 0;
7
+ function isApiGraphQLConfig(apiGraphQLConfig) {
8
+ return apiGraphQLConfig !== undefined;
9
+ }
10
+ exports.isApiGraphQLConfig = isApiGraphQLConfig;
11
+ //# sourceMappingURL=isApiGraphQLProviderConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isApiGraphQLProviderConfig.js","sources":["../../../../../../src/runtime/internals/utils/runtimeTypeGuards/isApiGraphQLProviderConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isApiGraphQLConfig = void 0;\nfunction isApiGraphQLConfig(apiGraphQLConfig) {\n return apiGraphQLConfig !== undefined;\n}\nexports.isApiGraphQLConfig = isApiGraphQLConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC,SAAS,kBAAkB,CAAC,gBAAgB,EAAE;AAC9C,IAAI,OAAO,gBAAgB,KAAK,SAAS,CAAC;AAC1C,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isConfigureEventWithResourceConfig = void 0;
7
+ function isConfigureEventWithResourceConfig(payload) {
8
+ return payload.event === 'configure';
9
+ }
10
+ exports.isConfigureEventWithResourceConfig = isConfigureEventWithResourceConfig;
11
+ //# sourceMappingURL=isConfigureEventWithResourceConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isConfigureEventWithResourceConfig.js","sources":["../../../../../../src/runtime/internals/utils/runtimeTypeGuards/isConfigureEventWithResourceConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isConfigureEventWithResourceConfig = void 0;\nfunction isConfigureEventWithResourceConfig(payload) {\n return payload.event === 'configure';\n}\nexports.isConfigureEventWithResourceConfig = isConfigureEventWithResourceConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kCAAkC,GAAG,KAAK,CAAC,CAAC;AACpD,SAAS,kCAAkC,CAAC,OAAO,EAAE;AACrD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,WAAW,CAAC;AACzC,CAAC;AACD,OAAO,CAAC,kCAAkC,GAAG,kCAAkC;;"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isGraphQLResponseWithErrors = void 0;
7
+ function isGraphQLResponseWithErrors(response) {
8
+ if (!response) {
9
+ return false;
10
+ }
11
+ const r = response;
12
+ return Array.isArray(r.errors) && r.errors.length > 0;
13
+ }
14
+ exports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;
15
+ //# sourceMappingURL=isGraphQLResponseWithErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGraphQLResponseWithErrors.js","sources":["../../../../../../src/runtime/internals/utils/runtimeTypeGuards/isGraphQLResponseWithErrors.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isGraphQLResponseWithErrors = void 0;\nfunction isGraphQLResponseWithErrors(response) {\n if (!response) {\n return false;\n }\n const r = response;\n return Array.isArray(r.errors) && r.errors.length > 0;\n}\nexports.isGraphQLResponseWithErrors = isGraphQLResponseWithErrors;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,2BAA2B,GAAG,KAAK,CAAC,CAAC;AAC7C,SAAS,2BAA2B,CAAC,QAAQ,EAAE;AAC/C,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC;AACvB,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1D,CAAC;AACD,OAAO,CAAC,2BAA2B,GAAG,2BAA2B;;"}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.findIndexByFields = void 0;
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ /**
8
+ * Iterates through a collection to find a matching item and returns the index.
9
+ *
10
+ * @param needle The item to search for
11
+ * @param haystack The collection to search
12
+ * @param keyFields The fields used to indicate a match
13
+ * @returns Index of `needle` in `haystack`, otherwise -1 if not found.
14
+ */
15
+ function findIndexByFields(needle, haystack, keyFields) {
16
+ const searchObject = Object.fromEntries(keyFields.map((fieldName) => [fieldName, needle[fieldName]]));
17
+ for (let i = 0; i < haystack.length; i++) {
18
+ if (Object.keys(searchObject).every((k) => searchObject[k] === haystack[i][k])) {
19
+ return i;
20
+ }
21
+ }
22
+ return -1;
23
+ }
24
+ exports.findIndexByFields = findIndexByFields;
25
+ //# sourceMappingURL=findIndexByFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findIndexByFields.js","sources":["../../../../src/runtime/utils/findIndexByFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.findIndexByFields = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Iterates through a collection to find a matching item and returns the index.\n *\n * @param needle The item to search for\n * @param haystack The collection to search\n * @param keyFields The fields used to indicate a match\n * @returns Index of `needle` in `haystack`, otherwise -1 if not found.\n */\nfunction findIndexByFields(needle, haystack, keyFields) {\n const searchObject = Object.fromEntries(keyFields.map((fieldName) => [fieldName, needle[fieldName]]));\n for (let i = 0; i < haystack.length; i++) {\n if (Object.keys(searchObject).every((k) => searchObject[k] === haystack[i][k])) {\n return i;\n }\n }\n return -1;\n}\nexports.findIndexByFields = findIndexByFields;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,KAAK,CAAC,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE;AACxD,IAAI,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1G,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC9C,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;AACxF,YAAY,OAAO,CAAC,CAAC;AACrB,SAAS;AACT,KAAK;AACL,IAAI,OAAO,CAAC,CAAC,CAAC;AACd,CAAC;AACD,OAAO,CAAC,iBAAiB,GAAG,iBAAiB;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findIndexByFields = exports.resolvePKFields = void 0;
7
+ var resolvePKFields_1 = require("./resolvePKFields");
8
+ Object.defineProperty(exports, "resolvePKFields", { enumerable: true, get: function () { return resolvePKFields_1.resolvePKFields; } });
9
+ var findIndexByFields_1 = require("./findIndexByFields");
10
+ Object.defineProperty(exports, "findIndexByFields", { enumerable: true, get: function () { return findIndexByFields_1.findIndexByFields; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/runtime/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.findIndexByFields = exports.resolvePKFields = void 0;\nvar resolvePKFields_1 = require(\"./resolvePKFields\");\nObject.defineProperty(exports, \"resolvePKFields\", { enumerable: true, get: function () { return resolvePKFields_1.resolvePKFields; } });\nvar findIndexByFields_1 = require(\"./findIndexByFields\");\nObject.defineProperty(exports, \"findIndexByFields\", { enumerable: true, get: function () { return findIndexByFields_1.findIndexByFields; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AAC7D,IAAI,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACrD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,iBAAiB,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AACxI,IAAI,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACzD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.resolveOwnerFields = void 0;
5
+ /**
6
+ * Given an introspection schema model, returns all owner fields.
7
+ *
8
+ * @param model Model from an introspection schema
9
+ * @returns List of owner field names
10
+ */
11
+ function resolveOwnerFields(model) {
12
+ const ownerFields = new Set();
13
+ for (const attr of model.attributes || []) {
14
+ if (isAuthAttribute(attr)) {
15
+ for (const rule of attr.properties.rules) {
16
+ if (rule.allow === 'owner') {
17
+ ownerFields.add(rule.ownerField || 'owner');
18
+ }
19
+ else if (rule.allow === 'groups' && rule.groupsField !== undefined) {
20
+ // only valid for dynamic group(s)
21
+ // static group auth will have an array of predefined groups in the attribute, groups: string[]
22
+ // but `groupsField` will be undefined
23
+ ownerFields.add(rule.groupsField);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ return Array.from(ownerFields);
29
+ }
30
+ exports.resolveOwnerFields = resolveOwnerFields;
31
+ /**
32
+ * Type guard that identifies an auth attribute with an attached rules list that
33
+ * specifies an `allow` attribute at a minimum.
34
+ *
35
+ * @param attribute Any object. Ideally a model introspection schema model attribute
36
+ * @returns True if given object is an auth attribute
37
+ */
38
+ function isAuthAttribute(attribute) {
39
+ if (attribute?.type === 'auth') {
40
+ if (typeof attribute?.properties === 'object') {
41
+ if (Array.isArray(attribute?.properties?.rules)) {
42
+ return (attribute?.properties?.rules).every((rule) => !!rule.allow);
43
+ }
44
+ }
45
+ }
46
+ return false;
47
+ }
48
+ //# sourceMappingURL=resolveOwnerFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveOwnerFields.js","sources":["../../../../src/runtime/utils/resolveOwnerFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveOwnerFields = void 0;\n/**\n * Given an introspection schema model, returns all owner fields.\n *\n * @param model Model from an introspection schema\n * @returns List of owner field names\n */\nfunction resolveOwnerFields(model) {\n const ownerFields = new Set();\n for (const attr of model.attributes || []) {\n if (isAuthAttribute(attr)) {\n for (const rule of attr.properties.rules) {\n if (rule.allow === 'owner') {\n ownerFields.add(rule.ownerField || 'owner');\n }\n else if (rule.allow === 'groups' && rule.groupsField !== undefined) {\n // only valid for dynamic group(s)\n // static group auth will have an array of predefined groups in the attribute, groups: string[]\n // but `groupsField` will be undefined\n ownerFields.add(rule.groupsField);\n }\n }\n }\n }\n return Array.from(ownerFields);\n}\nexports.resolveOwnerFields = resolveOwnerFields;\n/**\n * Type guard that identifies an auth attribute with an attached rules list that\n * specifies an `allow` attribute at a minimum.\n *\n * @param attribute Any object. Ideally a model introspection schema model attribute\n * @returns True if given object is an auth attribute\n */\nfunction isAuthAttribute(attribute) {\n if (attribute?.type === 'auth') {\n if (typeof attribute?.properties === 'object') {\n if (Array.isArray(attribute?.properties?.rules)) {\n return (attribute?.properties?.rules).every((rule) => !!rule.allow);\n }\n }\n }\n return false;\n}\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,IAAI,MAAM,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;AAClC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE;AAC/C,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE;AACnC,YAAY,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACtD,gBAAgB,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;AAC5C,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC;AAChE,iBAAiB;AACjB,qBAAqB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;AACpF;AACA;AACA;AACA,oBAAoB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtD,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACnC,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,SAAS,EAAE;AACpC,IAAI,IAAI,SAAS,EAAE,IAAI,KAAK,MAAM,EAAE;AACpC,QAAQ,IAAI,OAAO,SAAS,EAAE,UAAU,KAAK,QAAQ,EAAE;AACvD,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE;AAC7D,gBAAgB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACpF,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,OAAO,KAAK,CAAC;AACjB;;"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.resolvePKFields = void 0;
5
+ /**
6
+ * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key
7
+ * as an array of field names.
8
+ *
9
+ * @param model The model object
10
+ * @returns Array of field names
11
+ */
12
+ function resolvePKFields(model) {
13
+ const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;
14
+ return [primaryKeyFieldName, ...sortKeyFieldNames];
15
+ }
16
+ exports.resolvePKFields = resolvePKFields;
17
+ //# sourceMappingURL=resolvePKFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvePKFields.js","sources":["../../../../src/runtime/utils/resolvePKFields.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolvePKFields = void 0;\n/**\n * Given a SchemaModel from a ModelIntrospectionSchema, returns the primary key\n * as an array of field names.\n *\n * @param model The model object\n * @returns Array of field names\n */\nfunction resolvePKFields(model) {\n const { primaryKeyFieldName, sortKeyFieldNames } = model.primaryKeyInfo;\n return [primaryKeyFieldName, ...sortKeyFieldNames];\n}\nexports.resolvePKFields = resolvePKFields;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,eAAe,CAAC,KAAK,EAAE;AAChC,IAAI,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC;AAC5E,IAAI,OAAO,CAAC,mBAAmB,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACvD,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
@@ -1,4 +1,5 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.getBrand = exports.brand = void 0;
4
5
  const brandSymbol = Symbol('brand');
@@ -30,3 +31,4 @@ function getBrand(branded) {
30
31
  return branded[brandSymbol];
31
32
  }
32
33
  exports.getBrand = getBrand;
34
+ //# sourceMappingURL=Brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Brand.js","sources":["../../../src/util/Brand.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getBrand = exports.brand = void 0;\nconst brandSymbol = Symbol('brand');\n/**\n * Create an object of a specific type Brand\n * string branded type.\n *\n * @param brand: The string to Brand onto a simple object\n * @returns A branded empty object\n *\n * @example\n * brand('example') => {[brandSymbol]: 'example'}\n *\n * Which I might use like this:\n * const myType = {content: \"default content\", ...brand<'example'>}\n */\nfunction brand(brand) {\n return {\n [brandSymbol]: brand,\n };\n}\nexports.brand = brand;\n/**\n *\n * @param branded: Branded object\n * @returns The string brand value\n */\nfunction getBrand(branded) {\n return branded[brandSymbol];\n}\nexports.getBrand = getBrand;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;AAC1C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,KAAK,CAAC,KAAK,EAAE;AACtB,IAAI,OAAO;AACX,QAAQ,CAAC,WAAW,GAAG,KAAK;AAC5B,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB;AACA;AACA;AACA;AACA;AACA,SAAS,QAAQ,CAAC,OAAO,EAAE;AAC3B,IAAI,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC;AACD,OAAO,CAAC,QAAQ,GAAG,QAAQ;;"}
@@ -1,2 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=IndexLimit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndexLimit.js","sources":["../../../src/util/IndexLimit.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,2 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=SpreadTuple.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpreadTuple.js","sources":["../../../src/util/SpreadTuple.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
@@ -1,6 +1,8 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.getBrand = exports.brand = void 0;
4
5
  var Brand_1 = require("./Brand");
5
6
  Object.defineProperty(exports, "brand", { enumerable: true, get: function () { return Brand_1.brand; } });
6
7
  Object.defineProperty(exports, "getBrand", { enumerable: true, get: function () { return Brand_1.getBrand; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/util/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getBrand = exports.brand = void 0;\nvar Brand_1 = require(\"./Brand\");\nObject.defineProperty(exports, \"brand\", { enumerable: true, get: function () { return Brand_1.brand; } });\nObject.defineProperty(exports, \"getBrand\", { enumerable: true, get: function () { return Brand_1.getBrand; } });\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;AAC1C,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1G,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;;"}
@@ -71,11 +71,7 @@ export type Authorization<AuthStrategy extends Strategy, AuthField extends strin
71
71
  };
72
72
  };
73
73
  export type OwnerField = object;
74
- type BuilderMethods<T extends object> = {
75
- [K in keyof T as T[K] extends (...args: any) => any ? K : never]: T[K];
76
- };
77
74
  declare function to<SELF extends Authorization<any, any, any>>(this: SELF, operations: Operation[]): Omit<SELF, "to">;
78
- declare function inField<SELF extends Authorization<any, any, any>, Field extends string>(this: SELF, field: Field): BuilderMethods<Omit<SELF, "inField">> & Authorization<SELF[typeof __data]["strategy"], Field, SELF[typeof __data]["multiOwner"]>;
79
75
  /**
80
76
  * Specifies a property of the identity JWT to use in place of `sub::username`
81
77
  * as the value to match against the owner field for authorization.
@@ -93,28 +89,33 @@ declare function withClaimIn<SELF extends Authorization<any, any, any>>(this: SE
93
89
  */
94
90
  export declare const allow: {
95
91
  /**
96
- * Authorize unauthenticated users. By default, `.public()` uses an API key based authorization. You can additionally
97
- * use `.public('iam')` to use IAM based authorization for unauthenticated users.
98
- * @param provider the authentication provider - supports "apiKey" or "iam" as valid providers
92
+ * Authorize unauthenticated users by using API key based authorization.
99
93
  * @returns an authorization rule for unauthenticated users
100
94
  */
101
- readonly public: (provider?: PublicProvider) => Authorization<"public", undefined, false> & {
95
+ readonly publicApiKey: () => Authorization<"public", undefined, false> & {
96
+ to: typeof to;
97
+ };
98
+ /**
99
+ * Authorize unauthenticated users by using IAM based authorization.
100
+ * @returns an authorization rule for unauthenticated users
101
+ */
102
+ readonly guest: () => Authorization<"public", undefined, false> & {
102
103
  to: typeof to;
103
104
  };
104
105
  /**
105
106
  * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally
106
- * use `.private("iam")` or `.private("oidc")` to use IAM or OIDC based authorization for authenticated users.
107
+ * use `.authenticated("iam")` or `.authenticated("oidc")` to use IAM or OIDC based authorization for authenticated users.
107
108
  * @param provider the authentication provider - supports "userPools", "iam", or "oidc"
108
109
  * @returns an authorization rule for authenticated users
109
110
  */
110
- readonly private: (provider?: PrivateProvider) => Authorization<"private", undefined, false> & {
111
+ readonly authenticated: (provider?: PrivateProvider) => Authorization<"private", undefined, false> & {
111
112
  to: typeof to;
112
113
  };
113
114
  /**
114
115
  * Authorize access on a per-user (owner) basis. By setting owner-based authorization, a new `owner: a.string()`
115
116
  * field will be added to the model to store which user "owns" the item. Upon item creation, the "owner field" is
116
- * auto-populated with the authenticated user's information. You can which field should be used as the owner field
117
- * by chaining the * `.inField(...)` method.
117
+ * auto-populated with the authenticated user's information. If you want to specify which field should be used as
118
+ * the owner field, you can use the `ownerDefinedIn` builder function instead.
118
119
  *
119
120
  * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally
120
121
  * use `.owner("oidc")` to use OIDC based authentication to designate the owner.
@@ -127,34 +128,51 @@ export declare const allow: {
127
128
  */
128
129
  readonly owner: (provider?: OwnerProviders) => Authorization<"owner", "owner", false> & {
129
130
  to: typeof to;
130
- inField: typeof inField;
131
+ identityClaim: typeof identityClaim;
132
+ };
133
+ /**
134
+ * Authorize access on a per-user (owner) basis with specifying which field should be used as the owner field.
135
+ *
136
+ * By default, `.owner()` uses an Amazon Cognito user pool based authorization. You can additionally
137
+ * use `.ownerDefinedIn("owner", "oidc")` to use OIDC based authentication to designate the owner.
138
+ *
139
+ * To change the specific claim that should be used as the user identifier within the owner field, chain the
140
+ * `.identityClaim(...)` method.
141
+ *
142
+ * @param ownerField the field that contains the owner information
143
+ * @param provider the authentication provider - supports "userPools", "iam", or "oidc"
144
+ * @returns an authorization rule for authenticated users
145
+ */
146
+ readonly ownerDefinedIn: <T extends string>(ownerField: T, provider?: OwnerProviders) => Authorization<"owner", T, false> & {
147
+ to: typeof to;
131
148
  identityClaim: typeof identityClaim;
132
149
  };
133
150
  /**
134
151
  * Authorize access for multi-user / multi-owner access. By setting multi-owner-based authorization, a new `owners: a.string().array()`
135
152
  * field will be added to the model to store which users "own" the item. Upon item creation, the "owners field" is
136
153
  * auto-populated with the authenticated user's information. To grant other users access to the item, append their user identifier into the `owners` array.
137
- * You can which field should be used as the owners field by chaining the * `.inField(...)` method.
138
154
  *
139
- * By default, `.multipleOwners()` uses an Amazon Cognito user pool based authorization. You can additionally
140
- * use `.multipleOwners("oidc")` to use OIDC based authentication to designate the owner.
155
+ * You can specify which field should be used as the owners field by passing the `ownersField` parameter.
156
+ *
157
+ * By default, `.ownersDefinedIn()` uses an Amazon Cognito user pool based authorization. You can additionally
158
+ * use `.ownersDefinedIn("owners", "oidc")` to use OIDC based authentication to designate the owner.
141
159
  *
142
160
  * To change the specific claim that should be used as the user identifier within the owners field, chain the
143
161
  * `.identityClaim(...)` method.
144
162
  *
163
+ * @param ownersField the field that contains the owners information
145
164
  * @param provider the authentication provider - supports "userPools", "iam", or "oidc"
146
165
  * @returns an authorization rule for authenticated users
147
166
  */
148
- readonly multipleOwners: (provider?: OwnerProviders) => Authorization<"owner", "owner", true> & {
167
+ readonly ownersDefinedIn: <T_1 extends string>(ownersField: T_1, provider?: OwnerProviders) => Authorization<"owner", T_1, true> & {
149
168
  to: typeof to;
150
- inField: typeof inField;
151
169
  identityClaim: typeof identityClaim;
152
170
  };
153
171
  /**
154
172
  * Authorize a specific user group. Provide the name of the specific user group to have access.
155
173
  *
156
- * By default, `.specificGroup()` uses an Amazon Cognito user pool based authorization. You can additionally
157
- * use `.specificGroup("group-name", "oidc")` to use OIDC based authentication to designate the user group.
174
+ * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally
175
+ * use `.group("group-name", "oidc")` to use OIDC based authentication to designate the user group.
158
176
  *
159
177
  * To change the specific claim that should be used as the user group identifier, chain the
160
178
  * `.withClaimIn(...)` method.
@@ -162,15 +180,15 @@ export declare const allow: {
162
180
  * @param provider the authentication provider - supports "userPools" or "oidc"
163
181
  * @returns an authorization rule to grant access by a specific group
164
182
  */
165
- readonly specificGroup: (group: string, provider?: GroupProvider) => Authorization<"groups", undefined, false> & {
183
+ readonly group: (group: string, provider?: GroupProvider) => Authorization<"groups", undefined, false> & {
166
184
  to: typeof to;
167
185
  withClaimIn: typeof withClaimIn;
168
186
  };
169
187
  /**
170
188
  * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.
171
189
  *
172
- * By default, `.specificGroups()` uses an Amazon Cognito user pool based authorization. You can additionally
173
- * use `.specificGroups(["group-a", "group-b"], "oidc")` to use OIDC based authentication to designate the user group.
190
+ * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally
191
+ * use `.groups(["group-a", "group-b"], "oidc")` to use OIDC based authentication to designate the user group.
174
192
  *
175
193
  * To change the specific claim that should be used as the user group identifier, chain the
176
194
  * `.withClaimIn(...)` method.
@@ -178,7 +196,7 @@ export declare const allow: {
178
196
  * @param provider the authentication provider - supports "userPools" or "oidc"
179
197
  * @returns an authorization rule to grant access by a specific group
180
198
  */
181
- readonly specificGroups: (groups: string[], provider?: GroupProvider) => Authorization<"groups", undefined, false> & {
199
+ readonly groups: (groups: string[], provider?: GroupProvider) => Authorization<"groups", undefined, false> & {
182
200
  to: typeof to;
183
201
  withClaimIn: typeof withClaimIn;
184
202
  };
@@ -194,7 +212,7 @@ export declare const allow: {
194
212
  * @param provider the authentication provider - supports "userPools" or "oidc"
195
213
  * @returns an authorization rule to grant access by a specific group
196
214
  */
197
- readonly groupDefinedIn: <T extends string>(groupsField: T, provider?: GroupProvider) => Authorization<"groups", T, false> & {
215
+ readonly groupDefinedIn: <T_2 extends string>(groupsField: T_2, provider?: GroupProvider) => Authorization<"groups", T_2, false> & {
198
216
  to: typeof to;
199
217
  withClaimIn: typeof withClaimIn;
200
218
  };
@@ -210,7 +228,7 @@ export declare const allow: {
210
228
  * @param provider the authentication provider - supports "userPools" or "oidc"
211
229
  * @returns an authorization rule to grant access by a specific group
212
230
  */
213
- readonly groupsDefinedIn: <T_1 extends string>(groupsField: T_1, provider?: GroupProvider) => Authorization<"groups", T_1, true> & {
231
+ readonly groupsDefinedIn: <T_3 extends string>(groupsField: T_3, provider?: GroupProvider) => Authorization<"groups", T_3, true> & {
214
232
  to: typeof to;
215
233
  withClaimIn: typeof withClaimIn;
216
234
  };
@@ -221,6 +239,61 @@ export declare const allow: {
221
239
  to: typeof resourceTo;
222
240
  };
223
241
  };
242
+ /**
243
+ * This is a copy of the {@link allow} defined above, with modifications for custom operations.
244
+ *
245
+ * Removed builder methods:
246
+ *
247
+ * * `owner`
248
+ * * `ownerDefinedIn`
249
+ * * `ownersDefinedIn`
250
+ * * `groupDefinedIn`
251
+ * * `groupsDefinedIn`
252
+ * * `resource`
253
+ * * `.to()` builder method from each available rule builder
254
+ */
255
+ export declare const allowForCustomOperations: {
256
+ /**
257
+ * Authorize unauthenticated users by using API key based authorization.
258
+ * @returns an authorization rule for unauthenticated users
259
+ */
260
+ readonly publicApiKey: () => Authorization<"public", undefined, false>;
261
+ /**
262
+ * Authorize unauthenticated users by using IAM based authorization.
263
+ * @returns an authorization rule for unauthenticated users
264
+ */
265
+ readonly guest: () => Authorization<"public", undefined, false>;
266
+ /**
267
+ * Authorize authenticated users. By default, `.private()` uses an Amazon Cognito user pool based authorization. You can additionally
268
+ * use `.authenticated("iam")` or `.authenticated("oidc")` to use IAM or OIDC based authorization for authenticated users.
269
+ * @param provider the authentication provider - supports "userPools", "iam", or "oidc"
270
+ * @returns an authorization rule for authenticated users
271
+ */
272
+ readonly authenticated: (provider?: PrivateProvider) => Authorization<"private", undefined, false>;
273
+ /**
274
+ * Authorize a specific user group. Provide the name of the specific user group to have access.
275
+ *
276
+ * By default, `.group()` uses an Amazon Cognito user pool based authorization. You can additionally
277
+ * use `.group("group-name", "oidc")` to use OIDC based authentication to designate the user group.
278
+ *
279
+ * @param group the name of the group to authorize
280
+ * @param provider the authentication provider - supports "userPools" or "oidc"
281
+ * @returns an authorization rule to grant access by a specific group
282
+ */
283
+ readonly group: (group: string, provider?: GroupProvider) => Authorization<"groups", undefined, false>;
284
+ /**
285
+ * Authorize multiple specific user groups. Provide the names of the specific user groups to have access.
286
+ *
287
+ * By default, `.groups()` uses an Amazon Cognito user pool based authorization. You can additionally
288
+ * use `.groups(["group-a", "group-b"], "oidc")` to use OIDC based authentication to designate the user group.
289
+ *
290
+ * @param groups the names of the group to authorize defined as an array
291
+ * @param provider the authentication provider - supports "userPools" or "oidc"
292
+ * @returns an authorization rule to grant access by a specific group
293
+ */
294
+ readonly groups: (groups: string[], provider?: GroupProvider) => Authorization<"groups", undefined, false>;
295
+ readonly custom: (provider?: CustomProvider) => Authorization<"custom", undefined, false>;
296
+ };
224
297
  declare function resourceTo<SELF extends ResourceAuthorization>(this: SELF, operations: ResourceOperation[]): Omit<SELF, "to">;
225
298
  /**
226
299
  * Turns the type from a list of `Authorization` rules like this:
@@ -228,8 +301,8 @@ declare function resourceTo<SELF extends ResourceAuthorization>(this: SELF, oper
228
301
  * ```typescript
229
302
  * [
230
303
  * allow.public(),
231
- * allow.owner().inField('otherfield'),
232
- * allow.multipleOwners().inField('editors')
304
+ * allow.ownerDefinedIn('otherfield'),
305
+ * allow.ownersDefinedIn('editors')
233
306
  * ]
234
307
  * ```
235
308
  *
@@ -256,8 +329,8 @@ export type ImpliedAuthField<T extends Authorization<any, any, any>> = T extends
256
329
  * ```typescript
257
330
  * [
258
331
  * allow.public(),
259
- * allow.owner().inField('otherfield'),
260
- * allow.multipleOwners().inField('editors')
332
+ * allow.ownerDefinedIn('otherfield'),
333
+ * allow.ownersDefinedIn('editors')
261
334
  * ]
262
335
  * ```
263
336
  *
@@ -283,5 +356,6 @@ export declare const accessData: <T extends Authorization<any, any, any>>(author
283
356
  groupClaim?: string | undefined;
284
357
  };
285
358
  export declare const accessSchemaData: <T extends SchemaAuthorization<any, any, any>>(authorization: T) => T[typeof __data];
359
+ export type AllowModifier = typeof allow;
360
+ export type AllowModifierForCustomOperation = typeof allowForCustomOperations;
286
361
  export {};
287
- //# sourceMappingURL=Authorization.d.ts.map