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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
"esbenp.prettier-vscode",
"mikestead.dotenv",
"prisma.prisma",
"vscode-icons-team.vscode-icons",
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"ms-playwright.playwright",
"wayou.vscode-todo-highlight",
"orta.vscode-jest",
"firsttris.vscode-jest-runner"
"wayou.vscode-todo-highlight"
]
}
12 changes: 6 additions & 6 deletions apps/api/src/app/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const routeDefinition = {
getCsrfToken: {
controllerFn: () => getCsrfToken,
validators: {
query: z.record(z.any()),
query: z.record(z.string(), z.any()),
hasSourceOrg: false,
},
},
Expand All @@ -86,29 +86,29 @@ export const routeDefinition = {
validators: {
params: z.object({ provider: OauthProviderTypeSchema }),
query: z.object({ returnUrl: z.string().nullish(), isAccountLink: z.literal('true').nullish() }),
body: z.object({ csrfToken: z.string(), callbackUrl: z.string().url() }),
body: z.object({ csrfToken: z.string(), callbackUrl: z.url() }),
hasSourceOrg: false,
},
},
callback: {
controllerFn: () => callback,
validators: {
query: z.record(z.any()),
query: z.record(z.string(), z.any()),
params: z.object({ provider: ProviderKeysSchema }),
body: z.union([
z.discriminatedUnion('action', [
z.object({
action: z.literal('login'),
csrfToken: z.string(),
captchaToken: z.string().nullish(),
email: z.string().email().min(5).max(255).toLowerCase(),
email: z.email().min(5).max(255).toLowerCase(),
password: z.string().min(8).max(255),
}),
z.object({
action: z.literal('register'),
csrfToken: z.string(),
captchaToken: z.string().nullish(),
email: z.string().email().min(5).max(255).toLowerCase(),
email: z.email().min(5).max(255).toLowerCase(),
name: z.string().min(1).max(255).trim(),
password: z.string().min(8).max(255),
}),
Expand Down Expand Up @@ -162,7 +162,7 @@ export const routeDefinition = {
controllerFn: () => validatePasswordReset,
validators: {
body: z.object({
email: z.string().email().toLowerCase(),
email: z.email().toLowerCase(),
token: z.string(),
password: z.string(),
csrfToken: z.string(),
Expand Down
7 changes: 3 additions & 4 deletions apps/api/src/app/controllers/data-sync.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import { createRoute } from '../utils/route.utils';

// FIXME: TEMPORARY UNTIL ALL CLIENTS HAVE BEEN BACKFILLED
export const SyncRecordOperationSchemaFillHashedKey = z
.object({
.looseObject({
key: z.string(),
hashedKey: z.string().optional(),
data: z.record(z.unknown()),
data: z.record(z.string(), z.unknown()),
})
.passthrough()
.array()
.transform((records) => {
return SyncRecordOperationSchema.array()
Expand Down Expand Up @@ -61,7 +60,7 @@ export const routeDefinition = {
controllerFn: () => push,
validators: {
query: z.object({
clientId: z.string().uuid(),
clientId: z.uuid(),
updatedAt: z
.string()
.regex(REGEX.ISO_DATE)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/desktop-app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const routeDefinition = {
controllerFn: () => initSession,
validators: {
query: z.object({
deviceId: z.string().uuid(),
deviceId: z.uuid(),
}),
hasSourceOrg: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const routeDefinition = {
controllerFn: () => updateOrganization,
validators: {
params: z.object({
id: z.string().uuid(),
id: z.uuid(),
}),
body: z.object({
name: z.string(),
Expand All @@ -38,7 +38,7 @@ export const routeDefinition = {
controllerFn: () => deleteOrganization,
validators: {
params: z.object({
id: z.string().uuid(),
id: z.uuid(),
}),
hasSourceOrg: false,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/oauth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const routeDefinition = {
salesforceOauthCallback: {
controllerFn: () => salesforceOauthCallback,
validators: {
query: z.record(z.any()),
query: z.record(z.string(), z.any()),
hasSourceOrg: false,
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/orgs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const routeDefinition = {
uniqueId: z.string().min(1),
}),
body: z.object({
jetstreamOrganizationId: z.string().uuid().nullish(),
jetstreamOrganizationId: z.uuid().nullish(),
}),
hasSourceOrg: false,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/controllers/web-extension.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const routeDefinition = {
controllerFn: () => initSession,
validators: {
query: z.object({
deviceId: z.string().uuid(),
deviceId: z.uuid(),
}),
hasSourceOrg: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ const FormSchema = z
})
.superRefine((data, ctx) => {
if (data.password !== data.confirmPassword) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
ctx.issues.push({
code: 'custom',
message: 'Passwords do not match',
path: ['confirmPassword'],
input: '',
});
}
});
Expand Down
6 changes: 3 additions & 3 deletions apps/jetstream-desktop/src/config/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ const envSchema = z.object({
.optional()
.transform((value) => value ?? 'production'),
CLIENT_URL: z.string(),
SERVER_URL: z.string().url(),
SERVER_URL: z.url(),
// TODO: allow updating this in the app
SFDC_API_VERSION: z.string().regex(/^[0-9]{2,4}\.[0-9]$/),
DESKTOP_SFDC_CLIENT_ID: z.string().min(1),
DESKTOP_SFDC_CALLBACK_URL: z.string().url(),
DESKTOP_SFDC_CALLBACK_URL: z.url(),
});

const parseResults = envSchema.safeParse({
Expand All @@ -73,7 +73,7 @@ const parseResults = envSchema.safeParse({

if (!parseResults.success) {
console.error(`❌ ${chalk.red('Error parsing environment variables:')}
${chalk.yellow(JSON.stringify(parseResults.error.flatten().fieldErrors, null, 2))}
${chalk.yellow(JSON.stringify(z.treeifyError(parseResults.error), null, 2))}
`);
process.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const routeDefinition = {
validators: {
body: z.object({
name: z.string(),
description: z.string().optional().nullable().default(null),
description: z.string().optional().nullable().prefault(null),
}),
hasSourceOrg: false,
},
Expand All @@ -23,11 +23,11 @@ export const routeDefinition = {
controllerFn: () => updateOrganization,
validators: {
params: z.object({
id: z.string().uuid(),
id: z.uuid(),
}),
body: z.object({
name: z.string(),
description: z.string().optional().nullable().default(null),
description: z.string().optional().nullable().prefault(null),
}),
hasSourceOrg: false,
},
Expand All @@ -36,7 +36,7 @@ export const routeDefinition = {
controllerFn: () => deleteOrganization,
validators: {
params: z.object({
id: z.string().uuid(),
id: z.uuid(),
}),
hasSourceOrg: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const routeDefinition = {
uniqueId: z.string().min(1),
}),
body: z.object({
jetstreamOrganizationId: z.string().uuid().nullish().default(null),
jetstreamOrganizationId: z.uuid().nullish().default(null),
}),
hasSourceOrg: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ const FormSchema = z
})
.superRefine((data, ctx) => {
if (data.password !== data.confirmPassword) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
ctx.issues.push({
code: 'custom',
message: 'Passwords do not match',
path: ['confirmPassword'],
input: '',
});
}
});
Expand Down
9 changes: 5 additions & 4 deletions apps/landing/components/auth/LoginOrSignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ const LoginSchema = z.object({
action: z.literal('login'),
csrfToken: z.string(),
captchaToken: z.string(),
email: z.string().email({ message: 'A valid email address is required' }).min(5).max(255).trim(),
email: z.email().min(5).max(255).trim(),
password: PasswordSchema,
});

const RegisterSchema = LoginSchema.omit({ action: true }).extend({
action: z.literal('register'),
name: z.string().min(1, { message: 'Name is required' }).max(255, { message: 'Name must be at most 255 characters' }),
name: z.string().min(1, { error: 'Name is required' }).max(255, { error: 'Name must be at most 255 characters' }),
confirmPassword: PasswordSchema,
});

const FormSchema = z.discriminatedUnion('action', [LoginSchema, RegisterSchema]).superRefine((data, ctx) => {
if (data.action === 'register') {
if (data.password !== data.confirmPassword) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
ctx.issues.push({
code: 'custom',
message: 'Passwords do not match',
path: ['confirmPassword'],
input: '',
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/landing/components/auth/PasswordResetInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Captcha } from './Captcha';
const FormSchema = z.object({
csrfToken: z.string(),
captchaToken: z.string(),
email: z.string().email({ message: 'A valid email address is required' }).min(5).max(255).trim(),
email: z.email({ error: 'A valid email address is required' }).min(5).max(255).trim(),
});

type Form = z.infer<typeof FormSchema>;
Expand Down
5 changes: 3 additions & 2 deletions apps/landing/components/auth/PasswordResetVerify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ const FormSchema = z
})
.superRefine((data, ctx) => {
if (data.password !== data.confirmPassword) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
ctx.issues.push({
code: 'custom',
message: 'Passwords do not match',
path: ['confirmPassword'],
input: '',
});
}
});
Expand Down
6 changes: 3 additions & 3 deletions apps/landing/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { z } from 'zod';

export const PasswordSchema = z
.string()
.min(1, { message: 'Password is required' })
.min(8, { message: 'Password must be at least 8 characters' })
.max(255, { message: 'Password must be at most 255 characters' });
.min(1, { error: 'Password is required' })
.min(8, { error: 'Password must be at least 8 characters' })
.max(255, { error: 'Password must be at most 255 characters' });

export interface AnalyticSummaryItem {
type: 'LOAD_SUMMARY' | 'QUERY_SUMMARY';
Expand Down
8 changes: 4 additions & 4 deletions libs/api-config/src/lib/env-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const envSchema = z.object({
})
.nullish(),
EXAMPLE_USER_PASSWORD: z.string().nullish(),
EXAMPLE_USER_FULL_PROFILE: z.record(z.any()).nullish(),
EXAMPLE_USER_FULL_PROFILE: z.record(z.string(), z.any()).nullish(),
IS_LOCAL_DOCKER: booleanSchema,
// SYSTEM
NODE_ENV: z
Expand Down Expand Up @@ -134,7 +134,7 @@ const envSchema = z.object({
.transform((val) => val || null),
JETSTREAM_POSTGRES_DBURI: z.string(),
JETSTREAM_SERVER_DOMAIN: z.string(),
JETSTREAM_SERVER_URL: z.string().url(),
JETSTREAM_SERVER_URL: z.url(),
JETSTREAM_CLIENT_URL: z.string(),
PRISMA_DEBUG: booleanSchema,
COMETD_DEBUG: z.enum(['error', 'warn', 'info', 'debug']).optional(),
Expand Down Expand Up @@ -191,7 +191,7 @@ const envSchema = z.object({
SFDC_API_VERSION: z.string().regex(/^[0-9]{2,4}\.[0-9]$/),
SFDC_CONSUMER_SECRET: z.string().min(1),
SFDC_CONSUMER_KEY: z.string().min(1),
SFDC_CALLBACK_URL: z.string().url(),
SFDC_CALLBACK_URL: z.url(),
/**
* Google OAuth2
* Allows google drive configuration
Expand Down Expand Up @@ -239,7 +239,7 @@ const parseResults = envSchema.safeParse({

if (!parseResults.success) {
console.error(`❌ ${chalk.red('Error parsing environment variables:')}
${chalk.yellow(JSON.stringify(parseResults.error.flatten().fieldErrors, null, 2))}
${chalk.yellow(JSON.stringify(z.treeifyError(parseResults.error), null, 2))}
`);
process.exit(1);
}
Expand Down
4 changes: 3 additions & 1 deletion libs/api-types/src/lib/api-metadata.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const DeployMetadataRequestSchema = z.object({
export type DeployMetadataRequest = z.infer<typeof DeployMetadataRequestSchema>;

export const RetrievePackageFromLisMetadataResultsRequestSchema = z.record(
z.string(),
z
.object({
fullName: z.string(),
Expand Down Expand Up @@ -63,14 +64,15 @@ export type CheckRetrieveStatusAndRedeployRequest = z.infer<typeof CheckRetrieve

export const GetPackageXmlSchema = z.object({
metadata: z.record(
z.string(),
z
.object({
fullName: z.string(),
namespacePrefix: z.string().nullish(),
})
.array()
), // TODO: define metadata type
otherFields: z.record(z.string()).nullish(),
otherFields: z.record(z.string(), z.string()).nullish(),
});
export type GetPackageXml = z.infer<typeof GetPackageXmlSchema>;

Expand Down
2 changes: 1 addition & 1 deletion libs/api-types/src/lib/api-misc.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const SalesforceApiRequestSchema = z.object({
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
isTooling: z.boolean().nullish(),
body: z.any().nullish(),
headers: z.record(z.string()).nullish(),
headers: z.record(z.string(), z.string()).nullish(),
options: z
.object({
responseType: z.enum(['json', 'text']).nullish().default('json'),
Expand Down
2 changes: 1 addition & 1 deletion libs/api-types/src/lib/api-shared.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const DeployOptionsSchema = z
}
return record;
},
{ message: 'RunSpecifiedTests requires specified tests to be provided' }
{ error: 'RunSpecifiedTests requires specified tests to be provided' }
)
.transform((record) => {
if (record.testLevel !== 'RunSpecifiedTests' && record.runTests) {
Expand Down
Loading
Loading