@code.store/arcxp-sdk-ts 5.3.3 → 5.5.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,7 +1,11 @@
1
1
  import { ArcAbstractAPI, type ArcAPIOptions } from '../abstract-api.js';
2
- import type { ListAuthorsParams, ListAuthorsResponse } from './types.js';
2
+ import type { AuthorANS, AuthorConfigurationResponse, CreateAuthorPayload, GetAuthorParams, ListAuthorsParams, ListAuthorsResponse, UpdateAuthorPayload } from './types.js';
3
3
  export declare class ArcAuthor extends ArcAbstractAPI {
4
4
  constructor(options: ArcAPIOptions);
5
+ getAuthor(params: GetAuthorParams): Promise<AuthorANS>;
5
6
  listAuthors(params?: ListAuthorsParams): Promise<ListAuthorsResponse>;
6
- delete(userId: string): Promise<void>;
7
+ createAuthor(payload: CreateAuthorPayload): Promise<AuthorANS>;
8
+ updateAuthor(id: string, payload: UpdateAuthorPayload): Promise<AuthorANS>;
9
+ deleteAuthor(id: string): Promise<void>;
10
+ getConfiguration(): Promise<AuthorConfigurationResponse>;
7
11
  }
@@ -1,4 +1,12 @@
1
1
  export type ListAuthorsParams = Partial<{
2
+ sort_by: 'lastName' | 'last_updated_date';
3
+ order: 'asc' | 'desc';
4
+ byline: string;
5
+ email: string;
6
+ firstName: string;
7
+ lastName: string;
8
+ slug: string;
9
+ include_inactive: boolean;
2
10
  limit: number;
3
11
  last: string;
4
12
  }>;
@@ -7,6 +15,34 @@ export type ListAuthorsResponse = {
7
15
  more?: boolean;
8
16
  last?: string;
9
17
  };
