@adobe-commerce/aio-toolkit 1.2.1 → 1.2.3
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/CHANGELOG.md +148 -0
- package/README.md +130 -20
- package/dist/index.d.mts +57 -8
- package/dist/index.d.ts +57 -8
- package/dist/index.js +3503 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3496 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,154 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.3] - 2026-04-01
|
|
9
|
+
|
|
10
|
+
### ✨ Features
|
|
11
|
+
|
|
12
|
+
- **feat(integration): Add `RabbitMQClient` — push-based AMQP consumer and publisher**
|
|
13
|
+
|
|
14
|
+
New `RabbitMQClient` class in `src/integration/rabbit-mq-client` provides a
|
|
15
|
+
clean, typed interface for consuming and publishing messages via AMQP (RabbitMQ).
|
|
16
|
+
|
|
17
|
+
**`consume(queueName, options, handler)`**
|
|
18
|
+
- Checks queue depth via `channel.checkQueue` — skips immediately when empty
|
|
19
|
+
- Sets `channel.prefetch(maxParallel)` for broker-side concurrency control
|
|
20
|
+
- Processes `effectiveBatch = min(batchSize, messageCount)` messages
|
|
21
|
+
- Acks on successful handler execution; nacks on failure (requeue configurable)
|
|
22
|
+
- Optional exchange assertion and queue binding via `options.exchange`
|
|
23
|
+
- Returns `ConsumeStats` — consumed, acked, nacked counts plus per-failure details
|
|
24
|
+
|
|
25
|
+
**`publish(queueName, payloads)`**
|
|
26
|
+
- Asserts queue and sends each payload via `sendToQueue` with `persistent: true`
|
|
27
|
+
- Records write-buffer-full (`sendToQueue` returns `false`) and thrown errors
|
|
28
|
+
- Returns `PublishStats` — published and failed counts plus per-failure details
|
|
29
|
+
|
|
30
|
+
Both methods open a dedicated connection per call and always close channel and
|
|
31
|
+
connection in a `finally` block.
|
|
32
|
+
|
|
33
|
+
**Exported types** (from `rabbit-mq-client/types`):
|
|
34
|
+
`RabbitMQCredentials`, `RabbitMQConsumeOptions`, `MessageHandler`,
|
|
35
|
+
`ConsumeStats`, `PublishStats`
|
|
36
|
+
|
|
37
|
+
**Note:** `batchSize` and `maxParallel` are required in `RabbitMQConsumeOptions`
|
|
38
|
+
— the caller must choose appropriate limits for their workload.
|
|
39
|
+
|
|
40
|
+
### 🐛 Bug Fixes
|
|
41
|
+
|
|
42
|
+
- **fix(abdb): Preserve `error.cause` on `AbdbCollection` thrown errors**
|
|
43
|
+
|
|
44
|
+
`run()` now assigns `.cause` to each re-thrown `Error` so callers can access
|
|
45
|
+
the original error via `err.cause`. Previously the root cause was silently
|
|
46
|
+
discarded. Assignment is done via `(err as any).cause` for compatibility with
|
|
47
|
+
the ES2020 TypeScript target (the ES2022 `Error(msg, { cause })` constructor
|
|
48
|
+
overload is not available in ES2020 lib typings).
|
|
49
|
+
|
|
50
|
+
- **fix(abdb): Guard `DbError instanceof` check against undefined export**
|
|
51
|
+
|
|
52
|
+
The `DbError` branch now uses `DbError && error instanceof DbError` so the
|
|
53
|
+
code does not throw a `TypeError` in environments where `@adobe/aio-lib-db`
|
|
54
|
+
does not export `DbError` at runtime. Unrecognised errors fall through to the
|
|
55
|
+
`unexpected error` path as expected.
|
|
56
|
+
|
|
57
|
+
- **fix(abdb): Correct file header comment in `adobe-aio-lib-db.d.ts`**
|
|
58
|
+
|
|
59
|
+
The comment incorrectly read `@adobe/aio-lib-ims`; updated to `@adobe/aio-lib-db`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## [1.2.2] - 2026-04-01
|
|
64
|
+
|
|
65
|
+
### 🐛 Bug Fixes
|
|
66
|
+
|
|
67
|
+
- **fix(abdb): Fixed `AbdbRepository` update path — `_updated_at` was placed outside `$set`**
|
|
68
|
+
|
|
69
|
+
`save(payload, id)` delegated to `updateOne` with `{ $set: payload }` as the payload, but `updateOne` then spread that into `{ $set: payload, _updated_at: now }`. The `_updated_at` key landed at the top level alongside `$set`, making it an invalid MongoDB update document. The `$set` wrapping is now done inside `updateOne` and `update`, so timestamps are always nested correctly.
|
|
70
|
+
|
|
71
|
+
- **fix(abdb): Fixed `update` method passing an array to `updateMany`**
|
|
72
|
+
|
|
73
|
+
`update` (previously `updateAll`) accepted `Array<Partial<T>> | Partial<T>` and always converted the input to an array before passing it as the second argument to `updateMany`. MongoDB's `updateMany` expects a **single** update document, not an array — this caused silent failures at runtime. The method now accepts a single `Partial<T>` and wraps it in `{ $set: ... }`.
|
|
74
|
+
|
|
75
|
+
- **fix(abdb): Fixed full schema validation on partial update payloads**
|
|
76
|
+
|
|
77
|
+
`updateOne` and `update` were calling `this._collection.validate()` (full validation — all required fields must be present) on update payloads. This caused spurious validation errors when patching a subset of fields. Both methods now use `_validatePartial`, which only checks the columns present in the payload.
|
|
78
|
+
|
|
79
|
+
### ✨ Features
|
|
80
|
+
|
|
81
|
+
- **feat(abdb): Expanded `AbdbRepository` API with granular single- and bulk-operation methods**
|
|
82
|
+
|
|
83
|
+
Five new public methods covering the full MongoDB CRUD surface:
|
|
84
|
+
|
|
85
|
+
| New method | Description |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `findById(id)` | Shorthand for `findOne({ _id: new ObjectId(id) })` |
|
|
88
|
+
| `insertOne(payload)` | Single-document insert via `insertOne`; stamps timestamps and validates |
|
|
89
|
+
| `updateOne(payload, filter?, options?)` | Single-document update via `updateOne` with `$set` wrapping and partial validation |
|
|
90
|
+
| `deleteOne(filter?)` | Single-document delete via `deleteOne`; returns raw result |
|
|
91
|
+
| `deleteById(id)` | Shorthand for `deleteOne({ _id: new ObjectId(id) })` |
|
|
92
|
+
|
|
93
|
+
- **feat(abdb): `save` delegates to `insertOne` / `updateOne`** — eliminates duplicated timestamp-stamping and validation logic.
|
|
94
|
+
|
|
95
|
+
- **feat(abdb): Split `exists` into `isIdExists` and `exists(filter, options?)`**
|
|
96
|
+
|
|
97
|
+
The original `exists(id: string)` only supported lookup by `_id`. It has been renamed to `isIdExists(id)` (preserving the empty-id guard that returns `false` without hitting the DB), and a new general-purpose `exists(filter?, options?)` method has been added that accepts any filter and proxies to `count`.
|
|
98
|
+
|
|
99
|
+
- **feat(abdb): `count` now accepts an optional `options` parameter**
|
|
100
|
+
|
|
101
|
+
`count(filter?, options?)` now forwards `options` to the underlying `countDocuments` call, enabling fine-grained control such as `{ limit: 1 }` for fast existence probes.
|
|
102
|
+
|
|
103
|
+
### ⚠️ Breaking Changes
|
|
104
|
+
|
|
105
|
+
- **`exists(id: string)` renamed to `isIdExists(id: string)`**
|
|
106
|
+
|
|
107
|
+
`exists` now accepts a general-purpose filter object. Any caller using `repo.exists(someId)` must switch to `repo.isIdExists(someId)`.
|
|
108
|
+
|
|
109
|
+
- **`delete(id: string)` → `delete(filter: AbdbRepositoryFilter)`**
|
|
110
|
+
|
|
111
|
+
`delete` previously accepted a string `_id` and silently no-oped when the id was empty. It now accepts a filter object and uses `deleteMany` under the hood (consistent with `deleteAll`). Use `deleteById(id)` for the old single-by-id behaviour.
|
|
112
|
+
|
|
113
|
+
- **`insertAll` renamed to `insert`** — identical behaviour, new name aligns with `insertOne`.
|
|
114
|
+
|
|
115
|
+
- **`updateAll` renamed to `update`** — identical behaviour (plus bug fixes above), new name aligns with `updateOne`.
|
|
116
|
+
|
|
117
|
+
- **Return types of all mutation methods changed to `Promise<Record<string, any>>`**
|
|
118
|
+
|
|
119
|
+
`save`, `insert`, `insertOne`, `update`, `updateOne`, `delete`, `deleteOne`, `deleteById`, and `deleteAll` previously returned `Promise<string>`, `Promise<string[]>`, `Promise<number>`, or `Promise<void>`. All now return the raw MongoDB result document so callers have access to `acknowledged`, `insertedId`, `insertedIds`, `modifiedCount`, `deletedCount`, etc.
|
|
120
|
+
|
|
121
|
+
### 💡 Migration Guide
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
// existence check by id — OLD
|
|
125
|
+
const found = await repo.exists(id);
|
|
126
|
+
// existence check by id — NEW
|
|
127
|
+
const found = await repo.isIdExists(id);
|
|
128
|
+
|
|
129
|
+
// general existence check (new) — by any filter
|
|
130
|
+
const active = await repo.exists({ status: 'active' });
|
|
131
|
+
|
|
132
|
+
// delete by id — OLD
|
|
133
|
+
await repo.delete(id);
|
|
134
|
+
// delete by id — NEW
|
|
135
|
+
await repo.deleteById(id);
|
|
136
|
+
|
|
137
|
+
// bulk insert — OLD
|
|
138
|
+
const ids = await repo.insertAll([...]);
|
|
139
|
+
// bulk insert — NEW
|
|
140
|
+
const result = await repo.insert([...]); // result.insertedIds contains the ids
|
|
141
|
+
|
|
142
|
+
// bulk update — OLD
|
|
143
|
+
await repo.updateAll({ active: false }, { email: 'bob@example.com' });
|
|
144
|
+
// bulk update — NEW
|
|
145
|
+
await repo.update({ active: false }, { email: 'bob@example.com' });
|
|
146
|
+
|
|
147
|
+
// return value of save (insert path) — OLD: string _id
|
|
148
|
+
const id = await repo.save({ name: 'Jane', email: 'jane@example.com' });
|
|
149
|
+
// return value of save (insert path) — NEW: raw insertOne result
|
|
150
|
+
const result = await repo.save({ name: 'Jane', email: 'jane@example.com' });
|
|
151
|
+
// result.insertedId contains the new _id
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
8
156
|
## [1.2.1] - 2026-03-31
|
|
9
157
|
|
|
10
158
|
### ✨ Features
|
package/README.md
CHANGED
|
@@ -848,7 +848,7 @@ A generic CRUD repository that wraps an `AbdbCollection` and holds the IMS token
|
|
|
848
848
|
##### Basic usage
|
|
849
849
|
|
|
850
850
|
```javascript
|
|
851
|
-
const { AbdbRepository
|
|
851
|
+
const { AbdbRepository } = require('@adobe-commerce/aio-toolkit');
|
|
852
852
|
const { generateAccessToken } = require('@adobe/aio-sdk').Core.AuthClient;
|
|
853
853
|
const UserCollection = require('@lib/UserCollection');
|
|
854
854
|
|
|
@@ -858,11 +858,12 @@ exports.main = async (params) => {
|
|
|
858
858
|
|
|
859
859
|
const repo = new AbdbRepository(new UserCollection(), accessToken);
|
|
860
860
|
|
|
861
|
-
// Insert — returns the new
|
|
862
|
-
const
|
|
861
|
+
// Insert — returns raw insertOne result (result.insertedId contains the new _id)
|
|
862
|
+
const insertResult = await repo.save({ first_name: 'Jane', last_name: 'Doe', email: 'jane@example.com' });
|
|
863
|
+
const id = insertResult.insertedId;
|
|
863
864
|
|
|
864
|
-
// Read
|
|
865
|
-
const doc = await repo.
|
|
865
|
+
// Read by _id (shorthand)
|
|
866
|
+
const doc = await repo.findById(id);
|
|
866
867
|
|
|
867
868
|
// Read one by any field
|
|
868
869
|
const byEmail = await repo.findOne({ email: 'jane@example.com' });
|
|
@@ -874,8 +875,8 @@ exports.main = async (params) => {
|
|
|
874
875
|
// Partial update — only provided fields are validated; required fields already in the DB are not re-checked
|
|
875
876
|
await repo.save({ first_name: 'Janet' }, id);
|
|
876
877
|
|
|
877
|
-
// Delete
|
|
878
|
-
await repo.
|
|
878
|
+
// Delete by _id
|
|
879
|
+
await repo.deleteById(id);
|
|
879
880
|
};
|
|
880
881
|
```
|
|
881
882
|
|
|
@@ -896,21 +897,26 @@ These are added once per collection instance, so re-using the same collection ac
|
|
|
896
897
|
|
|
897
898
|
| Method | Description | Returns |
|
|
898
899
|
|---|---|---|
|
|
899
|
-
| `save(payload)` | Insert
|
|
900
|
-
| `save(payload, id)` |
|
|
901
|
-
| `
|
|
900
|
+
| `save(payload)` | Insert via `insertOne` (full validation, stamps both timestamps) | `Promise<Record<string, any>>` — raw `insertOne` result |
|
|
901
|
+
| `save(payload, id)` | Update via `updateOne` with `upsert: true` (partial validation, stamps `_updated_at`) | `Promise<Record<string, any>>` — raw `updateOne` result |
|
|
902
|
+
| `insertOne(payload)` | Single-document insert (full validation, stamps both timestamps) | `Promise<Record<string, any>>` — raw `insertOne` result (e.g. `insertedId`) |
|
|
903
|
+
| `updateOne(payload, filter?, options?)` | Single-document update via `{ $set: payload }` (partial validation, stamps `_updated_at`) | `Promise<Record<string, any>>` — raw `updateOne` result (e.g. `modifiedCount`) |
|
|
904
|
+
| `findOne(filter)` | First document matching filter, e.g. `{ email: 'a@b.com' }` | `Promise<T \| null>` |
|
|
905
|
+
| `findById(id)` | Shorthand for `findOne({ _id: new ObjectId(id) })` | `Promise<T \| null>` |
|
|
902
906
|
| `find(filter?)` | All documents matching filter (default: all) | `Promise<T[]>` |
|
|
903
|
-
| `
|
|
904
|
-
| `
|
|
905
|
-
| `
|
|
907
|
+
| `isIdExists(id)` | Returns `true` if a document with the given `_id` exists (no-op for empty id) | `Promise<boolean>` |
|
|
908
|
+
| `exists(filter?, options?)` | Returns `true` if any document matching `filter` exists via `countDocuments` | `Promise<boolean>` |
|
|
909
|
+
| `deleteOne(filter?)` | Delete first matching document via `deleteOne` | `Promise<Record<string, any>>` — raw `deleteOne` result |
|
|
910
|
+
| `deleteById(id)` | Shorthand for `deleteOne({ _id: new ObjectId(id) })` | `Promise<Record<string, any>>` |
|
|
911
|
+
| `count(filter?, options?)` | Count matching documents via `countDocuments` (default: all) | `Promise<number>` |
|
|
906
912
|
|
|
907
913
|
**Bulk operations (single DB round-trip each):**
|
|
908
914
|
|
|
909
915
|
| Method | Description | Returns |
|
|
910
916
|
|---|---|---|
|
|
911
|
-
| `
|
|
912
|
-
| `
|
|
913
|
-
| `
|
|
917
|
+
| `insert(payloads[])` | Bulk insert via `insertMany` — each payload stamped and validated | `Promise<Record<string, any>>` — raw `insertMany` result (e.g. `insertedIds`) |
|
|
918
|
+
| `update(payload, filter?, options?)` | Bulk update via `updateMany` with `{ $set: payload }` — stamps `_updated_at`, partial validation | `Promise<Record<string, any>>` — raw `updateMany` result (e.g. `modifiedCount`) |
|
|
919
|
+
| `delete(filter?)` | Bulk delete via `deleteMany` (default: all documents) | `Promise<Record<string, any>>` — raw `deleteMany` result (e.g. `deletedCount`) |
|
|
914
920
|
|
|
915
921
|
**Accessors:**
|
|
916
922
|
|
|
@@ -930,19 +936,22 @@ const repo = new AbdbRepository(new UserCollection(), accessToken, 'emea');
|
|
|
930
936
|
|
|
931
937
|
```javascript
|
|
932
938
|
// Insert multiple documents in one DB call
|
|
933
|
-
const
|
|
939
|
+
const result = await repo.insert([
|
|
934
940
|
{ first_name: 'Alice', last_name: 'Smith', email: 'alice@example.com' },
|
|
935
941
|
{ first_name: 'Bob', last_name: 'Jones', email: 'bob@example.com' },
|
|
936
942
|
]);
|
|
943
|
+
console.log(result.insertedIds); // array of inserted _id values
|
|
937
944
|
|
|
938
945
|
// Update all matching documents in one DB call
|
|
939
|
-
await repo.
|
|
946
|
+
const updateResult = await repo.update({ active: false }, { email: 'bob@example.com' });
|
|
947
|
+
console.log(updateResult.modifiedCount); // number of documents updated
|
|
940
948
|
|
|
941
949
|
// Delete all matching documents in one DB call
|
|
942
|
-
await repo.
|
|
950
|
+
const deleteResult = await repo.delete({ active: false });
|
|
951
|
+
console.log(deleteResult.deletedCount); // number of documents deleted
|
|
943
952
|
|
|
944
953
|
// Delete everything in the collection
|
|
945
|
-
await repo.
|
|
954
|
+
await repo.delete();
|
|
946
955
|
```
|
|
947
956
|
|
|
948
957
|
### 🏪 Commerce Components
|
|
@@ -1499,6 +1508,107 @@ if (directInfo.isValid) {
|
|
|
1499
1508
|
- `extract(headersOrParams)` - Extracts Bearer token from headers or OpenWhisk params
|
|
1500
1509
|
- `info(token)` - Analyzes token string and returns validation/expiry details
|
|
1501
1510
|
|
|
1511
|
+
#### `RabbitMQClient`
|
|
1512
|
+
Push-based AMQP consumer and publisher for RabbitMQ. Manages the full connection lifecycle per call (connect → channel → close) and exposes a clean, typed interface without exposing raw AMQP primitives to the caller.
|
|
1513
|
+
|
|
1514
|
+
**Installation**
|
|
1515
|
+
```bash
|
|
1516
|
+
npm install amqplib
|
|
1517
|
+
```
|
|
1518
|
+
|
|
1519
|
+
**Basic Usage**
|
|
1520
|
+
```typescript
|
|
1521
|
+
const { RabbitMQClient } = require('@adobe-commerce/aio-toolkit');
|
|
1522
|
+
|
|
1523
|
+
const client = new RabbitMQClient({
|
|
1524
|
+
host: 'rabbitmq.example.com',
|
|
1525
|
+
port: '5672',
|
|
1526
|
+
username: 'user',
|
|
1527
|
+
password: 'secret',
|
|
1528
|
+
vhost: '/',
|
|
1529
|
+
secure: false, // set true to use amqps://
|
|
1530
|
+
});
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
**Consuming messages**
|
|
1534
|
+
```typescript
|
|
1535
|
+
const stats = await client.consume(
|
|
1536
|
+
'orders-queue',
|
|
1537
|
+
{ batchSize: 100, maxParallel: 10 },
|
|
1538
|
+
async (queueName, content) => {
|
|
1539
|
+
const order = JSON.parse(content);
|
|
1540
|
+
await processOrder(order);
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
|
|
1544
|
+
console.log(`consumed=${stats.consumed} acked=${stats.acked} nacked=${stats.nacked}`);
|
|
1545
|
+
if (stats.errors.length) {
|
|
1546
|
+
console.error('Failed messages:', stats.errors);
|
|
1547
|
+
}
|
|
1548
|
+
```
|
|
1549
|
+
|
|
1550
|
+
**Consuming with exchange binding**
|
|
1551
|
+
```typescript
|
|
1552
|
+
const stats = await client.consume(
|
|
1553
|
+
'orders-queue',
|
|
1554
|
+
{
|
|
1555
|
+
batchSize: 50,
|
|
1556
|
+
maxParallel: 5,
|
|
1557
|
+
exchange: 'orders-exchange', // asserts exchange + binds queue before consuming
|
|
1558
|
+
nackRequeue: false, // dead-letter failed messages instead of requeueing
|
|
1559
|
+
},
|
|
1560
|
+
async (queueName, content) => {
|
|
1561
|
+
await processOrder(JSON.parse(content));
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
**Publishing messages**
|
|
1567
|
+
```typescript
|
|
1568
|
+
const payloads = orders.map(o => JSON.stringify(o));
|
|
1569
|
+
const stats = await client.publish('orders-queue', payloads);
|
|
1570
|
+
|
|
1571
|
+
console.log(`published=${stats.published} failed=${stats.failed}`);
|
|
1572
|
+
if (stats.errors.length) {
|
|
1573
|
+
console.error('Failed payloads:', stats.errors);
|
|
1574
|
+
}
|
|
1575
|
+
```
|
|
1576
|
+
|
|
1577
|
+
**API Reference**
|
|
1578
|
+
|
|
1579
|
+
| Method | Description | Returns |
|
|
1580
|
+
|---|---|---|
|
|
1581
|
+
| `consume(queueName, options, handler)` | Checks queue depth, sets prefetch, and push-consumes up to `batchSize` messages | `Promise<ConsumeStats>` |
|
|
1582
|
+
| `publish(queueName, payloads)` | Asserts queue and enqueues each payload as a persistent message | `Promise<PublishStats>` |
|
|
1583
|
+
|
|
1584
|
+
**`RabbitMQConsumeOptions`**
|
|
1585
|
+
|
|
1586
|
+
| Field | Type | Required | Description |
|
|
1587
|
+
|---|---|---|---|
|
|
1588
|
+
| `batchSize` | `number` | ✅ | Maximum number of messages to process in this call |
|
|
1589
|
+
| `maxParallel` | `number` | ✅ | Max unacked messages in-flight at once (broker-side prefetch) |
|
|
1590
|
+
| `nackRequeue` | `boolean` | — | Requeue on nack (default: `true`) |
|
|
1591
|
+
| `exchange` | `string` | — | If set, asserts a `direct` exchange and binds the queue before consuming |
|
|
1592
|
+
|
|
1593
|
+
**`ConsumeStats`**
|
|
1594
|
+
|
|
1595
|
+
| Field | Type | Description |
|
|
1596
|
+
|---|---|---|
|
|
1597
|
+
| `consumed` | `number` | Total messages received from the broker |
|
|
1598
|
+
| `acked` | `number` | Messages successfully processed and acked |
|
|
1599
|
+
| `nacked` | `number` | Messages that failed handler and were nacked |
|
|
1600
|
+
| `errors` | `Array<{ content: string; error: unknown }>` | Per-failure details |
|
|
1601
|
+
|
|
1602
|
+
**`PublishStats`**
|
|
1603
|
+
|
|
1604
|
+
| Field | Type | Description |
|
|
1605
|
+
|---|---|---|
|
|
1606
|
+
| `published` | `number` | Messages successfully enqueued |
|
|
1607
|
+
| `failed` | `number` | Messages that could not be enqueued |
|
|
1608
|
+
| `errors` | `Array<{ payload: string; error: unknown }>` | Per-failure details (buffer full or thrown) |
|
|
1609
|
+
|
|
1610
|
+
---
|
|
1611
|
+
|
|
1502
1612
|
#### `InfiniteLoopBreaker`
|
|
1503
1613
|
Detect and prevent infinite loops in event-driven applications.
|
|
1504
1614
|
|
package/dist/index.d.mts
CHANGED
|
@@ -281,13 +281,18 @@ declare class AbdbRepository<T extends AbdbRecord = AbdbRecord> {
|
|
|
281
281
|
getCollection(): AbdbCollection;
|
|
282
282
|
find(filter?: AbdbRepositoryFilter): Promise<T[]>;
|
|
283
283
|
findOne(filter: AbdbRepositoryFilter): Promise<T | null>;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
findById(id: string): Promise<T | null>;
|
|
285
|
+
delete(filter?: AbdbRepositoryFilter): Promise<Record<string, any>>;
|
|
286
|
+
deleteOne(filter?: AbdbRepositoryFilter): Promise<Record<string, any>>;
|
|
287
|
+
deleteById(id: string): Promise<Record<string, any>>;
|
|
288
|
+
insert(payloads: Array<Partial<T>>): Promise<Record<string, any>>;
|
|
289
|
+
insertOne(payload: Partial<T>): Promise<Record<string, any>>;
|
|
290
|
+
update(payload: Partial<T>, filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
291
|
+
updateOne(payload: Partial<T>, filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
292
|
+
save(payload?: Partial<T>, id?: string): Promise<Record<string, any>>;
|
|
293
|
+
isIdExists(id: string): Promise<boolean>;
|
|
294
|
+
exists(filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<boolean>;
|
|
295
|
+
count(filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<number>;
|
|
291
296
|
private _validatePartial;
|
|
292
297
|
}
|
|
293
298
|
|
|
@@ -783,6 +788,50 @@ declare class OnboardCommerce {
|
|
|
783
788
|
private logEventSubscriptionSummary;
|
|
784
789
|
}
|
|
785
790
|
|
|
791
|
+
type RabbitMQCredentials = {
|
|
792
|
+
host: string;
|
|
793
|
+
port: string;
|
|
794
|
+
username: string;
|
|
795
|
+
password: string;
|
|
796
|
+
vhost: string;
|
|
797
|
+
secure?: boolean;
|
|
798
|
+
};
|
|
799
|
+
type RabbitMQConsumeOptions = {
|
|
800
|
+
batchSize: number;
|
|
801
|
+
maxParallel: number;
|
|
802
|
+
nackRequeue?: boolean;
|
|
803
|
+
exchange?: string;
|
|
804
|
+
};
|
|
805
|
+
type MessageHandler = (queueName: string, content: string) => Promise<void> | void;
|
|
806
|
+
type ConsumeStats = {
|
|
807
|
+
consumed: number;
|
|
808
|
+
acked: number;
|
|
809
|
+
nacked: number;
|
|
810
|
+
errors: Array<{
|
|
811
|
+
content: string;
|
|
812
|
+
error: unknown;
|
|
813
|
+
}>;
|
|
814
|
+
};
|
|
815
|
+
type PublishStats = {
|
|
816
|
+
published: number;
|
|
817
|
+
failed: number;
|
|
818
|
+
errors: Array<{
|
|
819
|
+
payload: string;
|
|
820
|
+
error: unknown;
|
|
821
|
+
}>;
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
declare class RabbitMQClient {
|
|
825
|
+
private readonly credentials;
|
|
826
|
+
constructor(credentials: RabbitMQCredentials);
|
|
827
|
+
consume(queueName: string, options: RabbitMQConsumeOptions, handler: MessageHandler): Promise<ConsumeStats>;
|
|
828
|
+
publish(queueName: string, payloads: string[]): Promise<PublishStats>;
|
|
829
|
+
private publishBatch;
|
|
830
|
+
private buildConnectionUrl;
|
|
831
|
+
private processBatch;
|
|
832
|
+
private processMessage;
|
|
833
|
+
}
|
|
834
|
+
|
|
786
835
|
declare class AdobeAuth {
|
|
787
836
|
static getToken(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: string[], currentContext?: string): Promise<string>;
|
|
788
837
|
}
|
|
@@ -1078,4 +1127,4 @@ declare class AdminUiSdk {
|
|
|
1078
1127
|
getRegistration(): AdminUiSdkRegistration;
|
|
1079
1128
|
}
|
|
1080
1129
|
|
|
1081
|
-
export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
|
1130
|
+
export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, type MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -281,13 +281,18 @@ declare class AbdbRepository<T extends AbdbRecord = AbdbRecord> {
|
|
|
281
281
|
getCollection(): AbdbCollection;
|
|
282
282
|
find(filter?: AbdbRepositoryFilter): Promise<T[]>;
|
|
283
283
|
findOne(filter: AbdbRepositoryFilter): Promise<T | null>;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
findById(id: string): Promise<T | null>;
|
|
285
|
+
delete(filter?: AbdbRepositoryFilter): Promise<Record<string, any>>;
|
|
286
|
+
deleteOne(filter?: AbdbRepositoryFilter): Promise<Record<string, any>>;
|
|
287
|
+
deleteById(id: string): Promise<Record<string, any>>;
|
|
288
|
+
insert(payloads: Array<Partial<T>>): Promise<Record<string, any>>;
|
|
289
|
+
insertOne(payload: Partial<T>): Promise<Record<string, any>>;
|
|
290
|
+
update(payload: Partial<T>, filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
291
|
+
updateOne(payload: Partial<T>, filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
292
|
+
save(payload?: Partial<T>, id?: string): Promise<Record<string, any>>;
|
|
293
|
+
isIdExists(id: string): Promise<boolean>;
|
|
294
|
+
exists(filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<boolean>;
|
|
295
|
+
count(filter?: AbdbRepositoryFilter, options?: Record<string, any>): Promise<number>;
|
|
291
296
|
private _validatePartial;
|
|
292
297
|
}
|
|
293
298
|
|
|
@@ -783,6 +788,50 @@ declare class OnboardCommerce {
|
|
|
783
788
|
private logEventSubscriptionSummary;
|
|
784
789
|
}
|
|
785
790
|
|
|
791
|
+
type RabbitMQCredentials = {
|
|
792
|
+
host: string;
|
|
793
|
+
port: string;
|
|
794
|
+
username: string;
|
|
795
|
+
password: string;
|
|
796
|
+
vhost: string;
|
|
797
|
+
secure?: boolean;
|
|
798
|
+
};
|
|
799
|
+
type RabbitMQConsumeOptions = {
|
|
800
|
+
batchSize: number;
|
|
801
|
+
maxParallel: number;
|
|
802
|
+
nackRequeue?: boolean;
|
|
803
|
+
exchange?: string;
|
|
804
|
+
};
|
|
805
|
+
type MessageHandler = (queueName: string, content: string) => Promise<void> | void;
|
|
806
|
+
type ConsumeStats = {
|
|
807
|
+
consumed: number;
|
|
808
|
+
acked: number;
|
|
809
|
+
nacked: number;
|
|
810
|
+
errors: Array<{
|
|
811
|
+
content: string;
|
|
812
|
+
error: unknown;
|
|
813
|
+
}>;
|
|
814
|
+
};
|
|
815
|
+
type PublishStats = {
|
|
816
|
+
published: number;
|
|
817
|
+
failed: number;
|
|
818
|
+
errors: Array<{
|
|
819
|
+
payload: string;
|
|
820
|
+
error: unknown;
|
|
821
|
+
}>;
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
declare class RabbitMQClient {
|
|
825
|
+
private readonly credentials;
|
|
826
|
+
constructor(credentials: RabbitMQCredentials);
|
|
827
|
+
consume(queueName: string, options: RabbitMQConsumeOptions, handler: MessageHandler): Promise<ConsumeStats>;
|
|
828
|
+
publish(queueName: string, payloads: string[]): Promise<PublishStats>;
|
|
829
|
+
private publishBatch;
|
|
830
|
+
private buildConnectionUrl;
|
|
831
|
+
private processBatch;
|
|
832
|
+
private processMessage;
|
|
833
|
+
}
|
|
834
|
+
|
|
786
835
|
declare class AdobeAuth {
|
|
787
836
|
static getToken(clientId: string, clientSecret: string, technicalAccountId: string, technicalAccountEmail: string, imsOrgId: string, scopes: string[], currentContext?: string): Promise<string>;
|
|
788
837
|
}
|
|
@@ -1078,4 +1127,4 @@ declare class AdminUiSdk {
|
|
|
1078
1127
|
getRegistration(): AdminUiSdkRegistration;
|
|
1079
1128
|
}
|
|
1080
1129
|
|
|
1081
|
-
export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
|
1130
|
+
export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, type MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|