@adobe-commerce/aio-toolkit 1.2.0 → 1.2.1

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,55 @@ 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.1] - 2026-03-31
9
+
10
+ ### ✨ Features
11
+
12
+ - **feat(abdb): Add `AbdbRepository` — generic CRUD repository for `AbdbCollection`**
13
+
14
+ 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.
15
+
16
+ #### `AbdbRepository`
17
+
18
+ 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.
19
+
20
+ **Single-document operations:**
21
+
22
+ - `save(payload)` — insert with full schema validation; stamps `_created_at` and `_updated_at`; returns new `_id`
23
+ - `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`
24
+ - `findOne(filter)` — returns the first document matching an arbitrary filter (e.g. `{ _id: 'x' }` or `{ email: 'a@b.com' }`), or `null`
25
+ - `find(filter?)` — returns all documents matching an optional filter; defaults to all documents
26
+ - `exists(id)` — lightweight existence check via `countDocuments`; returns `boolean`
27
+ - `delete(id)` — deletes by `_id`; no-ops silently for empty id
28
+ - `count(filter?)` — counts matching documents; defaults to all documents
29
+
30
+ **Bulk operations (single DB round-trip each):**
31
+
32
+ - `insertAll(payloads[])` — bulk insert via `insertMany`; each payload is stamped and fully validated before the DB call; returns array of inserted ids
33
+ - `updateAll(payload, filter?)` — bulk partial update via `updateMany`; stamps `_updated_at`; partial validation on present fields only
34
+ - `deleteAll(filter?)` — bulk delete via `deleteMany`; defaults to all documents
35
+
36
+ **Accessors:**
37
+
38
+ - `getName()` — returns the underlying collection name
39
+ - `getCollection()` — returns the underlying `AbdbCollection` instance
40
+
41
+ #### Automatic timestamp management
42
+
43
+ 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.
44
+
45
+ #### Partial update validation
46
+
47
+ 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.
48
+
49
+ ### 📖 Documentation
50
+
51
+ - **`@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
52
+ - **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
53
+ - **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
54
+ - **`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
55
+ - **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)`
56
+
8
57
  ## [1.2.0] - 2026-03-30
9
58
 
10
59
  ### ✨ 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,110 @@ 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, AbdbColumnType } = 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 the new document _id
862
+ const id = await repo.save({ first_name: 'Jane', last_name: 'Doe', email: 'jane@example.com' });
863
+
864
+ // Read one by _id
865
+ const doc = await repo.findOne({ _id: id });
866
+
867
+ // Read one by any field
868
+ const byEmail = await repo.findOne({ email: 'jane@example.com' });
869
+
870
+ // Read all (optional filter)
871
+ const all = await repo.find();
872
+ const active = await repo.find({ active: true });
873
+
874
+ // Partial update — only provided fields are validated; required fields already in the DB are not re-checked
875
+ await repo.save({ first_name: 'Janet' }, id);
876
+
877
+ // Delete
878
+ await repo.delete(id);
879
+ };
880
+ ```
881
+
882
+ ##### Automatic timestamps
883
+
884
+ The repository automatically registers two extra columns on the collection:
885
+
886
+ | Column | Set on | Value |
887
+ |---|---|---|
888
+ | `_created_at` | First insert only | ISO 8601 UTC string |
889
+ | `_updated_at` | Every insert and update | ISO 8601 UTC string |
890
+
891
+ These are added once per collection instance, so re-using the same collection across multiple repository instances is safe.
892
+
893
+ ##### API reference
894
+
895
+ **Single-document operations:**
896
+
897
+ | Method | Description | Returns |
898
+ |---|---|---|
899
+ | `save(payload)` | Insert a new document (full validation) | `Promise<string>` — new `_id` |
900
+ | `save(payload, id)` | Partial update by `_id` (only present fields validated) | `Promise<string>` — same `id` |
901
+ | `findOne(filter)` | First document matching filter, e.g. `{ _id: 'x' }` | `Promise<T \| null>` |
902
+ | `find(filter?)` | All documents matching filter (default: all) | `Promise<T[]>` |
903
+ | `exists(id)` | Lightweight existence check via `countDocuments` | `Promise<boolean>` |
904
+ | `delete(id)` | Delete document by `_id`; no-ops for empty id | `Promise<void>` |
905
+ | `count(filter?)` | Count matching documents (default: all) | `Promise<number>` |
906
+
907
+ **Bulk operations (single DB round-trip each):**
908
+
909
+ | Method | Description | Returns |
910
+ |---|---|---|
911
+ | `insertAll(payloads[])` | Bulk insert via `insertMany` — each payload stamped and validated | `Promise<string[]>` — inserted ids |
912
+ | `updateAll(payload, filter?)` | Bulk partial update via `updateMany` — stamps `_updated_at` | `Promise<void>` |
913
+ | `deleteAll(filter?)` | Bulk delete via `deleteMany` (default: all documents) | `Promise<void>` |
914
+
915
+ **Accessors:**
916
+
917
+ | Method | Description |
918
+ |---|---|
919
+ | `getName()` | Returns the underlying collection name |
920
+ | `getCollection()` | Returns the underlying `AbdbCollection` instance |
921
+
922
+ ##### Custom region
923
+
924
+ ```javascript
925
+ // Default region is 'amer'. Pass a third argument to override:
926
+ const repo = new AbdbRepository(new UserCollection(), accessToken, 'emea');
927
+ ```
928
+
929
+ ##### Bulk operations
930
+
931
+ ```javascript
932
+ // Insert multiple documents in one DB call
933
+ const ids = await repo.insertAll([
934
+ { first_name: 'Alice', last_name: 'Smith', email: 'alice@example.com' },
935
+ { first_name: 'Bob', last_name: 'Jones', email: 'bob@example.com' },
936
+ ]);
937
+
938
+ // Update all matching documents in one DB call
939
+ await repo.updateAll({ active: false }, { email: 'bob@example.com' });
940
+
941
+ // Delete all matching documents in one DB call
942
+ await repo.deleteAll({ active: false });
943
+
944
+ // Delete everything in the collection
945
+ await repo.deleteAll();
946
+ ```
947
+
790
948
  ### 🏪 Commerce Components
