@microsoft/app-manifest 1.0.0-alpha.3db80d0af.0 → 1.0.0-beta.2025041708.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 +115 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
## 📦 Package Name
|
|
2
|
+
|
|
3
|
+
`@microsoft/app-manifest`
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🚀 Summary
|
|
8
|
+
|
|
9
|
+
A collection of TypeScript definitions and converters for Microsoft 365 App manifests, including:
|
|
10
|
+
|
|
11
|
+
- **Strongly‑typed interfaces** for three manifest types with all versions:
|
|
12
|
+
- Teams Manifest: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.19, 1.20, devPreview
|
|
13
|
+
- Declarative Agent Manifest: v1.0, v1.2, v1.3
|
|
14
|
+
- API Plugin Manifest: v2.1, v2.2
|
|
15
|
+
- **Conversion utilities** between JSON strings and typed manifest objects.
|
|
16
|
+
- **Utility tools** for:
|
|
17
|
+
- Validating manifests against manifest schemas
|
|
18
|
+
- Reading/writing manifest files from disk with type checking
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## ✨ Features
|
|
23
|
+
|
|
24
|
+
- **Type‑safe definitions** of all versions generated from Microsoft’s official [JSON schemas](https://developer.microsoft.com/json-schemas/), guaranteeing compile‑time type correctness.
|
|
25
|
+
|
|
26
|
+
- **Bi‑directional conversion functions** (`jsonToManifest` and `manifestToJson`) for all types and all versions of manifest with runtime type validation.
|
|
27
|
+
|
|
28
|
+
- **Schema validation utilities** to generate validation errors.
|
|
29
|
+
|
|
30
|
+
- **File I/O helpers** to conveniently load and dump manifest files in JSON format.
|
|
31
|
+
|
|
32
|
+
- **Modular versioning**: manifests organized per version file, avoiding type collisions.
|
|
33
|
+
|
|
34
|
+
## 📥 Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @microsoft/app-manifest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 📖 Usage
|
|
41
|
+
|
|
42
|
+
### Manipulate manifest
|
|
43
|
+
|
|
44
|
+
**Automatic version inference**
|
|
45
|
+
|
|
46
|
+
You can assign a manifest object directly to the discriminated union types (`TeamsManifest`, `DeclarativeAgentManifest` or `APIPluginManifest`) without specifying a concrete version type. TypeScript will infer the specific version based on the `manifestVersion` field:
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
**Manually specified version**
|
|
51
|
+
|
|
52
|
+
You can specify a concrete version type:
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
### Manifest to/from JSON converters
|
|
57
|
+
|
|
58
|
+
Convert JSON string to manifest type and check the version at run time:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const json = "{ \"manifestVersion\": \"1.20\", \"id\": \"app-id\", ...}";
|
|
62
|
+
const manifest = TeamsManifestConverter.jsonToManifest(json);
|
|
63
|
+
if (manifest.manifestVersion === "1.20") {
|
|
64
|
+
// TypeScript will infer the type as TeamsManifestV1D20
|
|
65
|
+
const manifestV1D20 = manifest as TeamsManifestV1D20;
|
|
66
|
+
// You can now access properties specific to TeamsManifestV1D20
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Convert JSON string to manifest type by specifying the version at compile time:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const json = "{ \"manifestVersion\": \"1.20\", \"id\": \"app-id\", ...}";
|
|
74
|
+
const manifest = TeamsManifestConverter.jsonToManifest(json) as TeamsManifestV1D20;
|
|
75
|
+
// You can now access properties specific to TeamsManifestV1D20
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Convert manifest object to JSON string:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const jsonString = TeamsManifestConverter.manifestToJson(manifest);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Note that the converts to/from JSON will throw runtime type check failures.
|
|
85
|
+
|
|
86
|
+
### Manifest utilities
|
|
87
|
+
|
|
88
|
+
Validate manifest against schema:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
const failures = await AppManifestUtils.validateAgainstSchema(manifest);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Read and write manifest:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const teamsManifestPath = "path/to/your/teams_manifest.json";
|
|
98
|
+
// read Teams manifest with type check
|
|
99
|
+
const teamsManifest1 = await AppManifestUtils.readTeamsManifest(teamsManifestPath);
|
|
100
|
+
// read Teams manifest and validate against schema
|
|
101
|
+
const [teamsManifest2, failedValidations1] = await AppManifestUtils.readAndValidateTeamsManifest(teamsManifestPath);
|
|
102
|
+
|
|
103
|
+
const daManifestPath = "path/to/your/da_manifest.json";
|
|
104
|
+
// read declarative agent manifest with type check
|
|
105
|
+
const daManifest1 = await AppManifestUtils.readDeclarativeAgentManifest(daManifestPath);
|
|
106
|
+
// read declarative agent manifest and validate against schema
|
|
107
|
+
const [daManifest2, failedValidations2] = await AppManifestUtils.readAndValidateDeclarativeAgentManifest(daManifestPath);
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const pluginManifestPath = "path/to/your/plugin_manifest.json";
|
|
111
|
+
// read API plugin manifest with type check
|
|
112
|
+
const pluginManifest1 = await AppManifestUtils.readApiPluginManifest(pluginManifestPath);
|
|
113
|
+
// read API plugin manifest and validate against schema
|
|
114
|
+
const [pluginManifest2, failedValidations3] = await AppManifestUtils.readAndValidateApiPluginManifest(pluginManifestPath);
|
|
115
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/app-manifest",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.2025041708.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"npx eslint --cache --fix --quiet"
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7fa1f2dc9a300961344a0e99a407487ecd551163"
|
|
68
68
|
}
|