@windyroad/voice-tone 0.9.4 → 0.9.5

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.
@@ -145,5 +145,5 @@
145
145
  }
146
146
  },
147
147
  "name": "wr-voice-tone",
148
- "version": "0.9.4"
148
+ "version": "0.9.5"
149
149
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wr-voice-tone",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Voice, tone, and external-communications governance",
5
5
  "author": {
6
6
  "name": "Windy Road Technology",
@@ -286,7 +286,7 @@ function registrations(input, target) {
286
286
  const path = join(transportDir(), name);
287
287
  try {
288
288
  const registered = JSON.parse(readFileSync(path, "utf8"));
289
- return registered.role === role && registered.target === target &&
289
+ return registered.role === role &&
290
290
  registered.root === current.root && registered.physical === current.physical
291
291
  ? [{ path, registered, age: Date.now() - Math.floor(statSync(path).mtimeMs) }]
292
292
  : [];
@@ -297,12 +297,15 @@ function registrations(input, target) {
297
297
  function persistPending(input, target, output) {
298
298
  target = normalizeTarget(target);
299
299
  if (!target || typeof output !== "string" || !output) return;
300
- const candidates = registrations(input, target);
300
+ const registrationsForCheckout = registrations(input, target);
301
+ const exact = registrationsForCheckout.filter(({ registered }) => registered.target === target);
302
+ const candidates = exact.length ? exact : registrationsForCheckout.filter(({ registered }) => registered.parentSession === input.session_id);
301
303
  if (candidates.length !== 1) {
302
304
  diagnostic(candidates.length ? "ambiguous-parent-registration" : "missing-parent-registration", input);
303
305
  return;
304
306
  }
305
307
  const { registered, age } = candidates[0];
308
+ target = registered.target;
306
309
  if (!validRegistration(registered, input, target, age)) return;
307
310
  if (!outputAllowed(output, registered)) {
308
311
  diagnostic("non-pass-or-mismatched-output", input);
@@ -286,7 +286,7 @@ function registrations(input, target) {
286
286
  const path = join(transportDir(), name);
287
287
  try {
288
288
  const registered = JSON.parse(readFileSync(path, "utf8"));
289
- return registered.role === role && registered.target === target &&
289
+ return registered.role === role &&
290
290
  registered.root === current.root && registered.physical === current.physical
291
291
  ? [{ path, registered, age: Date.now() - Math.floor(statSync(path).mtimeMs) }]
292
292
  : [];
@@ -297,12 +297,15 @@ function registrations(input, target) {
297
297
  function persistPending(input, target, output) {
298
298
  target = normalizeTarget(target);
299
299
  if (!target || typeof output !== "string" || !output) return;
300
- const candidates = registrations(input, target);
300
+ const registrationsForCheckout = registrations(input, target);
301
+ const exact = registrationsForCheckout.filter(({ registered }) => registered.target === target);
302
+ const candidates = exact.length ? exact : registrationsForCheckout.filter(({ registered }) => registered.parentSession === input.session_id);
301
303
  if (candidates.length !== 1) {
302
304
  diagnostic(candidates.length ? "ambiguous-parent-registration" : "missing-parent-registration", input);
303
305
  return;
304
306
  }
305
307
  const { registered, age } = candidates[0];
308
+ target = registered.target;
306
309
  if (!validRegistration(registered, input, target, age)) return;
307
310
  if (!outputAllowed(output, registered)) {
308
311
  diagnostic("non-pass-or-mismatched-output", input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windyroad/voice-tone",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Voice and tone enforcement for user-facing copy",
5
5
  "bin": {
6
6
  "windyroad-voice-tone": "./bin/install.mjs"