791
949
 
792
950
  **Adobe Commerce API integration and authentication**
@@ -1892,12 +2050,13 @@ Packages that maintain **singleton state or shared registries** — if two copie
1892
2050
  | Package | Why it must be shared |
1893
2051
  |---|---|
1894
2052
  | `@adobe/aio-sdk` | Singleton services — logger, config, state are shared across the app |
2053
+ | `@adobe/aio-lib-db` | Database client singleton — connection state and collection registry must be shared |
1895
2054
  | `graphql` | Schema registry is a singleton — `instanceof GraphQLSchema` and type checks fail with two copies |
1896
2055
  | `@adobe/aio-lib-ims` | Token cache and auth context must be the same shared instance |
1897
2056
  | `@adobe/aio-lib-telemetry` | Single telemetry pipeline — two copies split traces and logs |
1898
2057
  | `@opentelemetry/resources` | Resource object tied to the telemetry pipeline instance |
1899
2058
 
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.
2059
+ 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
2060
 
1902
2061
  ### Installing peer dependencies
1903
2062
 
@@ -1906,6 +2065,7 @@ Install the toolkit and all required peer dependencies in one command:
1906
2065
  ```bash
1907
2066
  npm install @adobe-commerce/aio-toolkit \
1908
2067
  @adobe/aio-sdk \
2068
+ @adobe/aio-lib-db \
1909
2069
  @adobe/aio-lib-ims \
1910
2070
  @adobe/aio-lib-telemetry \
1911
2071
  @opentelemetry/resources \
@@ -1918,14 +2078,15 @@ Or individually if you prefer to control versions:
1918
2078
  npm install @adobe-commerce/aio-toolkit
1919
2079
 
1920
2080
  # Required peer dependencies
1921
- npm install @adobe/aio-sdk@^5.0.0
2081
+ npm install @adobe/aio-sdk@^6.0.0
2082
+ npm install @adobe/aio-lib-db@^1.0.0
1922
2083
  npm install @adobe/aio-lib-ims@^7.0.0
1923
2084
  npm install @adobe/aio-lib-telemetry@^1.0.0
1924
2085
  npm install @opentelemetry/resources@^2.0.0
1925
2086
  npm install graphql@^16.0.0
1926
2087
  ```
