lancer-shared 1.2.19 → 1.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +22 -8
- package/dist/constants/collections.js +14 -0
- package/dist/constants/common-questions.js +57 -0
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +18 -0
- package/dist/constants/invoice.d.ts +2 -0
- package/dist/constants/job-filter-options.js +265 -0
- package/dist/constants/job-status.js +21 -0
- package/dist/constants/mappings/countryMapping.js +120 -0
- package/dist/constants/mappings/regionMapping.js +240 -0
- package/dist/constants/routes.js +116 -0
- package/dist/constants/upwork-accounts.js +18 -0
- package/dist/index.js +4 -0
- package/dist/schemas/account/account-status.js +8 -0
- package/dist/schemas/account/bidder-account.js +35 -0
- package/dist/schemas/account/index.js +3 -0
- package/dist/schemas/account/scraper-account.js +34 -0
- package/dist/schemas/ai/ai-config.d.ts +36 -0
- package/dist/schemas/ai/ai-config.js +9 -0
- package/dist/schemas/ai/index.d.ts +3 -0
- package/dist/schemas/ai/index.js +3 -0
- package/dist/schemas/ai/proposal.d.ts +82 -0
- package/dist/schemas/ai/proposal.js +13 -0
- package/dist/schemas/ai/suitability.d.ts +37 -0
- package/dist/schemas/ai/suitability.js +14 -0
- package/dist/schemas/bid/bid-result.js +11 -0
- package/dist/schemas/bid/bid.js +35 -0
- package/dist/schemas/bid/index.js +2 -0
- package/dist/schemas/campaign/campaign-ai-metrics.js +6 -0
- package/dist/schemas/campaign/campaign-analytics.js +42 -0
- package/dist/schemas/campaign/campaign-expenses.js +6 -0
- package/dist/schemas/campaign/campaign-insights.js +31 -0
- package/dist/schemas/campaign/campaign-integrations.js +13 -0
- package/dist/schemas/campaign/campaign-job-count.js +3 -0
- package/dist/schemas/campaign/campaign.js +41 -0
- package/dist/schemas/campaign/index.js +7 -0
- package/dist/schemas/chat-message/chat-message.js +10 -0
- package/dist/schemas/chat-message/index.js +1 -0
- package/dist/schemas/config/agency-config.js +7 -0
- package/dist/schemas/config/index.js +1 -0
- package/dist/schemas/event/index.d.ts +58 -0
- package/dist/schemas/index.js +17 -0
- package/dist/schemas/invoice/index.d.ts +8 -0
- package/dist/schemas/job-filters/index.js +1 -0
- package/dist/schemas/job-filters/job-filters.js +84 -0
- package/dist/schemas/lead/index.js +173 -0
- package/dist/schemas/lead/lead-note.js +27 -0
- package/dist/schemas/lead/lead-status.js +23 -0
- package/dist/schemas/lead/nuxt.js +287 -0
- package/dist/schemas/logger/index.js +1 -0
- package/dist/schemas/logger/log-event.js +117 -0
- package/dist/schemas/organization/index.d.ts +68 -1
- package/dist/schemas/organization/index.js +70 -0
- package/dist/schemas/organization/member.js +7 -0
- package/dist/schemas/organization/organization.d.ts +118 -22
- package/dist/schemas/organization/organization.js +16 -0
- package/dist/schemas/organization/subscription.d.ts +47 -0
- package/dist/schemas/organization/subscription.js +17 -0
- package/dist/schemas/plan/index.d.ts +36 -3
- package/dist/schemas/proxy/index.js +3 -0
- package/dist/schemas/proxy/proxy-available-replacements.js +3 -0
- package/dist/schemas/proxy/proxy-country.js +249 -0
- package/dist/schemas/proxy/proxy.js +29 -0
- package/dist/schemas/saved-search/index.js +9 -0
- package/dist/schemas/scraper/index.js +2 -0
- package/dist/schemas/scraper/scrape-payload.d.ts +49 -0
- package/dist/schemas/scraper/scrape-payload.js +21 -0
- package/dist/schemas/scraper/scrape-result.js +23 -0
- package/dist/schemas/shared.js +19 -0
- package/dist/schemas/tier/index.d.ts +119 -0
- package/dist/schemas/time-filter/index.js +6 -0
- package/dist/schemas/transaction/index.js +17 -0
- package/dist/schemas/usage/index.js +18 -0
- package/dist/schemas/user/index.js +52 -0
- package/dist/types/account/account-status.js +1 -0
- package/dist/types/account/bidder-account.js +1 -0
- package/dist/types/account/index.js +3 -0
- package/dist/types/account/scraper-account.js +1 -0
- package/dist/types/ai/ai-config.d.ts +6 -0
- package/dist/types/ai/ai-config.js +1 -0
- package/dist/types/ai/index.d.ts +3 -0
- package/dist/types/ai/index.js +3 -0
- package/dist/types/ai/proposal.d.ts +10 -0
- package/dist/types/ai/proposal.js +1 -0
- package/dist/types/ai/suitability.d.ts +6 -0
- package/dist/types/ai/suitability.js +1 -0
- package/dist/types/bid/bid-result.js +1 -0
- package/dist/types/bid/bid.js +1 -0
- package/dist/types/bid/index.js +2 -0
- package/dist/types/campaign/campaign-analytics.js +1 -0
- package/dist/types/campaign/campaign-expenses.js +1 -0
- package/dist/types/campaign/campaign-insights.js +1 -0
- package/dist/types/campaign/campaign-integrations.js +1 -0
- package/dist/types/campaign/campaign-job-count.js +1 -0
- package/dist/types/campaign/campaign.js +1 -0
- package/dist/types/campaign/index.js +6 -0
- package/dist/types/chat-message/chat-message.js +1 -0
- package/dist/types/chat-message/index.js +1 -0
- package/dist/types/config/agency-config.js +1 -0
- package/dist/types/config/index.js +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/job/index.js +3 -0
- package/dist/types/job/job-note.js +1 -0
- package/dist/types/job/job-status.js +9 -0
- package/dist/types/job/nuxt.js +1 -0
- package/dist/types/job-filters/index.js +1 -0
- package/dist/types/job-filters/job-filters.js +1 -0
- package/dist/types/logger/index.js +1 -0
- package/dist/types/logger/log-event.js +1 -0
- package/dist/types/saved-search/index.js +1 -0
- package/dist/types/scraper/index.js +2 -0
- package/dist/types/scraper/scrape-payload.js +1 -0
- package/dist/types/scraper/scrape-result.js +1 -0
- package/dist/types/shared.js +1 -0
- package/dist/types/time-filter/index.js +1 -0
- package/dist/types/transaction/index.js +1 -0
- package/dist/types/usage/index.js +1 -0
- package/dist/types/user/index.js +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/try-catch.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const agentStatusSchema = z.enum([
|
|
3
|
+
"suitabilityPending",
|
|
4
|
+
"suitabilityProcessing",
|
|
5
|
+
"suitabilityComplete",
|
|
6
|
+
"suitabilityFailed",
|
|
7
|
+
"proposalProcessing",
|
|
8
|
+
"proposalComplete",
|
|
9
|
+
"proposalFailed",
|
|
10
|
+
"biddingProcessing",
|
|
11
|
+
"biddingComplete",
|
|
12
|
+
"biddingFailed",
|
|
13
|
+
"jobArchived",
|
|
14
|
+
]);
|
|
15
|
+
export const leadStatusSchema = z.enum([
|
|
16
|
+
"leads",
|
|
17
|
+
"contacted",
|
|
18
|
+
"viewed",
|
|
19
|
+
"replied",
|
|
20
|
+
"negotiations",
|
|
21
|
+
"won",
|
|
22
|
+
"lost",
|
|
23
|
+
]);
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { any, array, boolean, number, object, record, string } from "zod";
|
|
2
|
+
const segmentationDataSchema = object({
|
|
3
|
+
customValue: string().nullable(),
|
|
4
|
+
label: string(),
|
|
5
|
+
name: string(),
|
|
6
|
+
sortOrder: number(),
|
|
7
|
+
type: string(),
|
|
8
|
+
value: string(),
|
|
9
|
+
skill: any().nullable(),
|
|
10
|
+
});
|
|
11
|
+
const clientActivitySchema = object({
|
|
12
|
+
lastBuyerActivity: string(),
|
|
13
|
+
totalApplicants: number(),
|
|
14
|
+
totalHired: number(),
|
|
15
|
+
totalInvitedToInterview: number(),
|
|
16
|
+
unansweredInvites: number(),
|
|
17
|
+
invitationsSent: number(),
|
|
18
|
+
numberOfPositionsToHire: number(),
|
|
19
|
+
});
|
|
20
|
+
const annotationsSchema = object({
|
|
21
|
+
tags: array(string()),
|
|
22
|
+
});
|
|
23
|
+
const budgetSchema = object({
|
|
24
|
+
amount: number(),
|
|
25
|
+
currencyCode: string(),
|
|
26
|
+
});
|
|
27
|
+
const engagementDurationSchema = object({
|
|
28
|
+
label: string(),
|
|
29
|
+
weeks: number(),
|
|
30
|
+
});
|
|
31
|
+
const extendedBudgetInfoSchema = object({
|
|
32
|
+
hourlyBudgetMin: number().nullable(),
|
|
33
|
+
hourlyBudgetMax: number().nullable(),
|
|
34
|
+
hourlyBudgetType: string().nullable(),
|
|
35
|
+
});
|
|
36
|
+
const qualificationsSchema = object({
|
|
37
|
+
countries: any().nullable(),
|
|
38
|
+
earnings: any().nullable(),
|
|
39
|
+
groupRecno: any().nullable(),
|
|
40
|
+
languages: any().nullable(),
|
|
41
|
+
localDescription: any().nullable(),
|
|
42
|
+
localFlexibilityDescription: any().nullable(),
|
|
43
|
+
localMarket: boolean(),
|
|
44
|
+
minJobSuccessScore: number(),
|
|
45
|
+
minOdeskHours: number(),
|
|
46
|
+
onSiteType: any().nullable(),
|
|
47
|
+
prefEnglishSkill: number(),
|
|
48
|
+
regions: any().nullable(),
|
|
49
|
+
risingTalent: boolean(),
|
|
50
|
+
shouldHavePortfolio: boolean(),
|
|
51
|
+
states: any().nullable(),
|
|
52
|
+
tests: any().nullable(),
|
|
53
|
+
timezones: any().nullable(),
|
|
54
|
+
type: number(),
|
|
55
|
+
locationCheckRequired: boolean(),
|
|
56
|
+
group: any().nullable(),
|
|
57
|
+
location: any().nullable(),
|
|
58
|
+
locations: any().nullable(),
|
|
59
|
+
});
|
|
60
|
+
const jobSchema = object({
|
|
61
|
+
status: number(),
|
|
62
|
+
category: object({
|
|
63
|
+
name: string(),
|
|
64
|
+
urlSlug: string(),
|
|
65
|
+
}),
|
|
66
|
+
categoryGroup: object({
|
|
67
|
+
name: string(),
|
|
68
|
+
urlSlug: string(),
|
|
69
|
+
}),
|
|
70
|
+
budget: budgetSchema,
|
|
71
|
+
postedOn: string(),
|
|
72
|
+
publishTime: string(),
|
|
73
|
+
wasRenewed: boolean(),
|
|
74
|
+
startDate: string().nullable(),
|
|
75
|
+
deliveryDate: string().nullable(),
|
|
76
|
+
workload: string().nullable(),
|
|
77
|
+
engagementDuration: engagementDurationSchema,
|
|
78
|
+
extendedBudgetInfo: extendedBudgetInfoSchema,
|
|
79
|
+
contractorTier: number(),
|
|
80
|
+
description: string(),
|
|
81
|
+
segmentationData: array(segmentationDataSchema),
|
|
82
|
+
clientActivity: clientActivitySchema,
|
|
83
|
+
annotations: annotationsSchema,
|
|
84
|
+
uid: string(),
|
|
85
|
+
title: string(),
|
|
86
|
+
type: number(),
|
|
87
|
+
ciphertext: string(),
|
|
88
|
+
access: number(),
|
|
89
|
+
createdOn: string(),
|
|
90
|
+
hideBudget: boolean(),
|
|
91
|
+
notSureProjectDuration: boolean(),
|
|
92
|
+
notSureFreelancersToHire: boolean(),
|
|
93
|
+
notSureExperienceLevel: boolean(),
|
|
94
|
+
numberOfPositionsToHire: number(),
|
|
95
|
+
isContractToHire: boolean(),
|
|
96
|
+
attachments: array(any()),
|
|
97
|
+
isPremium: boolean(),
|
|
98
|
+
qualifications: qualificationsSchema,
|
|
99
|
+
questions: array(object({ question: string(), position: number() })),
|
|
100
|
+
durationIdV3: number(),
|
|
101
|
+
durationLabel: string(),
|
|
102
|
+
});
|
|
103
|
+
const buyerSchema = object({
|
|
104
|
+
isEnterprise: boolean(),
|
|
105
|
+
isPaymentMethodVerified: boolean(),
|
|
106
|
+
stats: object({
|
|
107
|
+
totalAssignments: number(),
|
|
108
|
+
activeAssignmentsCount: number(),
|
|
109
|
+
hoursCount: number(),
|
|
110
|
+
feedbackCount: number(),
|
|
111
|
+
score: number(),
|
|
112
|
+
totalJobsWithHires: number(),
|
|
113
|
+
totalCharges: object({
|
|
114
|
+
amount: number(),
|
|
115
|
+
}),
|
|
116
|
+
}),
|
|
117
|
+
location: object({
|
|
118
|
+
offsetFromUtcMillis: number(),
|
|
119
|
+
countryTimezone: string(),
|
|
120
|
+
city: string(),
|
|
121
|
+
country: string(),
|
|
122
|
+
}),
|
|
123
|
+
company: object({
|
|
124
|
+
isEDCReplicated: any().nullable(),
|
|
125
|
+
contractDate: string(),
|
|
126
|
+
profile: object({
|
|
127
|
+
industry: string(),
|
|
128
|
+
size: number(),
|
|
129
|
+
}),
|
|
130
|
+
name: string().nullable(),
|
|
131
|
+
}),
|
|
132
|
+
jobs: object({
|
|
133
|
+
postedCount: number(),
|
|
134
|
+
openCount: number(),
|
|
135
|
+
}),
|
|
136
|
+
avgHourlyJobsRate: object({
|
|
137
|
+
amount: number(),
|
|
138
|
+
}).nullable(),
|
|
139
|
+
});
|
|
140
|
+
const currentUserInfoSchema = object({
|
|
141
|
+
owner: boolean(),
|
|
142
|
+
freelancerInfo: object({
|
|
143
|
+
profileState: string(),
|
|
144
|
+
applied: any().nullable(),
|
|
145
|
+
devProfileCiphertext: string(),
|
|
146
|
+
hired: any().nullable(),
|
|
147
|
+
application: record(any()),
|
|
148
|
+
pendingInvite: record(any()),
|
|
149
|
+
contract: any().nullable(),
|
|
150
|
+
hourlyRate: object({
|
|
151
|
+
amount: number(),
|
|
152
|
+
}),
|
|
153
|
+
qualificationsMatches: object({
|
|
154
|
+
matches: array(object({
|
|
155
|
+
clientPreferred: string(),
|
|
156
|
+
clientPreferredLabel: string().nullable(),
|
|
157
|
+
freelancerValue: string(),
|
|
158
|
+
freelancerValueLabel: string(),
|
|
159
|
+
qualification: number(),
|
|
160
|
+
qualified: boolean(),
|
|
161
|
+
})),
|
|
162
|
+
}),
|
|
163
|
+
}),
|
|
164
|
+
});
|
|
165
|
+
const workHistorySchema = array(object({
|
|
166
|
+
isPtcJob: any().nullable(),
|
|
167
|
+
status: any().nullable(),
|
|
168
|
+
isEDCReplicated: any().nullable(),
|
|
169
|
+
startDate: string(),
|
|
170
|
+
endDate: string(),
|
|
171
|
+
totalCharge: number(),
|
|
172
|
+
totalHours: number(),
|
|
173
|
+
jobInfo: object({
|
|
174
|
+
title: string(),
|
|
175
|
+
id: any().nullable(),
|
|
176
|
+
uid: any().nullable(),
|
|
177
|
+
access: number(),
|
|
178
|
+
type: number(),
|
|
179
|
+
ciphertext: any().nullable(),
|
|
180
|
+
}),
|
|
181
|
+
contractorInfo: object({
|
|
182
|
+
contractorName: string(),
|
|
183
|
+
accessType: string(),
|
|
184
|
+
ciphertext: string(),
|
|
185
|
+
}),
|
|
186
|
+
rate: object({
|
|
187
|
+
amount: number(),
|
|
188
|
+
}).nullable(),
|
|
189
|
+
feedback: object({
|
|
190
|
+
feedbackSuppressed: boolean(),
|
|
191
|
+
score: number(),
|
|
192
|
+
comment: string(),
|
|
193
|
+
feedback_suppressed: boolean(),
|
|
194
|
+
}),
|
|
195
|
+
feedbackToClient: object({
|
|
196
|
+
feedbackSuppressed: boolean(),
|
|
197
|
+
score: number(),
|
|
198
|
+
comment: string(),
|
|
199
|
+
feedback_suppressed: boolean(),
|
|
200
|
+
}),
|
|
201
|
+
isEDCPublic: boolean(),
|
|
202
|
+
}));
|
|
203
|
+
const sandsSchema = object({
|
|
204
|
+
occupation: object({
|
|
205
|
+
freeText: string().nullable(),
|
|
206
|
+
ontologyId: string(),
|
|
207
|
+
prefLabel: string(),
|
|
208
|
+
id: string(),
|
|
209
|
+
uid: string(),
|
|
210
|
+
}),
|
|
211
|
+
ontologySkills: array(any()),
|
|
212
|
+
additionalSkills: array(object({
|
|
213
|
+
uid: string(),
|
|
214
|
+
name: string(),
|
|
215
|
+
isFreeText: boolean(),
|
|
216
|
+
})),
|
|
217
|
+
});
|
|
218
|
+
const connectsSchema = object({
|
|
219
|
+
pricing: object({
|
|
220
|
+
price: number(),
|
|
221
|
+
context: string(),
|
|
222
|
+
auctionPrice: number(),
|
|
223
|
+
}),
|
|
224
|
+
requiredConnects: number(),
|
|
225
|
+
availableConnects: number(),
|
|
226
|
+
chooseConnectsStatus: object({
|
|
227
|
+
isExplainerModalShown: boolean().nullable(),
|
|
228
|
+
}),
|
|
229
|
+
canSeeApplicantsRates: boolean(),
|
|
230
|
+
});
|
|
231
|
+
const authSchema = object({
|
|
232
|
+
canFlagOpening: boolean(),
|
|
233
|
+
canPostJob: boolean(),
|
|
234
|
+
domestic: object({
|
|
235
|
+
country: string().nullable(),
|
|
236
|
+
isInfographicTooltipAvailable: boolean(),
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
const applicationContextSchema = object({
|
|
240
|
+
freelancerAllowed: boolean(),
|
|
241
|
+
clientAllowed: boolean(),
|
|
242
|
+
userIntentEvaluation: object({
|
|
243
|
+
isDeclined: boolean(),
|
|
244
|
+
reason: string().nullable(),
|
|
245
|
+
}),
|
|
246
|
+
canApplyOnBehalfOfAgencyFreelancers: boolean(),
|
|
247
|
+
canSubmitMoreProposals: boolean(),
|
|
248
|
+
submittedProposals: any().nullable(),
|
|
249
|
+
});
|
|
250
|
+
export const nuxtStateJobSchema = object({
|
|
251
|
+
cache: boolean(),
|
|
252
|
+
job: jobSchema,
|
|
253
|
+
buyer: buyerSchema,
|
|
254
|
+
currentUserInfo: currentUserInfoSchema,
|
|
255
|
+
isVisitor: boolean(),
|
|
256
|
+
openJobs: array(any()),
|
|
257
|
+
workHistory: workHistorySchema,
|
|
258
|
+
similarJobs: array(any()),
|
|
259
|
+
sands: sandsSchema,
|
|
260
|
+
auth: authSchema,
|
|
261
|
+
applicants: object({
|
|
262
|
+
applicantsBidsStats: any().nullable(),
|
|
263
|
+
}),
|
|
264
|
+
connects: connectsSchema.nullish(),
|
|
265
|
+
enterpriseJobAdditionalInfo: record(any()),
|
|
266
|
+
applicationContext: applicationContextSchema,
|
|
267
|
+
profileMatchServiceUid: string(),
|
|
268
|
+
seo: object({
|
|
269
|
+
title: string(),
|
|
270
|
+
description: string(),
|
|
271
|
+
url: string(),
|
|
272
|
+
}),
|
|
273
|
+
teamUid: any().nullable(),
|
|
274
|
+
proposalPermissions: object({
|
|
275
|
+
freelancerAllowed: boolean(),
|
|
276
|
+
clientAllowed: boolean(),
|
|
277
|
+
}),
|
|
278
|
+
jobSlug: any().nullable(),
|
|
279
|
+
prefillWith: any().nullable(),
|
|
280
|
+
isGroupOpportunity: boolean(),
|
|
281
|
+
workLocation: any().nullable(),
|
|
282
|
+
isPhoneVerified: boolean(),
|
|
283
|
+
errorResponse: any().nullable(),
|
|
284
|
+
isApplyBlocked: boolean(),
|
|
285
|
+
hasAiInterview: boolean(),
|
|
286
|
+
talentFeePromotion: boolean().nullish(),
|
|
287
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./log-event";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { boolean, number, object, string, z } from 'zod';
|
|
2
|
+
import { jobActivityOffsetHourSchema, jobActivitySchema, jobListingSchema, } from '../lead';
|
|
3
|
+
import { regionSchema } from '../shared';
|
|
4
|
+
export const LogEventTypeEnum = z.enum([
|
|
5
|
+
// Scraper Events
|
|
6
|
+
'scraperStarted',
|
|
7
|
+
'scraperCompleted',
|
|
8
|
+
'jobScraped',
|
|
9
|
+
'jobScrapeFailed',
|
|
10
|
+
'jobsIndexed',
|
|
11
|
+
'jobDuplicateSkipped',
|
|
12
|
+
'scraperFailed',
|
|
13
|
+
'jobActivityScraped',
|
|
14
|
+
'jobActivityScrapeFailed',
|
|
15
|
+
// Feed Scraper Events
|
|
16
|
+
'feedScrapeStarted',
|
|
17
|
+
'feedScrapeCompleted',
|
|
18
|
+
'feedScrapeFailed',
|
|
19
|
+
'jobListingScraped',
|
|
20
|
+
// Job Sync & Campaign Matching
|
|
21
|
+
'jobSyncPublished',
|
|
22
|
+
'jobSyncReceived',
|
|
23
|
+
'leadsCreatedAndSynced',
|
|
24
|
+
// Suitability Events
|
|
25
|
+
'suitabilityPending',
|
|
26
|
+
'suitabilityProcessing',
|
|
27
|
+
'suitabilityComplete',
|
|
28
|
+
'suitabilityFailed',
|
|
29
|
+
'manualSuitabilityAnalyzed',
|
|
30
|
+
// Proposal Events
|
|
31
|
+
'proposalProcessing',
|
|
32
|
+
'proposalComplete',
|
|
33
|
+
'proposalFailed',
|
|
34
|
+
'manualProposalGenerated',
|
|
35
|
+
// Bidding Events
|
|
36
|
+
'biddingProcessing',
|
|
37
|
+
'biddingComplete',
|
|
38
|
+
'biddingFailed',
|
|
39
|
+
'biddingSkipped',
|
|
40
|
+
'biddingPending',
|
|
41
|
+
'biddingRetry',
|
|
42
|
+
'biddingInsufficientConnects',
|
|
43
|
+
'biddingWarningAlert',
|
|
44
|
+
// System/Generic Events
|
|
45
|
+
'errorLogged',
|
|
46
|
+
'cloudTaskRetry',
|
|
47
|
+
'manualLeadEdited',
|
|
48
|
+
'leadArchived',
|
|
49
|
+
'auditTrailLogged',
|
|
50
|
+
// Knowledge Base Events
|
|
51
|
+
'knowledgeBaseGenerationComplete',
|
|
52
|
+
'knowledgeBaseGenerationFailed',
|
|
53
|
+
// Model Chain Events
|
|
54
|
+
'modelFailed',
|
|
55
|
+
]);
|
|
56
|
+
export const logEventSchema = z.object({
|
|
57
|
+
// The type of event (use a z.enum if possible)
|
|
58
|
+
type: LogEventTypeEnum, // e.g. "suitability-failed", "proposal-generated"
|
|
59
|
+
// The service that triggered the event
|
|
60
|
+
source: z.string(), // e.g. "lancer-agents", "lancer-bidding"
|
|
61
|
+
// Optional: Allow logging non-lead events in the future
|
|
62
|
+
resourceType: z.string().default('lead'), // e.g. "lead", "campaign", "user"
|
|
63
|
+
// ID of the resource (primary entity affected)
|
|
64
|
+
resourceId: z.string().nullable(), // fallback if leadId is not applicable
|
|
65
|
+
// Lead-level metadata
|
|
66
|
+
leadId: z.string().nullable(),
|
|
67
|
+
campaignId: z.string().nullable(),
|
|
68
|
+
userId: z.string().nullable(),
|
|
69
|
+
// Reason or message for the event
|
|
70
|
+
reason: z.string().nullable(),
|
|
71
|
+
// Generic metadata (stacktrace, score, raw request, etc.)
|
|
72
|
+
metadata: z.record(z.unknown()).nullable(),
|
|
73
|
+
// Optional timestamp override
|
|
74
|
+
timestamp: z.number(),
|
|
75
|
+
});
|
|
76
|
+
export const listingScrapedEventMetadata = object({
|
|
77
|
+
listing: jobListingSchema,
|
|
78
|
+
region: regionSchema,
|
|
79
|
+
});
|
|
80
|
+
export const jobActivityScrapedEventMetadata = object({
|
|
81
|
+
activity: jobActivitySchema,
|
|
82
|
+
region: regionSchema,
|
|
83
|
+
offsetHour: jobActivityOffsetHourSchema,
|
|
84
|
+
scrapedAt: number(),
|
|
85
|
+
});
|
|
86
|
+
export const jobActivityScrapeFailedEventMetadata = object({
|
|
87
|
+
listing: jobListingSchema,
|
|
88
|
+
region: regionSchema,
|
|
89
|
+
offsetHour: jobActivityOffsetHourSchema,
|
|
90
|
+
});
|
|
91
|
+
export const feedScrapeStartedEventMetadata = object({
|
|
92
|
+
id: string(),
|
|
93
|
+
startTime: number(),
|
|
94
|
+
region: regionSchema,
|
|
95
|
+
});
|
|
96
|
+
export const feedScrapeCompletedEventMetadata = object({
|
|
97
|
+
id: string(),
|
|
98
|
+
endTime: number(),
|
|
99
|
+
region: regionSchema,
|
|
100
|
+
accountUsername: string(),
|
|
101
|
+
});
|
|
102
|
+
export const biddingCompletedEventMetadata = object({
|
|
103
|
+
biddingAmount: number(),
|
|
104
|
+
boosted: boolean(),
|
|
105
|
+
boostingAmount: number(),
|
|
106
|
+
});
|
|
107
|
+
export const biddingFailedEventMetadata = object({
|
|
108
|
+
errorType: string(),
|
|
109
|
+
errorMessage: string(),
|
|
110
|
+
context: z.string().optional(),
|
|
111
|
+
});
|
|
112
|
+
export const biddingWarningAlertEventMetadata = object({
|
|
113
|
+
warningMessage: string(),
|
|
114
|
+
});
|
|
115
|
+
export const biddingRetryEventMetadata = object({
|
|
116
|
+
errorMessage: string(),
|
|
117
|
+
});
|
|
@@ -37,6 +37,7 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
37
37
|
tierId: z.ZodEnum<["free", "premium"]>;
|
|
38
38
|
subscription: z.ZodNullable<z.ZodObject<{
|
|
39
39
|
planId: z.ZodString;
|
|
40
|
+
pendingPlanId: z.ZodNullable<z.ZodString>;
|
|
40
41
|
status: z.ZodEnum<["active", "trialing", "cancelled", "paused", "payment_pending", "payment_failed"]>;
|
|
41
42
|
startedAt: z.ZodNumber;
|
|
42
43
|
currentPeriodEnd: z.ZodNumber;
|
|
@@ -62,6 +63,16 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
62
63
|
id: string;
|
|
63
64
|
};
|
|
64
65
|
}>, "many">;
|
|
66
|
+
invoice: z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
hosted_invoice_url: z.ZodNullable<z.ZodString>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
id: string;
|
|
71
|
+
hosted_invoice_url: string | null;
|
|
72
|
+
}, {
|
|
73
|
+
id: string;
|
|
74
|
+
hosted_invoice_url: string | null;
|
|
75
|
+
}>;
|
|
65
76
|
}, "strip", z.ZodTypeAny, {
|
|
66
77
|
id: string;
|
|
67
78
|
items: {
|
|
@@ -70,6 +81,10 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
70
81
|
id: string;
|
|
71
82
|
};
|
|
72
83
|
}[];
|
|
84
|
+
invoice: {
|
|
85
|
+
id: string;
|
|
86
|
+
hosted_invoice_url: string | null;
|
|
87
|
+
};
|
|
73
88
|
}, {
|
|
74
89
|
id: string;
|
|
75
90
|
items: {
|
|
@@ -78,11 +93,16 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
78
93
|
id: string;
|
|
79
94
|
};
|
|
80
95
|
}[];
|
|
96
|
+
invoice: {
|
|
97
|
+
id: string;
|
|
98
|
+
hosted_invoice_url: string | null;
|
|
99
|
+
};
|
|
81
100
|
}>;
|
|
82
101
|
source: z.ZodEnum<["stripe", "manual"]>;
|
|
83
102
|
}, "strip", z.ZodTypeAny, {
|
|
84
103
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
85
104
|
planId: string;
|
|
105
|
+
pendingPlanId: string | null;
|
|
86
106
|
startedAt: number;
|
|
87
107
|
currentPeriodEnd: number;
|
|
88
108
|
stripe: {
|
|
@@ -93,11 +113,16 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
93
113
|
id: string;
|
|
94
114
|
};
|
|
95
115
|
}[];
|
|
116
|
+
invoice: {
|
|
117
|
+
id: string;
|
|
118
|
+
hosted_invoice_url: string | null;
|
|
119
|
+
};
|
|
96
120
|
};
|
|
97
121
|
source: "stripe" | "manual";
|
|
98
122
|
}, {
|
|
99
123
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
100
124
|
planId: string;
|
|
125
|
+
pendingPlanId: string | null;
|
|
101
126
|
startedAt: number;
|
|
102
127
|
currentPeriodEnd: number;
|
|
103
128
|
stripe: {
|
|
@@ -108,6 +133,10 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
108
133
|
id: string;
|
|
109
134
|
};
|
|
110
135
|
}[];
|
|
136
|
+
invoice: {
|
|
137
|
+
id: string;
|
|
138
|
+
hosted_invoice_url: string | null;
|
|
139
|
+
};
|
|
111
140
|
};
|
|
112
141
|
source: "stripe" | "manual";
|
|
113
142
|
}>>;
|
|
@@ -186,6 +215,7 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
186
215
|
subscription: {
|
|
187
216
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
188
217
|
planId: string;
|
|
218
|
+
pendingPlanId: string | null;
|
|
189
219
|
startedAt: number;
|
|
190
220
|
currentPeriodEnd: number;
|
|
191
221
|
stripe: {
|
|
@@ -196,6 +226,10 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
196
226
|
id: string;
|
|
197
227
|
};
|
|
198
228
|
}[];
|
|
229
|
+
invoice: {
|
|
230
|
+
id: string;
|
|
231
|
+
hosted_invoice_url: string | null;
|
|
232
|
+
};
|
|
199
233
|
};
|
|
200
234
|
source: "stripe" | "manual";
|
|
201
235
|
} | null;
|
|
@@ -229,6 +263,7 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
229
263
|
subscription: {
|
|
230
264
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
231
265
|
planId: string;
|
|
266
|
+
pendingPlanId: string | null;
|
|
232
267
|
startedAt: number;
|
|
233
268
|
currentPeriodEnd: number;
|
|
234
269
|
stripe: {
|
|
@@ -239,6 +274,10 @@ export declare const organizationSchema: z.ZodObject<{
|
|
|
239
274
|
id: string;
|
|
240
275
|
};
|
|
241
276
|
}[];
|
|
277
|
+
invoice: {
|
|
278
|
+
id: string;
|
|
279
|
+
hosted_invoice_url: string | null;
|
|
280
|
+
};
|
|
242
281
|
};
|
|
243
282
|
source: "stripe" | "manual";
|
|
244
283
|
} | null;
|
|
@@ -271,6 +310,7 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
271
310
|
tierId: z.ZodEnum<["free", "premium"]>;
|
|
272
311
|
subscription: z.ZodNullable<z.ZodObject<{
|
|
273
312
|
planId: z.ZodString;
|
|
313
|
+
pendingPlanId: z.ZodNullable<z.ZodString>;
|
|
274
314
|
status: z.ZodEnum<["active", "trialing", "cancelled", "paused", "payment_pending", "payment_failed"]>;
|
|
275
315
|
startedAt: z.ZodNumber;
|
|
276
316
|
currentPeriodEnd: z.ZodNumber;
|
|
@@ -296,6 +336,16 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
296
336
|
id: string;
|
|
297
337
|
};
|
|
298
338
|
}>, "many">;
|
|
339
|
+
invoice: z.ZodObject<{
|
|
340
|
+
id: z.ZodString;
|
|
341
|
+
hosted_invoice_url: z.ZodNullable<z.ZodString>;
|
|
342
|
+
}, "strip", z.ZodTypeAny, {
|
|
343
|
+
id: string;
|
|
344
|
+
hosted_invoice_url: string | null;
|
|
345
|
+
}, {
|
|
346
|
+
id: string;
|
|
347
|
+
hosted_invoice_url: string | null;
|
|
348
|
+
}>;
|
|
299
349
|
}, "strip", z.ZodTypeAny, {
|
|
300
350
|
id: string;
|
|
301
351
|
items: {
|
|
@@ -304,6 +354,10 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
304
354
|
id: string;
|
|
305
355
|
};
|
|
306
356
|
}[];
|
|
357
|
+
invoice: {
|
|
358
|
+
id: string;
|
|
359
|
+
hosted_invoice_url: string | null;
|
|
360
|
+
};
|
|
307
361
|
}, {
|
|
308
362
|
id: string;
|
|
309
363
|
items: {
|
|
@@ -312,11 +366,16 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
312
366
|
id: string;
|
|
313
367
|
};
|
|
314
368
|
}[];
|
|
369
|
+
invoice: {
|
|
370
|
+
id: string;
|
|
371
|
+
hosted_invoice_url: string | null;
|
|
372
|
+
};
|
|
315
373
|
}>;
|
|
316
374
|
source: z.ZodEnum<["stripe", "manual"]>;
|
|
317
375
|
}, "strip", z.ZodTypeAny, {
|
|
318
376
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
319
377
|
planId: string;
|
|
378
|
+
pendingPlanId: string | null;
|
|
320
379
|
startedAt: number;
|
|
321
380
|
currentPeriodEnd: number;
|
|
322
381
|
stripe: {
|
|
@@ -327,11 +386,16 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
327
386
|
id: string;
|
|
328
387
|
};
|
|
329
388
|
}[];
|
|
389
|
+
invoice: {
|
|
390
|
+
id: string;
|
|
391
|
+
hosted_invoice_url: string | null;
|
|
392
|
+
};
|
|
330
393
|
};
|
|
331
394
|
source: "stripe" | "manual";
|
|
332
395
|
}, {
|
|
333
396
|
status: "active" | "trialing" | "cancelled" | "paused" | "payment_pending" | "payment_failed";
|
|
334
397
|
planId: string;
|
|
398
|
+
pendingPlanId: string | null;
|
|
335
399
|
startedAt: number;
|
|
336
400
|
currentPeriodEnd: number;
|
|
337
401
|
stripe: {
|
|
@@ -342,6 +406,10 @@ export declare const createOrganizationSchema: z.ZodObject<Pick<{
|
|
|
342
406
|
id: string;
|
|
343
407
|
};
|
|
344
408
|
}[];
|
|
409
|
+
invoice: {
|
|
410
|
+
id: string;
|
|
411
|
+
hosted_invoice_url: string | null;
|
|
412
|
+
};
|
|
345
413
|
};
|
|
346
414
|
source: "stripe" | "manual";
|
|
347
415
|
}>>;
|
|
@@ -527,7 +595,6 @@ export declare const subscribePayloadSchema: z.ZodObject<{
|
|
|
527
595
|
paymentMethodId: string;
|
|
528
596
|
}>;
|
|
529
597
|
export interface Organization extends infer<typeof organizationSchema> {
|
|
530
|
-
planName?: string;
|
|
531
598
|
}
|
|
532
599
|
export type TrackUsageEventType = z.infer<typeof trackUsageEventTypeEnum>;
|
|
533
600
|
export interface TrackUsagePayloadSchema extends infer<typeof trackUsagePayloadSchema> {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { boolean, number, object, string, z } from "zod";
|
|
2
|
+
import { LogEventTypeEnum } from "../logger";
|
|
3
|
+
import { organizationSubscriptionSchema } from "./subscription";
|
|
4
|
+
export const bidConfigSchema = object({
|
|
5
|
+
agencyName: string().nullable(),
|
|
6
|
+
bidderId: string().nullable(),
|
|
7
|
+
contractorName: string().nullable(),
|
|
8
|
+
specialisedProfile: string().nullable(),
|
|
9
|
+
});
|
|
10
|
+
export const organizationTypeSchema = z.enum(["agency", "freelancer"]);
|
|
11
|
+
export const organizationTierEnum = z.enum(["free", "premium"]);
|
|
12
|
+
export const organizationLimitsSchema = object({
|
|
13
|
+
monthlyCredits: number(),
|
|
14
|
+
usedCredits: number(),
|
|
15
|
+
extraCredits: number(),
|
|
16
|
+
});
|
|
17
|
+
export const organizationBillingSchema = object({
|
|
18
|
+
stripeCustomerId: string(),
|
|
19
|
+
savedCard: boolean(),
|
|
20
|
+
creditsRemaining: number(),
|
|
21
|
+
});
|
|
22
|
+
export const organizationSchema = object({
|
|
23
|
+
id: string(),
|
|
24
|
+
name: string(),
|
|
25
|
+
type: organizationTypeSchema,
|
|
26
|
+
tierId: organizationTierEnum,
|
|
27
|
+
subscription: organizationSubscriptionSchema.nullable(),
|
|
28
|
+
bidConfig: bidConfigSchema,
|
|
29
|
+
active: boolean(),
|
|
30
|
+
limits: organizationLimitsSchema,
|
|
31
|
+
billing: organizationBillingSchema.nullable(),
|
|
32
|
+
createdAt: number(),
|
|
33
|
+
updatedAt: number(),
|
|
34
|
+
});
|
|
35
|
+
export const creditDeductionEventTypeEnum = LogEventTypeEnum.extract([
|
|
36
|
+
"suitabilityComplete",
|
|
37
|
+
"proposalComplete",
|
|
38
|
+
]);
|
|
39
|
+
export const creditDeductionPayloadSchema = object({
|
|
40
|
+
event: creditDeductionEventTypeEnum,
|
|
41
|
+
campaignId: string().nullish(),
|
|
42
|
+
});
|
|
43
|
+
export const aiConfigOldSchema = object({
|
|
44
|
+
id: string(),
|
|
45
|
+
suitabilityPrompt: string().nullable(),
|
|
46
|
+
proposalPrompt: string().nullable(),
|
|
47
|
+
questionProposalPrompt: string().nullable(),
|
|
48
|
+
knowledgeBase: string().nullable(),
|
|
49
|
+
});
|
|
50
|
+
export const aiConfigSchema = object({
|
|
51
|
+
suitabilityRules: string().nullable(),
|
|
52
|
+
coverLetterRules: string().nullable(),
|
|
53
|
+
questionRules: string().nullable(),
|
|
54
|
+
});
|
|
55
|
+
export const knowledgeBaseSchema = object({
|
|
56
|
+
about: string(),
|
|
57
|
+
caseStudies: string(),
|
|
58
|
+
});
|
|
59
|
+
export const notificationConfigSchema = object({
|
|
60
|
+
emailEnabled: boolean(),
|
|
61
|
+
discordWebhookUrl: string().nullable(),
|
|
62
|
+
slackWebhookUrl: string().nullable(),
|
|
63
|
+
});
|
|
64
|
+
export const organizationSettingsSchema = object({
|
|
65
|
+
aiConfig: aiConfigSchema,
|
|
66
|
+
knowledgeBase: knowledgeBaseSchema,
|
|
67
|
+
notifications: notificationConfigSchema,
|
|
68
|
+
});
|
|
69
|
+
export * from "./member";
|
|
70
|
+
export * from "./subscription";
|