@adobe-commerce/aio-toolkit 1.2.0 → 1.2.2

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 CHANGED
@@ -5,6 +5,148 @@ 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.2] - 2026-04-01
9
+
10
+ ### 🐛 Bug Fixes
11
+
12
+ - **fix(abdb): Fixed `AbdbRepository` update path — `_updated_at` was placed outside `$set`**
13
+
14
+ `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.
15
+
16
+ - **fix(abdb): Fixed `update` method passing an array to `updateMany`**
17
+
18
+ `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: ... }`.
19
+
20
+ - **fix(abdb): Fixed full schema validation on partial update payloads**
21
+
22
+ `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.
23
+
24
+ ### ✨ Features
25
+
26
+ - **feat(abdb): Expanded `AbdbRepository` API with granular single- and bulk-operation methods**
27
+
28
+ Five new public methods covering the full MongoDB CRUD surface:
29
+
30
+ | New method | Description |
31
+ |---|---|
32
+ | `findById(id)` | Shorthand for `findOne({ _id: new ObjectId(id) })` |
33
+ | `insertOne(payload)` | Single-document insert via `insertOne`; stamps timestamps and validates |
34
+ | `updateOne(payload, filter?, options?)` | Single-document update via `updateOne` with `$set` wrapping and partial validation |
35
+ | `deleteOne(filter?)` | Single-document delete via `deleteOne`; returns raw result |
36
+ | `deleteById(id)` | Shorthand for `deleteOne({ _id: new ObjectId(id) })` |
37
+
38
+ - **feat(abdb): `save` delegates to `insertOne` / `updateOne`** — eliminates duplicated timestamp-stamping and validation logic.
39
+
40
+ - **feat(abdb): Split `exists` into `isIdExists` and `exists(filter, options?)`**
41
+
42
+ 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`.
43
+
44
+ - **feat(abdb): `count` now accepts an optional `options` parameter**
45
+
46
+ `count(filter?, options?)` now forwards `options` to the underlying `countDocuments` call, enabling fine-grained control such as `{ limit: 1 }` for fast existence probes.
47
+
48
+ ### ⚠️ Breaking Changes
49
+
50
+ - **`exists(id: string)` renamed to `isIdExists(id: string)`**
51
+
52
+ `exists` now accepts a general-purpose filter object. Any caller using `repo.exists(someId)` must switch to `repo.isIdExists(someId)`.
53
+
54
+ - **`delete(id: string)` → `delete(filter: AbdbRepositoryFilter)`**
55
+
56
+ `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.
57
+
58
+ - **`insertAll` renamed to `insert`** — identical behaviour, new name aligns with `insertOne`.
59
+
60
+ - **`updateAll` renamed to `update`** — identical behaviour (plus bug fixes above), new name aligns with `updateOne`.
61
+
62
+ - **Return types of all mutation methods changed to `Promise<Record<string, any>>`**
63
+
64
+ `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.
65
+
66
+ ### 💡 Migration Guide
67
+
68
+ ```typescript
69
+ // existence check by id — OLD
70
+ const found = await repo.exists(id);
71
+ // existence check by id — NEW
72
+ const found = await repo.isIdExists(id);
73
+
74
+ // general existence check (new) — by any filter
75
+ const active = await repo.exists({ status: 'active' });
76
+
77
+ // delete by id — OLD
78
+ await repo.delete(id);
79
+ // delete by id — NEW
80
+ await repo.deleteById(id);
81
+
82
+ // bulk insert — OLD
83
+ const ids = await repo.insertAll([...]);
84
+ // bulk insert — NEW
85
+ const result = await repo.insert([...]); // result.insertedIds contains the ids
86
+
87
+ // bulk update — OLD
88
+ await repo.updateAll({ active: false }, { email: 'bob@example.com' });
89
+ // bulk update — NEW
90
+ await repo.update({ active: false }, { email: 'bob@example.com' });
91
+
92
+ // return value of save (insert path) — OLD: string _id
93
+ const id = await repo.save({ name: 'Jane', email: 'jane@example.com' });
94
+ // return value of save (insert path) — NEW: raw insertOne result
95
+ const result = await repo.save({ name: 'Jane', email: 'jane@example.com' });
96
+ // result.insertedId contains the new _id
97
+ ```
98
+
99
+ ---
100
+
101
+ ## [1.2.1] - 2026-03-31
102
+
103
+ ### ✨ Features
104
+
105
+ - **feat(abdb): Add `AbdbRepository` — generic CRUD repository for `AbdbCollection`**
106
+
107
+ A typed, token-aware repository layer that wraps any `AbdbCollection` and exposes a clean CRUD surface without requiring callers to manage tokens, regions, or raw DB connections per call.
108
+
109
+ #### `AbdbRepository`
110
+
111
+ Generic repository class that holds the IMS token and region for its lifetime, auto-stamps `_created_at` / `_updated_at`, and validates every payload against the collection schema before touching the database.
112
+
113
+ **Single-document operations:**
114
+
115
+ - `save(payload)` — insert with full schema validation; stamps `_created_at` and `_updated_at`; returns new `_id`
116
+ - `save(payload, id)` — partial update by `_id`; stamps `_updated_at`; only validates fields present in the payload (absent required fields are not re-enforced); returns the same `id`
117
+ - `findOne(filter)` — returns the first document matching an arbitrary filter (e.g. `{ _id: 'x' }` or `{ email: 'a@b.com' }`), or `null`
118
+ - `find(filter?)` — returns all documents matching an optional filter; defaults to all documents
119
+ - `exists(id)` — lightweight existence check via `countDocuments`; returns `boolean`
120
+ - `delete(id)` — deletes by `_id`; no-ops silently for empty id
121
+ - `count(filter?)` — counts matching documents; defaults to all documents
122
+
123
+ **Bulk operations (single DB round-trip each):**
124
+
125
+ - `insertAll(payloads[])` — bulk insert via `insertMany`; each payload is stamped and fully validated before the DB call; returns array of inserted ids
126
+ - `updateAll(payload, filter?)` — bulk partial update via `updateMany`; stamps `_updated_at`; partial validation on present fields only
127
+ - `deleteAll(filter?)` — bulk delete via `deleteMany`; defaults to all documents
128
+
129
+ **Accessors:**
130
+
131
+ - `getName()` — returns the underlying collection name
132
+ - `getCollection()` — returns the underlying `AbdbCollection` instance
133
+
134
+ #### Automatic timestamp management
135
+
136
+ The constructor registers `_created_at` and `_updated_at` columns on the collection exactly once — re-using the same collection across multiple repository instances (e.g. different tokens or regions) is safe.
137
+
138
+ #### Partial update validation
139
+
140
+ The update path (`save(payload, id)` and `updateAll`) uses `_validatePartial`, which checks only the columns present in the payload. Required columns that are absent are not re-enforced because they already exist in the stored document. This prevents spurious validation failures when doing field-level patches.
141
+
142
+ ### 📖 Documentation
143
+
144
+ - **`@adobe/aio-lib-db` declared as required peer dependency** — added to the top-level installation command, peer dependencies table, individual install steps, App Builder `npm list` check command, and ERESOLVE upgrade guide in the README
145
+ - **Database provisioning guide added** — declarative `app.config.yaml` provisioning and `aio app db provision` CLI command documented as step 1 of the `AbdbCollection` usage guide
146
+ - **Authentication guide added** — `generateAccessToken` pattern with `include-ims-credentials` annotation documented as step 2; runtime action example updated to use real token generation instead of a placeholder comment
147
+ - **`AbdbRepository` section added to README** — covers basic usage, automatic timestamps, full API reference tables (single-document and bulk operations), custom region, and bulk operation examples
148
+ - **Fixed `RuntimeApiGatewayService` constructor call** in `test/framework/index.test.ts` — was passing 7 arguments copied from `ImsToken`; corrected to the actual 3-argument signature `(namespace, imsOrgId, imsToken)`
149
+
8
150
  ## [1.2.0] - 2026-03-30
9
151
 
10
152
  ### ✨ Features
package/README.md CHANGED
@@ -9,6 +9,7 @@ A comprehensive TypeScript toolkit for Adobe App Builder applications providing
9
9
  ```bash