1927
2088
 
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.
2089
+ > **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
2090
 
1930
2091
  ### Resolving `ERESOLVE` errors
1931
2092
 
@@ -1940,9 +2101,12 @@ npm install @adobe-commerce/aio-toolkit 2>&1 | grep "Found:"
1940
2101
  **Upgrade the conflicting package to a compatible version:**
1941
2102
 
1942
2103
  ```bash
1943
- # @adobe/aio-sdk must be >=5.0.0
2104
+ # @adobe/aio-sdk must be >=6.0.0
1944
2105
  npm install @adobe/aio-sdk@latest
1945
2106
 
2107
+ # @adobe/aio-lib-db must be >=1.0.0
2108
+ npm install @adobe/aio-lib-db@latest
2109
+
1946
2110
  # graphql must be >=14.0.0
1947
2111
  npm install graphql@latest
1948
2112
 
package/dist/index.d.mts CHANGED
@@ -203,6 +203,94 @@ 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
+ exists(id: string): Promise<boolean>;
285
+ count(filter?: AbdbRepositoryFilter): Promise<number>;
286
+ save(payload?: Partial<T>, id?: string): Promise<string>;
287
+ delete(id?: string): Promise<void>;
288
+ insertAll(payloads: Array<Partial<T>>): Promise<string[]>;
289
+ updateAll(payload: Partial<T>, filter?: AbdbRepositoryFilter): Promise<void>;
290
+ deleteAll(filter?: AbdbRepositoryFilter): Promise<void>;
291
+ private _validatePartial;
292
+ }
293
+
206
294
  interface EventData {
207
295
  type: string;
208
296
  data: any;
@@ -328,67 +416,6 @@ declare class RuntimeApiGatewayService {
328
416
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
329
417
  }
330
418
 
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
419
  declare class TelemetryInputError extends Error {
393
420
  constructor(message: string);
394
421
  }
@@ -1051,4 +1078,4 @@ declare class AdminUiSdk {
1051
1078
  getRegistration(): AdminUiSdkRegistration;
1052
1079
  }
1053
1080
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -203,6 +203,94 @@ 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
+ exists(id: string): Promise<boolean>;
285
+ count(filter?: AbdbRepositoryFilter): Promise<number>;
286
+ save(payload?: Partial<T>, id?: string): Promise<string>;
287
+ delete(id?: string): Promise<void>;
288
+ insertAll(payloads: Array<Partial<T>>): Promise<string[]>;
289
+ updateAll(payload: Partial<T>, filter?: AbdbRepositoryFilter): Promise<void>;
290
+ deleteAll(filter?: AbdbRepositoryFilter): Promise<void>;
291
+ private _validatePartial;
292
+ }
293
+
206
294
  interface EventData {
207
295
  type: string;
208
296
  data: any;
@@ -328,67 +416,6 @@ declare class RuntimeApiGatewayService {
328
416
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
329
417
  }
330
418
 
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
419
  declare class TelemetryInputError extends Error {
393
420
  constructor(message: string);
394
421
  }
@@ -1051,4 +1078,4 @@ declare class AdminUiSdk {
1051
1078
  getRegistration(): AdminUiSdkRegistration;
1052
1079
  }
1053
1080
 
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 };
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 };