@hcengineering/drive 0.7.423
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/lib/analytics.js +30 -0
- package/lib/analytics.js.map +7 -0
- package/lib/index.js +31 -0
- package/lib/index.js.map +7 -0
- package/lib/plugin.js +101 -0
- package/lib/plugin.js.map +7 -0
- package/lib/types.js +40 -0
- package/lib/types.js.map +7 -0
- package/lib/utils.js +139 -0
- package/lib/utils.js.map +7 -0
- package/package.json +52 -0
- package/tsconfig.json +12 -0
package/lib/analytics.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var analytics_exports = {};
|
|
20
|
+
__export(analytics_exports, {
|
|
21
|
+
DriveEvents: () => DriveEvents
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(analytics_exports);
|
|
24
|
+
var DriveEvents = /* @__PURE__ */ ((DriveEvents2) => {
|
|
25
|
+
DriveEvents2["FileUploaded"] = "drive.FileUploaded";
|
|
26
|
+
DriveEvents2["FolderCreated"] = "drive.folder.Created";
|
|
27
|
+
DriveEvents2["DriveCreated"] = "drive.drive.Created";
|
|
28
|
+
return DriveEvents2;
|
|
29
|
+
})(DriveEvents || {});
|
|
30
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/analytics.ts"],
|
|
4
|
+
"sourcesContent": ["export enum DriveEvents {\n FileUploaded = 'drive.FileUploaded',\n FolderCreated = 'drive.folder.Created',\n DriveCreated = 'drive.drive.Created'\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,aAAA,kBAAe;AACf,EAAAA,aAAA,mBAAgB;AAChB,EAAAA,aAAA,kBAAe;AAHL,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["DriveEvents"]
|
|
7
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
default: () => index_default,
|
|
23
|
+
driveId: () => import_plugin.driveId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_plugin = require("./plugin");
|
|
27
|
+
__reExport(index_exports, require("./types"), module.exports);
|
|
28
|
+
__reExport(index_exports, require("./utils"), module.exports);
|
|
29
|
+
__reExport(index_exports, require("./analytics"), module.exports);
|
|
30
|
+
var index_default = import_plugin.drivePlugin;
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright \u00A9 2024 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport { driveId, drivePlugin } from './plugin'\n\nexport * from './types'\nexport * from './utils'\nexport * from './analytics'\nexport { driveId }\n\nexport default drivePlugin\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,oBAAqC;AAErC,0BAAc,oBAjBd;AAkBA,0BAAc,oBAlBd;AAmBA,0BAAc,wBAnBd;AAsBA,IAAO,gBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var plugin_exports = {};
|
|
21
|
+
__export(plugin_exports, {
|
|
22
|
+
default: () => plugin_default,
|
|
23
|
+
driveId: () => driveId,
|
|
24
|
+
drivePlugin: () => drivePlugin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
27
|
+
var import_platform = require("@hcengineering/platform");
|
|
28
|
+
__reExport(plugin_exports, require("./types"), module.exports);
|
|
29
|
+
const driveId = "drive";
|
|
30
|
+
const drivePlugin = (0, import_platform.plugin)(driveId, {
|
|
31
|
+
class: {
|
|
32
|
+
Drive: "",
|
|
33
|
+
File: "",
|
|
34
|
+
FileVersion: "",
|
|
35
|
+
Folder: "",
|
|
36
|
+
Resource: "",
|
|
37
|
+
TypeFileVersion: ""
|
|
38
|
+
},
|
|
39
|
+
mixin: {
|
|
40
|
+
DefaultDriveTypeData: ""
|
|
41
|
+
},
|
|
42
|
+
icon: {
|
|
43
|
+
DriveApplication: "",
|
|
44
|
+
Drive: "",
|
|
45
|
+
Drives: "",
|
|
46
|
+
Grid: "",
|
|
47
|
+
File: "",
|
|
48
|
+
Folder: "",
|
|
49
|
+
FolderOpen: "",
|
|
50
|
+
FolderClosed: "",
|
|
51
|
+
Download: "",
|
|
52
|
+
Restore: ""
|
|
53
|
+
},
|
|
54
|
+
app: {
|
|
55
|
+
Drive: ""
|
|
56
|
+
},
|
|
57
|
+
ids: {
|
|
58
|
+
Root: ""
|
|
59
|
+
},
|
|
60
|
+
resolver: {
|
|
61
|
+
Location: ""
|
|
62
|
+
},
|
|
63
|
+
string: {
|
|
64
|
+
Drive: "",
|
|
65
|
+
File: "",
|
|
66
|
+
FileVersion: "",
|
|
67
|
+
Folder: "",
|
|
68
|
+
Resource: "",
|
|
69
|
+
ForbidCreateDrivePermission: "",
|
|
70
|
+
ForbidCreateDrivePermissionDescription: "",
|
|
71
|
+
CreateFilePermission: "",
|
|
72
|
+
CreateFilePermissionDescription: "",
|
|
73
|
+
UpdateFilePermission: "",
|
|
74
|
+
UpdateFilePermissionDescription: "",
|
|
75
|
+
RemoveFilePermission: "",
|
|
76
|
+
RemoveFilePermissionDescription: "",
|
|
77
|
+
CreateFolderPermission: "",
|
|
78
|
+
CreateFolderPermissionDescription: "",
|
|
79
|
+
UpdateFolderPermission: "",
|
|
80
|
+
UpdateFolderPermissionDescription: "",
|
|
81
|
+
RemoveFolderPermission: "",
|
|
82
|
+
RemoveFolderPermissionDescription: ""
|
|
83
|
+
},
|
|
84
|
+
descriptor: {
|
|
85
|
+
DriveType: ""
|
|
86
|
+
},
|
|
87
|
+
spaceType: {
|
|
88
|
+
DefaultDrive: ""
|
|
89
|
+
},
|
|
90
|
+
permission: {
|
|
91
|
+
ForbidCreateDrive: "",
|
|
92
|
+
CreateFile: "",
|
|
93
|
+
UpdateFile: "",
|
|
94
|
+
RemoveFile: "",
|
|
95
|
+
CreateFolder: "",
|
|
96
|
+
UpdateFolder: "",
|
|
97
|
+
RemoveFolder: ""
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var plugin_default = drivePlugin;
|
|
101
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/plugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright \u00A9 2024 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport type { Class, Doc, Mixin, Ref, SpaceType, SpaceTypeDescriptor, Type, Permission } from '@hcengineering/core'\nimport type { Asset, IntlString, Plugin, Resource as PlatformResource } from '@hcengineering/platform'\nimport { plugin } from '@hcengineering/platform'\nimport type { Location, ResolvedLocation } from '@hcengineering/ui/src/types'\nimport { Drive, File, FileVersion, Folder, Resource } from './types'\n\nexport * from './types'\n\n/**\n * @public\n */\nexport const driveId = 'drive' as Plugin\n\nexport const drivePlugin = plugin(driveId, {\n class: {\n Drive: '' as Ref<Class<Drive>>,\n File: '' as Ref<Class<File>>,\n FileVersion: '' as Ref<Class<FileVersion>>,\n Folder: '' as Ref<Class<Folder>>,\n Resource: '' as Ref<Class<Resource>>,\n TypeFileVersion: '' as Ref<Class<Type<number>>>\n },\n mixin: {\n DefaultDriveTypeData: '' as Ref<Mixin<Drive>>\n },\n icon: {\n DriveApplication: '' as Asset,\n Drive: '' as Asset,\n Drives: '' as Asset,\n Grid: '' as Asset,\n File: '' as Asset,\n Folder: '' as Asset,\n FolderOpen: '' as Asset,\n FolderClosed: '' as Asset,\n Download: '' as Asset,\n Restore: '' as Asset\n },\n app: {\n Drive: '' as Ref<Doc>\n },\n ids: {\n Root: '' as Ref<Folder>\n },\n resolver: {\n Location: '' as PlatformResource<(loc: Location) => Promise<ResolvedLocation | undefined>>\n },\n string: {\n Drive: '' as IntlString,\n File: '' as IntlString,\n FileVersion: '' as IntlString,\n Folder: '' as IntlString,\n Resource: '' as IntlString,\n ForbidCreateDrivePermission: '' as IntlString,\n ForbidCreateDrivePermissionDescription: '' as IntlString,\n CreateFilePermission: '' as IntlString,\n CreateFilePermissionDescription: '' as IntlString,\n UpdateFilePermission: '' as IntlString,\n UpdateFilePermissionDescription: '' as IntlString,\n RemoveFilePermission: '' as IntlString,\n RemoveFilePermissionDescription: '' as IntlString,\n CreateFolderPermission: '' as IntlString,\n CreateFolderPermissionDescription: '' as IntlString,\n UpdateFolderPermission: '' as IntlString,\n UpdateFolderPermissionDescription: '' as IntlString,\n RemoveFolderPermission: '' as IntlString,\n RemoveFolderPermissionDescription: '' as IntlString\n },\n descriptor: {\n DriveType: '' as Ref<SpaceTypeDescriptor>\n },\n spaceType: {\n DefaultDrive: '' as Ref<SpaceType>\n },\n permission: {\n ForbidCreateDrive: '' as Ref<Permission>,\n CreateFile: '' as Ref<Permission>,\n UpdateFile: '' as Ref<Permission>,\n RemoveFile: '' as Ref<Permission>,\n CreateFolder: '' as Ref<Permission>,\n UpdateFolder: '' as Ref<Permission>,\n RemoveFolder: '' as Ref<Permission>\n }\n})\n\nexport default drivePlugin\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,sBAAuB;AAIvB,2BAAc,oBArBd;AA0BO,MAAM,UAAU;AAEhB,MAAM,kBAAc,wB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|
7
|
+
}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var types_exports = {};
|
|
31
|
+
__export(types_exports, {
|
|
32
|
+
TypeFileVersion: () => TypeFileVersion
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(types_exports);
|
|
35
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
36
|
+
function TypeFileVersion() {
|
|
37
|
+
return { _class: import_plugin.default.class.TypeFileVersion, label: import_plugin.default.string.FileVersion };
|
|
38
|
+
}
|
|
39
|
+
__name(TypeFileVersion, "TypeFileVersion");
|
|
40
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright \u00A9 2024 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport { AttachedDoc, Blob, CollectionSize, Doc, Ref, Type, TypedSpace } from '@hcengineering/core'\n\nimport drive from './plugin'\n\n/** @public */\nexport function TypeFileVersion (): Type<number> {\n return { _class: drive.class.TypeFileVersion, label: drive.string.FileVersion }\n}\n\n/** @public */\nexport interface Drive extends TypedSpace {}\n\n/** @public */\nexport interface Resource extends Doc<Drive> {\n title: string\n parent: Ref<Resource>\n path: Ref<Resource>[]\n\n comments?: number\n\n // ugly but needed here to get version lookup work for Resource\n file?: Ref<FileVersion>\n}\n\n/** @public */\nexport interface Folder extends Resource {\n parent: Ref<Folder>\n path: Ref<Folder>[]\n\n file?: undefined\n}\n\n/** @public */\nexport interface File extends Resource {\n parent: Ref<Folder>\n path: Ref<Folder>[]\n\n file: Ref<FileVersion>\n versions: CollectionSize<FileVersion>\n version: number\n}\n\n/** @public */\nexport interface FileVersion extends AttachedDoc<File, 'versions', Drive> {\n title: string\n file: Ref<Blob>\n size: number\n type: string\n lastModified: number\n metadata?: Record<string, any>\n version: number\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,oBAAkB;AAGX,SAAS,kBAAiC;AAC/C,SAAO,EAAE,QAAQ,cAAAA,QAAM,MAAM,iBAAiB,OAAO,cAAAA,QAAM,OAAO,YAAY;AAChF;AAFgB;",
|
|
6
|
+
"names": ["drive"]
|
|
7
|
+
}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
createFile: () => createFile,
|
|
33
|
+
createFileVersion: () => createFileVersion,
|
|
34
|
+
createFolder: () => createFolder,
|
|
35
|
+
getDriveLink: () => getDriveLink,
|
|
36
|
+
getFileLink: () => getFileLink,
|
|
37
|
+
getFolderLink: () => getFolderLink,
|
|
38
|
+
restoreFileVersion: () => restoreFileVersion
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(utils_exports);
|
|
41
|
+
var import_core = require("@hcengineering/core");
|
|
42
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
43
|
+
async function createFolder(client, space, data) {
|
|
44
|
+
let path = [];
|
|
45
|
+
if (data.parent !== import_plugin.default.ids.Root) {
|
|
46
|
+
const parent = await client.findOne(import_plugin.default.class.Folder, { _id: data.parent });
|
|
47
|
+
if (parent === void 0) {
|
|
48
|
+
throw new Error("parent not found");
|
|
49
|
+
}
|
|
50
|
+
path = [parent._id, ...parent.path];
|
|
51
|
+
}
|
|
52
|
+
return await client.createDoc(import_plugin.default.class.Folder, space, { ...data, path });
|
|
53
|
+
}
|
|
54
|
+
__name(createFolder, "createFolder");
|
|
55
|
+
async function createFile(client, space, parent, data) {
|
|
56
|
+
const folder = await client.findOne(import_plugin.default.class.Folder, { _id: parent });
|
|
57
|
+
const path = folder !== void 0 ? [folder._id, ...folder.path] : [];
|
|
58
|
+
const version = 1;
|
|
59
|
+
const versionId = (0, import_core.generateId)();
|
|
60
|
+
const fileId = await client.createDoc(import_plugin.default.class.File, space, {
|
|
61
|
+
title: data.title,
|
|
62
|
+
parent,
|
|
63
|
+
path,
|
|
64
|
+
file: versionId,
|
|
65
|
+
version,
|
|
66
|
+
versions: 0
|
|
67
|
+
});
|
|
68
|
+
await client.addCollection(
|
|
69
|
+
import_plugin.default.class.FileVersion,
|
|
70
|
+
space,
|
|
71
|
+
fileId,
|
|
72
|
+
import_plugin.default.class.File,
|
|
73
|
+
"versions",
|
|
74
|
+
{ ...data, version },
|
|
75
|
+
versionId
|
|
76
|
+
);
|
|
77
|
+
return fileId;
|
|
78
|
+
}
|
|
79
|
+
__name(createFile, "createFile");
|
|
80
|
+
async function createFileVersion(client, file, data) {
|
|
81
|
+
const current = await client.findOne(import_plugin.default.class.File, { _id: file });
|
|
82
|
+
if (current === void 0) {
|
|
83
|
+
throw new Error("file not found");
|
|
84
|
+
}
|
|
85
|
+
const incResult = await client.update(current, { $inc: { version: 1 } }, true);
|
|
86
|
+
const version = incResult.object.version;
|
|
87
|
+
const ops = client.apply(file);
|
|
88
|
+
const versionId = await ops.addCollection(
|
|
89
|
+
import_plugin.default.class.FileVersion,
|
|
90
|
+
current.space,
|
|
91
|
+
current._id,
|
|
92
|
+
current._class,
|
|
93
|
+
"versions",
|
|
94
|
+
{ ...data, version }
|
|
95
|
+
);
|
|
96
|
+
await ops.update(current, { file: versionId });
|
|
97
|
+
await ops.commit();
|
|
98
|
+
}
|
|
99
|
+
__name(createFileVersion, "createFileVersion");
|
|
100
|
+
async function restoreFileVersion(client, file, version) {
|
|
101
|
+
const currentFile = await client.findOne(import_plugin.default.class.File, { _id: file });
|
|
102
|
+
if (currentFile === void 0) {
|
|
103
|
+
throw new Error("file not found");
|
|
104
|
+
}
|
|
105
|
+
if (currentFile.file !== version) {
|
|
106
|
+
await client.update(currentFile, { file: version });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
__name(restoreFileVersion, "restoreFileVersion");
|
|
110
|
+
function getDriveLink(loc, _id) {
|
|
111
|
+
loc.path.length = 2;
|
|
112
|
+
loc.fragment = void 0;
|
|
113
|
+
loc.query = void 0;
|
|
114
|
+
loc.path[2] = import_plugin.driveId;
|
|
115
|
+
loc.path[3] = _id;
|
|
116
|
+
return loc;
|
|
117
|
+
}
|
|
118
|
+
__name(getDriveLink, "getDriveLink");
|
|
119
|
+
function getFolderLink(loc, _id) {
|
|
120
|
+
loc.path.length = 2;
|
|
121
|
+
loc.fragment = void 0;
|
|
122
|
+
loc.query = void 0;
|
|
123
|
+
loc.path[2] = import_plugin.driveId;
|
|
124
|
+
loc.path[3] = "folder";
|
|
125
|
+
loc.path[4] = _id;
|
|
126
|
+
return loc;
|
|
127
|
+
}
|
|
128
|
+
__name(getFolderLink, "getFolderLink");
|
|
129
|
+
function getFileLink(loc, _id) {
|
|
130
|
+
loc.path.length = 2;
|
|
131
|
+
loc.fragment = void 0;
|
|
132
|
+
loc.query = void 0;
|
|
133
|
+
loc.path[2] = import_plugin.driveId;
|
|
134
|
+
loc.path[3] = "file";
|
|
135
|
+
loc.path[4] = _id;
|
|
136
|
+
return loc;
|
|
137
|
+
}
|
|
138
|
+
__name(getFileLink, "getFileLink");
|
|
139
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright \u00A9 2024 Hardcore Engineering Inc.\n//\n// Licensed under the Eclipse Public License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License. You may\n// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport { type AttachedData, type Data, type Ref, type TxOperations, generateId } from '@hcengineering/core'\nimport { type Location } from '@hcengineering/ui'\n\nimport drive, { driveId } from './plugin'\nimport type { Drive, File, FileVersion, Folder } from './types'\n\n/** @public */\nexport async function createFolder (\n client: TxOperations,\n space: Ref<Drive>,\n data: Omit<Data<Folder>, 'path'>\n): Promise<Ref<Folder>> {\n let path: Array<Ref<Folder>> = []\n\n if (data.parent !== drive.ids.Root) {\n const parent = await client.findOne(drive.class.Folder, { _id: data.parent })\n if (parent === undefined) {\n throw new Error('parent not found')\n }\n path = [parent._id, ...parent.path]\n }\n\n return await client.createDoc(drive.class.Folder, space, { ...data, path })\n}\n\n/** @public */\nexport async function createFile (\n client: TxOperations,\n space: Ref<Drive>,\n parent: Ref<Folder>,\n data: Omit<AttachedData<FileVersion>, 'version'>\n): Promise<Ref<File>> {\n const folder = await client.findOne(drive.class.Folder, { _id: parent })\n const path = folder !== undefined ? [folder._id, ...folder.path] : []\n\n const version = 1\n const versionId: Ref<FileVersion> = generateId()\n\n const fileId = await client.createDoc(drive.class.File, space, {\n title: data.title,\n parent,\n path,\n file: versionId,\n version,\n versions: 0\n })\n\n await client.addCollection(\n drive.class.FileVersion,\n space,\n fileId,\n drive.class.File,\n 'versions',\n { ...data, version },\n versionId\n )\n\n return fileId\n}\n\n/** @public */\nexport async function createFileVersion (\n client: TxOperations,\n file: Ref<File>,\n data: Omit<AttachedData<FileVersion>, 'version'>\n): Promise<void> {\n const current = await client.findOne(drive.class.File, { _id: file })\n if (current === undefined) {\n throw new Error('file not found')\n }\n\n const incResult = await client.update(current, { $inc: { version: 1 } }, true)\n const version = (incResult as any).object.version\n\n const ops = client.apply(file)\n\n const versionId = await ops.addCollection(\n drive.class.FileVersion,\n current.space,\n current._id,\n current._class,\n 'versions',\n { ...data, version }\n )\n\n await ops.update(current, { file: versionId })\n\n await ops.commit()\n}\n\n/** @public */\nexport async function restoreFileVersion (\n client: TxOperations,\n file: Ref<File>,\n version: Ref<FileVersion>\n): Promise<void> {\n const currentFile = await client.findOne(drive.class.File, { _id: file })\n if (currentFile === undefined) {\n throw new Error('file not found')\n }\n\n if (currentFile.file !== version) {\n await client.update(currentFile, { file: version })\n }\n}\n\nexport function getDriveLink (loc: Location, _id: Ref<Drive>): Location {\n loc.path.length = 2\n loc.fragment = undefined\n loc.query = undefined\n loc.path[2] = driveId\n loc.path[3] = _id\n\n return loc\n}\n\nexport function getFolderLink (loc: Location, _id: Ref<Folder>): Location {\n loc.path.length = 2\n loc.fragment = undefined\n loc.query = undefined\n loc.path[2] = driveId\n loc.path[3] = 'folder'\n loc.path[4] = _id\n\n return loc\n}\n\nexport function getFileLink (loc: Location, _id: Ref<File>): Location {\n loc.path.length = 2\n loc.fragment = undefined\n loc.query = undefined\n loc.path[2] = driveId\n loc.path[3] = 'file'\n loc.path[4] = _id\n\n return loc\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,kBAAsF;AAGtF,oBAA+B;AAI/B,eAAsB,aACpB,QACA,OACA,MACsB;AACtB,MAAI,OAA2B,CAAC;AAEhC,MAAI,KAAK,WAAW,cAAAA,QAAM,IAAI,MAAM;AAClC,UAAM,SAAS,MAAM,OAAO,QAAQ,cAAAA,QAAM,MAAM,QAAQ,EAAE,KAAK,KAAK,OAAO,CAAC;AAC5E,QAAI,WAAW,QAAW;AACxB,YAAM,IAAI,MAAM,kBAAkB;AAAA,IACpC;AACA,WAAO,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI;AAAA,EACpC;AAEA,SAAO,MAAM,OAAO,UAAU,cAAAA,QAAM,MAAM,QAAQ,OAAO,EAAE,GAAG,MAAM,KAAK,CAAC;AAC5E;AAhBsB;AAmBtB,eAAsB,WACpB,QACA,OACA,QACA,MACoB;AACpB,QAAM,SAAS,MAAM,OAAO,QAAQ,cAAAA,QAAM,MAAM,QAAQ,EAAE,KAAK,OAAO,CAAC;AACvE,QAAM,OAAO,WAAW,SAAY,CAAC,OAAO,KAAK,G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AAM,IAAI,MAAM,gBAAgB;AAAA,EAClC;AAEA,MAAI,YAAY,SAAS,SAAS;AAChC,UAAM,OAAO,OAAO,aAAa,EAAE,MAAM,QAAQ,CAAC;AAAA,EACpD;AACF;AAbsB;AAef,SAAS,aAAc,KAAe,KAA2B;AACtE,MAAI,KAAK,SAAS;AAClB,MAAI,WAAW;AACf,MAAI,QAAQ;AACZ,MAAI,KAAK,CAAC,IAAI;AACd,MAAI,KAAK,CAAC,IAAI;AAEd,SAAO;AACT;AARgB;AAUT,SAAS,cAAe,KAAe,KAA4B;AACxE,MAAI,KAAK,SAAS;AAClB,MAAI,WAAW;AACf,MAAI,QAAQ;AACZ,MAAI,KAAK,CAAC,IAAI;AACd,MAAI,KAAK,CAAC,IAAI;AACd,MAAI,KAAK,CAAC,IAAI;AAEd,SAAO;AACT;AATgB;AAWT,SAAS,YAAa,KAAe,KAA0B;AACpE,MAAI,KAAK,SAAS;AAClB,MAAI,WAAW;AACf,MAAI,QAAQ;AACZ,MAAI,KAAK,CAAC,IAAI;AACd,MAAI,KAAK,CAAC,IAAI;AACd,MAAI,KAAK,CAAC,IAAI;AAEd,SAAO;AACT;AATgB;",
|
|
6
|
+
"names": ["drive"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hcengineering/drive",
|
|
3
|
+
"version": "0.7.423",
|
|
4
|
+
"main": "lib/index.js",
|
|
5
|
+
"svelte": "src/index.ts",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*",
|
|
9
|
+
"types/**/*",
|
|
10
|
+
"tsconfig.json"
|
|
11
|
+
],
|
|
12
|
+
"author": "Hardcore Engineering Inc.",
|
|
13
|
+
"license": "EPL-2.0",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "compile",
|
|
16
|
+
"build:watch": "compile",
|
|
17
|
+
"format": "format src",
|
|
18
|
+
"test": "jest --passWithNoTests --silent",
|
|
19
|
+
"_phase:build": "compile transpile src",
|
|
20
|
+
"_phase:test": "jest --passWithNoTests --silent",
|
|
21
|
+
"_phase:format": "format src",
|
|
22
|
+
"_phase:validate": "compile validate"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@hcengineering/platform-rig": "^0.7.423",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
27
|
+
"eslint-plugin-import": "^2.26.0",
|
|
28
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
29
|
+
"eslint-plugin-n": "^15.4.0",
|
|
30
|
+
"eslint": "^8.54.0",
|
|
31
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
32
|
+
"eslint-config-standard-with-typescript": "^40.0.0",
|
|
33
|
+
"prettier": "^3.6.2",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"jest": "^29.7.0",
|
|
36
|
+
"ts-jest": "^29.1.1",
|
|
37
|
+
"@types/jest": "^29.5.5"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@hcengineering/core": "^0.7.423",
|
|
41
|
+
"@hcengineering/platform": "^0.7.423",
|
|
42
|
+
"@hcengineering/preference": "^0.7.423",
|
|
43
|
+
"@hcengineering/ui": "^0.7.423"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/hcengineering/platform.git"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./node_modules/@hcengineering/platform-rig/profiles/default/tsconfig.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./lib",
|
|
7
|
+
"declarationDir": "./types",
|
|
8
|
+
"tsBuildInfoFile": ".build/build.tsbuildinfo"
|
|
9
|
+
},
|
|
10
|
+
"include": ["src/**/*"],
|
|
11
|
+
"exclude": ["node_modules", "lib", "dist", "types", "bundle"]
|
|
12
|
+
}
|