integreat 0.8.9 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/README.md +186 -37
  2. package/dist/authenticators/anonymous.d.ts +3 -0
  3. package/dist/authenticators/anonymous.js +22 -0
  4. package/dist/authenticators/anonymous.js.map +1 -0
  5. package/dist/authenticators/ident.d.ts +3 -0
  6. package/dist/authenticators/ident.js +24 -0
  7. package/dist/authenticators/ident.js.map +1 -0
  8. package/dist/authenticators/index.d.ts +1 -0
  9. package/dist/authenticators/index.js +1 -0
  10. package/dist/authenticators/index.js.map +1 -1
  11. package/dist/authenticators/options.d.ts +1 -1
  12. package/dist/authenticators/options.js +2 -2
  13. package/dist/authenticators/options.js.map +1 -1
  14. package/dist/authenticators/token.d.ts +1 -1
  15. package/dist/authenticators/token.js +2 -2
  16. package/dist/authenticators/token.js.map +1 -1
  17. package/dist/close.d.ts +1 -1
  18. package/dist/dispatch.d.ts +4 -4
  19. package/dist/dispatch.js +68 -71
  20. package/dist/dispatch.js.map +1 -1
  21. package/dist/dispatchScheduled.d.ts +2 -6
  22. package/dist/dispatchScheduled.js +7 -8
  23. package/dist/dispatchScheduled.js.map +1 -1
  24. package/dist/handlers/delete.js +4 -5
  25. package/dist/handlers/delete.js.map +1 -1
  26. package/dist/handlers/expire.js +5 -5
  27. package/dist/handlers/expire.js.map +1 -1
  28. package/dist/handlers/get.js +7 -6
  29. package/dist/handlers/get.js.map +1 -1
  30. package/dist/handlers/getAll.js +3 -3
  31. package/dist/handlers/getAll.js.map +1 -1
  32. package/dist/handlers/getIdent.js +10 -10
  33. package/dist/handlers/getIdent.js.map +1 -1
  34. package/dist/handlers/getMeta.js +6 -6
  35. package/dist/handlers/getMeta.js.map +1 -1
  36. package/dist/handlers/index.js +1 -1
  37. package/dist/handlers/index.js.map +1 -1
  38. package/dist/handlers/queue.js +6 -4
  39. package/dist/handlers/queue.js.map +1 -1
  40. package/dist/handlers/run.d.ts +3 -6
  41. package/dist/handlers/run.js +8 -272
  42. package/dist/handlers/run.js.map +1 -1
  43. package/dist/handlers/service.js +3 -6
  44. package/dist/handlers/service.js.map +1 -1
  45. package/dist/handlers/set.js +2 -2
  46. package/dist/handlers/set.js.map +1 -1
  47. package/dist/handlers/setMeta.js +2 -2
  48. package/dist/handlers/setMeta.js.map +1 -1
  49. package/dist/handlers/sync.js +6 -6
  50. package/dist/handlers/sync.js.map +1 -1
  51. package/dist/index.d.ts +8 -9
  52. package/dist/index.js +5 -6
  53. package/dist/index.js.map +1 -1
  54. package/dist/instance.d.ts +20 -0
  55. package/dist/instance.js +106 -0
  56. package/dist/instance.js.map +1 -0
  57. package/dist/jobs/Job.d.ts +10 -0
  58. package/dist/jobs/Job.js +109 -0
  59. package/dist/jobs/Job.js.map +1 -0
  60. package/dist/jobs/Schedule.d.ts +7 -0
  61. package/dist/jobs/Schedule.js +29 -0
  62. package/dist/jobs/Schedule.js.map +1 -0
  63. package/dist/jobs/Step.d.ts +14 -0
  64. package/dist/jobs/Step.js +256 -0
  65. package/dist/jobs/Step.js.map +1 -0
  66. package/dist/jobs/types.d.ts +23 -0
  67. package/dist/{service/endpoints → jobs}/types.js.map +1 -1
  68. package/dist/listen.d.ts +1 -1
  69. package/dist/middleware/completeIdent.js +1 -1
  70. package/dist/middleware/completeIdent.js.map +1 -1
  71. package/dist/schema/Schema.d.ts +12 -0
  72. package/dist/schema/Schema.js +34 -0
  73. package/dist/schema/Schema.js.map +1 -0
  74. package/dist/schema/accessForAction.d.ts +1 -1
  75. package/dist/schema/accessForAction.js +2 -3
  76. package/dist/schema/accessForAction.js.map +1 -1
  77. package/dist/schema/castFns/boolean.d.ts +1 -0
  78. package/dist/schema/castFns/boolean.js +9 -0
  79. package/dist/schema/castFns/boolean.js.map +1 -0
  80. package/dist/schema/castFns/date.d.ts +1 -0
  81. package/dist/{transformers/builtIns → schema/castFns}/date.js +1 -4
  82. package/dist/schema/castFns/date.js.map +1 -0
  83. package/dist/schema/castFns/integer.d.ts +1 -0
  84. package/dist/{transformers/builtIns → schema/castFns}/integer.js +1 -4
  85. package/dist/schema/castFns/integer.js.map +1 -0
  86. package/dist/schema/castFns/nonPrimitive.d.ts +2 -0
  87. package/dist/schema/castFns/nonPrimitive.js +58 -0
  88. package/dist/schema/castFns/nonPrimitive.js.map +1 -0
  89. package/dist/schema/castFns/number.d.ts +1 -0
  90. package/dist/{transformers/builtIns → schema/castFns}/number.js +1 -4
  91. package/dist/schema/castFns/number.js.map +1 -0
  92. package/dist/schema/castFns/object.d.ts +1 -0
  93. package/dist/schema/castFns/object.js +10 -0
  94. package/dist/schema/castFns/object.js.map +1 -0
  95. package/dist/schema/castFns/string.d.ts +1 -0
  96. package/dist/{transformers/builtIns → schema/castFns}/string.js +1 -4
  97. package/dist/schema/castFns/string.js.map +1 -0
  98. package/dist/schema/createCast.d.ts +3 -0
  99. package/dist/schema/createCast.js +125 -0
  100. package/dist/schema/createCast.js.map +1 -0
  101. package/dist/schema/expandShape.d.ts +2 -0
  102. package/dist/schema/expandShape.js +34 -0
  103. package/dist/schema/expandShape.js.map +1 -0
  104. package/dist/schema/types.d.ts +8 -2
  105. package/dist/service/Auth.d.ts +4 -7
  106. package/dist/service/Auth.js +18 -2
  107. package/dist/service/Auth.js.map +1 -1
  108. package/dist/service/Connection.d.ts +2 -2
  109. package/dist/service/Connection.js.map +1 -1
  110. package/dist/service/Endpoint.d.ts +20 -0
  111. package/dist/service/Endpoint.js +85 -0
  112. package/dist/service/Endpoint.js.map +1 -0
  113. package/dist/service/Service.d.ts +30 -0
  114. package/dist/service/Service.js +178 -0
  115. package/dist/service/Service.js.map +1 -0
  116. package/dist/service/types.d.ts +34 -28
  117. package/dist/service/utils/authAction.d.ts +26 -0
  118. package/dist/service/{authorize/action.js → utils/authAction.js} +19 -8
  119. package/dist/service/utils/authAction.js.map +1 -0
  120. package/dist/service/utils/authData.d.ts +7 -0
  121. package/dist/service/{authorize/data.js → utils/authData.js} +17 -13
  122. package/dist/service/utils/authData.js.map +1 -0
  123. package/dist/service/utils/cast.d.ts +7 -0
  124. package/dist/service/utils/cast.js +21 -0
  125. package/dist/service/utils/cast.js.map +1 -0
  126. package/dist/service/{endpoints/compare.d.ts → utils/compareEndpoints.d.ts} +1 -1
  127. package/dist/service/{endpoints/compare.js → utils/compareEndpoints.js} +3 -1
  128. package/dist/service/utils/compareEndpoints.js.map +1 -0
  129. package/dist/service/utils/incoming.d.ts +5 -0
  130. package/dist/service/utils/incoming.js +81 -0
  131. package/dist/service/utils/incoming.js.map +1 -0
  132. package/dist/service/utils/matchEnpoints.d.ts +3 -0
  133. package/dist/service/{endpoints/match.js → utils/matchEnpoints.js} +24 -5
  134. package/dist/service/utils/matchEnpoints.js.map +1 -0
  135. package/dist/service/utils/options.d.ts +17 -0
  136. package/dist/service/utils/options.js +41 -0
  137. package/dist/service/utils/options.js.map +1 -0
  138. package/dist/service/utils/resolveAuth.d.ts +5 -0
  139. package/dist/service/utils/resolveAuth.js +34 -0
  140. package/dist/service/utils/resolveAuth.js.map +1 -0
  141. package/dist/service/utils/send.d.ts +3 -0
  142. package/dist/service/utils/send.js +15 -0
  143. package/dist/service/utils/send.js.map +1 -0
  144. package/dist/transformers/index.js +0 -6
  145. package/dist/transformers/index.js.map +1 -1
  146. package/dist/types.d.ts +53 -55
  147. package/dist/utils/action.d.ts +4 -2
  148. package/dist/utils/action.js +18 -3
  149. package/dist/utils/action.js.map +1 -1
  150. package/dist/utils/array.d.ts +1 -0
  151. package/dist/utils/array.js +4 -0
  152. package/dist/utils/array.js.map +1 -1
  153. package/dist/utils/createMapOptions.d.ts +4 -4
  154. package/dist/utils/createMapOptions.js +10 -5
  155. package/dist/utils/createMapOptions.js.map +1 -1
  156. package/dist/utils/createUnknownServiceError.js +1 -1
  157. package/dist/utils/createUnknownServiceError.js.map +1 -1
  158. package/dist/utils/getField.d.ts +1 -1
  159. package/dist/utils/getField.js +1 -1
  160. package/dist/utils/getField.js.map +1 -1
  161. package/dist/utils/getService.d.ts +3 -3
  162. package/dist/utils/getService.js +1 -1
  163. package/dist/utils/getService.js.map +1 -1
  164. package/dist/utils/indexUtils.d.ts +2 -1
  165. package/dist/utils/indexUtils.js +6 -2
  166. package/dist/utils/indexUtils.js.map +1 -1
  167. package/dist/utils/is.d.ts +5 -8
  168. package/dist/utils/is.js +9 -13
  169. package/dist/utils/is.js.map +1 -1
  170. package/dist/utils/mergeDefinitions.d.ts +1 -1
  171. package/dist/utils/mergeResources.d.ts +1 -1
  172. package/dist/utils/modifyOperationObject.d.ts +1 -0
  173. package/dist/utils/modifyOperationObject.js +11 -0
  174. package/dist/utils/modifyOperationObject.js.map +1 -0
  175. package/dist/utils/mutateAndSend.d.ts +2 -2
  176. package/dist/utils/mutationHelpers.js +12 -11
  177. package/dist/utils/mutationHelpers.js.map +1 -1
  178. package/dist/utils/validateFilters.d.ts +1 -1
  179. package/dist/utils/validateFilters.js +3 -5
  180. package/dist/utils/validateFilters.js.map +1 -1
  181. package/dist/utils/validation.d.ts +3 -0
  182. package/dist/utils/validation.js +34 -0
  183. package/dist/utils/validation.js.map +1 -0
  184. package/package.json +9 -8
  185. package/dist/adapters/index.d.ts +0 -1
  186. package/dist/adapters/index.js +0 -2
  187. package/dist/adapters/index.js.map +0 -1
  188. package/dist/adapters/uri.d.ts +0 -3
  189. package/dist/adapters/uri.js +0 -23
  190. package/dist/adapters/uri.js.map +0 -1
  191. package/dist/create.d.ts +0 -40
  192. package/dist/create.js +0 -79
  193. package/dist/create.js.map +0 -1
  194. package/dist/mutations/exchangeForm.d.ts +0 -9
  195. package/dist/mutations/exchangeForm.js +0 -5
  196. package/dist/mutations/exchangeForm.js.map +0 -1
  197. package/dist/mutations/exchangeJson.d.ts +0 -47
  198. package/dist/mutations/exchangeJson.js +0 -40
  199. package/dist/mutations/exchangeJson.js.map +0 -1
  200. package/dist/mutations/exchangeUri.d.ts +0 -16
  201. package/dist/mutations/exchangeUri.js +0 -13
  202. package/dist/mutations/exchangeUri.js.map +0 -1
  203. package/dist/mutations/index.d.ts +0 -72
  204. package/dist/mutations/index.js +0 -9
  205. package/dist/mutations/index.js.map +0 -1
  206. package/dist/schema/createCastMapping.d.ts +0 -3
  207. package/dist/schema/createCastMapping.js +0 -133
  208. package/dist/schema/createCastMapping.js.map +0 -1
  209. package/dist/schema/index.d.ts +0 -13
  210. package/dist/schema/index.js +0 -43
  211. package/dist/schema/index.js.map +0 -1
  212. package/dist/service/authorize/action.d.ts +0 -4
  213. package/dist/service/authorize/action.js.map +0 -1
  214. package/dist/service/authorize/data.d.ts +0 -7
  215. package/dist/service/authorize/data.js.map +0 -1
  216. package/dist/service/endpoints/compare.js.map +0 -1
  217. package/dist/service/endpoints/create.d.ts +0 -8
  218. package/dist/service/endpoints/create.js +0 -78
  219. package/dist/service/endpoints/create.js.map +0 -1
  220. package/dist/service/endpoints/index.d.ts +0 -6
  221. package/dist/service/endpoints/index.js +0 -15
  222. package/dist/service/endpoints/index.js.map +0 -1
  223. package/dist/service/endpoints/match.d.ts +0 -3
  224. package/dist/service/endpoints/match.js.map +0 -1
  225. package/dist/service/endpoints/types.d.ts +0 -36
  226. package/dist/service/index.d.ts +0 -18
  227. package/dist/service/index.js +0 -250
  228. package/dist/service/index.js.map +0 -1
  229. package/dist/transformers/builtIns/boolean.d.ts +0 -3
  230. package/dist/transformers/builtIns/boolean.js +0 -12
  231. package/dist/transformers/builtIns/boolean.js.map +0 -1
  232. package/dist/transformers/builtIns/date.d.ts +0 -4
  233. package/dist/transformers/builtIns/date.js.map +0 -1
  234. package/dist/transformers/builtIns/index.d.ts +0 -3
  235. package/dist/transformers/builtIns/index.js +0 -20
  236. package/dist/transformers/builtIns/index.js.map +0 -1
  237. package/dist/transformers/builtIns/integer.d.ts +0 -3
  238. package/dist/transformers/builtIns/integer.js.map +0 -1
  239. package/dist/transformers/builtIns/number.d.ts +0 -4
  240. package/dist/transformers/builtIns/number.js.map +0 -1
  241. package/dist/transformers/builtIns/object.d.ts +0 -3
  242. package/dist/transformers/builtIns/object.js +0 -13
  243. package/dist/transformers/builtIns/object.js.map +0 -1
  244. package/dist/transformers/builtIns/reference.d.ts +0 -3
  245. package/dist/transformers/builtIns/reference.js +0 -48
  246. package/dist/transformers/builtIns/reference.js.map +0 -1
  247. package/dist/transformers/builtIns/string.d.ts +0 -3
  248. package/dist/transformers/builtIns/string.js.map +0 -1
  249. package/dist/transformers/builtIns/unarray.d.ts +0 -3
  250. package/dist/transformers/builtIns/unarray.js +0 -9
  251. package/dist/transformers/builtIns/unarray.js.map +0 -1
  252. package/dist/transformers/form.d.ts +0 -3
  253. package/dist/transformers/form.js +0 -33
  254. package/dist/transformers/form.js.map +0 -1
  255. package/dist/transformers/generateUri.d.ts +0 -9
  256. package/dist/transformers/generateUri.js +0 -66
  257. package/dist/transformers/generateUri.js.map +0 -1
  258. package/dist/transformers/json.d.ts +0 -3
  259. package/dist/transformers/json.js +0 -20
  260. package/dist/transformers/json.js.map +0 -1
  261. package/dist/utils/createSchedule.d.ts +0 -7
  262. package/dist/utils/createSchedule.js +0 -26
  263. package/dist/utils/createSchedule.js.map +0 -1
  264. package/dist/utils/xor.d.ts +0 -1
  265. package/dist/utils/xor.js +0 -4
  266. package/dist/utils/xor.js.map +0 -1
  267. /package/dist/{service/endpoints → jobs}/types.js +0 -0
