@adobe/aio-commerce-lib-app 0.3.1 → 1.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +1 -4
  3. package/bin/cli.mjs +24 -0
  4. package/dist/cjs/actions/app-config.cjs +27 -0
  5. package/dist/cjs/actions/app-config.d.cts +15 -0
  6. package/dist/cjs/actions/config.cjs +79 -0
  7. package/dist/cjs/actions/config.d.cts +15 -0
  8. package/dist/cjs/actions/installation.cjs +424 -0
  9. package/dist/cjs/actions/{index.d.cts → installation.d.cts} +4 -3
  10. package/dist/cjs/actions/scope-tree.cjs +97 -0
  11. package/dist/cjs/actions/scope-tree.d.cts +8 -0
  12. package/dist/cjs/{app-Dx0ca6oL.d.cts → app-PTKvEBea.d.cts} +6 -6
  13. package/dist/cjs/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  14. package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  15. package/dist/cjs/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  16. package/dist/cjs/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  17. package/dist/cjs/commands/index.cjs +105 -113
  18. package/dist/cjs/config/index.cjs +21 -19
  19. package/dist/cjs/config/index.d.cts +32 -332
  20. package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
  21. package/dist/cjs/installation-nwF2RC7F.cjs +241 -0
  22. package/dist/cjs/{logging-DYwr5WQk.cjs → logging-IDRQG0as.cjs} +2 -2
  23. package/dist/cjs/management/index.cjs +9 -8
  24. package/dist/cjs/management/index.d.cts +2 -2
  25. package/dist/cjs/parser-DIchX9SL.cjs +267 -0
  26. package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
  27. package/dist/cjs/{management-Dm5h0E6l.cjs → runner-CUJ8RHzY.cjs} +24 -30
  28. package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-Ds2m27Q4.d.cts} +49 -95
  29. package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
  30. package/dist/cjs/validate-BegMfe-i.cjs +235 -0
  31. package/dist/es/actions/app-config.d.mts +15 -0
  32. package/dist/es/actions/app-config.mjs +25 -0
  33. package/dist/es/actions/config.d.mts +15 -0
  34. package/dist/es/actions/config.mjs +77 -0
  35. package/dist/es/actions/{index.d.mts → installation.d.mts} +4 -3
  36. package/dist/es/actions/{index.mjs → installation.mjs} +27 -427
  37. package/dist/es/actions/scope-tree.d.mts +8 -0
  38. package/dist/es/actions/scope-tree.mjs +95 -0
  39. package/dist/es/{app-Cx1-6dn0.d.mts → app-vKXaAr6f.d.mts} +6 -6
  40. package/dist/es/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  41. package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  42. package/dist/es/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  43. package/dist/es/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  44. package/dist/es/commands/index.mjs +82 -91
  45. package/dist/es/config/index.d.mts +32 -332
  46. package/dist/es/config/index.mjs +3 -2
  47. package/dist/es/error-CMV3IjBz.mjs +18 -0
  48. package/dist/es/{error-P7JgUTds.mjs → installation-SWIwhpKT.mjs} +72 -124
  49. package/dist/es/management/index.d.mts +2 -3
  50. package/dist/es/management/index.mjs +1 -1
  51. package/dist/es/parser-CKQyrTB7.mjs +201 -0
  52. package/dist/es/router-CJ4VWoCt.mjs +404 -0
  53. package/dist/es/{management-Y7pwEbNI.mjs → runner-DB2tDBQS.mjs} +17 -24
  54. package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-Uk7263hG.d.mts} +49 -95
  55. package/dist/es/schemas-B8yIv0_b.mjs +41 -0
  56. package/dist/es/validate-DXI6gwZ2.mjs +187 -0
  57. package/package.json +39 -25
  58. package/dist/cjs/actions/index.cjs +0 -824
  59. package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  60. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  61. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  62. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  63. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  64. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  65. package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  66. package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  67. package/dist/cjs/config-JQ_n-5Nk.cjs +0 -565
  68. package/dist/cjs/error-Byj1DVHZ.cjs +0 -344
  69. package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  70. package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  71. package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  72. package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  73. package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  74. package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  75. package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  76. package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  77. package/dist/es/config-BSGerqCG.mjs +0 -457
  78. /package/dist/es/{logging-VgerMhp6.mjs → logging-CzmXDzxI.mjs} +0 -0
