@attlaz/client 1.84.0 → 1.86.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.
- package/dist/Client.d.ts +2 -0
- package/dist/Client.js +5 -0
- package/dist/Http/Transport/OAuthClient.js +1 -1
- package/dist/Model/Pulse/CrawlJob.d.ts +17 -0
- package/dist/Model/Pulse/CrawlJob.js +29 -0
- package/dist/Service/Endpoint.d.ts +7 -0
- package/dist/Service/Endpoint.js +15 -2
- package/dist/Service/Pulse/CrawlJobEndpoint.d.ts +15 -0
- package/dist/Service/Pulse/CrawlJobEndpoint.js +32 -0
- package/dist/Service/RunnerPoolEndpoint.d.ts +4 -0
- package/dist/Service/RunnerPoolEndpoint.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/Client.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { ProjectEndpoint } from './Service/ProjectEndpoint.js';
|
|
|
25
25
|
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint.js';
|
|
26
26
|
import { ProviderTokenEndpoint } from './Service/ProviderTokenEndpoint.js';
|
|
27
27
|
import { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
28
|
+
import { CrawlJobEndpoint } from './Service/Pulse/CrawlJobEndpoint.js';
|
|
28
29
|
import { RunnerEndpoint } from './Service/RunnerEndpoint.js';
|
|
29
30
|
import { RunnerPoolEndpoint } from './Service/RunnerPoolEndpoint.js';
|
|
30
31
|
import { SearchEndpoint } from './Service/SearchEndpoint.js';
|
|
@@ -111,6 +112,7 @@ export declare class Client {
|
|
|
111
112
|
getProviderTokenEndpoint(): ProviderTokenEndpoint;
|
|
112
113
|
getFirewallEndpoint(): FirewallEndpoint;
|
|
113
114
|
getVendorProductEndpoint(): VendorProductEndpoint;
|
|
115
|
+
getCrawlJobEndpoint(): CrawlJobEndpoint;
|
|
114
116
|
private getEndpoint;
|
|
115
117
|
getVersion(): string;
|
|
116
118
|
}
|
package/dist/Client.js
CHANGED
|
@@ -25,6 +25,7 @@ import { ProjectEndpoint } from './Service/ProjectEndpoint.js';
|
|
|
25
25
|
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint.js';
|
|
26
26
|
import { ProviderTokenEndpoint } from './Service/ProviderTokenEndpoint.js';
|
|
27
27
|
import { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
28
|
+
import { CrawlJobEndpoint } from './Service/Pulse/CrawlJobEndpoint.js';
|
|
28
29
|
import { RunnerEndpoint } from './Service/RunnerEndpoint.js';
|
|
29
30
|
import { RunnerPoolEndpoint } from './Service/RunnerPoolEndpoint.js';
|
|
30
31
|
import { SearchEndpoint } from './Service/SearchEndpoint.js';
|
|
@@ -77,6 +78,7 @@ export class Client {
|
|
|
77
78
|
RunnerPoolEndpoint,
|
|
78
79
|
ProviderTokenEndpoint,
|
|
79
80
|
VendorProductEndpoint,
|
|
81
|
+
CrawlJobEndpoint,
|
|
80
82
|
};
|
|
81
83
|
apiEndpoint = 'https://api.attlaz.com';
|
|
82
84
|
constructor(token = null, config = {}) {
|
|
@@ -261,6 +263,9 @@ export class Client {
|
|
|
261
263
|
getVendorProductEndpoint() {
|
|
262
264
|
return this.getEndpoint('vendor-product', this.Store.VendorProductEndpoint);
|
|
263
265
|
}
|
|
266
|
+
getCrawlJobEndpoint() {
|
|
267
|
+
return this.getEndpoint('crawl-job', this.Store.CrawlJobEndpoint);
|
|
268
|
+
}
|
|
264
269
|
getEndpoint(key, ClassName) {
|
|
265
270
|
if (!this.endpoints.has(key)) {
|
|
266
271
|
try {
|
|
@@ -311,7 +311,7 @@ export class OAuthClient {
|
|
|
311
311
|
if (this.version !== null) {
|
|
312
312
|
requestData.setHeader('Attlaz-API-Version', this.version);
|
|
313
313
|
}
|
|
314
|
-
if ((method === 'POST' || method === 'DELETE' || method === 'PUT') && parameters !== null && parameters !== undefined) {
|
|
314
|
+
if ((method === 'POST' || method === 'DELETE' || method === 'PUT' || method === 'PATCH') && parameters !== null && parameters !== undefined) {
|
|
315
315
|
if (typeof parameters === 'object') {
|
|
316
316
|
requestData.body = JsonSerializable.stringify(parameters);
|
|
317
317
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiRecord } from '../ApiRecord.js';
|
|
2
|
+
export type CrawlJobStatus = 'pending' | 'started' | 'cancelled' | 'finished';
|
|
3
|
+
/**
|
|
4
|
+
* A Market Pulse crawl job: one run of scraping a vendor. Its lifecycle (pending → started →
|
|
5
|
+
* finished) drives the vendor's "last scraped" timestamp (`finishedAt`) and, on finish, triggers
|
|
6
|
+
* post-crawl processing (price history, product matching, …).
|
|
7
|
+
*/
|
|
8
|
+
export declare class CrawlJob {
|
|
9
|
+
id: string;
|
|
10
|
+
vendorId: string;
|
|
11
|
+
status: CrawlJobStatus;
|
|
12
|
+
requestedAt: Date | null;
|
|
13
|
+
startedAt: Date | null;
|
|
14
|
+
finishedAt: Date | null;
|
|
15
|
+
constructor(id: string, vendorId: string);
|
|
16
|
+
static parse(raw: ApiRecord): CrawlJob;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Market Pulse crawl job: one run of scraping a vendor. Its lifecycle (pending → started →
|
|
3
|
+
* finished) drives the vendor's "last scraped" timestamp (`finishedAt`) and, on finish, triggers
|
|
4
|
+
* post-crawl processing (price history, product matching, …).
|
|
5
|
+
*/
|
|
6
|
+
export class CrawlJob {
|
|
7
|
+
id;
|
|
8
|
+
vendorId;
|
|
9
|
+
status;
|
|
10
|
+
requestedAt;
|
|
11
|
+
startedAt;
|
|
12
|
+
finishedAt;
|
|
13
|
+
constructor(id, vendorId) {
|
|
14
|
+
this.id = id;
|
|
15
|
+
this.vendorId = vendorId;
|
|
16
|
+
this.status = 'pending';
|
|
17
|
+
this.requestedAt = null;
|
|
18
|
+
this.startedAt = null;
|
|
19
|
+
this.finishedAt = null;
|
|
20
|
+
}
|
|
21
|
+
static parse(raw) {
|
|
22
|
+
const job = new CrawlJob(raw.id, (raw.vendor ?? raw.vendor_id));
|
|
23
|
+
job.status = raw.status ?? 'pending';
|
|
24
|
+
job.requestedAt = raw.requested_at ? new Date(raw.requested_at) : null;
|
|
25
|
+
job.startedAt = raw.started_at ? new Date(raw.started_at) : null;
|
|
26
|
+
job.finishedAt = raw.finished_at ? new Date(raw.finished_at) : null;
|
|
27
|
+
return job;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -6,6 +6,13 @@ import { ObjectResult } from '../Model/Result/ObjectResult.js';
|
|
|
6
6
|
export declare abstract class Endpoint {
|
|
7
7
|
protected httpClient: ITransport;
|
|
8
8
|
constructor(httpClient: ITransport);
|
|
9
|
+
/**
|
|
10
|
+
* Prepare a request body for sending. Normally the keys are rewritten to the API's snake_case /
|
|
11
|
+
* id-stripped convention (see {@link formatParameters}). A caller that has already shaped the
|
|
12
|
+
* body — or that carries an opaque payload whose keys must NOT be rewritten, such as a flow
|
|
13
|
+
* run's `arguments` — sets `_formatted: true`; then the body is sent verbatim (minus the marker).
|
|
14
|
+
*/
|
|
15
|
+
private prepareParameters;
|
|
9
16
|
private formatParameters;
|
|
10
17
|
private formatKey;
|
|
11
18
|
requestCollection<T>(action: string | QueryString, parser: (input: any) => T, parameters?: Parameters, method?: string, signWithOauthToken?: boolean): Promise<CollectionResult<T>>;
|
package/dist/Service/Endpoint.js
CHANGED
|
@@ -13,6 +13,19 @@ export class Endpoint {
|
|
|
13
13
|
constructor(httpClient) {
|
|
14
14
|
this.httpClient = httpClient;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Prepare a request body for sending. Normally the keys are rewritten to the API's snake_case /
|
|
18
|
+
* id-stripped convention (see {@link formatParameters}). A caller that has already shaped the
|
|
19
|
+
* body — or that carries an opaque payload whose keys must NOT be rewritten, such as a flow
|
|
20
|
+
* run's `arguments` — sets `_formatted: true`; then the body is sent verbatim (minus the marker).
|
|
21
|
+
*/
|
|
22
|
+
prepareParameters(parameters) {
|
|
23
|
+
if (parameters !== null && typeof parameters === 'object' && parameters._formatted === true) {
|
|
24
|
+
const { _formatted, ...rest } = parameters;
|
|
25
|
+
return rest;
|
|
26
|
+
}
|
|
27
|
+
return this.formatParameters(parameters);
|
|
28
|
+
}
|
|
16
29
|
formatParameters(data = null) {
|
|
17
30
|
if (data === null || data === undefined) {
|
|
18
31
|
return null;
|
|
@@ -65,7 +78,7 @@ export class Endpoint {
|
|
|
65
78
|
return formattedKey;
|
|
66
79
|
}
|
|
67
80
|
async requestCollection(action, parser, parameters = null, method = 'GET', signWithOauthToken = true) {
|
|
68
|
-
parameters = this.
|
|
81
|
+
parameters = this.prepareParameters(parameters);
|
|
69
82
|
if (action instanceof QueryString) {
|
|
70
83
|
action = action.build();
|
|
71
84
|
}
|
|
@@ -94,7 +107,7 @@ export class Endpoint {
|
|
|
94
107
|
return result;
|
|
95
108
|
}
|
|
96
109
|
async requestObject(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
|
|
97
|
-
parameters = this.
|
|
110
|
+
parameters = this.prepareParameters(parameters);
|
|
98
111
|
if (action instanceof QueryString) {
|
|
99
112
|
action = action.build();
|
|
100
113
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CrawlJob, CrawlJobStatus } from '../../Model/Pulse/CrawlJob.js';
|
|
2
|
+
import { Endpoint } from '../Endpoint.js';
|
|
3
|
+
/**
|
|
4
|
+
* Market Pulse crawl jobs — `/pulse/crawl-jobs`. Mirrors the PHP client's MarketPulse\CrawlJobEndpoint.
|
|
5
|
+
* A crawl job's lifecycle drives the vendor's "last scraped" timestamp and, on `finished`, triggers
|
|
6
|
+
* post-crawl processing (price history, product matching, price-index snapshots).
|
|
7
|
+
*/
|
|
8
|
+
export declare class CrawlJobEndpoint extends Endpoint {
|
|
9
|
+
/** Create a new (pending) crawl job for a vendor. */
|
|
10
|
+
create(vendorId: string): Promise<CrawlJob>;
|
|
11
|
+
/** Update a crawl job's status ('started', 'finished', 'cancelled'). */
|
|
12
|
+
updateStatus(crawlJobId: string, status: CrawlJobStatus): Promise<CrawlJob>;
|
|
13
|
+
/** The crawl job with this id, or null. */
|
|
14
|
+
getById(crawlJobId: string): Promise<CrawlJob | null>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CrawlJob } from '../../Model/Pulse/CrawlJob.js';
|
|
2
|
+
import { Endpoint } from '../Endpoint.js';
|
|
3
|
+
/**
|
|
4
|
+
* Market Pulse crawl jobs — `/pulse/crawl-jobs`. Mirrors the PHP client's MarketPulse\CrawlJobEndpoint.
|
|
5
|
+
* A crawl job's lifecycle drives the vendor's "last scraped" timestamp and, on `finished`, triggers
|
|
6
|
+
* post-crawl processing (price history, product matching, price-index snapshots).
|
|
7
|
+
*/
|
|
8
|
+
export class CrawlJobEndpoint extends Endpoint {
|
|
9
|
+
/** Create a new (pending) crawl job for a vendor. */
|
|
10
|
+
async create(vendorId) {
|
|
11
|
+
const result = await this.requestObject('/pulse/crawl-jobs', { vendor: vendorId }, CrawlJob.parse, 'POST');
|
|
12
|
+
const job = result.getData();
|
|
13
|
+
if (job === null) {
|
|
14
|
+
throw new Error('Unable to create crawl job: empty response');
|
|
15
|
+
}
|
|
16
|
+
return job;
|
|
17
|
+
}
|
|
18
|
+
/** Update a crawl job's status ('started', 'finished', 'cancelled'). */
|
|
19
|
+
async updateStatus(crawlJobId, status) {
|
|
20
|
+
const result = await this.requestObject('/pulse/crawl-jobs/' + crawlJobId, { status }, CrawlJob.parse, 'PATCH');
|
|
21
|
+
const job = result.getData();
|
|
22
|
+
if (job === null) {
|
|
23
|
+
throw new Error('Unable to update crawl job: empty response');
|
|
24
|
+
}
|
|
25
|
+
return job;
|
|
26
|
+
}
|
|
27
|
+
/** The crawl job with this id, or null. */
|
|
28
|
+
async getById(crawlJobId) {
|
|
29
|
+
const result = await this.requestObject('/pulse/crawl-jobs/' + crawlJobId, null, CrawlJob.parse, 'GET');
|
|
30
|
+
return result.getData();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -4,6 +4,10 @@ import { CollectionResult } from '../Model/Result/CollectionResult.js';
|
|
|
4
4
|
import { Endpoint } from './Endpoint.js';
|
|
5
5
|
export declare class RunnerPoolEndpoint extends Endpoint {
|
|
6
6
|
getByProjectEnvironment(projectEnvironmentId: string, pagination?: CursorPagination | null): Promise<CollectionResult<RunnerPool>>;
|
|
7
|
+
create(projectEnvironmentId: string, pool: RunnerPoolCreate): Promise<RunnerPool | null>;
|
|
7
8
|
getById(queueSpecificationId: string): Promise<RunnerPool | null>;
|
|
8
9
|
redeploy(runnerPoolId: string): Promise<void>;
|
|
9
10
|
}
|
|
11
|
+
export interface RunnerPoolCreate {
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
@@ -8,6 +8,14 @@ export class RunnerPoolEndpoint extends Endpoint {
|
|
|
8
8
|
const result = await this.requestCollection(queryString, RunnerPool.parse);
|
|
9
9
|
return result;
|
|
10
10
|
}
|
|
11
|
+
async create(projectEnvironmentId, pool) {
|
|
12
|
+
const queryString = new QueryString('/runner-pools/project-environments/' + projectEnvironmentId + '');
|
|
13
|
+
const body = {
|
|
14
|
+
name: pool.name,
|
|
15
|
+
};
|
|
16
|
+
const result = await this.requestObject(queryString, body, RunnerPool.parse, 'POST');
|
|
17
|
+
return result.getData();
|
|
18
|
+
}
|
|
11
19
|
async getById(queueSpecificationId) {
|
|
12
20
|
const queryString = new QueryString('/runner-pools/' + queueSpecificationId);
|
|
13
21
|
const result = await this.requestObject(queryString, null, RunnerPool.parse);
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ export { StorageInformation } from './Model/Storage/StorageInformation.js';
|
|
|
81
81
|
export { StorageType } from './Model/Storage/StorageType.js';
|
|
82
82
|
export { VendorProduct } from './Model/Pulse/VendorProduct.js';
|
|
83
83
|
export { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
84
|
+
export { CrawlJob, CrawlJobStatus } from './Model/Pulse/CrawlJob.js';
|
|
85
|
+
export { CrawlJobEndpoint } from './Service/Pulse/CrawlJobEndpoint.js';
|
|
84
86
|
export { StorageItem } from './Model/Storage/StorageItem.js';
|
|
85
87
|
export { StorageItemInformation } from './Model/Storage/StorageItemInformation.js';
|
|
86
88
|
/** Queue * */
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,8 @@ export { StorageInformation } from './Model/Storage/StorageInformation.js';
|
|
|
69
69
|
export { StorageType } from './Model/Storage/StorageType.js';
|
|
70
70
|
export { VendorProduct } from './Model/Pulse/VendorProduct.js';
|
|
71
71
|
export { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
72
|
+
export { CrawlJob } from './Model/Pulse/CrawlJob.js';
|
|
73
|
+
export { CrawlJobEndpoint } from './Service/Pulse/CrawlJobEndpoint.js';
|
|
72
74
|
export { StorageItem } from './Model/Storage/StorageItem.js';
|
|
73
75
|
export { StorageItemInformation } from './Model/Storage/StorageItemInformation.js';
|
|
74
76
|
/** Queue * */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.85.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.85.0";
|