@oddington/sdk 0.1.72 → 0.1.73
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.
- package/dist/browser.js +21 -5
- package/dist/index.js +2 -2
- package/dist/types/shared/inbox-contract.d.ts +3 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -5247,17 +5247,31 @@ function validateBlock(value) {
|
|
|
5247
5247
|
let asks = distinctIds(b.asks, "Ask IDs");
|
|
5248
5248
|
return asks.some((ask) => !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(ask)) && fail("Invalid Ask ID"), { kind: "asks", problem: text(b.problem, "problem"), asks };
|
|
5249
5249
|
}
|
|
5250
|
-
["record", "records", "files"].includes(b.kind) || fail("Unknown Block kind"), keys(b, ["kind", "label", "initiallyExpanded", ...b.kind === "record" ? ["record"] : b.kind === "records" ? ["records"] : ["files"]], "Block");
|
|
5250
|
+
["record", "records", "files"].includes(b.kind) || fail("Unknown Block kind"), keys(b, ["kind", "label", "initiallyExpanded", ...b.kind === "record" ? ["record", "fields"] : b.kind === "records" ? ["records", "previewCount"] : ["files", "previewCount"]], "Block");
|
|
5251
5251
|
let label = text(b.label, "Block label");
|
|
5252
5252
|
b.initiallyExpanded !== void 0 && typeof b.initiallyExpanded != "boolean" && fail("Invalid initiallyExpanded");
|
|
5253
5253
|
let expanded = b.initiallyExpanded === void 0 ? {} : { initiallyExpanded: b.initiallyExpanded };
|
|
5254
|
-
if (b.kind === "record")
|
|
5254
|
+
if (b.kind === "record") {
|
|
5255
|
+
let fields4 = b.fields === void 0 ? void 0 : array(b.fields, "fields").map((value2) => text(value2, "field name"));
|
|
5256
|
+
return fields4 && (!fields4.length || new Set(fields4).size !== fields4.length) && fail("Empty or duplicate fields"), {
|
|
5257
|
+
kind: "record",
|
|
5258
|
+
label,
|
|
5259
|
+
record: validateQualifiedRecordRef(b.record),
|
|
5260
|
+
...fields4 === void 0 ? {} : { fields: fields4 },
|
|
5261
|
+
...expanded
|
|
5262
|
+
};
|
|
5263
|
+
}
|
|
5264
|
+
let preview = (length) => {
|
|
5265
|
+
if (b.previewCount === void 0) return {};
|
|
5266
|
+
let previewCount = natural(b.previewCount, "previewCount", 1);
|
|
5267
|
+
return previewCount > length && fail("previewCount exceeds collection length"), { previewCount };
|
|
5268
|
+
};
|
|
5255
5269
|
if (b.kind === "records") {
|
|
5256
5270
|
let records = array(b.records, "records").map(validateQualifiedRecordRef);
|
|
5257
|
-
return (!records.length || new Set(records.map((r) => JSON.stringify([r.repository, r.ref]))).size !== records.length) && fail("Empty or duplicate records"), { kind: "records", label, records, ...expanded };
|
|
5271
|
+
return (!records.length || new Set(records.map((r) => JSON.stringify([r.repository, r.ref]))).size !== records.length) && fail("Empty or duplicate records"), { kind: "records", label, records, ...preview(records.length), ...expanded };
|
|
5258
5272
|
}
|
|
5259
5273
|
let files3 = array(b.files, "files").map(validateInboxFile);
|
|
5260
|
-
return (!files3.length || new Set(files3.map((file2) => file2.id)).size !== files3.length) && fail("Empty or duplicate files"), { kind: "files", label, files: files3, ...expanded };
|
|
5274
|
+
return (!files3.length || new Set(files3.map((file2) => file2.id)).size !== files3.length) && fail("Empty or duplicate files"), { kind: "files", label, files: files3, ...preview(files3.length), ...expanded };
|
|
5261
5275
|
}
|
|
5262
5276
|
function richTextBlock(value) {
|
|
5263
5277
|
return validateBlock({ ...value, kind: "rich-text" });
|
|
@@ -10128,7 +10142,9 @@ function parseInboxItem(value) {
|
|
|
10128
10142
|
}
|
|
10129
10143
|
}), array2(item.activity).forEach((value2) => {
|
|
10130
10144
|
let event = object8(value2);
|
|
10131
|
-
assert(integer(event.id) && text4(event.type) && (event.actorId === null || id2(event.actorId)) && (event.questionId === null || text4(event.questionId)) && integer(event.revision) && date(event.createdAt))
|
|
10145
|
+
assert(integer(event.id) && text4(event.type) && (event.actorId === null || id2(event.actorId)) && (event.questionId === null || text4(event.questionId)) && integer(event.revision) && date(event.createdAt));
|
|
10146
|
+
let data3 = object8(event.data);
|
|
10147
|
+
event.type === "recipient-added" && (keys6(data3, ["personId"]), assert(id2(event.actorId) && id2(data3.personId)));
|
|
10132
10148
|
}), array2(item.work).forEach((value2) => {
|
|
10133
10149
|
let work = object8(value2);
|
|
10134
10150
|
assert(id2(work.id) && text4(work.questionId) && text4(work.reason) && optionalDate(work.settledAt));
|