@aligent/nx-appbuilder 0.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/README.md +203 -0
- package/generators.json +18 -0
- package/package.json +20 -0
- package/src/generators/app/files/base/.editorconfig.template +18 -0
- package/src/generators/app/files/base/.gitignore.template +9 -0
- package/src/generators/app/files/base/.nvmrc.template +1 -0
- package/src/generators/app/files/base/README.md.template +44 -0
- package/src/generators/app/files/base/app.config.yaml.template +77 -0
- package/src/generators/app/files/base/babel.actions.config.js.template +6 -0
- package/src/generators/app/files/base/eslint.config.mjs.template +8 -0
- package/src/generators/app/files/base/global-types/@adobe/ADOBE_TYPES.md.template +10 -0
- package/src/generators/app/files/base/global-types/@adobe/aio-sdk/aio-core-logging.d.ts.template +15 -0
- package/src/generators/app/files/base/global-types/@adobe/aio-sdk/aio-lib-core-config.d.ts.template +43 -0
- package/src/generators/app/files/base/hooks/check-action-types.sh.template +13 -0
- package/src/generators/app/files/base/prettier.config.mjs.template +3 -0
- package/src/generators/app/files/base/src/actions/tsconfig.json.template +8 -0
- package/src/generators/app/files/base/tests/tsconfig.json.template +13 -0
- package/src/generators/app/files/base/tsconfig.base.json.template +14 -0
- package/src/generators/app/files/base/tsconfig.json.template +3 -0
- package/src/generators/app/files/base/vitest.config.ts.template +19 -0
- package/src/generators/app/files/commerce-backend-ui/extension-manifest.json.template +8 -0
- package/src/generators/app/files/commerce-backend-ui/hooks/check-web-types.sh.template +11 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/registration/index.ts.template +32 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/tsconfig.json.template +8 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/http.ts.template +18 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/runtime.ts.template +47 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/actions/utils/utils.ts.template +187 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/ext.config.yaml.template +20 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/.gitignore.template +2 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/index.html.template +15 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/components/App.tsx.template +37 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/components/ExtensionRegistration.tsx.template +15 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/config.json.d.ts.template +4 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/constants/extension.ts.template +1 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/context/AdobeRuntimeContextProvider.tsx.template +65 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/context/PageContextProvider.tsx.template +78 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/hooks/useAppBuilderAction.ts.template +41 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/hooks/useLazyAppBuilderAction.ts.template +116 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/index.css.template +4 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/index.tsx.template +20 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/src/types/ActionName.ts.template +9 -0
- package/src/generators/app/files/commerce-backend-ui/src/commerce-backend-ui-1/web-src/tsconfig.json.template +14 -0
- package/src/generators/app/files/commerce-config/src/commerce-configuration-1/ext.config.yaml.template +37 -0
- package/src/generators/app/files/commerce-config/src/commerce-configuration-1/my-webpack-config.cjs.template +24 -0
- package/src/generators/app/files/commerce-extensibility/app.commerce.config.ts.template +138 -0
- package/src/generators/app/files/commerce-extensibility/install.yaml.template +17 -0
- package/src/generators/app/files/commerce-extensibility/src/commerce-extensibility-1/ext.config.yaml.template +25 -0
- package/src/generators/app/files/commerce-extensibility/src/commerce-extensibility-1/my-webpack-config.cjs.template +24 -0
- package/src/generators/app/files/events/global-types/@adobe/aio-sdk/aio-lib-events.d.ts.template +7 -0
- package/src/generators/app/files/events/src/actions/handle-sample-event.ts.template +35 -0
- package/src/generators/app/files/install-steps/scripts/install/sample-step.js.template +14 -0
- package/src/generators/app/files/rest-actions/src/actions/rest-sample.ts.template +30 -0
- package/src/generators/app/files/scheduled/src/actions/cron-sample.ts.template +23 -0
- package/src/generators/app/generator.d.ts +3 -0
- package/src/generators/app/generator.js +38 -0
- package/src/generators/app/lib/apply-feature-files.d.ts +9 -0
- package/src/generators/app/lib/apply-feature-files.js +76 -0
- package/src/generators/app/lib/compose-package-json.d.ts +3 -0
- package/src/generators/app/lib/compose-package-json.js +164 -0
- package/src/generators/app/lib/normalize-options.d.ts +3 -0
- package/src/generators/app/lib/normalize-options.js +67 -0
- package/src/generators/app/lib/template-package/package.json +31 -0
- package/src/generators/app/lib/update-root-package.d.ts +6 -0
- package/src/generators/app/lib/update-root-package.js +23 -0
- package/src/generators/app/lib/update-root-tsconfig.d.ts +8 -0
- package/src/generators/app/lib/update-root-tsconfig.js +24 -0
- package/src/generators/app/schema.d.ts +32 -0
- package/src/generators/app/schema.json +73 -0
- package/src/generators/preset/files/.gitignore.template +30 -0
- package/src/generators/preset/files/.npmrc.template +2 -0
- package/src/generators/preset/files/.nvmrc.template +1 -0
- package/src/generators/preset/files/README.md.template +38 -0
- package/src/generators/preset/files/tsconfig.json.template +6 -0
- package/src/generators/preset/nx-json.d.ts +4 -0
- package/src/generators/preset/nx-json.js +36 -0
- package/src/generators/preset/preset.d.ts +13 -0
- package/src/generators/preset/preset.js +113 -0
- package/src/generators/preset/schema.d.ts +4 -0
- package/src/generators/preset/schema.json +25 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +19 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Known App Builder action names registered in config.json.
|
|
3
|
+
* Update this type when actions are added or removed in app.config.yaml — it
|
|
4
|
+
* keeps the useAppBuilderAction / useLazyAppBuilderAction hooks type-safe.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* export type ActionName = 'my-package/my-action' | 'my-package/another-action';
|
|
8
|
+
*/
|
|
9
|
+
export type ActionName = never;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@aligent/ts-code-standards/tsconfigs-react",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowImportingTsExtensions": true,
|
|
5
|
+
"resolveJsonModule": true,
|
|
6
|
+
"baseUrl": "../../..",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/web/*": ["src/commerce-backend-ui-1/web-src/src/*"],
|
|
9
|
+
"@/*": ["src/*"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"include": ["**/*.tsx", "**/*.ts"],
|
|
13
|
+
"exclude": []
|
|
14
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# The [pre-app-build] hooks are auto-generated. Do not remove or manually edit.
|
|
2
|
+
hooks:
|
|
3
|
+
pre-app-build: EXTENSION=configuration/1 npx aio-commerce-lib-app hooks pre-app-build
|
|
4
|
+
|
|
5
|
+
operations:
|
|
6
|
+
# These worker processes definitions are auto-generated. Do not remove or manually edit.
|
|
7
|
+
workerProcess:
|
|
8
|
+
- type: action
|
|
9
|
+
impl: app-management/config
|
|
10
|
+
- type: action
|
|
11
|
+
impl: app-management/scope-tree
|
|
12
|
+
|
|
13
|
+
runtimeManifest:
|
|
14
|
+
packages:
|
|
15
|
+
# This package definition is auto-generated. Do not remove or manually edit.
|
|
16
|
+
app-management:
|
|
17
|
+
license: Apache-2.0
|
|
18
|
+
actions:
|
|
19
|
+
config:
|
|
20
|
+
function: .generated/actions/app-management/config.js
|
|
21
|
+
web: yes
|
|
22
|
+
runtime: nodejs:22
|
|
23
|
+
inputs:
|
|
24
|
+
LOG_LEVEL: $LOG_LEVEL
|
|
25
|
+
AIO_COMMERCE_CONFIG_ENCRYPTION_KEY: $AIO_COMMERCE_CONFIG_ENCRYPTION_KEY
|
|
26
|
+
annotations:
|
|
27
|
+
require-adobe-auth: true
|
|
28
|
+
final: true
|
|
29
|
+
scope-tree:
|
|
30
|
+
function: .generated/actions/app-management/scope-tree.js
|
|
31
|
+
web: yes
|
|
32
|
+
runtime: nodejs:22
|
|
33
|
+
inputs:
|
|
34
|
+
LOG_LEVEL: $LOG_LEVEL
|
|
35
|
+
annotations:
|
|
36
|
+
require-adobe-auth: true
|
|
37
|
+
final: true
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
module: {
|
|
5
|
+
rules: [
|
|
6
|
+
{
|
|
7
|
+
test: /\.js$/,
|
|
8
|
+
// Do not exclude node_modules if you need to process ES modules from dependencies
|
|
9
|
+
// but for now let's focus on the .generated folder
|
|
10
|
+
include: [
|
|
11
|
+
path.resolve(__dirname, '.generated'),
|
|
12
|
+
/node_modules\/@adobe\/aio-commerce-lib-app/,
|
|
13
|
+
],
|
|
14
|
+
use: {
|
|
15
|
+
loader: 'babel-loader',
|
|
16
|
+
options: {
|
|
17
|
+
configFile: path.resolve(__dirname, '../../babel.actions.config.js'),
|
|
18
|
+
sourceType: 'unambiguous',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { defineConfig } from '@adobe/aio-commerce-lib-app/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
metadata: {
|
|
5
|
+
id: '<%= name %>',
|
|
6
|
+
displayName: '<%= displayName %>',
|
|
7
|
+
description: '<%= description %>',
|
|
8
|
+
version: '0.0.1',
|
|
9
|
+
},
|
|
10
|
+
<%_ if (hasBusinessConfig) { _%>
|
|
11
|
+
businessConfig: {
|
|
12
|
+
schema: [
|
|
13
|
+
// Add merchant-facing configuration fields here. Each field
|
|
14
|
+
// renders a control in the Commerce admin under
|
|
15
|
+
// Stores → Configuration for this app's section.
|
|
16
|
+
//
|
|
17
|
+
// Examples:
|
|
18
|
+
//
|
|
19
|
+
// {
|
|
20
|
+
// type: 'text',
|
|
21
|
+
// name: 'api_key',
|
|
22
|
+
// label: 'API Key',
|
|
23
|
+
// description: 'Authentication key for the upstream service.',
|
|
24
|
+
// },
|
|
25
|
+
// {
|
|
26
|
+
// type: 'list',
|
|
27
|
+
// name: 'environment',
|
|
28
|
+
// label: 'Environment',
|
|
29
|
+
// selectionMode: 'single',
|
|
30
|
+
// options: [
|
|
31
|
+
// { label: 'Staging', value: 'staging' },
|
|
32
|
+
// { label: 'Production', value: 'production' },
|
|
33
|
+
// ],
|
|
34
|
+
// default: 'staging',
|
|
35
|
+
// },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
<%_ } _%>
|
|
39
|
+
<%_ if (hasEvents) { _%>
|
|
40
|
+
eventing: {
|
|
41
|
+
// Commerce events fire from Adobe Commerce instances. Subscribe a
|
|
42
|
+
// runtime action by name; pre-app-build wires it up.
|
|
43
|
+
commerce: [
|
|
44
|
+
{
|
|
45
|
+
provider: {
|
|
46
|
+
label: '<%= displayName %> Commerce Events',
|
|
47
|
+
description: 'Events emitted by the connected Commerce instance.',
|
|
48
|
+
},
|
|
49
|
+
events: [
|
|
50
|
+
{
|
|
51
|
+
name: 'observer.sales_order_place_after',
|
|
52
|
+
label: 'Order placed',
|
|
53
|
+
description: 'Fired after an order is successfully placed.',
|
|
54
|
+
fields: [
|
|
55
|
+
{ name: 'order.entity_id' },
|
|
56
|
+
{ name: 'order.increment_id' },
|
|
57
|
+
{ name: 'order.customer_email' },
|
|
58
|
+
],
|
|
59
|
+
runtimeActions: ['<%= runtimePackageName %>/handle-sample-event'],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
// External events come from third-party systems (ERP, CRM, etc.).
|
|
65
|
+
// Remove this block if you don't subscribe to any.
|
|
66
|
+
external: [
|
|
67
|
+
{
|
|
68
|
+
provider: {
|
|
69
|
+
label: '<%= displayName %> External Events',
|
|
70
|
+
description: 'Events emitted by an external integration.',
|
|
71
|
+
},
|
|
72
|
+
events: [
|
|
73
|
+
{
|
|
74
|
+
name: 'be-observer.sample_event',
|
|
75
|
+
label: 'Sample external event',
|
|
76
|
+
description: 'Use case description for the event.',
|
|
77
|
+
runtimeActions: ['<%= runtimePackageName %>/handle-sample-event'],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
<%_ } _%>
|
|
84
|
+
<%_ if (hasCommerceWebhooks) { _%>
|
|
85
|
+
webhooks: [
|
|
86
|
+
// Each webhook binds a Commerce extensibility hook to one of your
|
|
87
|
+
// runtime actions (declared in app.config.yaml). At install time the
|
|
88
|
+
// lib provisions the subscription on the Commerce instance.
|
|
89
|
+
//
|
|
90
|
+
// Schema reference:
|
|
91
|
+
// https://developer.adobe.com/commerce/extensibility/app-management/installation/webhooks/
|
|
92
|
+
//
|
|
93
|
+
// Worked example — point at a runtime action you've defined:
|
|
94
|
+
//
|
|
95
|
+
// {
|
|
96
|
+
// label: 'Validate order before placement',
|
|
97
|
+
// description: 'Halt order placement when a custom rule fails.',
|
|
98
|
+
// category: 'validation',
|
|
99
|
+
// runtimeAction: '<%= runtimePackageName %>/validate-order',
|
|
100
|
+
// requireAdobeAuth: true,
|
|
101
|
+
// webhook: {
|
|
102
|
+
// webhook_method: 'observer.sales_order_place_before',
|
|
103
|
+
// webhook_type: 'before',
|
|
104
|
+
// batch_name: '<%= runtimePackageName %>_validate_batch',
|
|
105
|
+
// hook_name: '<%= runtimePackageName %>_validate_hook',
|
|
106
|
+
// method: 'POST',
|
|
107
|
+
// priority: 100,
|
|
108
|
+
// required: true,
|
|
109
|
+
// timeout: 5000,
|
|
110
|
+
// fallback_error_message: '<%= displayName %> validation unavailable',
|
|
111
|
+
// fields: [
|
|
112
|
+
// { name: 'grand_total', source: 'data.order.grand_total' },
|
|
113
|
+
// ],
|
|
114
|
+
// rules: [],
|
|
115
|
+
// headers: [],
|
|
116
|
+
// },
|
|
117
|
+
// },
|
|
118
|
+
//
|
|
119
|
+
// Or send to an external URL instead of a runtime action — drop
|
|
120
|
+
// `runtimeAction`/`requireAdobeAuth` and add `url` under `webhook`.
|
|
121
|
+
],
|
|
122
|
+
<%_ } _%>
|
|
123
|
+
<%_ if (hasCustomInstallSteps) { _%>
|
|
124
|
+
installation: {
|
|
125
|
+
messages: {
|
|
126
|
+
// preInstallation: 'Shown to the merchant before installing the app.',
|
|
127
|
+
// postInstallation: 'Shown to the merchant after the app installs successfully.',
|
|
128
|
+
},
|
|
129
|
+
customInstallationSteps: [
|
|
130
|
+
{
|
|
131
|
+
name: 'sample-step',
|
|
132
|
+
description: 'Use case description for the step.',
|
|
133
|
+
script: './scripts/install/sample-step.js',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
<%_ } _%>
|
|
138
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
$schema: http://json-schema.org/draft-07/schema
|
|
2
|
+
$id: https://adobe.io/schemas/app-builder-templates/1
|
|
3
|
+
|
|
4
|
+
categories:
|
|
5
|
+
- action
|
|
6
|
+
<%_ if (hasAdminUI) { _%>
|
|
7
|
+
- ui
|
|
8
|
+
<%_ } _%>
|
|
9
|
+
|
|
10
|
+
extensions:
|
|
11
|
+
<%_ if (hasAdminUI) { _%>
|
|
12
|
+
- extensionPointId: commerce/backend-ui/1
|
|
13
|
+
<%_ } _%>
|
|
14
|
+
<%_ if (hasBusinessConfig) { _%>
|
|
15
|
+
- extensionPointId: commerce/configuration/1
|
|
16
|
+
<%_ } _%>
|
|
17
|
+
- extensionPointId: commerce/extensibility/1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# The [pre-app-build] hooks are auto-generated. Do not remove or manually edit.
|
|
2
|
+
hooks:
|
|
3
|
+
pre-app-build: EXTENSION=extensibility/1 npx aio-commerce-lib-app hooks pre-app-build
|
|
4
|
+
|
|
5
|
+
operations:
|
|
6
|
+
# These worker processes definitions are auto-generated. Do not remove or manually edit.
|
|
7
|
+
workerProcess:
|
|
8
|
+
- type: action
|
|
9
|
+
impl: app-management/app-config
|
|
10
|
+
|
|
11
|
+
runtimeManifest:
|
|
12
|
+
packages:
|
|
13
|
+
# This package definition is auto-generated. Do not remove or manually edit.
|
|
14
|
+
app-management:
|
|
15
|
+
license: Apache-2.0
|
|
16
|
+
actions:
|
|
17
|
+
app-config:
|
|
18
|
+
function: .generated/actions/app-management/app-config.js
|
|
19
|
+
web: yes
|
|
20
|
+
runtime: nodejs:22
|
|
21
|
+
inputs:
|
|
22
|
+
LOG_LEVEL: $LOG_LEVEL
|
|
23
|
+
annotations:
|
|
24
|
+
require-adobe-auth: true
|
|
25
|
+
final: true
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
module: {
|
|
5
|
+
rules: [
|
|
6
|
+
{
|
|
7
|
+
test: /\.js$/,
|
|
8
|
+
// Do not exclude node_modules if you need to process ES modules from dependencies
|
|
9
|
+
// but for now let's focus on the .generated folder
|
|
10
|
+
include: [
|
|
11
|
+
path.resolve(__dirname, '.generated'),
|
|
12
|
+
/node_modules\/@adobe\/aio-commerce-lib-app/,
|
|
13
|
+
],
|
|
14
|
+
use: {
|
|
15
|
+
loader: 'babel-loader',
|
|
16
|
+
options: {
|
|
17
|
+
configFile: path.resolve(__dirname, '../../babel.actions.config.js'),
|
|
18
|
+
sourceType: 'unambiguous',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Core } from '@adobe/aio-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stub event handler.
|
|
5
|
+
*
|
|
6
|
+
* The `eventing` section of `app.commerce.config.ts` references this action by
|
|
7
|
+
* name. When the user installs the app, `aio-commerce-lib-app` registers the
|
|
8
|
+
* subscription and routes matching events here as CloudEvent payloads —
|
|
9
|
+
* `params.type` is the event type, `params.data` is the payload.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface EventParams {
|
|
13
|
+
type?: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
LOG_LEVEL?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function main(params: EventParams) {
|
|
21
|
+
const logger = Core.Logger('handle-sample-event', { level: params.LOG_LEVEL || 'info' });
|
|
22
|
+
|
|
23
|
+
logger.info('Event received', {
|
|
24
|
+
type: params.type,
|
|
25
|
+
source: params.source,
|
|
26
|
+
id: params.id,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// TODO: dispatch on params.type and process params.data.
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
statusCode: 200,
|
|
33
|
+
body: { received: true },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom installation step.
|
|
3
|
+
*
|
|
4
|
+
* Referenced from `installation.customInstallationSteps` in
|
|
5
|
+
* `app.commerce.config.ts`. Runs once during merchant install of the app.
|
|
6
|
+
*
|
|
7
|
+
* The script receives the runtime context as its argument and should return
|
|
8
|
+
* `{ success: true }` to proceed, or throw to halt installation.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = async function sampleStep(_context) {
|
|
12
|
+
// TODO: implement the install step.
|
|
13
|
+
return { success: true };
|
|
14
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Core } from '@adobe/aio-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stub REST endpoint. Adjust the response shape and add domain logic as needed.
|
|
5
|
+
*
|
|
6
|
+
* Invoked at:
|
|
7
|
+
* https://{namespace}.adobeioruntime.net/api/v1/web/<runtime-package-name>/rest-sample
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface ActionParams {
|
|
11
|
+
__ow_method?: string;
|
|
12
|
+
__ow_query?: string;
|
|
13
|
+
__ow_body?: string;
|
|
14
|
+
__ow_headers: Record<string, string | undefined>;
|
|
15
|
+
LOG_LEVEL?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function main(params: ActionParams) {
|
|
19
|
+
const logger = Core.Logger('rest-sample', { level: params.LOG_LEVEL || 'info' });
|
|
20
|
+
|
|
21
|
+
logger.info('REST request received', {
|
|
22
|
+
method: params.__ow_method,
|
|
23
|
+
query: params.__ow_query,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
statusCode: 200,
|
|
28
|
+
body: { message: 'Hello from rest-sample' },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Core } from '@adobe/aio-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stub cron-triggered action.
|
|
5
|
+
*
|
|
6
|
+
* Bound to a `/whisk.system/alarms/alarm` trigger by the rule declared in
|
|
7
|
+
* app.config.yaml. The default cron expression is hourly — adjust it under
|
|
8
|
+
* `triggers.cron-sample-trigger.inputs.cron` to suit.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface CronParams {
|
|
12
|
+
LOG_LEVEL?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function main(params: CronParams) {
|
|
16
|
+
const logger = Core.Logger('cron-sample', { level: params.LOG_LEVEL || 'info' });
|
|
17
|
+
|
|
18
|
+
logger.info('Scheduled action fired', { timestamp: new Date().toISOString() });
|
|
19
|
+
|
|
20
|
+
// TODO: implement scheduled work.
|
|
21
|
+
|
|
22
|
+
return { ok: true };
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = appGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const enquirer_1 = require("enquirer");
|
|
6
|
+
const apply_feature_files_1 = require("./lib/apply-feature-files");
|
|
7
|
+
const compose_package_json_1 = require("./lib/compose-package-json");
|
|
8
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
9
|
+
const update_root_package_1 = require("./lib/update-root-package");
|
|
10
|
+
const update_root_tsconfig_1 = require("./lib/update-root-tsconfig");
|
|
11
|
+
async function appGenerator(tree, rawOptions) {
|
|
12
|
+
await promptForConditionalInputs(rawOptions);
|
|
13
|
+
const options = (0, normalize_options_1.normalizeOptions)(tree, rawOptions);
|
|
14
|
+
(0, apply_feature_files_1.applyFeatureFiles)(tree, options);
|
|
15
|
+
(0, compose_package_json_1.writePackageJson)(tree, options);
|
|
16
|
+
(0, update_root_package_1.updateRootPackageJson)(tree, options);
|
|
17
|
+
(0, update_root_tsconfig_1.addTsConfigReference)(tree, options);
|
|
18
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
|
+
return () => {
|
|
20
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Prompts that depend on the value of other prompts can't be expressed in
|
|
25
|
+
* Nx's schema.json, so they're driven from here. Currently only one:
|
|
26
|
+
* sidebar category is asked iff hasAdminUI=true and the user didn't pass it.
|
|
27
|
+
*/
|
|
28
|
+
async function promptForConditionalInputs(opts) {
|
|
29
|
+
if (opts.hasAdminUI && opts.sidebarCategory === undefined) {
|
|
30
|
+
const answer = await (0, enquirer_1.prompt)({
|
|
31
|
+
type: 'select',
|
|
32
|
+
name: 'sidebarCategory',
|
|
33
|
+
message: 'Which sidebar category does the menu item belong under?',
|
|
34
|
+
choices: ['catalog', 'sales', 'customers', 'content', 'none'],
|
|
35
|
+
});
|
|
36
|
+
opts.sidebarCategory = answer.sidebarCategory;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { NormalizedSchema } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Renders template files into the new app's directory based on selected flags.
|
|
5
|
+
*
|
|
6
|
+
* Each call to generateFiles overwrites earlier ones for the same file paths,
|
|
7
|
+
* so subtree order matters when subtrees overlap (none currently do).
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyFeatureFiles(tree: Tree, options: NormalizedSchema): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.applyFeatureFiles = applyFeatureFiles;
|
|
37
|
+
const devkit_1 = require("@nx/devkit");
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Renders template files into the new app's directory based on selected flags.
|
|
41
|
+
*
|
|
42
|
+
* Each call to generateFiles overwrites earlier ones for the same file paths,
|
|
43
|
+
* so subtree order matters when subtrees overlap (none currently do).
|
|
44
|
+
*/
|
|
45
|
+
function applyFeatureFiles(tree, options) {
|
|
46
|
+
const filesRoot = path.join(__dirname, '..', 'files');
|
|
47
|
+
const subs = {
|
|
48
|
+
...options,
|
|
49
|
+
nodeMajor: options.nodeVersion.split('.')[0],
|
|
50
|
+
};
|
|
51
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'base'), options.appRoot, subs);
|
|
52
|
+
const usesCommerceLib = options.hasAdminUI || options.hasBusinessConfig || options.hasCommerceWebhooks;
|
|
53
|
+
if (usesCommerceLib) {
|
|
54
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'commerce-extensibility'), options.appRoot, subs);
|
|
55
|
+
}
|
|
56
|
+
if (options.hasBusinessConfig) {
|
|
57
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'commerce-config'), options.appRoot, subs);
|
|
58
|
+
}
|
|
59
|
+
if (options.hasAdminUI) {
|
|
60
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'commerce-backend-ui'), options.appRoot, subs);
|
|
61
|
+
}
|
|
62
|
+
// Webhooks no longer have their own subtree — they're a section in
|
|
63
|
+
// app.commerce.config.ts (rendered above as part of commerce-extensibility).
|
|
64
|
+
if (options.hasRestActions) {
|
|
65
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'rest-actions'), options.appRoot, subs);
|
|
66
|
+
}
|
|
67
|
+
if (options.hasEvents) {
|
|
68
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'events'), options.appRoot, subs);
|
|
69
|
+
}
|
|
70
|
+
if (options.hasScheduledActions) {
|
|
71
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'scheduled'), options.appRoot, subs);
|
|
72
|
+
}
|
|
73
|
+
if (options.hasCustomInstallSteps) {
|
|
74
|
+
(0, devkit_1.generateFiles)(tree, path.join(filesRoot, 'install-steps'), options.appRoot, subs);
|
|
75
|
+
}
|
|
76
|
+
}
|