10
10
  npm install @adobe-commerce/aio-toolkit \
11
11
  @adobe/aio-sdk \
12
+ @adobe/aio-lib-db \
12
13
  @adobe/aio-lib-ims \
13
14
  @adobe/aio-lib-telemetry \
14
15
  @opentelemetry/resources \
@@ -681,7 +682,58 @@ Typed schema definition and managed database connectivity via `@adobe/aio-lib-db
681
682
 
682
683
  The recommended pattern is to create a dedicated collection class per entity by extending `AbdbCollection`, then use it directly inside runtime actions.
683
684
 
684
- ##### 1. Define a custom collection
685
+ ##### 1. Provision a database
686
+
687
+ A database must be provisioned before any collection can connect. There are two ways to do this:
688
+
689
+ **Declarative provisioning via `app.config.yaml`** (runs on `aio app deploy`):
690
+
691
+ ```yaml
692
+ application:
693
+ runtimeManifest:
694
+ database:
695
+ auto-provision: true
696
+ region: emea
697
+ ```
698
+
699
+ When the application is deployed with `aio app deploy`, a database is provisioned in the specified region unless one is already present. Declarative provisioning does **not** run during `aio app run` or `aio app dev`, so the database must be provisioned manually for local development (see below).
700
+
701
+ **Manual provisioning via the AIO CLI:**
702
+
703
+ ```bash
704
+ aio app db provision [--region <area>]
705
+ ```
706
+
707
+ ##### 2. Configure authentication
708
+
709
+ Every `@adobe/aio-lib-db` call requires an IMS access token. The recommended approach is to use `@adobe/aio-sdk`, which handles token caching and refresh automatically:
710
+
711
+ ```javascript
712
+ const { generateAccessToken } = require('@adobe/aio-sdk').Core.AuthClient;
713
+ const libDb = require('@adobe/aio-lib-db');
714
+
715
+ async function main(params) {
716
+ const token = await generateAccessToken(params);
717
+ const db = await libDb.init({ token: token.access_token });
718
+ }
719
+ ```
720
+
721
+ **Requirements:**
722
+
723
+ - The AIO project workspace must include the **App Builder Data Services API**.
724
+ - The runtime action must have the `include-ims-credentials` annotation set to `true` in `app.config.yaml`:
725
+
726
+ ```yaml
727
+ actions:
728
+ action:
729
+ function: actions/generic/action.js
730
+ annotations:
731
+ include-ims-credentials: true
732
+ ```
733
+
734
+ > `@adobe/aio-sdk` transparently manages token caching and refresh — you do not need to implement this yourself.
735
+
736
+ ##### 3. Define a custom collection
685
737
 
686
738
  Create a reusable collection class that declares the schema once:
687
739
 
@@ -712,10 +764,11 @@ class UserCollection extends AbdbCollection {
712
764
  module.exports = UserCollection;
713
765
  ```
