@attlaz/client 1.82.0 → 1.84.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/README.md +2 -2
- package/dist/Client.d.ts +2 -0
- package/dist/Client.js +5 -0
- package/dist/Model/Pulse/VendorProduct.d.ts +26 -0
- package/dist/Model/Pulse/VendorProduct.js +53 -0
- package/dist/Service/AccessTokenEndpoint.d.ts +1 -1
- package/dist/Service/AccessTokenEndpoint.js +2 -2
- package/dist/Service/Pulse/VendorProductEndpoint.d.ts +14 -0
- package/dist/Service/Pulse/VendorProductEndpoint.js +49 -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 +3 -3
package/README.md
CHANGED
|
@@ -12,13 +12,13 @@ Getting Started
|
|
|
12
12
|
Install Attlaz using `yarn`:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
yarn add attlaz
|
|
15
|
+
yarn add @attlaz/client
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Or npm, if you wish:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npm install attlaz
|
|
21
|
+
npm install @attlaz/client
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Getting Help
|
package/dist/Client.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { PlatformLanguageEndpoint } from './Service/PlatformLanguageEndpoint.js'
|
|
|
24
24
|
import { ProjectEndpoint } from './Service/ProjectEndpoint.js';
|
|
25
25
|
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint.js';
|
|
26
26
|
import { ProviderTokenEndpoint } from './Service/ProviderTokenEndpoint.js';
|
|
27
|
+
import { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
27
28
|
import { RunnerEndpoint } from './Service/RunnerEndpoint.js';
|
|
28
29
|
import { RunnerPoolEndpoint } from './Service/RunnerPoolEndpoint.js';
|
|
29
30
|
import { SearchEndpoint } from './Service/SearchEndpoint.js';
|
|
@@ -109,6 +110,7 @@ export declare class Client {
|
|
|
109
110
|
getRunnerPoolEndpoint(): RunnerPoolEndpoint;
|
|
110
111
|
getProviderTokenEndpoint(): ProviderTokenEndpoint;
|
|
111
112
|
getFirewallEndpoint(): FirewallEndpoint;
|
|
113
|
+
getVendorProductEndpoint(): VendorProductEndpoint;
|
|
112
114
|
private getEndpoint;
|
|
113
115
|
getVersion(): string;
|
|
114
116
|
}
|
package/dist/Client.js
CHANGED
|
@@ -24,6 +24,7 @@ import { PlatformLanguageEndpoint } from './Service/PlatformLanguageEndpoint.js'
|
|
|
24
24
|
import { ProjectEndpoint } from './Service/ProjectEndpoint.js';
|
|
25
25
|
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint.js';
|
|
26
26
|
import { ProviderTokenEndpoint } from './Service/ProviderTokenEndpoint.js';
|
|
27
|
+
import { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
27
28
|
import { RunnerEndpoint } from './Service/RunnerEndpoint.js';
|
|
28
29
|
import { RunnerPoolEndpoint } from './Service/RunnerPoolEndpoint.js';
|
|
29
30
|
import { SearchEndpoint } from './Service/SearchEndpoint.js';
|
|
@@ -75,6 +76,7 @@ export class Client {
|
|
|
75
76
|
CollectionsEndpoint,
|
|
76
77
|
RunnerPoolEndpoint,
|
|
77
78
|
ProviderTokenEndpoint,
|
|
79
|
+
VendorProductEndpoint,
|
|
78
80
|
};
|
|
79
81
|
apiEndpoint = 'https://api.attlaz.com';
|
|
80
82
|
constructor(token = null, config = {}) {
|
|
@@ -256,6 +258,9 @@ export class Client {
|
|
|
256
258
|
getFirewallEndpoint() {
|
|
257
259
|
return this.getEndpoint('firewall', this.Store.FirewallEndpoint);
|
|
258
260
|
}
|
|
261
|
+
getVendorProductEndpoint() {
|
|
262
|
+
return this.getEndpoint('vendor-product', this.Store.VendorProductEndpoint);
|
|
263
|
+
}
|
|
259
264
|
getEndpoint(key, ClassName) {
|
|
260
265
|
if (!this.endpoints.has(key)) {
|
|
261
266
|
try {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ApiRecord } from '../ApiRecord.js';
|
|
2
|
+
/**
|
|
3
|
+
* A competitor's product as tracked by Market Pulse — the `/pulse/vendors/:vendorId/products`
|
|
4
|
+
* resource. `identifier` is the product's stable id on the competitor's site (the upsert key).
|
|
5
|
+
*/
|
|
6
|
+
export declare class VendorProduct {
|
|
7
|
+
id: string | null;
|
|
8
|
+
vendorId: string;
|
|
9
|
+
identifier: string;
|
|
10
|
+
name: string | null;
|
|
11
|
+
image: string | null;
|
|
12
|
+
gtin: string | null;
|
|
13
|
+
brand: string | null;
|
|
14
|
+
url: string | null;
|
|
15
|
+
sku: string | null;
|
|
16
|
+
currency: string | null;
|
|
17
|
+
price: number | null;
|
|
18
|
+
originalPrice: number | null;
|
|
19
|
+
shippingCost: number | null;
|
|
20
|
+
isInStock: boolean | null;
|
|
21
|
+
properties: Record<string, unknown> | null;
|
|
22
|
+
createdAt: Date | null;
|
|
23
|
+
updatedAt: Date | null;
|
|
24
|
+
constructor(vendorId: string, identifier: string);
|
|
25
|
+
static parse(raw: ApiRecord): VendorProduct;
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A competitor's product as tracked by Market Pulse — the `/pulse/vendors/:vendorId/products`
|
|
3
|
+
* resource. `identifier` is the product's stable id on the competitor's site (the upsert key).
|
|
4
|
+
*/
|
|
5
|
+
export class VendorProduct {
|
|
6
|
+
id = null;
|
|
7
|
+
vendorId;
|
|
8
|
+
identifier;
|
|
9
|
+
name = null;
|
|
10
|
+
image = null;
|
|
11
|
+
gtin = null;
|
|
12
|
+
brand = null;
|
|
13
|
+
url = null;
|
|
14
|
+
sku = null;
|
|
15
|
+
currency = null;
|
|
16
|
+
price = null;
|
|
17
|
+
originalPrice = null;
|
|
18
|
+
shippingCost = null;
|
|
19
|
+
isInStock = null;
|
|
20
|
+
properties = null;
|
|
21
|
+
createdAt = null;
|
|
22
|
+
updatedAt = null;
|
|
23
|
+
constructor(vendorId, identifier) {
|
|
24
|
+
this.vendorId = vendorId;
|
|
25
|
+
this.identifier = identifier;
|
|
26
|
+
}
|
|
27
|
+
static parse(raw) {
|
|
28
|
+
const product = new VendorProduct(raw.vendor, raw.identifier);
|
|
29
|
+
product.id = raw.id ?? null;
|
|
30
|
+
product.name = raw.name ?? null;
|
|
31
|
+
product.image = raw.image ?? null;
|
|
32
|
+
product.gtin = raw.gtin ?? null;
|
|
33
|
+
product.brand = raw.brand ?? null;
|
|
34
|
+
product.url = raw.url ?? null;
|
|
35
|
+
product.sku = raw.sku ?? null;
|
|
36
|
+
product.currency = raw.currency ?? null;
|
|
37
|
+
product.price = toNumber(raw.price);
|
|
38
|
+
product.originalPrice = toNumber(raw.original_price);
|
|
39
|
+
product.shippingCost = toNumber(raw.shipping_cost);
|
|
40
|
+
product.isInStock = typeof raw.is_in_stock === 'boolean' ? raw.is_in_stock : null;
|
|
41
|
+
product.properties = raw.properties ?? null;
|
|
42
|
+
product.createdAt = raw.created_at ? new Date(raw.created_at) : null;
|
|
43
|
+
product.updatedAt = raw.updated_at ? new Date(raw.updated_at) : null;
|
|
44
|
+
return product;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function toNumber(value) {
|
|
48
|
+
if (value === null || value === undefined || value === '') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const n = Number(value);
|
|
52
|
+
return Number.isFinite(n) ? n : null;
|
|
53
|
+
}
|
|
@@ -6,6 +6,6 @@ import { Endpoint } from './Endpoint.js';
|
|
|
6
6
|
export declare class AccessTokenEndpoint extends Endpoint {
|
|
7
7
|
getByUser(pagination: CursorPagination, status?: UserAccessTokenStatus | null): Promise<CollectionResult<UserAccessToken>>;
|
|
8
8
|
create(name: string, scopes: string[], expiresAt: Date): Promise<UserAccessToken>;
|
|
9
|
-
update(tokenId: string, name: string
|
|
9
|
+
update(tokenId: string, name: string): Promise<UserAccessToken>;
|
|
10
10
|
revoke(tokenId: string): Promise<boolean>;
|
|
11
11
|
}
|
|
@@ -41,11 +41,11 @@ export class AccessTokenEndpoint extends Endpoint {
|
|
|
41
41
|
throw ex;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
async update(tokenId, name
|
|
44
|
+
async update(tokenId, name) {
|
|
45
45
|
try {
|
|
46
46
|
const url = '/access-tokens/' + tokenId;
|
|
47
47
|
const result = await this.requestObject(url, {
|
|
48
|
-
name,
|
|
48
|
+
name,
|
|
49
49
|
}, UserAccessToken.parse, 'POST');
|
|
50
50
|
const updatedToken = result.getData();
|
|
51
51
|
if (updatedToken === null) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VendorProduct } from '../../Model/Pulse/VendorProduct.js';
|
|
2
|
+
import { Endpoint } from '../Endpoint.js';
|
|
3
|
+
/**
|
|
4
|
+
* Market Pulse competitor products — `/pulse/vendors/:vendorId/products`. Mirrors the PHP client's
|
|
5
|
+
* MarketPulse\VendorProductEndpoint so the (Node) scraper can upsert competitor products.
|
|
6
|
+
*/
|
|
7
|
+
export declare class VendorProductEndpoint extends Endpoint {
|
|
8
|
+
/** The product with this identifier for the vendor, or null. */
|
|
9
|
+
getByIdentifier(vendorId: string, identifier: string): Promise<VendorProduct | null>;
|
|
10
|
+
/** Create a new vendor product. */
|
|
11
|
+
save(product: VendorProduct): Promise<VendorProduct>;
|
|
12
|
+
/** Update the mutable fields of an existing vendor product (JSON-patch style, per the API). */
|
|
13
|
+
update(product: VendorProduct): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { VendorProduct } from '../../Model/Pulse/VendorProduct.js';
|
|
2
|
+
import { Endpoint } from '../Endpoint.js';
|
|
3
|
+
/**
|
|
4
|
+
* Market Pulse competitor products — `/pulse/vendors/:vendorId/products`. Mirrors the PHP client's
|
|
5
|
+
* MarketPulse\VendorProductEndpoint so the (Node) scraper can upsert competitor products.
|
|
6
|
+
*/
|
|
7
|
+
export class VendorProductEndpoint extends Endpoint {
|
|
8
|
+
/** The product with this identifier for the vendor, or null. */
|
|
9
|
+
async getByIdentifier(vendorId, identifier) {
|
|
10
|
+
const result = await this.requestCollection('/pulse/vendors/' + vendorId + '/products?identifier=' + encodeURIComponent(identifier), VendorProduct.parse);
|
|
11
|
+
const products = result.getData();
|
|
12
|
+
return products.length > 0 ? products[0] : null;
|
|
13
|
+
}
|
|
14
|
+
/** Create a new vendor product. */
|
|
15
|
+
async save(product) {
|
|
16
|
+
// camelCase keys are snake_cased by the base Endpoint (originalPrice -> original_price, ...).
|
|
17
|
+
const body = {
|
|
18
|
+
name: product.name,
|
|
19
|
+
image: product.image,
|
|
20
|
+
identifier: product.identifier,
|
|
21
|
+
gtin: product.gtin,
|
|
22
|
+
brand: product.brand,
|
|
23
|
+
url: product.url,
|
|
24
|
+
currency: product.currency,
|
|
25
|
+
price: product.price,
|
|
26
|
+
originalPrice: product.originalPrice,
|
|
27
|
+
shippingCost: product.shippingCost,
|
|
28
|
+
isInStock: product.isInStock,
|
|
29
|
+
properties: product.properties,
|
|
30
|
+
};
|
|
31
|
+
const result = await this.requestObject('/pulse/vendors/' + product.vendorId + '/products', body, VendorProduct.parse, 'POST');
|
|
32
|
+
return result.getData() ?? product;
|
|
33
|
+
}
|
|
34
|
+
/** Update the mutable fields of an existing vendor product (JSON-patch style, per the API). */
|
|
35
|
+
async update(product) {
|
|
36
|
+
const operations = [
|
|
37
|
+
{ op: 'add', path: 'price', value: product.price },
|
|
38
|
+
{ op: 'add', path: 'original_price', value: product.originalPrice },
|
|
39
|
+
{ op: 'add', path: 'brand', value: product.brand },
|
|
40
|
+
{ op: 'add', path: 'shipping_cost', value: product.shippingCost },
|
|
41
|
+
{ op: 'add', path: 'is_in_stock', value: product.isInStock },
|
|
42
|
+
{ op: 'add', path: 'url', value: product.url },
|
|
43
|
+
{ op: 'add', path: 'gtin', value: product.gtin },
|
|
44
|
+
{ op: 'add', path: 'image', value: product.image },
|
|
45
|
+
{ op: 'add', path: 'properties', value: product.properties },
|
|
46
|
+
];
|
|
47
|
+
await this.requestObject('/pulse/vendors/' + product.vendorId + '/products/' + product.id, operations, (raw) => raw, 'PATCH');
|
|
48
|
+
}
|
|
49
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,8 @@ export { ObjectResult } from './Model/Result/ObjectResult.js';
|
|
|
79
79
|
export { ResultError } from './Model/Result/ResultError.js';
|
|
80
80
|
export { StorageInformation } from './Model/Storage/StorageInformation.js';
|
|
81
81
|
export { StorageType } from './Model/Storage/StorageType.js';
|
|
82
|
+
export { VendorProduct } from './Model/Pulse/VendorProduct.js';
|
|
83
|
+
export { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
82
84
|
export { StorageItem } from './Model/Storage/StorageItem.js';
|
|
83
85
|
export { StorageItemInformation } from './Model/Storage/StorageItemInformation.js';
|
|
84
86
|
/** Queue * */
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,8 @@ export { ObjectResult } from './Model/Result/ObjectResult.js';
|
|
|
67
67
|
export { ResultError } from './Model/Result/ResultError.js';
|
|
68
68
|
export { StorageInformation } from './Model/Storage/StorageInformation.js';
|
|
69
69
|
export { StorageType } from './Model/Storage/StorageType.js';
|
|
70
|
+
export { VendorProduct } from './Model/Pulse/VendorProduct.js';
|
|
71
|
+
export { VendorProductEndpoint } from './Service/Pulse/VendorProductEndpoint.js';
|
|
70
72
|
export { StorageItem } from './Model/Storage/StorageItem.js';
|
|
71
73
|
export { StorageItemInformation } from './Model/Storage/StorageItemInformation.js';
|
|
72
74
|
/** Queue * */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.83.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.83.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attlaz/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.84.0",
|
|
4
4
|
"description": "Javascript Client to access Attlaz API",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/node": "^26.1.1",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
56
56
|
"@typescript-eslint/parser": "^8.59.3",
|
|
57
|
-
"eslint": "^9.39.
|
|
57
|
+
"eslint": "^9.39.5",
|
|
58
58
|
"eslint-config-attlaz-base": "^1.8.0",
|
|
59
59
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
60
60
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint-plugin-promise": "^7.3.0",
|
|
64
64
|
"jest": "^30.4.2",
|
|
65
65
|
"rimraf": "^6.1.3",
|
|
66
|
-
"ts-jest": "^29.4.
|
|
66
|
+
"ts-jest": "^29.4.12",
|
|
67
67
|
"typescript": "^6.0.3"
|
|
68
68
|
},
|
|
69
69
|
"directories": {
|