@thescaffold/ntx-apps-blobs 0.0.10
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/README.md +1 -0
- package/api/file/dto/create-file.dto.d.ts +10 -0
- package/api/file/dto/create-file.dto.js +63 -0
- package/api/file/dto/create-file.dto.js.map +1 -0
- package/api/file/dto/update-file.dto.d.ts +10 -0
- package/api/file/dto/update-file.dto.js +67 -0
- package/api/file/dto/update-file.dto.js.map +1 -0
- package/api/file/entities/file.entity.d.ts +16 -0
- package/api/file/entities/file.entity.js +75 -0
- package/api/file/entities/file.entity.js.map +1 -0
- package/api/file/file.controller.d.ts +25 -0
- package/api/file/file.controller.js +47 -0
- package/api/file/file.controller.js.map +1 -0
- package/api/file/file.module.d.ts +2 -0
- package/api/file/file.module.js +27 -0
- package/api/file/file.module.js.map +1 -0
- package/api/file/file.service.d.ts +17 -0
- package/api/file/file.service.js +46 -0
- package/api/file/file.service.js.map +1 -0
- package/api/file/index.d.ts +6 -0
- package/api/file/index.js +23 -0
- package/api/file/index.js.map +1 -0
- package/api/page/dto/create-page.dto.d.ts +7 -0
- package/api/page/dto/create-page.dto.js +47 -0
- package/api/page/dto/create-page.dto.js.map +1 -0
- package/api/page/dto/update-page.dto.d.ts +7 -0
- package/api/page/dto/update-page.dto.js +48 -0
- package/api/page/dto/update-page.dto.js.map +1 -0
- package/api/page/entities/page.entity.d.ts +11 -0
- package/api/page/entities/page.entity.js +53 -0
- package/api/page/entities/page.entity.js.map +1 -0
- package/api/page/index.d.ts +6 -0
- package/api/page/index.js +23 -0
- package/api/page/index.js.map +1 -0
- package/api/page/page.controller.d.ts +19 -0
- package/api/page/page.controller.js +40 -0
- package/api/page/page.controller.js.map +1 -0
- package/api/page/page.module.d.ts +2 -0
- package/api/page/page.module.js +27 -0
- package/api/page/page.module.js.map +1 -0
- package/api/page/page.service.d.ts +17 -0
- package/api/page/page.service.js +48 -0
- package/api/page/page.service.js.map +1 -0
- package/app.config.d.ts +0 -0
- package/app.config.js +1 -0
- package/app.config.js.map +1 -0
- package/app.controller.d.ts +62 -0
- package/app.controller.js +145 -0
- package/app.controller.js.map +1 -0
- package/app.dto.d.ts +13 -0
- package/app.dto.js +48 -0
- package/app.dto.js.map +1 -0
- package/app.module.d.ts +2 -0
- package/app.module.js +42 -0
- package/app.module.js.map +1 -0
- package/app.service.d.ts +31 -0
- package/app.service.js +170 -0
- package/app.service.js.map +1 -0
- package/index.d.ts +20 -0
- package/index.js +50 -0
- package/index.js.map +1 -0
- package/migrations/1759862889830-BlobsFile.d.ts +5 -0
- package/migrations/1759862889830-BlobsFile.js +47 -0
- package/migrations/1759862889830-BlobsFile.js.map +1 -0
- package/migrations/1759862889909-BlobsPage.d.ts +5 -0
- package/migrations/1759862889909-BlobsPage.js +33 -0
- package/migrations/1759862889909-BlobsPage.js.map +1 -0
- package/migrations/index.d.ts +2 -0
- package/migrations/index.js +7 -0
- package/migrations/index.js.map +1 -0
- package/package.json +18 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
package/app.service.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { TrackerService } from '@thescaffold/ntx-core';
|
|
3
|
+
import { FastifyReply } from 'fastify';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
5
|
+
import { File, FileService } from './api/file';
|
|
6
|
+
import { Page, PageService } from './api/page';
|
|
7
|
+
export declare class AppService {
|
|
8
|
+
private readonly dataSource;
|
|
9
|
+
private readonly fileService;
|
|
10
|
+
private readonly pageService;
|
|
11
|
+
private readonly trackerService;
|
|
12
|
+
private readonly configService;
|
|
13
|
+
constructor(dataSource: DataSource, fileService: FileService, pageService: PageService, trackerService: TrackerService, configService: ConfigService);
|
|
14
|
+
getHello(): string;
|
|
15
|
+
init(file: Partial<File>): Promise<File & {
|
|
16
|
+
url: string;
|
|
17
|
+
}>;
|
|
18
|
+
batch(pages: Partial<Page>[]): Promise<Page[]>;
|
|
19
|
+
verify(file: Partial<File>): Promise<File & {
|
|
20
|
+
pagesCount: number;
|
|
21
|
+
url: string;
|
|
22
|
+
}>;
|
|
23
|
+
upload(file: Partial<File>, pages: Partial<Page>[]): Promise<[
|
|
24
|
+
File & {
|
|
25
|
+
url: string;
|
|
26
|
+
},
|
|
27
|
+
Page[],
|
|
28
|
+
number
|
|
29
|
+
]>;
|
|
30
|
+
download(fileIdOrName: string, res: FastifyReply): Promise<void>;
|
|
31
|
+
}
|
package/app.service.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AppService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const ntx_core_1 = require("@thescaffold/ntx-core");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
const typeorm_1 = require("typeorm");
|
|
18
|
+
const file_1 = require("./api/file");
|
|
19
|
+
const page_1 = require("./api/page");
|
|
20
|
+
let AppService = class AppService {
|
|
21
|
+
constructor(dataSource, fileService, pageService, trackerService, configService) {
|
|
22
|
+
this.dataSource = dataSource;
|
|
23
|
+
this.fileService = fileService;
|
|
24
|
+
this.pageService = pageService;
|
|
25
|
+
this.trackerService = trackerService;
|
|
26
|
+
this.configService = configService;
|
|
27
|
+
}
|
|
28
|
+
getHello() {
|
|
29
|
+
return 'Hello World!';
|
|
30
|
+
}
|
|
31
|
+
async init(file) {
|
|
32
|
+
const nFile = await this.fileService.withContext({}).findOrCreate({
|
|
33
|
+
userId: file.userId,
|
|
34
|
+
clientId: file.clientId,
|
|
35
|
+
workspaceId: file.workspaceId,
|
|
36
|
+
type: file.type,
|
|
37
|
+
name: file.name,
|
|
38
|
+
}, {
|
|
39
|
+
parentId: file.parentId,
|
|
40
|
+
tags: file.tags,
|
|
41
|
+
size: file.size,
|
|
42
|
+
mime: file.mime,
|
|
43
|
+
status: file.status,
|
|
44
|
+
meta: file.meta,
|
|
45
|
+
});
|
|
46
|
+
return Object.assign(Object.assign({}, nFile), { url: `${this.configService.get('BLOBS_BASE_URL')}/${nFile.id}` });
|
|
47
|
+
}
|
|
48
|
+
async batch(pages) {
|
|
49
|
+
const nPages = [];
|
|
50
|
+
for (let i = 0; i < pages.length; i += 1) {
|
|
51
|
+
const page = pages[i];
|
|
52
|
+
const nPage = await this.pageService.withContext({}).findOrCreate({
|
|
53
|
+
fileId: page.fileId,
|
|
54
|
+
index: page.index,
|
|
55
|
+
}, {
|
|
56
|
+
raw: page.raw,
|
|
57
|
+
});
|
|
58
|
+
nPages.push(nPage);
|
|
59
|
+
}
|
|
60
|
+
return nPages;
|
|
61
|
+
}
|
|
62
|
+
async verify(file) {
|
|
63
|
+
const nFile = await this.fileService.withContext({}).findOne({
|
|
64
|
+
where: [
|
|
65
|
+
{
|
|
66
|
+
userId: file.userId,
|
|
67
|
+
clientId: file.clientId,
|
|
68
|
+
workspaceId: file.workspaceId,
|
|
69
|
+
type: file.type,
|
|
70
|
+
name: file.name,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
const pagesCount = await this.pageService.withContext({}).count({
|
|
75
|
+
where: [
|
|
76
|
+
{
|
|
77
|
+
fileId: nFile.id,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
return Object.assign(Object.assign({}, nFile), { pagesCount, url: `${this.configService.get('BLOBS_BASE_URL')}/${nFile.id}` });
|
|
82
|
+
}
|
|
83
|
+
async upload(file, pages) {
|
|
84
|
+
const nFile = await this.fileService.withContext({}).findOrCreate({
|
|
85
|
+
userId: file.userId,
|
|
86
|
+
clientId: file.clientId,
|
|
87
|
+
workspaceId: file.workspaceId,
|
|
88
|
+
type: file.type,
|
|
89
|
+
name: file.name,
|
|
90
|
+
}, {
|
|
91
|
+
parentId: file.parentId,
|
|
92
|
+
tags: file.tags,
|
|
93
|
+
size: file.size,
|
|
94
|
+
mime: file.mime,
|
|
95
|
+
status: file.status,
|
|
96
|
+
meta: file.meta,
|
|
97
|
+
});
|
|
98
|
+
const nPages = [];
|
|
99
|
+
for (let i = 0; i < pages.length; i += 1) {
|
|
100
|
+
const page = pages[i];
|
|
101
|
+
const nPage = await this.pageService.withContext({}).findOrCreate({
|
|
102
|
+
fileId: nFile.id,
|
|
103
|
+
index: i,
|
|
104
|
+
}, {
|
|
105
|
+
raw: page.raw,
|
|
106
|
+
});
|
|
107
|
+
nPages.push(nPage);
|
|
108
|
+
}
|
|
109
|
+
return [
|
|
110
|
+
Object.assign(Object.assign({}, nFile), { url: `${this.configService.get('BLOBS_BASE_URL')}/${nFile.id}` }),
|
|
111
|
+
nPages,
|
|
112
|
+
nPages.length,
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
async download(fileIdOrName, res) {
|
|
116
|
+
if (!(0, class_validator_1.isUUID)(fileIdOrName)) {
|
|
117
|
+
const existingFile = await this.fileService.withContext({}).findOne({
|
|
118
|
+
where: [{ name: fileIdOrName }],
|
|
119
|
+
});
|
|
120
|
+
if (existingFile) {
|
|
121
|
+
fileIdOrName = existingFile.id;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!fileIdOrName) {
|
|
125
|
+
throw new Error('File not found');
|
|
126
|
+
}
|
|
127
|
+
res.header('Content-Type', 'application/octet-stream');
|
|
128
|
+
res.header('Content-Disposition', `attachment; filename="${fileIdOrName}.bin"`);
|
|
129
|
+
const queryRunner = this.dataSource.createQueryRunner();
|
|
130
|
+
await queryRunner.connect();
|
|
131
|
+
try {
|
|
132
|
+
const query = `
|
|
133
|
+
SELECT raw
|
|
134
|
+
FROM BlobsFiles
|
|
135
|
+
WHERE fileId = ?
|
|
136
|
+
ORDER BY index ASC
|
|
137
|
+
`;
|
|
138
|
+
const stream = await queryRunner.stream(query, [fileIdOrName]);
|
|
139
|
+
stream.on('data', (row) => {
|
|
140
|
+
res.raw.write(row.raw);
|
|
141
|
+
});
|
|
142
|
+
stream.on('end', () => {
|
|
143
|
+
res.raw.end();
|
|
144
|
+
});
|
|
145
|
+
stream.on('error', (err) => {
|
|
146
|
+
if (!res.raw.writableEnded) {
|
|
147
|
+
res.status(500).send(`Error streaming file: ${err.message}`);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
res.status(500).send(`Error streaming file: ${err.message}`);
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
res.raw.on('close', async () => {
|
|
156
|
+
await queryRunner.release();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
exports.AppService = AppService;
|
|
162
|
+
exports.AppService = AppService = __decorate([
|
|
163
|
+
(0, common_1.Injectable)(),
|
|
164
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource,
|
|
165
|
+
file_1.FileService,
|
|
166
|
+
page_1.PageService,
|
|
167
|
+
ntx_core_1.TrackerService,
|
|
168
|
+
config_1.ConfigService])
|
|
169
|
+
], AppService);
|
|
170
|
+
//# sourceMappingURL=app.service.js.map
|
|
@@ -0,0 +1 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AAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAQ,EAAE,EAAE;gBAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;oBAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;gBAC7B,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AA3MY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAGoB,oBAAU;QACT,kBAAW;QACX,kBAAW;QACR,yBAAc;QACf,sBAAa;GANpC,UAAU,CA2MtB"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { File } from './api/file/entities/file.entity';
|
|
2
|
+
import { Page } from './api/page/entities/page.entity';
|
|
3
|
+
export * from './app.module';
|
|
4
|
+
export * from './app.service';
|
|
5
|
+
export * from './migrations';
|
|
6
|
+
export declare const name = "blobs";
|
|
7
|
+
export declare const defaultRolesNPermissions: {
|
|
8
|
+
guest: string[];
|
|
9
|
+
member: string[];
|
|
10
|
+
admin: string[];
|
|
11
|
+
global_member: string[];
|
|
12
|
+
global_admin: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare const entities: (typeof Page | typeof File)[];
|
|
15
|
+
export declare const messages: {};
|
|
16
|
+
export declare const unsafeEventList: any[];
|
|
17
|
+
export declare const subscriptions: any[];
|
|
18
|
+
export declare const paths: string[];
|
|
19
|
+
export declare const jobs: any[];
|
|
20
|
+
export declare const crons: any[];
|
package/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.crons = exports.jobs = exports.paths = exports.subscriptions = exports.unsafeEventList = exports.messages = exports.entities = exports.defaultRolesNPermissions = exports.name = void 0;
|
|
18
|
+
const ntx_core_1 = require("@thescaffold/ntx-core");
|
|
19
|
+
const file_entity_1 = require("./api/file/entities/file.entity");
|
|
20
|
+
const page_entity_1 = require("./api/page/entities/page.entity");
|
|
21
|
+
__exportStar(require("./app.module"), exports);
|
|
22
|
+
__exportStar(require("./app.service"), exports);
|
|
23
|
+
__exportStar(require("./migrations"), exports);
|
|
24
|
+
exports.name = 'blobs';
|
|
25
|
+
exports.defaultRolesNPermissions = {
|
|
26
|
+
[ntx_core_1.DefaultRoleTypeName.Guest]: [
|
|
27
|
+
'guest:read:apps:blobs:remote:*:self',
|
|
28
|
+
'guest:read:apps:blobs:dynamic:*:self',
|
|
29
|
+
'guest:create:apps:blobs:file:*:self',
|
|
30
|
+
'guest:update:apps:blobs:file:*:self',
|
|
31
|
+
'guest:read:apps:blobs:file:*:self',
|
|
32
|
+
],
|
|
33
|
+
[ntx_core_1.DefaultRoleTypeName.Member]: [
|
|
34
|
+
'member:create:apps:blobs:*:*:workspace',
|
|
35
|
+
'member:update:apps:blobs:*:*:self',
|
|
36
|
+
'member:read:apps:blobs:*:*:workspace',
|
|
37
|
+
'member:delete:apps:blobs:*:*:self',
|
|
38
|
+
],
|
|
39
|
+
[ntx_core_1.DefaultRoleTypeName.Admin]: ['admin:*:apps:blobs:*:*:workspace'],
|
|
40
|
+
[ntx_core_1.DefaultRoleTypeName.GlobalMember]: ['global-member:*:apps:blobs:*:*:global'],
|
|
41
|
+
[ntx_core_1.DefaultRoleTypeName.GlobalAdmin]: ['global-admin:*:apps:blobs:*:*:global'],
|
|
42
|
+
};
|
|
43
|
+
exports.entities = [file_entity_1.File, page_entity_1.Page];
|
|
44
|
+
exports.messages = {};
|
|
45
|
+
exports.unsafeEventList = [];
|
|
46
|
+
exports.subscriptions = [];
|
|
47
|
+
exports.paths = [`translations/en/ntx/apps/${exports.name}.yaml`];
|
|
48
|
+
exports.jobs = [];
|
|
49
|
+
exports.crons = [];
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/blobs/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAA4D;AAC5D,iEAAuD;AACvD,iEAAuD;AAEvD,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B;AAEhB,QAAA,IAAI,GAAG,OAAO,CAAC;AAEf,QAAA,wBAAwB,GAAG;IACtC,CAAC,8BAAmB,CAAC,KAAK,CAAC,EAAE;QAC3B,qCAAqC;QACrC,sCAAsC;QACtC,qCAAqC;QACrC,qCAAqC;QACrC,mCAAmC;KACpC;IACD,CAAC,8BAAmB,CAAC,MAAM,CAAC,EAAE;QAC5B,wCAAwC;QACxC,mCAAmC;QACnC,sCAAsC;QACtC,mCAAmC;KACpC;IACD,CAAC,8BAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,kCAAkC,CAAC;IACjE,CAAC,8BAAmB,CAAC,YAAY,CAAC,EAAE,CAAC,uCAAuC,CAAC;IAC7E,CAAC,8BAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,sCAAsC,CAAC;CAC5E,CAAC;AAEW,QAAA,QAAQ,GAAG,CAAC,kBAAI,EAAE,kBAAI,CAAC,CAAC;AAExB,QAAA,QAAQ,GAAG,EAAE,CAAC;AAEd,QAAA,eAAe,GAAG,EAAE,CAAC;AAErB,QAAA,aAAa,GAAG,EAAE,CAAC;AAEnB,QAAA,KAAK,GAAG,CAAC,4BAA4B,YAAI,OAAO,CAAC,CAAC;AAElD,QAAA,IAAI,GAAG,EAAE,CAAC;AAEV,QAAA,KAAK,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlobsFile1759862889830 = void 0;
|
|
4
|
+
class BlobsFile1759862889830 {
|
|
5
|
+
async up(queryRunner) {
|
|
6
|
+
await queryRunner.query(`
|
|
7
|
+
CREATE TABLE \`BlobsFiles\` (
|
|
8
|
+
\`id\` char(36) NOT NULL,
|
|
9
|
+
\`createdAt\` datetime(6) DEFAULT NULL,
|
|
10
|
+
\`updatedAt\` datetime(6) DEFAULT NULL,
|
|
11
|
+
\`deletedAt\` datetime(6) DEFAULT NULL,
|
|
12
|
+
\`userId\` char(36) NOT NULL,
|
|
13
|
+
\`clientId\` char(36) NOT NULL,
|
|
14
|
+
\`workspaceId\` char(36) NOT NULL,
|
|
15
|
+
\`type\` varchar(52) NOT NULL,
|
|
16
|
+
\`parentId\` char(36) NOT NULL,
|
|
17
|
+
\`name\` varchar(255) NOT NULL,
|
|
18
|
+
\`tags\` json DEFAULT NULL,
|
|
19
|
+
\`size\` int NOT NULL,
|
|
20
|
+
\`mime\` varchar(255) NOT NULL,
|
|
21
|
+
\`status\` varchar(52) DEFAULT NULL,
|
|
22
|
+
\`meta\` json DEFAULT NULL,
|
|
23
|
+
PRIMARY KEY (\`id\`),
|
|
24
|
+
KEY \`IdxBlobsFilesCreatedAt\` (\`createdAt\`),
|
|
25
|
+
KEY \`IdxBlobsFilesUpdatedAt\` (\`updatedAt\`),
|
|
26
|
+
KEY \`IdxBlobsFilesDeletedAt\` (\`deletedAt\`),
|
|
27
|
+
KEY \`IdxBlobsFilesUserId\` (\`userId\`),
|
|
28
|
+
KEY \`IdxBlobsFilesClientId\` (\`clientId\`),
|
|
29
|
+
KEY \`IdxBlobsFilesWorkspaceId\` (\`workspaceId\`),
|
|
30
|
+
KEY \`IdxBlobsFilesType\` (\`type\`),
|
|
31
|
+
KEY \`IdxBlobsFilesParentId\` (\`parentId\`),
|
|
32
|
+
UNIQUE KEY \`IdxBlobsFilesName\` (\`name\`),
|
|
33
|
+
KEY \`IdxBlobsFilesMime\` (\`mime\`),
|
|
34
|
+
KEY \`IdxBlobsFilesStatus\` (\`status\`)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
);
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
async down(queryRunner) {
|
|
41
|
+
await queryRunner.query(`
|
|
42
|
+
DROP TABLE IF EXISTS \`BlobsFiles\`;
|
|
43
|
+
`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.BlobsFile1759862889830 = BlobsFile1759862889830;
|
|
47
|
+
//# sourceMappingURL=1759862889830-BlobsFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1759862889830-BlobsFile.js","sourceRoot":"","sources":["../../../../libs/blobs/src/migrations/1759862889830-BlobsFile.ts"],"names":[],"mappings":";;;AAEA,MAAa,sBAAsB;IAC1B,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCvB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,KAAK,CAAC;;KAEvB,CAAC,CAAC;IACL,CAAC;CACF;AA1CD,wDA0CC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlobsPage1759862889909 = void 0;
|
|
4
|
+
class BlobsPage1759862889909 {
|
|
5
|
+
async up(queryRunner) {
|
|
6
|
+
await queryRunner.query(`
|
|
7
|
+
CREATE TABLE \`BlobsPages\` (
|
|
8
|
+
\`id\` char(36) NOT NULL,
|
|
9
|
+
\`createdAt\` datetime(6) DEFAULT NULL,
|
|
10
|
+
\`updatedAt\` datetime(6) DEFAULT NULL,
|
|
11
|
+
\`deletedAt\` datetime(6) DEFAULT NULL,
|
|
12
|
+
\`fileId\` char(36) NOT NULL,
|
|
13
|
+
\`index\` int NOT NULL,
|
|
14
|
+
\`raw\` longblob,
|
|
15
|
+
\`status\` varchar(52) DEFAULT NULL,
|
|
16
|
+
\`meta\` json DEFAULT NULL,
|
|
17
|
+
PRIMARY KEY (\`id\`),
|
|
18
|
+
KEY \`IdxBlobsPagesCreatedAt\` (\`createdAt\`),
|
|
19
|
+
KEY \`IdxBlobsPagesUpdatedAt\` (\`updatedAt\`),
|
|
20
|
+
KEY \`IdxBlobsPagesDeletedAt\` (\`deletedAt\`),
|
|
21
|
+
KEY \`IdxBlobsPagesFileIdIndex\` (\`fileId\`, \`index\`),
|
|
22
|
+
KEY \`IdxBlobsPagesStatus\` (\`status\`)
|
|
23
|
+
);
|
|
24
|
+
`);
|
|
25
|
+
}
|
|
26
|
+
async down(queryRunner) {
|
|
27
|
+
await queryRunner.query(`
|
|
28
|
+
DROP TABLE IF EXISTS \`BlobsPages\`;
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BlobsPage1759862889909 = BlobsPage1759862889909;
|
|
33
|
+
//# sourceMappingURL=1759862889909-BlobsPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1759862889909-BlobsPage.js","sourceRoot":"","sources":["../../../../libs/blobs/src/migrations/1759862889909-BlobsPage.ts"],"names":[],"mappings":";;;AAEA,MAAa,sBAAsB;IAC1B,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;KAkBvB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,KAAK,CAAC;;KAEvB,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,wDA4BC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrations = void 0;
|
|
4
|
+
const _1759862889830_BlobsFile_1 = require("./1759862889830-BlobsFile");
|
|
5
|
+
const _1759862889909_BlobsPage_1 = require("./1759862889909-BlobsPage");
|
|
6
|
+
exports.migrations = [_1759862889830_BlobsFile_1.BlobsFile1759862889830, _1759862889909_BlobsPage_1.BlobsPage1759862889909];
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/blobs/src/migrations/index.ts"],"names":[],"mappings":";;;AAAA,wEAAmE;AACnE,wEAAmE;AAEtD,QAAA,UAAU,GAAG,CAAC,iDAAsB,EAAE,iDAAsB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thescaffold/ntx-apps-blobs",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@nestjs/axios": "^3.0.2",
|
|
6
|
+
"@nestjs/common": "^10.3.9",
|
|
7
|
+
"@nestjs/config": "^3.2.2",
|
|
8
|
+
"@nestjs/core": "^10.3.9",
|
|
9
|
+
"@thescaffold/jsx-polylog": "*"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"typings": "index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"default": "./index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|