714
766
 
715
- ##### 2. Use it in a runtime action
767
+ ##### 4. Use it in a runtime action
716
768
 
717
769
  ```javascript
718
770
  const { HttpMethod, RuntimeAction, RuntimeActionResponse } = require('@adobe-commerce/aio-toolkit');
771
+ const { generateAccessToken } = require('@adobe/aio-sdk').Core.AuthClient;
719
772
  const UserCollection = require('@lib/UserCollection');
720
773
 
721
774
  exports.main = RuntimeAction.execute(
@@ -727,7 +780,8 @@ exports.main = RuntimeAction.execute(
727
780
  const { first_name, last_name, email } = params;
728
781
  const { logger } = ctx;
729
782
 
730
- const accessToken = /* extract from params / IMS */;
783
+ const token = await generateAccessToken(params);
784
+ const accessToken = token.access_token;
731
785
 
732
786
  const users = new UserCollection();
733
787
 
@@ -746,7 +800,7 @@ exports.main = RuntimeAction.execute(
746
800
  );
747
801
  ```
748
802
 
749
- ##### 3. API surface reference
803
+ ##### 5. API surface reference
750
804
 
751
805
  **`addColumn` call forms:**
752
806
 
@@ -787,6 +841,119 @@ users.getColumn('email'); // AbdbColumn instance (or undefined)
787
841
  users.getColumns(); // Map<string, AbdbColumn> in insertion order
