@memberjunction/server 0.9.242 → 0.9.243
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/build.log.json +396 -408
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +4 -1
- package/dist/context.js.map +1 -1
- package/dist/generated/generated.d.ts +6 -0
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +24 -0
- package/dist/generated/generated.js.map +1 -1
- package/dist/resolvers/FileResolver.d.ts +21 -0
- package/dist/resolvers/FileResolver.d.ts.map +1 -0
- package/dist/resolvers/FileResolver.js +124 -0
- package/dist/resolvers/FileResolver.js.map +1 -0
- package/package.json +77 -76
- package/src/context.ts +4 -1
- package/src/generated/generated.ts +19 -1
- package/src/resolvers/FileResolver.ts +106 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AppContext, PubSubEngine } from '@memberjunction/server';
|
|
2
|
+
import { CreateFileInput, FileResolver as FileResolverBase, File_ } from '../generated/generated';
|
|
3
|
+
export declare class CreateUploadURLInput {
|
|
4
|
+
FileID: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class CreateFilePayload {
|
|
7
|
+
File: File_;
|
|
8
|
+
UploadUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class FileExt extends File_ {
|
|
11
|
+
DownloadUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class FileResolver extends FileResolverBase {
|
|
14
|
+
CreateFile(input: CreateFileInput, { dataSource, userPayload }: AppContext, pubSub: PubSubEngine): Promise<{
|
|
15
|
+
File: {};
|
|
16
|
+
UploadUrl: string;
|
|
17
|
+
}>;
|
|
18
|
+
DownloadUrl(file: File_, { userPayload }: AppContext): Promise<string>;
|
|
19
|
+
DeleteFile(ID: number, { dataSource, userPayload }: AppContext, pubSub: PubSubEngine): Promise<{}>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FileResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileResolver.d.ts","sourceRoot":"","sources":["../../src/resolvers/FileResolver.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAUV,YAAY,EAGb,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,YAAY,IAAI,gBAAgB,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElG,qBACa,oBAAoB;IAE/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBACa,iBAAiB;IAE5B,IAAI,EAAE,KAAK,CAAC;IAEZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBACa,OAAQ,SAAQ,KAAK;IAEhC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBACa,YAAa,SAAQ,gBAAgB;IAE1C,UAAU,CACuB,KAAK,EAAE,eAAe,EACpD,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,UAAU,EACpC,MAAM,EAAE,YAAY;;;;IA2B1B,WAAW,CAAS,IAAI,EAAE,KAAK,EAAS,EAAE,WAAW,EAAE,EAAE,UAAU;IAcnE,UAAU,CAAuB,EAAE,EAAE,MAAM,EAAS,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,UAAU,EAAY,MAAM,EAAE,YAAY;CAkBlI"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FileResolver = exports.FileExt = exports.CreateFilePayload = exports.CreateUploadURLInput = void 0;
|
|
16
|
+
const core_1 = require("@memberjunction/core");
|
|
17
|
+
const server_1 = require("@memberjunction/server");
|
|
18
|
+
const storage_1 = require("@memberjunction/storage");
|
|
19
|
+
const generated_1 = require("../generated/generated");
|
|
20
|
+
let CreateUploadURLInput = class CreateUploadURLInput {
|
|
21
|
+
};
|
|
22
|
+
exports.CreateUploadURLInput = CreateUploadURLInput;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, server_1.Field)(() => server_1.Int),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], CreateUploadURLInput.prototype, "FileID", void 0);
|
|
27
|
+
exports.CreateUploadURLInput = CreateUploadURLInput = __decorate([
|
|
28
|
+
(0, server_1.InputType)()
|
|
29
|
+
], CreateUploadURLInput);
|
|
30
|
+
let CreateFilePayload = class CreateFilePayload {
|
|
31
|
+
};
|
|
32
|
+
exports.CreateFilePayload = CreateFilePayload;
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, server_1.Field)(() => generated_1.File_),
|
|
35
|
+
__metadata("design:type", generated_1.File_)
|
|
36
|
+
], CreateFilePayload.prototype, "File", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, server_1.Field)(() => String),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], CreateFilePayload.prototype, "UploadUrl", void 0);
|
|
41
|
+
exports.CreateFilePayload = CreateFilePayload = __decorate([
|
|
42
|
+
(0, server_1.ObjectType)()
|
|
43
|
+
], CreateFilePayload);
|
|
44
|
+
let FileExt = class FileExt extends generated_1.File_ {
|
|
45
|
+
};
|
|
46
|
+
exports.FileExt = FileExt;
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, server_1.Field)(() => String),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], FileExt.prototype, "DownloadUrl", void 0);
|
|
51
|
+
exports.FileExt = FileExt = __decorate([
|
|
52
|
+
(0, server_1.ObjectType)()
|
|
53
|
+
], FileExt);
|
|
54
|
+
let FileResolver = class FileResolver extends generated_1.FileResolver {
|
|
55
|
+
async CreateFile(input, { dataSource, userPayload }, pubSub) {
|
|
56
|
+
const md = new core_1.Metadata();
|
|
57
|
+
const userInfo = this.GetUserFromPayload(userPayload);
|
|
58
|
+
const providerEntity = await md.GetEntityObject('File Storage Providers', userInfo);
|
|
59
|
+
const fileRecord = (await super.CreateFile({ ...input, Status: 'Pending' }, { dataSource, userPayload }, pubSub));
|
|
60
|
+
if (!fileRecord) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const { updatedInput, UploadUrl } = await (0, storage_1.createUploadUrl)(providerEntity, fileRecord);
|
|
64
|
+
const fileEntity = await new core_1.Metadata().GetEntityObject('Files', userInfo);
|
|
65
|
+
fileEntity.LoadFromData(input);
|
|
66
|
+
fileEntity.SetMany(updatedInput);
|
|
67
|
+
await fileEntity.Save();
|
|
68
|
+
const File = fileEntity.GetAll();
|
|
69
|
+
return { File, UploadUrl };
|
|
70
|
+
}
|
|
71
|
+
async DownloadUrl(file, { userPayload }) {
|
|
72
|
+
const md = new core_1.Metadata();
|
|
73
|
+
const providerEntity = await md.GetEntityObject('File Storage Providers', this.GetUserFromPayload(userPayload));
|
|
74
|
+
await providerEntity.Load(file.ProviderID);
|
|
75
|
+
const url = await (0, storage_1.createDownloadUrl)(providerEntity, file.ProviderKey ?? file.ID);
|
|
76
|
+
return url;
|
|
77
|
+
}
|
|
78
|
+
async DeleteFile(ID, { dataSource, userPayload }, pubSub) {
|
|
79
|
+
const md = new core_1.Metadata();
|
|
80
|
+
const userInfo = this.GetUserFromPayload(userPayload);
|
|
81
|
+
const fileEntity = await md.GetEntityObject('Files', userInfo);
|
|
82
|
+
await fileEntity.Load(ID);
|
|
83
|
+
if (!fileEntity) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (fileEntity.Status === 'Uploaded') {
|
|
87
|
+
const providerEntity = await md.GetEntityObject('File Storage Providers', userInfo);
|
|
88
|
+
await providerEntity.Load(fileEntity.ProviderID);
|
|
89
|
+
await (0, storage_1.deleteObject)(providerEntity, fileEntity.ProviderKey ?? fileEntity.ID);
|
|
90
|
+
}
|
|
91
|
+
return super.DeleteFile(ID, { dataSource, userPayload }, pubSub);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.FileResolver = FileResolver;
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, server_1.Mutation)(() => CreateFilePayload),
|
|
97
|
+
__param(0, (0, server_1.Arg)('input', () => generated_1.CreateFileInput)),
|
|
98
|
+
__param(1, (0, server_1.Ctx)()),
|
|
99
|
+
__param(2, (0, server_1.PubSub)()),
|
|
100
|
+
__metadata("design:type", Function),
|
|
101
|
+
__metadata("design:paramtypes", [generated_1.CreateFileInput, Object, server_1.PubSubEngine]),
|
|
102
|
+
__metadata("design:returntype", Promise)
|
|
103
|
+
], FileResolver.prototype, "CreateFile", null);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, server_1.FieldResolver)(() => String),
|
|
106
|
+
__param(0, (0, server_1.Root)()),
|
|
107
|
+
__param(1, (0, server_1.Ctx)()),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [generated_1.File_, Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], FileResolver.prototype, "DownloadUrl", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, server_1.Mutation)(() => generated_1.File_),
|
|
114
|
+
__param(0, (0, server_1.Arg)('ID', () => server_1.Int)),
|
|
115
|
+
__param(1, (0, server_1.Ctx)()),
|
|
116
|
+
__param(2, (0, server_1.PubSub)()),
|
|
117
|
+
__metadata("design:type", Function),
|
|
118
|
+
__metadata("design:paramtypes", [Number, Object, server_1.PubSubEngine]),
|
|
119
|
+
__metadata("design:returntype", Promise)
|
|
120
|
+
], FileResolver.prototype, "DeleteFile", null);
|
|
121
|
+
exports.FileResolver = FileResolver = __decorate([
|
|
122
|
+
(0, server_1.Resolver)(generated_1.File_)
|
|
123
|
+
], FileResolver);
|
|
124
|
+
//# sourceMappingURL=FileResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileResolver.js","sourceRoot":"","sources":["../../src/resolvers/FileResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAEhD,mDAcgC;AAChC,qDAA2F;AAC3F,sDAAkG;AAG3F,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAGhC,CAAA;AAHY,oDAAoB;AAE/B;IADC,IAAA,cAAK,EAAC,GAAG,EAAE,CAAC,YAAG,CAAC;;oDACF;+BAFJ,oBAAoB;IADhC,IAAA,kBAAS,GAAE;GACC,oBAAoB,CAGhC;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAK7B,CAAA;AALY,8CAAiB;AAE5B;IADC,IAAA,cAAK,EAAC,GAAG,EAAE,CAAC,iBAAK,CAAC;8BACb,iBAAK;+CAAC;AAEZ;IADC,IAAA,cAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;oDACF;4BAJP,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAK7B;AAGM,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,iBAAK;CAGjC,CAAA;AAHY,0BAAO;AAElB;IADC,IAAA,cAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;4CACA;kBAFT,OAAO;IADnB,IAAA,mBAAU,GAAE;GACA,OAAO,CAGnB;AAGM,IAAM,YAA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
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
2
|
+
"name": "@memberjunction/server",
|
|
3
|
+
"version": "0.9.243",
|
|
4
|
+
"description": "MemberJunction: This project provides API access via GraphQL to the common data store.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"author": "MemberJunction.com",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf dist",
|
|
11
|
+
"build": "rimraf dist && tsc",
|
|
12
|
+
"watch": "tsc -w",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
+
"lint:eslint": "eslint \"**/*.{ts,js,}\" --max-warnings=0",
|
|
15
|
+
"lint:tsc": "tsc --noemit",
|
|
16
|
+
"lint": "concurrently \"npm:lint:eslint\" \"npm:lint:tsc\"",
|
|
17
|
+
"pretty": "prettier --write \"**/*.{ts,js,}\"",
|
|
18
|
+
"codegen": "cpy --flat ../codegen/output/entities/*.ts src/entities",
|
|
19
|
+
"postcodegen": "npm run pretty"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@apollo/server": "^4.9.1",
|
|
23
|
+
"@graphql-tools/utils": "^10.0.1",
|
|
24
|
+
"@memberjunction/ai": "^0.9.163",
|
|
25
|
+
"@memberjunction/aiengine": "^0.9.64",
|
|
26
|
+
"@memberjunction/core": "^0.9.177",
|
|
27
|
+
"@memberjunction/core-entities": "^0.9.163",
|
|
28
|
+
"@memberjunction/data-context": "^0.9.50",
|
|
29
|
+
"@memberjunction/data-context-server": "^0.9.46",
|
|
30
|
+
"@memberjunction/global": "^0.9.156",
|
|
31
|
+
"@memberjunction/storage": "^0.9.8",
|
|
32
|
+
"@memberjunction/queue": "^0.9.185",
|
|
33
|
+
"@memberjunction/sqlserver-dataprovider": "^0.9.200",
|
|
34
|
+
"@memberjunction/skip-types": "^0.9.75",
|
|
35
|
+
"@types/cors": "^2.8.13",
|
|
36
|
+
"@types/jsonwebtoken": "^8.5.9",
|
|
37
|
+
"@types/node": "^18.11.14",
|
|
38
|
+
"@types/ws": "^8.5.5",
|
|
39
|
+
"axios": "^1.4.0",
|
|
40
|
+
"body-parser": "^1.20.2",
|
|
41
|
+
"class-validator": "^0.14.0",
|
|
42
|
+
"cors": "^2.8.5",
|
|
43
|
+
"dotenv": "^16.0.3",
|
|
44
|
+
"env-var": "^7.3.0",
|
|
45
|
+
"express": "^4.18.2",
|
|
46
|
+
"fast-glob": "^3.3.1",
|
|
47
|
+
"graphql": "^16.8.0",
|
|
48
|
+
"graphql-ws": "^5.14.0",
|
|
49
|
+
"jsonwebtoken": "^8.5.1",
|
|
50
|
+
"jwks-rsa": "^3.0.0",
|
|
51
|
+
"lru-cache": "^10.0.0",
|
|
52
|
+
"mssql": "^10.0.2",
|
|
53
|
+
"reflect-metadata": "^0.1.13",
|
|
54
|
+
"rxjs": "^7.8.1",
|
|
55
|
+
"type-graphql": "2.0.0-beta.3",
|
|
56
|
+
"typedi": "^0.10.0",
|
|
57
|
+
"typeorm": "^0.3.20",
|
|
58
|
+
"ws": "^8.13.0",
|
|
59
|
+
"zod": "^3.22.4"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
63
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
64
|
+
"concurrently": "^7.6.0",
|
|
65
|
+
"cpy-cli": "^4.2.0",
|
|
66
|
+
"eslint": "^8.29.0",
|
|
67
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
68
|
+
"eslint-config-prettier": "^8.5.0",
|
|
69
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
|
70
|
+
"eslint-plugin-import": "^2.26.0",
|
|
71
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
72
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
73
|
+
"prettier": "^2.8.1",
|
|
74
|
+
"rimraf": "^4.4.0",
|
|
75
|
+
"ts-node": "^10.9.1",
|
|
76
|
+
"ts-node-dev": "^2.0.0",
|
|
77
|
+
"typescript": "^5.3.3"
|
|
78
|
+
}
|
|
78
79
|
}
|
package/src/context.ts
CHANGED
|
@@ -110,7 +110,10 @@ export const contextFunction =
|
|
|
110
110
|
const userPayload = await getUserPayload(bearerToken, sessionId, dataSource, requestDomain?.hostname ? requestDomain.hostname : undefined);
|
|
111
111
|
|
|
112
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
-
|
|
113
|
+
const operationName: string| undefined = (req as any).body?.operationName;
|
|
114
|
+
if (operationName !== 'IntrospectionQuery') {
|
|
115
|
+
console.log({ operationName });
|
|
116
|
+
}
|
|
114
117
|
|
|
115
118
|
return { dataSource, userPayload };
|
|
116
119
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ALL ENTITIES - TypeGraphQL Type Class Definition - AUTO GENERATED FILE
|
|
3
3
|
* Generated Entities and Resolvers for Server
|
|
4
4
|
*
|
|
5
|
-
* GENERATED: 3/
|
|
5
|
+
* GENERATED: 3/22/2024, 1:17:14 PM
|
|
6
6
|
*
|
|
7
7
|
* >>> DO NOT MODIFY THIS FILE!!!!!!!!!!!!
|
|
8
8
|
* >>> YOUR CHANGES WILL BE OVERWRITTEN
|
|
@@ -4012,6 +4012,9 @@ export class EntityRelationship_ {
|
|
|
4012
4012
|
@Field(() => Int)
|
|
4013
4013
|
EntityID: number;
|
|
4014
4014
|
|
|
4015
|
+
@Field(() => Int, {description: 'Used for display order in generated forms and in other places in the UI where relationships for an entity are shown'})
|
|
4016
|
+
Sequence: number;
|
|
4017
|
+
|
|
4015
4018
|
@Field(() => Int)
|
|
4016
4019
|
RelatedEntityID: number;
|
|
4017
4020
|
|
|
@@ -4117,6 +4120,9 @@ export class CreateEntityRelationshipInput {
|
|
|
4117
4120
|
@Field(() => Int)
|
|
4118
4121
|
EntityID: number;
|
|
4119
4122
|
|
|
4123
|
+
@Field(() => Int)
|
|
4124
|
+
Sequence: number;
|
|
4125
|
+
|
|
4120
4126
|
@Field(() => Int)
|
|
4121
4127
|
RelatedEntityID: number;
|
|
4122
4128
|
|
|
@@ -4163,6 +4169,9 @@ export class UpdateEntityRelationshipInput {
|
|
|
4163
4169
|
@Field(() => Int)
|
|
4164
4170
|
EntityID: number;
|
|
4165
4171
|
|
|
4172
|
+
@Field(() => Int)
|
|
4173
|
+
Sequence: number;
|
|
4174
|
+
|
|
4166
4175
|
@Field(() => Int)
|
|
4167
4176
|
RelatedEntityID: number;
|
|
4168
4177
|
|
|
@@ -16714,6 +16723,9 @@ export class UserViewCategory_ {
|
|
|
16714
16723
|
@MaxLength(8)
|
|
16715
16724
|
UpdatedAt: Date;
|
|
16716
16725
|
|
|
16726
|
+
@Field(() => Int)
|
|
16727
|
+
EntityID: number;
|
|
16728
|
+
|
|
16717
16729
|
@Field({nullable: true})
|
|
16718
16730
|
@MaxLength(200)
|
|
16719
16731
|
Parent?: string;
|
|
@@ -16739,6 +16751,9 @@ export class CreateUserViewCategoryInput {
|
|
|
16739
16751
|
|
|
16740
16752
|
@Field(() => Int, { nullable: true })
|
|
16741
16753
|
ParentID: number;
|
|
16754
|
+
|
|
16755
|
+
@Field(() => Int)
|
|
16756
|
+
EntityID: number;
|
|
16742
16757
|
}
|
|
16743
16758
|
|
|
16744
16759
|
|
|
@@ -16758,6 +16773,9 @@ export class UpdateUserViewCategoryInput {
|
|
|
16758
16773
|
|
|
16759
16774
|
@Field(() => Int, { nullable: true })
|
|
16760
16775
|
ParentID: number;
|
|
16776
|
+
|
|
16777
|
+
@Field(() => Int)
|
|
16778
|
+
EntityID: number;
|
|
16761
16779
|
}
|
|
16762
16780
|
|
|
16763
16781
|
//****************************************************************************
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Metadata } from '@memberjunction/core';
|
|
2
|
+
import { FileEntity, FileStorageProviderEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import {
|
|
4
|
+
AppContext,
|
|
5
|
+
Arg,
|
|
6
|
+
Ctx,
|
|
7
|
+
Field,
|
|
8
|
+
FieldResolver,
|
|
9
|
+
InputType,
|
|
10
|
+
Int,
|
|
11
|
+
Mutation,
|
|
12
|
+
ObjectType,
|
|
13
|
+
PubSub,
|
|
14
|
+
PubSubEngine,
|
|
15
|
+
Resolver,
|
|
16
|
+
Root,
|
|
17
|
+
} from '@memberjunction/server';
|
|
18
|
+
import { createDownloadUrl, createUploadUrl, deleteObject } from '@memberjunction/storage';
|
|
19
|
+
import { CreateFileInput, FileResolver as FileResolverBase, File_ } from '../generated/generated';
|
|
20
|
+
|
|
21
|
+
@InputType()
|
|
22
|
+
export class CreateUploadURLInput {
|
|
23
|
+
@Field(() => Int)
|
|
24
|
+
FileID: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ObjectType()
|
|
28
|
+
export class CreateFilePayload {
|
|
29
|
+
@Field(() => File_)
|
|
30
|
+
File: File_;
|
|
31
|
+
@Field(() => String)
|
|
32
|
+
UploadUrl: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ObjectType()
|
|
36
|
+
export class FileExt extends File_ {
|
|
37
|
+
@Field(() => String)
|
|
38
|
+
DownloadUrl: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Resolver(File_)
|
|
42
|
+
export class FileResolver extends FileResolverBase {
|
|
43
|
+
@Mutation(() => CreateFilePayload)
|
|
44
|
+
async CreateFile(
|
|
45
|
+
@Arg('input', () => CreateFileInput) input: CreateFileInput,
|
|
46
|
+
@Ctx() { dataSource, userPayload }: AppContext,
|
|
47
|
+
@PubSub() pubSub: PubSubEngine
|
|
48
|
+
) {
|
|
49
|
+
const md = new Metadata();
|
|
50
|
+
const userInfo = this.GetUserFromPayload(userPayload);
|
|
51
|
+
const providerEntity = await md.GetEntityObject<FileStorageProviderEntity>('File Storage Providers', userInfo);
|
|
52
|
+
|
|
53
|
+
const fileRecord = (await super.CreateFile({ ...input, Status: 'Pending' }, { dataSource, userPayload }, pubSub)) as File_;
|
|
54
|
+
|
|
55
|
+
// If there's a problem creating the file record, the base resolver will return null
|
|
56
|
+
if (!fileRecord) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Create the upload URL and get the record updates (provider key, content type, etc)
|
|
61
|
+
const { updatedInput, UploadUrl } = await createUploadUrl(providerEntity, fileRecord);
|
|
62
|
+
|
|
63
|
+
// Save the file record with the updated input
|
|
64
|
+
const fileEntity = <FileEntity>await new Metadata().GetEntityObject('Files', userInfo);
|
|
65
|
+
fileEntity.LoadFromData(input);
|
|
66
|
+
fileEntity.SetMany(updatedInput);
|
|
67
|
+
await fileEntity.Save();
|
|
68
|
+
const File = fileEntity.GetAll();
|
|
69
|
+
|
|
70
|
+
return { File, UploadUrl };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@FieldResolver(() => String)
|
|
74
|
+
async DownloadUrl(@Root() file: File_, @Ctx() { userPayload }: AppContext) {
|
|
75
|
+
const md = new Metadata();
|
|
76
|
+
const providerEntity = await md.GetEntityObject<FileStorageProviderEntity>(
|
|
77
|
+
'File Storage Providers',
|
|
78
|
+
this.GetUserFromPayload(userPayload)
|
|
79
|
+
);
|
|
80
|
+
await providerEntity.Load(file.ProviderID);
|
|
81
|
+
|
|
82
|
+
const url = await createDownloadUrl(providerEntity, file.ProviderKey ?? file.ID);
|
|
83
|
+
|
|
84
|
+
return url;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Mutation(() => File_)
|
|
88
|
+
async DeleteFile(@Arg('ID', () => Int) ID: number, @Ctx() { dataSource, userPayload }: AppContext, @PubSub() pubSub: PubSubEngine) {
|
|
89
|
+
const md = new Metadata();
|
|
90
|
+
const userInfo = this.GetUserFromPayload(userPayload);
|
|
91
|
+
|
|
92
|
+
const fileEntity = <FileEntity>await md.GetEntityObject('Files', userInfo);
|
|
93
|
+
await fileEntity.Load(ID);
|
|
94
|
+
if (!fileEntity) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (fileEntity.Status === 'Uploaded') {
|
|
99
|
+
const providerEntity = await md.GetEntityObject<FileStorageProviderEntity>('File Storage Providers', userInfo);
|
|
100
|
+
await providerEntity.Load(fileEntity.ProviderID);
|
|
101
|
+
await deleteObject(providerEntity, fileEntity.ProviderKey ?? fileEntity.ID);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return super.DeleteFile(ID, { dataSource, userPayload }, pubSub);
|
|
105
|
+
}
|
|
106
|
+
}
|