@toa.io/extensions.cadence 1.0.0-alpha.320 → 1.0.0-alpha.322

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.
@@ -27,7 +27,7 @@ entity:
27
27
  description: >
28
28
  The chain of hops that asked for the call, which the call is then made by. A delay is a
29
29
  hop like any other, so a circle routed through one is still a circle. Absent where the
30
- caller detached the call, and on a row written before this existed.
30
+ caller unchained the call, and on a row written before this existed.
31
31
  type: array
32
32
  items:
33
33
  type: string
@@ -24,7 +24,7 @@ export function transition(input, entry) {
24
24
  // there at all, and a null would not fit it
25
25
  if (input.request !== undefined) entry.request = input.request
26
26
 
27
- // the chain that asked for the call, absent where the caller detached it
27
+ // the chain that asked for the call, absent where the caller unchained it
28
28
  if (input.trail !== undefined) entry.trail = input.trail
29
29
 
30
30
  return entry.id
@@ -15,7 +15,7 @@ export interface Entity {
15
15
  endpoint: string
16
16
  /** The request to make, as it was handed over */
17
17
  request?: Record<string, unknown>
18
- /** The chain of hops that asked for the call, which the call is then made by. A delay is a hop like any other, so a circle routed through one is still a circle. Absent where the caller detached the call, and on a row written before this existed. */
18
+ /** The chain of hops that asked for the call, which the call is then made by. A delay is a hop like any other, so a circle routed through one is still a circle. Absent where the caller unchained the call, and on a row written before this existed. */
19
19
  trail?: string[]
20
20
  id: string
21
21
  VERSION: number
@@ -25,6 +25,8 @@ export interface Entity {
25
25
  REGION: number
26
26
  }
27
27
 
28
+ export type State = Entity & { DISCARD: boolean, TRAILERS: Record<string, unknown> }
29
+
28
30
  export type DelayInput = {
29
31
  endpoint: string
30
32
  request?: Record<string, unknown>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.cadence",
3
- "version": "1.0.0-alpha.320",
3
+ "version": "1.0.0-alpha.322",
4
4
  "type": "module",
5
5
  "description": "Toa Schedule",
6
6
  "author": "temich <tema.gurtovoy@gmail.com>",
@@ -26,8 +26,8 @@
26
26
  "!**/.env*"
27
27
  ],
28
28
  "dependencies": {
29
- "@toa.io/core": "1.0.0-alpha.320",
30
- "@toa.io/definitions": "1.0.0-alpha.320",
29
+ "@toa.io/core": "1.0.0-alpha.322",
30
+ "@toa.io/definitions": "1.0.0-alpha.322",
31
31
  "@toa.io/generic": "1.0.0-alpha.311",
32
32
  "@toa.io/schemas": "1.0.0-alpha.311",
33
33
  "openspan": "1.0.0-alpha.305"
@@ -35,5 +35,5 @@
35
35
  "scripts": {
36
36
  "transpile": "tsc"
37
37
  },
38
- "gitHead": "5ef92ab939a596e4ac820965c59c015820eba7b2"
38
+ "gitHead": "ef65352a8bd7bc0ef400fcc8cde0e19a3bb92199"
39
39
  }
package/readme.md CHANGED
@@ -127,11 +127,11 @@ const id = await context.delay(
127
127
  await context.delay.cancel(id)
128
128
  ```
129
129
 
130
- | | |
131
- | ---------- | --------------------------------------------------------------------------- |
132
- | `interval` | milliseconds from now |
133
- | `overdue` | milliseconds the call may be late and still be made, or `null` for no bound |
134
- | `detached` | whether the call begins a chain of its own; see below |
130
+ | | |
131
+ | ----------- | --------------------------------------------------------------------------- |
132
+ | `interval` | milliseconds from now |
133
+ | `overdue` | milliseconds the call may be late and still be made, or `null` for no bound |
134
+ | `unchained` | whether the call begins a chain of its own; see below |
135
135
 
136
136
  The call is made once the delay has passed, and waits for the target where it is not there to
137
137
  take it. The id it answers cancels it, and `cancel` raises where the id was never issued.
@@ -149,8 +149,8 @@ The call is made by the chain that asked for it, so an operation that delays a c
149
149
  going round in a circle and is refused on its third round — see
150
150
  [call cycles](/documentation/cycles.md). A delay makes it a slow circle rather than not one.
151
151
 
152
- Nothing here repeats a call: a delayed call is made **once**, and `detached` does not change
153
- that. What repeats is an operation that re-arms itself, and `detached: true` is how that
152
+ Nothing here repeats a call: a delayed call is made **once**, and `unchained` does not change
153
+ that. What repeats is an operation that re-arms itself, and `unchained: true` is how that
154
154
  operation says the call it is arming begins a chain of its own rather than continuing the one it
155
155
  is running in:
156
156
 
@@ -162,7 +162,7 @@ export async function effect (input, context) {
162
162
  await context.delay(
163
163
  'billing.dunning.chase',
164
164
  { input },
165
- { interval: DAY, overdue: null, detached: true }
165
+ { interval: DAY, overdue: null, unchained: true }
166
166
  )
167
167
  }
168
168
  ```
@@ -170,8 +170,11 @@ export async function effect (input, context) {
170
170
  Without it the second chase is hop two of one chain and the third is refused. With it each chase
171
171
  is its own chain, and they go on for as long as the operation keeps arming them.
172
172
 
173
+ An operation declared [`unchained`](/documentation/cycles.md#an-operation-meant-to-be-re-entered)
174
+ begins a chain of its own on every call, delayed or not, and needs no option here.
175
+
173
176
  A [pulse](#pulse) is the other way to write recurring work, and where it fits it is the simpler
174
- one: one timer for the component rather than a row per item, and no chain to detach, because it
177
+ one: one timer for the component rather than a row per item, and no chain to break, because it
175
178
  is called from the clock. Reach for a delay instead when each item has its own schedule — this
176
179
  invoice a day from now, that one in a week.
177
180
 
@@ -52,7 +52,7 @@ export class Aspect extends Connector {
52
52
  * It rides the row rather than the request, because the request is the caller's and a call
53
53
  * that carries none must go on carrying none.
54
54
  */
55
- const hops = options.detached === true ? undefined : trail.current()?.hops;
55
+ const hops = options.unchained === true ? undefined : trail.current()?.hops;
56
56
  if (hops !== undefined)
57
57
  input.trail = hops;
58
58
  /*
@@ -1 +1 @@
1
- {"version":3,"file":"Aspect.js","sourceRoot":"","sources":["../source/Aspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAG3D,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAU5C;;;;;;;;GAQG;AACH,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnB,IAAI,GAAG,OAAO,CAAA;IAEb,SAAS,CAAO;IAEjC,YAAmB,SAAgB;QACjC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAE1B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzB,C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AAE,IAAI,EAAE,CAAC,CAAA;IACjF,CAAC;CACF"}
@@ -266,7 +266,7 @@ export class Dispatcher extends Connector {
266
266
  /*
267
267
  * Set after the stored request is spread, so a stored field of that name cannot stand in
268
268
  * for it: the row's chain is the one that was in scope when the call was asked for. Absent
269
- * — the caller detached the call — `Call` starts one under cadence's own name.
269
+ * — the caller unchained the call — `Call` starts one under cadence's own name.
270
270
  */
271
271
  if (row.trail !== undefined)
272
272
  request.trail = row.trail;