@kanvas/openclaw-plugin 0.1.0

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.
@@ -0,0 +1,199 @@
1
+ export class InventoryService {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async searchProducts(search, first = 10) {
7
+ const query = `
8
+ query SearchProducts($first: Int, $search: String) {
9
+ products(first: $first, search: $search) {
10
+ data {
11
+ id
12
+ uuid
13
+ name
14
+ slug
15
+ is_published
16
+ created_at
17
+ status { name }
18
+ warehouses { id name }
19
+ }
20
+ }
21
+ }
22
+ `;
23
+ return this.client.query(query, { first, search });
24
+ }
25
+ async getProduct(id) {
26
+ const query = `
27
+ query GetProduct($first: Int, $where: QueryProductsWhereWhereConditions) {
28
+ products(first: $first, where: $where) {
29
+ data {
30
+ id
31
+ uuid
32
+ name
33
+ slug
34
+ description
35
+ is_published
36
+ status { id name }
37
+ categories { id name }
38
+ warehouses { id name }
39
+ variants(includeUnpublished: true) {
40
+ id
41
+ uuid
42
+ name
43
+ sku
44
+ }
45
+ }
46
+ }
47
+ }
48
+ `;
49
+ return this.client.query(query, {
50
+ first: 1,
51
+ where: [{ column: "ID", operator: "EQ", value: id }],
52
+ });
53
+ }
54
+ async listVariants(first = 25, where) {
55
+ const query = `
56
+ query Variants($first: Int, $where: QueryVariantsWhereWhereConditions) {
57
+ variants(first: $first, where: $where) {
58
+ data {
59
+ id
60
+ uuid
61
+ name
62
+ sku
63
+ ean
64
+ barcode
65
+ is_published
66
+ status { id name }
67
+ product {
68
+ id
69
+ uuid
70
+ name
71
+ }
72
+ channels {
73
+ name
74
+ warehouses_id
75
+ discounted_price
76
+ price
77
+ channels_id
78
+ is_published
79
+ }
80
+ warehouses {
81
+ quantity
82
+ price
83
+ cost
84
+ warehouseinfo {
85
+ id
86
+ name
87
+ location
88
+ total_products
89
+ }
90
+ }
91
+ attributes {
92
+ id
93
+ name
94
+ value
95
+ }
96
+ }
97
+ }
98
+ }
99
+ `;
100
+ return this.client.query(query, { first, where });
101
+ }
102
+ async listWarehouses(first = 50, where) {
103
+ const query = `
104
+ query Warehouses($first: Int, $where: QueryWarehousesWhereWhereConditions) {
105
+ warehouses(first: $first, where: $where) {
106
+ data {
107
+ id
108
+ uuid
109
+ name
110
+ is_default
111
+ is_published
112
+ location
113
+ total_products
114
+ regions {
115
+ name
116
+ currencies {
117
+ id
118
+ code
119
+ currency
120
+ }
121
+ }
122
+ company {
123
+ id
124
+ name
125
+ }
126
+ }
127
+ }
128
+ }
129
+ `;
130
+ return this.client.query(query, { first, where });
131
+ }
132
+ async listChannels(first = 50, where) {
133
+ const query = `
134
+ query Channels($first: Int, $where: QueryChannelsWhereWhereConditions) {
135
+ channels(first: $first, where: $where) {
136
+ data {
137
+ id
138
+ uuid
139
+ name
140
+ slug
141
+ is_default
142
+ is_published
143
+ companies {
144
+ id
145
+ name
146
+ }
147
+ regions {
148
+ id
149
+ name
150
+ }
151
+ }
152
+ }
153
+ }
154
+ `;
155
+ return this.client.query(query, { first, where });
156
+ }
157
+ async listCategories(first = 50, where) {
158
+ const query = `
159
+ query Categories($first: Int, $where: QueryCategoriesWhereWhereConditions) {
160
+ categories(first: $first, where: $where) {
161
+ data {
162
+ id
163
+ uuid
164
+ name
165
+ slug
166
+ code
167
+ total_products
168
+ is_published
169
+ companies {
170
+ id
171
+ name
172
+ }
173
+ }
174
+ }
175
+ }
176
+ `;
177
+ return this.client.query(query, { first, where });
178
+ }
179
+ async listStatuses(first = 50, where) {
180
+ const query = `
181
+ query Statuses($first: Int, $where: QueryStatusWhereWhereConditions) {
182
+ status(first: $first, where: $where) {
183
+ data {
184
+ id
185
+ name
186
+ slug
187
+ is_default
188
+ is_published
189
+ company {
190
+ id
191
+ name
192
+ }
193
+ }
194
+ }
195
+ }
196
+ `;
197
+ return this.client.query(query, { first, where });
198
+ }
199
+ }
@@ -0,0 +1,57 @@
1
+ export class OrdersService {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async searchOrders(search, first = 10) {
7
+ const query = `
8
+ query SearchOrders($first: Int!, $search: String) {
9
+ orders(first: $first, search: $search) {
10
+ data {
11
+ id
12
+ uuid
13
+ order_number
14
+ status
15
+ created_at
16
+ fulfillment_status
17
+ total_net_amount
18
+ total_gross_amount
19
+ order_status { id name slug }
20
+ }
21
+ }
22
+ }
23
+ `;
24
+ return this.client.query(query, { first, search });
25
+ }
26
+ async getOrder(id) {
27
+ const query = `
28
+ query GetOrder($first: Int!, $where: QueryOrdersWhereWhereConditions) {
29
+ orders(first: $first, where: $where) {
30
+ data {
31
+ id
32
+ uuid
33
+ order_number
34
+ status
35
+ currency
36
+ created_at
37
+ fulfillment_status
38
+ payment_status
39
+ order_status { id name slug }
40
+ people { id uuid name }
41
+ items(includeAllItems: true) {
42
+ id
43
+ uuid
44
+ product_name
45
+ product_sku
46
+ quantity
47
+ }
48
+ }
49
+ }
50
+ }
51
+ `;
52
+ return this.client.query(query, {
53
+ first: 1,
54
+ where: [{ column: "ID", operator: "EQ", value: id }],
55
+ });
56
+ }
57
+ }
@@ -0,0 +1,374 @@
1
+ export class SocialService {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ async createMessage(input) {
7
+ const mutation = `
8
+ mutation CreateMessage($input: MessageInput!) {
9
+ createMessage(input: $input) {
10
+ id
11
+ uuid
12
+ slug
13
+ message
14
+ is_public
15
+ created_at
16
+ parent {
17
+ id
18
+ }
19
+ messageType {
20
+ id
21
+ name
22
+ verb
23
+ }
24
+ channels {
25
+ id
26
+ slug
27
+ name
28
+ entity_id
29
+ entity_namespace
30
+ }
31
+ appModuleMessage {
32
+ entity_id
33
+ system_modules
34
+ }
35
+ tags {
36
+ id
37
+ name
38
+ }
39
+ custom_fields {
40
+ name
41
+ value
42
+ }
43
+ }
44
+ }
45
+ `;
46
+ return this.client.query(mutation, {
47
+ input: {
48
+ message_verb: input.message_verb,
49
+ message: input.message,
50
+ parent_id: input.parent_id,
51
+ entity_id: input.entity_id,
52
+ channel_slug: input.channel_slug,
53
+ is_public: input.is_public,
54
+ tags: input.tags,
55
+ custom_fields: input.custom_fields,
56
+ },
57
+ });
58
+ }
59
+ async getMessage(id) {
60
+ const query = `
61
+ query GetMessage($where: QueryMessagesWhereWhereConditions) {
62
+ messages(first: 1, where: $where) {
63
+ data {
64
+ id
65
+ uuid
66
+ slug
67
+ message
68
+ is_public
69
+ is_locked
70
+ created_at
71
+ updated_at
72
+ parent {
73
+ id
74
+ uuid
75
+ }
76
+ user {
77
+ id
78
+ uuid
79
+ firstname
80
+ lastname
81
+ displayname
82
+ }
83
+ messageType {
84
+ id
85
+ name
86
+ verb
87
+ }
88
+ channels {
89
+ id
90
+ slug
91
+ name
92
+ entity_id
93
+ entity_namespace
94
+ }
95
+ appModuleMessage {
96
+ entity_id
97
+ system_modules
98
+ }
99
+ files {
100
+ data {
101
+ id
102
+ uuid
103
+ name
104
+ url
105
+ type
106
+ }
107
+ }
108
+ children(first: 50) {
109
+ data {
110
+ id
111
+ uuid
112
+ message
113
+ created_at
114
+ user {
115
+ id
116
+ displayname
117
+ }
118
+ }
119
+ }
120
+ tags {
121
+ id
122
+ name
123
+ }
124
+ custom_fields {
125
+ name
126
+ value
127
+ }
128
+ }
129
+ }
130
+ }
131
+ `;
132
+ return this.client.query(query, {
133
+ where: { column: "ID", operator: "EQ", value: id },
134
+ });
135
+ }
136
+ async updateMessage(id, input) {
137
+ const mutation = `
138
+ mutation UpdateMessage($id: ID!, $input: MessageUpdateInput!) {
139
+ updateMessage(id: $id, input: $input) {
140
+ id
141
+ uuid
142
+ slug
143
+ message
144
+ is_public
145
+ is_locked
146
+ updated_at
147
+ messageType {
148
+ id
149
+ name
150
+ verb
151
+ }
152
+ tags {
153
+ id
154
+ name
155
+ }
156
+ custom_fields {
157
+ name
158
+ value
159
+ }
160
+ }
161
+ }
162
+ `;
163
+ return this.client.query(mutation, { id, input });
164
+ }
165
+ async deleteMessage(id) {
166
+ const mutation = `
167
+ mutation DeleteMessage($id: ID!) {
168
+ deleteMessage(id: $id)
169
+ }
170
+ `;
171
+ return this.client.query(mutation, { id });
172
+ }
173
+ async listChannelMessages(channelSlug, first = 25, page = 1, orderBy) {
174
+ const query = `
175
+ query ChannelMessages(
176
+ $channelSlug: String!
177
+ $first: Int
178
+ $page: Int
179
+ $orderBy: [QueryChannelMessagesOrderByOrderByClause!]
180
+ ) {
181
+ channelMessages(
182
+ channel_slug: $channelSlug
183
+ first: $first
184
+ page: $page
185
+ orderBy: $orderBy
186
+ ) {
187
+ data {
188
+ id
189
+ uuid
190
+ slug
191
+ message
192
+ is_public
193
+ created_at
194
+ user {
195
+ id
196
+ uuid
197
+ displayname
198
+ }
199
+ messageType {
200
+ id
201
+ name
202
+ verb
203
+ }
204
+ files {
205
+ data {
206
+ id
207
+ uuid
208
+ name
209
+ url
210
+ type
211
+ }
212
+ }
213
+ children(first: 10) {
214
+ data {
215
+ id
216
+ uuid
217
+ message
218
+ created_at
219
+ }
220
+ }
221
+ tags {
222
+ id
223
+ name
224
+ }
225
+ }
226
+ paginatorInfo {
227
+ currentPage
228
+ lastPage
229
+ total
230
+ }
231
+ }
232
+ }
233
+ `;
234
+ return this.client.query(query, {
235
+ channelSlug,
236
+ first,
237
+ page,
238
+ orderBy: orderBy ?? [{ column: "CREATED_AT", order: "DESC" }],
239
+ });
240
+ }
241
+ async searchMessages(search, first = 25, hasType, hasChannel, hasAppModuleMessage, where) {
242
+ const query = `
243
+ query SearchMessages(
244
+ $first: Int
245
+ $search: String
246
+ $where: QueryMessagesWhereWhereConditions
247
+ $hasType: QueryMessagesHasTypeWhereHasConditions
248
+ $hasChannel: QueryMessagesHasChannelWhereHasConditions
249
+ $hasAppModuleMessage: QueryMessagesHasAppModuleMessageWhereHasConditions
250
+ ) {
251
+ messages(
252
+ first: $first
253
+ search: $search
254
+ where: $where
255
+ hasType: $hasType
256
+ hasChannel: $hasChannel
257
+ hasAppModuleMessage: $hasAppModuleMessage
258
+ orderBy: [{ column: CREATED_AT, order: DESC }]
259
+ ) {
260
+ data {
261
+ id
262
+ uuid
263
+ slug
264
+ message
265
+ is_public
266
+ created_at
267
+ user {
268
+ id
269
+ uuid
270
+ displayname
271
+ }
272
+ messageType {
273
+ id
274
+ name
275
+ verb
276
+ }
277
+ channels {
278
+ id
279
+ slug
280
+ name
281
+ entity_id
282
+ entity_namespace
283
+ }
284
+ appModuleMessage {
285
+ entity_id
286
+ system_modules
287
+ }
288
+ tags {
289
+ id
290
+ name
291
+ }
292
+ }
293
+ paginatorInfo {
294
+ currentPage
295
+ lastPage
296
+ total
297
+ }
298
+ }
299
+ }
300
+ `;
301
+ return this.client.query(query, {
302
+ first,
303
+ search,
304
+ where,
305
+ hasType,
306
+ hasChannel,
307
+ hasAppModuleMessage,
308
+ });
309
+ }
310
+ async listMessageTypes(first = 50) {
311
+ const query = `
312
+ query MessageTypes($first: Int) {
313
+ messageTypes(first: $first) {
314
+ data {
315
+ id
316
+ uuid
317
+ name
318
+ verb
319
+ template
320
+ templates_plura
321
+ created_at
322
+ }
323
+ }
324
+ }
325
+ `;
326
+ return this.client.query(query, { first });
327
+ }
328
+ async createMessageType(input) {
329
+ const mutation = `
330
+ mutation CreateMessageType($input: CreateMessageTypeInput!) {
331
+ createMessageType(input: $input) {
332
+ id
333
+ uuid
334
+ name
335
+ verb
336
+ template
337
+ templates_plura
338
+ created_at
339
+ }
340
+ }
341
+ `;
342
+ return this.client.query(mutation, { input });
343
+ }
344
+ /**
345
+ * Send an anonymous email using a notification template.
346
+ * Requires xKanvasKey (uses @guardByAppKey auth).
347
+ */
348
+ async sendAnonymousEmail(input) {
349
+ const mutation = `
350
+ mutation SendAnonymousEmail(
351
+ $template_name: String!
352
+ $data: Mixed!
353
+ $email: Email!
354
+ $subject: String!
355
+ $attachment: [String]
356
+ ) {
357
+ sendNotificationAnonymousBaseOnTemplate(
358
+ template_name: $template_name
359
+ data: $data
360
+ email: $email
361
+ subject: $subject
362
+ attachment: $attachment
363
+ )
364
+ }
365
+ `;
366
+ return this.client.queryWithAppKey(mutation, {
367
+ template_name: input.template_name,
368
+ data: input.data,
369
+ email: input.email,
370
+ subject: input.subject,
371
+ attachment: input.attachment,
372
+ });
373
+ }
374
+ }
@@ -0,0 +1 @@
1
+ export {};