Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omniboxd",
"version": "0.1.2",
"version": "0.1.3",
"private": true,
"scripts": {
"build": "nest build",
Expand Down
8 changes: 8 additions & 0 deletions src/resources/dto/resource.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class ResourceMetaDto {
resource_type: string;
attrs: Record<string, any>;
tags: TagDto[];
created_at: string;
updated_at: string;

static fromEntity(resource: Resource, tags: TagDto[] = []) {
const dto = new ResourceMetaDto();
Expand All @@ -23,6 +25,8 @@ export class ResourceMetaDto {
dto.resource_type = resource.resourceType;
dto.attrs = resource.attrs;
dto.tags = tags;
dto.created_at = resource.createdAt.toISOString();
dto.updated_at = resource.updatedAt.toISOString();
return dto;
}
}
Expand All @@ -40,6 +44,8 @@ export class ResourceDto {
current_permission: ResourcePermission;
path: ResourceMetaDto[];
space_type: SpaceType;
created_at: string;
updated_at: string;

static fromEntity(
resource: Resource,
Expand All @@ -61,6 +67,8 @@ export class ResourceDto {
dto.current_permission = currentPermission;
dto.path = path;
dto.space_type = spaceType;
dto.created_at = resource.createdAt.toISOString();
dto.updated_at = resource.updatedAt.toISOString();
return dto;
}
}
2 changes: 1 addition & 1 deletion src/resources/file-resources.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const uploadLanguageDatasets = [
{ filename: '🚀🔥.txt', content: '😊👍🌍' },
];

describe('ResourcesController (e2e)', () => {
describe('FileResourcesController (e2e)', () => {
let client: TestClient;

beforeAll(async () => {
Expand Down
10 changes: 10 additions & 0 deletions src/resources/resources.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,16 @@ describe('ResourcesController (e2e)', () => {
expect(childResource).toBeDefined();
expect(childResource.name).toBe('Child Resource for List');
expect(childResource.attrs).toEqual(childAttrs);

// Check for required timestamp fields
expect(childResource).toHaveProperty('created_at');
expect(childResource).toHaveProperty('updated_at');
expect(childResource.created_at).toMatch(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
);
expect(childResource.updated_at).toMatch(
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
);
});

it('should return empty array for resource with no children', async () => {
Expand Down
27 changes: 24 additions & 3 deletions src/resources/resources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class ResourcesService {
'name',
'attrs',
'parentId',
'createdAt',
'updatedAt',
'namespaceId',
'resourceType',
Expand Down Expand Up @@ -331,6 +332,7 @@ export class ResourcesService {
'name',
'attrs',
'parentId',
'createdAt',
'updatedAt',
'namespaceId',
'resourceType',
Expand Down Expand Up @@ -459,7 +461,16 @@ export class ResourcesService {
}

const children = await this.resourceRepository.find({
select: ['id', 'name', 'parentId', 'resourceType', 'attrs', 'tagIds'],
select: [
'id',
'name',
'parentId',
'resourceType',
'attrs',
'tagIds',
'createdAt',
'updatedAt',
],
where: {
namespaceId,
parentId: resourceId,
Expand Down Expand Up @@ -574,7 +585,15 @@ export class ResourcesService {
while (true) {
const resource = await this.resourceRepository.findOne({
where: { namespaceId, id: resourceId },
select: ['id', 'name', 'resourceType', 'parentId', 'globalPermission'],
select: [
'id',
'name',
'resourceType',
'parentId',
'globalPermission',
'createdAt',
'updatedAt',
],
});
if (!resource) {
throw new NotFoundException('Resource not found');
Expand Down Expand Up @@ -698,7 +717,8 @@ export class ResourcesService {
parentId?: string,
resourceId?: string,
) {
const originalName = encodeFileName(fileName);
const originalName = getOriginalFileName(fileName);
const encodedName = encodeFileName(fileName);
let resource: Resource;
if (resourceId) {
resource = await this.get(resourceId);
Expand All @@ -713,6 +733,7 @@ export class ResourcesService {
parentId,
attrs: {
original_name: originalName,
encoded_name: encodedName,
mimetype: mimetype,
},
});
Expand Down