788
842
  ```
789
843
 
844
+ #### `AbdbRepository`
845
+
846
+ A generic CRUD repository that wraps an `AbdbCollection` and holds the IMS token and region for the lifetime of the instance. All write methods validate payloads against the collection schema before touching the database, and `_created_at` / `_updated_at` timestamps are stamped automatically.
847
+
848
+ ##### Basic usage
849
+
850
+ ```javascript
851
+ const { AbdbRepository } = require('@adobe-commerce/aio-toolkit');
852
+ const { generateAccessToken } = require('@adobe/aio-sdk').Core.AuthClient;
853
+ const UserCollection = require('@lib/UserCollection');
854
+
855
+ exports.main = async (params) => {
856
+ const token = await generateAccessToken(params);
857
+ const accessToken = token.access_token;
858
+
859
+ const repo = new AbdbRepository(new UserCollection(), accessToken);
860
+
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;
864
+
865
+ // Read by _id (shorthand)
866
+ const doc = await repo.findById(id);
867
+
868
+ // Read one by any field
869
+ const byEmail = await repo.findOne({ email: 'jane@example.com' });
870
+
871
+ // Read all (optional filter)
872
+ const all = await repo.find();
873
+ const active = await repo.find({ active: true });
874
+
875
+ // Partial update — only provided fields are validated; required fields already in the DB are not re-checked
876
+ await repo.save({ first_name: 'Janet' }, id);
877
+
878
+ // Delete by _id
879
+ await repo.deleteById(id);
880
+ };
881
+ ```
882
+
883
+ ##### Automatic timestamps
884
+
885
+ The repository automatically registers two extra columns on the collection:
886
+
887
+ | Column | Set on | Value |
888
+ |---|---|---|
889
+ | `_created_at` | First insert only | ISO 8601 UTC string |
890
+ | `_updated_at` | Every insert and update | ISO 8601 UTC string |
891
+
892
+ These are added once per collection instance, so re-using the same collection across multiple repository instances is safe.
893
+
894
+ ##### API reference
895
+
896
+ **Single-document operations:**
897
+
898
+ | Method | Description | Returns |
899
+ |---|---|---|
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>` |
906
+ | `find(filter?)` | All documents matching filter (default: all) | `Promise<T[]>` |
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>` |
912
+
913
+ **Bulk operations (single DB round-trip each):**
914
+
915
+ | Method | Description | Returns |
916
+ |---|---|---|
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`) |
920
+
921
+ **Accessors:**
922
+
923
+ | Method | Description |
924
+ |---|---|
925
+ | `getName()` | Returns the underlying collection name |
926
+ | `getCollection()` | Returns the underlying `AbdbCollection` instance |
927
+
928
+ ##### Custom region
929
+
930
+ ```javascript
931
+ // Default region is 'amer'. Pass a third argument to override:
932
+ const repo = new AbdbRepository(new UserCollection(), accessToken, 'emea');
933
+ ```
934
+
935
+ ##### Bulk operations
936
+
937
+ ```javascript
938
+ // Insert multiple documents in one DB call
939
+ const result = await repo.insert([
940
+ { first_name: 'Alice', last_name: 'Smith', email: 'alice@example.com' },
941
+ { first_name: 'Bob', last_name: 'Jones', email: 'bob@example.com' },
942
+ ]);
943
+ console.log(result.insertedIds); // array of inserted _id values
944
+
945
+ // Update all matching documents in one DB call
946
+ const updateResult = await repo.update({ active: false }, { email: 'bob@example.com' });
947
+ console.log(updateResult.modifiedCount); // number of documents updated
948
+
949
+ // Delete all matching documents in one DB call
950
+ const deleteResult = await repo.delete({ active: false });
951
+ console.log(deleteResult.deletedCount); // number of documents deleted
952
+
953
+ // Delete everything in the collection
954
+ await repo.delete();
955
+ ```
956
+
790
957
  ### 🏪 Commerce Components
