@code.store/arcxp-sdk-ts 5.3.2 → 5.4.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.
@@ -1,25 +1,48 @@
1
1
  import { ArcAbstractAPI, type ArcAPIOptions } from '../abstract-api.js';
2
- import type { AddSecretPayload, Bundle, CreateIntegrationPayload, GenereteDeleteTokenResponse, GetBundlesResponse, GetSubscriptionsResponse, Integration, SubscribePayload, UpdateIntegrationPayload } from './types.js';
2
+ import type { AddSecretPayload, Bundle, CreateIntegrationPayload, CreateWebhookPayload, CustomEvent, CustomEventUpdatePayload, GenereteDeleteTokenResponse, GetBundlesResponse, GetCustomEventsResponse, GetEventHistoryParams, GetEventHistoryResponse, GetEventPayloadResponse, GetIntegrationsResponse, GetLogQueriesResponse, GetLogsResponse, GetSubscriptionsResponse, GetWebhooksResponse, InitializeLogQueryParams, IntegrationDetail, SubscribePayload, TriggerWebhookPayload, UpdateIntegrationPayload, Webhook } from './types.js';
3
3
  export declare class ArcIFX extends ArcAbstractAPI {
4
4
  constructor(options: ArcAPIOptions);
5
5
  createIntegration(payload: CreateIntegrationPayload): Promise<void>;
6
+ getIntegration(integrationName: string): Promise<IntegrationDetail>;
7
+ getIntegrations(page?: number, pageSize?: number): Promise<GetIntegrationsResponse>;
6
8
  updateIntegration(integrationName: string, payload: UpdateIntegrationPayload): Promise<void>;
7
9
  deleteIntegration(integrationName: string, token: string): Promise<void>;
8
10
  generateDeleteIntegrationToken(integrationName: string): Promise<GenereteDeleteTokenResponse>;
9
- getIntegrations(): Promise<Integration[]>;
10
- getJobs(integrationName: string): Promise<any>;
11
- getStatus(integrationName: string): Promise<any>;
12
- initializeQuery(integrationName: string, query?: string): Promise<{
13
- queryId: string;
14
- }>;
15
- getLogs(queryId: string, raw?: boolean): Promise<any>;
11
+ getBundles(integrationName: string): Promise<GetBundlesResponse>;
12
+ uploadBundle(integrationName: string, name: string, bundlePath: string): Promise<Bundle>;
13
+ deployBundle(integrationName: string, bundleName: string): Promise<Bundle>;
14
+ downloadBundle(integrationName: string, bundleName: string): Promise<Buffer>;
15
+ promoteBundle(integrationName: string, version: number): Promise<Bundle>;
16
16
  subscribe(payload: SubscribePayload): Promise<any>;
17
17
  updateSubscription(payload: SubscribePayload): Promise<any>;
18
18
  getSubscriptions(): Promise<GetSubscriptionsResponse>;
19
+ getEventPayload(integrationName: string, invocationId: string): Promise<GetEventPayloadResponse>;
20
+ getEventHistory(integrationName: string, params?: GetEventHistoryParams): Promise<GetEventHistoryResponse>;
21
+ getCustomEvents(page?: number, pageSize?: number): Promise<GetCustomEventsResponse>;
22
+ createCustomEvent(payload: CustomEvent): Promise<CustomEvent>;
23
+ updateCustomEvent(eventName: string, payload: CustomEventUpdatePayload): Promise<CustomEvent>;
24
+ deleteCustomEvent(eventName: string): Promise<{
25
+ message: string;
26
+ }>;
27
+ deleteCustomEventSchedule(eventName: string): Promise<{
28
+ message: string;
29
+ }>;
30
+ getWebhooks(page?: number, pageSize?: number): Promise<GetWebhooksResponse>;
31
+ createWebhook(eventName: string, payload?: CreateWebhookPayload): Promise<Webhook>;
32
+ updateWebhook(eventName: string, payload: CreateWebhookPayload): Promise<Webhook>;
33
+ deleteWebhook(eventName: string): Promise<{
34
+ message: string;
35
+ }>;
36
+ triggerWebhook(uuid: string, payload: TriggerWebhookPayload): Promise<void>;
19
37
  addSecret(payload: AddSecretPayload): Promise<any>;
20
- getSecrets(integrationName: string): Promise<any>;
21
- getBundles(integrationName: string): Promise<GetBundlesResponse>;
22
- uploadBundle(integrationName: string, name: string, bundlePath: string): Promise<Bundle>;
23
- deployBundle(integrationName: string, name: string): Promise<Bundle>;
24
- promoteBundle(integrationName: string, version: number): Promise<Bundle>;
38
+ updateSecret(payload: AddSecretPayload): Promise<any>;
39
+ getSecrets(integrationName: string): Promise<string[]>;
40
+ initializeLogQuery(integrationName: string, params?: InitializeLogQueryParams): Promise<{
41
+ queryId: string;
42
+ }>;
43
+ getLogs(queryId: string, raw?: boolean): Promise<GetLogsResponse>;
44
+ cancelLogQuery(queryId: string): Promise<{
45
+ message: string;
46
+ }>;
47
+ getLogQueries(page?: number, pageSize?: number): Promise<GetLogQueriesResponse>;
25
48
  }
