Compare commits
34 Commits
fix/graphq
...
feat/share
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
131b014e64 | ||
|
|
877f210ad7 | ||
|
|
23bb9bc3d1 | ||
|
|
4dcb0afb18 | ||
|
|
2e445224da | ||
|
|
032164f263 | ||
|
|
61efaaa248 | ||
|
|
c8c3314430 | ||
|
|
3eef6c9b04 | ||
|
|
2064af92fc | ||
|
|
1b00ff6c9e | ||
|
|
8fe1483de5 | ||
|
|
892be11445 | ||
|
|
00ad3307d4 | ||
|
|
2e396b3402 | ||
|
|
0be35633cf | ||
|
|
91c07e15b3 | ||
|
|
130aa8503c | ||
|
|
1703f2ee8a | ||
|
|
f780ca7a92 | ||
|
|
3747da9939 | ||
|
|
8007191d7a | ||
|
|
a1b952329b | ||
|
|
1124ba1ba3 | ||
|
|
6023ee27cf | ||
|
|
d56224b17b | ||
|
|
b7462ab014 | ||
|
|
b74c1abf6f | ||
|
|
7876c42312 | ||
|
|
f149582a62 | ||
|
|
12f2840013 | ||
|
|
28a88759c6 | ||
|
|
d1c9c3583f | ||
|
|
2462492c86 |
@@ -17,12 +17,12 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/language": "^6.9.1",
|
"@codemirror/language": "^6.9.0",
|
||||||
"@lezer/highlight": "^1.1.6",
|
"@lezer/highlight": "^1.1.6",
|
||||||
"@lezer/lr": "^1.3.13"
|
"@lezer/lr": "^1.3.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lezer/generator": "^1.5.1",
|
"@lezer/generator": "^1.5.0",
|
||||||
"mocha": "^9.2.2",
|
"mocha": "^9.2.2",
|
||||||
"rollup": "^3.29.3",
|
"rollup": "^3.29.3",
|
||||||
"rollup-plugin-dts": "^6.0.2",
|
"rollup-plugin-dts": "^6.0.2",
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[id]` on the table `Shortcode` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Shortcode" ADD COLUMN "embedProperties" JSONB,
|
||||||
|
ADD COLUMN "updatedOn" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Shortcode_id_key" ON "Shortcode"("id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Shortcode" ADD CONSTRAINT "Shortcode_creatorUid_fkey" FOREIGN KEY ("creatorUid") REFERENCES "User"("uid") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -68,11 +68,13 @@ model TeamRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Shortcode {
|
model Shortcode {
|
||||||
id String @id
|
id String @id @unique
|
||||||
request Json
|
request Json
|
||||||
creatorUid String?
|
embedProperties Json?
|
||||||
createdOn DateTime @default(now())
|
creatorUid String?
|
||||||
|
User User? @relation(fields: [creatorUid], references: [uid])
|
||||||
|
createdOn DateTime @default(now())
|
||||||
|
updatedOn DateTime @updatedAt @default(now())
|
||||||
@@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
|
@@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +104,7 @@ model User {
|
|||||||
currentGQLSession Json?
|
currentGQLSession Json?
|
||||||
createdOn DateTime @default(now()) @db.Timestamp(3)
|
createdOn DateTime @default(now()) @db.Timestamp(3)
|
||||||
invitedUsers InvitedUsers[]
|
invitedUsers InvitedUsers[]
|
||||||
|
shortcodes Shortcode[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Account {
|
model Account {
|
||||||
|
|||||||
@@ -318,18 +318,6 @@ export const TEAM_INVITATION_NOT_FOUND =
|
|||||||
*/
|
*/
|
||||||
export const SHORTCODE_NOT_FOUND = 'shortcode/not_found' as const;
|
export const SHORTCODE_NOT_FOUND = 'shortcode/not_found' as const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalid ShortCode format
|
|
||||||
* (ShortcodeService)
|
|
||||||
*/
|
|
||||||
export const SHORTCODE_INVALID_JSON = 'shortcode/invalid_json' as const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ShortCode already exists in DB
|
|
||||||
* (ShortcodeService)
|
|
||||||
*/
|
|
||||||
export const SHORTCODE_ALREADY_EXISTS = 'shortcode/already_exists' as const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid or non-existent TEAM ENVIRONMENT ID
|
* Invalid or non-existent TEAM ENVIRONMENT ID
|
||||||
* (TeamEnvironmentsService)
|
* (TeamEnvironmentsService)
|
||||||
@@ -621,3 +609,24 @@ export const MAILER_SMTP_URL_UNDEFINED = 'mailer/smtp_url_undefined' as const;
|
|||||||
*/
|
*/
|
||||||
export const MAILER_FROM_ADDRESS_UNDEFINED =
|
export const MAILER_FROM_ADDRESS_UNDEFINED =
|
||||||
'mailer/from_address_undefined' as const;
|
'mailer/from_address_undefined' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid request JSON format
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_INVALID_REQUEST_JSON =
|
||||||
|
'shortcode/request_invalid_format' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid properties JSON format
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_INVALID_PROPERTIES_JSON =
|
||||||
|
'shortcode/properties_invalid_format' as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SharedRequest invalid properties not found
|
||||||
|
* (ShortcodeService)
|
||||||
|
*/
|
||||||
|
export const SHORTCODE_PROPERTIES_NOT_FOUND =
|
||||||
|
'shortcode/properties_not_found' as const;
|
||||||
|
|||||||
@@ -69,5 +69,7 @@ export type TopicDef = {
|
|||||||
[topic: `team_req/${string}/req_deleted`]: string;
|
[topic: `team_req/${string}/req_deleted`]: string;
|
||||||
[topic: `team/${string}/invite_added`]: TeamInvitation;
|
[topic: `team/${string}/invite_added`]: TeamInvitation;
|
||||||
[topic: `team/${string}/invite_removed`]: string;
|
[topic: `team/${string}/invite_removed`]: string;
|
||||||
[topic: `shortcode/${string}/${'created' | 'revoked'}`]: Shortcode;
|
[
|
||||||
|
topic: `shortcode/${string}/${'created' | 'revoked' | 'updated'}`
|
||||||
|
]: Shortcode;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Field, ID, ObjectType } from '@nestjs/graphql';
|
|||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Shortcode {
|
export class Shortcode {
|
||||||
@Field(() => ID, {
|
@Field(() => ID, {
|
||||||
description: 'The shortcode. 12 digit alphanumeric.',
|
description: 'The 12 digit alphanumeric code',
|
||||||
})
|
})
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@@ -12,6 +12,12 @@ export class Shortcode {
|
|||||||
})
|
})
|
||||||
request: string;
|
request: string;
|
||||||
|
|
||||||
|
@Field({
|
||||||
|
description: 'JSON string representing the properties for an embed',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
properties: string;
|
||||||
|
|
||||||
@Field({
|
@Field({
|
||||||
description: 'Timestamp of when the Shortcode was created',
|
description: 'Timestamp of when the Shortcode was created',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { JwtModule } from '@nestjs/jwt';
|
|
||||||
import { PrismaModule } from 'src/prisma/prisma.module';
|
import { PrismaModule } from 'src/prisma/prisma.module';
|
||||||
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
||||||
import { UserModule } from 'src/user/user.module';
|
import { UserModule } from 'src/user/user.module';
|
||||||
@@ -7,14 +6,7 @@ import { ShortcodeResolver } from './shortcode.resolver';
|
|||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [PrismaModule, UserModule, PubSubModule],
|
||||||
PrismaModule,
|
|
||||||
UserModule,
|
|
||||||
PubSubModule,
|
|
||||||
JwtModule.register({
|
|
||||||
secret: process.env.JWT_SECRET,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
providers: [ShortcodeService, ShortcodeResolver],
|
providers: [ShortcodeService, ShortcodeResolver],
|
||||||
exports: [ShortcodeService],
|
exports: [ShortcodeService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
Args,
|
Args,
|
||||||
Context,
|
|
||||||
ID,
|
ID,
|
||||||
Mutation,
|
Mutation,
|
||||||
Query,
|
Query,
|
||||||
@@ -11,14 +10,12 @@ import * as E from 'fp-ts/Either';
|
|||||||
import { UseGuards } from '@nestjs/common';
|
import { UseGuards } from '@nestjs/common';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode } from './shortcode.model';
|
||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
import { UserService } from 'src/user/user.service';
|
|
||||||
import { throwErr } from 'src/utils';
|
import { throwErr } from 'src/utils';
|
||||||
import { GqlUser } from 'src/decorators/gql-user.decorator';
|
import { GqlUser } from 'src/decorators/gql-user.decorator';
|
||||||
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
||||||
import { User } from 'src/user/user.model';
|
import { User } from 'src/user/user.model';
|
||||||
import { PubSubService } from 'src/pubsub/pubsub.service';
|
import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||||
import { AuthUser } from '../types/AuthUser';
|
import { AuthUser } from '../types/AuthUser';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
|
||||||
import { PaginationArgs } from 'src/types/input-types.args';
|
import { PaginationArgs } from 'src/types/input-types.args';
|
||||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||||
import { SkipThrottle } from '@nestjs/throttler';
|
import { SkipThrottle } from '@nestjs/throttler';
|
||||||
@@ -28,9 +25,7 @@ import { SkipThrottle } from '@nestjs/throttler';
|
|||||||
export class ShortcodeResolver {
|
export class ShortcodeResolver {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly shortcodeService: ShortcodeService,
|
private readonly shortcodeService: ShortcodeService,
|
||||||
private readonly userService: UserService,
|
|
||||||
private readonly pubsub: PubSubService,
|
private readonly pubsub: PubSubService,
|
||||||
private jwtService: JwtService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/* Queries */
|
/* Queries */
|
||||||
@@ -64,20 +59,53 @@ export class ShortcodeResolver {
|
|||||||
@Mutation(() => Shortcode, {
|
@Mutation(() => Shortcode, {
|
||||||
description: 'Create a shortcode for the given request.',
|
description: 'Create a shortcode for the given request.',
|
||||||
})
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
async createShortcode(
|
async createShortcode(
|
||||||
|
@GqlUser() user: AuthUser,
|
||||||
@Args({
|
@Args({
|
||||||
name: 'request',
|
name: 'request',
|
||||||
description: 'JSON string of the request object',
|
description: 'JSON string of the request object',
|
||||||
})
|
})
|
||||||
request: string,
|
request: string,
|
||||||
@Context() ctx: any,
|
@Args({
|
||||||
|
name: 'properties',
|
||||||
|
description: 'JSON string of the properties of the embed',
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
properties: string,
|
||||||
) {
|
) {
|
||||||
const decodedAccessToken = this.jwtService.verify(
|
|
||||||
ctx.req.cookies['access_token'],
|
|
||||||
);
|
|
||||||
const result = await this.shortcodeService.createShortcode(
|
const result = await this.shortcodeService.createShortcode(
|
||||||
request,
|
request,
|
||||||
decodedAccessToken?.sub,
|
properties,
|
||||||
|
user,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (E.isLeft(result)) throwErr(result.left);
|
||||||
|
return result.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation(() => Shortcode, {
|
||||||
|
description: 'Update a user generated Shortcode',
|
||||||
|
})
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
async updateEmbedProperties(
|
||||||
|
@GqlUser() user: AuthUser,
|
||||||
|
@Args({
|
||||||
|
name: 'code',
|
||||||
|
type: () => ID,
|
||||||
|
description: 'The Shortcode to update',
|
||||||
|
})
|
||||||
|
code: string,
|
||||||
|
@Args({
|
||||||
|
name: 'properties',
|
||||||
|
description: 'JSON string of the properties of the embed',
|
||||||
|
})
|
||||||
|
properties: string,
|
||||||
|
) {
|
||||||
|
const result = await this.shortcodeService.updateEmbedProperties(
|
||||||
|
code,
|
||||||
|
user.uid,
|
||||||
|
properties,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (E.isLeft(result)) throwErr(result.left);
|
if (E.isLeft(result)) throwErr(result.left);
|
||||||
@@ -114,6 +142,16 @@ export class ShortcodeResolver {
|
|||||||
return this.pubsub.asyncIterator(`shortcode/${user.uid}/created`);
|
return this.pubsub.asyncIterator(`shortcode/${user.uid}/created`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscription(() => Shortcode, {
|
||||||
|
description: 'Listen for Shortcode updates',
|
||||||
|
resolve: (value) => value,
|
||||||
|
})
|
||||||
|
@SkipThrottle()
|
||||||
|
@UseGuards(GqlAuthGuard)
|
||||||
|
myShortcodesUpdated(@GqlUser() user: AuthUser) {
|
||||||
|
return this.pubsub.asyncIterator(`shortcode/${user.uid}/updated`);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscription(() => Shortcode, {
|
@Subscription(() => Shortcode, {
|
||||||
description: 'Listen for shortcode deletion',
|
description: 'Listen for shortcode deletion',
|
||||||
resolve: (value) => value,
|
resolve: (value) => value,
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import { mockDeep, mockReset } from 'jest-mock-extended';
|
import { mockDeep, mockReset } from 'jest-mock-extended';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import {
|
import {
|
||||||
SHORTCODE_ALREADY_EXISTS,
|
SHORTCODE_INVALID_PROPERTIES_JSON,
|
||||||
SHORTCODE_INVALID_JSON,
|
SHORTCODE_INVALID_REQUEST_JSON,
|
||||||
SHORTCODE_NOT_FOUND,
|
SHORTCODE_NOT_FOUND,
|
||||||
|
SHORTCODE_PROPERTIES_NOT_FOUND,
|
||||||
} from 'src/errors';
|
} from 'src/errors';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode } from './shortcode.model';
|
||||||
import { ShortcodeService } from './shortcode.service';
|
import { ShortcodeService } from './shortcode.service';
|
||||||
import { UserService } from 'src/user/user.service';
|
import { UserService } from 'src/user/user.service';
|
||||||
|
import { AuthUser } from 'src/types/AuthUser';
|
||||||
|
|
||||||
const mockPrisma = mockDeep<PrismaService>();
|
const mockPrisma = mockDeep<PrismaService>();
|
||||||
|
|
||||||
@@ -22,7 +24,7 @@ const mockFB = {
|
|||||||
doc: mockDocFunc,
|
doc: mockDocFunc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const mockUserService = new UserService(mockFB as any, mockPubSub as any);
|
const mockUserService = new UserService(mockPrisma as any, mockPubSub as any);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -38,18 +40,34 @@ beforeEach(() => {
|
|||||||
});
|
});
|
||||||
const createdOn = new Date();
|
const createdOn = new Date();
|
||||||
|
|
||||||
const shortCodeWithOutUser = {
|
const user: AuthUser = {
|
||||||
id: '123',
|
uid: '123344',
|
||||||
request: '{}',
|
email: 'dwight@dundermifflin.com',
|
||||||
|
displayName: 'Dwight Schrute',
|
||||||
|
photoURL: 'https://en.wikipedia.org/wiki/Dwight_Schrute',
|
||||||
|
isAdmin: false,
|
||||||
|
refreshToken: 'hbfvdkhjbvkdvdfjvbnkhjb',
|
||||||
createdOn: createdOn,
|
createdOn: createdOn,
|
||||||
creatorUid: null,
|
currentGQLSession: {},
|
||||||
|
currentRESTSession: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const shortCodeWithUser = {
|
const mockEmbed = {
|
||||||
id: '123',
|
id: '123',
|
||||||
request: '{}',
|
request: '{}',
|
||||||
|
embedProperties: '{}',
|
||||||
createdOn: createdOn,
|
createdOn: createdOn,
|
||||||
creatorUid: 'user_uid_1',
|
creatorUid: user.uid,
|
||||||
|
updatedOn: createdOn,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockShortcode = {
|
||||||
|
id: '123',
|
||||||
|
request: '{}',
|
||||||
|
embedProperties: null,
|
||||||
|
createdOn: createdOn,
|
||||||
|
creatorUid: user.uid,
|
||||||
|
updatedOn: createdOn,
|
||||||
};
|
};
|
||||||
|
|
||||||
const shortcodes = [
|
const shortcodes = [
|
||||||
@@ -58,33 +76,38 @@ const shortcodes = [
|
|||||||
request: {
|
request: {
|
||||||
hello: 'there',
|
hello: 'there',
|
||||||
},
|
},
|
||||||
creatorUid: 'testuser',
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'blablabla1',
|
id: 'blablabla1',
|
||||||
request: {
|
request: {
|
||||||
hello: 'there',
|
hello: 'there',
|
||||||
},
|
},
|
||||||
creatorUid: 'testuser',
|
embedProperties: {
|
||||||
|
foo: 'bar',
|
||||||
|
},
|
||||||
|
creatorUid: user.uid,
|
||||||
createdOn: new Date(),
|
createdOn: new Date(),
|
||||||
|
updatedOn: createdOn,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('ShortcodeService', () => {
|
describe('ShortcodeService', () => {
|
||||||
describe('getShortCode', () => {
|
describe('getShortCode', () => {
|
||||||
test('should return a valid shortcode with valid shortcode ID', async () => {
|
test('should return a valid Shortcode with valid Shortcode ID', async () => {
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockResolvedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockResolvedValueOnce(mockEmbed);
|
||||||
shortCodeWithOutUser,
|
|
||||||
);
|
|
||||||
|
|
||||||
const result = await shortcodeService.getShortCode(
|
const result = await shortcodeService.getShortCode(mockEmbed.id);
|
||||||
shortCodeWithOutUser.id,
|
|
||||||
);
|
|
||||||
expect(result).toEqualRight(<Shortcode>{
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithOutUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithOutUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithOutUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,10 +122,10 @@ describe('ShortcodeService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('fetchUserShortCodes', () => {
|
describe('fetchUserShortCodes', () => {
|
||||||
test('should return list of shortcodes with valid inputs and no cursor', async () => {
|
test('should return list of Shortcode with valid inputs and no cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValueOnce(shortcodes);
|
mockPrisma.shortcode.findMany.mockResolvedValueOnce(shortcodes);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: null,
|
cursor: null,
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -110,20 +133,22 @@ describe('ShortcodeService', () => {
|
|||||||
{
|
{
|
||||||
id: shortcodes[0].id,
|
id: shortcodes[0].id,
|
||||||
request: JSON.stringify(shortcodes[0].request),
|
request: JSON.stringify(shortcodes[0].request),
|
||||||
|
properties: JSON.stringify(shortcodes[0].embedProperties),
|
||||||
createdOn: shortcodes[0].createdOn,
|
createdOn: shortcodes[0].createdOn,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: shortcodes[1].id,
|
id: shortcodes[1].id,
|
||||||
request: JSON.stringify(shortcodes[1].request),
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
createdOn: shortcodes[1].createdOn,
|
createdOn: shortcodes[1].createdOn,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return list of shortcodes with valid inputs and cursor', async () => {
|
test('should return list of Shortcode with valid inputs and cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValue([shortcodes[1]]);
|
mockPrisma.shortcode.findMany.mockResolvedValue([shortcodes[1]]);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: 'blablabla',
|
cursor: 'blablabla',
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -131,6 +156,7 @@ describe('ShortcodeService', () => {
|
|||||||
{
|
{
|
||||||
id: shortcodes[1].id,
|
id: shortcodes[1].id,
|
||||||
request: JSON.stringify(shortcodes[1].request),
|
request: JSON.stringify(shortcodes[1].request),
|
||||||
|
properties: JSON.stringify(shortcodes[1].embedProperties),
|
||||||
createdOn: shortcodes[1].createdOn,
|
createdOn: shortcodes[1].createdOn,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -139,7 +165,7 @@ describe('ShortcodeService', () => {
|
|||||||
test('should return an empty array for an invalid cursor', async () => {
|
test('should return an empty array for an invalid cursor', async () => {
|
||||||
mockPrisma.shortcode.findMany.mockResolvedValue([]);
|
mockPrisma.shortcode.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
const result = await shortcodeService.fetchUserShortCodes('testuser', {
|
const result = await shortcodeService.fetchUserShortCodes(user.uid, {
|
||||||
cursor: 'invalidcursor',
|
cursor: 'invalidcursor',
|
||||||
take: 10,
|
take: 10,
|
||||||
});
|
});
|
||||||
@@ -171,77 +197,111 @@ describe('ShortcodeService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('createShortcode', () => {
|
describe('createShortcode', () => {
|
||||||
test('should throw SHORTCODE_INVALID_JSON error if incoming request data is invalid', async () => {
|
test('should throw SHORTCODE_INVALID_REQUEST_JSON error if incoming request data is invalid', async () => {
|
||||||
const result = await shortcodeService.createShortcode(
|
const result = await shortcodeService.createShortcode(
|
||||||
'invalidRequest',
|
'invalidRequest',
|
||||||
'user_uid_1',
|
null,
|
||||||
|
user,
|
||||||
);
|
);
|
||||||
expect(result).toEqualLeft(SHORTCODE_INVALID_JSON);
|
expect(result).toEqualLeft(SHORTCODE_INVALID_REQUEST_JSON);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should successfully create a new shortcode with valid user uid', async () => {
|
test('should throw SHORTCODE_INVALID_PROPERTIES_JSON error if incoming properties data is invalid', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
const result = await shortcodeService.createShortcode(
|
||||||
|
'{}',
|
||||||
|
'invalid_data',
|
||||||
|
user,
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should successfully create a new Embed with valid user uid', async () => {
|
||||||
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', 'user_uid_1');
|
const result = await shortcodeService.createShortcode('{}', '{}', user);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should successfully create a new shortcode with null user uid', async () => {
|
test('should successfully create a new ShortCode with valid user uid', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockShortcode);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', null);
|
const result = await shortcodeService.createShortcode('{}', null, user);
|
||||||
expect(result).toEqualRight({
|
expect(result).toEqualRight(<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockShortcode.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockShortcode.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithOutUser.request),
|
request: JSON.stringify(mockShortcode.request),
|
||||||
|
properties: mockShortcode.embedProperties,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of shortcode', async () => {
|
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of a Shortcode', async () => {
|
||||||
// generateUniqueShortCodeID --> getShortCode
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
'NotFoundError',
|
'NotFoundError',
|
||||||
);
|
);
|
||||||
mockPrisma.shortcode.create.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockShortcode);
|
||||||
|
|
||||||
|
const result = await shortcodeService.createShortcode('{}', null, user);
|
||||||
|
|
||||||
const result = await shortcodeService.createShortcode('{}', 'user_uid_1');
|
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`shortcode/${shortCodeWithUser.creatorUid}/created`,
|
`shortcode/${mockShortcode.creatorUid}/created`,
|
||||||
{
|
<Shortcode>{
|
||||||
id: shortCodeWithUser.id,
|
id: mockShortcode.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockShortcode.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockShortcode.request),
|
||||||
|
properties: mockShortcode.embedProperties,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should send pubsub message to `shortcode/{uid}/created` on successful creation of an Embed', async () => {
|
||||||
|
// generateUniqueShortCodeID --> getShortcode
|
||||||
|
mockPrisma.shortcode.findFirstOrThrow.mockRejectedValueOnce(
|
||||||
|
'NotFoundError',
|
||||||
|
);
|
||||||
|
mockPrisma.shortcode.create.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
|
const result = await shortcodeService.createShortcode('{}', '{}', user);
|
||||||
|
|
||||||
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
|
`shortcode/${mockEmbed.creatorUid}/created`,
|
||||||
|
<Shortcode>{
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('revokeShortCode', () => {
|
describe('revokeShortCode', () => {
|
||||||
test('should return true on successful deletion of shortcode with valid inputs', async () => {
|
test('should return true on successful deletion of Shortcode with valid inputs', async () => {
|
||||||
mockPrisma.shortcode.delete.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.delete.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.revokeShortCode(
|
const result = await shortcodeService.revokeShortCode(
|
||||||
shortCodeWithUser.id,
|
mockEmbed.id,
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockPrisma.shortcode.delete).toHaveBeenCalledWith({
|
expect(mockPrisma.shortcode.delete).toHaveBeenCalledWith({
|
||||||
where: {
|
where: {
|
||||||
creator_uid_shortcode_unique: {
|
creator_uid_shortcode_unique: {
|
||||||
creatorUid: shortCodeWithUser.creatorUid,
|
creatorUid: mockEmbed.creatorUid,
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -249,52 +309,53 @@ describe('ShortcodeService', () => {
|
|||||||
expect(result).toEqualRight(true);
|
expect(result).toEqualRight(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when shortcode is invalid and user uid is valid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode is invalid and user uid is valid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('invalid', 'testuser'),
|
shortcodeService.revokeShortCode('invalid', 'testuser'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when shortcode is valid and user uid is invalid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode is valid and user uid is invalid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('blablablabla', 'invalidUser'),
|
shortcodeService.revokeShortCode('blablablabla', 'invalidUser'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return SHORTCODE_NOT_FOUND error when both shortcode and user uid are invalid', async () => {
|
test('should return SHORTCODE_NOT_FOUND error when both Shortcode and user uid are invalid', async () => {
|
||||||
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
mockPrisma.shortcode.delete.mockRejectedValue('RecordNotFound');
|
||||||
expect(
|
expect(
|
||||||
shortcodeService.revokeShortCode('invalid', 'invalid'),
|
shortcodeService.revokeShortCode('invalid', 'invalid'),
|
||||||
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
).resolves.toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should send pubsub message to `shortcode/{uid}/revoked` on successful deletion of shortcode', async () => {
|
test('should send pubsub message to `shortcode/{uid}/revoked` on successful deletion of Shortcode', async () => {
|
||||||
mockPrisma.shortcode.delete.mockResolvedValueOnce(shortCodeWithUser);
|
mockPrisma.shortcode.delete.mockResolvedValueOnce(mockEmbed);
|
||||||
|
|
||||||
const result = await shortcodeService.revokeShortCode(
|
const result = await shortcodeService.revokeShortCode(
|
||||||
shortCodeWithUser.id,
|
mockEmbed.id,
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
`shortcode/${shortCodeWithUser.creatorUid}/revoked`,
|
`shortcode/${mockEmbed.creatorUid}/revoked`,
|
||||||
{
|
{
|
||||||
id: shortCodeWithUser.id,
|
id: mockEmbed.id,
|
||||||
createdOn: shortCodeWithUser.createdOn,
|
createdOn: mockEmbed.createdOn,
|
||||||
request: JSON.stringify(shortCodeWithUser.request),
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify(mockEmbed.embedProperties),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteUserShortCodes', () => {
|
describe('deleteUserShortCodes', () => {
|
||||||
test('should successfully delete all users shortcodes with valid user uid', async () => {
|
test('should successfully delete all users Shortcodes with valid user uid', async () => {
|
||||||
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 1 });
|
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 1 });
|
||||||
|
|
||||||
const result = await shortcodeService.deleteUserShortCodes(
|
const result = await shortcodeService.deleteUserShortCodes(
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(1);
|
expect(result).toEqual(1);
|
||||||
});
|
});
|
||||||
@@ -303,9 +364,81 @@ describe('ShortcodeService', () => {
|
|||||||
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 0 });
|
mockPrisma.shortcode.deleteMany.mockResolvedValueOnce({ count: 0 });
|
||||||
|
|
||||||
const result = await shortcodeService.deleteUserShortCodes(
|
const result = await shortcodeService.deleteUserShortCodes(
|
||||||
shortCodeWithUser.creatorUid,
|
mockEmbed.creatorUid,
|
||||||
);
|
);
|
||||||
expect(result).toEqual(0);
|
expect(result).toEqual(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateShortcode', () => {
|
||||||
|
test('should return SHORTCODE_PROPERTIES_NOT_FOUND error when updatedProps in invalid', async () => {
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_PROPERTIES_NOT_FOUND);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return SHORTCODE_PROPERTIES_NOT_FOUND error when updatedProps in invalid JSON format', async () => {
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{kk',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should return SHORTCODE_NOT_FOUND error when Shortcode ID is invalid', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockRejectedValue('RecordNotFound');
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
'invalidID',
|
||||||
|
user.uid,
|
||||||
|
'{}',
|
||||||
|
);
|
||||||
|
expect(result).toEqualLeft(SHORTCODE_NOT_FOUND);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should successfully update a Shortcodes with valid inputs', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockResolvedValueOnce({
|
||||||
|
...mockEmbed,
|
||||||
|
embedProperties: '{"foo":"bar"}',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{"foo":"bar"}',
|
||||||
|
);
|
||||||
|
expect(result).toEqualRight({
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify('{"foo":"bar"}'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should send pubsub message to `shortcode/{uid}/updated` on successful Update of Shortcode', async () => {
|
||||||
|
mockPrisma.shortcode.update.mockResolvedValueOnce({
|
||||||
|
...mockEmbed,
|
||||||
|
embedProperties: '{"foo":"bar"}',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await shortcodeService.updateEmbedProperties(
|
||||||
|
mockEmbed.id,
|
||||||
|
user.uid,
|
||||||
|
'{"foo":"bar"}',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||||
|
`shortcode/${mockEmbed.creatorUid}/updated`,
|
||||||
|
{
|
||||||
|
id: mockEmbed.id,
|
||||||
|
createdOn: mockEmbed.createdOn,
|
||||||
|
request: JSON.stringify(mockEmbed.request),
|
||||||
|
properties: JSON.stringify('{"foo":"bar"}'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
import * as T from 'fp-ts/Task';
|
import * as T from 'fp-ts/Task';
|
||||||
import * as O from 'fp-ts/Option';
|
|
||||||
import * as TO from 'fp-ts/TaskOption';
|
import * as TO from 'fp-ts/TaskOption';
|
||||||
import * as E from 'fp-ts/Either';
|
import * as E from 'fp-ts/Either';
|
||||||
import { PrismaService } from 'src/prisma/prisma.service';
|
import { PrismaService } from 'src/prisma/prisma.service';
|
||||||
import { SHORTCODE_INVALID_JSON, SHORTCODE_NOT_FOUND } from 'src/errors';
|
import {
|
||||||
|
SHORTCODE_INVALID_PROPERTIES_JSON,
|
||||||
|
SHORTCODE_INVALID_REQUEST_JSON,
|
||||||
|
SHORTCODE_NOT_FOUND,
|
||||||
|
SHORTCODE_PROPERTIES_NOT_FOUND,
|
||||||
|
} from 'src/errors';
|
||||||
import { UserDataHandler } from 'src/user/user.data.handler';
|
import { UserDataHandler } from 'src/user/user.data.handler';
|
||||||
import { Shortcode } from './shortcode.model';
|
import { Shortcode } from './shortcode.model';
|
||||||
import { Shortcode as DBShortCode } from '@prisma/client';
|
import { Shortcode as DBShortCode } from '@prisma/client';
|
||||||
@@ -46,10 +50,14 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
* @param shortcodeInfo Prisma Shortcode type
|
* @param shortcodeInfo Prisma Shortcode type
|
||||||
* @returns GQL Shortcode
|
* @returns GQL Shortcode
|
||||||
*/
|
*/
|
||||||
private returnShortCode(shortcodeInfo: DBShortCode): Shortcode {
|
private cast(shortcodeInfo: DBShortCode): Shortcode {
|
||||||
return <Shortcode>{
|
return <Shortcode>{
|
||||||
id: shortcodeInfo.id,
|
id: shortcodeInfo.id,
|
||||||
request: JSON.stringify(shortcodeInfo.request),
|
request: JSON.stringify(shortcodeInfo.request),
|
||||||
|
properties:
|
||||||
|
shortcodeInfo.embedProperties != null
|
||||||
|
? JSON.stringify(shortcodeInfo.embedProperties)
|
||||||
|
: null,
|
||||||
createdOn: shortcodeInfo.createdOn,
|
createdOn: shortcodeInfo.createdOn,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,7 +102,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
const shortcodeInfo = await this.prisma.shortcode.findFirstOrThrow({
|
const shortcodeInfo = await this.prisma.shortcode.findFirstOrThrow({
|
||||||
where: { id: shortcode },
|
where: { id: shortcode },
|
||||||
});
|
});
|
||||||
return E.right(this.returnShortCode(shortcodeInfo));
|
return E.right(this.cast(shortcodeInfo));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return E.left(SHORTCODE_NOT_FOUND);
|
return E.left(SHORTCODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -104,14 +112,22 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
* Create a new ShortCode
|
* Create a new ShortCode
|
||||||
*
|
*
|
||||||
* @param request JSON string of request details
|
* @param request JSON string of request details
|
||||||
* @param userUID user UID, if present
|
* @param userInfo user UI
|
||||||
|
* @param properties JSON string of embed properties, if present
|
||||||
* @returns Either of ShortCode or error
|
* @returns Either of ShortCode or error
|
||||||
*/
|
*/
|
||||||
async createShortcode(request: string, userUID: string | null) {
|
async createShortcode(
|
||||||
const shortcodeData = stringToJson(request);
|
request: string,
|
||||||
if (E.isLeft(shortcodeData)) return E.left(SHORTCODE_INVALID_JSON);
|
properties: string | null = null,
|
||||||
|
userInfo: AuthUser,
|
||||||
|
) {
|
||||||
|
const requestData = stringToJson(request);
|
||||||
|
if (E.isLeft(requestData) || !requestData.right)
|
||||||
|
return E.left(SHORTCODE_INVALID_REQUEST_JSON);
|
||||||
|
|
||||||
const user = await this.userService.findUserById(userUID);
|
const parsedProperties = stringToJson(properties);
|
||||||
|
if (E.isLeft(parsedProperties))
|
||||||
|
return E.left(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
|
||||||
const generatedShortCode = await this.generateUniqueShortCodeID();
|
const generatedShortCode = await this.generateUniqueShortCodeID();
|
||||||
if (E.isLeft(generatedShortCode)) return E.left(generatedShortCode.left);
|
if (E.isLeft(generatedShortCode)) return E.left(generatedShortCode.left);
|
||||||
@@ -119,8 +135,9 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
const createdShortCode = await this.prisma.shortcode.create({
|
const createdShortCode = await this.prisma.shortcode.create({
|
||||||
data: {
|
data: {
|
||||||
id: generatedShortCode.right,
|
id: generatedShortCode.right,
|
||||||
request: shortcodeData.right,
|
request: requestData.right,
|
||||||
creatorUid: O.isNone(user) ? null : user.value.uid,
|
embedProperties: parsedProperties.right ?? undefined,
|
||||||
|
creatorUid: userInfo.uid,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -128,11 +145,11 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
if (createdShortCode.creatorUid) {
|
if (createdShortCode.creatorUid) {
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`shortcode/${createdShortCode.creatorUid}/created`,
|
`shortcode/${createdShortCode.creatorUid}/created`,
|
||||||
this.returnShortCode(createdShortCode),
|
this.cast(createdShortCode),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return E.right(this.returnShortCode(createdShortCode));
|
return E.right(this.cast(createdShortCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +173,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fetchedShortCodes: Shortcode[] = shortCodes.map((code) =>
|
const fetchedShortCodes: Shortcode[] = shortCodes.map((code) =>
|
||||||
this.returnShortCode(code),
|
this.cast(code),
|
||||||
);
|
);
|
||||||
|
|
||||||
return fetchedShortCodes;
|
return fetchedShortCodes;
|
||||||
@@ -182,7 +199,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
|
|
||||||
this.pubsub.publish(
|
this.pubsub.publish(
|
||||||
`shortcode/${deletedShortCodes.creatorUid}/revoked`,
|
`shortcode/${deletedShortCodes.creatorUid}/revoked`,
|
||||||
this.returnShortCode(deletedShortCodes),
|
this.cast(deletedShortCodes),
|
||||||
);
|
);
|
||||||
|
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
@@ -205,4 +222,45 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
|
|
||||||
return deletedShortCodes.count;
|
return deletedShortCodes.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a created Shortcode
|
||||||
|
* @param shortcodeID Shortcode ID
|
||||||
|
* @param uid User Uid
|
||||||
|
* @returns Updated Shortcode
|
||||||
|
*/
|
||||||
|
async updateEmbedProperties(
|
||||||
|
shortcodeID: string,
|
||||||
|
uid: string,
|
||||||
|
updatedProps: string,
|
||||||
|
) {
|
||||||
|
if (!updatedProps) return E.left(SHORTCODE_PROPERTIES_NOT_FOUND);
|
||||||
|
|
||||||
|
const parsedProperties = stringToJson(updatedProps);
|
||||||
|
if (E.isLeft(parsedProperties) || !parsedProperties.right)
|
||||||
|
return E.left(SHORTCODE_INVALID_PROPERTIES_JSON);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedShortcode = await this.prisma.shortcode.update({
|
||||||
|
where: {
|
||||||
|
creator_uid_shortcode_unique: {
|
||||||
|
creatorUid: uid,
|
||||||
|
id: shortcodeID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
embedProperties: parsedProperties.right,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pubsub.publish(
|
||||||
|
`shortcode/${updatedShortcode.creatorUid}/updated`,
|
||||||
|
this.cast(updatedShortcode),
|
||||||
|
);
|
||||||
|
|
||||||
|
return E.right(this.cast(updatedShortcode));
|
||||||
|
} catch (error) {
|
||||||
|
return E.left(SHORTCODE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hoppscotch/cli",
|
"name": "@hoppscotch/cli",
|
||||||
"version": "0.3.3",
|
"version": "0.4.0",
|
||||||
"description": "A CLI to run Hoppscotch test scripts in CI environments.",
|
"description": "A CLI to run Hoppscotch test scripts in CI environments.",
|
||||||
"homepage": "https://hoppscotch.io",
|
"homepage": "https://hoppscotch.io",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm exec tsup",
|
"build": "pnpm exec tsup",
|
||||||
"dev": "pnpm exec tsup --watch",
|
"dev": "pnpm exec tsup --watch",
|
||||||
@@ -38,24 +41,24 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@hoppscotch/data": "workspace:^",
|
"@hoppscotch/data": "workspace:^",
|
||||||
"@hoppscotch/js-sandbox": "workspace:^",
|
"@hoppscotch/js-sandbox": "workspace:^",
|
||||||
"@relmify/jest-fp-ts": "^2.0.2",
|
"@relmify/jest-fp-ts": "^2.1.1",
|
||||||
"@swc/core": "^1.2.181",
|
"@swc/core": "^1.3.92",
|
||||||
"@types/jest": "^27.4.1",
|
"@types/jest": "^29.5.5",
|
||||||
"@types/lodash": "^4.14.181",
|
"@types/lodash": "^4.14.199",
|
||||||
"@types/qs": "^6.9.7",
|
"@types/qs": "^6.9.8",
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"chalk": "^4.1.1",
|
"chalk": "^4.1.2",
|
||||||
"commander": "^8.0.0",
|
"commander": "^11.0.0",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"fp-ts": "^2.12.1",
|
"fp-ts": "^2.16.1",
|
||||||
"io-ts": "^2.2.16",
|
"io-ts": "^2.2.20",
|
||||||
"jest": "^27.5.1",
|
"jest": "^29.7.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^3.0.3",
|
||||||
"qs": "^6.10.3",
|
"qs": "^6.11.2",
|
||||||
"ts-jest": "^27.1.4",
|
"ts-jest": "^29.1.1",
|
||||||
"tsup": "^5.12.7",
|
"tsup": "^7.2.0",
|
||||||
"typescript": "^4.6.4",
|
"typescript": "^5.2.2",
|
||||||
"zod": "^3.22.2"
|
"zod": "^3.22.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,17 +22,17 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/swagger-parser": "^10.1.0",
|
"@apidevtools/swagger-parser": "^10.1.0",
|
||||||
"@codemirror/autocomplete": "^6.10.2",
|
"@codemirror/autocomplete": "^6.9.0",
|
||||||
"@codemirror/commands": "^6.3.0",
|
"@codemirror/commands": "^6.2.4",
|
||||||
"@codemirror/lang-javascript": "^6.2.1",
|
"@codemirror/lang-javascript": "^6.1.9",
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
"@codemirror/lang-xml": "^6.0.2",
|
"@codemirror/lang-xml": "^6.0.2",
|
||||||
"@codemirror/language": "^6.9.1",
|
"@codemirror/language": "^6.9.0",
|
||||||
"@codemirror/legacy-modes": "^6.3.3",
|
"@codemirror/legacy-modes": "^6.3.3",
|
||||||
"@codemirror/lint": "^6.4.2",
|
"@codemirror/lint": "^6.4.0",
|
||||||
"@codemirror/search": "^6.5.4",
|
"@codemirror/search": "^6.5.1",
|
||||||
"@codemirror/state": "^6.3.1",
|
"@codemirror/state": "^6.2.1",
|
||||||
"@codemirror/view": "^6.21.3",
|
"@codemirror/view": "^6.16.0",
|
||||||
"@fontsource-variable/inter": "^5.0.8",
|
"@fontsource-variable/inter": "^5.0.8",
|
||||||
"@fontsource-variable/material-symbols-rounded": "^5.0.7",
|
"@fontsource-variable/material-symbols-rounded": "^5.0.7",
|
||||||
"@fontsource-variable/roboto-mono": "^5.0.9",
|
"@fontsource-variable/roboto-mono": "^5.0.9",
|
||||||
@@ -42,6 +42,8 @@
|
|||||||
"@hoppscotch/ui": "workspace:^",
|
"@hoppscotch/ui": "workspace:^",
|
||||||
"@hoppscotch/vue-toasted": "^0.1.0",
|
"@hoppscotch/vue-toasted": "^0.1.0",
|
||||||
"@lezer/highlight": "^1.1.6",
|
"@lezer/highlight": "^1.1.6",
|
||||||
|
"@sentry/tracing": "^7.64.0",
|
||||||
|
"@sentry/vue": "^7.64.0",
|
||||||
"@urql/core": "^4.1.1",
|
"@urql/core": "^4.1.1",
|
||||||
"@urql/devtools": "^2.0.3",
|
"@urql/devtools": "^2.0.3",
|
||||||
"@urql/exchange-auth": "^2.1.6",
|
"@urql/exchange-auth": "^2.1.6",
|
||||||
|
|||||||
200
packages/hoppscotch-common/src/modules/sentry.ts
Normal file
200
packages/hoppscotch-common/src/modules/sentry.ts
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
import { HoppModule } from "."
|
||||||
|
import * as Sentry from "@sentry/vue"
|
||||||
|
import { BrowserTracing } from "@sentry/tracing"
|
||||||
|
import { Route } from "@sentry/vue/types/router"
|
||||||
|
import { RouteLocationNormalized, Router } from "vue-router"
|
||||||
|
import { settingsStore } from "~/newstore/settings"
|
||||||
|
import { App } from "vue"
|
||||||
|
import { APP_IS_IN_DEV_MODE } from "~/helpers/dev"
|
||||||
|
import { gqlClientError$ } from "~/helpers/backend/GQLClient"
|
||||||
|
import { platform } from "~/platform"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tag names we allow giving to Sentry
|
||||||
|
*/
|
||||||
|
type SentryTag = "BACKEND_OPERATIONS"
|
||||||
|
|
||||||
|
interface SentryVueRouter {
|
||||||
|
onError: (fn: (err: Error) => void) => void
|
||||||
|
beforeEach: (fn: (to: Route, from: Route, next: () => void) => void) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizedRouteToSentryRoute(route: RouteLocationNormalized): Route {
|
||||||
|
return {
|
||||||
|
matched: route.matched,
|
||||||
|
// route.params' type translates just to a fancy version of this, hence assertion
|
||||||
|
params: route.params as Route["params"],
|
||||||
|
path: route.path,
|
||||||
|
// route.query's type translates just to a fancy version of this, hence assertion
|
||||||
|
query: route.query as Route["query"],
|
||||||
|
name: route.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInstrumentationVueRouter(router: Router): SentryVueRouter {
|
||||||
|
return <SentryVueRouter>{
|
||||||
|
onError: router.onError,
|
||||||
|
beforeEach(func) {
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
func(
|
||||||
|
normalizedRouteToSentryRoute(to),
|
||||||
|
normalizedRouteToSentryRoute(from),
|
||||||
|
next
|
||||||
|
)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sentryActive = false
|
||||||
|
|
||||||
|
function initSentry(dsn: string, router: Router, app: App) {
|
||||||
|
Sentry.init({
|
||||||
|
app,
|
||||||
|
dsn,
|
||||||
|
release: import.meta.env.VITE_SENTRY_RELEASE_TAG ?? undefined,
|
||||||
|
environment: APP_IS_IN_DEV_MODE
|
||||||
|
? "dev"
|
||||||
|
: import.meta.env.VITE_SENTRY_ENVIRONMENT,
|
||||||
|
integrations: [
|
||||||
|
new BrowserTracing({
|
||||||
|
routingInstrumentation: Sentry.vueRouterInstrumentation(
|
||||||
|
getInstrumentationVueRouter(router)
|
||||||
|
),
|
||||||
|
// TODO: We may want to limit this later on
|
||||||
|
tracingOrigins: [new URL(import.meta.env.VITE_BACKEND_GQL_URL).origin],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
tracesSampleRate: 0.8,
|
||||||
|
})
|
||||||
|
sentryActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function deinitSentry() {
|
||||||
|
Sentry.close()
|
||||||
|
sentryActive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports a set of related errors to Sentry
|
||||||
|
* @param errs The errors to report
|
||||||
|
* @param tag The tag for the errord
|
||||||
|
* @param extraTags Additional tag data to add
|
||||||
|
* @param extras Extra information to attach
|
||||||
|
*/
|
||||||
|
function reportErrors(
|
||||||
|
errs: Error[],
|
||||||
|
tag: SentryTag,
|
||||||
|
extraTags: Record<string, string | number | boolean> | null = null,
|
||||||
|
extras: any = undefined
|
||||||
|
) {
|
||||||
|
if (sentryActive) {
|
||||||
|
Sentry.withScope((scope) => {
|
||||||
|
scope.setTag("tag", tag)
|
||||||
|
if (extraTags) {
|
||||||
|
Object.entries(extraTags).forEach(([key, value]) => {
|
||||||
|
scope.setTag(key, value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (extras !== null && extras === undefined) scope.setExtras(extras)
|
||||||
|
|
||||||
|
scope.addAttachment({
|
||||||
|
filename: "extras-dump.json",
|
||||||
|
data: JSON.stringify(extras),
|
||||||
|
contentType: "application/json",
|
||||||
|
})
|
||||||
|
|
||||||
|
errs.forEach((err) => Sentry.captureException(err))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports a specific error to Sentry
|
||||||
|
* @param err The error to report
|
||||||
|
* @param tag The tag for the error
|
||||||
|
* @param extraTags Additional tag data to add
|
||||||
|
* @param extras Extra information to attach
|
||||||
|
*/
|
||||||
|
function reportError(
|
||||||
|
err: Error,
|
||||||
|
tag: SentryTag,
|
||||||
|
extraTags: Record<string, string | number | boolean> | null = null,
|
||||||
|
extras: any = undefined
|
||||||
|
) {
|
||||||
|
reportErrors([err], tag, extraTags, extras)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribes to events occuring in various subsystems in the app
|
||||||
|
* for personalized error reporting
|
||||||
|
*/
|
||||||
|
function subscribeToAppEventsForReporting() {
|
||||||
|
gqlClientError$.subscribe((ev) => {
|
||||||
|
switch (ev.type) {
|
||||||
|
case "SUBSCRIPTION_CONN_CALLBACK_ERR_REPORT":
|
||||||
|
reportErrors(ev.errors, "BACKEND_OPERATIONS", { from: ev.type })
|
||||||
|
break
|
||||||
|
|
||||||
|
case "CLIENT_REPORTED_ERROR":
|
||||||
|
reportError(
|
||||||
|
ev.error,
|
||||||
|
"BACKEND_OPERATIONS",
|
||||||
|
{ from: ev.type },
|
||||||
|
{ op: ev.op }
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "GQL_CLIENT_REPORTED_ERROR":
|
||||||
|
reportError(
|
||||||
|
new Error("Backend Query Failed"),
|
||||||
|
"BACKEND_OPERATIONS",
|
||||||
|
{ opType: ev.opType },
|
||||||
|
{
|
||||||
|
opResult: ev.opResult,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribe to app system events for adding
|
||||||
|
* additional data tags for the error reporting
|
||||||
|
*/
|
||||||
|
function subscribeForAppDataTags() {
|
||||||
|
const currentUser$ = platform.auth.getCurrentUserStream()
|
||||||
|
|
||||||
|
currentUser$.subscribe((user) => {
|
||||||
|
if (sentryActive) {
|
||||||
|
Sentry.setTag("user_logged_in", !!user)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default <HoppModule>{
|
||||||
|
onRouterInit(app, router) {
|
||||||
|
if (!import.meta.env.VITE_SENTRY_DSN) {
|
||||||
|
console.log(
|
||||||
|
"Sentry tracing is not enabled because 'VITE_SENTRY_DSN' env is not defined"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsStore.value.TELEMETRY_ENABLED) {
|
||||||
|
initSentry(import.meta.env.VITE_SENTRY_DSN, router, app)
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsStore.subject$.subscribe(({ TELEMETRY_ENABLED }) => {
|
||||||
|
if (!TELEMETRY_ENABLED && sentryActive) {
|
||||||
|
deinitSentry()
|
||||||
|
} else if (TELEMETRY_ENABLED && !sentryActive) {
|
||||||
|
initSentry(import.meta.env.VITE_SENTRY_DSN!, router, app)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
subscribeToAppEventsForReporting()
|
||||||
|
subscribeForAppDataTags()
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -60,7 +60,6 @@
|
|||||||
<div class="py-4 space-y-4">
|
<div class="py-4 space-y-4">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<HoppSmartToggle
|
<HoppSmartToggle
|
||||||
v-if="hasPlatformTelemetry"
|
|
||||||
:on="TELEMETRY_ENABLED"
|
:on="TELEMETRY_ENABLED"
|
||||||
@change="showConfirmModal"
|
@change="showConfirmModal"
|
||||||
>
|
>
|
||||||
@@ -135,7 +134,6 @@ import { InterceptorService } from "~/services/interceptor.service"
|
|||||||
import { pipe } from "fp-ts/function"
|
import { pipe } from "fp-ts/function"
|
||||||
import * as O from "fp-ts/Option"
|
import * as O from "fp-ts/Option"
|
||||||
import * as A from "fp-ts/Array"
|
import * as A from "fp-ts/Array"
|
||||||
import { platform } from "~/platform"
|
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
@@ -165,8 +163,6 @@ const TELEMETRY_ENABLED = useSetting("TELEMETRY_ENABLED")
|
|||||||
const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
|
const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
|
||||||
const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")
|
const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")
|
||||||
|
|
||||||
const hasPlatformTelemetry = Boolean(platform.platformFeatureFlags.hasTelemetry)
|
|
||||||
|
|
||||||
const confirmRemove = ref(false)
|
const confirmRemove = ref(false)
|
||||||
|
|
||||||
const proxySettings = computed(() => ({
|
const proxySettings = computed(() => ({
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export type PlatformDef = {
|
|||||||
additionalInspectors?: InspectorsPlatformDef
|
additionalInspectors?: InspectorsPlatformDef
|
||||||
platformFeatureFlags: {
|
platformFeatureFlags: {
|
||||||
exportAsGIST: boolean
|
exportAsGIST: boolean
|
||||||
hasTelemetry: boolean
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
function generateREForProtocol(protocol) {
|
function generateREForProtocol(protocol) {
|
||||||
return [
|
return [
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(:[0-9]+)?(\\/[^?#]*)?(\\?[^#]*)?(#.*)?$`
|
`${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
|
||||||
),
|
),
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])(:[0-9]+)?(\\/[^?#]*)?(\\?[^#]*)?(#.*)?$`
|
`${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
"main": "dist/hoppscotch-data.cjs",
|
"main": "dist/hoppscotch-data.cjs",
|
||||||
"module": "dist/hoppscotch-data.js",
|
"module": "dist/hoppscotch-data.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"files": [
|
"files": [ "dist/*" ],
|
||||||
"dist/*"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:code": "vite build",
|
"build:code": "vite build",
|
||||||
"build:decl": "tsc --project tsconfig.decl.json",
|
"build:decl": "tsc --project tsconfig.decl.json",
|
||||||
@@ -35,15 +33,13 @@
|
|||||||
"homepage": "https://github.com/hoppscotch/hoppscotch#readme",
|
"homepage": "https://github.com/hoppscotch/hoppscotch#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/lodash": "^4.14.181",
|
"@types/lodash": "^4.14.181",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^4.6.3",
|
||||||
"vite": "^3.2.3"
|
"vite": "^3.2.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fp-ts": "^2.11.10",
|
"fp-ts": "^2.11.10",
|
||||||
"io-ts": "^2.2.16",
|
"io-ts": "^2.2.16",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"parser-ts": "^0.6.16",
|
"parser-ts": "^0.6.16"
|
||||||
"verzod": "^0.1.1",
|
|
||||||
"zod": "^3.22.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
import * as E from "fp-ts/Either"
|
|
||||||
import { pipe } from "fp-ts/function"
|
import { pipe } from "fp-ts/function"
|
||||||
import { InferredEntity, createVersionedEntity } from "verzod"
|
import * as E from "fp-ts/Either"
|
||||||
|
|
||||||
import V0_VERSION from "./v/0"
|
export type Environment = {
|
||||||
|
id?: string
|
||||||
export const Environment = createVersionedEntity({
|
name: string
|
||||||
latestVersion: 0,
|
variables: {
|
||||||
versionMap: {
|
key: string
|
||||||
0: V0_VERSION
|
value: string
|
||||||
},
|
}[]
|
||||||
getVersion(x) {
|
}
|
||||||
return V0_VERSION.schema.safeParse(x).success
|
|
||||||
? 0
|
|
||||||
: null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export type Environment = InferredEntity<typeof Environment>
|
|
||||||
|
|
||||||
const REGEX_ENV_VAR = /<<([^>]*)>>/g // "<<myVariable>>"
|
const REGEX_ENV_VAR = /<<([^>]*)>>/g // "<<myVariable>>"
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import { z } from "zod"
|
|
||||||
import { defineVersion } from "verzod"
|
|
||||||
|
|
||||||
export const V0_SCHEMA = z.object({
|
|
||||||
id: z.optional(z.string()),
|
|
||||||
name: z.string(),
|
|
||||||
variables: z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
export default defineVersion({
|
|
||||||
initial: true,
|
|
||||||
schema: V0_SCHEMA
|
|
||||||
})
|
|
||||||
43
packages/hoppscotch-data/src/graphql/HoppGQLAuth.ts
Normal file
43
packages/hoppscotch-data/src/graphql/HoppGQLAuth.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
export type HoppGQLAuthNone = {
|
||||||
|
authType: "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppGQLAuthBasic = {
|
||||||
|
authType: "basic"
|
||||||
|
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppGQLAuthBearer = {
|
||||||
|
authType: "bearer"
|
||||||
|
|
||||||
|
token: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppGQLAuthOAuth2 = {
|
||||||
|
authType: "oauth-2"
|
||||||
|
|
||||||
|
token: string
|
||||||
|
oidcDiscoveryURL: string
|
||||||
|
authURL: string
|
||||||
|
accessTokenURL: string
|
||||||
|
clientID: string
|
||||||
|
scope: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppGQLAuthAPIKey = {
|
||||||
|
authType: "api-key"
|
||||||
|
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
addTo: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppGQLAuth = { authActive: boolean } & (
|
||||||
|
| HoppGQLAuthNone
|
||||||
|
| HoppGQLAuthBasic
|
||||||
|
| HoppGQLAuthBearer
|
||||||
|
| HoppGQLAuthOAuth2
|
||||||
|
| HoppGQLAuthAPIKey
|
||||||
|
)
|
||||||
@@ -1,73 +1,49 @@
|
|||||||
import { InferredEntity, createVersionedEntity } from "verzod"
|
import { HoppGQLAuth } from "./HoppGQLAuth"
|
||||||
import { z } from "zod"
|
|
||||||
import V1_VERSION from "./v/1"
|
|
||||||
import V2_VERSION from "./v/2"
|
|
||||||
|
|
||||||
export { GQLHeader } from "./v/1"
|
export * from "./HoppGQLAuth"
|
||||||
export {
|
|
||||||
HoppGQLAuth,
|
|
||||||
HoppGQLAuthAPIKey,
|
|
||||||
HoppGQLAuthBasic,
|
|
||||||
HoppGQLAuthBearer,
|
|
||||||
HoppGQLAuthNone,
|
|
||||||
HoppGQLAuthOAuth2,
|
|
||||||
} from "./v/2"
|
|
||||||
|
|
||||||
export const GQL_REQ_SCHEMA_VERSION = 2
|
export const GQL_REQ_SCHEMA_VERSION = 2
|
||||||
|
|
||||||
const versionedObject = z.object({
|
export type GQLHeader = {
|
||||||
v: z.number(),
|
key: string
|
||||||
})
|
value: string
|
||||||
|
active: boolean
|
||||||
export const HoppGQLRequest = createVersionedEntity({
|
|
||||||
latestVersion: 2,
|
|
||||||
versionMap: {
|
|
||||||
1: V1_VERSION,
|
|
||||||
2: V2_VERSION,
|
|
||||||
},
|
|
||||||
getVersion(x) {
|
|
||||||
const result = versionedObject.safeParse(x)
|
|
||||||
|
|
||||||
return result.success ? result.data.v : null
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLRequest = InferredEntity<typeof HoppGQLRequest>
|
|
||||||
|
|
||||||
const DEFAULT_QUERY = `
|
|
||||||
query Request {
|
|
||||||
method
|
|
||||||
url
|
|
||||||
headers {
|
|
||||||
key
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}`.trim()
|
|
||||||
|
|
||||||
export function getDefaultGQLRequest(): HoppGQLRequest {
|
|
||||||
return {
|
|
||||||
v: GQL_REQ_SCHEMA_VERSION,
|
|
||||||
name: "Untitled",
|
|
||||||
url: "https://echo.hoppscotch.io/graphql",
|
|
||||||
headers: [],
|
|
||||||
variables: `
|
|
||||||
{
|
|
||||||
"id": "1"
|
|
||||||
}`.trim(),
|
|
||||||
query: DEFAULT_QUERY,
|
|
||||||
auth: {
|
|
||||||
authType: "none",
|
|
||||||
authActive: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export type HoppGQLRequest = {
|
||||||
* @deprecated This function is deprecated. Use `HoppGQLRequest` instead.
|
id?: string
|
||||||
*/
|
v: number
|
||||||
export function translateToGQLRequest(x: unknown): HoppGQLRequest {
|
name: string
|
||||||
const result = HoppGQLRequest.safeParse(x)
|
url: string
|
||||||
return result.type === "ok" ? result.value : getDefaultGQLRequest()
|
headers: GQLHeader[]
|
||||||
|
query: string
|
||||||
|
variables: string
|
||||||
|
auth: HoppGQLAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
export function translateToGQLRequest(x: any): HoppGQLRequest {
|
||||||
|
if (x.v && x.v === GQL_REQ_SCHEMA_VERSION) return x
|
||||||
|
|
||||||
|
// Old request
|
||||||
|
const name = x.name ?? "Untitled"
|
||||||
|
const url = x.url ?? ""
|
||||||
|
const headers = x.headers ?? []
|
||||||
|
const query = x.query ?? ""
|
||||||
|
const variables = x.variables ?? []
|
||||||
|
const auth = x.auth ?? {
|
||||||
|
authType: "none",
|
||||||
|
authActive: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
v: GQL_REQ_SCHEMA_VERSION,
|
||||||
|
name,
|
||||||
|
url,
|
||||||
|
headers,
|
||||||
|
query,
|
||||||
|
variables,
|
||||||
|
auth
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeGQLRequest(x: Omit<HoppGQLRequest, "v">): HoppGQLRequest {
|
export function makeGQLRequest(x: Omit<HoppGQLRequest, "v">): HoppGQLRequest {
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { z } from "zod"
|
|
||||||
import { defineVersion } from "verzod"
|
|
||||||
|
|
||||||
export const GQLHeader = z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type GQLHeader = z.infer<typeof GQLHeader>
|
|
||||||
|
|
||||||
export const V1_SCHEMA = z.object({
|
|
||||||
v: z.literal(1),
|
|
||||||
name: z.string(),
|
|
||||||
url: z.string(),
|
|
||||||
headers: z.array(GQLHeader),
|
|
||||||
query: z.string(),
|
|
||||||
variables: z.string(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export default defineVersion({
|
|
||||||
initial: true,
|
|
||||||
schema: V1_SCHEMA
|
|
||||||
})
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
import { z } from "zod"
|
|
||||||
import { defineVersion } from "verzod"
|
|
||||||
import { GQLHeader, V1_SCHEMA } from "./1"
|
|
||||||
|
|
||||||
export const HoppGQLAuthNone = z.object({
|
|
||||||
authType: z.literal("none")
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLAuthNone = z.infer<typeof HoppGQLAuthNone>
|
|
||||||
|
|
||||||
export const HoppGQLAuthBasic = z.object({
|
|
||||||
authType: z.literal("basic"),
|
|
||||||
|
|
||||||
username: z.string(),
|
|
||||||
password: z.string()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLAuthBasic = z.infer<typeof HoppGQLAuthBasic>
|
|
||||||
|
|
||||||
export const HoppGQLAuthBearer = z.object({
|
|
||||||
authType: z.literal("bearer"),
|
|
||||||
|
|
||||||
token: z.string()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLAuthBearer = z.infer<typeof HoppGQLAuthBearer>
|
|
||||||
|
|
||||||
export const HoppGQLAuthOAuth2 = z.object({
|
|
||||||
authType: z.literal("oauth-2"),
|
|
||||||
|
|
||||||
token: z.string(),
|
|
||||||
oidcDiscoveryURL: z.string(),
|
|
||||||
authURL: z.string(),
|
|
||||||
accessTokenURL: z.string(),
|
|
||||||
clientID: z.string(),
|
|
||||||
scope: z.string()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLAuthOAuth2 = z.infer<typeof HoppGQLAuthOAuth2>
|
|
||||||
|
|
||||||
export const HoppGQLAuthAPIKey = z.object({
|
|
||||||
authType: z.literal("api-key"),
|
|
||||||
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
addTo: z.string()
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppGQLAuthAPIKey = z.infer<typeof HoppGQLAuthAPIKey>
|
|
||||||
|
|
||||||
export const HoppGQLAuth = z.discriminatedUnion("authType", [
|
|
||||||
HoppGQLAuthNone,
|
|
||||||
HoppGQLAuthBasic,
|
|
||||||
HoppGQLAuthBearer,
|
|
||||||
HoppGQLAuthOAuth2,
|
|
||||||
HoppGQLAuthAPIKey
|
|
||||||
]).and(
|
|
||||||
z.object({
|
|
||||||
authActive: z.boolean()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
export type HoppGQLAuth = z.infer<typeof HoppGQLAuth>
|
|
||||||
|
|
||||||
const V2_SCHEMA = z.object({
|
|
||||||
id: z.optional(z.string()),
|
|
||||||
v: z.literal(2),
|
|
||||||
|
|
||||||
name: z.string(),
|
|
||||||
url: z.string(),
|
|
||||||
headers: z.array(GQLHeader),
|
|
||||||
query: z.string(),
|
|
||||||
variables: z.string(),
|
|
||||||
|
|
||||||
auth: HoppGQLAuth
|
|
||||||
})
|
|
||||||
|
|
||||||
export default defineVersion({
|
|
||||||
initial: false,
|
|
||||||
schema: V2_SCHEMA,
|
|
||||||
up(old: z.infer<typeof V1_SCHEMA>) {
|
|
||||||
return <z.infer<typeof V2_SCHEMA>>{
|
|
||||||
...old,
|
|
||||||
v: 2,
|
|
||||||
auth: {
|
|
||||||
authActive: true,
|
|
||||||
authType: "none",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
43
packages/hoppscotch-data/src/rest/HoppRESTAuth.ts
Normal file
43
packages/hoppscotch-data/src/rest/HoppRESTAuth.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
export type HoppRESTAuthNone = {
|
||||||
|
authType: "none"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppRESTAuthBasic = {
|
||||||
|
authType: "basic"
|
||||||
|
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppRESTAuthBearer = {
|
||||||
|
authType: "bearer"
|
||||||
|
|
||||||
|
token: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppRESTAuthOAuth2 = {
|
||||||
|
authType: "oauth-2"
|
||||||
|
|
||||||
|
token: string
|
||||||
|
oidcDiscoveryURL: string
|
||||||
|
authURL: string
|
||||||
|
accessTokenURL: string
|
||||||
|
clientID: string
|
||||||
|
scope: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppRESTAuthAPIKey = {
|
||||||
|
authType: "api-key"
|
||||||
|
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
addTo: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HoppRESTAuth = { authActive: boolean } & (
|
||||||
|
| HoppRESTAuthNone
|
||||||
|
| HoppRESTAuthBasic
|
||||||
|
| HoppRESTAuthBearer
|
||||||
|
| HoppRESTAuthOAuth2
|
||||||
|
| HoppRESTAuthAPIKey
|
||||||
|
)
|
||||||
@@ -11,5 +11,3 @@ export const knownContentTypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ValidContentTypes = keyof typeof knownContentTypes
|
export type ValidContentTypes = keyof typeof knownContentTypes
|
||||||
|
|
||||||
export const ValidContentTypesList = Object.keys(knownContentTypes) as ValidContentTypes[]
|
|
||||||
|
|||||||
@@ -1,58 +1,66 @@
|
|||||||
|
import cloneDeep from "lodash/cloneDeep"
|
||||||
import * as Eq from "fp-ts/Eq"
|
import * as Eq from "fp-ts/Eq"
|
||||||
import * as S from "fp-ts/string"
|
import * as S from "fp-ts/string"
|
||||||
import cloneDeep from "lodash/cloneDeep"
|
import { ValidContentTypes } from "./content-types"
|
||||||
import V0_VERSION from "./v/0"
|
import { HoppRESTAuth } from "./HoppRESTAuth"
|
||||||
import V1_VERSION from "./v/1"
|
|
||||||
import { createVersionedEntity, InferredEntity } from "verzod"
|
|
||||||
import { lodashIsEqualEq, mapThenEq, undefinedEq } from "../utils/eq"
|
import { lodashIsEqualEq, mapThenEq, undefinedEq } from "../utils/eq"
|
||||||
import {
|
|
||||||
HoppRESTAuth,
|
|
||||||
HoppRESTReqBody,
|
|
||||||
HoppRESTHeaders,
|
|
||||||
HoppRESTParams,
|
|
||||||
} from "./v/1"
|
|
||||||
import { z } from "zod"
|
|
||||||
|
|
||||||
export * from "./content-types"
|
export * from "./content-types"
|
||||||
export {
|
export * from "./HoppRESTAuth"
|
||||||
FormDataKeyValue,
|
|
||||||
HoppRESTReqBodyFormData,
|
|
||||||
HoppRESTAuth,
|
|
||||||
HoppRESTAuthAPIKey,
|
|
||||||
HoppRESTAuthBasic,
|
|
||||||
HoppRESTAuthBearer,
|
|
||||||
HoppRESTAuthNone,
|
|
||||||
HoppRESTAuthOAuth2,
|
|
||||||
HoppRESTReqBody,
|
|
||||||
} from "./v/1"
|
|
||||||
|
|
||||||
const versionedObject = z.object({
|
export const RESTReqSchemaVersion = "1"
|
||||||
// v is a stringified number
|
|
||||||
v: z.string().regex(/^\d+$/).transform(Number),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const HoppRESTRequest = createVersionedEntity({
|
export type HoppRESTParam = {
|
||||||
latestVersion: 1,
|
key: string
|
||||||
versionMap: {
|
value: string
|
||||||
0: V0_VERSION,
|
active: boolean
|
||||||
1: V1_VERSION,
|
}
|
||||||
},
|
|
||||||
getVersion(data) {
|
|
||||||
// For V1 onwards we have the v string storing the number
|
|
||||||
const versionCheck = versionedObject.safeParse(data)
|
|
||||||
|
|
||||||
if (versionCheck.success) return versionCheck.data.v
|
export type HoppRESTHeader = {
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
active: boolean
|
||||||
|
}
|
||||||
|
|
||||||
// For V0 we have to check the schema
|
export type FormDataKeyValue = {
|
||||||
const result = V0_VERSION.schema.safeParse(data)
|
key: string
|
||||||
|
active: boolean
|
||||||
|
} & ({ isFile: true; value: Blob[] } | { isFile: false; value: string })
|
||||||
|
|
||||||
return result.success ? 0 : null
|
export type HoppRESTReqBodyFormData = {
|
||||||
},
|
contentType: "multipart/form-data"
|
||||||
})
|
body: FormDataKeyValue[]
|
||||||
|
}
|
||||||
|
|
||||||
export type HoppRESTRequest = InferredEntity<typeof HoppRESTRequest>
|
export type HoppRESTReqBody =
|
||||||
|
| {
|
||||||
|
contentType: Exclude<ValidContentTypes, "multipart/form-data">
|
||||||
|
body: string
|
||||||
|
}
|
||||||
|
| HoppRESTReqBodyFormData
|
||||||
|
| {
|
||||||
|
contentType: null
|
||||||
|
body: null
|
||||||
|
}
|
||||||
|
|
||||||
const HoppRESTRequestEq = Eq.struct<HoppRESTRequest>({
|
export interface HoppRESTRequest {
|
||||||
|
v: string
|
||||||
|
id?: string // Firebase Firestore ID
|
||||||
|
|
||||||
|
name: string
|
||||||
|
method: string
|
||||||
|
endpoint: string
|
||||||
|
params: HoppRESTParam[]
|
||||||
|
headers: HoppRESTHeader[]
|
||||||
|
preRequestScript: string
|
||||||
|
testScript: string
|
||||||
|
|
||||||
|
auth: HoppRESTAuth
|
||||||
|
|
||||||
|
body: HoppRESTReqBody
|
||||||
|
}
|
||||||
|
|
||||||
|
export const HoppRESTRequestEq = Eq.struct<HoppRESTRequest>({
|
||||||
id: undefinedEq(S.Eq),
|
id: undefinedEq(S.Eq),
|
||||||
v: S.Eq,
|
v: S.Eq,
|
||||||
auth: lodashIsEqualEq,
|
auth: lodashIsEqualEq,
|
||||||
@@ -72,11 +80,6 @@ const HoppRESTRequestEq = Eq.struct<HoppRESTRequest>({
|
|||||||
testScript: S.Eq,
|
testScript: S.Eq,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const RESTReqSchemaVersion = "1"
|
|
||||||
|
|
||||||
export type HoppRESTParam = HoppRESTRequest["params"][number]
|
|
||||||
export type HoppRESTHeader = HoppRESTRequest["headers"][number]
|
|
||||||
|
|
||||||
export const isEqualHoppRESTRequest = HoppRESTRequestEq.equals
|
export const isEqualHoppRESTRequest = HoppRESTRequestEq.equals
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,9 +87,6 @@ export const isEqualHoppRESTRequest = HoppRESTRequestEq.equals
|
|||||||
* If we fail to detect certain bits, we just resolve it to the default value
|
* If we fail to detect certain bits, we just resolve it to the default value
|
||||||
* @param x The value to extract REST Request data from
|
* @param x The value to extract REST Request data from
|
||||||
* @param defaultReq The default REST Request to source from
|
* @param defaultReq The default REST Request to source from
|
||||||
*
|
|
||||||
* @deprecated Usage of this function is no longer recommended and is only here
|
|
||||||
* for legacy reasons and will be removed
|
|
||||||
*/
|
*/
|
||||||
export function safelyExtractRESTRequest(
|
export function safelyExtractRESTRequest(
|
||||||
x: unknown,
|
x: unknown,
|
||||||
@@ -94,53 +94,40 @@ export function safelyExtractRESTRequest(
|
|||||||
): HoppRESTRequest {
|
): HoppRESTRequest {
|
||||||
const req = cloneDeep(defaultReq)
|
const req = cloneDeep(defaultReq)
|
||||||
|
|
||||||
|
// TODO: A cleaner way to do this ?
|
||||||
if (!!x && typeof x === "object") {
|
if (!!x && typeof x === "object") {
|
||||||
if ("id" in x && typeof x.id === "string") req.id = x.id
|
if (x.hasOwnProperty("v") && typeof x.v === "string")
|
||||||
|
req.v = x.v
|
||||||
|
|
||||||
if ("name" in x && typeof x.name === "string") req.name = x.name
|
if (x.hasOwnProperty("id") && typeof x.id === "string")
|
||||||
|
req.id = x.id
|
||||||
|
|
||||||
if ("method" in x && typeof x.method === "string") req.method = x.method
|
if (x.hasOwnProperty("name") && typeof x.name === "string")
|
||||||
|
req.name = x.name
|
||||||
|
|
||||||
if ("endpoint" in x && typeof x.endpoint === "string")
|
if (x.hasOwnProperty("method") && typeof x.method === "string")
|
||||||
|
req.method = x.method
|
||||||
|
|
||||||
|
if (x.hasOwnProperty("endpoint") && typeof x.endpoint === "string")
|
||||||
req.endpoint = x.endpoint
|
req.endpoint = x.endpoint
|
||||||
|
|
||||||
if ("preRequestScript" in x && typeof x.preRequestScript === "string")
|
if (x.hasOwnProperty("preRequestScript") && typeof x.preRequestScript === "string")
|
||||||
req.preRequestScript = x.preRequestScript
|
req.preRequestScript = x.preRequestScript
|
||||||
|
|
||||||
if ("testScript" in x && typeof x.testScript === "string")
|
if (x.hasOwnProperty("testScript") && typeof x.testScript === "string")
|
||||||
req.testScript = x.testScript
|
req.testScript = x.testScript
|
||||||
|
|
||||||
if ("body" in x) {
|
if (x.hasOwnProperty("body") && typeof x.body === "object" && !!x.body)
|
||||||
const result = HoppRESTReqBody.safeParse(x.body)
|
req.body = x.body as any // TODO: Deep nested checks
|
||||||
|
|
||||||
if (result.success) {
|
if (x.hasOwnProperty("auth") && typeof x.auth === "object" && !!x.auth)
|
||||||
req.body = result.data
|
req.auth = x.auth as any // TODO: Deep nested checks
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("auth" in x) {
|
if (x.hasOwnProperty("params") && Array.isArray(x.params))
|
||||||
const result = HoppRESTAuth.safeParse(x.auth)
|
req.params = x.params // TODO: Deep nested checks
|
||||||
|
|
||||||
if (result.success) {
|
if (x.hasOwnProperty("headers") && Array.isArray(x.headers))
|
||||||
req.auth = result.data
|
req.headers = x.headers // TODO: Deep nested checks
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("params" in x) {
|
|
||||||
const result = HoppRESTParams.safeParse(x.params)
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
req.params = result.data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("headers" in x) {
|
|
||||||
const result = HoppRESTHeaders.safeParse(x.headers)
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
req.headers = result.data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return req
|
return req
|
||||||
@@ -150,51 +137,105 @@ export function makeRESTRequest(
|
|||||||
x: Omit<HoppRESTRequest, "v">
|
x: Omit<HoppRESTRequest, "v">
|
||||||
): HoppRESTRequest {
|
): HoppRESTRequest {
|
||||||
return {
|
return {
|
||||||
v: RESTReqSchemaVersion,
|
|
||||||
...x,
|
...x,
|
||||||
|
v: RESTReqSchemaVersion,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultRESTRequest(): HoppRESTRequest {
|
export function isHoppRESTRequest(x: any): x is HoppRESTRequest {
|
||||||
|
return x && typeof x === "object" && "v" in x
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseRequestBody(x: any): HoppRESTReqBody {
|
||||||
|
if (x.contentType === "application/json") {
|
||||||
|
return {
|
||||||
|
contentType: "application/json",
|
||||||
|
body: x.rawParams,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
v: "1",
|
contentType: "application/json",
|
||||||
endpoint: "https://echo.hoppscotch.io",
|
body: "",
|
||||||
name: "Untitled",
|
}
|
||||||
params: [],
|
}
|
||||||
headers: [],
|
|
||||||
method: "GET",
|
export function translateToNewRequest(x: any): HoppRESTRequest {
|
||||||
auth: {
|
if (isHoppRESTRequest(x)) {
|
||||||
|
return x
|
||||||
|
} else {
|
||||||
|
// Old format
|
||||||
|
const endpoint: string = `${x?.url ?? ""}${x?.path ?? ""}`
|
||||||
|
|
||||||
|
const headers: HoppRESTHeader[] = x?.headers ?? []
|
||||||
|
|
||||||
|
// Remove old keys from params
|
||||||
|
const params: HoppRESTParam[] = (x?.params ?? []).map(
|
||||||
|
({
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
active,
|
||||||
|
}: {
|
||||||
|
key: string
|
||||||
|
value: string
|
||||||
|
active: boolean
|
||||||
|
}) => ({
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
active,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
const name = x?.name ?? "Untitled request"
|
||||||
|
const method = x?.method ?? ""
|
||||||
|
|
||||||
|
const preRequestScript = x?.preRequestScript ?? ""
|
||||||
|
const testScript = x?.testScript ?? ""
|
||||||
|
|
||||||
|
const body = parseRequestBody(x)
|
||||||
|
|
||||||
|
const auth = parseOldAuth(x)
|
||||||
|
|
||||||
|
const result: HoppRESTRequest = {
|
||||||
|
name,
|
||||||
|
endpoint,
|
||||||
|
headers,
|
||||||
|
params,
|
||||||
|
method,
|
||||||
|
preRequestScript,
|
||||||
|
testScript,
|
||||||
|
body,
|
||||||
|
auth,
|
||||||
|
v: RESTReqSchemaVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x.id) result.id = x.id
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseOldAuth(x: any): HoppRESTAuth {
|
||||||
|
if (!x.auth || x.auth === "None")
|
||||||
|
return {
|
||||||
authType: "none",
|
authType: "none",
|
||||||
authActive: true,
|
authActive: true,
|
||||||
},
|
}
|
||||||
preRequestScript: "",
|
|
||||||
testScript: "",
|
|
||||||
body: {
|
|
||||||
contentType: null,
|
|
||||||
body: null,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (x.auth === "Basic Auth")
|
||||||
* Checks if the given value is a HoppRESTRequest
|
return {
|
||||||
* @param x The value to check
|
authType: "basic",
|
||||||
*
|
authActive: true,
|
||||||
* @deprecated This function is no longer recommended and is only here for legacy reasons
|
username: x.httpUser,
|
||||||
* Use `HoppRESTRequest.is`/`HoppRESTRequest.isLatest` instead.
|
password: x.httpPassword,
|
||||||
*/
|
}
|
||||||
export function isHoppRESTRequest(x: unknown): x is HoppRESTRequest {
|
|
||||||
return HoppRESTRequest.isLatest(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (x.auth === "Bearer Token")
|
||||||
* Safely parses a value into a HoppRESTRequest.
|
return {
|
||||||
* @param x The value to check
|
authType: "bearer",
|
||||||
*
|
authActive: true,
|
||||||
* @deprecated This function is no longer recommended and is only here for
|
token: x.bearerToken,
|
||||||
* legacy reasons. Use `HoppRESTRequest.safeParse` instead.
|
}
|
||||||
*/
|
|
||||||
export function translateToNewRequest(x: unknown): HoppRESTRequest {
|
return { authType: "none", authActive: true }
|
||||||
const result = HoppRESTRequest.safeParse(x)
|
|
||||||
return result.type === "ok" ? result.value : getDefaultRESTRequest()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import { defineVersion } from "verzod"
|
|
||||||
import { z } from "zod"
|
|
||||||
|
|
||||||
export const V0_SCHEMA = z.object({
|
|
||||||
id: z.optional(z.string()), // Firebase Firestore ID
|
|
||||||
|
|
||||||
url: z.string(),
|
|
||||||
path: z.string(),
|
|
||||||
headers: z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
})
|
|
||||||
),
|
|
||||||
params: z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
})
|
|
||||||
),
|
|
||||||
name: z.string(),
|
|
||||||
method: z.string(),
|
|
||||||
preRequestScript: z.string(),
|
|
||||||
testScript: z.string(),
|
|
||||||
contentType: z.string(),
|
|
||||||
body: z.string(),
|
|
||||||
rawParams: z.optional(z.string()),
|
|
||||||
auth: z.optional(z.string()),
|
|
||||||
httpUser: z.optional(z.string()),
|
|
||||||
httpPassword: z.optional(z.string()),
|
|
||||||
bearerToken: z.optional(z.string()),
|
|
||||||
})
|
|
||||||
|
|
||||||
export default defineVersion({
|
|
||||||
initial: true,
|
|
||||||
schema: V0_SCHEMA
|
|
||||||
})
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
import { defineVersion } from "verzod"
|
|
||||||
import { z } from "zod"
|
|
||||||
|
|
||||||
import { V0_SCHEMA } from "./0"
|
|
||||||
|
|
||||||
export const FormDataKeyValue = z.object({
|
|
||||||
key: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
}).and(
|
|
||||||
z.union([
|
|
||||||
z.object({
|
|
||||||
isFile: z.literal(true),
|
|
||||||
value: z.array(z.instanceof(Blob))
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
isFile: z.literal(false),
|
|
||||||
value: z.string()
|
|
||||||
})
|
|
||||||
])
|
|
||||||
)
|
|
||||||
|
|
||||||
export type FormDataKeyValue = z.infer<typeof FormDataKeyValue>
|
|
||||||
|
|
||||||
export const HoppRESTReqBodyFormData = z.object({
|
|
||||||
contentType: z.literal("multipart/form-data"),
|
|
||||||
body: z.array(FormDataKeyValue)
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTReqBodyFormData = z.infer<typeof HoppRESTReqBodyFormData>
|
|
||||||
|
|
||||||
export const HoppRESTReqBody = z.union([
|
|
||||||
z.object({
|
|
||||||
contentType: z.literal(null),
|
|
||||||
body: z.literal(null)
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
contentType: z.literal("multipart/form-data"),
|
|
||||||
body: FormDataKeyValue
|
|
||||||
}),
|
|
||||||
z.object({
|
|
||||||
contentType: z.union([
|
|
||||||
z.literal("application/json"),
|
|
||||||
z.literal("application/ld+json"),
|
|
||||||
z.literal("application/hal+json"),
|
|
||||||
z.literal("application/vnd.api+json"),
|
|
||||||
z.literal("application/xml"),
|
|
||||||
z.literal("application/x-www-form-urlencoded"),
|
|
||||||
z.literal("text/html"),
|
|
||||||
z.literal("text/plain"),
|
|
||||||
]),
|
|
||||||
body: z.string()
|
|
||||||
})
|
|
||||||
])
|
|
||||||
|
|
||||||
export type HoppRESTReqBody = z.infer<typeof HoppRESTReqBody>
|
|
||||||
|
|
||||||
export const HoppRESTAuthNone = z.object({
|
|
||||||
authType: z.literal("none")
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTAuthNone = z.infer<typeof HoppRESTAuthNone>
|
|
||||||
|
|
||||||
export const HoppRESTAuthBasic = z.object({
|
|
||||||
authType: z.literal("basic"),
|
|
||||||
username: z.string(),
|
|
||||||
password: z.string(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTAuthBasic = z.infer<typeof HoppRESTAuthBasic>
|
|
||||||
|
|
||||||
export const HoppRESTAuthBearer = z.object({
|
|
||||||
authType: z.literal("bearer"),
|
|
||||||
token: z.string(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTAuthBearer = z.infer<typeof HoppRESTAuthBearer>
|
|
||||||
|
|
||||||
export const HoppRESTAuthOAuth2 = z.object({
|
|
||||||
authType: z.literal("oauth-2"),
|
|
||||||
token: z.string(),
|
|
||||||
oidcDiscoveryURL: z.string(),
|
|
||||||
authURL: z.string(),
|
|
||||||
accessTokenURL: z.string(),
|
|
||||||
clientID: z.string(),
|
|
||||||
scope: z.string(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTAuthOAuth2 = z.infer<typeof HoppRESTAuthOAuth2>
|
|
||||||
|
|
||||||
export const HoppRESTAuthAPIKey = z.object({
|
|
||||||
authType: z.literal("api-key"),
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
addTo: z.string(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type HoppRESTAuthAPIKey = z.infer<typeof HoppRESTAuthAPIKey>
|
|
||||||
|
|
||||||
export const HoppRESTAuth = z.discriminatedUnion("authType", [
|
|
||||||
HoppRESTAuthNone,
|
|
||||||
HoppRESTAuthBasic,
|
|
||||||
HoppRESTAuthBearer,
|
|
||||||
HoppRESTAuthOAuth2,
|
|
||||||
HoppRESTAuthAPIKey
|
|
||||||
]).and(
|
|
||||||
z.object({
|
|
||||||
authActive: z.boolean(),
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
export type HoppRESTAuth = z.infer<typeof HoppRESTAuth>
|
|
||||||
|
|
||||||
export const HoppRESTParams = z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
export type HoppRESTParams = z.infer<typeof HoppRESTParams>
|
|
||||||
|
|
||||||
export const HoppRESTHeaders = z.array(
|
|
||||||
z.object({
|
|
||||||
key: z.string(),
|
|
||||||
value: z.string(),
|
|
||||||
active: z.boolean()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
export type HoppRESTHeaders = z.infer<typeof HoppRESTHeaders>
|
|
||||||
|
|
||||||
const V1_SCHEMA = z.object({
|
|
||||||
v: z.literal("1"),
|
|
||||||
id: z.optional(z.string()), // Firebase Firestore ID
|
|
||||||
|
|
||||||
name: z.string(),
|
|
||||||
method: z.string(),
|
|
||||||
endpoint: z.string(),
|
|
||||||
params: HoppRESTParams,
|
|
||||||
headers: HoppRESTHeaders,
|
|
||||||
preRequestScript: z.string(),
|
|
||||||
testScript: z.string(),
|
|
||||||
|
|
||||||
auth: HoppRESTAuth,
|
|
||||||
|
|
||||||
body: HoppRESTReqBody
|
|
||||||
})
|
|
||||||
|
|
||||||
function parseRequestBody(x: z.infer<typeof V0_SCHEMA>): z.infer<typeof V1_SCHEMA>["body"] {
|
|
||||||
return {
|
|
||||||
contentType: "application/json",
|
|
||||||
body: x.contentType === "application/json" ? x.rawParams ?? "" : "",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parseOldAuth(x: z.infer<typeof V0_SCHEMA>): z.infer<typeof V1_SCHEMA>["auth"] {
|
|
||||||
if (!x.auth || x.auth === "None")
|
|
||||||
return {
|
|
||||||
authType: "none",
|
|
||||||
authActive: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x.auth === "Basic Auth")
|
|
||||||
return {
|
|
||||||
authType: "basic",
|
|
||||||
authActive: true,
|
|
||||||
username: x.httpUser ?? "",
|
|
||||||
password: x.httpPassword ?? "",
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x.auth === "Bearer Token")
|
|
||||||
return {
|
|
||||||
authType: "bearer",
|
|
||||||
authActive: true,
|
|
||||||
token: x.bearerToken ?? "",
|
|
||||||
}
|
|
||||||
|
|
||||||
return { authType: "none", authActive: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineVersion({
|
|
||||||
initial: false,
|
|
||||||
schema: V1_SCHEMA,
|
|
||||||
up(old: z.infer<typeof V0_SCHEMA>) {
|
|
||||||
const { url, path, headers, params, name, method, preRequestScript, testScript } = old
|
|
||||||
|
|
||||||
const endpoint = `${url}${path}`
|
|
||||||
const body = parseRequestBody(old)
|
|
||||||
const auth = parseOldAuth(old)
|
|
||||||
|
|
||||||
const result: z.infer<typeof V1_SCHEMA> = {
|
|
||||||
v: "1",
|
|
||||||
endpoint,
|
|
||||||
headers,
|
|
||||||
params,
|
|
||||||
name,
|
|
||||||
method,
|
|
||||||
preRequestScript,
|
|
||||||
testScript,
|
|
||||||
body,
|
|
||||||
auth,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (old.id) result.id = old.id
|
|
||||||
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
})
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"lib": ["esnext", "DOM"],
|
"lib": ["esnext"],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"lib": ["esnext", "DOM"],
|
"lib": ["esnext"],
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true,
|
||||||
},
|
},
|
||||||
"include": ["src/*.ts"]
|
"include": ["src/*.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
preset: "ts-jest",
|
preset: "ts-jest",
|
||||||
testEnvironment: "jsdom",
|
testEnvironment: "node",
|
||||||
collectCoverage: true,
|
collectCoverage: true,
|
||||||
setupFilesAfterEnv: ["./jest.setup.ts"],
|
setupFilesAfterEnv: ["./jest.setup.ts"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,5 @@ createHoppApp("#app", {
|
|||||||
],
|
],
|
||||||
platformFeatureFlags: {
|
platformFeatureFlags: {
|
||||||
exportAsGIST: false,
|
exportAsGIST: false,
|
||||||
hasTelemetry: false,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
VitePWA({
|
VitePWA({
|
||||||
useCredentials: true,
|
|
||||||
manifest: {
|
manifest: {
|
||||||
name: APP_INFO.name,
|
name: APP_INFO.name,
|
||||||
short_name: APP_INFO.name,
|
short_name: APP_INFO.name,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"@fontsource-variable/material-symbols-rounded": "^5.0.5",
|
"@fontsource-variable/material-symbols-rounded": "^5.0.5",
|
||||||
"@fontsource-variable/roboto-mono": "^5.0.6",
|
"@fontsource-variable/roboto-mono": "^5.0.6",
|
||||||
"@hoppscotch/vue-toasted": "^0.1.0",
|
"@hoppscotch/vue-toasted": "^0.1.0",
|
||||||
|
"@lezer/highlight": "^1.0.0",
|
||||||
"@vitejs/plugin-legacy": "^2.3.0",
|
"@vitejs/plugin-legacy": "^2.3.0",
|
||||||
"@vueuse/core": "^8.7.5",
|
"@vueuse/core": "^8.7.5",
|
||||||
"fp-ts": "^2.12.1",
|
"fp-ts": "^2.12.1",
|
||||||
@@ -80,4 +81,4 @@
|
|||||||
"./style.css": "./dist/style.css"
|
"./style.css": "./dist/style.css"
|
||||||
},
|
},
|
||||||
"types": "./dist/index.d.ts"
|
"types": "./dist/index.d.ts"
|
||||||
}
|
}
|
||||||
|
|||||||
3994
pnpm-lock.yaml
generated
3994
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user