@@ -1,7 +1,7 @@
1
- import { n as CommerceAppConfigOutputModel } from "./app-Dx0ca6oL.cjs";
2
- import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
3
- import * as v from "valibot";
1
+ import { n as CommerceAppConfigOutputModel } from "./app-vKXaAr6f.mjs";
4
2
  import AioLogger from "@adobe/aio-lib-core-logging";
3
+ import * as v from "valibot";
4
+ import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
5
5
 
6
6
  //#region source/management/installation/schema.d.ts
7
7
  /** Schema for validating Adobe I/O app credentials required for installation. */
@@ -21,9 +21,7 @@ type AppData = v.InferOutput<typeof AppDataSchema>;
21
21
  //#region source/management/installation/workflow/step.d.ts
22
22
  /** Shared context available to all steps during installation. */
23
23
  type InstallationContext = {
24
- /** The credentials of the app being installed */
25
- appData: AppData;
26
- /** The raw action parameters from the App Builder runtime action. */
24
+ /** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
27
25
  params: RuntimeActionParams & {
28
26
  AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
29
27
  AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
@@ -31,10 +29,8 @@ type InstallationContext = {
31
29
  AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
32
30
  AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
33
31
  AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
34
- };
35
- /** Logger instance for installation logging. */
36
- logger: ReturnType<typeof AioLogger>;
37
- /** Custom scripts defined in the configuration (if any). */
32
+ }; /** Logger instance for installation logging. */
33
+ logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
38
34
  customScripts?: Record<string, unknown>;
39
35
  };
40
36
  /** Factory function type for creating step-specific context. */
@@ -48,45 +44,39 @@ type StepMeta = {
48
44
  };
49
45
  /** Defines the base properties of a step. */
50
46
  type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
51
- /** The name of this step. */
52
- name: TName;
53
- /** Metadata associated with the step. */
54
- meta: StepMeta;
55
- /** Whether the step should be taken into consideration. */
47
+ /** The name of this step. */name: TName; /** Metadata associated with the step. */
48
+ meta: StepMeta; /** Whether the step should be taken into consideration. */
56
49
  when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
57
50
  };
58
51
  /** A leaf step that executes work (no children). */
59
- type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = StepBase<TName, TConfig> & {
60
- type: "leaf";
61
- /** The execution handler for the step. */
62
- run: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput$1 | Promise<TOutput$1>;
52
+ type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
53
+ type: "leaf"; /** The execution handler for the step. */
54
+ run: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
63
55
  };
64
56
  /** A branch step that contains children (no execution). */
65
57
  type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>> = StepBase<TName, TConfig> & {
66
- type: "branch";
67
- /** An optional factory function to setup shared context for the children steps. */
68
- context?: StepContextFactory<TStepCtx>;
69
- /** The children steps of this branch. */
58
+ type: "branch"; /** An optional factory function to setup shared context for the children steps. */
59
+ context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
70
60
  children: AnyStep[];
71
61
  };
72
62
  /** A step in the installation tree (discriminated union by `type`). */
73
- type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput$1> | BranchStep<TName, TConfig, TStepCtx>;
63
+ type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput> | BranchStep<TName, TConfig, TStepCtx>;
74
64
  /** Loosely-typed step for use in non type-safe contexts. */
75
65
  interface AnyStep {
76
- type: "leaf" | "branch";
77
- name: string;
78
- meta: StepMeta;
79
- when?: (config: CommerceAppConfigOutputModel) => boolean;
80
66
  children?: AnyStep[];
81
67
  context?: (context: InstallationContext) => any;
68
+ meta: StepMeta;
69
+ name: string;
82
70
  run?: (config: any, context: any) => unknown | Promise<unknown>;
71
+ type: "leaf" | "branch";
72
+ when?: (config: CommerceAppConfigOutputModel) => boolean;
83
73
  }
84
74
  /** Check if a step is a leaf step. */
85
75
  declare function isLeafStep(step: AnyStep): step is LeafStep;
86
76
  /** Check if a step is a branch step. */
87
77
  declare function isBranchStep(step: AnyStep): step is BranchStep;
88
78
  /** Options for defining a leaf step. */
