@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/audit.js
CHANGED
|
@@ -2,12 +2,12 @@ import { AUDIT_STREAM_STARTS } from "./db/src/enums.js";
|
|
|
2
2
|
import { auditLogs } from "./db/src/schema/platform.js";
|
|
3
3
|
import { auditStreams } from "./db/src/schema/auditStreams.js";
|
|
4
4
|
import "./db/src/schema/index.js";
|
|
5
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
5
6
|
import { AuditStreamFormat } from "./values.js";
|
|
6
7
|
import { CursorQuery, Id, cursorPageOf, isoDate, listOf } from "./common.js";
|
|
7
|
-
import { ActorRef } from "./platform.js";
|
|
8
8
|
import { oc } from "@orpc/contract";
|
|
9
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
9
|
import { z } from "zod";
|
|
10
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
11
11
|
// src/audit.ts
|
|
12
12
|
const AuditEntry = createSelectSchema(auditLogs, {
|
|
13
13
|
id: Id,
|
|
@@ -16,6 +16,9 @@ const AuditEntry = createSelectSchema(auditLogs, {
|
|
|
16
16
|
createdAt: isoDate
|
|
17
17
|
}).pick({
|
|
18
18
|
id: true,
|
|
19
|
+
/** A team member (`actorId` = user id), a plugin (its name) or `system`. */
|
|
20
|
+
actorType: true,
|
|
21
|
+
actorId: true,
|
|
19
22
|
/** `<record>.<verb>`: `customer.deleted`, `user.role_changed`, `auth.signed_in`. */
|
|
20
23
|
action: true,
|
|
21
24
|
targetType: true,
|
|
@@ -29,7 +32,7 @@ const AuditEntry = createSelectSchema(auditLogs, {
|
|
|
29
32
|
/** `core` or the plugin that recorded it. */
|
|
30
33
|
source: true,
|
|
31
34
|
createdAt: true
|
|
32
|
-
})
|
|
35
|
+
});
|
|
33
36
|
const StreamUrl = z.string().trim().check(z.url()).max(2e3).refine((value) => /^https?:\/\//.test(value), "an http(s) address");
|
|
34
37
|
/** A header the log service needs (`DD-API-KEY`, `Authorization: Splunk …`); its value is write-only. */
|
|
35
38
|
const AuthHeader = z.object({
|
|
@@ -67,8 +70,19 @@ const StreamFields = createUpdateSchema(auditStreams, {
|
|
|
67
70
|
format: true,
|
|
68
71
|
status: true
|
|
69
72
|
});
|
|
73
|
+
const { INVALID_ACTOR, INVALID_OWNER, INVALID_RECIPIENT, INVALID_TYPE, INVALID_URL, LIMIT_EXCEEDED } = ERRORS;
|
|
74
|
+
/** What these procedures answer with besides the common errors. */
|
|
75
|
+
const base = oc.errors({
|
|
76
|
+
...COMMON_ERRORS,
|
|
77
|
+
INVALID_ACTOR,
|
|
78
|
+
INVALID_OWNER,
|
|
79
|
+
INVALID_RECIPIENT,
|
|
80
|
+
INVALID_TYPE,
|
|
81
|
+
INVALID_URL,
|
|
82
|
+
LIMIT_EXCEEDED
|
|
83
|
+
});
|
|
70
84
|
const auditContract = {
|
|
71
|
-
list:
|
|
85
|
+
list: base.route({
|
|
72
86
|
method: "GET",
|
|
73
87
|
path: "/audit",
|
|
74
88
|
summary: "Audit log, newest first (owners and admins)"
|
|
@@ -88,7 +102,7 @@ const auditContract = {
|
|
|
88
102
|
})).output(cursorPageOf(AuditEntry).extend({
|
|
89
103
|
/** `totalCount` stopped counting at this many. */
|
|
90
104
|
totalCapped: z.boolean() })),
|
|
91
|
-
record:
|
|
105
|
+
record: base.route({
|
|
92
106
|
method: "POST",
|
|
93
107
|
path: "/audit",
|
|
94
108
|
successStatus: 201,
|
|
@@ -105,7 +119,7 @@ totalCapped: z.boolean() })),
|
|
|
105
119
|
ip: z.string().trim().max(64).optional(),
|
|
106
120
|
userAgent: z.string().trim().max(500).optional()
|
|
107
121
|
})).min(1).max(100) })).output(z.object({ recorded: z.int() })),
|
|
108
|
-
verify:
|
|
122
|
+
verify: base.route({
|
|
109
123
|
method: "GET",
|
|
110
124
|
path: "/audit/verify",
|
|
111
125
|
summary: "Check the audit log’s hash chain: has any entry been changed or removed? (owners and admins)"
|
|
@@ -126,7 +140,7 @@ totalCapped: z.boolean() })),
|
|
|
126
140
|
mismatchAt: z.int().nullable()
|
|
127
141
|
})
|
|
128
142
|
})),
|
|
129
|
-
checkpoints:
|
|
143
|
+
checkpoints: base.route({
|
|
130
144
|
method: "GET",
|
|
131
145
|
path: "/audit/checkpoints",
|
|
132
146
|
summary: "Signed checkpoints of the audit chain (JWS, ES256; keys at /core/v1/.well-known/jwks.json), to keep outside erxes (owners and admins)"
|
|
@@ -140,7 +154,7 @@ totalCapped: z.boolean() })),
|
|
|
140
154
|
signature: z.string(),
|
|
141
155
|
createdAt: isoDate()
|
|
142
156
|
})).max(1e3) })),
|
|
143
|
-
settings:
|
|
157
|
+
settings: base.route({
|
|
144
158
|
method: "GET",
|
|
145
159
|
path: "/settings/audit",
|
|
146
160
|
summary: "How long the audit log keeps entries"
|
|
@@ -148,7 +162,7 @@ totalCapped: z.boolean() })),
|
|
|
148
162
|
retentionDays: z.int(),
|
|
149
163
|
maxRetentionDays: z.int()
|
|
150
164
|
})),
|
|
151
|
-
updateSettings:
|
|
165
|
+
updateSettings: base.route({
|
|
152
166
|
method: "PUT",
|
|
153
167
|
path: "/settings/audit",
|
|
154
168
|
summary: "Change audit retention (owners)"
|
|
@@ -156,12 +170,12 @@ totalCapped: z.boolean() })),
|
|
|
156
170
|
retentionDays: z.int(),
|
|
157
171
|
maxRetentionDays: z.int()
|
|
158
172
|
})),
|
|
159
|
-
streams:
|
|
173
|
+
streams: base.route({
|
|
160
174
|
method: "GET",
|
|
161
175
|
path: "/audit/streams",
|
|
162
176
|
summary: "Where the audit log is streamed (owners)"
|
|
163
177
|
}).output(listOf(AuditStream)),
|
|
164
|
-
createStream:
|
|
178
|
+
createStream: base.route({
|
|
165
179
|
method: "POST",
|
|
166
180
|
path: "/audit/streams",
|
|
167
181
|
successStatus: 201,
|
|
@@ -178,18 +192,18 @@ totalCapped: z.boolean() })),
|
|
|
178
192
|
stream: AuditStream,
|
|
179
193
|
secret: z.string()
|
|
180
194
|
})),
|
|
181
|
-
updateStream:
|
|
195
|
+
updateStream: base.route({
|
|
182
196
|
method: "PATCH",
|
|
183
197
|
path: "/audit/streams/{id}"
|
|
184
198
|
}).input(StreamFields.extend({
|
|
185
199
|
id: Id,
|
|
186
200
|
authHeader: AuthHeader.nullable().optional()
|
|
187
201
|
})).output(AuditStream),
|
|
188
|
-
removeStream:
|
|
202
|
+
removeStream: base.route({
|
|
189
203
|
method: "DELETE",
|
|
190
204
|
path: "/audit/streams/{id}"
|
|
191
205
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
192
|
-
testStream:
|
|
206
|
+
testStream: base.route({
|
|
193
207
|
method: "POST",
|
|
194
208
|
path: "/audit/streams/{id}/test",
|
|
195
209
|
summary: "Send one test entry now and report the answer"
|