@erxes/core-contract 0.1.0-v2.1 → 0.1.0-v2.3
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/activities.d.ts +1387 -139
- package/dist/activities.js +90 -30
- package/dist/audit.d.ts +1081 -33
- package/dist/audit.js +28 -14
- package/dist/auth.d.ts +2834 -26
- package/dist/auth.js +47 -18
- package/dist/automationRuns.d.ts +7 -9
- package/dist/automationRuns.js +12 -13
- package/dist/automations.d.ts +2443 -61
- package/dist/automations.js +41 -21
- package/dist/client.d.ts +30704 -0
- package/dist/client.js +62 -0
- package/dist/common.d.ts +0 -13
- package/dist/common.js +1 -13
- package/dist/companies.d.ts +1120 -10
- package/dist/companies.js +27 -12
- package/dist/contract/routes.json.js +17 -1
- package/dist/customerAuth.d.ts +1456 -17
- package/dist/customerAuth.js +33 -16
- package/dist/customers.d.ts +1232 -11
- package/dist/customers.js +28 -13
- package/dist/{automationDefinition.d.ts → db/src/automationDefinition.d.ts} +2 -2
- package/dist/{automationDefinition.js → db/src/automationDefinition.js} +2 -2
- package/dist/db/src/enums.js +1 -3
- package/dist/db/src/schema/automations.d.ts +1 -0
- package/dist/db/src/schema/automations.js +3 -3
- package/dist/db/src/schema/index.d.ts +3 -0
- package/dist/db/src/schema/index.js +3 -2
- package/dist/db/src/schema/leads.js +2 -2
- package/dist/db/src/schema/notes.js +92 -0
- package/dist/db/src/schema/payments.js +2 -2
- package/dist/db/src/schema/platform.js +0 -5
- package/dist/db/src/schema/plugins.js +7 -2
- package/dist/db/src/schema/transfer.js +2 -2
- package/dist/errors.d.ts +516 -0
- package/dist/errors.js +218 -0
- package/dist/events.d.ts +570 -121
- package/dist/events.js +41 -24
- package/dist/fields.d.ts +1456 -16
- package/dist/fields.js +27 -19
- package/dist/files.d.ts +761 -62
- package/dist/files.js +32 -21
- package/dist/index.d.ts +25187 -618
- package/dist/index.js +8 -7
- package/dist/leads.d.ts +1105 -21
- package/dist/leads.js +31 -13
- package/dist/notifications.d.ts +689 -48
- package/dist/notifications.js +38 -18
- package/dist/organizations.d.ts +260 -2
- package/dist/organizations.js +21 -2
- package/dist/payments.d.ts +1766 -62
- package/dist/payments.js +48 -26
- package/dist/platform.d.ts +12 -21
- package/dist/platform.js +7 -17
- package/dist/plugins.d.ts +802 -71
- package/dist/plugins.js +48 -27
- package/dist/products.d.ts +1380 -17
- package/dist/products.js +32 -16
- package/dist/roles.d.ts +560 -5
- package/dist/roles.js +20 -6
- package/dist/saas.d.ts +164 -2
- package/dist/saas.js +9 -2
- package/dist/tags.d.ts +340 -4
- package/dist/tags.js +14 -6
- package/dist/transfer.d.ts +1299 -12
- package/dist/transfer.js +32 -13
- package/dist/trash.d.ts +278 -21
- package/dist/trash.js +23 -16
- package/dist/users.d.ts +1206 -18
- package/dist/users.js +35 -13
- package/dist/values.d.ts +0 -9
- package/dist/values.js +2 -7
- package/dist/views.d.ts +396 -5
- package/dist/views.js +10 -7
- package/dist/webhooks.d.ts +765 -9
- package/dist/webhooks.js +18 -10
- package/package.json +6 -2
package/dist/transfer.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EXPORT_FORMATS, IMPORT_MATCH_KEYS, IMPORT_MODES, IMPORT_ROW_ACTIONS, IMPORT_STATUSES, TRANSFER_FIELD_GROUPS, TRANSFER_RECORD_TYPES } from "./db/src/enums.js";
|
|
2
2
|
import { exports, importRows, imports } from "./db/src/schema/transfer.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
5
|
+
import { ConditionGroup } from "./db/src/automationDefinition.js";
|
|
5
6
|
import { CursorQuery, Id, cursorPageOf, isoDate, listOf } from "./common.js";
|
|
6
7
|
import { oc } from "@orpc/contract";
|
|
7
|
-
import { createSelectSchema } from "drizzle-zod";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import { createSelectSchema } from "drizzle-zod";
|
|
9
10
|
// src/transfer.ts
|
|
10
11
|
const TransferRecordType = z.enum(TRANSFER_RECORD_TYPES);
|
|
11
12
|
/** A page of imports or exports: 50, the most the lists showed before they paged. */
|
|
@@ -113,22 +114,40 @@ const Export = createSelectSchema(exports, {
|
|
|
113
114
|
finishedAt: true
|
|
114
115
|
});
|
|
115
116
|
/** Imports from CSV or Excel (mapped, checked, run in the background, undoable) and exports of lists. */
|
|
117
|
+
const { CROSS_SITE, IMPORT_LOCKED, INVALID_COLUMNS, INVALID_MAPPING, INVALID_OPTIONS, INVALID_RECIPIENT, INVALID_TAG, LIMIT_EXCEEDED, NOT_UNDOABLE, TAG_LIMIT, UNSUPPORTED_FILE, UPLOAD_CHANGED, UPLOAD_INCOMPLETE } = ERRORS;
|
|
118
|
+
/** What these procedures answer with besides the common errors. */
|
|
119
|
+
const base = oc.errors({
|
|
120
|
+
...COMMON_ERRORS,
|
|
121
|
+
CROSS_SITE,
|
|
122
|
+
IMPORT_LOCKED,
|
|
123
|
+
INVALID_COLUMNS,
|
|
124
|
+
INVALID_MAPPING,
|
|
125
|
+
INVALID_OPTIONS,
|
|
126
|
+
INVALID_RECIPIENT,
|
|
127
|
+
INVALID_TAG,
|
|
128
|
+
LIMIT_EXCEEDED,
|
|
129
|
+
NOT_UNDOABLE,
|
|
130
|
+
TAG_LIMIT,
|
|
131
|
+
UNSUPPORTED_FILE,
|
|
132
|
+
UPLOAD_CHANGED,
|
|
133
|
+
UPLOAD_INCOMPLETE
|
|
134
|
+
});
|
|
116
135
|
const transferContract = {
|
|
117
|
-
columns:
|
|
136
|
+
columns: base.route({
|
|
118
137
|
method: "GET",
|
|
119
138
|
path: "/transfer/columns",
|
|
120
139
|
summary: "What imports can fill and exports can write, for a record type"
|
|
121
140
|
}).input(z.object({ recordType: TransferRecordType })).output(listOf(TransferColumn)),
|
|
122
|
-
imports:
|
|
141
|
+
imports: base.route({
|
|
123
142
|
method: "GET",
|
|
124
143
|
path: "/imports",
|
|
125
144
|
summary: "Imports, newest first"
|
|
126
145
|
}).input(TransferPage).output(cursorPageOf(Import)),
|
|
127
|
-
import:
|
|
146
|
+
import: base.route({
|
|
128
147
|
method: "GET",
|
|
129
148
|
path: "/imports/{id}"
|
|
130
149
|
}).input(z.object({ id: Id })).output(Import),
|
|
131
|
-
createImport:
|
|
150
|
+
createImport: base.route({
|
|
132
151
|
method: "POST",
|
|
133
152
|
path: "/imports",
|
|
134
153
|
successStatus: 201,
|
|
@@ -137,7 +156,7 @@ const transferContract = {
|
|
|
137
156
|
recordType: TransferRecordType,
|
|
138
157
|
fileId: Id
|
|
139
158
|
})).output(Import),
|
|
140
|
-
updateImport:
|
|
159
|
+
updateImport: base.route({
|
|
141
160
|
method: "PATCH",
|
|
142
161
|
path: "/imports/{id}",
|
|
143
162
|
summary: "Set the column mapping and options (before it runs); the check result is cleared"
|
|
@@ -146,22 +165,22 @@ const transferContract = {
|
|
|
146
165
|
mapping: z.record(z.string(), z.string()).optional(),
|
|
147
166
|
options: ImportOptions.partial().optional()
|
|
148
167
|
})).output(Import),
|
|
149
|
-
checkImport:
|
|
168
|
+
checkImport: base.route({
|
|
150
169
|
method: "POST",
|
|
151
170
|
path: "/imports/{id}/check",
|
|
152
171
|
summary: "A dry run: what each row would do (create, update, skip, error), changing nothing"
|
|
153
172
|
}).input(z.object({ id: Id })).output(Import),
|
|
154
|
-
startImport:
|
|
173
|
+
startImport: base.route({
|
|
155
174
|
method: "POST",
|
|
156
175
|
path: "/imports/{id}/start",
|
|
157
176
|
summary: "Run it, in the background, in batches"
|
|
158
177
|
}).input(z.object({ id: Id })).output(Import),
|
|
159
|
-
undoImport:
|
|
178
|
+
undoImport: base.route({
|
|
160
179
|
method: "POST",
|
|
161
180
|
path: "/imports/{id}/undo",
|
|
162
181
|
summary: "Remove the records it created (to the recycle bin), within 30 days; updates stay"
|
|
163
182
|
}).input(z.object({ id: Id })).output(Import),
|
|
164
|
-
importRows:
|
|
183
|
+
importRows: base.route({
|
|
165
184
|
method: "GET",
|
|
166
185
|
path: "/imports/{id}/rows",
|
|
167
186
|
summary: "Rows of an import, by what they did (errors first for the report)"
|
|
@@ -170,12 +189,12 @@ const transferContract = {
|
|
|
170
189
|
action: z.enum(IMPORT_ROW_ACTIONS).optional(),
|
|
171
190
|
limit: z.coerce.number().int().min(1).max(1e3).default(200)
|
|
172
191
|
})).output(z.object({ data: z.array(ImportRow).max(1e3) })),
|
|
173
|
-
exports:
|
|
192
|
+
exports: base.route({
|
|
174
193
|
method: "GET",
|
|
175
194
|
path: "/exports",
|
|
176
195
|
summary: "Exports, newest first"
|
|
177
196
|
}).input(TransferPage).output(cursorPageOf(Export)),
|
|
178
|
-
createExport:
|
|
197
|
+
createExport: base.route({
|
|
179
198
|
method: "POST",
|
|
180
199
|
path: "/exports",
|
|
181
200
|
successStatus: 202,
|
package/dist/trash.d.ts
CHANGED
|
@@ -7,17 +7,15 @@ export declare const TrashItem: z.ZodObject<{
|
|
|
7
7
|
}>;
|
|
8
8
|
recordId: z.ZodString;
|
|
9
9
|
label: z.ZodNullable<z.ZodString>;
|
|
10
|
+
deletedByType: z.ZodEnum<{
|
|
11
|
+
customer: "customer";
|
|
12
|
+
plugin: "plugin";
|
|
13
|
+
system: "system";
|
|
14
|
+
user: "user";
|
|
15
|
+
}>;
|
|
16
|
+
deletedBy: z.ZodNullable<z.ZodString>;
|
|
10
17
|
deletedAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
11
18
|
purgeAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
12
|
-
deletedBy: z.ZodObject<{
|
|
13
|
-
type: z.ZodEnum<{
|
|
14
|
-
customer: "customer";
|
|
15
|
-
plugin: "plugin";
|
|
16
|
-
system: "system";
|
|
17
|
-
user: "user";
|
|
18
|
-
}>;
|
|
19
|
-
id: z.ZodNullable<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
19
|
counts: z.ZodObject<{
|
|
22
20
|
tags: z.ZodInt;
|
|
23
21
|
links: z.ZodInt;
|
|
@@ -57,17 +55,15 @@ export declare const trashContract: {
|
|
|
57
55
|
}>;
|
|
58
56
|
recordId: z.ZodString;
|
|
59
57
|
label: z.ZodNullable<z.ZodString>;
|
|
58
|
+
deletedByType: z.ZodEnum<{
|
|
59
|
+
customer: "customer";
|
|
60
|
+
plugin: "plugin";
|
|
61
|
+
system: "system";
|
|
62
|
+
user: "user";
|
|
63
|
+
}>;
|
|
64
|
+
deletedBy: z.ZodNullable<z.ZodString>;
|
|
60
65
|
deletedAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
61
66
|
purgeAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
62
|
-
deletedBy: z.ZodObject<{
|
|
63
|
-
type: z.ZodEnum<{
|
|
64
|
-
customer: "customer";
|
|
65
|
-
plugin: "plugin";
|
|
66
|
-
system: "system";
|
|
67
|
-
user: "user";
|
|
68
|
-
}>;
|
|
69
|
-
id: z.ZodNullable<z.ZodString>;
|
|
70
|
-
}, z.core.$strip>;
|
|
71
67
|
counts: z.ZodObject<{
|
|
72
68
|
tags: z.ZodInt;
|
|
73
69
|
links: z.ZodInt;
|
|
@@ -85,7 +81,94 @@ export declare const trashContract: {
|
|
|
85
81
|
}, z.core.$strip>;
|
|
86
82
|
totalCount: z.ZodInt;
|
|
87
83
|
totalCapped: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
-
}, z.core.$strip>, Record<never, never>,
|
|
84
|
+
}, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
|
85
|
+
UNAUTHORIZED: {
|
|
86
|
+
status: number;
|
|
87
|
+
};
|
|
88
|
+
NOT_ALLOWED: {
|
|
89
|
+
status: number;
|
|
90
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
91
|
+
permission: z.ZodString;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
};
|
|
94
|
+
PLUGIN_ONLY: {
|
|
95
|
+
status: number;
|
|
96
|
+
};
|
|
97
|
+
MEMBERS_ONLY: {
|
|
98
|
+
status: number;
|
|
99
|
+
};
|
|
100
|
+
ORG_REQUIRED: {
|
|
101
|
+
status: number;
|
|
102
|
+
};
|
|
103
|
+
SCOPE_REQUIRED: {
|
|
104
|
+
status: number;
|
|
105
|
+
};
|
|
106
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
107
|
+
status: number;
|
|
108
|
+
};
|
|
109
|
+
ORGANIZATION_DISABLED: {
|
|
110
|
+
status: number;
|
|
111
|
+
data: z.ZodObject<{
|
|
112
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
};
|
|
115
|
+
NOT_IN_PLAN: {
|
|
116
|
+
status: number;
|
|
117
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
118
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
};
|
|
121
|
+
READ_ONLY: {
|
|
122
|
+
status: number;
|
|
123
|
+
};
|
|
124
|
+
TOO_MANY_REQUESTS: {
|
|
125
|
+
status: number;
|
|
126
|
+
};
|
|
127
|
+
INVALID_INPUT: {
|
|
128
|
+
status: number;
|
|
129
|
+
data: z.ZodObject<{
|
|
130
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
131
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
132
|
+
message: z.ZodString;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
};
|
|
136
|
+
NOT_FOUND: {
|
|
137
|
+
status: number;
|
|
138
|
+
};
|
|
139
|
+
TAKEN: {
|
|
140
|
+
status: number;
|
|
141
|
+
data: z.ZodObject<{
|
|
142
|
+
field: z.ZodString;
|
|
143
|
+
id: z.ZodOptional<z.ZodString>;
|
|
144
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
};
|
|
147
|
+
INVALID_CURSOR: {
|
|
148
|
+
status: number;
|
|
149
|
+
};
|
|
150
|
+
INVALID_REFERENCE: {
|
|
151
|
+
status: number;
|
|
152
|
+
data: z.ZodObject<{
|
|
153
|
+
field: z.ZodString;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
};
|
|
156
|
+
INVALID_FILTER: {
|
|
157
|
+
status: number;
|
|
158
|
+
};
|
|
159
|
+
FILTER_TOO_SLOW: {
|
|
160
|
+
status: number;
|
|
161
|
+
};
|
|
162
|
+
LIMIT_EXCEEDED: {
|
|
163
|
+
status: number;
|
|
164
|
+
};
|
|
165
|
+
NOTHING_TO_RETRY: {
|
|
166
|
+
status: number;
|
|
167
|
+
};
|
|
168
|
+
SUBJECT_REQUIRED: {
|
|
169
|
+
status: number;
|
|
170
|
+
};
|
|
171
|
+
}>, Record<never, never>>;
|
|
89
172
|
restore: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
90
173
|
ids: z.ZodArray<z.ZodString>;
|
|
91
174
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -94,10 +177,184 @@ export declare const trashContract: {
|
|
|
94
177
|
id: z.ZodString;
|
|
95
178
|
reason: z.ZodString;
|
|
96
179
|
}, z.core.$strip>>;
|
|
97
|
-
}, z.core.$strip>, Record<never, never>,
|
|
180
|
+
}, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
|
181
|
+
UNAUTHORIZED: {
|
|
182
|
+
status: number;
|
|
183
|
+
};
|
|
184
|
+
NOT_ALLOWED: {
|
|
185
|
+
status: number;
|
|
186
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
permission: z.ZodString;
|
|
188
|
+
}, z.core.$strip>>;
|
|
189
|
+
};
|
|
190
|
+
PLUGIN_ONLY: {
|
|
191
|
+
status: number;
|
|
192
|
+
};
|
|
193
|
+
MEMBERS_ONLY: {
|
|
194
|
+
status: number;
|
|
195
|
+
};
|
|
196
|
+
ORG_REQUIRED: {
|
|
197
|
+
status: number;
|
|
198
|
+
};
|
|
199
|
+
SCOPE_REQUIRED: {
|
|
200
|
+
status: number;
|
|
201
|
+
};
|
|
202
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
203
|
+
status: number;
|
|
204
|
+
};
|
|
205
|
+
ORGANIZATION_DISABLED: {
|
|
206
|
+
status: number;
|
|
207
|
+
data: z.ZodObject<{
|
|
208
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
};
|
|
211
|
+
NOT_IN_PLAN: {
|
|
212
|
+
status: number;
|
|
213
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
214
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
215
|
+
}, z.core.$strip>>;
|
|
216
|
+
};
|
|
217
|
+
READ_ONLY: {
|
|
218
|
+
status: number;
|
|
219
|
+
};
|
|
220
|
+
TOO_MANY_REQUESTS: {
|
|
221
|
+
status: number;
|
|
222
|
+
};
|
|
223
|
+
INVALID_INPUT: {
|
|
224
|
+
status: number;
|
|
225
|
+
data: z.ZodObject<{
|
|
226
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
227
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
228
|
+
message: z.ZodString;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
};
|
|
232
|
+
NOT_FOUND: {
|
|
233
|
+
status: number;
|
|
234
|
+
};
|
|
235
|
+
TAKEN: {
|
|
236
|
+
status: number;
|
|
237
|
+
data: z.ZodObject<{
|
|
238
|
+
field: z.ZodString;
|
|
239
|
+
id: z.ZodOptional<z.ZodString>;
|
|
240
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
};
|
|
243
|
+
INVALID_CURSOR: {
|
|
244
|
+
status: number;
|
|
245
|
+
};
|
|
246
|
+
INVALID_REFERENCE: {
|
|
247
|
+
status: number;
|
|
248
|
+
data: z.ZodObject<{
|
|
249
|
+
field: z.ZodString;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
};
|
|
252
|
+
INVALID_FILTER: {
|
|
253
|
+
status: number;
|
|
254
|
+
};
|
|
255
|
+
FILTER_TOO_SLOW: {
|
|
256
|
+
status: number;
|
|
257
|
+
};
|
|
258
|
+
LIMIT_EXCEEDED: {
|
|
259
|
+
status: number;
|
|
260
|
+
};
|
|
261
|
+
NOTHING_TO_RETRY: {
|
|
262
|
+
status: number;
|
|
263
|
+
};
|
|
264
|
+
SUBJECT_REQUIRED: {
|
|
265
|
+
status: number;
|
|
266
|
+
};
|
|
267
|
+
}>, Record<never, never>>;
|
|
98
268
|
purge: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
99
269
|
ids: z.ZodArray<z.ZodString>;
|
|
100
270
|
}, z.core.$strip>, z.ZodObject<{
|
|
101
271
|
purged: z.ZodInt;
|
|
102
|
-
}, z.core.$strip>, Record<never, never>,
|
|
272
|
+
}, z.core.$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
|
273
|
+
UNAUTHORIZED: {
|
|
274
|
+
status: number;
|
|
275
|
+
};
|
|
276
|
+
NOT_ALLOWED: {
|
|
277
|
+
status: number;
|
|
278
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
279
|
+
permission: z.ZodString;
|
|
280
|
+
}, z.core.$strip>>;
|
|
281
|
+
};
|
|
282
|
+
PLUGIN_ONLY: {
|
|
283
|
+
status: number;
|
|
284
|
+
};
|
|
285
|
+
MEMBERS_ONLY: {
|
|
286
|
+
status: number;
|
|
287
|
+
};
|
|
288
|
+
ORG_REQUIRED: {
|
|
289
|
+
status: number;
|
|
290
|
+
};
|
|
291
|
+
SCOPE_REQUIRED: {
|
|
292
|
+
status: number;
|
|
293
|
+
};
|
|
294
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
295
|
+
status: number;
|
|
296
|
+
};
|
|
297
|
+
ORGANIZATION_DISABLED: {
|
|
298
|
+
status: number;
|
|
299
|
+
data: z.ZodObject<{
|
|
300
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
301
|
+
}, z.core.$strip>;
|
|
302
|
+
};
|
|
303
|
+
NOT_IN_PLAN: {
|
|
304
|
+
status: number;
|
|
305
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
306
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
307
|
+
}, z.core.$strip>>;
|
|
308
|
+
};
|
|
309
|
+
READ_ONLY: {
|
|
310
|
+
status: number;
|
|
311
|
+
};
|
|
312
|
+
TOO_MANY_REQUESTS: {
|
|
313
|
+
status: number;
|
|
314
|
+
};
|
|
315
|
+
INVALID_INPUT: {
|
|
316
|
+
status: number;
|
|
317
|
+
data: z.ZodObject<{
|
|
318
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
319
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
320
|
+
message: z.ZodString;
|
|
321
|
+
}, z.core.$strip>>;
|
|
322
|
+
}, z.core.$strip>;
|
|
323
|
+
};
|
|
324
|
+
NOT_FOUND: {
|
|
325
|
+
status: number;
|
|
326
|
+
};
|
|
327
|
+
TAKEN: {
|
|
328
|
+
status: number;
|
|
329
|
+
data: z.ZodObject<{
|
|
330
|
+
field: z.ZodString;
|
|
331
|
+
id: z.ZodOptional<z.ZodString>;
|
|
332
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
333
|
+
}, z.core.$strip>;
|
|
334
|
+
};
|
|
335
|
+
INVALID_CURSOR: {
|
|
336
|
+
status: number;
|
|
337
|
+
};
|
|
338
|
+
INVALID_REFERENCE: {
|
|
339
|
+
status: number;
|
|
340
|
+
data: z.ZodObject<{
|
|
341
|
+
field: z.ZodString;
|
|
342
|
+
}, z.core.$strip>;
|
|
343
|
+
};
|
|
344
|
+
INVALID_FILTER: {
|
|
345
|
+
status: number;
|
|
346
|
+
};
|
|
347
|
+
FILTER_TOO_SLOW: {
|
|
348
|
+
status: number;
|
|
349
|
+
};
|
|
350
|
+
LIMIT_EXCEEDED: {
|
|
351
|
+
status: number;
|
|
352
|
+
};
|
|
353
|
+
NOTHING_TO_RETRY: {
|
|
354
|
+
status: number;
|
|
355
|
+
};
|
|
356
|
+
SUBJECT_REQUIRED: {
|
|
357
|
+
status: number;
|
|
358
|
+
};
|
|
359
|
+
}>, Record<never, never>>;
|
|
103
360
|
};
|
package/dist/trash.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTENT_TYPES } from "./db/src/enums.js";
|
|
2
2
|
import { trash } from "./db/src/schema/trash.js";
|
|
3
3
|
import "./db/src/schema/index.js";
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
4
5
|
import { CursorQuery, Id, cursorPageOf, isoDate } from "./common.js";
|
|
5
6
|
import { oc } from "@orpc/contract";
|
|
6
|
-
import { createSelectSchema } from "drizzle-zod";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
import { createSelectSchema } from "drizzle-zod";
|
|
8
9
|
// src/trash.ts
|
|
9
10
|
const TrashItem = createSelectSchema(trash, {
|
|
10
11
|
id: Id,
|
|
@@ -16,27 +17,33 @@ const TrashItem = createSelectSchema(trash, {
|
|
|
16
17
|
recordType: true,
|
|
17
18
|
recordId: true,
|
|
18
19
|
label: true,
|
|
20
|
+
/** Who deleted it: a team member (`deletedBy` = user id), a plugin (its name) or `system`. */
|
|
21
|
+
deletedByType: true,
|
|
22
|
+
deletedBy: true,
|
|
19
23
|
deletedAt: true,
|
|
20
24
|
/** When it is gone for good. */
|
|
21
25
|
purgeAt: true
|
|
22
|
-
}).extend({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
}).extend({
|
|
27
|
+
/** What comes back with it, counted in the query. */
|
|
28
|
+
counts: z.object({
|
|
29
|
+
tags: z.int(),
|
|
30
|
+
links: z.int(),
|
|
31
|
+
activities: z.int()
|
|
32
|
+
}) });
|
|
33
|
+
const { LIMIT_EXCEEDED, NOTHING_TO_RETRY, SUBJECT_REQUIRED } = ERRORS;
|
|
34
|
+
/** What these procedures answer with besides the common errors. */
|
|
35
|
+
const base = oc.errors({
|
|
36
|
+
...COMMON_ERRORS,
|
|
37
|
+
LIMIT_EXCEEDED,
|
|
38
|
+
NOTHING_TO_RETRY,
|
|
39
|
+
SUBJECT_REQUIRED
|
|
33
40
|
});
|
|
34
41
|
/**
|
|
35
42
|
* The recycle bin: deleted customers and companies stay restorable for 30
|
|
36
43
|
* days — with their tags, links and timeline — then are purged for good.
|
|
37
44
|
*/
|
|
38
45
|
const trashContract = {
|
|
39
|
-
list:
|
|
46
|
+
list: base.route({
|
|
40
47
|
method: "GET",
|
|
41
48
|
path: "/trash",
|
|
42
49
|
summary: "Deleted customers and companies, newest first (contacts.delete)"
|
|
@@ -44,7 +51,7 @@ const trashContract = {
|
|
|
44
51
|
type: z.enum(CONTENT_TYPES).optional(),
|
|
45
52
|
limit: z.coerce.number().int().min(1).max(500).default(100)
|
|
46
53
|
})).output(cursorPageOf(TrashItem)),
|
|
47
|
-
restore:
|
|
54
|
+
restore: base.route({
|
|
48
55
|
method: "POST",
|
|
49
56
|
path: "/trash/restore",
|
|
50
57
|
summary: "Bring records back with their tags, links and timeline (409 when an email or phone is taken now)"
|
|
@@ -55,7 +62,7 @@ const trashContract = {
|
|
|
55
62
|
reason: z.string()
|
|
56
63
|
}))
|
|
57
64
|
})),
|
|
58
|
-
purge:
|
|
65
|
+
purge: base.route({
|
|
59
66
|
method: "POST",
|
|
60
67
|
path: "/trash/purge",
|
|
61
68
|
summary: "Delete for good now (privacy requests; owners)"
|