18
+ export type CreateAuthorPayload = Omit<AuthorANS, 'last_updated_date'>;
19
+ export type UpdateAuthorPayload = Partial<Omit<AuthorANS, '_id' | 'last_updated_date'>>;
20
+ export type GetAuthorParams = {
21
+ _id: string;
22
+ };
23
+ export type AuthorConfigurationResponse = {
24
+ q_results: AuthorFieldConfig[];
25
+ count: number;
26
+ limit: number;
27
+ offset: number;
28
+ total_count: number;
29
+ };
30
+ export type AuthorFieldConfig = {
31
+ _id: string;
32
+ key: string;
33
+ label?: string;
34
+ type?: string;
35
+ required?: boolean;
36
+ hidden?: boolean;
37
+ placeholder?: string;
38
+ default?: string;
39
+ max?: number;
40
+ versionAdded?: number;
41
+ picklist_options?: {
42
+ value: string;
43
+ label: string;
44
+ }[];
45
+ };
10
46
  export type AuthorANS = {
11
47
  type: 'author';
12
48
  _id: string;
@@ -16,6 +52,9 @@ export type AuthorANS = {
16
52
  slug: string;
17
53
  email: string;
18
54
  image?: string;
55
+ url?: string;
56
+ middleName?: string;
57
+ suffix?: string;
19
58
  affiliations?: string;
20
59
  author_type?: string;
21
60
  education?: {
@@ -24,6 +63,16 @@ export type AuthorANS = {
24
63
  awards?: {
25
64
  name: string;
26
65
  }[];
66
+ books?: {
67
+ title: string;
68
+ url?: string;
69
+ publisher?: string;
70
+ }[];
71
+ podcasts?: {
72
+ name?: string;
73
+ url?: string;
74
+ download_url?: string;
75
+ }[];
27
76
  bio_page?: string;
28
77
  bio?: string;
29
78
  longBio?: string;
@@ -33,9 +82,22 @@ export type AuthorANS = {
33
82
  location?: string;
34
83
  role?: string;
35
84
  expertise?: string;
85
+ languages?: string;
86
+ beat?: string;
36
87
  personal_website?: string;
37
88
  twitter?: string;
38
89
  facebook?: string;
39
90
  linkedin?: string;
91
+ youtube?: string;
92
+ tumblr?: string;
93
+ pinterest?: string;
94
+ soundcloud?: string;
95
+ instagram?: string;
96
+ rss?: string;
97
+ snapchat?: string;
98
+ whatsapp?: string;
99
+ medium?: string;
100
+ reddit?: string;
101
+ last_updated_date?: string;
40
102
  status?: boolean;
41
103
  };
@@ -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
+ };
package/dist/index.cjs CHANGED
@@ -129,12 +129,27 @@ class ArcAuthor extends ArcAbstractAPI {
129
129
  constructor(options) {
130
130
  super({ ...options, apiPath: 'author' });
131
131
  }
132
+ async getAuthor(params) {
133
+ const { data } = await this.client.get('/v1/author-service', { params });
134
+ return data;
135
+ }
132
136
  async listAuthors(params) {
133
137
  const { data } = await this.client.get('/v2/author-service', { params });
134
138
  return data;
135
139
  }
136
- async delete(userId) {
137
- const { data } = await this.client.delete(`/v2/author-service/${userId}`);
140
+ async createAuthor(payload) {
141
+ const { data } = await this.client.post('/v2/author-service', payload);
142
+ return data;
143
+ }
144
+ async updateAuthor(id, payload) {
145
+ const { data } = await this.client.post(`/v2/author-service/${id}`, payload);
146
+ return data;
147
+ }
148
+ async deleteAuthor(id) {
149
+ await this.client.delete(`/v2/author-service/${id}`);
150
+ }
151
+ async getConfiguration() {
152
+ const { data } = await this.client.get('/v1/configuration');
138
153
  return data;
139
154
  }
140
155
  }
@@ -444,9 +459,22 @@ class ArcIFX extends ArcAbstractAPI {
444
459
  constructor(options) {
445
460
  super({ ...options, apiPath: 'ifx/api/v1' });
446
461
  }
462
+ // ---------------------------------------------------------------------------
463
+ // Integrations
464
+ // ---------------------------------------------------------------------------
447
465
  async createIntegration(payload) {
448
466
  await this.client.post('/admin/integration', payload);
449
467
  }
468
+ async getIntegration(integrationName) {
469
+ const { data } = await this.client.get(`/admin/integration/${integrationName}`);
470
+ return data;
471
+ }
472
+ async getIntegrations(page = 1, pageSize = 50) {
473
+ const { data } = await this.client.get('/admin/integration', {
474
+ params: { page, pageSize },
475
+ });
476
+ return data;
477
+ }
450
478
  async updateIntegration(integrationName, payload) {
451
479
  await this.client.put(`/admin/integration/${integrationName}`, payload);
452
480
  }
@@ -454,29 +482,45 @@ class ArcIFX extends ArcAbstractAPI {
454
482
  await this.client.delete(`/admin/integration/${integrationName}`, { params: { token } });
455
483
  }
456
484
  async generateDeleteIntegrationToken(integrationName) {
457
- const response = await this.client.get(`/admin/integration/${integrationName}/token`);
458
- return response.data;
485
+ const { data } = await this.client.get(`/admin/integration/${integrationName}/token`);
486
+ return data;
459
487
  }
460
- async getIntegrations() {
461
- const { data } = await this.client.get('/admin/integrations');
488
+ // ---------------------------------------------------------------------------
489
+ // Bundles
490
+ // ---------------------------------------------------------------------------
491
+ async getBundles(integrationName) {
492
+ const { data } = await this.client.get(`/admin/bundles/${integrationName}`);
462
493
  return data;
463
494
  }
464
- async getJobs(integrationName) {
465
- const { data } = await this.client.get(`/admin/jobs/status/${integrationName}`);
495
+ async uploadBundle(integrationName, name, bundlePath) {
496
+ const fs = await platform.fs();
497
+ const FormData = await platform.form_data();
498
+ const form = new FormData();
499
+ const bundle = fs.createReadStream(bundlePath);
500
+ form.append('bundle', bundle);
501
+ form.append('name', name);
502
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}`, form, {
503
+ headers: form.getHeaders(),
504
+ });
466
505
  return data;
467
506
  }
468
- async getStatus(integrationName) {
469
- const { data } = await this.client.get(`/admin/integration/${integrationName}/provisionStatus`);
507
+ async deployBundle(integrationName, bundleName) {
508
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}/deploy/${bundleName}`);
470
509
  return data;
471
510
  }
472
- async initializeQuery(integrationName, query) {
473
- const { data } = await this.client.get(`/admin/logs/integration/${integrationName}?${query}`);
511
+ async downloadBundle(integrationName, bundleName) {
512
+ const { data } = await this.client.get(`/admin/bundles/${integrationName}/download/${bundleName}`, {
513
+ responseType: 'arraybuffer',
514
+ });
474
515
  return data;
475
516
  }
476
- async getLogs(queryId, raw = true) {
477
- const { data } = await this.client.get('/admin/logs/results', { params: { queryId, raw } });
517
+ async promoteBundle(integrationName, version) {
518
+ const { data } = await this.client.post(`/admin/bundles/${integrationName}/promote/${version}`);
478
519
  return data;
479
520
  }
521
+ // ---------------------------------------------------------------------------
522
+ // Event Subscriptions
523
+ // ---------------------------------------------------------------------------
480
524
  async subscribe(payload) {
481
525
  const { data } = await this.client.post('/admin/events/subscriptions', payload);
482
526
  return data;
@@ -489,6 +533,69 @@ class ArcIFX extends ArcAbstractAPI {
489
533
  const { data } = await this.client.get('/admin/events/subscriptions');
490
534
  return data;
491
535
  }
536
+ // ---------------------------------------------------------------------------
537
+ // Events
538
+ // ---------------------------------------------------------------------------
539
+ async getEventPayload(integrationName, invocationId) {
540
+ const { data } = await this.client.get(`/eventdata/${integrationName}/${invocationId}`);
541
+ return data;
542
+ }
543
+ async getEventHistory(integrationName, params) {
544
+ const { data } = await this.client.get(`/admin/events/${integrationName}/history`, { params });
545
+ return data;
546
+ }
547
+ // ---------------------------------------------------------------------------
548
+ // Custom Events
549
+ // ---------------------------------------------------------------------------
550
+ async getCustomEvents(page = 1, pageSize = 50) {
551
+ const { data } = await this.client.get('/admin/events/custom', {
552
+ params: { page, pageSize },
553
+ });
554
+ return data;
555
+ }
556
+ async createCustomEvent(payload) {
557
+ const { data } = await this.client.post('/admin/events/custom', payload);
558
+ return data;
559
+ }
560
+ async updateCustomEvent(eventName, payload) {
561
+ const { data } = await this.client.put(`/admin/events/custom/${eventName}`, payload);
562
+ return data;
563
+ }
564
+ async deleteCustomEvent(eventName) {
565
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}`);
566
+ return data;
567
+ }
568
+ async deleteCustomEventSchedule(eventName) {
569
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}/schedule`);
570
+ return data;
571
+ }
572
+ // ---------------------------------------------------------------------------
573
+ // Webhooks
574
+ // ---------------------------------------------------------------------------
575
+ async getWebhooks(page = 1, pageSize = 50) {
576
+ const { data } = await this.client.get('/admin/events/custom/webhooks', {
577
+ params: { page, pageSize },
578
+ });
579
+ return data;
580
+ }
581
+ async createWebhook(eventName, payload) {
582
+ const { data } = await this.client.post(`/admin/events/custom/${eventName}/webhooks`, payload ?? {});
583
+ return data;
584
+ }
585
+ async updateWebhook(eventName, payload) {
586
+ const { data } = await this.client.put(`/admin/events/custom/${eventName}/webhooks`, payload);
587
+ return data;
588
+ }
589
+ async deleteWebhook(eventName) {
590
+ const { data } = await this.client.delete(`/admin/events/custom/${eventName}/webhooks`);
591
+ return data;
592
+ }
593
+ async triggerWebhook(uuid, payload) {
594
+ await this.client.post(`/webhook/${uuid}`, payload);
595
+ }
596
+ // ---------------------------------------------------------------------------
597
+ // Secrets
598
+ // ---------------------------------------------------------------------------
492
599
  async addSecret(payload) {
493
600
  const { data } = await this.client.post(`/admin/secret?integrationName=${payload.integrationName}`, {
494
601
  secretName: payload.secretName,
@@ -496,34 +603,40 @@ class ArcIFX extends ArcAbstractAPI {
496
603
  });
497
604
  return data;
498
605
  }
606
+ async updateSecret(payload) {
607
+ const { data } = await this.client.put(`/admin/secret?integrationName=${payload.integrationName}`, {
608
+ secretName: payload.secretName,
609
+ secretValue: payload.secretValue,
610
+ });
611
+ return data;
612
+ }
499
613
  async getSecrets(integrationName) {
500
- const { data } = await this.client.get(`/admin/secret?integrationName=${integrationName}`);
614
+ const { data } = await this.client.get(`/admin/secret`, { params: { integrationName } });
501
615
  return data;
502
616
  }
503
- async getBundles(integrationName) {
504
- const { data } = await this.client.get(`/admin/bundles/${integrationName}`);
617
+ // ---------------------------------------------------------------------------
618
+ // Logs
619
+ // ---------------------------------------------------------------------------
620
+ async initializeLogQuery(integrationName, params) {
621
+ const { data } = await this.client.get(`/admin/logs/integration/${integrationName}`, { params });
505
622
  return data;
506
623
  }
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(),
624
+ async getLogs(queryId, raw = false) {
625
+ const { data } = await this.client.get('/admin/logs/results', {
626
+ params: { queryId, raw },
518
627
  });
519
628
  return data;
520
629
  }
521
- async deployBundle(integrationName, name) {
522
- const { data } = await this.client.post(`/admin/bundles/${integrationName}/deploy/${name}`);
630
+ async cancelLogQuery(queryId) {
631
+ const { data } = await this.client.delete('/admin/logs/cancel', {
632
+ params: { queryId },
633
+ });
523
634
  return data;
524
635
  }
525
- async promoteBundle(integrationName, version) {
526
- const { data } = await this.client.post(`/admin/bundles/${integrationName}/promote/${version}`);
636
+ async getLogQueries(page, pageSize) {
637
+ const { data } = await this.client.get('/admin/logs/queries', {
638
+ params: { page, pageSize },
639
+ });
527
640
  return data;
528
641
  }
529
642
  }