791
958
 
792
959
  **Adobe Commerce API integration and authentication**
@@ -1892,12 +2059,13 @@ Packages that maintain **singleton state or shared registries** — if two copie
1892
2059
  | Package | Why it must be shared |
1893
2060
  |---|---|
1894
2061
  | `@adobe/aio-sdk` | Singleton services — logger, config, state are shared across the app |
2062
+ | `@adobe/aio-lib-db` | Database client singleton — connection state and collection registry must be shared |
1895
2063
  | `graphql` | Schema registry is a singleton — `instanceof GraphQLSchema` and type checks fail with two copies |
1896
2064
  | `@adobe/aio-lib-ims` | Token cache and auth context must be the same shared instance |
1897
2065
  | `@adobe/aio-lib-telemetry` | Single telemetry pipeline — two copies split traces and logs |
1898
2066
  | `@opentelemetry/resources` | Resource object tied to the telemetry pipeline instance |
1899
2067
 
1900
- All five are **required** — they are unconditionally imported when the package loads (`export * from './framework'` and `export * from './commerce'` in the root `index.ts`). If any is missing, the entire package will fail to load with a `Cannot find module` error.
2068
+ All six are **required** — they are unconditionally imported when the package loads (`export * from './framework'` and `export * from './commerce'` in the root `index.ts`). If any is missing, the entire package will fail to load with a `Cannot find module` error.
1901
2069
 
1902
2070
  ### Installing peer dependencies
1903
2071
 
@@ -1906,6 +2074,7 @@ Install the toolkit and all required peer dependencies in one command:
1906
2074
  ```bash
1907
2075
  npm install @adobe-commerce/aio-toolkit \
1908
2076
  @adobe/aio-sdk \
2077
+ @adobe/aio-lib-db \
1909
2078
  @adobe/aio-lib-ims \
1910
2079
  @adobe/aio-lib-telemetry \
1911
2080
  @opentelemetry/resources \
@@ -1918,14 +2087,15 @@ Or individually if you prefer to control versions:
1918
2087
  npm install @adobe-commerce/aio-toolkit
1919
2088
 
1920
2089
  # Required peer dependencies
1921
- npm install @adobe/aio-sdk@^5.0.0
2090
+ npm install @adobe/aio-sdk@^6.0.0
2091
+ npm install @adobe/aio-lib-db@^1.0.0
1922
2092
  npm install @adobe/aio-lib-ims@^7.0.0
1923
2093
  npm install @adobe/aio-lib-telemetry@^1.0.0
1924
2094
  npm install @opentelemetry/resources@^2.0.0
1925
2095
  npm install graphql@^16.0.0
1926
2096
  ```
1927
2097
 
1928
- > **Note for App Builder projects:** `@adobe/aio-sdk`, `graphql`, and `@adobe/aio-lib-ims` are almost always already present in a standard App Builder project. Run `npm list @adobe/aio-sdk graphql @adobe/aio-lib-ims` to check before installing.
2098
+ > **Note for App Builder projects:** `@adobe/aio-sdk`, `graphql`, and `@adobe/aio-lib-ims` are almost always already present in a standard App Builder project. Run `npm list @adobe/aio-sdk @adobe/aio-lib-db graphql @adobe/aio-lib-ims` to check before installing.
1929
2099
 