89
- type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput$1>, "type">;
79
+ type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput>, "type">;
90
80
  /** Options for defining a branch step. */
91
81
  type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>> = Omit<BranchStep<TName, TConfig, TStepCtx>, "type">;
92
82
  /**
@@ -104,7 +94,7 @@ type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOu
104
94
  * });
105
95
  * ```
106
96
  */
107
- declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput$1>): LeafStep<TName, TConfig, TStepCtx, TOutput$1>;
97
+ declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput>): LeafStep<TName, TConfig, TStepCtx, TOutput>;
108
98
  /**
109
99
  * Define a branch step (container with children, no runner).
110
100
  *
@@ -130,28 +120,18 @@ type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
130
120
  type InstallationStatus = "pending" | "in-progress" | "succeeded" | "failed";
131
121
  /** A structured error with path to the failing step. */
132
122
  type InstallationError<TPayload = unknown> = {
133
- /** Path to the step that failed (e.g., ["eventing", "commerce", "providers"]). */
134
- path: string[];
135
- /** Error key for easy identification. */
136
- key: string;
137
- /** Human-readable error message. */
138
- message?: string;
139
- /** Additional error payload. */
123
+ /** Path to the step that failed (e.g., ["eventing", "commerce", "providers"]). */path: string[]; /** Error key for easy identification. */
124
+ key: string; /** Human-readable error message. */
125
+ message?: string; /** Additional error payload. */
140
126
  payload?: TPayload;
141
127
  };
142
128
  /** Status of a step in the installation tree. */
143
129
  type StepStatus = {
144
- /** Step name (unique among siblings). */
145
- name: string;
146
- /** Unique step identifier (e.g., UUID). */
147
- id: string;
148
- /** Full path from root to this step. */
149
- path: string[];
150
- /** Step metadata (for display purposes). */
151
- meta: StepMeta;
152
- /** Current execution status. */
153
- status: ExecutionStatus;
154
- /** Child step statuses (empty for leaf steps). */
130
+ /** Step name (unique among siblings). */name: string; /** Unique step identifier (e.g., UUID). */
131
+ id: string; /** Full path from root to this step. */
132
+ path: string[]; /** Step metadata (for display purposes). */
133
+ meta: StepMeta; /** Current execution status. */
134
+ status: ExecutionStatus; /** Child step statuses (empty for leaf steps). */
155
135
  children: StepStatus[];
156
136
  };
157
137
  /** Data collected during installation as a nested structure following step paths. */
@@ -160,35 +140,26 @@ type InstallationData = {
160
140
  };
161
141
  /** Base properties shared by all installation states. */
162
142
  type InstallationStateBase = {
163
- /** Unique installation identifier. */
164
- id: string;
165
- /** Root step status. */
166
- step: StepStatus;
167
- /** Results from executed leaf steps, keyed by path. */
143
+ /** Unique installation identifier. */id: string; /** Root step status. */
144
+ step: StepStatus; /** Results from executed leaf steps, keyed by path. */
168
145
  data: InstallationData | null;
169
146
  };
170
147
  /** Installation state when in progress. */
171
148
  type InProgressInstallationState = InstallationStateBase & {
172
- status: "in-progress";
173
- /** ISO timestamp when installation started. */
149
+ status: "in-progress"; /** ISO timestamp when installation started. */
174
150
  startedAt: string;
175
151
  };
176
152
  /** Installation state when completed successfully. */
177
153
  type SucceededInstallationState = InstallationStateBase & {
178
- status: "succeeded";
179
- /** ISO timestamp when installation started. */
180
- startedAt: string;
181
- /** ISO timestamp when installation completed. */
154
+ status: "succeeded"; /** ISO timestamp when installation started. */
155
+ startedAt: string; /** ISO timestamp when installation completed. */
182
156
  completedAt: string;
183
157
  };
184
158
  /** Installation state when failed. */
185
159
  type FailedInstallationState = InstallationStateBase & {
186
- status: "failed";
187
- /** ISO timestamp when installation started. */
188
- startedAt: string;
189
- /** ISO timestamp when installation failed. */
190
- completedAt: string;
191
- /** Error information about the failure. */
160
+ status: "failed"; /** ISO timestamp when installation started. */
161
+ startedAt: string; /** ISO timestamp when installation failed. */
162
+ completedAt: string; /** Error information about the failure. */
192
163
  error: InstallationError;
193
164
  };