package/README.md CHANGED
@@ -111,8 +111,10 @@ const services = [
111
111
  transporter: 'http', // Use the http transporter
112
112
  adapters: ['json'], // Run the request and the response through the json adapter
113
113
  options: {
114
- // Options for the transporter
115
- uri: 'https://cat-fact.herokuapp.com/facts', // Only the uri is needed here
114
+ transporter: {
115
+ // Options for the transporter
116
+ uri: 'https://cat-fact.herokuapp.com/facts', // Only the uri is needed here
117
+ },
116
118
  },
117
119
  endpoints: [
118
120
  {
@@ -204,7 +206,7 @@ for transporters, adapters, etc.
204
206
  id: <service id>,
205
207
  transporter: <transporter id>,
206
208
  adapters: [<adapter id>, <adapter id>, ...],
207
- auth: <auth id>,
209
+ auth: <auth config>,
208
210
  meta: <type id>,
209
211
  options: {...},
210
212
  mutation: <mutation pipeline>,
@@ -226,7 +228,17 @@ The `auth` property should normally be set to the id of an
226
228
  [auth definition](#service-authentication), if the service requires
227
229
  authentication. In cases where the service is authenticated by other means, e.g.
228
230
  by including username and password in the uri, set the `auth` property to `true`
229
- to signal that this is an authenticated service.
231
+ to signal that this is an authenticated service. For services accepting incoming
232
+ actions, `auth` should be set to an object with
233
+ `{ outgoing: <auth id | true>, incoming: <auth id | true>}`.
234
+
235
+ **Note:** When connecting to a service for listening, the `outgoing` auth is
236
+ used. `incoming` is only used for validating the actions being dispatched "back"
237
+ from the service.
238
+
239
+ In `options`, you may provide options for transporters and adapters. It is
240
+ merged with the `options` object on the endpoint. See
241
+ [the `options` object](#options-object) for more on this.
230
242
 
231
243
  ### Endpoints
232
244
 
@@ -278,18 +290,18 @@ Here's the format of an endpoint definition:
278
290
  action: <action type>,
279
291
  params: {...},
280
292
  incoming: <boolean>,
281
- filters: {...}
293
+ conditions: [...]
282
294
  },
283
295
  validate: [
284
296
  {
285
297
  condition: <mutation pipeline>,
286
298
  failResponse: <response object>
287
299
  }
288
- ]
289
- mutation: <mutation pipeline>,
290
- options: {...},
300
+ ],
301
+ mutate: <mutation pipeline>,
291
302
  allowRawRequest: <boolean>,
292
303
  allowRawResponse: <boolean>
304
+ options: {...},
293
305
  }
294
306
  ```
295
307
 
@@ -305,31 +317,29 @@ specify a few things:
305
317
  - `match`: The match object is used to decide the right endpoint for an action.
306
318
  More one this in the [Match properties](#match-properties) section.
307
319
  - `validate`: This is an array of condition that have to be met in order for
308
- Integreat to proceed with the endpoint. This may sound similar to `match`, but
309
- `validate` is only processed after a match is found, and if the validation
310
- fails, no other endpoint is considered and the `failResponse` is returned as
311
- the response from this action without ever running mutations or sending
312
- anything to the service (or a `badrequest` response if no `failResponse` is
313
- provided). The `condition` is a mutation pipeline that should return a truthy
314
- value for the validation to pass. Any falsy value will cause the validation to
315
- fail. If `validate` is missing or an empty array, no validation will be done.
316
- - `mutation`: A mutation pipeline for the endpoint. The pipeline is run for both
320
+ Integreat to proceed with the endpoint. The `condition` is a mutation pipeline
321
+ that should return a truthy value for the validation to pass. Any falsy value
322
+ will cause the validation to fail. If `validate` is missing or an empty array,
323
+ no validation will be done. This may sound similar to `match`, but `validate`
324
+ is only processed after a match is found, and if the validation fails, no
325
+ other endpoint is considered. On a failing validation, the `failResponse` is
326
+ returned as the response from this action, or a `badrequest` response if no
327
+ `failResponse` is provided. There's also a shorthand, where you set
328
+ `failResponse` to a string, which will be the `error` message of the
329
+ `badrequest` response. The response is passed through the mutation pipeline.
330
+ - `mutate`: A mutation pipeline for the endpoint. The pipeline is run for both
317
331
  actions going to a service and the response coming back, so keep this in mind
318
332
  when you set up this pipeline. See [Mutation pipelines](#mutations)
319
- for more on how to define the mutation.
320
- - `options`: This object will be passed on to the transporter and may contain
321
- any properties that are meaningful to the transporter. You may also add other
322
- properties for use in your mutations, but keep in mind that they will be sent
323
- to the transporter. The endpoint `options` object is merged with the service
324
- `options` object. Endpoint properties will override equally named service
325
- properties, but this is done through deep merging, so child objects will be
326
- merged as well.
333
+ for more on how to define the mutation. `mutation` is an alias for `mutate`.
327
334
  - `allowRawRequest`: When set to `true`, payload `data` sent to this endpoint
328
335
  will not by cast automatically nor will an error be returned if the data is
329
336
  not typed.
330
337
  - `allowRawResponse`: When set to `true`, response `data` coming from this
331
338
  endpoint will not by cast automatically nor will an error be returned if the
332
339
  data is not typed.
340
+ - `options`: This object is merged with the `options` object on the service
341
+ definition, and provide options for transporters and adapters. See
342
+ [the `options` object](#options-object) for more on this.
333
343
 
334
344
  #### Match properties
335
345
 
@@ -355,10 +365,15 @@ An endpoint may specify none or more of the following match properties:
355
365
  case several match, the endpoint with more specified params will be preferred.
356
366
  - `incoming`: If this is `true`, it will only match incoming actions, if `false`
357
367
  only outgoing, and if not set, it will match both.
358
- - `filters`: The filter object specifies a set of tests that needs to match an
359
- action. The key of the object is a full dot notation path for the action
360
- object, e.g. `payload.onlyArchived` and the value is a
361
- [JSON Schema Validation object](https://json-schema.org/draft/2020-12/json-schema-validation.html).
368
+ - `conditions`: An array of mutation pipelines that will be run on the action to
369
+ see if it's a fit for this endpoint. If all pipelines return a truthy value,
370
+ the endpoint is chosen (given that the other match properties also match). We
371
+ rely on JavaScript definition of 'truthy' here, so any value that is not
372
+ `false`, `null`, `undefined`, `0`, `NaN`, or `''` will be considered truthy.
373
+
374
+ > There used to be a `filters` property on the endpoint match object. It is
375
+ > still supported, but it's deprecated and will be removed in v1.1. Please use
376
+ > `conditions` instead.
362
377
 
363
378
  > Editor's note: Describe what incoming actions are, and give more details on
364
379
  > filters.
@@ -399,7 +414,9 @@ Example service definition with endpoint match object:
399
414
  }
400
415
  },
401
416
  options: {
402
- uri: 'https://example.api.com/1.0/{author}/{type}_log?archive={archive}'
417
+ transporter: {
418
+ uri: 'https://example.api.com/1.0/{author}/{type}_log?archive={archive}'
419
+ }
403
420
  }
404
421
  }
405
422
  ],
@@ -407,6 +424,97 @@ Example service definition with endpoint match object:
407
424
  }
408
425
  ```
409
426
 
427
+ ### Options object
428
+
429
+ A service defintion may have `options` object in two places: Direction on the
430
+ service definition and on any of the endpoints. When an action is sent to an
431
+ endpoint, the combination of the two `options` are used. Also, there may be
432
+ different options for the transporter and for the adapters.
433
+
434
+ Example of an `options` object set on the service definition:
435
+
436
+ ```javascript
437
+ {
438
+ id: 'entries',
439
+ options: {
440
+ uri: 'https://ourapi.com/v1',
441
+ transporter: {
442
+ method: 'POST',
443
+ incoming: { port: 3000 }
444
+ },
445
+ adapters: {
446
+ xml: { namespaces: { ... } },
447
+ // ...
448
+ }
449
+ }
450
+ }
451
+ ```
452
+
453
+ Any properties set directly on the `options` object or on a `transporter`
454
+ property, are treated as options for the transporter. If there are properties on
455
+ both the `options` and a `transporter` object, they will be merged, with the
456
+ `transporter` object having priority if conflicts. This is a shallow merge, so
457
+ objects used in the options will not be merged.
458
+
459
+ In the example above, the options passed to the transporter will include `uri`,
460
+ `method`, and `incoming`.
461
+
462
+ The `incoming` object on the transporter options is a bit special, as it holds
463
+ separate options for transporters that support incoming requests trough the
464
+ `listen()` method. If there are `incoming` objects on both the `options` and
465
+ `transporter` objects, they will be merged, again with priority to the one on
466
+ the `transporter` object.
467
+
468
+ Note that we recommend setting transporter options on the `transporter` object
469
+ for clarity, but both will work.
470
+
471
+ Adapter options may be given in an `adapters` object, where each adapter may
472
+ have its own options, set with the id of the adapter as a key. In the example
473
+ above, the `xml` adapter will be given the `namespaces` object. A requirement
474
+ for this, is that the adapter actually have an id. Adapters provided directly on
475
+ service definition may not have an id, but all adapters that are referenced by
476
+ an id, will also be given options set on that id, which is the common behavior.
477
+
478
+ Finally, when all this sorting have been done on options from both the service
479
+ definition and an endpoint, the two options structures are merged before being
480
+ used. Here, the endpoint options take priority, so that you may set a general
481
+ option on the service, and override it on the endpoint.
482
+
483
+ Example of endpoint options overriding service options:
484
+
485
+ ```javascript
486
+ {
487
+ id: 'entries',
488
+ options: {
489
+ transporter: {
490
+ uri: 'https://ourapi.com/v1',
491
+ method: 'GET',
492
+ }
493
+ },
494
+ endpoints: [
495
+ {
496
+ match: { ... }
497
+ },
498
+ {
499
+ match: { ... },
500
+ options: {
501
+ transporter: {
502
+ method: 'POST'
503
+ }
504
+ }
505
+ }
506
+ ]
507
+ }
508
+ ```
509
+
510
+ Here, the first enpoint will be given `method: 'GET'`, while the next will get
511
+ `method: 'POST'`.
512
+
513
+ Before actions are passed through mutations and finally passed to the
514
+ transporter, the merged transporter options is set on an `options` property in
515
+ the `meta` object of the action. This way, you may also mutate these options
516
+ before they reach the transporter.
517
+
410
518
  ### Service authentication
411
519
 
412
520
  This definition format is used to authenticate with a service:
@@ -431,6 +539,9 @@ This definition format is used to authenticate with a service:
431
539
 
432
540
  Available authenticators:
433
541
 
542
+ - `ident`: Will always grant access and `validate()` will return an ident with
543
+ the id provided in `identId` on the `options` object, or `'anonymous'` if no
544
+ `identId` is provided. This is built into Integreat.
434
545
  - `options`: Will pass on the options as authentication, so whatever you provide
435
546
  here is the authentication. What options to provide, then, is depending on
436
547
  what the relevant transporter requires. This is built into Integreat.
@@ -810,7 +921,7 @@ Set the `access` property on a schema to enforce permission checking. This
810
921
  applies to any service that provides data in this schema.
811
922
 
812
923
  The simplest access rule is `auth`, which means that anyone can do anything with
813
- the data of this schema, as long as they are authenticated. Being authenticated
924
+ the data of this schema, as long as they are authenticated. Being authenticated,
814
925
  in this context, means that the dispatched action has an `ident` in the `meta`
815
926
  object. See [the section on idents](#idents) for more on this.
816
927
 
@@ -1084,7 +1195,8 @@ Current meta properties reserved by Integreat:
1084
1195
  Integreat).
1085
1196
  - `options`: Used for passing the processed service endpoint options object to
1086
1197
  a transporter. The `options` object is available through mutations, so that
1087
- you may modify it futher before it goes to the transporter.
1198
+ you may modify it futher before it goes to the transporter. Note that only the
1199
+ transporter options are provided here, not the adapter options.
1088
1200
  - `authorized`: An internal flag signaling that the action has been authorized.
1089
1201
  Will be removed from any dispatched actions.
1090
1202
 
@@ -1098,12 +1210,12 @@ When you dispatch an action, you will get a response object back in this format:
1098
1210
  data: <data from the service, usually mutated>,
1099
1211
  error: <error message>,
1100
1212
  warning: <warning message>,
1101
- access: <ident of the user>,
1213
+ origin: <code telling where an error originated>
1214
+ access: <holds the ident actually being used>,
1102
1215
  paging: <pagination objects>,
1103
1216
  params: <key/value pairs>,
1104
1217
  headers: <key/value pairs>,
1105
1218
  responses: <array of sub-responses when relevant>,
1106
- meta: <meta object>
1107
1219
  }
1108
1220
  ```
1109
1221
 
@@ -1120,6 +1232,13 @@ When you dispatch an action, you will get a response object back in this format:
1120
1232
  should know, the warning message is where you'll get noticed. An example is
1121
1233
  when you get an array of data items, but some of them was removed due to the
1122
1234
  access of the ident on the action.
1235
+ - `origin`: When the response is an error (status is not `'ok'` or `'queue'`),
1236
+ this property will hold a code for where the error originated. The goal is to
1237
+ set it as close to the actual origin as possible. See
1238
+ [list of origin codes](#origin-codes) below.
1239
+ - `access`: An object holding the `ident` that was actually being used. This may
1240
+ be different than the `meta.ident` on the action, as the ident may also be
1241
+ mutated or completed with roles etc. along the way.
1123
1242
  - `paging`: For services and transporters that support
1124
1243
  [pagination](#pagination), this object will hold information about how to get
1125
1244
  the next or previous page, in a `next` or `prev` object. These objects are
@@ -1136,8 +1255,6 @@ When you dispatch an action, you will get a response object back in this format:
1136
1255
  `SYNC` or `RUN`. The action handlers _may_ then provide an array of all the
1137
1256
  sub-response objects here.
1138
1257
 
1139
- > Editor's note: Do we return access in responses?
1140
- > Editor's note: Do we return meta in responses?
1141
1258
  > Editor's note: Is it correct that queues return the id in the data?
1142
1259
 
1143
1260
  When the status is `queued`, the id of the queued action may found in
@@ -1146,7 +1263,8 @@ the same as `action.meta.id`.
1146
1263
 
1147
1264
  ### Status codes
1148
1265
 
1149
- The `status` or the action response will be one of the following status codes:
1266
+ The `status` property on the action response will be one of the following status
1267
+ codes:
1150
1268
 
1151
1269
  - `ok`: Everything is well, data is returned as expected
1152
1270
  - `queued`: The action has been queued. This is regarded as a success status
@@ -1160,6 +1278,37 @@ The `status` or the action response will be one of the following status codes:
1160
1278
  - `badresponse`: Response data is not as expected
1161
1279
  - `error`: Any other error
1162
1280
 
1281
+ ### Origin codes
1282
+
1283
+ The `origin` property is not exclusively defined, but these are some of the more
1284
+ common codes:
1285
+
1286
+ - `service:<service id>`: The error originated in service. There may also be
1287
+ third level of detail here, if the service sets an origin code of its own.
1288
+ E.g. `'service:entries:handshake`.
1289
+ - `middleware:service:<service id>`: The error happened in the middleware chain
1290
+ on the service side.
1291
+ - `internal:service:<service id>`: Used for errors in the service class, that
1292
+ has nothing to do with the actual service, e.g. if the service class is not
1293
+ configured correctly.
1294
+ - `mutate:request`: The error was set in a request mutation pipeline.
1295
+ - `mutate:response`: The error was set in a response mutation pipeline.
1296
+ - `auth:action`: The error occured while attempting to authorize the action.
1297
+ - `auth:data`: The error occured while attempting to authorize data in an
1298
+ action payload or a response.
1299
+ - `auth:service:<service id>`: The error occured while attempting to authorize
1300
+ the service with the given id.
1301
+ - `auth:service:<service id>:<authenticator id>`: The error occured while
1302
+ attempting to authorize the service with the given id, through the given
1303
+ authenticator.
1304
+ - `handler:<handler id>`: The error occurred with the handler with the given id,
1305
+ e.g. `'handler:GET'`. This means the error did happen in the service or the
1306
+ mutation pipelines, but in the internal workings of then handler.
1307
+ - `middleware:dispatch`: The error happened within the middleware chain, on the
1308
+ `dispatch()` end (not on the service end).
1309
+ - `dispatch`: This is the lowest level of origin, as the error happened within
1310
+ the `dispatch()` method.
1311
+
1163
1312
  ### Idents
1164
1313
 
1165
1314
  An ident in Integreat is basically an id unique to one participant in the
@@ -0,0 +1,3 @@
1
+ import type { Authenticator } from '../types.js';
2
+ declare const anonymousAuth: Authenticator;
3
+ export default anonymousAuth;
@@ -0,0 +1,22 @@
1
+ const anonymousAuth = {
2
+ id: 'anonymous',
3
+ async authenticate(_options) {
4
+ return { status: 'granted' };
5
+ },
6
+ isAuthenticated(_authentication) {
7
+ return true;
8
+ },
9
+ async validate(_authentication) {
10
+ return { id: 'anonymous' };
11
+ },
12
+ authentication: {
13
+ asObject(_authentication) {
14
+ return {};
15
+ },
16
+ asHttpHeaders(_authentication) {
17
+ return {};
18
+ },
19
+ },
20
+ };
21
+ export default anonymousAuth;
22
+ //# sourceMappingURL=anonymous.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anonymous.js","sourceRoot":"","sources":["../../src/authenticators/anonymous.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAkB;IACnC,EAAE,EAAE,WAAW;IAOf,KAAK,CAAC,YAAY,CAAC,QAAQ;QACzB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAMD,eAAe,CAAC,eAAe;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAMD,KAAK,CAAC,QAAQ,CAAC,eAAe;QAC5B,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,CAAA;IAC5B,CAAC;IAED,cAAc,EAAE;QAMd,QAAQ,CAAC,eAAe;YACtB,OAAO,EAAE,CAAA;QACX,CAAC;QAOD,aAAa,CAAC,eAAe;YAC3B,OAAO,EAAE,CAAA;QACX,CAAC;KACF;CACF,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Authenticator } from '../types.js';
2
+ declare const identAuth: Authenticator;
3
+ export default identAuth;
@@ -0,0 +1,24 @@
1
+ const identAuth = {
2
+ id: 'ident',
3
+ async authenticate(_options) {
4
+ return { status: 'granted' };
5
+ },
6
+ isAuthenticated(_authentication) {
7
+ return true;
8
+ },
9
+ async validate(_authentication, options) {
10
+ const { identId } = options || {};
11
+ const id = typeof identId === 'string' ? identId : 'anonymous';
12
+ return { id };
13
+ },
14
+ authentication: {
15
+ asObject(_authentication) {
16
+ return {};
17
+ },
18
+ asHttpHeaders(_authentication) {
19
+ return {};
20
+ },
21
+ },
22
+ };
23
+ export default identAuth;
24
+ //# sourceMappingURL=ident.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ident.js","sourceRoot":"","sources":["../../src/authenticators/ident.ts"],"names":[],"mappings":"AAOA,MAAM,SAAS,GAAkB;IAC/B,EAAE,EAAE,OAAO;IAOX,KAAK,CAAC,YAAY,CAAC,QAAQ;QACzB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAMD,eAAe,CAAC,eAAe;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAMD,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO;QACrC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QACjC,MAAM,EAAE,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAA;QAC9D,OAAO,EAAE,EAAE,EAAE,CAAA;IACf,CAAC;IAED,cAAc,EAAE;QAMd,QAAQ,CAAC,eAAe;YACtB,OAAO,EAAE,CAAA;QACX,CAAC;QAOD,aAAa,CAAC,eAAe;YAC3B,OAAO,EAAE,CAAA;QACX,CAAC;KACF;CACF,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -1,2 +1,3 @@
1
+ export { default as ident } from './ident.js';
1
2
  export { default as options } from './options.js';
2
3
  export { default as token } from './token.js';
@@ -1,3 +1,4 @@
1
+ export { default as ident } from './ident.js';
1
2
  export { default as options } from './options.js';
2
3
  export { default as token } from './token.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authenticators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authenticators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { Authenticator } from '../service/types.js';
1
+ import type { Authenticator } from '../types.js';
2
2
  declare const optionsAuth: Authenticator;
3
3
  export default optionsAuth;
@@ -1,9 +1,9 @@
1
1
  import { isObject } from '../utils/is.js';
2
2
  const optionsAuth = {
3
- async authenticate(options, _action) {
3
+ async authenticate(options) {
4
4
  return { status: 'granted', ...options };
5
5
  },
6
- isAuthenticated(authentication, _options, _action) {
6
+ isAuthenticated(authentication) {
7
7
  return !!(authentication && authentication.status === 'granted');
8
8
  },
9
9
  authentication: {
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/authenticators/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAA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AAK,SAAS,CAAC,CAAA;IAClE,CAAC;IAED,cAAc,EAAE;QAOd,QAAQ,CAAC,cAAqC;YAC5C,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE;gBAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,cAAc,CAAA;gBAC7C,IAAI,MAAM,KAAK,SAAS,EAAE;oBACxB,OAAO,OAAO,CAAA;iBACf;aACF;YACD,OAAO,EAAE,CAAA;QACX,CAAC;QAOD,aAAa,CACX,cAAqC;YAErC,IAAI,QAAQ,CAAC,cAAc,CAAC,EAAE;gBAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,cAAc,CAAA;gBAC7C,IAAI,MAAM,KAAK,SAAS,EAAE;oBACxB,OAAO,OAAO,CAAA;iBACf;aACF;YACD,OAAO,EAAE,CAAA;QACX,CAAC;KACF;CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { Authenticator } from '../service/types.js';
1
+ import type { Authenticator } from '../types.js';
2
2
  export interface TokenObject extends Record<string, unknown> {
3
3
  token?: string | null;
4
4
  type?: string;
@@ -9,13 +9,13 @@ const getTypeAndToken = (authentication) => {
9
9
  };
10
10
  };
11
11
  const tokenAuth = {
12
- async authenticate(options, _action) {
12
+ async authenticate(options) {
13
13
  const { token = null, type, encode = false } = options || {};
14
14
  return token
15
15
  ? { status: 'granted', token, type, encode }
16
16
  : { status: 'refused' };
17
17
  },
18
- isAuthenticated(authentication, _options, _action) {
18
+ isAuthenticated(authentication) {
19
19
  return !!(authentication &&
20
20
  authentication.status === 'granted' &&
21
21
  authentication.token);
@@ -1 +1 @@
1
- {"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/authenticators/token.ts"],"names":[],"mappings":"AAiBA,MAAM,eAAe,GAAG,CAAC,cAA0C,EAAE,EAAE;IACrE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,c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I,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAC1E,CAAC;KACF;CACF,CAAA;AAED,eAAe,SAAS,CAAA"}
package/dist/close.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Service } from './service/types.js';
1
+ import type Service from './service/Service.js';
2
2
  import type { Response } from './types.js';
3
3
  export default function close(services: Service[]): Promise<Response>;
@@ -1,12 +1,12 @@
1
1
  import type { Dispatch, Middleware, ActionHandler, HandlerOptions } from './types.js';
2
- import type { Service } from './service/types.js';
3
- import type { Schema } from './schema/index.js';
4
- export declare const compose: (...fns: Middleware[]) => Middleware;
2
+ import type Service from './service/Service.js';
3
+ import type Schema from './schema/Schema.js';
5
4
  export interface Resources {
6
5
  handlers: Record<string, ActionHandler>;
7
- schemas: Record<string, Schema>;
6
+ schemas: Map<string, Schema>;
8
7
  services: Record<string, Service>;
9
8
  middleware?: Middleware[];
10
9
  options: HandlerOptions;
11
10
  }
11
+ export declare const compose: (...fns: Middleware[]) => Middleware;
12
12
  export default function createDispatch({ handlers, schemas, services, middleware, options, }: Resources): Dispatch;