@erxes/core-contract 0.1.0-v2.0 → 0.1.0-v2.2
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 +1394 -139
- package/dist/activities.js +96 -40
- package/dist/audit.d.ts +1092 -48
- package/dist/audit.js +37 -23
- package/dist/auth.d.ts +2867 -61
- package/dist/auth.js +55 -25
- package/dist/automationRuns.d.ts +12 -13
- package/dist/automationRuns.js +15 -30
- package/dist/automations.d.ts +2474 -93
- package/dist/automations.js +56 -44
- package/dist/client.d.ts +30704 -0
- package/dist/client.js +62 -0
- package/dist/common.d.ts +28 -16
- package/dist/common.js +30 -22
- package/dist/companies.d.ts +1154 -44
- package/dist/companies.js +33 -17
- package/dist/contract/routes.json.js +1810 -0
- package/dist/customerAuth.d.ts +1661 -0
- package/dist/customerAuth.js +197 -0
- package/dist/customers.d.ts +1283 -65
- package/dist/customers.js +35 -25
- package/dist/{automationDefinition.d.ts → db/src/automationDefinition.d.ts} +4 -3
- package/dist/{automationDefinition.js → db/src/automationDefinition.js} +10 -32
- package/dist/db/src/enums.d.ts +8 -0
- package/dist/db/src/enums.js +334 -0
- package/dist/db/src/schema/auditStreams.js +6 -14
- package/dist/db/src/schema/authTokens.js +4 -6
- package/dist/db/src/schema/automations.d.ts +1 -0
- package/dist/db/src/schema/automations.js +15 -31
- package/dist/db/src/schema/common.d.ts +2 -6
- package/dist/db/src/schema/common.js +1 -24
- package/dist/db/src/schema/companies.js +6 -5
- package/dist/db/src/schema/customerAuth.js +101 -0
- package/dist/db/src/schema/customers.js +6 -6
- package/dist/db/src/schema/events.js +12 -60
- package/dist/db/src/schema/fieldValues.js +2 -2
- package/dist/db/src/schema/fields.js +10 -28
- package/dist/db/src/schema/index.d.ts +3 -0
- package/dist/db/src/schema/index.js +22 -20
- package/dist/db/src/schema/leadStages.js +5 -10
- package/dist/db/src/schema/leads.js +6 -11
- package/dist/db/src/schema/notes.js +92 -0
- package/dist/db/src/schema/oauth.js +3 -3
- package/dist/db/src/schema/payments.js +13 -23
- package/dist/db/src/schema/platform.js +11 -31
- package/dist/db/src/schema/plugins.js +10 -5
- package/dist/db/src/schema/products.js +7 -8
- package/dist/db/src/schema/rateLimits.js +7 -0
- package/dist/db/src/schema/saas.js +3 -9
- package/dist/db/src/schema/tags.js +6 -5
- package/dist/db/src/schema/transfer.js +13 -33
- package/dist/db/src/schema/trash.js +6 -7
- package/dist/db/src/schema/users.js +6 -10
- package/dist/db/src/schema/views.js +5 -13
- package/dist/db/src/schema/webhooks.js +7 -14
- package/dist/db/src/table.js +16 -2
- package/dist/errors.d.ts +516 -0
- package/dist/errors.js +218 -0
- package/dist/events.d.ts +585 -140
- package/dist/events.js +57 -42
- package/dist/fields.d.ts +1478 -66
- package/dist/fields.js +33 -47
- package/dist/files.d.ts +766 -62
- package/dist/files.js +34 -22
- package/dist/index.d.ts +25707 -902
- package/dist/index.js +22 -20
- package/dist/leads.d.ts +1108 -22
- package/dist/leads.js +39 -20
- package/dist/notifications.d.ts +691 -94
- package/dist/notifications.js +45 -91
- package/dist/organizations.d.ts +263 -5
- package/dist/organizations.js +21 -2
- package/dist/payments.d.ts +1794 -120
- package/dist/payments.js +58 -60
- package/dist/platform.d.ts +12 -20
- package/dist/platform.js +8 -21
- package/dist/plugins.d.ts +808 -71
- package/dist/plugins.js +66 -35
- package/dist/products.d.ts +1411 -53
- package/dist/products.js +40 -23
- package/dist/roles.d.ts +560 -8
- package/dist/roles.js +25 -11
- package/dist/routes.d.ts +8 -0
- package/dist/routes.js +13 -0
- package/dist/saas.d.ts +164 -8
- package/dist/saas.js +14 -29
- package/dist/tags.d.ts +344 -8
- package/dist/tags.js +16 -8
- package/dist/transfer.d.ts +1361 -36
- package/dist/transfer.js +47 -49
- package/dist/trash.d.ts +299 -23
- package/dist/trash.js +27 -20
- package/dist/users.d.ts +1233 -59
- package/dist/users.js +48 -39
- package/dist/values.d.ts +150 -0
- package/dist/values.js +139 -0
- package/dist/views.d.ts +404 -13
- package/dist/views.js +18 -28
- package/dist/webhooks.d.ts +791 -29
- package/dist/webhooks.js +36 -21
- package/package.json +9 -2
- package/dist/db/src/schema/jobs.js +0 -44
package/dist/notifications.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { NOTIFICATION_PRIORITIES
|
|
1
|
+
import { NOTIFICATION_PRIORITIES } from "./db/src/enums.js";
|
|
2
|
+
import { notifications } from "./db/src/schema/platform.js";
|
|
2
3
|
import "./db/src/schema/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
5
|
+
import { NotificationDelivery } from "./values.js";
|
|
6
|
+
import { CursorQuery, Id, QueryFlag, cursorPageOf, isoDate } from "./common.js";
|
|
7
|
+
import { AppLink, DedupeKey, EntityType, EventType } from "./platform.js";
|
|
5
8
|
import { oc } from "@orpc/contract";
|
|
6
|
-
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
7
9
|
import { z } from "zod";
|
|
10
|
+
import { createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
8
11
|
// src/notifications.ts
|
|
9
12
|
const Notification = createSelectSchema(notifications, {
|
|
10
13
|
id: Id,
|
|
11
14
|
data: z.record(z.string(), z.unknown()),
|
|
15
|
+
readAt: isoDate,
|
|
12
16
|
createdAt: isoDate
|
|
13
17
|
}).pick({
|
|
14
18
|
id: true,
|
|
@@ -21,11 +25,15 @@ const Notification = createSelectSchema(notifications, {
|
|
|
21
25
|
/** Details to show when opened; core's `*.updated` kinds carry `{ changes: { field: [before, after] } }`. */
|
|
22
26
|
data: true,
|
|
23
27
|
priority: true,
|
|
28
|
+
/** The plugin's own record it is about. */
|
|
29
|
+
entityType: true,
|
|
30
|
+
entityId: true,
|
|
31
|
+
/** Who it is from: a team member (`actorId` = user id), a plugin (its name) or `system`. */
|
|
32
|
+
actorType: true,
|
|
33
|
+
actorId: true,
|
|
34
|
+
/** Null while unread. */
|
|
35
|
+
readAt: true,
|
|
24
36
|
createdAt: true
|
|
25
|
-
}).extend({
|
|
26
|
-
entity: EntityRef.nullable(),
|
|
27
|
-
actor: ActorRef,
|
|
28
|
-
read: z.boolean()
|
|
29
37
|
});
|
|
30
38
|
const NotificationInput = createUpdateSchema(notifications, {
|
|
31
39
|
kind: () => EventType,
|
|
@@ -34,7 +42,9 @@ const NotificationInput = createUpdateSchema(notifications, {
|
|
|
34
42
|
link: AppLink.optional(),
|
|
35
43
|
data: () => z.record(z.string(), z.unknown()).refine((value) => JSON.stringify(value).length <= 8e3, "at most 8 KB"),
|
|
36
44
|
priority: z.enum(NOTIFICATION_PRIORITIES).default("normal"),
|
|
37
|
-
dedupeKey: DedupeKey.optional()
|
|
45
|
+
dedupeKey: DedupeKey.optional(),
|
|
46
|
+
entityType: EntityType.optional(),
|
|
47
|
+
entityId: Id.optional()
|
|
38
48
|
}).pick({
|
|
39
49
|
/** Must start with the plugin's name: `hr.leave.requested`. */
|
|
40
50
|
kind: true,
|
|
@@ -45,17 +55,19 @@ const NotificationInput = createUpdateSchema(notifications, {
|
|
|
45
55
|
data: true,
|
|
46
56
|
priority: true,
|
|
47
57
|
/** Retry-safe: one notification per recipient and key. */
|
|
48
|
-
dedupeKey: true
|
|
58
|
+
dedupeKey: true,
|
|
59
|
+
/** The plugin's own record it is about. */
|
|
60
|
+
entityType: true,
|
|
61
|
+
entityId: true
|
|
49
62
|
}).required({
|
|
50
63
|
kind: true,
|
|
51
64
|
title: true
|
|
52
65
|
}).extend({
|
|
53
66
|
/** Team members to notify (active members of the organisation). */
|
|
54
67
|
userIds: z.array(Id).min(1).max(500),
|
|
55
|
-
entity: EntityRef.optional(),
|
|
56
68
|
/** The team member who caused it, if any (shown as the sender). */
|
|
57
69
|
actorUserId: Id.optional()
|
|
58
|
-
});
|
|
70
|
+
}).refine((value) => value.entityType === void 0 === (value.entityId === void 0), "entityType and entityId go together");
|
|
59
71
|
/**
|
|
60
72
|
* Notifications core sends itself. Members mute any of them, or a plugin's
|
|
61
73
|
* notifications by its name, in their notification settings.
|
|
@@ -82,73 +94,6 @@ const CORE_NOTIFICATION_KINDS = [
|
|
|
82
94
|
"core.export.ready",
|
|
83
95
|
"core.security.new_sign_in"
|
|
84
96
|
];
|
|
85
|
-
/** Security notices a member can't mute. */
|
|
86
|
-
const UNMUTABLE_NOTIFICATION_KINDS = [
|
|
87
|
-
"core.user.role_changed",
|
|
88
|
-
"core.user.password_set",
|
|
89
|
-
"core.security.mass_deletion",
|
|
90
|
-
"core.security.alert",
|
|
91
|
-
"core.security.new_sign_in"
|
|
92
|
-
];
|
|
93
|
-
/** Where a group of notifications goes: the inbox and email, the inbox only, or nowhere. */
|
|
94
|
-
const NotificationDelivery = z.enum([
|
|
95
|
-
"email",
|
|
96
|
-
"inbox",
|
|
97
|
-
"off"
|
|
98
|
-
]);
|
|
99
|
-
/**
|
|
100
|
-
* Core's notifications in groups a member chooses for at once (each plugin
|
|
101
|
-
* is a group of its own). `security` is always on.
|
|
102
|
-
*/
|
|
103
|
-
const CORE_NOTIFICATION_GROUPS = [
|
|
104
|
-
{
|
|
105
|
-
key: "assigned",
|
|
106
|
-
label: "Assigned to me",
|
|
107
|
-
kinds: ["core.customer.assigned", "core.company.assigned"],
|
|
108
|
-
default: "email"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
key: "records",
|
|
112
|
-
label: "Changes to records I own",
|
|
113
|
-
kinds: [
|
|
114
|
-
"core.customer.updated",
|
|
115
|
-
"core.customer.merged",
|
|
116
|
-
"core.customer.deleted",
|
|
117
|
-
"core.company.updated",
|
|
118
|
-
"core.company.merged",
|
|
119
|
-
"core.company.deleted",
|
|
120
|
-
"core.customer.activity",
|
|
121
|
-
"core.company.activity"
|
|
122
|
-
],
|
|
123
|
-
default: "inbox"
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
key: "mentions",
|
|
127
|
-
label: "Mentions",
|
|
128
|
-
kinds: ["core.note.mentioned"],
|
|
129
|
-
default: "email"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
key: "automations",
|
|
133
|
-
label: "Automations",
|
|
134
|
-
kinds: ["core.automation.message", "core.automation.failed"],
|
|
135
|
-
default: "inbox"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
key: "transfer",
|
|
139
|
-
label: "Imports and exports",
|
|
140
|
-
kinds: ["core.import.done", "core.export.ready"],
|
|
141
|
-
default: "inbox"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
key: "security",
|
|
145
|
-
label: "Security",
|
|
146
|
-
kinds: UNMUTABLE_NOTIFICATION_KINDS,
|
|
147
|
-
default: "inbox"
|
|
148
|
-
}
|
|
149
|
-
];
|
|
150
|
-
/** The group a notification belongs to: a core group, or the plugin that sent it. */
|
|
151
|
-
const notificationGroupOf = (source, kind) => source === "core" ? CORE_NOTIFICATION_GROUPS.find((group) => group.kinds.includes(kind))?.key ?? "records" : source;
|
|
152
97
|
const NotificationGroupSetting = z.object({
|
|
153
98
|
key: z.string(),
|
|
154
99
|
label: z.string(),
|
|
@@ -165,21 +110,30 @@ const NotificationSettings = z.object({
|
|
|
165
110
|
/** Desktop notifications in this member's browsers (each browser also asks permission). */
|
|
166
111
|
browser: z.boolean()
|
|
167
112
|
});
|
|
168
|
-
const
|
|
169
|
-
/**
|
|
113
|
+
const { ALWAYS_ON, INVALID_ACTOR, INVALID_OWNER, INVALID_RECIPIENT, INVALID_TYPE } = ERRORS;
|
|
114
|
+
/** What these procedures answer with besides the common errors. */
|
|
115
|
+
const base = oc.errors({
|
|
116
|
+
...COMMON_ERRORS,
|
|
117
|
+
/** The signed-in member's inbox. Plugins create notifications with `create`. */
|
|
118
|
+
ALWAYS_ON,
|
|
119
|
+
INVALID_ACTOR,
|
|
120
|
+
INVALID_OWNER,
|
|
121
|
+
INVALID_RECIPIENT,
|
|
122
|
+
INVALID_TYPE
|
|
123
|
+
});
|
|
170
124
|
const notificationsContract = {
|
|
171
|
-
list:
|
|
125
|
+
list: base.route({
|
|
172
126
|
method: "GET",
|
|
173
127
|
path: "/notifications",
|
|
174
128
|
summary: "My notifications, newest first"
|
|
175
129
|
}).input(CursorQuery.extend({
|
|
176
|
-
unread:
|
|
130
|
+
unread: QueryFlag.optional(),
|
|
177
131
|
source: z.string().trim().max(40).optional(),
|
|
178
|
-
priority: z.enum(
|
|
132
|
+
priority: z.enum(NOTIFICATION_PRIORITIES).optional(),
|
|
179
133
|
/** A kind, or a prefix ending in `.` or `*` (`core.customer.`). */
|
|
180
134
|
kind: z.string().trim().max(100).optional()
|
|
181
135
|
})).output(cursorPageOf(Notification)),
|
|
182
|
-
unreadCount:
|
|
136
|
+
unreadCount: base.route({
|
|
183
137
|
method: "GET",
|
|
184
138
|
path: "/notifications/unread-count",
|
|
185
139
|
summary: "My unread notifications, in total and per inbox (core and each plugin); `source` for one inbox"
|
|
@@ -187,7 +141,7 @@ const notificationsContract = {
|
|
|
187
141
|
count: z.int(),
|
|
188
142
|
bySource: z.record(z.string(), z.int())
|
|
189
143
|
})),
|
|
190
|
-
markRead:
|
|
144
|
+
markRead: base.route({
|
|
191
145
|
method: "POST",
|
|
192
146
|
path: "/notifications/read",
|
|
193
147
|
summary: "Mark some (`ids`), one inbox’s (`source`) or all of my notifications read, or unread with `read: false`"
|
|
@@ -196,17 +150,17 @@ const notificationsContract = {
|
|
|
196
150
|
source: z.string().trim().max(40).optional(),
|
|
197
151
|
read: z.boolean().default(true)
|
|
198
152
|
})).output(z.object({ updated: z.int() })),
|
|
199
|
-
remove:
|
|
153
|
+
remove: base.route({
|
|
200
154
|
method: "DELETE",
|
|
201
155
|
path: "/notifications/{id}",
|
|
202
156
|
summary: "Remove one of my notifications"
|
|
203
157
|
}).input(z.object({ id: Id })).output(z.object({ ok: z.literal(true) })),
|
|
204
|
-
settings:
|
|
158
|
+
settings: base.route({
|
|
205
159
|
method: "GET",
|
|
206
160
|
path: "/notifications/settings",
|
|
207
161
|
summary: "My notification settings"
|
|
208
162
|
}).output(NotificationSettings),
|
|
209
|
-
updateSettings:
|
|
163
|
+
updateSettings: base.route({
|
|
210
164
|
method: "PUT",
|
|
211
165
|
path: "/notifications/settings",
|
|
212
166
|
summary: "Where each group of notifications goes, and the email and browser switches"
|
|
@@ -215,7 +169,7 @@ const notificationsContract = {
|
|
|
215
169
|
email: z.boolean().optional(),
|
|
216
170
|
browser: z.boolean().optional()
|
|
217
171
|
})).output(NotificationSettings),
|
|
218
|
-
create:
|
|
172
|
+
create: base.route({
|
|
219
173
|
method: "POST",
|
|
220
174
|
path: "/notifications",
|
|
221
175
|
successStatus: 201,
|
|
@@ -225,4 +179,4 @@ const notificationsContract = {
|
|
|
225
179
|
skipped: z.int()
|
|
226
180
|
}))
|
|
227
181
|
};
|
|
228
|
-
export {
|
|
182
|
+
export { CORE_NOTIFICATION_KINDS, Notification, NotificationGroupSetting, NotificationInput, NotificationSettings, notificationsContract };
|
package/dist/organizations.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const Organization: z.ZodObject<{
|
|
|
5
5
|
name: z.ZodString;
|
|
6
6
|
country: z.ZodNullable<z.ZodString>;
|
|
7
7
|
currency: z.ZodString;
|
|
8
|
-
createdAt: z.ZodISODateTime
|
|
8
|
+
createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
9
9
|
}, {
|
|
10
10
|
out: {};
|
|
11
11
|
in: {};
|
|
@@ -26,11 +26,140 @@ export declare const organizationsContract: {
|
|
|
26
26
|
name: z.ZodString;
|
|
27
27
|
country: z.ZodNullable<z.ZodString>;
|
|
28
28
|
currency: z.ZodString;
|
|
29
|
-
createdAt: z.ZodISODateTime
|
|
29
|
+
createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
30
30
|
}, {
|
|
31
31
|
out: {};
|
|
32
32
|
in: {};
|
|
33
|
-
}>, Record<never, never>,
|
|
33
|
+
}>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
|
|
34
|
+
UNAUTHORIZED: {
|
|
35
|
+
status: number;
|
|
36
|
+
};
|
|
37
|
+
NOT_ALLOWED: {
|
|
38
|
+
status: number;
|
|
39
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
permission: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
};
|
|
43
|
+
PLUGIN_ONLY: {
|
|
44
|
+
status: number;
|
|
45
|
+
};
|
|
46
|
+
MEMBERS_ONLY: {
|
|
47
|
+
status: number;
|
|
48
|
+
};
|
|
49
|
+
ORG_REQUIRED: {
|
|
50
|
+
status: number;
|
|
51
|
+
};
|
|
52
|
+
SCOPE_REQUIRED: {
|
|
53
|
+
status: number;
|
|
54
|
+
};
|
|
55
|
+
SERVICE_TOKEN_REQUIRED: {
|
|
56
|
+
status: number;
|
|
57
|
+
};
|
|
58
|
+
ORGANIZATION_DISABLED: {
|
|
59
|
+
status: number;
|
|
60
|
+
data: z.ZodObject<{
|
|
61
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
};
|
|
64
|
+
NOT_IN_PLAN: {
|
|
65
|
+
status: number;
|
|
66
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
manageUrl: z.ZodNullable<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
};
|
|
70
|
+
READ_ONLY: {
|
|
71
|
+
status: number;
|
|
72
|
+
};
|
|
73
|
+
TOO_MANY_REQUESTS: {
|
|
74
|
+
status: number;
|
|
75
|
+
};
|
|
76
|
+
INVALID_INPUT: {
|
|
77
|
+
status: number;
|
|
78
|
+
data: z.ZodObject<{
|
|
79
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
80
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
|
|
81
|
+
message: z.ZodString;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
};
|
|
85
|
+
NOT_FOUND: {
|
|
86
|
+
status: number;
|
|
87
|
+
};
|
|
88
|
+
TAKEN: {
|
|
89
|
+
status: number;
|
|
90
|
+
data: z.ZodObject<{
|
|
91
|
+
field: z.ZodString;
|
|
92
|
+
id: z.ZodOptional<z.ZodString>;
|
|
93
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
};
|
|
96
|
+
INVALID_CURSOR: {
|
|
97
|
+
status: number;
|
|
98
|
+
};
|
|
99
|
+
INVALID_REFERENCE: {
|
|
100
|
+
status: number;
|
|
101
|
+
data: z.ZodObject<{
|
|
102
|
+
field: z.ZodString;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
};
|
|
105
|
+
INVALID_FILTER: {
|
|
106
|
+
status: number;
|
|
107
|
+
};
|
|
108
|
+
FILTER_TOO_SLOW: {
|
|
109
|
+
status: number;
|
|
110
|
+
};
|
|
111
|
+
BEYOND_OWN_PERMISSIONS: {
|
|
112
|
+
status: number;
|
|
113
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
};
|
|
117
|
+
BUILTIN_ROLE: {
|
|
118
|
+
status: number;
|
|
119
|
+
};
|
|
120
|
+
FIXED_ROLE: {
|
|
121
|
+
status: number;
|
|
122
|
+
};
|
|
123
|
+
INVALID_CLIENT: {
|
|
124
|
+
status: number;
|
|
125
|
+
};
|
|
126
|
+
INVALID_SUBDOMAIN: {
|
|
127
|
+
status: number;
|
|
128
|
+
};
|
|
129
|
+
LAST_OPEN_STAGE: {
|
|
130
|
+
status: number;
|
|
131
|
+
};
|
|
132
|
+
LEAD_STAGE_IN_USE: {
|
|
133
|
+
status: number;
|
|
134
|
+
data: z.ZodObject<{
|
|
135
|
+
count: z.ZodInt;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
};
|
|
138
|
+
NAMESPACE_REQUIRED: {
|
|
139
|
+
status: number;
|
|
140
|
+
};
|
|
141
|
+
NOT_INSTALLED: {
|
|
142
|
+
status: number;
|
|
143
|
+
};
|
|
144
|
+
OWNER_ONLY_PERMISSION: {
|
|
145
|
+
status: number;
|
|
146
|
+
data: z.ZodObject<{
|
|
147
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
};
|
|
150
|
+
ROLE_IN_USE: {
|
|
151
|
+
status: number;
|
|
152
|
+
};
|
|
153
|
+
ROLE_NOT_FOUND: {
|
|
154
|
+
status: number;
|
|
155
|
+
};
|
|
156
|
+
UNKNOWN_PERMISSION: {
|
|
157
|
+
status: number;
|
|
158
|
+
data: z.ZodObject<{
|
|
159
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
};
|
|
162
|
+
}>, Record<never, never>>;
|
|
34
163
|
update: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<z.ZodObject<{
|
|
35
164
|
name: z.ZodOptional<z.ZodString>;
|
|
36
165
|
country: z.ZodOptional<z.ZodString & z.ZodType<"AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AN" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW", string, z.core.$ZodTypeInternals<"AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AN" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "XK" | "YE" | "YT" | "ZA" | "ZM" | "ZW", string>>>;
|
|
@@ -44,9 +173,138 @@ export declare const organizationsContract: {
|
|
|
44
173
|
name: z.ZodString;
|
|
45
174
|
country: z.ZodNullable<z.ZodString>;
|
|
46
175
|
currency: z.ZodString;
|
|
47
|
-
createdAt: z.ZodISODateTime
|
|
176
|
+
createdAt: z.ZodCodec<z.ZodDate, z.ZodISODateTime>;
|
|
48
177
|
}, {
|
|
49
178
|
out: {};
|
|
50
179
|
in: {};
|
|
51
|
-
}>, Record<never, never>,
|
|
180
|
+
}>, 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
|
+
BEYOND_OWN_PERMISSIONS: {
|
|
259
|
+
status: number;
|
|
260
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
261
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
262
|
+
}, z.core.$strip>>;
|
|
263
|
+
};
|
|
264
|
+
BUILTIN_ROLE: {
|
|
265
|
+
status: number;
|
|
266
|
+
};
|
|
267
|
+
FIXED_ROLE: {
|
|
268
|
+
status: number;
|
|
269
|
+
};
|
|
270
|
+
INVALID_CLIENT: {
|
|
271
|
+
status: number;
|
|
272
|
+
};
|
|
273
|
+
INVALID_SUBDOMAIN: {
|
|
274
|
+
status: number;
|
|
275
|
+
};
|
|
276
|
+
LAST_OPEN_STAGE: {
|
|
277
|
+
status: number;
|
|
278
|
+
};
|
|
279
|
+
LEAD_STAGE_IN_USE: {
|
|
280
|
+
status: number;
|
|
281
|
+
data: z.ZodObject<{
|
|
282
|
+
count: z.ZodInt;
|
|
283
|
+
}, z.core.$strip>;
|
|
284
|
+
};
|
|
285
|
+
NAMESPACE_REQUIRED: {
|
|
286
|
+
status: number;
|
|
287
|
+
};
|
|
288
|
+
NOT_INSTALLED: {
|
|
289
|
+
status: number;
|
|
290
|
+
};
|
|
291
|
+
OWNER_ONLY_PERMISSION: {
|
|
292
|
+
status: number;
|
|
293
|
+
data: z.ZodObject<{
|
|
294
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
295
|
+
}, z.core.$strip>;
|
|
296
|
+
};
|
|
297
|
+
ROLE_IN_USE: {
|
|
298
|
+
status: number;
|
|
299
|
+
};
|
|
300
|
+
ROLE_NOT_FOUND: {
|
|
301
|
+
status: number;
|
|
302
|
+
};
|
|
303
|
+
UNKNOWN_PERMISSION: {
|
|
304
|
+
status: number;
|
|
305
|
+
data: z.ZodObject<{
|
|
306
|
+
permissions: z.ZodArray<z.ZodString>;
|
|
307
|
+
}, z.core.$strip>;
|
|
308
|
+
};
|
|
309
|
+
}>, Record<never, never>>;
|
|
52
310
|
};
|
package/dist/organizations.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { organizations } from "./db/src/schema/organizations.js";
|
|
2
2
|
import "./db/src/schema/index.js";
|
|
3
|
+
import { COMMON_ERRORS, ERRORS } from "./errors.js";
|
|
3
4
|
import { Id, isoDate } from "./common.js";
|
|
4
5
|
import { Country, Currency } from "./money.js";
|
|
5
6
|
import { oc } from "@orpc/contract";
|
|
@@ -29,13 +30,31 @@ const OrganizationRegion = OrganizationFields.pick({
|
|
|
29
30
|
country: true,
|
|
30
31
|
currency: true
|
|
31
32
|
});
|
|
33
|
+
const { BEYOND_OWN_PERMISSIONS, BUILTIN_ROLE, FIXED_ROLE, INVALID_CLIENT, INVALID_SUBDOMAIN, LAST_OPEN_STAGE, LEAD_STAGE_IN_USE, NAMESPACE_REQUIRED, NOT_INSTALLED, OWNER_ONLY_PERMISSION, ROLE_IN_USE, ROLE_NOT_FOUND, UNKNOWN_PERMISSION } = ERRORS;
|
|
34
|
+
/** What these procedures answer with besides the common errors. */
|
|
35
|
+
const base = oc.errors({
|
|
36
|
+
...COMMON_ERRORS,
|
|
37
|
+
BEYOND_OWN_PERMISSIONS,
|
|
38
|
+
BUILTIN_ROLE,
|
|
39
|
+
FIXED_ROLE,
|
|
40
|
+
INVALID_CLIENT,
|
|
41
|
+
INVALID_SUBDOMAIN,
|
|
42
|
+
LAST_OPEN_STAGE,
|
|
43
|
+
LEAD_STAGE_IN_USE,
|
|
44
|
+
NAMESPACE_REQUIRED,
|
|
45
|
+
NOT_INSTALLED,
|
|
46
|
+
OWNER_ONLY_PERMISSION,
|
|
47
|
+
ROLE_IN_USE,
|
|
48
|
+
ROLE_NOT_FOUND,
|
|
49
|
+
UNKNOWN_PERMISSION
|
|
50
|
+
});
|
|
32
51
|
const organizationsContract = {
|
|
33
|
-
current:
|
|
52
|
+
current: base.route({
|
|
34
53
|
method: "GET",
|
|
35
54
|
path: "/organization",
|
|
36
55
|
summary: "The organisation of the signed-in member or the plugin token"
|
|
37
56
|
}).output(Organization),
|
|
38
|
-
update:
|
|
57
|
+
update: base.route({
|
|
39
58
|
method: "PATCH",
|
|
40
59
|
path: "/organization",
|
|
41
60
|
summary: "Rename the organisation or change its country and currency. Products and invoices keep the currency they were made in; a new country without a currency also sets the country's currency"
|