194
165
  /**
@@ -213,24 +184,19 @@ type HookFunction<TEvent> = (event: TEvent, state: InstallationState) => void |
213
184
  type InstallationHook = (state: InstallationState) => void | Promise<void>;
214
185
  /** Base event payload for step events. */
215
186
  type StepEvent = {
216
- /** Full path to the step (e.g., ["eventing", "commerce", "providers"]). */
217
- path: string[];
218
- /** Step name (last element of path, for convenience). */
219
- stepName: string;
220
- /** Whether this is a leaf step (executable) or branch step (container). */
187
+ /** Full path to the step (e.g., ["eventing", "commerce", "providers"]). */path: string[]; /** Step name (last element of path, for convenience). */
188
+ stepName: string; /** Whether this is a leaf step (executable) or branch step (container). */
221
189
  isLeaf: boolean;
222
190
  };
223
191
  /** Event payload when a step starts execution. */
224
192
  type StepStartedEvent = StepEvent;
225
193
  /** Event payload when a step succeeds. */
226
194
  type StepSucceededEvent = StepEvent & {
227
- /** Result returned by the step (only for leaf steps). */
228
- result: unknown;
195
+ /** Result returned by the step (only for leaf steps). */result: unknown;
229
196
  };
230
197
  /** Event payload when a step fails. */
231
198
  type StepFailedEvent = StepEvent & {
232
- /** Error information. */
233
- error: InstallationError;
199
+ /** Error information. */error: InstallationError;
234
200
  };
235
201
  /** Lifecycle hooks for installation execution. */
