@trailmix-cms/cms 0.0.2 → 0.0.4
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/dist/auth.guard.d.ts +3 -1
- package/dist/auth.guard.d.ts.map +1 -1
- package/dist/auth.guard.js +14 -10
- package/dist/auth.guard.js.map +1 -1
- package/dist/cms.providers.d.ts +2 -1
- package/dist/cms.providers.d.ts.map +1 -1
- package/dist/cms.providers.js +4 -0
- package/dist/cms.providers.js.map +1 -1
- package/dist/services/account.service.d.ts +33 -0
- package/dist/services/account.service.d.ts.map +1 -0
- package/dist/services/account.service.js +92 -0
- package/dist/services/account.service.js.map +1 -0
- package/package.json +7 -7
- package/dist/controllers/file.controller.d.ts +0 -2
- package/dist/controllers/file.controller.d.ts.map +0 -1
- package/dist/controllers/file.controller.js +0 -80
- package/dist/controllers/file.controller.js.map +0 -1
- package/dist/controllers/text.controller.d.ts +0 -2
- package/dist/controllers/text.controller.d.ts.map +0 -1
- package/dist/controllers/text.controller.js +0 -48
- package/dist/controllers/text.controller.js.map +0 -1
package/dist/auth.guard.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Account } from '@trailmix-cms/models';
|
|
|
4
4
|
import { AccountCollection } from './collections';
|
|
5
5
|
import { ConfigService } from '@nestjs/config';
|
|
6
6
|
import { AppConfig } from './config';
|
|
7
|
+
import { AccountService } from './services/account.service';
|
|
7
8
|
declare module 'fastify' {
|
|
8
9
|
interface FastifyRequest {
|
|
9
10
|
account?: Account.Entity;
|
|
@@ -12,10 +13,11 @@ declare module 'fastify' {
|
|
|
12
13
|
export declare class AuthGuard implements CanActivate {
|
|
13
14
|
private reflector;
|
|
14
15
|
private accountCollection;
|
|
16
|
+
private accountService;
|
|
15
17
|
private configService;
|
|
16
18
|
private readonly logger;
|
|
17
19
|
private readonly clerkClient;
|
|
18
|
-
constructor(reflector: Reflector, accountCollection: AccountCollection, configService: ConfigService<AppConfig>);
|
|
20
|
+
constructor(reflector: Reflector, accountCollection: AccountCollection, accountService: AccountService, configService: ConfigService<AppConfig>);
|
|
19
21
|
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
20
22
|
private getAccount;
|
|
21
23
|
}
|
package/dist/auth.guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAc,WAAW,EAAE,gBAAgB,EAAmF,MAAM,gBAAgB,CAAC;AAG5J,OAAO,EAAE,OAAO,EAAQ,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAc,WAAW,EAAE,gBAAgB,EAAmF,MAAM,gBAAgB,CAAC;AAG5J,OAAO,EAAE,OAAO,EAAQ,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,QAAQ,SAAS,CAAC;IACrB,UAAU,cAAc;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAA;KAC3B;CACJ;AAED,qBACa,SAAU,YAAW,WAAW;IAKrC,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,aAAa;IAPzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAG9B,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC;IAO7C,WAAW,CACb,OAAO,EAAE,gBAAgB,GAC1B,OAAO,CAAC,OAAO,CAAC;YA2CL,UAAU;CAwC3B"}
|
package/dist/auth.guard.js
CHANGED
|
@@ -18,15 +18,18 @@ const models_1 = require("@trailmix-cms/models");
|
|
|
18
18
|
const collections_1 = require("./collections");
|
|
19
19
|
const config_1 = require("@nestjs/config");
|
|
20
20
|
const auth_decorator_1 = require("./decorators/auth.decorator");
|
|
21
|
+
const account_service_1 = require("./services/account.service");
|
|
21
22
|
let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
22
23
|
reflector;
|
|
23
24
|
accountCollection;
|
|
25
|
+
accountService;
|
|
24
26
|
configService;
|
|
25
27
|
logger = new common_1.Logger(AuthGuard_1.name);
|
|
26
28
|
clerkClient;
|
|
27
|
-
constructor(reflector, accountCollection, configService) {
|
|
29
|
+
constructor(reflector, accountCollection, accountService, configService) {
|
|
28
30
|
this.reflector = reflector;
|
|
29
31
|
this.accountCollection = accountCollection;
|
|
32
|
+
this.accountService = accountService;
|
|
30
33
|
this.configService = configService;
|
|
31
34
|
this.clerkClient = (0, fastify_1.createClerkClient)({
|
|
32
35
|
secretKey: this.configService.get('CLERK_SECRET_KEY'),
|
|
@@ -71,6 +74,7 @@ let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
|
71
74
|
if (!auth.userId) {
|
|
72
75
|
return {};
|
|
73
76
|
}
|
|
77
|
+
// TODO: Cache user
|
|
74
78
|
// const cachedUser = await this.userCache.getUser(auth.userId);
|
|
75
79
|
// if (cachedUser) {
|
|
76
80
|
// return {
|
|
@@ -79,15 +83,14 @@ let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
|
79
83
|
// };
|
|
80
84
|
// }
|
|
81
85
|
const user = await this.clerkClient.users.getUser(auth.userId);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
86
|
+
const accountExists = await this.accountService.getAccount(auth.userId);
|
|
87
|
+
if (accountExists) {
|
|
88
|
+
return {
|
|
89
|
+
account: accountExists,
|
|
90
|
+
userPublicMetadata: user.publicMetadata,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const account = await this.accountService.upsertAccount(auth.userId);
|
|
91
94
|
// TODO: Cache user
|
|
92
95
|
// await this.userCache.cacheUser(auth.userId, {
|
|
93
96
|
// account: account!,
|
|
@@ -104,6 +107,7 @@ exports.AuthGuard = AuthGuard = AuthGuard_1 = __decorate([
|
|
|
104
107
|
(0, common_1.Injectable)(),
|
|
105
108
|
__metadata("design:paramtypes", [core_1.Reflector,
|
|
106
109
|
collections_1.AccountCollection,
|
|
110
|
+
account_service_1.AccountService,
|
|
107
111
|
config_1.ConfigService])
|
|
108
112
|
], AuthGuard);
|
|
109
113
|
//# sourceMappingURL=auth.guard.js.map
|
package/dist/auth.guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAAyC;AACzC,2CAA4J;AAE5J,4CAAyE;AACzE,iDAAqD;AACrD,+CAAkD;AAClD,2CAA+C;AAG/C,gEAA6E;
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAAyC;AACzC,2CAA4J;AAE5J,4CAAyE;AACzE,iDAAqD;AACrD,+CAAkD;AAClD,2CAA+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;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErE,mBAAmB;QACnB,gDAAgD;QAChD,yBAAyB;QACzB,qCAAqC;QACrC,MAAM;QAEN,OAAO;YACH,OAAO;YACP,kBAAkB,EAAE,IAAI,CAAC,cAAc;SAC1C,CAAC;IACN,CAAC;CACJ,CAAA;AApGY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAMc,gBAAS;QACD,+BAAiB;QACpB,gCAAc;QACf,sBAAa;GAR/B,SAAS,CAoGrB"}
|
package/dist/cms.providers.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as models from '@trailmix-cms/models';
|
|
|
4
4
|
import { CollectionConfig } from './types/collection-config';
|
|
5
5
|
import { Collection } from 'mongodb';
|
|
6
6
|
import { AccountCollection, FileCollection, TextCollection } from './collections';
|
|
7
|
+
import { AccountService } from './services/account.service';
|
|
7
8
|
export declare function configureCollections(options?: {
|
|
8
9
|
features?: {
|
|
9
10
|
file?: boolean;
|
|
@@ -32,7 +33,7 @@ export declare function createCmsProviders<AccountEntity extends models.Account.
|
|
|
32
33
|
file?: boolean;
|
|
33
34
|
text?: boolean;
|
|
34
35
|
};
|
|
35
|
-
}): (typeof AccountCollection | typeof FileCollection | typeof TextCollection | {
|
|
36
|
+
}): (typeof AccountCollection | typeof FileCollection | typeof TextCollection | typeof AccountService | {
|
|
36
37
|
provide: string;
|
|
37
38
|
useFactory: (databaseService: import("@trailmix-cms/db").DatabaseService) => Promise<Collection<import("bson").Document>>;
|
|
38
39
|
inject: (typeof import("@trailmix-cms/db").DatabaseService)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.providers.d.ts","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,M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OAAO,CAAC,IAAI,CAAC;;;;KA2ExE"}
|
package/dist/cms.providers.js
CHANGED
|
@@ -40,6 +40,7 @@ const constants_1 = require("./constants");
|
|
|
40
40
|
const constants_2 = require("./constants");
|
|
41
41
|
const db_1 = require("@trailmix-cms/db");
|
|
42
42
|
const collections_1 = require("./collections");
|
|
43
|
+
const account_service_1 = require("./services/account.service");
|
|
43
44
|
function configureCollections(options) {
|
|
44
45
|
return {
|
|
45
46
|
collectionNames: [
|
|
@@ -64,6 +65,9 @@ function createCmsProviders(options) {
|
|
|
64
65
|
disableDefaultIndexes: false
|
|
65
66
|
};
|
|
66
67
|
return [
|
|
68
|
+
// Services
|
|
69
|
+
account_service_1.AccountService,
|
|
70
|
+
// Collections
|
|
67
71
|
...mongodbCollectionProviders,
|
|
68
72
|
// Account
|
|
69
73
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms.providers.js","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"cms.providers.js","sourceRoot":"","sources":["../src/cms.providers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,oDAkBC;AAED,gDA4FC;AA1HD,6DAA+C;AAC/C,2CAA+C;AAC/C,2CAAgD;AAChD,yCAAqD;AAIrD,+CAAkF;AAClF,gEAA4D;AAE5D,SAAgB,oBAAoB,CAAC,OAKpC;IACG,OAAO;QACH,eAAe,EAAE;YACb,6BAAiB,CAAC,OAAO;YACzB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,6BAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAA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AE,OAAO,EAAE,QAAQ,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE,UAAkC,EAAE,EAAE,GAAG,CAAC,CAAC;aAChG;YACD;gBACI,OAAO,EAAE,4BAAgB,CAAC,2BAA2B;gBACrD,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,IAAI,uBAAuB;aACrE;SACJ,CAAC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW;KAC/C,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AccountCollection } from '../collections';
|
|
2
|
+
export declare class AccountService {
|
|
3
|
+
private accountCollection;
|
|
4
|
+
private readonly logger;
|
|
5
|
+
constructor(accountCollection: AccountCollection);
|
|
6
|
+
/**
|
|
7
|
+
* Get account by userId
|
|
8
|
+
*
|
|
9
|
+
* @param userId
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
getAccount(userId: string): Promise<import("mongodb").WithId<{
|
|
13
|
+
_id: import("bson").ObjectId;
|
|
14
|
+
created_at: Date;
|
|
15
|
+
user_id: string;
|
|
16
|
+
roles: string[];
|
|
17
|
+
updated_at?: Date | undefined;
|
|
18
|
+
}> | null>;
|
|
19
|
+
/**
|
|
20
|
+
* If account does not exist, create it, upsert is safe for race conditions
|
|
21
|
+
*
|
|
22
|
+
* @param userId
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
upsertAccount(userId: string): Promise<import("mongodb").WithId<{
|
|
26
|
+
_id: import("bson").ObjectId;
|
|
27
|
+
created_at: Date;
|
|
28
|
+
user_id: string;
|
|
29
|
+
roles: string[];
|
|
30
|
+
updated_at?: Date | undefined;
|
|
31
|
+
}>>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=account.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.service.d.ts","sourceRoot":"","sources":["../../src/services/account.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,qBACa,cAAc;IAInB,OAAO,CAAC,iBAAiB;IAH7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;gBAG9C,iBAAiB,EAAE,iBAAiB;IAGhD;;;;;OAKG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM;;;;;;;IAI/B;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM;;;;;;;CAerC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var AccountService_1;
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.AccountService = void 0;
|
|
47
|
+
const common_1 = require("@nestjs/common");
|
|
48
|
+
const models = __importStar(require("@trailmix-cms/models"));
|
|
49
|
+
const collections_1 = require("../collections");
|
|
50
|
+
let AccountService = AccountService_1 = class AccountService {
|
|
51
|
+
accountCollection;
|
|
52
|
+
logger = new common_1.Logger(AccountService_1.name);
|
|
53
|
+
constructor(accountCollection) {
|
|
54
|
+
this.accountCollection = accountCollection;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get account by userId
|
|
58
|
+
*
|
|
59
|
+
* @param userId
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
async getAccount(userId) {
|
|
63
|
+
return await this.accountCollection.findOne({ user_id: userId });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* If account does not exist, create it, upsert is safe for race conditions
|
|
67
|
+
*
|
|
68
|
+
* @param userId
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
async upsertAccount(userId) {
|
|
72
|
+
const account = await this.accountCollection.upsertOne({ user_id: userId }, {
|
|
73
|
+
$set: {
|
|
74
|
+
user_id: userId,
|
|
75
|
+
},
|
|
76
|
+
$setOnInsert: {
|
|
77
|
+
roles: [models.Role.User],
|
|
78
|
+
},
|
|
79
|
+
}, {
|
|
80
|
+
system: true,
|
|
81
|
+
message: 'Account upserted',
|
|
82
|
+
source: AccountService_1.name,
|
|
83
|
+
});
|
|
84
|
+
return account;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.AccountService = AccountService;
|
|
88
|
+
exports.AccountService = AccountService = AccountService_1 = __decorate([
|
|
89
|
+
(0, common_1.Injectable)(),
|
|
90
|
+
__metadata("design:paramtypes", [collections_1.AccountCollection])
|
|
91
|
+
], AccountService);
|
|
92
|
+
//# sourceMappingURL=account.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.service.js","sourceRoot":"","sources":["../../src/services/account.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+G;AAC/G,6DAA+C;AAC/C,gDAAmD;AAG5C,IAAM,cAAc,sBAApB,MAAM,cAAc;IAIX;IAHK,MAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAE1D,YACY,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAC5C,CAAC;IAEL;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC3B,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,MAAc;QAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YACxE,IAAI,EAAE;gBACF,OAAO,EAAE,MAAM;aAClB;YACD,YAAY,EAAE;gBACV,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;aAC5B;SACJ,EAAE;YACC,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,kBAAkB;YAC3B,MAAM,EAAE,gBAAc,CAAC,IAAI;SAC9B,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ,CAAA;AAtCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAKsB,+BAAiB;GAJvC,cAAc,CAsC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trailmix-cms/cms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@nestjs/config": "^4.0.2",
|
|
16
16
|
"@nestjs/core": "^11.1.9",
|
|
17
17
|
"@nestjs/swagger": "^11.2.3",
|
|
18
|
-
"@trailmix-cms/db": "0.0.
|
|
19
|
-
"@trailmix-cms/models": "0.0.
|
|
20
|
-
"@trailmix-cms/utils": "0.0.
|
|
18
|
+
"@trailmix-cms/db": "0.0.4",
|
|
19
|
+
"@trailmix-cms/models": "0.0.4",
|
|
20
|
+
"@trailmix-cms/utils": "0.0.4",
|
|
21
21
|
"cache-manager": "^7.2.5",
|
|
22
22
|
"envalid": "^8.1.1",
|
|
23
23
|
"mongodb": "^7.0.0",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@clerk/fastify": "^2.6.8",
|
|
35
35
|
"@nestjs/common": "^11.1.9",
|
|
36
36
|
"@nestjs/config": "^4.0.2",
|
|
37
|
-
"@trailmix-cms/db": "0.0.
|
|
38
|
-
"@trailmix-cms/models": "0.0.
|
|
39
|
-
"@trailmix-cms/utils": "0.0.
|
|
37
|
+
"@trailmix-cms/db": "0.0.4",
|
|
38
|
+
"@trailmix-cms/models": "0.0.4",
|
|
39
|
+
"@trailmix-cms/utils": "0.0.4",
|
|
40
40
|
"mongodb": "^7.0.0",
|
|
41
41
|
"reflect-metadata": "^0.2.2",
|
|
42
42
|
"rxjs": "^7.8.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/file.controller.ts"],"names":[],"mappings":""}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller, Get, Res, Param, Query, BadRequestException } from '@nestjs/common';
|
|
3
|
-
// import { ApiOperation, ApiTags, ApiOkResponse, ApiParam, ApiExtraModels } from '@nestjs/swagger';
|
|
4
|
-
// import { FastifyReply } from 'fastify';
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// import * as models from '@trailmixcms/models';
|
|
7
|
-
// import { StorageService } from '@trailmixcms/storage';
|
|
8
|
-
// import { Collections } from '@trailmixcms/db';
|
|
9
|
-
// import { FileCollection } from '../collections/file.collection';
|
|
10
|
-
// import * as dto from '../dto/file';
|
|
11
|
-
// import { FileByIdPipe } from '../pipes/file.pipe';
|
|
12
|
-
// import { FileService } from '../services/file.service';
|
|
13
|
-
// import { Auth } from '../auth/auth.decorator';
|
|
14
|
-
// import { AccountAuthorization, AuthorizationService } from '../services/authorization.service';
|
|
15
|
-
// import { FileDto } from '../dto/file';
|
|
16
|
-
// @ApiExtraModels(FileDto)
|
|
17
|
-
// @Auth({ allowAnonymous: true })
|
|
18
|
-
// @ApiTags('file')
|
|
19
|
-
// @Controller('file')
|
|
20
|
-
// export class FileController {
|
|
21
|
-
// constructor(
|
|
22
|
-
// private readonly storageService: StorageService,
|
|
23
|
-
// private readonly fileService: FileService,
|
|
24
|
-
// private readonly fileCollection: FileCollection,
|
|
25
|
-
// private readonly authorizationService: AuthorizationService,
|
|
26
|
-
// ) { }
|
|
27
|
-
// @Get()
|
|
28
|
-
// @ApiOperation({ summary: 'Get all files' })
|
|
29
|
-
// @ApiOkResponse({ description: 'List of files.', type: dto.FileListResponseDto })
|
|
30
|
-
// async list(
|
|
31
|
-
// @Query() query: dto.FileListQueryDto,
|
|
32
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
33
|
-
// ): Promise<dto.FileListResponseDto> {
|
|
34
|
-
// if (!query.guid) {
|
|
35
|
-
// throw new BadRequestException('Guid is required');
|
|
36
|
-
// }
|
|
37
|
-
// const files = await this.fileCollection.find({
|
|
38
|
-
// guid: query.guid,
|
|
39
|
-
// });
|
|
40
|
-
// return {
|
|
41
|
-
// items: files
|
|
42
|
-
// .filter(entity => this.authorizationService.checkAccountAuthorizationOnEntity(accountAuthorization, entity))
|
|
43
|
-
// .map((file: models.File.Entity) => ({
|
|
44
|
-
// ...models.File.entityToDto(file),
|
|
45
|
-
// cdn_url: this.fileService.getCDNUrl(file),
|
|
46
|
-
// direct_url: `/file/${file._id}/download`
|
|
47
|
-
// }))
|
|
48
|
-
// };
|
|
49
|
-
// }
|
|
50
|
-
// @Get(':id')
|
|
51
|
-
// @ApiParam({ name: 'id', type: String })
|
|
52
|
-
// @ApiOperation({ summary: 'Get file by id' })
|
|
53
|
-
// @ApiOkResponse({ description: 'File.', type: dto.FileResponseDto })
|
|
54
|
-
// async get(
|
|
55
|
-
// @Param('id', FileByIdPipe) entity: models.File.Entity,
|
|
56
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
57
|
-
// ): Promise<dto.FileResponseDto> {
|
|
58
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
59
|
-
// return {
|
|
60
|
-
// ...models.File.entityToDto(entity),
|
|
61
|
-
// cdn_url: this.fileService.getCDNUrl(entity),
|
|
62
|
-
// direct_url: `/file/${entity._id}/download`
|
|
63
|
-
// };
|
|
64
|
-
// }
|
|
65
|
-
// @Get(':id/download')
|
|
66
|
-
// @ApiParam({ name: 'id', type: String })
|
|
67
|
-
// @ApiOperation({ summary: 'Get file contents by id' })
|
|
68
|
-
// async getRaw(
|
|
69
|
-
// @Param('id', FileByIdPipe) entity: models.File.Entity,
|
|
70
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
71
|
-
// @Res() reply: FastifyReply,
|
|
72
|
-
// ) {
|
|
73
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
74
|
-
// reply.header('Content-Type', `application/${entity.file_extension}`);
|
|
75
|
-
// reply.header('Content-disposition', `attachment; filename=${entity.file_name}`);
|
|
76
|
-
// const fileStream = await this.fileService.downloadFile(entity);
|
|
77
|
-
// reply.send(fileStream);
|
|
78
|
-
// }
|
|
79
|
-
// }
|
|
80
|
-
//# sourceMappingURL=file.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.controller.js","sourceRoot":"","sources":["../../src/controllers/file.controller.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,oGAAoG;AACpG,0CAA0C;;AAE1C,iDAAiD;AACjD,yDAAyD;AACzD,iDAAiD;AACjD,mEAAmE;AAEnE,sCAAsC;AACtC,qDAAqD;AACrD,0DAA0D;AAC1D,iDAAiD;AACjD,kGAAkG;AAClG,yCAAyC;AAEzC,2BAA2B;AAC3B,kCAAkC;AAClC,mBAAmB;AACnB,sBAAsB;AACtB,gCAAgC;AAChC,mBAAmB;AACnB,2DAA2D;AAC3D,qDAAqD;AACrD,2DAA2D;AAC3D,uEAAuE;AACvE,YAAY;AAEZ,aAAa;AACb,kDAAkD;AAClD,uFAAuF;AACvF,kBAAkB;AAClB,gDAAgD;AAChD,8EAA8E;AAC9E,4CAA4C;AAC5C,6BAA6B;AAC7B,iEAAiE;AACjE,YAAY;AAEZ,yDAAyD;AACzD,gCAAgC;AAChC,cAAc;AAEd,mBAAmB;AACnB,2BAA2B;AAC3B,+HAA+H;AAC/H,wDAAwD;AACxD,wDAAwD;AACxD,iEAAiE;AACjE,+DAA+D;AAC/D,sBAAsB;AACtB,aAAa;AACb,QAAQ;AAER,kBAAkB;AAClB,8CAA8C;AAC9C,mDAAmD;AACnD,0EAA0E;AAC1E,iBAAiB;AACjB,iEAAiE;AACjE,8EAA8E;AAC9E,wCAAwC;AACxC,+FAA+F;AAE/F,mBAAmB;AACnB,kDAAkD;AAClD,2DAA2D;AAC3D,yDAAyD;AACzD,aAAa;AACb,QAAQ;AAER,2BAA2B;AAC3B,8CAA8C;AAC9C,4DAA4D;AAC5D,oBAAoB;AACpB,iEAAiE;AACjE,8EAA8E;AAC9E,sCAAsC;AACtC,UAAU;AACV,+FAA+F;AAE/F,gFAAgF;AAChF,2FAA2F;AAE3F,0EAA0E;AAC1E,kCAAkC;AAClC,QAAQ;AACR,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/text.controller.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { Controller, Get, Param, Query, BadRequestException, NotFoundException } from '@nestjs/common';
|
|
3
|
-
// import { ApiOperation, ApiTags, ApiOkResponse, ApiParam } from '@nestjs/swagger';
|
|
4
|
-
// import { Collections } from '@trailmixcms/db';
|
|
5
|
-
// import * as models from '@trailmixcms/models';
|
|
6
|
-
// import * as dto from '../dto/text';
|
|
7
|
-
// import { TextPipe } from '../pipes/text.pipe';
|
|
8
|
-
// import { Auth } from '../auth/auth.decorator';
|
|
9
|
-
// import { AccountAuthorization, AuthorizationService } from '../services/authorization.service';
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
// @Auth({ allowAnonymous: true })
|
|
12
|
-
// @ApiTags('text')
|
|
13
|
-
// @Controller('text')
|
|
14
|
-
// export class TextController {
|
|
15
|
-
// constructor(
|
|
16
|
-
// private readonly textCollection: Collections.TextCollection,
|
|
17
|
-
// private readonly authorizationService: AuthorizationService,
|
|
18
|
-
// ) { }
|
|
19
|
-
// @Get()
|
|
20
|
-
// @ApiOperation({ summary: 'Search texts by guid' })
|
|
21
|
-
// @ApiOkResponse({ description: 'Texts.', type: dto.TextListResponseDto })
|
|
22
|
-
// async list(
|
|
23
|
-
// @Query() query: dto.TextListQueryDto,
|
|
24
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
25
|
-
// ) {
|
|
26
|
-
// if (!query.guid) {
|
|
27
|
-
// throw new BadRequestException('Guid is required');
|
|
28
|
-
// }
|
|
29
|
-
// const texts = await this.textCollection.find({ guid: query.guid });
|
|
30
|
-
// return {
|
|
31
|
-
// items: texts
|
|
32
|
-
// .filter(entity => this.authorizationService.checkAccountAuthorizationOnEntity(accountAuthorization, entity))
|
|
33
|
-
// .map((entity: models.Text.Entity) => models.Text.entityToDto(entity))
|
|
34
|
-
// };
|
|
35
|
-
// }
|
|
36
|
-
// @Get(':id')
|
|
37
|
-
// @ApiParam({ name: 'id', type: String })
|
|
38
|
-
// @ApiOperation({ summary: 'Get text by id' })
|
|
39
|
-
// @ApiOkResponse({ description: 'Text details.', type: dto.TextDto })
|
|
40
|
-
// async get(
|
|
41
|
-
// @Param('id', TextPipe) entity: models.Text.Entity,
|
|
42
|
-
// @AccountAuthorization() accountAuthorization: AccountAuthorization,
|
|
43
|
-
// ) {
|
|
44
|
-
// await this.authorizationService.validateAuthorization(accountAuthorization, entity);
|
|
45
|
-
// return models.Text.entityToDto(entity);
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
//# sourceMappingURL=text.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.controller.js","sourceRoot":"","sources":["../../src/controllers/text.controller.ts"],"names":[],"mappings":";AAAA,0GAA0G;AAC1G,oFAAoF;AACpF,iDAAiD;AACjD,iDAAiD;AACjD,sCAAsC;AACtC,iDAAiD;AACjD,iDAAiD;AACjD,kGAAkG;;AAElG,kCAAkC;AAClC,mBAAmB;AACnB,sBAAsB;AACtB,gCAAgC;AAChC,mBAAmB;AACnB,uEAAuE;AACvE,uEAAuE;AACvE,YAAY;AAEZ,aAAa;AACb,yDAAyD;AACzD,+EAA+E;AAC/E,kBAAkB;AAClB,gDAAgD;AAChD,8EAA8E;AAC9E,UAAU;AACV,6BAA6B;AAC7B,iEAAiE;AACjE,YAAY;AACZ,8EAA8E;AAE9E,mBAAmB;AACnB,2BAA2B;AAC3B,+HAA+H;AAC/H,wFAAwF;AACxF,aAAa;AACb,QAAQ;AAER,kBAAkB;AAClB,8CAA8C;AAC9C,mDAAmD;AACnD,0EAA0E;AAC1E,iBAAiB;AACjB,6DAA6D;AAC7D,8EAA8E;AAC9E,UAAU;AACV,+FAA+F;AAC/F,kDAAkD;AAClD,QAAQ;AACR,KAAK"}
|