@@ -59,3 +59,118 @@ export type Integration = {
59
59
  export type GenereteDeleteTokenResponse = {
60
60
  deleteToken: string;
61
61
  };
62
+ export type IntegrationDetail = {
63
+ integrationName: string;
64
+ enabled: boolean;
65
+ description: string;
66
+ runtime: string;
67
+ email: string;
68
+ liveBundle: string;
69
+ created: string;
70
+ status: string;
71
+ };
72
+ export type GetIntegrationsResponse = {
73
+ page: number;
74
+ pageSize: number;
75
+ totalCount: number;
76
+ results: IntegrationDetail[];
77
+ };
78
+ export type EventInvocation = {
79
+ invocationID: string;
80
+ eventTime: string;
81
+ eventStatus: string;
82
+ eventName: string;
83
+ payloadUrl: string;
84
+ logsUrl: string;
85
+ };
86
+ export type GetEventHistoryParams = {
87
+ start?: string;
88
+ end?: string;
89
+ from?: string;
90
+ size?: number;
91
+ eventName?: string;
92
+ eventStatus?: string;
93
+ };
94
+ export type GetEventHistoryResponse = {
95
+ from: string | null;
96
+ count: number;
97
+ size: number;
98
+ events: EventInvocation[];
99
+ };
100
+ export type GetEventPayloadResponse = {
101
+ payload: Record<string, unknown>;
102
+ };
103
+ export type CustomEventSchedule = {
104
+ cron: string;
105
+ };
106
+ export type CustomEvent = {
107
+ eventName: string;
108
+ description?: string;
109
+ schedule?: CustomEventSchedule;
110
+ };
111
+ export type CustomEventUpdatePayload = {
112
+ description?: string;
113
+ schedule?: CustomEventSchedule;
114
+ };
115
+ export type GetCustomEventsResponse = {
116
+ page: number;
117
+ pageSize: number;
118
+ totalCount: number;
119
+ results: CustomEvent[];
120
+ };
121
+ export type Webhook = {
122
+ webhookUrl: string;
123
+ eventName: string;
124
+ description: string;
125
+ };
126
+ export type CreateWebhookPayload = {
127
+ description?: string;
128
+ };
129
+ export type GetWebhooksResponse = {
130
+ page: number;
131
+ pageSize: number;
132
+ totalCount: number;
133
+ results: Webhook[];
134
+ };
135
+ export type TriggerWebhookPayload = Record<string, unknown>;
136
+ export type InitializeLogQueryParams = {
137
+ start?: number;
138
+ end?: number;
139
+ limit?: number;
140
+ sort?: 'asc' | 'desc';
141
+ q?: string;
142
+ queryName?: string;
143
+ };
144
+ export type LogEvent = {
145
+ timestamp: string;
146
+ message: string;
147
+ logStream: string;
148
+ };
149
+ export type GetLogsResponse = {
150
+ status: string;
151
+ statistics: {
152
+ recordsMatched: number;
153
+ recordsScanned: number;
154
+ bytesScanned: number;
155
+ };
156
+ events: LogEvent[];
157
+ };
158
+ export type LogQuery = {
159
+ queryId: string;
160
+ created: number;
161
+ createdBy: string;
162
+ startTime: number;
163
+ endTime: number;
164
+ integrationName: string;
165
+ queryName: string;
166
+ limit: number;
167
+ sort: string;
168
+ queryString: string;
169
+ status: string;
170
+ };
171
+ export type GetLogQueriesResponse = {
172
+ page: number;
173
+ pageSize: number;
174
+ totalCount: number;
175
+ results: LogQuery[];
176
+ };
@@ -63,7 +63,7 @@ export declare const ContentElement: {
63
63
  referent_properties: {
64
64
  type: "image";
65
65
  _id: ANS.GloballyUniqueIDTrait;
66
- version?: "0.10.12" | undefined;
66
+ version?: "0.10.11" | undefined;
67
67
  subtype?: ANS.SubtypeOrTemplate;
68
68
  channels?: ANS.ChannelTrait;
69
69
  alignment?: ANS.Alignment;
package/dist/index.cjs CHANGED
@@ -444,9 +444,22 @@ class ArcIFX extends ArcAbstractAPI {
444
444
  constructor(options) {
445
445
  super({ ...options, apiPath: 'ifx/api/v1' });
446
446
  }
447
+ // ---------------------------------------------------------------------------
448
+ // Integrations
449
+ // ---------------------------------------------------------------------------
447
450
  async createIntegration(payload) {
448
451
  await this.client.post('/admin/integration', payload);
449
452
  }
453
+ async getIntegration(integrationName) {
454
+ const { data } = await this.client.get(`/admin/integration/${integrationName}`);
455
+ return data;
456
+ }
457
+ async getIntegrations(page = 1, pageSize = 50) {
458
+ const { data } = await this.client.get('/admin/integration', {
459
+ params: { page, pageSize },
460
+ });
461
+ return data;
462
+ }
450
463
  async updateIntegration(integrationName, payload) {
451
464
  await this.client.put(`/admin/integration/${integrationName}`, payload);
452
465
  }
@@ -454,29 +467,45 @@ class ArcIFX extends ArcAbstractAPI {
454
467
  await this.client.delete(`/admin/integration/${integrationName}`, { params: { token } });
455
468
  }
456
469
  async generateDeleteIntegrationToken(integrationName) {
457
- const response = await this.client.get(`/admin/integration/${integrationName}/token`);
458
- return response.data;
470
+ const { data } = await this.client.get(`/admin/integration/${integrationName}/token`);
471
+ return data;
459
472
  }
460
- async getIntegrations() {
461
- const { data } = await this.client.get('/admin/integrations');
473
+ // ---------------------------------------------------------------------------
474
+ // Bundles
475
+ // ---------------------------------------------------------------------------
476
+ async getBundles(integrationName) {
477
+ const { data } = await this.client.get(`/admin/bundles/${integrationName}`);
462
478
  return data;
463
479
  }
464
- async getJobs(integrationName) {
465
- const { data } = await this.client.get(`/admin/jobs/status/${integrationName}`);
480
+ async uploadBundle(integrationName, name, bundlePath) {
481
+ const fs = await platform.fs();
482
+ const FormData = await platform.form_data();
483
+ const form = new FormData();
484
+ const bundle = fs.createReadStream(bundlePath);
485
+ form.append('bundle', bundle);
486
+ form.append('name', name);
487
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}`, form, {
488
+ headers: form.getHeaders(),
489
+ });
466
490
  return data;
467
491
  }
468
- async getStatus(integrationName) {
469
- const { data } = await this.client.get(`/admin/integration/${integrationName}/provisionStatus`);
492
+ async deployBundle(integrationName, bundleName) {
493
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}/deploy/${bundleName}`);
470
494
  return data;
471
495
  }
472
- async initializeQuery(integrationName, query) {
473
- const { data } = await this.client.get(`/admin/logs/integration/${integrationName}?${query}`);
496
+ async downloadBundle(integrationName, bundleName) {
497
+ const { data } = await this.client.get(`/admin/bundles/${integrationName}/download/${bundleName}`, {
498
+ responseType: 'arraybuffer',
499
+ });
474
500
  return data;
475
501
  }
476
- async getLogs(queryId, raw = true) {
477
- const { data } = await this.client.get('/admin/logs/results', { params: { queryId, raw } });
502
+ async promoteBundle(integrationName, version) {
503
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}/promote/${version}`);
478
504
  return data;
479
505
  }
506
+ // ---------------------------------------------------------------------------
507
+ // Event Subscriptions
508
+ // ---------------------------------------------------------------------------
480
509
  async subscribe(payload) {
481
510
  const { data } = await this.client.post('/admin/events/subscriptions', payload);
482
511
  return data;
@@ -489,6 +518,69 @@ class ArcIFX extends ArcAbstractAPI {
489
518
  const { data } = await this.client.get('/admin/events/subscriptions');
490
519
  return data;
491
520
  }
521
+ // ---------------------------------------------------------------------------
522
+ // Events
523
+ // ---------------------------------------------------------------------------
524
+ async getEventPayload(integrationName, invocationId) {
525
+ const { data } = await this.client.get(`/eventdata/${integrationName}/${invocationId}`);
526
+ return data;
527
+ }
528
+ async getEventHistory(integrationName, params) {
529
+ const { data } = await this.client.get(`/admin/events/${integrationName}/history`, { params });
530
+ return data;
531
+ }
532
+ // ---------------------------------------------------------------------------
533
+ // Custom Events
534
+ // ---------------------------------------------------------------------------
535
+ async getCustomEvents(page = 1, pageSize = 50) {
536
+ const { data } = await this.client.get('/admin/events/custom', {
537
+ params: { page, pageSize },
538
+ });
539
+ return data;
540
+ }
541
+ async createCustomEvent(payload) {
542
+ const { data } = await this.client.post('/admin/events/custom', payload);
543
+ return data;
544
+ }
545
+ async updateCustomEvent(eventName, payload) {
546
+ const { data } = await this.client.put(`/admin/events/custom/${eventName}`, payload);
547
+ return data;
548
+ }
549
+ async deleteCustomEvent(eventName) {
550
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}`);
551
+ return data;
552
+ }
553
+ async deleteCustomEventSchedule(eventName) {
554
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}/schedule`);
555
+ return data;
556
+ }
557
+ // ---------------------------------------------------------------------------
558
+ // Webhooks
559
+ // ---------------------------------------------------------------------------
560
+ async getWebhooks(page = 1, pageSize = 50) {
561
+ const { data } = await this.client.get('/admin/events/custom/webhooks', {
562
+ params: { page, pageSize },
563
+ });
564
+ return data;
565
+ }
566
+ async createWebhook(eventName, payload) {
567
+ const { data } = await this.client.post(`/admin/events/custom/${eventName}/webhooks`, payload ?? {});
568
+ return data;
569
+ }
570
+ async updateWebhook(eventName, payload) {
571
+ const { data } = await this.client.put(`/admin/events/custom/${eventName}/webhooks`, payload);
572
+ return data;
573
+ }
574
+ async deleteWebhook(eventName) {
575
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}/webhooks`);
576
+ return data;
577
+ }
578
+ async triggerWebhook(uuid, payload) {
579
+ await this.client.post(`/webhook/${uuid}`, payload);
580
+ }
581
+ // ---------------------------------------------------------------------------
582
+ // Secrets
583
+ // ---------------------------------------------------------------------------
492
584
  async addSecret(payload) {
493
585
  const { data } = await this.client.post(`/admin/secret?integrationName=${payload.integrationName}`, {
494
586
  secretName: payload.secretName,
@@ -496,34 +588,40 @@ class ArcIFX extends ArcAbstractAPI {
496
588
  });
497
589
  return data;
498
590
  }
591
+ async updateSecret(payload) {
592
+ const { data } = await this.client.put(`/admin/secret?integrationName=${payload.integrationName}`, {
593
+ secretName: payload.secretName,
594
+ secretValue: payload.secretValue,
595
+ });
596
+ return data;
597
+ }
499
598
  async getSecrets(integrationName) {
500
- const { data } = await this.client.get(`/admin/secret?integrationName=${integrationName}`);
599
+ const { data } = await this.client.get(`/admin/secret`, { params: { integrationName } });
501
600
  return data;
502
601
  }
503
- async getBundles(integrationName) {
504
- const { data } = await this.client.get(`/admin/bundles/${integrationName}`);
602
+ // ---------------------------------------------------------------------------
603
+ // Logs
604
+ // ---------------------------------------------------------------------------
605
+ async initializeLogQuery(integrationName, params) {
606
+ const { data } = await this.client.get(`/admin/logs/integration/${integrationName}`, { params });
505
607
  return data;
506
608
  }
507
- async uploadBundle(integrationName, name, bundlePath) {
508
- const fs = await platform.fs();
509
- const FormData = await platform.form_data();
510
- const form = new FormData();
511
- console.log('platform', platform);
512
- console.log(form);
513
- const bundle = fs.createReadStream(bundlePath);
514
- form.append('bundle', bundle);
515
- form.append('name', name);
516
- const { data } = await this.client.post(`/admin/bundles/${integrationName}`, form, {
517
- headers: form.getHeaders(),
609
+ async getLogs(queryId, raw = false) {
610
+ const { data } = await this.client.get('/admin/logs/results', {
611
+ params: { queryId, raw },
518
612
  });
519
613
  return data;
520
614
  }
521
- async deployBundle(integrationName, name) {
522
- const { data } = await this.client.post(`/admin/bundles/${integrationName}/deploy/${name}`);
615
+ async cancelLogQuery(queryId) {
616
+ const { data } = await this.client.delete('/admin/logs/cancel', {
617
+ params: { queryId },
618
+ });
523
619
  return data;
524
620
  }
525
- async promoteBundle(integrationName, version) {
526
- const { data } = await this.client.post(`/admin/bundles/${integrationName}/promote/${version}`);
621
+ async getLogQueries(page, pageSize) {
622
+ const { data } = await this.client.get('/admin/logs/queries', {
623
+ params: { page, pageSize },
624
+ });
527
625
  return data;
528
626
  }
529
627
  }