@proteinjs/db-file 1.9.0 → 1.10.0
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/CHANGELOG.md +22 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/FileStorage.d.ts +19 -6
- package/dist/src/FileStorage.d.ts.map +1 -1
- package/dist/src/FileStorage.js +33 -8
- package/dist/src/FileStorage.js.map +1 -1
- package/dist/src/FileVariantMaker.d.ts +8 -3
- package/dist/src/FileVariantMaker.d.ts.map +1 -1
- package/dist/src/FileVariantMaker.js.map +1 -1
- package/dist/src/tables/FileTable.d.ts +28 -3
- package/dist/src/tables/FileTable.d.ts.map +1 -1
- package/dist/src/tables/FileTable.js +23 -0
- package/dist/src/tables/FileTable.js.map +1 -1
- package/dist/test/FileDerivedProvenance.test.d.ts +2 -0
- package/dist/test/FileDerivedProvenance.test.d.ts.map +1 -0
- package/dist/test/FileDerivedProvenance.test.js +420 -0
- package/dist/test/FileDerivedProvenance.test.js.map +1 -0
- package/dist/test/FileMediaMetadata.test.js +30 -0
- package/dist/test/FileMediaMetadata.test.js.map +1 -1
- package/generated/index.ts +1 -1
- package/package.json +2 -2
- package/src/FileStorage.ts +32 -7
- package/src/FileVariantMaker.ts +8 -3
- package/src/tables/FileTable.ts +47 -4
- package/test/FileDerivedProvenance.test.ts +248 -0
- package/test/FileMediaMetadata.test.ts +19 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileVariantMaker.js","sourceRoot":"","sources":["../../src/FileVariantMaker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAmE;AAUtD,QAAA,kBAAkB,GAA+B,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"FileVariantMaker.js","sourceRoot":"","sources":["../../src/FileVariantMaker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAmE;AAUt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AAO,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,gBAAgB;YACtD,CAAC,CAAC,UAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,WAAG;YAC1D,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IA3BuB,uBAAI,GAAG,oBAAoB,CAAC;IACpD,gEAAgE;IACxC,mCAAgB,GAAG,GAAG,CAAC;IA0BjD,yBAAC;CAAA,AA7BD,CAAwC,KAAK,GA6B5C;AA7BY,gDAAkB"}
|
|
@@ -12,8 +12,9 @@ export interface File extends ScopedRecord {
|
|
|
12
12
|
* A VARIANT — one of the derived Files of this file the {@link FileVariantMaker} seam makes
|
|
13
13
|
* (`preview`, `stage`): the same lifecycle for each — named here, made once (at ingest with the
|
|
14
14
|
* bytes in hand, or lazily on the first request through `FileStorage.getVariant`), dropped when
|
|
15
|
-
* this file's bytes change (`FileStorage.updateFileData`), deleted with this file (cascade),
|
|
16
|
-
* readable by whoever can read this file (`variantOf`)
|
|
15
|
+
* this file's bytes change (`FileStorage.updateFileData`), deleted with this file (cascade),
|
|
16
|
+
* readable by whoever can read this file (`variantOf`), and carrying this file's provenance
|
|
17
|
+
* ({@link FileTable.provenanceColumns}) — a rendition's provenance is its original's.
|
|
17
18
|
*/
|
|
18
19
|
preview?: Reference<File> | null;
|
|
19
20
|
/**
|
|
@@ -40,7 +41,8 @@ export interface File extends ScopedRecord {
|
|
|
40
41
|
* it. `null`/absent means no copy has been made yet: the next non-owner read makes one when the
|
|
41
42
|
* maker applies to this file, and serves the original when it does not. Dropped when the
|
|
42
43
|
* original's bytes change (`FileStorage.updateFileData`) and deleted with this file (cascade).
|
|
43
|
-
* The owner is never served it — their own scoped read serves the original.
|
|
44
|
+
* The owner is never served it — their own scoped read serves the original. Carries this
|
|
45
|
+
* file's provenance ({@link FileTable.provenanceColumns}), as every derived File does.
|
|
44
46
|
*/
|
|
45
47
|
copyForOthers?: Reference<File> | null;
|
|
46
48
|
/**
|
|
@@ -52,6 +54,15 @@ export interface File extends ScopedRecord {
|
|
|
52
54
|
width?: number;
|
|
53
55
|
height?: number;
|
|
54
56
|
durationMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the picture has see-through pixels — read off the BYTES at ingest (the alpha channel's
|
|
59
|
+
* pixels, never the file's declared colour type alone and never the producer that made it): a
|
|
60
|
+
* mark made on a transparent background is true; a photograph, a JPEG, an opaque PNG false.
|
|
61
|
+
* A viewer reads it to seat the picture on the surface its thumbnail sat on instead of a black
|
|
62
|
+
* stage (a see-through mark on black is not the mark the person saw). Absent for video, for
|
|
63
|
+
* non-media files and for pictures stored before the column existed — read as opaque.
|
|
64
|
+
*/
|
|
65
|
+
transparent?: boolean;
|
|
55
66
|
/**
|
|
56
67
|
* Web provenance — set when the bytes were fetched from the internet on the user's behalf
|
|
57
68
|
* (a saved web image): the direct URL the bytes came from, the page they were found on, and
|
|
@@ -96,6 +107,19 @@ export interface File extends ScopedRecord {
|
|
|
96
107
|
originModel?: string;
|
|
97
108
|
}
|
|
98
109
|
export declare class FileTable extends Table<File> {
|
|
110
|
+
/**
|
|
111
|
+
* The columns that are a file's PROVENANCE — where its bytes came from and under what terms: the
|
|
112
|
+
* producer (`origin`, `originModel`), the web source (`sourceUrl`, `sourcePageUrl`,
|
|
113
|
+
* `retrievedAt`) and the rights record (`license`, `licenseUrl`, `attribution`). ONE list, the
|
|
114
|
+
* table's own: every derived File the library makes of a file — a variant (`preview`, `stage`)
|
|
115
|
+
* and the copy for others — carries these from the row it was made from (`FileStorage` writes
|
|
116
|
+
* them at insert), so a consumer reads a rendition's provenance off the row it draws, without a
|
|
117
|
+
* join, and a row with none derives rows with none. A column that describes THE ROW'S OWN bytes
|
|
118
|
+
* (`size`, `contentHash`, the media dimensions) is not provenance and is never copied — the
|
|
119
|
+
* maker answers those. A new provenance column is added HERE with its column; nothing else
|
|
120
|
+
* names the list.
|
|
121
|
+
*/
|
|
122
|
+
static readonly provenanceColumns: ReadonlyArray<keyof File>;
|
|
99
123
|
name: string;
|
|
100
124
|
auth: Table<File>['auth'];
|
|
101
125
|
columns: {
|
|
@@ -114,6 +138,7 @@ export declare class FileTable extends Table<File> {
|
|
|
114
138
|
width: import("@proteinjs/db").Column<number | undefined, any>;
|
|
115
139
|
height: import("@proteinjs/db").Column<number | undefined, any>;
|
|
116
140
|
durationMs: import("@proteinjs/db").Column<number | undefined, any>;
|
|
141
|
+
transparent: import("@proteinjs/db").Column<boolean | undefined, any>;
|
|
117
142
|
sourceUrl: import("@proteinjs/db").Column<string | undefined, any>;
|
|
118
143
|
sourcePageUrl: import("@proteinjs/db").Column<string | undefined, any>;
|
|
119
144
|
retrievedAt: import("@proteinjs/db").Column<Date | undefined, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTable.d.ts","sourceRoot":"","sources":["../../../src/tables/FileTable.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FileTable.d.ts","sourceRoot":"","sources":["../../../src/tables/FileTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAKL,SAAS,EAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAA8C,MAAM,iBAAiB,CAAC;AAI3F,MAAM,WAAW,IAAK,SAAQ,YAAY;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACnC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,SAAU,SAAQ,KAAK,CAAC,IAAI,CAAC;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,CAS1D;IAEK,IAAI,SAAmB;IACvB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAO9B;IACK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BX;IAGI,OAAO;;;QAA0F;CAGzG"}
|
|
@@ -47,6 +47,7 @@ var FileTable = /** @class */ (function (_super) {
|
|
|
47
47
|
width: new db_1.IntegerColumn('width'),
|
|
48
48
|
height: new db_1.IntegerColumn('height'),
|
|
49
49
|
durationMs: new db_1.IntegerColumn('duration_ms'),
|
|
50
|
+
transparent: new db_1.BooleanColumn('transparent'),
|
|
50
51
|
// Web provenance (see the interface docs). URLs can be long — MAX, like any URL storage.
|
|
51
52
|
sourceUrl: new db_1.StringColumn('source_url', {}, 'MAX'),
|
|
52
53
|
sourcePageUrl: new db_1.StringColumn('source_page_url', {}, 'MAX'),
|
|
@@ -67,6 +68,28 @@ var FileTable = /** @class */ (function (_super) {
|
|
|
67
68
|
// No cascadeDeleteReferences for FileData: byte cleanup (FileData rows included) is owned by
|
|
68
69
|
// FileStorageDriver.deleteFile, invoked for every file-row delete by FileStorageTableWatcher.
|
|
69
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The columns that are a file's PROVENANCE — where its bytes came from and under what terms: the
|
|
73
|
+
* producer (`origin`, `originModel`), the web source (`sourceUrl`, `sourcePageUrl`,
|
|
74
|
+
* `retrievedAt`) and the rights record (`license`, `licenseUrl`, `attribution`). ONE list, the
|
|
75
|
+
* table's own: every derived File the library makes of a file — a variant (`preview`, `stage`)
|
|
76
|
+
* and the copy for others — carries these from the row it was made from (`FileStorage` writes
|
|
77
|
+
* them at insert), so a consumer reads a rendition's provenance off the row it draws, without a
|
|
78
|
+
* join, and a row with none derives rows with none. A column that describes THE ROW'S OWN bytes
|
|
79
|
+
* (`size`, `contentHash`, the media dimensions) is not provenance and is never copied — the
|
|
80
|
+
* maker answers those. A new provenance column is added HERE with its column; nothing else
|
|
81
|
+
* names the list.
|
|
82
|
+
*/
|
|
83
|
+
FileTable.provenanceColumns = [
|
|
84
|
+
'origin',
|
|
85
|
+
'originModel',
|
|
86
|
+
'sourceUrl',
|
|
87
|
+
'sourcePageUrl',
|
|
88
|
+
'retrievedAt',
|
|
89
|
+
'license',
|
|
90
|
+
'licenseUrl',
|
|
91
|
+
'attribution',
|
|
92
|
+
];
|
|
70
93
|
return FileTable;
|
|
71
94
|
}(db_1.Table));
|
|
72
95
|
exports.FileTable = FileTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTable.js","sourceRoot":"","sources":["../../../src/tables/FileTable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"FileTable.js","sourceRoot":"","sources":["../../../src/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D,WAAW,EAAE,IAAI,eAAU,CAAC,cAAc,CAAC;YAC3C,wFAAwF;YACxF,iEAAiE;YACjE,OAAO,EAAE,IAAI,iBAAY,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC;YAC5C,UAAU,EAAE,IAAI,iBAAY,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,CAAC;YACtD,WAAW,EAAE,IAAI,iBAAY,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,CAAC;YACvD,WAAW,EAAE,IAAI,iBAAY,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,CAAC;YACrD,MAAM,EAAE,IAAI,iBAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC;YACjD,WAAW,EAAE,IAAI,iBAAY,CAAC,cAAc,EAAE,SAAS,EAAE,GAAG,CAAC;SAC9D,CAAC,CAAC;QACH,0FAA0F;QAC1F,wEAAwE;QACjE,aAAO,GAAG,CAAC,IAAA,wBAAiB,EAAO,EAAE,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC;;QACxG,6FAA6F;QAC7F,8FAA8F;IAChG,CAAC;IAlEC;;;;;;;;;;;OAWG;IACa,2BAAiB,GAA8B;QAC7D,QAAQ;QACR,aAAa;QACb,WAAW;QACX,eAAe;QACf,aAAa;QACb,SAAS;QACT,YAAY;QACZ,aAAa;KACd,AATgC,CAS/B;IA6CJ,gBAAC;CAAA,AAnED,CAA+B,UAAK,GAmEnC;AAnEY,8BAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDerivedProvenance.test.d.ts","sourceRoot":"","sources":["../../test/FileDerivedProvenance.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var db_1 = require("@proteinjs/db");
|
|
60
|
+
var reflection_1 = require("@proteinjs/reflection");
|
|
61
|
+
var user_1 = require("@proteinjs/user");
|
|
62
|
+
var FileTable_1 = require("../src/tables/FileTable");
|
|
63
|
+
var tables_1 = require("../src/tables/tables");
|
|
64
|
+
var FileStorage_1 = require("../src/FileStorage");
|
|
65
|
+
var FileTestEnvironment_1 = require("./FileTestEnvironment");
|
|
66
|
+
/**
|
|
67
|
+
* A derived File — a variant the seam makes (at ingest with the bytes in hand, or on the read
|
|
68
|
+
* path's first request) and the copy for others — carries its ORIGINAL's provenance: who made the
|
|
69
|
+
* bytes (`origin`, `originModel`), where they came from (`sourceUrl`, `sourcePageUrl`,
|
|
70
|
+
* `retrievedAt`) and the rights that ride with them (`license`, `licenseUrl`, `attribution`) —
|
|
71
|
+
* the columns the table itself names as provenance (`FileTable.provenanceColumns`). A rendition's
|
|
72
|
+
* provenance is its original's: a consumer that labels a thumbnail with what made it, or refuses a
|
|
73
|
+
* non-capture picture as evidence, reads the row it draws, without a join. The library that makes
|
|
74
|
+
* the row writes it, whichever door made the row; a row with no provenance derives rows with none
|
|
75
|
+
* (nothing is invented); a row derived from a derived row carries what that row carries — its
|
|
76
|
+
* original's. The facts of a row's OWN bytes (`size`, `contentHash`, the dimensions) stay the
|
|
77
|
+
* maker's answer, never the original's.
|
|
78
|
+
*/
|
|
79
|
+
var originalBytes = Buffer.concat([Buffer.from('ORIGINAL:'), Buffer.from(Array.from({ length: 64 }, function (_, i) { return i; }))]);
|
|
80
|
+
/** What the copy-for-others maker takes off a copy (the location marker of the real one). */
|
|
81
|
+
var COPY_MARK = Buffer.from('-FOR-OTHERS');
|
|
82
|
+
/**
|
|
83
|
+
* Every provenance column populated at once — whatever the story, each is seen to travel. The
|
|
84
|
+
* fixture is tied to the table's list below: a provenance column added to the table must be added
|
|
85
|
+
* here, and is then proven to travel like the rest.
|
|
86
|
+
*/
|
|
87
|
+
var PROVENANCE = {
|
|
88
|
+
origin: 'generation',
|
|
89
|
+
originModel: 'vendor/picture-model-1',
|
|
90
|
+
sourceUrl: 'https://source.test/pictures/1.jpg',
|
|
91
|
+
sourcePageUrl: 'https://source.test/pages/1',
|
|
92
|
+
retrievedAt: new Date('2026-09-25T10:00:00.000Z'),
|
|
93
|
+
license: 'CC BY-SA 4.0',
|
|
94
|
+
licenseUrl: 'https://creativecommons.org/licenses/by-sa/4.0/',
|
|
95
|
+
attribution: 'Photo by Someone, CC BY-SA 4.0',
|
|
96
|
+
};
|
|
97
|
+
/** In-memory proxy-shape driver (no signed URLs) — the DbFileStorageDriver serving shape. */
|
|
98
|
+
var ProxyDriver = /** @class */ (function () {
|
|
99
|
+
function ProxyDriver() {
|
|
100
|
+
this.store = new Map();
|
|
101
|
+
}
|
|
102
|
+
ProxyDriver.prototype.createFile = function (file, fileData) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
this.store.set(file.id, Buffer.from(fileData, 'base64'));
|
|
106
|
+
return [2 /*return*/];
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
ProxyDriver.prototype.getFileData = function (fileId) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
var data;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
data = this.store.get(fileId);
|
|
115
|
+
if (data === undefined) {
|
|
116
|
+
throw new Error("No such object: ".concat(fileId));
|
|
117
|
+
}
|
|
118
|
+
return [2 /*return*/, data.toString('base64')];
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
ProxyDriver.prototype.updateFileData = function (fileId, data) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
this.store.set(fileId, Buffer.from(data, 'base64'));
|
|
126
|
+
return [2 /*return*/];
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
ProxyDriver.prototype.deleteFile = function (fileId) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
return __generator(this, function (_a) {
|
|
133
|
+
this.store.delete(fileId);
|
|
134
|
+
return [2 /*return*/];
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
return ProxyDriver;
|
|
139
|
+
}());
|
|
140
|
+
var testEnv = new FileTestEnvironment_1.FileTestEnvironment();
|
|
141
|
+
var objectCache = function () { return reflection_1.SourceRepository.get().objectCache; };
|
|
142
|
+
var owner;
|
|
143
|
+
var recipient;
|
|
144
|
+
var reachableFileIds = new Set();
|
|
145
|
+
/** The stub variant maker: a picture's `preview` and `stage` — bytes marked with the kind, a type, dimensions. Keeps the copy mark on (the real one keeps a picture's tags for its owner). */
|
|
146
|
+
var registerVariantMaker = function () {
|
|
147
|
+
objectCache()['@proteinjs/db-file/FileVariantMaker'] = [
|
|
148
|
+
{
|
|
149
|
+
appliesTo: function (file) { return file.type.startsWith('image/'); },
|
|
150
|
+
make: function (file, bytes, kind) { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
return [2 /*return*/, ({
|
|
153
|
+
bytes: Buffer.concat([Buffer.from("".concat(kind.toUpperCase(), ":")), bytes.subarray(0, 8), COPY_MARK]),
|
|
154
|
+
type: 'image/webp',
|
|
155
|
+
width: kind === 'stage' ? 1600 : 512,
|
|
156
|
+
height: kind === 'stage' ? 800 : 256,
|
|
157
|
+
})];
|
|
158
|
+
});
|
|
159
|
+
}); },
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
};
|
|
163
|
+
/** The stub copy maker: a picture's copy is its bytes with the mark taken off. */
|
|
164
|
+
var registerCopyMaker = function () {
|
|
165
|
+
objectCache()['@proteinjs/db-file/FileCopyForOthers'] = [
|
|
166
|
+
{
|
|
167
|
+
appliesTo: function (file) { return file.type.startsWith('image/'); },
|
|
168
|
+
make: function (file, bytes) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
169
|
+
return [2 /*return*/, bytes.subarray(0, bytes.length - COPY_MARK.length)];
|
|
170
|
+
}); }); },
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
};
|
|
174
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
178
|
+
case 1:
|
|
179
|
+
_a.sent();
|
|
180
|
+
objectCache()['@proteinjs/user-auth/AuthenticatedUserRepo'] = [new user_1.UserRepo()];
|
|
181
|
+
user_1.UserAuth.userRepo = undefined;
|
|
182
|
+
objectCache()['@proteinjs/db-file/FileReachabilityResolver'] = [
|
|
183
|
+
// The content leg vouches for the recipient alone (a share they accepted).
|
|
184
|
+
{
|
|
185
|
+
canReadViaReference: function (fileId) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
186
|
+
return [2 /*return*/, reachableFileIds.has(fileId) && new user_1.UserRepo().getUser().id === recipient.id];
|
|
187
|
+
}); }); },
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
return [4 /*yield*/, testEnv.createUser({ name: 'File owner', email: 'provenance-owner@test.local' })];
|
|
191
|
+
case 2:
|
|
192
|
+
owner = _a.sent();
|
|
193
|
+
return [4 /*yield*/, testEnv.createUser({ name: 'Share recipient', email: 'provenance-recipient@test.local' })];
|
|
194
|
+
case 3:
|
|
195
|
+
recipient = _a.sent();
|
|
196
|
+
testEnv.actAs(owner);
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); });
|
|
201
|
+
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
switch (_a.label) {
|
|
204
|
+
case 0:
|
|
205
|
+
delete objectCache()['@proteinjs/db-file/FileReachabilityResolver'];
|
|
206
|
+
delete objectCache()['@proteinjs/db-file/FileVariantMaker'];
|
|
207
|
+
delete objectCache()['@proteinjs/db-file/FileCopyForOthers'];
|
|
208
|
+
user_1.UserAuth.userRepo = undefined;
|
|
209
|
+
return [4 /*yield*/, testEnv.afterAll()];
|
|
210
|
+
case 1:
|
|
211
|
+
_a.sent();
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); });
|
|
216
|
+
var driver = new ProxyDriver();
|
|
217
|
+
beforeEach(function () {
|
|
218
|
+
reachableFileIds.clear();
|
|
219
|
+
registerVariantMaker();
|
|
220
|
+
registerCopyMaker();
|
|
221
|
+
testEnv.setDriver(driver);
|
|
222
|
+
testEnv.actAs(owner);
|
|
223
|
+
});
|
|
224
|
+
/** A picture of the owner's, with (or without) its provenance, stored with no variant. */
|
|
225
|
+
var createOwnerPicture = function (name, provenance) {
|
|
226
|
+
if (provenance === void 0) { provenance = {}; }
|
|
227
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
case 0: return [4 /*yield*/, new FileStorage_1.FileStorage().createFile(__assign({ name: name, type: 'image/jpeg', size: originalBytes.length, width: 4032, height: 3024, contentHash: 'a'.repeat(64) }, provenance), Buffer.concat([originalBytes, COPY_MARK]).toString('base64'))];
|
|
231
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
var rowAsSystem = function (fileId) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
237
|
+
switch (_a.label) {
|
|
238
|
+
case 0: return [4 /*yield*/, (0, db_1.getDbAsSystem)().get(tables_1.tables.File, { id: fileId })];
|
|
239
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
240
|
+
}
|
|
241
|
+
}); }); };
|
|
242
|
+
/** The provenance a row carries, column for column as the table names them — `null` for a column it does not hold. */
|
|
243
|
+
var provenanceOf = function (row) {
|
|
244
|
+
return FileTable_1.FileTable.provenanceColumns.reduce(function (carried, column) {
|
|
245
|
+
var _a;
|
|
246
|
+
var _b;
|
|
247
|
+
return (__assign(__assign({}, carried), (_a = {}, _a[column] = (_b = row[column]) !== null && _b !== void 0 ? _b : null, _a)));
|
|
248
|
+
}, {});
|
|
249
|
+
};
|
|
250
|
+
var NO_PROVENANCE = provenanceOf({});
|
|
251
|
+
/** The copy for others of a file, made by a recipient's read of its bytes. */
|
|
252
|
+
var copyForOthersOf = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
253
|
+
var copyId;
|
|
254
|
+
var _a;
|
|
255
|
+
return __generator(this, function (_b) {
|
|
256
|
+
switch (_b.label) {
|
|
257
|
+
case 0:
|
|
258
|
+
reachableFileIds.add(file.id);
|
|
259
|
+
testEnv.actAs(recipient);
|
|
260
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().getFileData(file.id)];
|
|
261
|
+
case 1:
|
|
262
|
+
_b.sent();
|
|
263
|
+
testEnv.actAs(owner);
|
|
264
|
+
return [4 /*yield*/, rowAsSystem(file.id)];
|
|
265
|
+
case 2:
|
|
266
|
+
copyId = (_a = (_b.sent()).copyForOthers) === null || _a === void 0 ? void 0 : _a._id;
|
|
267
|
+
expect(copyId).toBeTruthy();
|
|
268
|
+
return [4 /*yield*/, rowAsSystem(copyId)];
|
|
269
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}); };
|
|
273
|
+
describe('the list is the table’s own', function () {
|
|
274
|
+
it('names the producer, the web source and the rights record — and the fixture covers every column it names, so a column added there is proven to travel', function () {
|
|
275
|
+
expect(__spreadArray([], FileTable_1.FileTable.provenanceColumns, true).sort()).toEqual(Object.keys(PROVENANCE).sort());
|
|
276
|
+
expect(FileTable_1.FileTable.provenanceColumns).toEqual(expect.arrayContaining(['origin', 'originModel']));
|
|
277
|
+
// The facts of a row's own bytes are not provenance.
|
|
278
|
+
expect(FileTable_1.FileTable.provenanceColumns).not.toEqual(expect.arrayContaining(['contentHash']));
|
|
279
|
+
expect(FileTable_1.FileTable.provenanceColumns).not.toEqual(expect.arrayContaining(['size']));
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe('a derived row carries its original’s provenance', function () {
|
|
283
|
+
it("the ingest door: every variant deriveVariants makes carries the original's provenance, column for column; the maker's own answer (bytes, type, dimensions) stays its own", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
284
|
+
var file, variants, _i, _a, kind, variant;
|
|
285
|
+
var _b;
|
|
286
|
+
return __generator(this, function (_c) {
|
|
287
|
+
switch (_c.label) {
|
|
288
|
+
case 0: return [4 /*yield*/, createOwnerPicture('made.jpg', PROVENANCE)];
|
|
289
|
+
case 1:
|
|
290
|
+
file = _c.sent();
|
|
291
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().deriveVariants(file, Buffer.concat([originalBytes, COPY_MARK]))];
|
|
292
|
+
case 2:
|
|
293
|
+
variants = (_c.sent()).variants;
|
|
294
|
+
expect(Object.keys(variants).sort()).toEqual(['preview', 'stage']);
|
|
295
|
+
_i = 0, _a = ['preview', 'stage'];
|
|
296
|
+
_c.label = 3;
|
|
297
|
+
case 3:
|
|
298
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
299
|
+
kind = _a[_i];
|
|
300
|
+
return [4 /*yield*/, rowAsSystem(variants[kind].id)];
|
|
301
|
+
case 4:
|
|
302
|
+
variant = _c.sent();
|
|
303
|
+
expect(provenanceOf(variant)).toEqual(PROVENANCE);
|
|
304
|
+
expect([variant.type, variant.width, variant.height]).toEqual([
|
|
305
|
+
'image/webp',
|
|
306
|
+
kind === 'stage' ? 1600 : 512,
|
|
307
|
+
kind === 'stage' ? 800 : 256,
|
|
308
|
+
]);
|
|
309
|
+
expect(variant.size).toEqual(driver.store.get(variant.id).length);
|
|
310
|
+
// The hash is of THESE bytes, which the maker did not answer: never the original's.
|
|
311
|
+
expect((_b = variant.contentHash) !== null && _b !== void 0 ? _b : null).toBeNull();
|
|
312
|
+
_c.label = 5;
|
|
313
|
+
case 5:
|
|
314
|
+
_i++;
|
|
315
|
+
return [3 /*break*/, 3];
|
|
316
|
+
case 6: return [2 /*return*/];
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}); });
|
|
320
|
+
it("the read path's door: the variant getVariant derives on the first request carries the original's provenance", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
321
|
+
var file, _a, stage, _b, _c;
|
|
322
|
+
var _d, _e, _f;
|
|
323
|
+
return __generator(this, function (_g) {
|
|
324
|
+
switch (_g.label) {
|
|
325
|
+
case 0: return [4 /*yield*/, createOwnerPicture('existing.jpg', PROVENANCE)];
|
|
326
|
+
case 1:
|
|
327
|
+
file = _g.sent();
|
|
328
|
+
_a = expect;
|
|
329
|
+
return [4 /*yield*/, rowAsSystem(file.id)];
|
|
330
|
+
case 2:
|
|
331
|
+
_a.apply(void 0, [(_e = (_d = (_g.sent()).stage) === null || _d === void 0 ? void 0 : _d._id) !== null && _e !== void 0 ? _e : null]).toBeNull();
|
|
332
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().getVariant(file.id, 'stage')];
|
|
333
|
+
case 3:
|
|
334
|
+
stage = (_g.sent());
|
|
335
|
+
expect((_f = stage.variantOf) === null || _f === void 0 ? void 0 : _f._id).toEqual(file.id);
|
|
336
|
+
_b = expect;
|
|
337
|
+
_c = provenanceOf;
|
|
338
|
+
return [4 /*yield*/, rowAsSystem(stage.id)];
|
|
339
|
+
case 4:
|
|
340
|
+
_b.apply(void 0, [_c.apply(void 0, [_g.sent()])]).toEqual(PROVENANCE);
|
|
341
|
+
return [2 /*return*/];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}); });
|
|
345
|
+
it("the copy for others carries the original's provenance", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
346
|
+
var file, copy;
|
|
347
|
+
var _a;
|
|
348
|
+
return __generator(this, function (_b) {
|
|
349
|
+
switch (_b.label) {
|
|
350
|
+
case 0: return [4 /*yield*/, createOwnerPicture('shared.jpg', PROVENANCE)];
|
|
351
|
+
case 1:
|
|
352
|
+
file = _b.sent();
|
|
353
|
+
return [4 /*yield*/, copyForOthersOf(file)];
|
|
354
|
+
case 2:
|
|
355
|
+
copy = _b.sent();
|
|
356
|
+
expect(copy.scope).toEqual(owner.id);
|
|
357
|
+
expect(provenanceOf(copy)).toEqual(PROVENANCE);
|
|
358
|
+
expect((_a = copy.contentHash) !== null && _a !== void 0 ? _a : null).toBeNull();
|
|
359
|
+
return [2 /*return*/];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}); });
|
|
363
|
+
it('a row derived from a derived row carries what that row carries — its original’s: the copy for others of a stage variant', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
364
|
+
var file, stage, copyOfStage, _a;
|
|
365
|
+
var _b, _c;
|
|
366
|
+
return __generator(this, function (_d) {
|
|
367
|
+
switch (_d.label) {
|
|
368
|
+
case 0: return [4 /*yield*/, createOwnerPicture('chain.jpg', PROVENANCE)];
|
|
369
|
+
case 1:
|
|
370
|
+
file = _d.sent();
|
|
371
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().getVariant(file.id, 'stage')];
|
|
372
|
+
case 2:
|
|
373
|
+
stage = (_d.sent());
|
|
374
|
+
reachableFileIds.add(file.id); // a variant's reachability is its original's: the grant names the original
|
|
375
|
+
_a = copyForOthersOf;
|
|
376
|
+
return [4 /*yield*/, rowAsSystem(stage.id)];
|
|
377
|
+
case 3: return [4 /*yield*/, _a.apply(void 0, [_d.sent()])];
|
|
378
|
+
case 4:
|
|
379
|
+
copyOfStage = _d.sent();
|
|
380
|
+
expect((_c = (_b = copyOfStage.variantOf) === null || _b === void 0 ? void 0 : _b._id) !== null && _c !== void 0 ? _c : null).toBeNull(); // a copy's own id stays nobody's but the owner's
|
|
381
|
+
expect(provenanceOf(copyOfStage)).toEqual(PROVENANCE);
|
|
382
|
+
return [2 /*return*/];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}); });
|
|
386
|
+
it('a row with NO provenance derives rows with none — nothing is invented, at any door', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
387
|
+
var file, _a, _b, variants, copy, _c, _d, _e, _f;
|
|
388
|
+
return __generator(this, function (_g) {
|
|
389
|
+
switch (_g.label) {
|
|
390
|
+
case 0: return [4 /*yield*/, createOwnerPicture('plain.jpg')];
|
|
391
|
+
case 1:
|
|
392
|
+
file = _g.sent();
|
|
393
|
+
_a = expect;
|
|
394
|
+
_b = provenanceOf;
|
|
395
|
+
return [4 /*yield*/, rowAsSystem(file.id)];
|
|
396
|
+
case 2:
|
|
397
|
+
_a.apply(void 0, [_b.apply(void 0, [_g.sent()])]).toEqual(NO_PROVENANCE);
|
|
398
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().deriveVariants(file, Buffer.concat([originalBytes, COPY_MARK]))];
|
|
399
|
+
case 3:
|
|
400
|
+
variants = (_g.sent()).variants;
|
|
401
|
+
return [4 /*yield*/, copyForOthersOf(file)];
|
|
402
|
+
case 4:
|
|
403
|
+
copy = _g.sent();
|
|
404
|
+
_c = expect;
|
|
405
|
+
_d = provenanceOf;
|
|
406
|
+
return [4 /*yield*/, rowAsSystem(variants.preview.id)];
|
|
407
|
+
case 5:
|
|
408
|
+
_c.apply(void 0, [_d.apply(void 0, [_g.sent()])]).toEqual(NO_PROVENANCE);
|
|
409
|
+
_e = expect;
|
|
410
|
+
_f = provenanceOf;
|
|
411
|
+
return [4 /*yield*/, rowAsSystem(variants.stage.id)];
|
|
412
|
+
case 6:
|
|
413
|
+
_e.apply(void 0, [_f.apply(void 0, [_g.sent()])]).toEqual(NO_PROVENANCE);
|
|
414
|
+
expect(provenanceOf(copy)).toEqual(NO_PROVENANCE);
|
|
415
|
+
return [2 /*return*/];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}); });
|
|
419
|
+
});
|
|
420
|
+
//# sourceMappingURL=FileDerivedProvenance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileDerivedProvenance.test.js","sourceRoot":"","sources":["../../test/FileDerivedProvenance.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;oBACnF,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SACnD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -132,6 +132,36 @@ describe('File media metadata columns', function () {
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
}); });
|
|
135
|
+
it('round-trips whether a picture has see-through pixels (`transparent`) — a fact read off the bytes at ingest, absent where nothing read it', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
|
+
var mark, _a, photo, _b, clip, _c;
|
|
137
|
+
var _d;
|
|
138
|
+
return __generator(this, function (_e) {
|
|
139
|
+
switch (_e.label) {
|
|
140
|
+
case 0: return [4 /*yield*/, new FileStorage_1.FileStorage().createFile({ name: 'mark.png', type: 'image/png', size: 4, width: 1024, height: 1024, transparent: true }, Buffer.from('mark').toString('base64'))];
|
|
141
|
+
case 1:
|
|
142
|
+
mark = _e.sent();
|
|
143
|
+
_a = expect;
|
|
144
|
+
return [4 /*yield*/, (0, db_1.getDbAsSystem)().get(tables_1.tables.File, { id: mark.id })];
|
|
145
|
+
case 2:
|
|
146
|
+
_a.apply(void 0, [(_e.sent()).transparent]).toBe(true);
|
|
147
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().createFile({ name: 'photo.jpg', type: 'image/jpeg', size: 4, width: 4032, height: 3024, transparent: false }, Buffer.from('jpeg').toString('base64'))];
|
|
148
|
+
case 3:
|
|
149
|
+
photo = _e.sent();
|
|
150
|
+
_b = expect;
|
|
151
|
+
return [4 /*yield*/, (0, db_1.getDbAsSystem)().get(tables_1.tables.File, { id: photo.id })];
|
|
152
|
+
case 4:
|
|
153
|
+
_b.apply(void 0, [(_e.sent()).transparent]).toBe(false);
|
|
154
|
+
return [4 /*yield*/, new FileStorage_1.FileStorage().createFile({ name: 'clip.mp4', type: 'video/mp4', size: 4, width: 1280, height: 720, durationMs: 1000 }, Buffer.from('clip').toString('base64'))];
|
|
155
|
+
case 5:
|
|
156
|
+
clip = _e.sent();
|
|
157
|
+
_c = expect;
|
|
158
|
+
return [4 /*yield*/, (0, db_1.getDbAsSystem)().get(tables_1.tables.File, { id: clip.id })];
|
|
159
|
+
case 6:
|
|
160
|
+
_c.apply(void 0, [(_d = (_e.sent()).transparent) !== null && _d !== void 0 ? _d : undefined]).toBeUndefined();
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}); });
|
|
135
165
|
it('round-trips the producer attribution — how the bytes came to exist (`origin`)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
166
|
var file, row, plain, _a;
|
|
137
167
|
return __generator(this, function (_b) {
|