@erxes/plugin-sdk 0.1.0-v2.1 → 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/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PluginManifest, coreContract } from "@erxes/core-contract";
2
+ import { z } from "zod";
2
3
  import { ContractRouterClient } from "@orpc/contract";
3
4
  export type CoreClient = ContractRouterClient<typeof coreContract>;
4
5
  export interface CoreClientOptions {
@@ -19,9 +20,201 @@ export declare const createCoreClient: (options: CoreClientOptions) => {
19
20
  /** Declares the plugin's UI, API, scopes, permissions and events. Call at startup. */
20
21
  registerManifest: (manifest: PluginManifest) => import("@orpc/client").ClientPromiseResult<{
21
22
  ok: true;
22
- }, Error>;
23
+ }, import("@orpc/contract").ErrorFromErrorMap<import("@orpc/contract").MergedErrorMap<Record<never, never>, {
24
+ UNAUTHORIZED: {
25
+ status: number;
26
+ };
27
+ NOT_ALLOWED: {
28
+ status: number;
29
+ data: z.ZodOptional<z.ZodObject<{
30
+ permission: z.ZodString;
31
+ }, z.core.$strip>>;
32
+ };
33
+ PLUGIN_ONLY: {
34
+ status: number;
35
+ };
36
+ MEMBERS_ONLY: {
37
+ status: number;
38
+ };
39
+ ORG_REQUIRED: {
40
+ status: number;
41
+ };
42
+ SCOPE_REQUIRED: {
43
+ status: number;
44
+ };
45
+ SERVICE_TOKEN_REQUIRED: {
46
+ status: number;
47
+ };
48
+ ORGANIZATION_DISABLED: {
49
+ status: number;
50
+ data: z.ZodObject<{
51
+ manageUrl: z.ZodNullable<z.ZodString>;
52
+ }, z.core.$strip>;
53
+ };
54
+ NOT_IN_PLAN: {
55
+ status: number;
56
+ data: z.ZodOptional<z.ZodObject<{
57
+ manageUrl: z.ZodNullable<z.ZodString>;
58
+ }, z.core.$strip>>;
59
+ };
60
+ READ_ONLY: {
61
+ status: number;
62
+ };
63
+ TOO_MANY_REQUESTS: {
64
+ status: number;
65
+ };
66
+ INVALID_INPUT: {
67
+ status: number;
68
+ data: z.ZodObject<{
69
+ issues: z.ZodArray<z.ZodObject<{
70
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
71
+ message: z.ZodString;
72
+ }, z.core.$strip>>;
73
+ }, z.core.$strip>;
74
+ };
75
+ NOT_FOUND: {
76
+ status: number;
77
+ };
78
+ TAKEN: {
79
+ status: number;
80
+ data: z.ZodObject<{
81
+ field: z.ZodString;
82
+ id: z.ZodOptional<z.ZodString>;
83
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
84
+ }, z.core.$strip>;
85
+ };
86
+ INVALID_CURSOR: {
87
+ status: number;
88
+ };
89
+ INVALID_REFERENCE: {
90
+ status: number;
91
+ data: z.ZodObject<{
92
+ field: z.ZodString;
93
+ }, z.core.$strip>;
94
+ };
95
+ INVALID_FILTER: {
96
+ status: number;
97
+ };
98
+ FILTER_TOO_SLOW: {
99
+ status: number;
100
+ };
101
+ CROSS_SITE: {
102
+ status: number;
103
+ };
104
+ INVALID_CLIENT: {
105
+ status: number;
106
+ };
107
+ LIMIT_EXCEEDED: {
108
+ status: number;
109
+ };
110
+ NAMESPACE_REQUIRED: {
111
+ status: number;
112
+ };
113
+ NOT_INSTALLED: {
114
+ status: number;
115
+ };
116
+ PLUGIN_NOT_FOUND: {
117
+ status: number;
118
+ };
119
+ }>>>;
23
120
  /** Tells the plugin's open UIs that topics changed (needs `live:write`). */
24
121
  signal: (orgId: string, topics: string[], userIds?: string[]) => import("@orpc/client").ClientPromiseResult<{
25
122
  ok: true;
26
- }, Error>;
123
+ }, import("@orpc/contract").ErrorFromErrorMap<import("@orpc/contract").MergedErrorMap<Record<never, never>, {
124
+ UNAUTHORIZED: {
125
+ status: number;
126
+ };
127
+ NOT_ALLOWED: {
128
+ status: number;
129
+ data: z.ZodOptional<z.ZodObject<{
130
+ permission: z.ZodString;
131
+ }, z.core.$strip>>;
132
+ };
133
+ PLUGIN_ONLY: {
134
+ status: number;
135
+ };
136
+ MEMBERS_ONLY: {
137
+ status: number;
138
+ };
139
+ ORG_REQUIRED: {
140
+ status: number;
141
+ };
142
+ SCOPE_REQUIRED: {
143
+ status: number;
144
+ };
145
+ SERVICE_TOKEN_REQUIRED: {
146
+ status: number;
147
+ };
148
+ ORGANIZATION_DISABLED: {
149
+ status: number;
150
+ data: z.ZodObject<{
151
+ manageUrl: z.ZodNullable<z.ZodString>;
152
+ }, z.core.$strip>;
153
+ };
154
+ NOT_IN_PLAN: {
155
+ status: number;
156
+ data: z.ZodOptional<z.ZodObject<{
157
+ manageUrl: z.ZodNullable<z.ZodString>;
158
+ }, z.core.$strip>>;
159
+ };
160
+ READ_ONLY: {
161
+ status: number;
162
+ };
163
+ TOO_MANY_REQUESTS: {
164
+ status: number;
165
+ };
166
+ INVALID_INPUT: {
167
+ status: number;
168
+ data: z.ZodObject<{
169
+ issues: z.ZodArray<z.ZodObject<{
170
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodInt]>>;
171
+ message: z.ZodString;
172
+ }, z.core.$strip>>;
173
+ }, z.core.$strip>;
174
+ };
175
+ NOT_FOUND: {
176
+ status: number;
177
+ };
178
+ TAKEN: {
179
+ status: number;
180
+ data: z.ZodObject<{
181
+ field: z.ZodString;
182
+ id: z.ZodOptional<z.ZodString>;
183
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
184
+ }, z.core.$strip>;
185
+ };
186
+ INVALID_CURSOR: {
187
+ status: number;
188
+ };
189
+ INVALID_REFERENCE: {
190
+ status: number;
191
+ data: z.ZodObject<{
192
+ field: z.ZodString;
193
+ }, z.core.$strip>;
194
+ };
195
+ INVALID_FILTER: {
196
+ status: number;
197
+ };
198
+ FILTER_TOO_SLOW: {
199
+ status: number;
200
+ };
201
+ CROSS_SITE: {
202
+ status: number;
203
+ };
204
+ INVALID_CLIENT: {
205
+ status: number;
206
+ };
207
+ LIMIT_EXCEEDED: {
208
+ status: number;
209
+ };
210
+ NAMESPACE_REQUIRED: {
211
+ status: number;
212
+ };
213
+ NOT_INSTALLED: {
214
+ status: number;
215
+ };
216
+ PLUGIN_NOT_FOUND: {
217
+ status: number;
218
+ };
219
+ }>>>;
27
220
  };
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * Payments (scopes `payments:write`, `payments:read`; subscribe to `core.payment.*`):
11
11
  *
