@scalemule/news-publication 0.0.85 → 0.0.86

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.
@@ -358,6 +358,16 @@ var canonical2 = (v) => Array.isArray(v) ? v.map(canonical2) : v && typeof v ===
358
358
  Object.keys(v).sort().map((k) => [k, canonical2(v[k])])
359
359
  ) : v;
360
360
  var equal = (a, b) => JSON.stringify(canonical2(a)) === JSON.stringify(canonical2(b));
361
+ var uuidIdentity = (value) => {
362
+ if (typeof value !== "string" || !/^(?:[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.test(value)) return value;
363
+ return value.replaceAll("-", "").toLowerCase();
364
+ };
365
+ var comparableDocument = (document) => document && typeof document === "object" ? { ...document, ...Array.isArray(document.media) ? { media: document.media.map((media) => ({
366
+ ...media,
367
+ contribution_id: uuidIdentity(media.contribution_id),
368
+ file_id: uuidIdentity(media.file_id)
369
+ })) } : {} } : document;
370
+ var documentsEqual = (a, b) => equal(comparableDocument(a), comparableDocument(b));
361
371
  var digest2 = async (v) => [
362
372
  ...new Uint8Array(
363
373
  await crypto.subtle.digest(
@@ -512,7 +522,7 @@ async function runArticleEdit(t, input) {
512
522
  state.revisionId
513
523
  );
514
524
  const selected = currentRevision(record);
515
- if (!selected || !equal(selected.document, state.document))
525
+ if (!selected || !documentsEqual(selected.document, state.document))
516
526
  throw new ArticleEditOperationError(
517
527
  "VERIFICATION_CONFLICT",
518
528
  stage,
@@ -580,7 +590,7 @@ async function runArticleEdit(t, input) {
580
590
  state.savedGeneration = saved.generation;
581
591
  await save("verify");
582
592
  record = await request(article + "/collaboration");
583
- if (record.current_revision_id !== state.revisionId || !equal(currentRevision(record)?.document, state.document))
593
+ if (record.current_revision_id !== state.revisionId || !documentsEqual(currentRevision(record)?.document, state.document))
584
594
  throw new ArticleEditOperationError(
585
595
  "ARTICLE_CHANGED",
586
596
  stage,
@@ -356,6 +356,16 @@ var canonical2 = (v) => Array.isArray(v) ? v.map(canonical2) : v && typeof v ===
356
356
  Object.keys(v).sort().map((k) => [k, canonical2(v[k])])
357
357
  ) : v;
358
358
  var equal = (a, b) => JSON.stringify(canonical2(a)) === JSON.stringify(canonical2(b));
359
+ var uuidIdentity = (value) => {
360
+ if (typeof value !== "string" || !/^(?:[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.test(value)) return value;
361
+ return value.replaceAll("-", "").toLowerCase();
362
+ };
363
+ var comparableDocument = (document) => document && typeof document === "object" ? { ...document, ...Array.isArray(document.media) ? { media: document.media.map((media) => ({
364
+ ...media,
365
+ contribution_id: uuidIdentity(media.contribution_id),
366
+ file_id: uuidIdentity(media.file_id)
367
+ })) } : {} } : document;
368
+ var documentsEqual = (a, b) => equal(comparableDocument(a), comparableDocument(b));
359
369
  var digest2 = async (v) => [
360
370
  ...new Uint8Array(
361
371
  await crypto.subtle.digest(
@@ -510,7 +520,7 @@ async function runArticleEdit(t, input) {
510
520
  state.revisionId
511
521
  );
512
522
  const selected = currentRevision(record);
513
- if (!selected || !equal(selected.document, state.document))
523
+ if (!selected || !documentsEqual(selected.document, state.document))
514
524
  throw new ArticleEditOperationError(
515
525
  "VERIFICATION_CONFLICT",
516
526
  stage,
@@ -578,7 +588,7 @@ async function runArticleEdit(t, input) {
578
588
  state.savedGeneration = saved.generation;
579
589
  await save("verify");
580
590
  record = await request(article + "/collaboration");
581
- if (record.current_revision_id !== state.revisionId || !equal(currentRevision(record)?.document, state.document))
591
+ if (record.current_revision_id !== state.revisionId || !documentsEqual(currentRevision(record)?.document, state.document))
582
592
  throw new ArticleEditOperationError(
583
593
  "ARTICLE_CHANGED",
584
594
  stage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/news-publication",
3
- "version": "0.0.85",
3
+ "version": "0.0.86",
4
4
  "description": "Shared server framework for ScaleMule local news publications. Walnut Creek Times is the broadsheet default; each paper supplies its own identity and feature flags.",
5
5
  "type": "module",
6
6
  "bin": {