@adobe-commerce/aio-toolkit 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,93 @@ 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.0] - 2026-03-30
9
+
10
+ ### ✨ Features
11
+
12
+ - **feat(abdb): Add `AbdbColumn` and `AbdbCollection` framework components**
13
+
14
+ Two new framework components that provide a typed schema definition layer and managed database connectivity via `@adobe/aio-lib-db`.
15
+
16
+ #### `AbdbColumn`
17
+
18
+ Immutable field definition class for describing a single column in an ABDB document schema.
19
+
20
+ - Supports four value types: `STRING`, `NUMBER`, `BOOLEAN`, `DATETIME`
21
+ - Comprehensive type coercion rules — accepts numeric strings, `"true"/"false"` strings, ISO 8601 date strings, finite numeric timestamps, and `Date` objects
22
+ - Required field enforcement via `isRequired` flag
23
+ - `validate(value)` — throws on the first type or requiredness violation
24
+ - `clone(overrides?)` — derives a new immutable instance with overridden fields
25
+ - `toJSON()` — serializes to a plain `AbdbColumnJson` object
26
+ - Fully immutable after construction (`Object.freeze`)
27
+ - Exhaustive `switch` guard via TypeScript `never` — compile-time safety if a new type is added without updating the validator
28
+
29
+ #### `AbdbCollection`
30
+
31
+ Named schema container with fluent column registration, validation, and a managed Adobe I/O DB lifecycle.
32
+
33
+ - `addColumn(name, type, description?, isRequired?)` — **positional form** (backward-compatible short syntax)
34
+ - `addColumn(name, type, options?)` — **options-object form** — no `undefined` placeholder needed to set only `isRequired`
35
+ - `getColumn(name)` — O(1) single-column lookup; returns `undefined` if not found
36
+ - `hasColumn(name)` — O(1) existence check
37
+ - `getColumns()` — defensive copy in insertion order
38
+ - `validate(record)` — fail-fast; throws on the **first** failing column
39
+ - `validateAll(record)` — collects **all** column errors; returns `string[]` — ideal for API error responses
40
+ - `run<T>(callback, token, region?)` — opens `@adobe/aio-lib-db` connection, invokes callback with `(collection, client)`, closes in `finally`
41
+
42
+ #### Types exported
43
+
44
+ | Type | Description |
45
+ |---|---|
46
+ | `AbdbColumnType` | String enum: `STRING \| NUMBER \| BOOLEAN \| DATETIME` |
47
+ | `AbdbColumnOptions` | Constructor input shape for `AbdbColumn` |
48
+ | `AbdbColumnJson` | `toJSON()` output shape |
49
+ | `AddColumnOptions` | `Omit<AbdbColumnOptions, 'name' \| 'type'>` — options-object form for `addColumn` |
50
+ | `AbdbCollectionCallback` | Constructor setup callback `(collection: AbdbCollection) => void` |
51
+ | `AbdbRunCallback<T>` | Async work callback for `run()` |
52
+
53
+ ## [1.1.1] - 2026-03-28
54
+
55
+ ### 🐛 Bug Fixes
56
+
57
+ - **Fixed `ERESOLVE` installation failures introduced in v1.1.0**
58
+ - `v1.1.0` moved `cloudevents`, `dotenv`, `node-fetch`, and `openwhisk` to `peerDependencies` to avoid duplicate module installs
59
+ - This caused hard `ERESOLVE` errors for any client that had one of those packages installed at a different major version (e.g. `cloudevents@4.x` vs the required `>=8.0.0`)
60
+ - Root cause: `peerDependenciesMeta.optional: true` only suppresses the "not installed" warning — it does **not** suppress `ERESOLVE` when the package IS installed at an incompatible version
61
+ - Fix: moved these four packages back to `dependencies` where they belong
62
+
63
+ ### 🔧 Dependency Changes
64
+
65
+ | Package | v1.1.0 | v1.1.1 | Reason |
66
+ |---|---|---|---|
67
+ | `cloudevents` | `peerDependencies` (optional) | `dependencies` | Clients have v4.x — incompatible with `>=8.0.0` range; duplicate copies harmless (stateless) |
68
+ | `dotenv` | `peerDependencies` (optional) | `dependencies` | Stateless — just sets `process.env`; two copies are harmless |
69
+ | `node-fetch` | `peerDependencies` (optional) | `dependencies` | Stateless HTTP function — no singleton, no shared state |
70
+ | `openwhisk` | `peerDependencies` (optional) | `dependencies` | Creates client instances per call — no global singleton |
71
+
72
+ ### 📝 Peer Dependency Philosophy
73
+
74
+ Only packages that maintain **shared singleton state** between the toolkit and the client application belong in `peerDependencies`. Stateless utilities where duplicate copies are functionally harmless must stay in `dependencies` to avoid blocking installation.
75
+
76
+ Packages that remain in `peerDependencies` as **required** peers (all five are unconditionally imported at package load time):
77
+
78
+ | Package | Why it must be a peer dep |
79
+ |---|---|
80
+ | `@adobe/aio-sdk` | Singleton services — logger, config, state shared across the app |
81
+ | `graphql` | Schema registry singleton — two copies cause `instanceof` and type failures |
82
+ | `@adobe/aio-lib-ims` | Token cache and auth context must be a single shared instance |
83
+ | `@adobe/aio-lib-telemetry` | Single telemetry pipeline — two copies split traces and logs |
84
+ | `@opentelemetry/resources` | Resource object tied to the telemetry pipeline instance |
85
+
86
+ ### 💡 Migration Guide
87
+
88
+ ```bash
89
+ # Upgrade from v1.1.0 — no code changes required
90
+ npm install @adobe-commerce/aio-toolkit@1.1.1
91
+ ```
92
+
93
+ ---
94
+
8
95
  ## [1.1.0] - 2026-03-27
9
96
 
10
97
  ### ⚠️ Breaking Changes
package/README.md CHANGED
@@ -7,9 +7,16 @@ A comprehensive TypeScript toolkit for Adobe App Builder applications providing
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install @adobe-commerce/aio-toolkit
10
+ npm install @adobe-commerce/aio-toolkit \
11
+ @adobe/aio-sdk \
12
+ @adobe/aio-lib-ims \
13
+ @adobe/aio-lib-telemetry \
14
+ @opentelemetry/resources \
15
+ graphql
11
16
  ```
12
17
 
18
+ > **App Builder projects** already include `@adobe/aio-sdk`, `@adobe/aio-lib-ims`, and `graphql` — you only need to add the missing ones. See [Dependency Resolution](#dependency-resolution) for details.
19
+
13
20
  ## Usage
14
21
 
15
22
  The toolkit is organized into five main modules:
@@ -668,6 +675,118 @@ This approach provides:
668
675
  - **Flexible ID management**: Support for explicit IDs, payload IDs, and auto-generation
669
676
  - **Automatic sanitization**: IDs are cleaned to ensure file system compatibility
670
677
 
678
+ #### `AbdbColumn` & `AbdbCollection`
679
+
680
+ Typed schema definition and managed database connectivity via `@adobe/aio-lib-db`.
681
+
682
+ The recommended pattern is to create a dedicated collection class per entity by extending `AbdbCollection`, then use it directly inside runtime actions.
683
+
684
+ ##### 1. Define a custom collection
685
+
686
+ Create a reusable collection class that declares the schema once:
687
+
688
+ ```javascript
689
+ // src/collections/UserCollection.js
690
+ 'use strict';
691
+
692
+ const { AbdbCollection, AbdbColumnType } = require('@adobe-commerce/aio-toolkit');
693
+
694
+ /**
695
+ * ABDB collection for the `users` table.
696
+ *
697
+ * Columns:
698
+ * - `first_name` (STRING, required)
699
+ * - `last_name` (STRING, required)
700
+ * - `email` (STRING, required)
701
+ */
702
+ class UserCollection extends AbdbCollection {
703
+ constructor() {
704
+ super('users', (c) => {
705
+ c.addColumn('first_name', AbdbColumnType.STRING, 'First name', true)
706
+ .addColumn('last_name', AbdbColumnType.STRING, 'Last name', true)
707
+ .addColumn('email', AbdbColumnType.STRING, 'Email address', true);
708
+ });
709
+ }
710
+ }
711
+
712
+ module.exports = UserCollection;
713
+ ```
714
+
715
+ ##### 2. Use it in a runtime action
716
+
717
+ ```javascript
718
+ const { HttpMethod, RuntimeAction, RuntimeActionResponse } = require('@adobe-commerce/aio-toolkit');
719
+ const UserCollection = require('@lib/UserCollection');
720
+
721
+ exports.main = RuntimeAction.execute(
722
+ 'users-create',
723
+ [HttpMethod.POST],
724
+ ['first_name', 'last_name', 'email'],
725
+ ['Authorization'],
726
+ async (params, ctx) => {
727
+ const { first_name, last_name, email } = params;
728
+ const { logger } = ctx;
729
+
730
+ const accessToken = /* extract from params / IMS */;
731
+
732
+ const users = new UserCollection();
733
+
734
+ // Fail-fast validation — throws before touching the DB
735
+ users.validate({ first_name, last_name, email });
736
+
737
+ // Open DB connection, run the operation, close in finally
738
+ const result = await users.run(async (collection) => {
739
+ return await collection.insertOne({ first_name, last_name, email });
740
+ }, accessToken);
741
+
742
+ logger.info(`User inserted: ${result.insertedId}`);
743
+
744
+ return RuntimeActionResponse.success(result);
745
+ }
746
+ );
747
+ ```
748
+
749
+ ##### 3. API surface reference
750
+
751
+ **`addColumn` call forms:**
752
+
753
+ ```javascript
754
+ // Positional (short form) — description and isRequired are optional positional args
755
+ c.addColumn('email', AbdbColumnType.STRING, 'Email address', true);
756
+
757
+ // Options-object form — no undefined placeholder needed when setting only one option
758
+ c.addColumn('email', AbdbColumnType.STRING, { isRequired: true });
759
+ c.addColumn('note', AbdbColumnType.STRING, { description: 'An optional note' });
760
+ ```
761
+
762
+ **Supported types (`AbdbColumnType`):**
763
+
764
+ | Value | Accepts |
765
+ |---|---|
766
+ | `STRING` | Primitive string |
767
+ | `NUMBER` | Finite number, or numeric string (e.g. `"3.14"`) |
768
+ | `BOOLEAN` | `true`/`false`, or `"true"`/`"false"` (case-insensitive) |
769
+ | `DATETIME` | `Date`, finite timestamp (ms), or ISO 8601 string |
770
+
771
+ **Validation strategies:**
772
+
773
+ ```javascript
774
+ // Fail-fast — throws on the first error (use before DB writes)
775
+ users.validate({ first_name: 'Jane', last_name: 'Doe', email: 'jane@example.com' });
776
+
777
+ // Collect all errors — ideal for API validation responses
778
+ const errors = users.validateAll({ first_name: '', email: 'not-an-email' });
779
+ // errors → ['"first_name" expects a string', '"last_name" is required']
780
+ ```
781
+
782
+ **Column introspection:**
783
+
784
+ ```javascript
785
+ users.hasColumn('email'); // true
786
+ users.getColumn('email'); // AbdbColumn instance (or undefined)
787
+ users.getColumns(); // Map<string, AbdbColumn> in insertion order
788
+ ```
789
+
671
790
  ### 🏪 Commerce Components
672
791
 
673
792
  **Adobe Commerce API integration and authentication**
@@ -1744,6 +1863,105 @@ COMMERCE_ACCESS_TOKEN=commerce-access-token
1744
1863
  COMMERCE_ACCESS_TOKEN_SECRET=commerce-access-token-secret
1745
1864
  ```
1746
1865
 
1866
+ ## Dependency Resolution
1867
+
1868
+ This toolkit carefully manages its dependency tree to avoid conflicts with packages already installed in your App Builder project.
1869
+
1870
+ ### How dependencies are split
1871
+
1872
+ #### `dependencies` — bundled with the toolkit
1873
+
1874
+ Packages installed directly by the toolkit that are either unique to it, or are stateless utilities where having two copies causes no functional harm:
1875
+
1876
+ | Package | Reason |
1877
+ |---|---|
1878
+ | `@adobe-commerce/aio-services-kit` | Companion package — not used by client projects directly |
1879
+ | `cloudevents` | Stateless event constructor — duplicate copies are harmless |
1880
+ | `dotenv` | Stateless — only sets `process.env`; two copies are harmless |
1881
+ | `got` | Internal HTTP client for Commerce API — not exposed externally |
1882
+ | `node-fetch` | Stateless HTTP function — no shared state |
1883
+ | `oauth-1.0a` | Internal OAuth 1.0a request signing — not exposed externally |
1884
+ | `openwhisk` | Creates client instances per call — no global singleton |
1885
+ | `uuid` | Pure stateless function — no conflict possible |
1886
+ | `yaml` | Stateless YAML parser — no shared state |
1887
+
1888
+ #### `peerDependencies` — must use your project's copy
1889
+
1890
+ Packages that maintain **singleton state or shared registries** — if two copies exist (one in the toolkit, one in your project), they behave as separate instances which breaks shared behaviour:
1891
+
1892
+ | Package | Why it must be shared |
1893
+ |---|---|
1894
+ | `@adobe/aio-sdk` | Singleton services — logger, config, state are shared across the app |
1895
+ | `graphql` | Schema registry is a singleton — `instanceof GraphQLSchema` and type checks fail with two copies |
1896
+ | `@adobe/aio-lib-ims` | Token cache and auth context must be the same shared instance |
1897
+ | `@adobe/aio-lib-telemetry` | Single telemetry pipeline — two copies split traces and logs |
1898
+ | `@opentelemetry/resources` | Resource object tied to the telemetry pipeline instance |
1899
+
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.
1901
+
1902
+ ### Installing peer dependencies
1903
+
1904
+ Install the toolkit and all required peer dependencies in one command:
1905
+
1906
+ ```bash
1907
+ npm install @adobe-commerce/aio-toolkit \
1908
+ @adobe/aio-sdk \
1909
+ @adobe/aio-lib-ims \
1910
+ @adobe/aio-lib-telemetry \
1911
+ @opentelemetry/resources \
1912
+ graphql
1913
+ ```
1914
+
1915
+ Or individually if you prefer to control versions:
1916
+
1917
+ ```bash
1918
+ npm install @adobe-commerce/aio-toolkit
1919
+
1920
+ # Required peer dependencies
1921
+ npm install @adobe/aio-sdk@^5.0.0
1922
+ npm install @adobe/aio-lib-ims@^7.0.0
1923
+ npm install @adobe/aio-lib-telemetry@^1.0.0
1924
+ npm install @opentelemetry/resources@^2.0.0
1925
+ npm install graphql@^16.0.0
1926
+ ```
1927
+
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.
1929
+
1930
+ ### Resolving `ERESOLVE` errors
1931
+
1932
+ If you see an `ERESOLVE` error when installing, it means one of the required peer dependencies is installed in your project at a version outside the supported range.
1933
+
1934
+ **Check which peer dep is conflicting:**
1935
+
1936
+ ```bash
1937
+ npm install @adobe-commerce/aio-toolkit 2>&1 | grep "Found:"
1938
+ ```
1939
+
1940
+ **Upgrade the conflicting package to a compatible version:**
1941
+
1942
+ ```bash
1943
+ # @adobe/aio-sdk must be >=5.0.0
1944
+ npm install @adobe/aio-sdk@latest
1945
+
1946
+ # graphql must be >=14.0.0
1947
+ npm install graphql@latest
1948
+
1949
+ # @adobe/aio-lib-ims must be >=7.0.0
1950
+ npm install @adobe/aio-lib-ims@latest
1951
+
1952
+ # @adobe/aio-lib-telemetry must be >=1.0.0
1953
+ npm install @adobe/aio-lib-telemetry@latest
1954
+
1955
+ # @opentelemetry/resources must be >=2.0.0
1956
+ npm install @opentelemetry/resources@latest
1957
+ ```
1958
+
1959
+ If upgrading is not immediately possible, you can bypass the check with `--legacy-peer-deps` (not recommended for production):
1960
+
1961
+ ```bash
1962
+ npm install @adobe-commerce/aio-toolkit --legacy-peer-deps
1963
+ ```
1964
+
1747
1965
  ## License
1748
1966
 
1749
1967
  See the LICENSE file (in package) for license rights and limitations.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import openwhisk, { Dict, Activation } from 'openwhisk';
2
+ import { DbCollection, DbClient } from '@adobe/aio-lib-db';
2
3
  import { EntrypointInstrumentationConfig } from '@adobe/aio-lib-telemetry';
3
4
  import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
4
5
  import { SdkLogRecord } from '@adobe/aio-lib-telemetry/otel';
@@ -327,6 +328,67 @@ declare class RuntimeApiGatewayService {
327
328
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
328
329
  }
329
330
 
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
+
330
392
  declare class TelemetryInputError extends Error {
331
393
  constructor(message: string);
332
394
  }
@@ -989,4 +1051,4 @@ declare class AdminUiSdk {
989
1051
  getRegistration(): AdminUiSdkRegistration;
990
1052
  }
991
1053
 
992
- export { 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import openwhisk, { Dict, Activation } from 'openwhisk';
2
+ import { DbCollection, DbClient } from '@adobe/aio-lib-db';
2
3
  import { EntrypointInstrumentationConfig } from '@adobe/aio-lib-telemetry';
3
4
  import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
4
5
  import { SdkLogRecord } from '@adobe/aio-lib-telemetry/otel';
@@ -327,6 +328,67 @@ declare class RuntimeApiGatewayService {
327
328
  delete(endpoint: string, additionalHeaders?: Record<string, string>): Promise<any>;
328
329
  }
329
330
 
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
+
330
392
  declare class TelemetryInputError extends Error {
331
393
  constructor(message: string);
332
394
  }
@@ -989,4 +1051,4 @@ declare class AdminUiSdk {
989
1051
  getRegistration(): AdminUiSdkRegistration;
990
1052
  }
991
1053
 
992
- export { 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 };
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 };