236
202
  type InstallationHooks = {
@@ -245,22 +211,15 @@ type InstallationHooks = {
245
211
  //#region source/management/installation/workflow/runner.d.ts
246
212
  /** Options for creating an initial installation state. */
247
213
  type CreateInitialStateOptions = {
248
- /** The root branch step to build the state from. */
249
- rootStep: BranchStep;
250
- /** The app configuration used to determine applicable steps. */
214
+ /** The root branch step to build the state from. */rootStep: BranchStep; /** The app configuration used to determine applicable steps. */
251
215
  config: CommerceAppConfigOutputModel;
252
216
  };
253
217
  /** Options for executing a workflow. */
254
218
  type ExecuteWorkflowOptions = {
255
- /** The root branch step to execute. */
256
- rootStep: BranchStep;
257
- /** Shared installation context (params, logger, etc.). */
258
- installationContext: InstallationContext;
259
- /** The app configuration. */
260
- config: CommerceAppConfigOutputModel;
261
- /** The initial installation state (with all steps pending). */
262
- initialState: InProgressInstallationState;
263
- /** Lifecycle hooks for status change notifications. */
219
+ /** The root branch step to execute. */rootStep: BranchStep; /** Shared installation context (params, logger, etc.). */
220
+ installationContext: InstallationContext; /** The app configuration. */
221
+ config: CommerceAppConfigOutputModel; /** The initial installation state (with all steps pending). */
222
+ initialState: InProgressInstallationState; /** Lifecycle hooks for status change notifications. */
264
223
  hooks?: InstallationHooks;
265
224
  };
266
225
  /**
@@ -317,18 +276,13 @@ declare function defineCustomInstallationStep<TResult = unknown>(handler: Custom
317
276
  //#region source/management/installation/runner.d.ts
318
277
  /** Options for creating an initial installation state. */
319
278
  type CreateInitialInstallationStateOptions = {
320
- /** The app configuration used to determine applicable steps. */
321
- config: CommerceAppConfigOutputModel;
279
+ /** The app configuration used to determine applicable steps. */config: CommerceAppConfigOutputModel;
322
280
  };
323
281
  /** Options for running an installation. */
324
282
  type RunInstallationOptions = {
325
- /** Shared installation context (params, logger, etc.). */
326
- installationContext: InstallationContext;
327
- /** The app configuration. */
328
- config: CommerceAppConfigOutputModel;
329
- /** The initial installation state (with all steps pending). */
330
- initialState: InProgressInstallationState;
331
- /** Lifecycle hooks for status change notifications. */
283
+ /** Shared installation context (params, logger, etc.). */installationContext: InstallationContext; /** The app configuration. */
284
+ config: CommerceAppConfigOutputModel; /** The initial installation state (with all steps pending). */
285
+ initialState: InProgressInstallationState; /** Lifecycle hooks for status change notifications. */
332
286
  hooks?: InstallationHooks;
333
287
  };
334
288
  /**
@@ -0,0 +1,41 @@
1
+ import * as v from "valibot";
2
+
3
+ //#region ../../packages-private/common-utils/source/valibot/schemas.ts
4
+ const ALPHANUMERIC_OR_HYPHEN_REGEX = {
5
+ any: /^[a-zA-Z0-9-]+$/,
6
+ lowercase: /^[a-z0-9-]+$/,
7
+ uppercase: /^[A-Z0-9-]+$/
8
+ };
9
+ /**
10
+ * A schema for a string value.
11
+ * @param name The name of the field this schema refers to.
12
+ */
13
+ function stringValueSchema(name) {
14
+ return v.string(`Expected a string value for '${name}'`);
15
+ }
16
+ /**
17
+ * A schema for a non-empty string value.
18
+ * @param name The name of the field this schema refers to.
19
+ */
20
+ function nonEmptyStringValueSchema(name) {
21
+ return v.pipe(stringValueSchema(name), v.nonEmpty(`The value of "${name}" must not be empty`));
22
+ }
23
+ /**
24
+ * A schema for a boolean value.
25
+ * @param name The name of the field this schema refers to.
26
+ */
27
+ function booleanValueSchema(name) {
28
+ return v.boolean(`Expected a boolean value for '${name}'`);
29
+ }
30
+ /**
31
+ * A schema for a string that only contains alphanumeric characters and hyphens.
32
+ * @param name The name of the field this schema refers to.
33
+ * @param casing The allowed casing for the string (default: "any").
34
+ */
35
+ function alphaNumericOrHyphenSchema(name, casing = "any") {
36
+ const casingLabel = casing === "any" ? "" : ` (${casing} only)`;
37
+ return v.pipe(stringValueSchema(name), v.regex(ALPHANUMERIC_OR_HYPHEN_REGEX[casing], `Only alphanumeric characters and hyphens are allowed in string value of "${name}"${casingLabel}`));
38
+ }
39
+
40
+ //#endregion
41
+ export { stringValueSchema as i, booleanValueSchema as n, nonEmptyStringValueSchema as r, alphaNumericOrHyphenSchema as t };
@@ -0,0 +1,187 @@
1
+ import { t as alphaNumericOrHyphenSchema } from "./schemas-B8yIv0_b.mjs";
2
+ import { a as hasCommerceEvents, i as EventingSchema, n as hasCustomInstallation, r as hasCustomInstallationSteps, s as hasExternalEvents, t as InstallationSchema } from "./installation-SWIwhpKT.mjs";
3
+ import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
4
+ import * as v from "valibot";
5
+ import { SchemaBusinessConfig } from "@adobe/aio-commerce-lib-config";
6
+
7
+ //#region source/config/schema/business-configuration.ts
8
+ /**
9
+ * Check if config has business config.
10
+ * @param config - The configuration to check.
11
+ */
12
+ function hasBusinessConfig(config) {
13
+ return config.businessConfig !== void 0;
14
+ }
15
+ /**
16
+ * Check if config has business config schema.
17
+ * @param config - The configuration to check.
18
+ */
19
+ function hasBusinessConfigSchema(config) {
20
+ return config.businessConfig?.schema !== void 0 && config.businessConfig.schema.length > 0;
21
+ }
22
+
23
+ //#endregion
24
+ //#region source/config/schema/metadata.ts
25
+ const MAX_DESCRIPTION_LENGTH = 255;
26
+ const MAX_DISPLAY_NAME_LENGTH = 50;
27
+ const NUMERIC_IDENTIFIER = "(0|[1-9]\\d*)";
28
+ const SEMVER_REGEX = new RegExp(`^${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}$`);
29
+ function nonEmptyString(fieldName) {
30
+ return v.pipe(v.string(`Expected a string for the ${fieldName}`), v.nonEmpty(`The ${fieldName} must not be empty`));
31
+ }
32
+ /** The schema for the metadata of the application. */
33
+ const MetadataSchema = v.object({
34
+ id: alphaNumericOrHyphenSchema("application id (metadata.id)"),
35
+ displayName: v.pipe(nonEmptyString("application display name"), v.maxLength(MAX_DISPLAY_NAME_LENGTH, `The application display name must not be longer than ${MAX_DISPLAY_NAME_LENGTH} characters`)),
36
+ description: v.pipe(nonEmptyString("metadata description"), v.maxLength(MAX_DESCRIPTION_LENGTH, `The metadata description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`)),
37
+ version: v.pipe(nonEmptyString("version"), v.regex(SEMVER_REGEX, "The version must follow semantic versioning (semver) format"))
38
+ });
39
+ /**
40
+ * Check if config has metadata.
41
+ * @param config - The configuration to check.
42
+ */
43
+ function hasMetadata(config) {
44
+ return config.metadata !== void 0;
45
+ }
46
+
47
+ //#endregion
48
+ //#region source/config/schema/app.ts
49
+ /** biome-ignore-all lint/performance/noBarrelFile: We want to have all the schema exports in one file. */
50
+ /** The schema used to validate the commerce app config file. */
51
+ const CommerceAppConfigSchema = v.looseObject({
52
+ metadata: MetadataSchema,
53
+ businessConfig: v.optional(SchemaBusinessConfig),
54
+ eventing: v.optional(EventingSchema),
55
+ installation: v.optional(InstallationSchema)
56
+ });
57
+
58
+ //#endregion
59
+ //#region source/config/schema/domains.ts
60
+ /** The individual validatable domains of the app config. */
61
+ const CommerceAppConfigSchemas = {
62
+ metadata: MetadataSchema,
63
+ businessConfig: SchemaBusinessConfig,
64
+ eventing: EventingSchema,
65
+ installation: InstallationSchema,
66
+ "businessConfig.schema": v.unwrap(SchemaBusinessConfig.entries.schema),
67
+ "eventing.commerce": v.unwrap(EventingSchema.entries.commerce),
68
+ "eventing.external": v.unwrap(EventingSchema.entries.external),
69
+ "installation.customInstallationSteps": v.unwrap(InstallationSchema.entries.customInstallationSteps)
70
+ };
71
+ /**
72
+ * Get the config domains that are present in the config.
73
+ * @param config - The configuration to check.
74
+ */
75
+ function getConfigDomains(config) {
76
+ const withCommerceEvents = hasCommerceEvents(config);
77
+ const withExternalEvents = hasExternalEvents(config);
78
+ const domains = {
79
+ metadata: hasMetadata(config),
80
+ businessConfig: hasBusinessConfig(config),
81
+ eventing: withCommerceEvents || withExternalEvents,
82
+ installation: hasCustomInstallation(config),
83
+ "businessConfig.schema": hasBusinessConfigSchema(config),
84
+ "eventing.commerce": withCommerceEvents,
85
+ "eventing.external": withExternalEvents,
86
+ "installation.customInstallationSteps": hasCustomInstallationSteps(config)
87
+ };
88
+ const domainsList = Object.entries(domains).filter(([_, value]) => value).map(([key]) => key);
89
+ return new Set(domainsList);
90
+ }
91
+ /**
92
+ * Check if the config has a specific domain.
93
+ * @param config - The configuration to check.
94
+ * @param domain - The domain to check.
95
+ */
96
+ function hasConfigDomain(config, domain) {
97
+ return getConfigDomains(config).has(domain);
98
+ }
99
+
100
+ //#endregion
101
+ //#region source/config/lib/validate.ts
102
+ const commerceAppConfigDomainsSchema = v.picklist(Object.keys(CommerceAppConfigSchemas));
103
+ /**
104
+ * Validates a complete commerce app configuration object against the schema.
105
+ *
106
+ * @param config - The configuration object to validate.
107
+ * @returns The validated and typed configuration output model.
108
+ *
109
+ * @throws {CommerceSdkValidationError} If the configuration is invalid, with
110
+ * detailed validation issues included.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const config = {
115
+ * businessConfiguration: {
116
+ * // ... configuration data
117
+ * }
118
+ * };
119
+ *
120
+ * try {
121
+ * const validatedConfig = validateCommerceAppConfig(config);
122
+ * // Use validatedConfig safely
123
+ * } catch (error) {
124
+ * if (error instanceof CommerceSdkValidationError) {
125
+ * console.error('Validation failed:', error.display());
126
+ * }
127
+ * }
128
+ * ```
129
+ */
130
+ function validateCommerceAppConfig(config) {
131
+ const validatedConfig = v.safeParse(CommerceAppConfigSchema, config);
132
+ if (!validatedConfig.success) throw new CommerceSdkValidationError("Invalid commerce app config", { issues: validatedConfig.issues });
133
+ return validatedConfig.output;
134
+ }
135
+ /**
136
+ * Validates a specific domain configuration within the commerce app config.
137
+ *
138
+ * This function validates only a specific domain's configuration rather than
139
+ * the entire commerce app configuration object. It first validates that the
140
+ * domain name is valid, then validates the configuration data against the
141
+ * schema for that specific domain.
142
+ *
143
+ * @template T - The type of the domain, constrained to valid domain names.
144
+ *
145
+ * @param config - The domain configuration object to validate.
146
+ * @param domain - The name of the domain to validate (e.g., 'businessConfiguration').
147
+ * @returns The validated and typed configuration for the specified domain.
148
+ *
149
+ * @throws {CommerceSdkValidationError} If the domain name is invalid or if the
150
+ * configuration doesn't match the domain's schema.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const businessConfig = {
155
+ * fields: [
156
+ * {
157
+ * name: 'category',
158
+ * type: 'dropdown',
159
+ * // ... field configuration
160
+ * }
161
+ * ]
162
+ * };
163
+ *
164
+ * try {
165
+ * const validatedConfig = validateCommerceAppConfigDomain(
166
+ * businessConfig,
167
+ * 'businessConfig'
168
+ * );
169
+ * // Use validatedConfig safely
170
+ * } catch (error) {
171
+ * if (error instanceof CommerceSdkValidationError) {
172
+ * console.error('Domain validation failed:', error.issues);
173
+ * }
174
+ * }
175
+ * ```
176
+ */
177
+ function validateCommerceAppConfigDomain(config, domain) {
178
+ const domainSchema = v.safeParse(commerceAppConfigDomainsSchema, domain);
179
+ if (!domainSchema.success) throw new CommerceSdkValidationError("Invalid commerce app config domain", { issues: domainSchema.issues });
180
+ const domainConfigSchema = CommerceAppConfigSchemas[domain];
181
+ const validatedConfig = v.safeParse(domainConfigSchema, config);
182
+ if (!validatedConfig.success) throw new CommerceSdkValidationError(`Invalid commerce app config: ${domain}`, { issues: validatedConfig.issues });
183
+ return validatedConfig.output;
184
+ }
185
+
186
+ //#endregion
187
+ export { hasConfigDomain as a, hasBusinessConfigSchema as c, getConfigDomains as i, validateCommerceAppConfigDomain as n, hasMetadata as o, CommerceAppConfigSchemas as r, hasBusinessConfig as s, validateCommerceAppConfig as t };
package/package.json CHANGED
@@ -2,13 +2,24 @@
2
2
  "name": "@adobe/aio-commerce-lib-app",
3
3
  "type": "module",
4
4
  "author": "Adobe Inc.",
5
- "version": "0.3.1",
5
+ "version": "1.0.0",
6
6
  "private": false,
7
7
  "engines": {
8
8
  "node": ">=20 <=24"
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "description": "App configuration management library for Adobe Commerce applications",
12
+ "keywords": [
13
+ "aio",
14
+ "adobe-io",
15
+ "commerce",
16
+ "adobe-commerce",
17
+ "adobe-commerce-sdk",
18
+ "aio-commerce-sdk",
19
+ "aio-commerce-lib-app",
20
+ "configuration",
21
+ "app-builder"
22
+ ],
12
23
  "bugs": {
13
24
  "url": "https://github.com/adobe/aio-commerce-sdk/issues"
14
25
  },
@@ -18,17 +29,17 @@
18
29
  "directory": "packages/aio-commerce-lib-app"
19
30
  },
20
31
  "bin": {
21
- "@adobe/aio-commerce-lib-app": "./dist/es/commands/index.mjs"
32
+ "@adobe/aio-commerce-lib-app": "./bin/cli.mjs"
22
33
  },
23
34
  "exports": {
24
- "./actions": {
35
+ "./actions/*": {
25
36
  "import": {
26
- "types": "./dist/es/actions/index.d.mts",
27
- "default": "./dist/es/actions/index.mjs"
37
+ "types": "./dist/es/actions/*.d.mts",
38
+ "default": "./dist/es/actions/*.mjs"
28
39
  },
29
40
  "require": {
30
- "types": "./dist/cjs/actions/index.d.cts",
31
- "default": "./dist/cjs/actions/index.cjs"
41
+ "types": "./dist/cjs/actions/*.d.cts",
42
+ "default": "./dist/cjs/actions/*.cjs"
32
43
  }
33
44
  },
34
45
  "./config": {
@@ -59,41 +70,44 @@
59
70
  "#templates/*": "./source/commands/generate/actions/templates/*.template"
60
71
  },
61
72
  "files": [
73
+ "bin",
62
74
  "dist",
63
75
  "package.json",
64
76
  "CHANGELOG.md",
65
77
  "README.md"
66
78
  ],
67
79
  "dependencies": {
80
+ "@adobe/aio-lib-core-config": "^5.0.1",
81
+ "@adobe/aio-lib-core-logging": "^3.0.2",
82
+ "@adobe/aio-lib-files": "^4.1.2",
83
+ "@adobe/aio-lib-ims": "^8.1.1",
84
+ "@adobe/aio-lib-state": "^5.3.1",
68
85
  "camelcase": "^8.0.0",
69
86
  "consola": "^3.4.2",
87
+ "dotenv": "^17.2.3",
70
88
  "jiti": "^2.6.1",
71
89
  "openwhisk": "^3.21.8",
72
90
  "prettier": "^3.8.1",
91
+ "regexparam": "^3.0.0",
73
92
  "safe-stable-stringify": "^2.5.0",
93
+ "type-fest": "^5.0.0",
74
94
  "valibot": "^1.1.0",
75
- "dotenv": "^17.2.3",
76
- "regexparam": "^3.0.0",
77
- "@adobe/aio-lib-core-config": "^5.0.1",
78
- "@adobe/aio-lib-ims": "^8.1.1",
79
- "@adobe/aio-lib-core-logging": "^3.0.2",
80
- "@adobe/aio-lib-files": "^4.1.2",
81
- "@adobe/aio-lib-state": "^5.3.1",
82
- "@standard-schema/spec": "^1.1.0",
83
- "yaml": "^2.8.2",
84
- "@adobe/aio-commerce-lib-api": "0.6.1",
85
- "@adobe/aio-commerce-lib-core": "0.6.1",
86
- "@adobe/aio-commerce-lib-events": "0.6.0",
87
- "@adobe/aio-commerce-lib-auth": "0.8.1"
95
+ "yaml": "^2.8.1",
96
+ "@adobe/aio-commerce-lib-api": "1.0.0",
97
+ "@adobe/aio-commerce-lib-auth": "1.0.0",
98
+ "@adobe/aio-commerce-lib-config": "1.0.0",
99
+ "@adobe/aio-commerce-lib-core": "1.0.0",
100
+ "@adobe/aio-commerce-lib-events": "1.0.0"
88
101
  },
89
102
  "devDependencies": {
90
- "@adobe/aio-lib-core-logging": "^3.0.2",
91
- "@aio-commerce-sdk/common-utils": "0.2.1",
92
- "@aio-commerce-sdk/config-tsdown": "1.0.0",
103
+ "typescript": "^5.9.2",
104
+ "@aio-commerce-sdk/common-utils": "0.2.2",
105
+ "@aio-commerce-sdk/config-tsdown": "1.0.1",
93
106
  "@aio-commerce-sdk/config-typedoc": "1.0.0",
94
107
  "@aio-commerce-sdk/config-typescript": "1.0.0",
95
- "@aio-commerce-sdk/scripting-utils": "0.2.1",
96
- "@aio-commerce-sdk/config-vitest": "1.0.0"
108
+ "@aio-commerce-sdk/config-vitest": "1.0.0",
109
+ "@aio-commerce-sdk/scripting-utils": "0.2.2",
110
+ "@aio-commerce-sdk/scripts": "0.0.1"
97
111
  },
98
112
  "sideEffects": false,
99
113
  "scripts": {