1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.FileSchema = void 0;
|
4 | var common_1 = require("../common");
|
5 | var FileLinks_1 = require("./FileLinks");
|
6 | var FilePath_1 = require("./FilePath");
|
7 | var Uri_1 = require("../Uri");
|
8 | exports.FileSchema = {
|
9 | ERROR: common_1.ERROR,
|
10 | Links: FileLinks_1.FileLinks,
|
11 | Path: FilePath_1.FilePath,
|
12 | type: 'FILE',
|
13 | toObject: function (args) {
|
14 | return {
|
15 | fileid: args.fileid,
|
16 | uri: args.uri,
|
17 | path: args.nsPath + "/" + exports.FileSchema.type + "/" + args.fileid,
|
18 | };
|
19 | },
|
20 | uri: function (args) {
|
21 | var path = (args.path || '').trim();
|
22 | var parts = path.split('/');
|
23 | if (parts[0] !== 'NS') {
|
24 | throw new Error("The DB path does not start with 'NS/'. Given '" + path + "'.");
|
25 | }
|
26 | if (parts[2] !== 'FILE') {
|
27 | throw new Error("The DB path does not contain '/FILE/'. Given '" + path + "'.");
|
28 | }
|
29 | var ns = parts[1];
|
30 | var file = parts[3];
|
31 | return Uri_1.Uri.create.file(ns, file);
|
32 | },
|
33 | toFileLocation: function (input) {
|
34 | if (input === void 0) { input = ''; }
|
35 | input = input.trim();
|
36 | return common_1.isHttp(input) ? input : "file://" + input;
|
37 | },
|
38 | };
|