12
12
  * const invoice = await core.forOrg(orgId).payments.createInvoice({
13
- * amount: 150000, description: 'Order #12', reference: { type: 'order', id: order.id },
13
+ * amount: 150000, description: 'Order #12', referenceType: 'order', referenceId: order.id,
14
14
  * metadata: { orderId: order.id }, dedupeKey: `order:${order.id}`,
15
15
  * }); // show invoice.payment.qrImage / links to the payer
16
16
  * app.post('/events', express.text({ type: '*\/*' }), async (req, res) => {
package/dist/verify.d.ts CHANGED
@@ -52,31 +52,23 @@ export declare const DeliveredEvent: z.ZodObject<{
52
52
  source: z.ZodString;
53
53
  type: z.ZodString;
54
54
  version: z.ZodInt;
55
+ subjectType: z.ZodNullable<z.ZodEnum<{
56
+ company: "company";
57
+ customer: "customer";
58
+ }>>;
59
+ subjectId: z.ZodNullable<z.ZodString>;
60
+ entityType: z.ZodNullable<z.ZodString>;
61
+ entityId: z.ZodNullable<z.ZodString>;
62
+ actorType: z.ZodEnum<{
63
+ customer: "customer";
64
+ plugin: "plugin";
65
+ system: "system";
66
+ user: "user";
67
+ }>;
68
+ actorId: z.ZodNullable<z.ZodString>;
55
69
  payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
56
70
  summary: z.ZodNullable<z.ZodString>;
57
71
  link: z.ZodNullable<z.ZodString>;
58
- subject: z.ZodNullable<z.ZodObject<{
59
- type: z.ZodEnum<{
60
- company: "company";
61
- customer: "customer";
62
- }>;
63
- id: z.ZodString;
64
- }, z.core.$strip>>;
65
- entity: z.ZodNullable<z.ZodObject<{
66
- type: z.ZodString;
67
- id: z.ZodString;
68
- }, z.core.$strip>>;
69
- actor: z.ZodObject<{
70
- type: z.ZodEnum<{
71
- customer: "customer";
72
- plugin: "plugin";
73
- system: "system";
74
- user: "user";
75
- }>;
76
- id: z.ZodNullable<z.ZodString>;
77
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
- avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
- }, z.core.$strip>;
80
72
  occurredAt: z.ZodISODateTime;
81
73
  createdAt: z.ZodISODateTime;
82
74
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/plugin-sdk",
3
- "version": "0.1.0-v2.1",
3
+ "version": "0.1.0-v2.2",
4
4
  "private": false,
5
5
  "description": "For erxes plugin servers: a typed core client with automatic plugin tokens, and verification of members' plugin session tokens",
6
6
  "license": "AGPL-3.0-only",
@@ -31,7 +31,7 @@
31
31
  "@orpc/openapi-client": "1.16.2",
32
32
  "jose": "^6.2.17",
33
33
  "zod": "^4.6.7",
34
- "@erxes/core-contract": "0.1.0-v2.1"
34
+ "@erxes/core-contract": "0.1.0-v2.2"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsdown"