@salesforce/ui-bundle-template-base-angular-app 11.1.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/.forceignore +15 -0
- package/.gitignore +1 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE.txt +82 -0
- package/README.md +17 -0
- package/package.json +18 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/.forceignore +15 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/.postcssrc.json +5 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/.prettierignore +8 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/.prettierrc +12 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/CHANGELOG.md +4 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/README.md +85 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/_uibundle.uibundle-meta.xml +7 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/angular.json +94 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/e2e/app.spec.ts +15 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/esbuild/api-version.mjs +17 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/eslint.config.js +56 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/middleware/html.mjs +3 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/middleware/proxy.mjs +12 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/package.json +52 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/playwright.config.ts +25 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/public/favicon.ico +0 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/scripts/rewrite-e2e-assets.mjs +30 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/api/graphql-client.service.spec.ts +154 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/api/graphql-client.service.ts +51 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.config.ts +8 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.css +0 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.html +1 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.routes.ts +21 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.spec.ts +18 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/app.ts +10 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/layout/app-layout.component.html +50 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/layout/app-layout.component.spec.ts +63 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/layout/app-layout.component.ts +21 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/home/home.component.html +6 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/home/home.component.spec.ts +23 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/home/home.component.ts +7 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/not-found/not-found.component.html +12 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/not-found/not-found.component.spec.ts +33 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/app/pages/not-found/not-found.component.ts +9 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/index.html +13 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/main.ts +5 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/styles.css +12 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/src/types/sf-globals.d.ts +9 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/tsconfig.app.json +11 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/tsconfig.json +33 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/tsconfig.spec.json +10 -0
- package/src/force-app/main/default/uiBundles/base-angular-app/ui-bundle.json +7 -0
package/.forceignore
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
|
|
2
|
+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
package.xml
|
|
6
|
+
|
|
7
|
+
# LWC configuration files
|
|
8
|
+
**/jsconfig.json
|
|
9
|
+
**/.eslintrc.json
|
|
10
|
+
|
|
11
|
+
# LWC Jest
|
|
12
|
+
**/__tests__/**
|
|
13
|
+
|
|
14
|
+
node_modules/
|
|
15
|
+
.DS_Store
|
package/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
schema.graphql
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [11.1.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v11.0.0...v11.1.0) (2026-06-26)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **template:** add base-angular-app template for Angular UI Bundles ([#652](https://github.com/salesforce-experience-platform-emu/webapps/issues/652)) ([3b0cda5](https://github.com/salesforce-experience-platform-emu/webapps/commit/3b0cda5bd501a72754f735bcedd8fd5c3a1eec8b))
|
|
11
|
+
|
|
12
|
+
## 0.1.0 (2026-06-17)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- Initial Angular base app template with @salesforce/angular-plugin-ui-bundle integration
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2025, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Base Angular App
|
|
2
|
+
|
|
3
|
+
Base Angular app template — an Angular UI Bundle with Angular CLI, @angular-builders/custom-esbuild, TypeScript, Tailwind, and Salesforce UI Bundle plugin. Used as the foundation for feature apps when applying patches.
|
|
4
|
+
|
|
5
|
+
## In this monorepo
|
|
6
|
+
|
|
7
|
+
This package is a **base app** in the ui-bundle monorepo. It is not built to a local `dist/`; instead, the source tree under `src/force-app/main/default/uiBundles/base-angular-app/` is copied into feature app build output when you run apply-patches for a template app.
|
|
8
|
+
|
|
9
|
+
### Test
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm run test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This runs the test:build (install + build in the UI Bundle folder) step.
|
|
16
|
+
|
|
17
|
+
To work on the UI Bundle locally (install, build, dev server), run commands from the UI Bundle directory: `src/force-app/main/default/uiBundles/base-angular-app/`.
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/ui-bundle-template-base-angular-app",
|
|
3
|
+
"version": "11.1.0",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"*"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "npm run test:build && npm run test:e2e",
|
|
14
|
+
"test:build": "cd src/force-app/main/default/uiBundles/base-angular-app && npm install @salesforce/platform-sdk@file:../../../../../../../../../sdk/platform-sdk && npm install && npm run build",
|
|
15
|
+
"test:coverage": "npm run test",
|
|
16
|
+
"test:e2e": "cd src/force-app/main/default/uiBundles/base-angular-app && rm -rf node_modules && npm install @salesforce/platform-sdk@file:../../../../../../../../../sdk/platform-sdk && npm install && npx playwright install chromium && npm run build:e2e && npx playwright test"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
|
|
2
|
+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
package.xml
|
|
6
|
+
|
|
7
|
+
# LWC configuration files
|
|
8
|
+
**/jsconfig.json
|
|
9
|
+
**/.eslintrc.json
|
|
10
|
+
|
|
11
|
+
# LWC Jest
|
|
12
|
+
**/__tests__/**
|
|
13
|
+
|
|
14
|
+
node_modules/
|
|
15
|
+
.DS_Store
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Base Angular App
|
|
2
|
+
|
|
3
|
+
Base Angular App is a template application that demonstrates how to build an Angular UI Bundle on the Salesforce platform with the Angular CLI, TypeScript, Tailwind, and the Salesforce UI Bundle SDK. It provides a minimal shell (home, 404), routing with standalone components and signals, so feature apps can extend it via the patches pipeline.
|
|
4
|
+
|
|
5
|
+
This UI Bundle lives inside an SFDX project. The project root is the directory that contains `force-app/` and `sfdx-project.json`. Run the commands in the sections below from the paths indicated.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
- [Run (development)](#run-development)
|
|
10
|
+
- [Build](#build)
|
|
11
|
+
- [Deploy](#deploy)
|
|
12
|
+
- [Test](#test)
|
|
13
|
+
- [Lint](#lint)
|
|
14
|
+
|
|
15
|
+
## Run (development)
|
|
16
|
+
|
|
17
|
+
From the UI Bundle directory (`force-app/main/default/uiBundles/base-angular-app`):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
npm run dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This starts the Salesforce Angular dev server (`sf-angular-serve`).
|
|
25
|
+
|
|
26
|
+
## Build
|
|
27
|
+
|
|
28
|
+
From the UI Bundle directory:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
npm run build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The production build is written to `dist/` inside the UI Bundle folder. Use `npm run watch` to rebuild on change in development mode. Deploy using the steps in [Deploy](#deploy).
|
|
36
|
+
|
|
37
|
+
## Deploy
|
|
38
|
+
|
|
39
|
+
From the **SFDX project root** (the directory that contains `force-app/`):
|
|
40
|
+
|
|
41
|
+
1. Build the UI Bundle:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd force-app/main/default/uiBundles/base-angular-app && npm install && npm run build && cd -
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. Deploy the UI Bundle only:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
sf project deploy start --source-dir force-app/main/default/ui-bundles --target-org <alias>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or deploy all metadata:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
sf project deploy start --source-dir force-app --target-org <alias>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Replace `<alias>` with your target org alias.
|
|
60
|
+
|
|
61
|
+
## Test
|
|
62
|
+
|
|
63
|
+
From the UI Bundle directory:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install
|
|
67
|
+
npm run test
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This runs the unit test suite via `ng test`. For end-to-end tests:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm run build:e2e
|
|
74
|
+
npm run e2e
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This builds with E2E asset rewrites and runs Playwright against the static build. Ensure Chromium is installed (`npx playwright install chromium` if needed).
|
|
78
|
+
|
|
79
|
+
## Lint
|
|
80
|
+
|
|
81
|
+
From the UI Bundle directory:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm run lint
|
|
85
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"cli": {
|
|
5
|
+
"packageManager": "npm",
|
|
6
|
+
"analytics": false
|
|
7
|
+
},
|
|
8
|
+
"newProjectRoot": "projects",
|
|
9
|
+
"projects": {
|
|
10
|
+
"<%= bundlename %>": {
|
|
11
|
+
"projectType": "application",
|
|
12
|
+
"schematics": {},
|
|
13
|
+
"root": "",
|
|
14
|
+
"sourceRoot": "src",
|
|
15
|
+
"prefix": "app",
|
|
16
|
+
"architect": {
|
|
17
|
+
"build": {
|
|
18
|
+
"builder": "@angular-builders/custom-esbuild:application",
|
|
19
|
+
"options": {
|
|
20
|
+
"outputPath": {
|
|
21
|
+
"base": "dist",
|
|
22
|
+
"browser": ""
|
|
23
|
+
},
|
|
24
|
+
"deployUrl": "./",
|
|
25
|
+
"browser": "src/main.ts",
|
|
26
|
+
"tsConfig": "tsconfig.app.json",
|
|
27
|
+
"assets": [
|
|
28
|
+
{
|
|
29
|
+
"glob": "**/*",
|
|
30
|
+
"input": "public"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"styles": ["src/styles.css"],
|
|
34
|
+
"plugins": ["./esbuild/api-version.mjs"]
|
|
35
|
+
},
|
|
36
|
+
"configurations": {
|
|
37
|
+
"production": {
|
|
38
|
+
"budgets": [
|
|
39
|
+
{
|
|
40
|
+
"type": "initial",
|
|
41
|
+
"maximumWarning": "500kB",
|
|
42
|
+
"maximumError": "1MB"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"type": "anyComponentStyle",
|
|
46
|
+
"maximumWarning": "4kB",
|
|
47
|
+
"maximumError": "8kB"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"outputHashing": "all",
|
|
51
|
+
"optimization": {
|
|
52
|
+
"scripts": true,
|
|
53
|
+
"styles": {
|
|
54
|
+
"minify": true,
|
|
55
|
+
"inlineCritical": false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"development": {
|
|
60
|
+
"optimization": false,
|
|
61
|
+
"extractLicenses": false,
|
|
62
|
+
"sourceMap": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"defaultConfiguration": "production"
|
|
66
|
+
},
|
|
67
|
+
"serve": {
|
|
68
|
+
"builder": "@angular-builders/custom-esbuild:dev-server",
|
|
69
|
+
"options": {
|
|
70
|
+
"middlewares": ["./middleware/html.mjs", "./middleware/proxy.mjs"]
|
|
71
|
+
},
|
|
72
|
+
"configurations": {
|
|
73
|
+
"production": {
|
|
74
|
+
"buildTarget": "<%= bundlename %>:build:production"
|
|
75
|
+
},
|
|
76
|
+
"development": {
|
|
77
|
+
"buildTarget": "<%= bundlename %>:build:development"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"defaultConfiguration": "development"
|
|
81
|
+
},
|
|
82
|
+
"test": {
|
|
83
|
+
"builder": "@angular/build:unit-test"
|
|
84
|
+
},
|
|
85
|
+
"lint": {
|
|
86
|
+
"builder": "@angular-eslint/builder:lint",
|
|
87
|
+
"options": {
|
|
88
|
+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
test.describe('base-angular-app', () => {
|
|
4
|
+
test('home page loads and shows welcome content', async ({ page }) => {
|
|
5
|
+
await page.goto('/');
|
|
6
|
+
await expect(page.getByRole('heading', { name: 'Home' })).toBeVisible();
|
|
7
|
+
await expect(page.getByText('Welcome to your Angular application.')).toBeVisible();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('not found route shows 404', async ({ page }) => {
|
|
11
|
+
await page.goto('/non-existent-route');
|
|
12
|
+
await expect(page.getByRole('heading', { name: '404' })).toBeVisible();
|
|
13
|
+
await expect(page.getByText('Page not found')).toBeVisible();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time substitution of `__SF_API_VERSION__` (production + main app code in dev).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the connected org's API version (from `sf` CLI session) once at
|
|
5
|
+
* builder startup and injects it via esbuild's `define`. Falls back to "65.0"
|
|
6
|
+
* if no session is available — matches @salesforce/platform-sdk's default.
|
|
7
|
+
*
|
|
8
|
+
* In `ng serve`, this plugin runs on the application esbuild pass but does NOT
|
|
9
|
+
* reach Vite's optimizeDeps prebundle of node_modules. `scripts/dev.mjs` covers
|
|
10
|
+
* that gap by passing the same value via `ng serve --define`.
|
|
11
|
+
*
|
|
12
|
+
* Referenced from angular.json: architect.build.options.plugins[].
|
|
13
|
+
*/
|
|
14
|
+
import { createApiVersionPlugin } from '@salesforce/angular-plugin-ui-bundle';
|
|
15
|
+
|
|
16
|
+
const { plugin } = await createApiVersionPlugin();
|
|
17
|
+
export default plugin;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import angular from 'angular-eslint';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(
|
|
6
|
+
// Global ignores
|
|
7
|
+
{
|
|
8
|
+
ignores: ['dist/**/*', '.angular/**/*', 'coverage/**/*', 'node_modules/**/*'],
|
|
9
|
+
},
|
|
10
|
+
// TypeScript files
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.ts'],
|
|
13
|
+
extends: [
|
|
14
|
+
js.configs.recommended,
|
|
15
|
+
...tseslint.configs.recommended,
|
|
16
|
+
...angular.configs.tsRecommended,
|
|
17
|
+
],
|
|
18
|
+
processor: angular.processInlineTemplates,
|
|
19
|
+
rules: {
|
|
20
|
+
'@angular-eslint/directive-selector': [
|
|
21
|
+
'error',
|
|
22
|
+
{
|
|
23
|
+
type: 'attribute',
|
|
24
|
+
prefix: 'app',
|
|
25
|
+
style: 'camelCase',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
'@angular-eslint/component-selector': [
|
|
29
|
+
'error',
|
|
30
|
+
{
|
|
31
|
+
type: 'element',
|
|
32
|
+
prefix: 'app',
|
|
33
|
+
style: 'kebab-case',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'@typescript-eslint/no-unused-vars': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
argsIgnorePattern: '^_',
|
|
40
|
+
varsIgnorePattern: '^_',
|
|
41
|
+
caughtErrorsIgnorePattern: '^_',
|
|
42
|
+
ignoreRestSiblings: true,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
46
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
47
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
// Template files
|
|
51
|
+
{
|
|
52
|
+
files: ['**/*.html'],
|
|
53
|
+
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
|
|
54
|
+
rules: {},
|
|
55
|
+
},
|
|
56
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy middleware for Angular CLI dev server.
|
|
3
|
+
*
|
|
4
|
+
* Forwards `/services/*` and other manifest-routed paths to the connected
|
|
5
|
+
* Salesforce org with authentication. Watches `ui-bundle.json` for changes
|
|
6
|
+
* and recreates the proxy handler automatically (manual browser refresh needed).
|
|
7
|
+
*
|
|
8
|
+
* Referenced from angular.json: architect.serve.options.middlewares[].
|
|
9
|
+
*/
|
|
10
|
+
import { createProxyMiddleware } from '@salesforce/angular-plugin-ui-bundle';
|
|
11
|
+
|
|
12
|
+
export default await createProxyMiddleware();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "base-angular-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "sf-angular-serve",
|
|
11
|
+
"build": "ng build",
|
|
12
|
+
"watch": "ng build --watch --configuration development",
|
|
13
|
+
"test": "ng test",
|
|
14
|
+
"lint": "ng lint",
|
|
15
|
+
"build:e2e": "ng build && node scripts/rewrite-e2e-assets.mjs",
|
|
16
|
+
"e2e": "playwright test"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@angular/common": "^21.2.0",
|
|
20
|
+
"@angular/compiler": "^21.2.0",
|
|
21
|
+
"@angular/core": "^21.2.0",
|
|
22
|
+
"@angular/forms": "^21.2.0",
|
|
23
|
+
"@angular/platform-browser": "^21.2.0",
|
|
24
|
+
"@angular/router": "^21.2.0",
|
|
25
|
+
"@salesforce/angular-plugin-ui-bundle": "^10.24.0",
|
|
26
|
+
"@salesforce/platform-sdk": "^10.24.0",
|
|
27
|
+
"rxjs": "~7.8.0",
|
|
28
|
+
"tslib": "^2.3.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@angular-builders/custom-esbuild": "^21.0.0",
|
|
32
|
+
"@angular-eslint/builder": "^21.0.0",
|
|
33
|
+
"@angular/build": "^21.2.11",
|
|
34
|
+
"@angular/cli": "^21.2.11",
|
|
35
|
+
"@angular/compiler-cli": "^21.2.0",
|
|
36
|
+
"@eslint/js": "^9.0.0",
|
|
37
|
+
"@playwright/test": "^1.49.0",
|
|
38
|
+
"@tailwindcss/postcss": "^4.0.0",
|
|
39
|
+
"angular-eslint": "^21.0.0",
|
|
40
|
+
"eslint": "^9.0.0",
|
|
41
|
+
"jsdom": "^28.0.0",
|
|
42
|
+
"postcss": "^8.5.0",
|
|
43
|
+
"serve": "^14.2.5",
|
|
44
|
+
"tailwindcss": "^4.0.0",
|
|
45
|
+
"typescript": "~5.9.2",
|
|
46
|
+
"typescript-eslint": "^8.0.0",
|
|
47
|
+
"vitest": "^4.1.0"
|
|
48
|
+
},
|
|
49
|
+
"overrides": {
|
|
50
|
+
"undici": "^7.28.0"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
const E2E_PORT = 5176;
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
testDir: './e2e',
|
|
7
|
+
fullyParallel: true,
|
|
8
|
+
forbidOnly: !!process.env.CI,
|
|
9
|
+
retries: process.env.CI ? 2 : 0,
|
|
10
|
+
workers: process.env.CI ? 1 : undefined,
|
|
11
|
+
reporter: 'html',
|
|
12
|
+
use: {
|
|
13
|
+
baseURL: `http://localhost:${E2E_PORT}`,
|
|
14
|
+
trace: 'on-first-retry',
|
|
15
|
+
},
|
|
16
|
+
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
|
17
|
+
webServer: {
|
|
18
|
+
// Serve built dist/ with a static server so e2e works in CI without an SF org
|
|
19
|
+
// (ng serve runs the SF plugin/proxy middleware and can fail without an org).
|
|
20
|
+
command: `npx serve dist -l ${E2E_PORT}`,
|
|
21
|
+
url: `http://localhost:${E2E_PORT}`,
|
|
22
|
+
reuseExistingServer: !process.env.CI,
|
|
23
|
+
timeout: process.env.CI ? 120_000 : 60_000,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepares dist/ for e2e: root-relative asset paths + SPA fallback for serve.
|
|
3
|
+
*
|
|
4
|
+
* angular.json sets deployUrl: "./", so the built index.html references
|
|
5
|
+
* scripts/styles with a relative "./" prefix (e.g. ./main-HASH.js). When the
|
|
6
|
+
* SPA fallback serves index.html for a deep route like /non-existent-route,
|
|
7
|
+
* those "./" paths resolve against the wrong base and 404, so the app never
|
|
8
|
+
* boots. Rewrite them to root-relative "/" paths.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join, dirname } from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
// angular.json outputPath: { base: "dist", browser: "" } -> files land in dist/
|
|
16
|
+
const distDir = join(__dirname, '..', 'dist');
|
|
17
|
+
|
|
18
|
+
// Rewrite index.html so asset paths are root-relative (./main-x.js -> /main-x.js)
|
|
19
|
+
const indexPath = join(distDir, 'index.html');
|
|
20
|
+
let html = readFileSync(indexPath, 'utf8');
|
|
21
|
+
html = html.replace(/(src|href)="\.\//g, '$1="/');
|
|
22
|
+
writeFileSync(indexPath, html);
|
|
23
|
+
|
|
24
|
+
// SPA fallback so /non-existent-route etc. serve index.html
|
|
25
|
+
writeFileSync(
|
|
26
|
+
join(distDir, 'serve.json'),
|
|
27
|
+
JSON.stringify({
|
|
28
|
+
rewrites: [{ source: '**', destination: '/index.html' }],
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { GraphqlClient } from './graphql-client.service';
|
|
3
|
+
import { createDataSDK } from '@salesforce/platform-sdk';
|
|
4
|
+
|
|
5
|
+
vi.mock('@salesforce/platform-sdk', () => ({
|
|
6
|
+
createDataSDK: vi.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe('GraphqlClient', () => {
|
|
10
|
+
let service: GraphqlClient;
|
|
11
|
+
let mockGraphqlQuery: ReturnType<typeof vi.fn>;
|
|
12
|
+
let mockGraphqlMutate: ReturnType<typeof vi.fn>;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
mockGraphqlQuery = vi.fn();
|
|
16
|
+
mockGraphqlMutate = vi.fn();
|
|
17
|
+
|
|
18
|
+
vi.mocked(createDataSDK).mockResolvedValue({
|
|
19
|
+
graphql: {
|
|
20
|
+
query: mockGraphqlQuery,
|
|
21
|
+
mutate: mockGraphqlMutate,
|
|
22
|
+
},
|
|
23
|
+
} as any);
|
|
24
|
+
|
|
25
|
+
await TestBed.configureTestingModule({
|
|
26
|
+
providers: [GraphqlClient],
|
|
27
|
+
}).compileComponents();
|
|
28
|
+
|
|
29
|
+
service = TestBed.inject(GraphqlClient);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
vi.clearAllMocks();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should create the service', () => {
|
|
37
|
+
expect(service).toBeTruthy();
|
|
38
|
+
expect(service).toBeInstanceOf(GraphqlClient);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should route plain query operations to graphql.query and return result.data', async () => {
|
|
42
|
+
const operation = 'query { user { id name } }';
|
|
43
|
+
const expectedData = { user: { id: '123', name: 'Test User' } };
|
|
44
|
+
mockGraphqlQuery.mockResolvedValue({ data: expectedData });
|
|
45
|
+
|
|
46
|
+
const result = await service.execute(operation);
|
|
47
|
+
|
|
48
|
+
expect(mockGraphqlQuery).toHaveBeenCalledWith({ query: operation, variables: undefined });
|
|
49
|
+
expect(mockGraphqlMutate).not.toHaveBeenCalled();
|
|
50
|
+
expect(result).toEqual(expectedData);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should route anonymous query operations to graphql.query', async () => {
|
|
54
|
+
const operation = '{ user { id name } }';
|
|
55
|
+
const expectedData = { user: { id: '456', name: 'Anonymous User' } };
|
|
56
|
+
mockGraphqlQuery.mockResolvedValue({ data: expectedData });
|
|
57
|
+
|
|
58
|
+
const result = await service.execute(operation);
|
|
59
|
+
|
|
60
|
+
expect(mockGraphqlQuery).toHaveBeenCalledWith({ query: operation, variables: undefined });
|
|
61
|
+
expect(mockGraphqlMutate).not.toHaveBeenCalled();
|
|
62
|
+
expect(result).toEqual(expectedData);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should route mutation operations to graphql.mutate', async () => {
|
|
66
|
+
const operation = 'mutation { updateUser(id: "123", name: "New Name") { id name } }';
|
|
67
|
+
const expectedData = { updateUser: { id: '123', name: 'New Name' } };
|
|
68
|
+
mockGraphqlMutate.mockResolvedValue({ data: expectedData });
|
|
69
|
+
|
|
70
|
+
const result = await service.execute(operation);
|
|
71
|
+
|
|
72
|
+
expect(mockGraphqlMutate).toHaveBeenCalledWith({ mutation: operation, variables: undefined });
|
|
73
|
+
expect(mockGraphqlQuery).not.toHaveBeenCalled();
|
|
74
|
+
expect(result).toEqual(expectedData);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should detect mutation with leading GraphQL comment and route to graphql.mutate', async () => {
|
|
78
|
+
const operation = '# This is a comment\nmutation { deleteUser(id: "123") { success } }';
|
|
79
|
+
const expectedData = { deleteUser: { success: true } };
|
|
80
|
+
mockGraphqlMutate.mockResolvedValue({ data: expectedData });
|
|
81
|
+
|
|
82
|
+
const result = await service.execute(operation);
|
|
83
|
+
|
|
84
|
+
expect(mockGraphqlMutate).toHaveBeenCalledWith({ mutation: operation, variables: undefined });
|
|
85
|
+
expect(mockGraphqlQuery).not.toHaveBeenCalled();
|
|
86
|
+
expect(result).toEqual(expectedData);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should not treat query as mutation when comment contains "mutation" word', async () => {
|
|
90
|
+
const operation = '# this is not a mutation, just a query\nquery { user { id } }';
|
|
91
|
+
const expectedData = { user: { id: '789' } };
|
|
92
|
+
mockGraphqlQuery.mockResolvedValue({ data: expectedData });
|
|
93
|
+
|
|
94
|
+
const result = await service.execute(operation);
|
|
95
|
+
|
|
96
|
+
expect(mockGraphqlQuery).toHaveBeenCalledWith({ query: operation, variables: undefined });
|
|
97
|
+
expect(mockGraphqlMutate).not.toHaveBeenCalled();
|
|
98
|
+
expect(result).toEqual(expectedData);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should throw error when result.errors contains errors', async () => {
|
|
102
|
+
const operation = 'query { user { id } }';
|
|
103
|
+
mockGraphqlQuery.mockResolvedValue({
|
|
104
|
+
data: null,
|
|
105
|
+
errors: [{ message: 'Field not found' }, { message: 'Permission denied' }],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
await expect(service.execute(operation)).rejects.toThrow(
|
|
109
|
+
'GraphQL Error: Field not found; Permission denied',
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should throw error when result.errors contains a single error', async () => {
|
|
114
|
+
const operation = 'query { user { id } }';
|
|
115
|
+
mockGraphqlQuery.mockResolvedValue({
|
|
116
|
+
data: null,
|
|
117
|
+
errors: [{ message: 'Unauthorized' }],
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await expect(service.execute(operation)).rejects.toThrow('GraphQL Error: Unauthorized');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should throw error when result.data is null with no errors', async () => {
|
|
124
|
+
const operation = 'query { user { id } }';
|
|
125
|
+
mockGraphqlQuery.mockResolvedValue({ data: null });
|
|
126
|
+
|
|
127
|
+
await expect(service.execute(operation)).rejects.toThrow('GraphQL response data is null');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should pass variables through to graphql.query', async () => {
|
|
131
|
+
const operation = 'query GetUser($id: ID!) { user(id: $id) { id name } }';
|
|
132
|
+
const variables = { id: '999' };
|
|
133
|
+
const expectedData = { user: { id: '999', name: 'Variable User' } };
|
|
134
|
+
mockGraphqlQuery.mockResolvedValue({ data: expectedData });
|
|
135
|
+
|
|
136
|
+
const result = await service.execute(operation, variables);
|
|
137
|
+
|
|
138
|
+
expect(mockGraphqlQuery).toHaveBeenCalledWith({ query: operation, variables });
|
|
139
|
+
expect(result).toEqual(expectedData);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should pass variables through to graphql.mutate', async () => {
|
|
143
|
+
const operation =
|
|
144
|
+
'mutation UpdateUser($id: ID!, $name: String!) { updateUser(id: $id, name: $name) { id name } }';
|
|
145
|
+
const variables = { id: '888', name: 'Updated Name' };
|
|
146
|
+
const expectedData = { updateUser: { id: '888', name: 'Updated Name' } };
|
|
147
|
+
mockGraphqlMutate.mockResolvedValue({ data: expectedData });
|
|
148
|
+
|
|
149
|
+
const result = await service.execute(operation, variables);
|
|
150
|
+
|
|
151
|
+
expect(mockGraphqlMutate).toHaveBeenCalledWith({ mutation: operation, variables });
|
|
152
|
+
expect(result).toEqual(expectedData);
|
|
153
|
+
});
|
|
154
|
+
});
|
package/src/force-app/main/default/uiBundles/base-angular-app/src/app/api/graphql-client.service.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { createDataSDK } from '@salesforce/platform-sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* True when the operation's first definition is a `mutation`. Strips GraphQL
|
|
6
|
+
* comments first so a leading `# ...` line can't mask the keyword. Queries
|
|
7
|
+
* (named or anonymous `{ ... }` shorthand) and subscriptions fall through to
|
|
8
|
+
* query().
|
|
9
|
+
*/
|
|
10
|
+
function isMutation(operation: string): boolean {
|
|
11
|
+
return /^\s*mutation\b/.test(operation.replace(/#[^\n\r]*/g, ''));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Thin GraphQL client: createDataSDK + sdk.graphql with centralized error
|
|
16
|
+
* handling. Mutations are routed to sdk.graphql.mutate and everything else to
|
|
17
|
+
* sdk.graphql.query (the SDK rejects an operation sent to the wrong method).
|
|
18
|
+
* Use with gql-tagged queries and generated operation types for type-safe calls.
|
|
19
|
+
*
|
|
20
|
+
* Injectable mirror of the React template's src/api/graphqlClient.ts so both
|
|
21
|
+
* frameworks share the same platform-sdk data-fetch contract.
|
|
22
|
+
*/
|
|
23
|
+
@Injectable({ providedIn: 'root' })
|
|
24
|
+
export class GraphqlClient {
|
|
25
|
+
async execute<TData, TVariables = Record<string, unknown>>(
|
|
26
|
+
operation: string,
|
|
27
|
+
variables?: TVariables,
|
|
28
|
+
): Promise<TData> {
|
|
29
|
+
const data = await createDataSDK();
|
|
30
|
+
const result = isMutation(operation)
|
|
31
|
+
? await data.graphql!.mutate<TData, TVariables>({
|
|
32
|
+
mutation: operation,
|
|
33
|
+
variables,
|
|
34
|
+
})
|
|
35
|
+
: await data.graphql!.query<TData, TVariables>({
|
|
36
|
+
query: operation,
|
|
37
|
+
variables,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (result.errors?.length) {
|
|
41
|
+
const msg = result.errors.map((e) => e.message).join('; ');
|
|
42
|
+
throw new Error(`GraphQL Error: ${msg}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (result.data == null) {
|
|
46
|
+
throw new Error('GraphQL response data is null');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result.data;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
|
|
2
|
+
import { provideRouter } from '@angular/router';
|
|
3
|
+
|
|
4
|
+
import { routes } from './app.routes';
|
|
5
|
+
|
|
6
|
+
export const appConfig: ApplicationConfig = {
|
|
7
|
+
providers: [provideBrowserGlobalErrorListeners(), provideRouter(routes)],
|
|
8
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<router-outlet />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Routes } from '@angular/router';
|
|
2
|
+
import { AppLayoutComponent } from './layout/app-layout.component';
|
|
3
|
+
import { HomeComponent } from './pages/home/home.component';
|
|
4
|
+
import { NotFoundComponent } from './pages/not-found/not-found.component';
|
|
5
|
+
|
|
6
|
+
export const routes: Routes = [
|
|
7
|
+
{
|
|
8
|
+
path: '',
|
|
9
|
+
component: AppLayoutComponent,
|
|
10
|
+
children: [
|
|
11
|
+
{
|
|
12
|
+
path: '',
|
|
13
|
+
component: HomeComponent,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
path: '**',
|
|
17
|
+
component: NotFoundComponent,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { provideRouter } from '@angular/router';
|
|
3
|
+
import { App } from './app';
|
|
4
|
+
|
|
5
|
+
describe('App', () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await TestBed.configureTestingModule({
|
|
8
|
+
imports: [App],
|
|
9
|
+
providers: [provideRouter([])],
|
|
10
|
+
}).compileComponents();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should create the app', () => {
|
|
14
|
+
const fixture = TestBed.createComponent(App);
|
|
15
|
+
const app = fixture.componentInstance;
|
|
16
|
+
expect(app).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<nav class="bg-white border-b border-gray-200">
|
|
2
|
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
3
|
+
<div class="flex justify-between items-center h-16">
|
|
4
|
+
<a routerLink="/" class="text-xl font-semibold text-gray-900"> Angular App </a>
|
|
5
|
+
<button
|
|
6
|
+
(click)="toggleMenu()"
|
|
7
|
+
class="p-2 rounded-md text-gray-700 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
8
|
+
aria-label="Toggle menu"
|
|
9
|
+
[attr.aria-expanded]="isOpen()"
|
|
10
|
+
>
|
|
11
|
+
<div class="w-6 h-6 flex flex-col justify-center space-y-1.5">
|
|
12
|
+
<span
|
|
13
|
+
class="block h-0.5 w-6 bg-current transition-all"
|
|
14
|
+
[class.rotate-45]="isOpen()"
|
|
15
|
+
[class.translate-y-2]="isOpen()"
|
|
16
|
+
></span>
|
|
17
|
+
<span
|
|
18
|
+
class="block h-0.5 w-6 bg-current transition-all"
|
|
19
|
+
[class.opacity-0]="isOpen()"
|
|
20
|
+
></span>
|
|
21
|
+
<span
|
|
22
|
+
class="block h-0.5 w-6 bg-current transition-all"
|
|
23
|
+
[class.-rotate-45]="isOpen()"
|
|
24
|
+
[class.-translate-y-2]="isOpen()"
|
|
25
|
+
></span>
|
|
26
|
+
</div>
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
@if (isOpen()) {
|
|
30
|
+
<div class="pb-4">
|
|
31
|
+
<ul class="flex flex-col space-y-2 list-none">
|
|
32
|
+
@for (item of navigationItems; track item.path) {
|
|
33
|
+
<li>
|
|
34
|
+
<a
|
|
35
|
+
[routerLink]="item.path"
|
|
36
|
+
routerLinkActive="bg-blue-100 text-blue-700"
|
|
37
|
+
[routerLinkActiveOptions]="{ exact: true }"
|
|
38
|
+
(click)="closeMenu()"
|
|
39
|
+
class="block px-3 py-2 rounded-md text-sm font-medium transition-colors text-gray-700 hover:bg-gray-100"
|
|
40
|
+
>
|
|
41
|
+
{{ item.label }}
|
|
42
|
+
</a>
|
|
43
|
+
</li>
|
|
44
|
+
}
|
|
45
|
+
</ul>
|
|
46
|
+
</div>
|
|
47
|
+
}
|
|
48
|
+
</div>
|
|
49
|
+
</nav>
|
|
50
|
+
<router-outlet />
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { provideRouter } from '@angular/router';
|
|
3
|
+
import { AppLayoutComponent } from './app-layout.component';
|
|
4
|
+
|
|
5
|
+
describe('AppLayoutComponent', () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await TestBed.configureTestingModule({
|
|
8
|
+
imports: [AppLayoutComponent],
|
|
9
|
+
providers: [provideRouter([])],
|
|
10
|
+
}).compileComponents();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should create the component', () => {
|
|
14
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
15
|
+
const component = fixture.componentInstance;
|
|
16
|
+
expect(component).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should toggle menu', () => {
|
|
20
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
21
|
+
const component = fixture.componentInstance;
|
|
22
|
+
expect(component.isOpen()).toBe(false);
|
|
23
|
+
component.toggleMenu();
|
|
24
|
+
expect(component.isOpen()).toBe(true);
|
|
25
|
+
component.toggleMenu();
|
|
26
|
+
expect(component.isOpen()).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should close menu', () => {
|
|
30
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
31
|
+
const component = fixture.componentInstance;
|
|
32
|
+
component.toggleMenu();
|
|
33
|
+
expect(component.isOpen()).toBe(true);
|
|
34
|
+
component.closeMenu();
|
|
35
|
+
expect(component.isOpen()).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should have navigation items', () => {
|
|
39
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
40
|
+
const component = fixture.componentInstance;
|
|
41
|
+
expect(component.navigationItems.length).toBeGreaterThan(0);
|
|
42
|
+
expect(component.navigationItems[0].path).toBe('/');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should render nav element', async () => {
|
|
46
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
47
|
+
await fixture.whenStable();
|
|
48
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
49
|
+
expect(compiled.querySelector('nav')).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should set aria-expanded on toggle button', async () => {
|
|
53
|
+
const fixture = TestBed.createComponent(AppLayoutComponent);
|
|
54
|
+
await fixture.whenStable();
|
|
55
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
56
|
+
const button = compiled.querySelector('button');
|
|
57
|
+
expect(button?.getAttribute('aria-expanded')).toBe('false');
|
|
58
|
+
|
|
59
|
+
fixture.componentInstance.toggleMenu();
|
|
60
|
+
fixture.detectChanges();
|
|
61
|
+
expect(button?.getAttribute('aria-expanded')).toBe('true');
|
|
62
|
+
});
|
|
63
|
+
});
|
package/src/force-app/main/default/uiBundles/base-angular-app/src/app/layout/app-layout.component.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Component, signal } from '@angular/core';
|
|
2
|
+
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'app-layout',
|
|
6
|
+
imports: [RouterLink, RouterLinkActive, RouterOutlet],
|
|
7
|
+
templateUrl: './app-layout.component.html',
|
|
8
|
+
})
|
|
9
|
+
export class AppLayoutComponent {
|
|
10
|
+
isOpen = signal(false);
|
|
11
|
+
|
|
12
|
+
navigationItems = [{ path: '/', label: 'Home' }];
|
|
13
|
+
|
|
14
|
+
toggleMenu(): void {
|
|
15
|
+
this.isOpen.update((v) => !v);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
closeMenu(): void {
|
|
19
|
+
this.isOpen.set(false);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { HomeComponent } from './home.component';
|
|
3
|
+
|
|
4
|
+
describe('HomeComponent', () => {
|
|
5
|
+
beforeEach(async () => {
|
|
6
|
+
await TestBed.configureTestingModule({
|
|
7
|
+
imports: [HomeComponent],
|
|
8
|
+
}).compileComponents();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should create the component', () => {
|
|
12
|
+
const fixture = TestBed.createComponent(HomeComponent);
|
|
13
|
+
const component = fixture.componentInstance;
|
|
14
|
+
expect(component).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should render main landmark', async () => {
|
|
18
|
+
const fixture = TestBed.createComponent(HomeComponent);
|
|
19
|
+
await fixture.whenStable();
|
|
20
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
21
|
+
expect(compiled.querySelector('main')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
|
2
|
+
<div class="text-center">
|
|
3
|
+
<h1 class="text-4xl font-bold text-gray-900 mb-4">404</h1>
|
|
4
|
+
<p class="text-lg text-gray-600 mb-8">Page not found</p>
|
|
5
|
+
<a
|
|
6
|
+
routerLink="/"
|
|
7
|
+
class="inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
|
8
|
+
>
|
|
9
|
+
Go to Home
|
|
10
|
+
</a>
|
|
11
|
+
</div>
|
|
12
|
+
</main>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { provideRouter } from '@angular/router';
|
|
3
|
+
import { NotFoundComponent } from './not-found.component';
|
|
4
|
+
|
|
5
|
+
describe('NotFoundComponent', () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await TestBed.configureTestingModule({
|
|
8
|
+
imports: [NotFoundComponent],
|
|
9
|
+
providers: [provideRouter([])],
|
|
10
|
+
}).compileComponents();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should create the component', () => {
|
|
14
|
+
const fixture = TestBed.createComponent(NotFoundComponent);
|
|
15
|
+
const component = fixture.componentInstance;
|
|
16
|
+
expect(component).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should render main landmark', async () => {
|
|
20
|
+
const fixture = TestBed.createComponent(NotFoundComponent);
|
|
21
|
+
await fixture.whenStable();
|
|
22
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
23
|
+
expect(compiled.querySelector('main')).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should have a link to home', async () => {
|
|
27
|
+
const fixture = TestBed.createComponent(NotFoundComponent);
|
|
28
|
+
await fixture.whenStable();
|
|
29
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
|
30
|
+
const link = compiled.querySelector('a');
|
|
31
|
+
expect(link?.getAttribute('href')).toBe('/');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>MyAngularApp</title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<app-root></app-root>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time constants injected via esbuild `define`. Substituted by
|
|
3
|
+
* @salesforce/angular-plugin-ui-bundle during build (see esbuild/api-version.mjs
|
|
4
|
+
* and angular.json plugins[]).
|
|
5
|
+
*
|
|
6
|
+
* Without substitution, `@salesforce/platform-sdk` and `@salesforce/ui-bundle`
|
|
7
|
+
* fall back to "65.0" — the published packages contain the literal token.
|
|
8
|
+
*/
|
|
9
|
+
declare const __SF_API_VERSION__: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "./out-tsc/app",
|
|
7
|
+
"types": []
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.ts"],
|
|
10
|
+
"exclude": ["src/**/*.spec.ts"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"compileOnSave": false,
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"importHelpers": true,
|
|
15
|
+
"target": "ES2022",
|
|
16
|
+
"module": "preserve"
|
|
17
|
+
},
|
|
18
|
+
"angularCompilerOptions": {
|
|
19
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
20
|
+
"strictInjectionParameters": true,
|
|
21
|
+
"strictInputAccessModifiers": true,
|
|
22
|
+
"strictTemplates": true
|
|
23
|
+
},
|
|
24
|
+
"files": [],
|
|
25
|
+
"references": [
|
|
26
|
+
{
|
|
27
|
+
"path": "./tsconfig.app.json"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "./tsconfig.spec.json"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "./out-tsc/spec",
|
|
7
|
+
"types": ["vitest/globals"]
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.d.ts", "src/**/*.spec.ts"]
|
|
10
|
+
}
|