1930
2100
  ### Resolving `ERESOLVE` errors
1931
2101
 
@@ -1940,9 +2110,12 @@ npm install @adobe-commerce/aio-toolkit 2>&1 | grep "Found:"
1940
2110
  **Upgrade the conflicting package to a compatible version:**
1941
2111
 
1942
2112
  ```bash
1943
- # @adobe/aio-sdk must be >=5.0.0
2113
+ # @adobe/aio-sdk must be >=6.0.0
1944
2114
  npm install @adobe/aio-sdk@latest
1945
2115
 
2116
+ # @adobe/aio-lib-db must be >=1.0.0
2117
+ npm install @adobe/aio-lib-db@latest
2118
+
1946
2119
  # graphql must be >=14.0.0
1947
2120
  npm install graphql@latest
1948
2121
 
package/dist/index.d.mts CHANGED
@@ -203,6 +203,99 @@ declare class FileRepository {
203
203
  private getFiles;
204
204
  }
205
205
 
206
+ declare enum AbdbColumnType {
207
+ STRING = "STRING",
208
+ NUMBER = "NUMBER",
209
+ BOOLEAN = "BOOLEAN",
210
+ DATETIME = "DATETIME"
211
+ }
212
+ interface AbdbColumnOptions {
213
+ name: string;
214
+ type: AbdbColumnType;
215
+ description?: string;
216
+ isRequired?: boolean;
217
+ }
218
+ interface AbdbColumnJson {
219
+ name: string;
220
+ type: AbdbColumnType;
221
+ description?: string;
222
+ isRequired?: true;
223
+ }
224
+
225
+ declare class AbdbColumn {
226
+ private readonly _name;
227
+ private readonly _type;
228
+ private readonly _description;
229
+ private readonly _isRequired;
230
+ constructor(options: AbdbColumnOptions);
231
+ getName(): string;
232
+ getType(): AbdbColumnType;
233
+ getDescription(): string | undefined;
234
+ getIsRequired(): boolean;
235
+ toJSON(): AbdbColumnJson;
236
+ clone(overrides?: Partial<AbdbColumnOptions>): AbdbColumn;
237
+ validate(value: unknown): void;
238
+ private _isMissingValue;
239
+ private _validateStringValue;
240
+ private _validateNumberValue;
241
+ private _validateBooleanValue;
242
+ private _validateDateTimeValue;
243
+ }
244
+
245
+ type AddColumnOptions = Omit<AbdbColumnOptions, 'name' | 'type'>;
246
+ type AbdbRunCallback<T = unknown> = (collection: DbCollection, client: DbClient) => Promise<T>;
247
+
248
+ type AbdbCollectionCallback = (collection: AbdbCollection) => void;
249
+ declare class AbdbCollection {
250
+ private readonly _name;
251
+ private readonly _columns;
252
+ constructor(name: string, callback?: AbdbCollectionCallback);
253
+ getName(): string;
254
+ addColumn(name: string, type: AbdbColumnType, options?: AddColumnOptions): this;
255
+ addColumn(name: string, type: AbdbColumnType, description?: string, isRequired?: boolean): this;
256
+ getColumns(): AbdbColumn[];
257
+ getColumn(name: string): AbdbColumn | undefined;
258
+ hasColumn(name: string): boolean;
259
+ validate(record: Record<string, unknown>): void;
260
+ validateAll(record: Record<string, unknown>): string[];
261
+ run<T>(callback: AbdbRunCallback<T>, token: string, region?: string): Promise<T>;
262
+ private _validateCollectionName;
263
+ private _validateColumnName;
264
+ private _validateIdentifier;
265
+ }
266
+
267
+ interface AbdbRecord {
268
+ _id?: string;
269
+ _created_at?: string;
270
+ _updated_at?: string;
271
+ [key: string]: unknown;
272
+ }
273
+ type AbdbRepositoryFilter = Record<string, unknown>;
274
+
275
+ declare class AbdbRepository<T extends AbdbRecord = AbdbRecord> {
276
+ private readonly _collection;
277
+ private readonly _token;
278
+ private readonly _region;
279
+ constructor(collection: AbdbCollection, token: string, region?: string);
280
+ getName(): string;
281
+ getCollection(): AbdbCollection;
282
+ find(filter?: AbdbRepositoryFilter): Promise<T[]>;
283
+ findOne(filter: AbdbRepositoryFilter): Promise<T | null>;
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>;
296
+ private _validatePartial;
297
+ }
298
+
206
299
  interface EventData {
207
300
  type: string;
208
301
  data: any;
@@ -328,67 +421,6 @@ declare class RuntimeApiGatewayService {
328
421
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
329
422
  }
330
423
 
331
- declare enum AbdbColumnType {
332
- STRING = "STRING",
333
- NUMBER = "NUMBER",
334
- BOOLEAN = "BOOLEAN",
335
- DATETIME = "DATETIME"
336
- }
337
- interface AbdbColumnOptions {
338
- name: string;
339
- type: AbdbColumnType;
340
- description?: string;
341
- isRequired?: boolean;
342
- }
343
- interface AbdbColumnJson {
344
- name: string;
345
- type: AbdbColumnType;
346
- description?: string;
347
- isRequired?: true;
348
- }
349
-
350
- declare class AbdbColumn {
351
- private readonly _name;
352
- private readonly _type;
353
- private readonly _description;
354
- private readonly _isRequired;
355
- constructor(options: AbdbColumnOptions);
356
- getName(): string;
357
- getType(): AbdbColumnType;
358
- getDescription(): string | undefined;
359
- getIsRequired(): boolean;
360
- toJSON(): AbdbColumnJson;
361
- clone(overrides?: Partial<AbdbColumnOptions>): AbdbColumn;
362
- validate(value: unknown): void;
363
- private _isMissingValue;
364
- private _validateStringValue;
365
- private _validateNumberValue;
366
- private _validateBooleanValue;
367
- private _validateDateTimeValue;
368
- }
369
-
370
- type AddColumnOptions = Omit<AbdbColumnOptions, 'name' | 'type'>;
371
- type AbdbRunCallback<T = unknown> = (collection: DbCollection, client: DbClient) => Promise<T>;
372
-
373
- type AbdbCollectionCallback = (collection: AbdbCollection) => void;
374
- declare class AbdbCollection {
375
- private readonly _name;
376
- private readonly _columns;
377
- constructor(name: string, callback?: AbdbCollectionCallback);
378
- getName(): string;
379
- addColumn(name: string, type: AbdbColumnType, options?: AddColumnOptions): this;
380
- addColumn(name: string, type: AbdbColumnType, description?: string, isRequired?: boolean): this;
381
- getColumns(): AbdbColumn[];
382
- getColumn(name: string): AbdbColumn | undefined;
383
- hasColumn(name: string): boolean;
384
- validate(record: Record<string, unknown>): void;
385
- validateAll(record: Record<string, unknown>): string[];
386
- run<T>(callback: AbdbRunCallback<T>, token: string, region?: string): Promise<T>;
387
- private _validateCollectionName;
388
- private _validateColumnName;
389
- private _validateIdentifier;
390
- }
391
-
392
424
  declare class TelemetryInputError extends Error {
393
425
  constructor(message: string);
394
426
  }
@@ -1051,4 +1083,4 @@ declare class AdminUiSdk {
1051
1083
  getRegistration(): AdminUiSdkRegistration;
1052
1084
  }
1053
1085
 
1054
- export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, 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 };
1086
+ 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 };