@microsoft/app-manifest 1.0.4-alpha.077878d77.0 → 1.0.4-alpha.08ea48cc3.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/build/ManifestCommonProperties.d.ts +4 -0
- package/build/declarativeCopilotManifest.d.ts +43 -0
- package/build/declarativeCopilotManifest.js +3 -0
- package/build/declarativeCopilotManifest.js.map +1 -1
- package/build/generated-types/copilot/declarative-agent/DeclarativeAgentManifestV1D6.d.ts +69 -6
- package/build/generated-types/copilot/declarative-agent/DeclarativeAgentManifestV1D6.js +19 -1
- package/build/generated-types/copilot/declarative-agent/DeclarativeAgentManifestV1D6.js.map +1 -1
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D2.d.ts +5 -5
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D2.js +2 -2
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D2.js.map +1 -1
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D3.d.ts +1 -5
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D3.js +1 -1
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D3.js.map +1 -1
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D4.d.ts +527 -0
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D4.js +320 -0
- package/build/generated-types/copilot/plugin/ApiPluginManifestV2D4.js.map +1 -0
- package/build/generated-types/index.d.ts +7 -4
- package/build/generated-types/index.js +33 -5
- package/build/generated-types/index.js.map +1 -1
- package/build/generated-types/teams/TeamsManifestV1D17.d.ts +1 -1
- package/build/generated-types/teams/TeamsManifestV1D19.d.ts +1 -1
- package/build/generated-types/teams/TeamsManifestV1D20.d.ts +1 -1
- package/build/generated-types/teams/TeamsManifestV1D21.d.ts +1 -1
- package/build/generated-types/teams/TeamsManifestV1D22.d.ts +1 -1
- package/build/generated-types/teams/TeamsManifestV1D23.d.ts +1941 -0
- package/build/generated-types/teams/TeamsManifestV1D23.js +1108 -0
- package/build/generated-types/teams/TeamsManifestV1D23.js.map +1 -0
- package/build/generated-types/teams/TeamsManifestV1D24.d.ts +2027 -0
- package/build/generated-types/teams/TeamsManifestV1D24.js +1141 -0
- package/build/generated-types/teams/TeamsManifestV1D24.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/manifest.d.ts +78 -2
- package/build/manifest.js +2 -2
- package/build/manifest.js.map +1 -1
- package/build/pluginManifest.d.ts +56 -0
- package/build/pluginManifest.js +2 -0
- package/build/pluginManifest.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/wrappers/APIPluginManifestWrapper.d.ts +185 -0
- package/build/wrappers/APIPluginManifestWrapper.js +309 -0
- package/build/wrappers/APIPluginManifestWrapper.js.map +1 -0
- package/build/wrappers/BaseManifest.d.ts +57 -0
- package/build/wrappers/BaseManifest.js +84 -0
- package/build/wrappers/BaseManifest.js.map +1 -0
- package/build/wrappers/DeclarativeAgentManifestWrapper.d.ts +245 -0
- package/build/wrappers/DeclarativeAgentManifestWrapper.js +403 -0
- package/build/wrappers/DeclarativeAgentManifestWrapper.js.map +1 -0
- package/build/wrappers/TeamsManifestWrapper.d.ts +436 -0
- package/build/wrappers/TeamsManifestWrapper.js +709 -0
- package/build/wrappers/TeamsManifestWrapper.js.map +1 -0
- package/build/wrappers/index.d.ts +15 -0
- package/build/wrappers/index.js +28 -0
- package/build/wrappers/index.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.APIPluginManifestWrapper = exports.RuntimeType = void 0;
|
|
6
|
+
const generated_types_1 = require("../generated-types");
|
|
7
|
+
const BaseManifest_1 = require("./BaseManifest");
|
|
8
|
+
/**
|
|
9
|
+
* Runtime type enum for plugin runtimes.
|
|
10
|
+
* These values match the auto-generated RuntimeType from the schema.
|
|
11
|
+
* @see RuntimeTypeValue for the type definition
|
|
12
|
+
*/
|
|
13
|
+
exports.RuntimeType = {
|
|
14
|
+
OpenApi: "OpenApi",
|
|
15
|
+
LocalPlugin: "LocalPlugin",
|
|
16
|
+
RemoteMCPServer: "RemoteMCPServer",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* OOP wrapper for API Plugin Manifest.
|
|
20
|
+
*
|
|
21
|
+
* Provides a fluent API for manipulating API plugin manifests with
|
|
22
|
+
* type safety, state tracking, and convenient operations.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Read existing manifest
|
|
27
|
+
* const plugin = await APIPluginManifestWrapper.read("plugin.json");
|
|
28
|
+
*
|
|
29
|
+
* // Modify with fluent API
|
|
30
|
+
* plugin
|
|
31
|
+
* .addFunction("getUser", "Get user information")
|
|
32
|
+
* .addOpenApiRuntime("openapi.yaml", "Bearer");
|
|
33
|
+
*
|
|
34
|
+
* // Save changes
|
|
35
|
+
* await plugin.save();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class APIPluginManifestWrapper extends BaseManifest_1.BaseManifest {
|
|
39
|
+
constructor(data, filePath) {
|
|
40
|
+
super(data, filePath);
|
|
41
|
+
}
|
|
42
|
+
// ============= Static Factory Methods =============
|
|
43
|
+
/**
|
|
44
|
+
* Reads a plugin manifest from a file.
|
|
45
|
+
* @param filePath - Path to the manifest JSON file.
|
|
46
|
+
* @returns A new APIPluginManifestWrapper instance.
|
|
47
|
+
*/
|
|
48
|
+
static async read(filePath) {
|
|
49
|
+
const data = await generated_types_1.AppManifestUtils.readApiPluginManifest(filePath);
|
|
50
|
+
return new APIPluginManifestWrapper(data, filePath);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reads a plugin manifest from a file synchronously.
|
|
54
|
+
* @param filePath - Path to the manifest JSON file.
|
|
55
|
+
* @returns A new APIPluginManifestWrapper instance.
|
|
56
|
+
*/
|
|
57
|
+
static readSync(filePath) {
|
|
58
|
+
const json = BaseManifest_1.BaseManifest.readJsonFileSync(filePath);
|
|
59
|
+
const data = generated_types_1.ApiPluginManifestConverter.jsonToManifest(JSON.stringify(json));
|
|
60
|
+
return new APIPluginManifestWrapper(data, filePath);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates an APIPluginManifestWrapper from a JSON string.
|
|
64
|
+
* @param json - JSON string representing the manifest.
|
|
65
|
+
* @returns A new APIPluginManifestWrapper instance.
|
|
66
|
+
*/
|
|
67
|
+
static fromJSON(json) {
|
|
68
|
+
const data = generated_types_1.ApiPluginManifestConverter.jsonToManifest(json);
|
|
69
|
+
return new APIPluginManifestWrapper(data);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates a new plugin manifest with required fields.
|
|
73
|
+
* @param init - Initial manifest data with required fields.
|
|
74
|
+
* @returns A new APIPluginManifestWrapper instance.
|
|
75
|
+
*/
|
|
76
|
+
static create(init) {
|
|
77
|
+
var _a;
|
|
78
|
+
const data = {
|
|
79
|
+
schema_version: init.schemaVersion,
|
|
80
|
+
name_for_human: init.nameForHuman,
|
|
81
|
+
description_for_human: init.descriptionForHuman,
|
|
82
|
+
namespace: (_a = init.namespace) !== null && _a !== void 0 ? _a : init.nameForHuman.replace(/\s+/g, "_"),
|
|
83
|
+
};
|
|
84
|
+
return new APIPluginManifestWrapper(data);
|
|
85
|
+
}
|
|
86
|
+
// ============= Getters =============
|
|
87
|
+
/**
|
|
88
|
+
* Returns the schema version of the manifest.
|
|
89
|
+
*/
|
|
90
|
+
get schemaVersion() {
|
|
91
|
+
return this._data.schema_version;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the human-readable name.
|
|
95
|
+
*/
|
|
96
|
+
get nameForHuman() {
|
|
97
|
+
return this._data.name_for_human;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the human-readable description.
|
|
101
|
+
*/
|
|
102
|
+
get descriptionForHuman() {
|
|
103
|
+
return this._data.description_for_human;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Returns the namespace (if available in the version).
|
|
107
|
+
*/
|
|
108
|
+
get namespace() {
|
|
109
|
+
return this._data.namespace;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns a readonly array of functions.
|
|
113
|
+
*/
|
|
114
|
+
get functions() {
|
|
115
|
+
var _a;
|
|
116
|
+
return (_a = this._data.functions) !== null && _a !== void 0 ? _a : [];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns a readonly array of runtimes.
|
|
120
|
+
*/
|
|
121
|
+
get runtimes() {
|
|
122
|
+
var _a;
|
|
123
|
+
return (_a = this._data.runtimes) !== null && _a !== void 0 ? _a : [];
|
|
124
|
+
}
|
|
125
|
+
// ============= Setters (Fluent API) =============
|
|
126
|
+
/**
|
|
127
|
+
* Sets the human-readable name.
|
|
128
|
+
*/
|
|
129
|
+
setNameForHuman(name) {
|
|
130
|
+
this._data.name_for_human = name;
|
|
131
|
+
this.markDirty();
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Sets the human-readable description.
|
|
136
|
+
*/
|
|
137
|
+
setDescriptionForHuman(description) {
|
|
138
|
+
this._data.description_for_human = description;
|
|
139
|
+
this.markDirty();
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sets the model description.
|
|
144
|
+
*/
|
|
145
|
+
setDescriptionForModel(description) {
|
|
146
|
+
this._data.description_for_model = description;
|
|
147
|
+
this.markDirty();
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Sets the namespace (for latest version).
|
|
152
|
+
*/
|
|
153
|
+
setNamespace(namespace) {
|
|
154
|
+
this._data.namespace = namespace;
|
|
155
|
+
this.markDirty();
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
// ============= Function Operations =============
|
|
159
|
+
/**
|
|
160
|
+
* Adds a function to the manifest.
|
|
161
|
+
* @param name - The function name (must match operationId in OpenAPI).
|
|
162
|
+
* @param description - Description for the model.
|
|
163
|
+
*/
|
|
164
|
+
addFunction(name, description) {
|
|
165
|
+
if (!this._data.functions) {
|
|
166
|
+
this._data.functions = [];
|
|
167
|
+
}
|
|
168
|
+
const existing = this._data.functions.find((f) => f.name === name);
|
|
169
|
+
if (!existing) {
|
|
170
|
+
this._data.functions.push({
|
|
171
|
+
name,
|
|
172
|
+
description,
|
|
173
|
+
});
|
|
174
|
+
this.markDirty();
|
|
175
|
+
}
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Removes a function by name.
|
|
180
|
+
* @param name - The name of the function to remove.
|
|
181
|
+
*/
|
|
182
|
+
removeFunction(name) {
|
|
183
|
+
if (this._data.functions) {
|
|
184
|
+
this._data.functions = this._data.functions.filter((f) => f.name !== name);
|
|
185
|
+
this.markDirty();
|
|
186
|
+
}
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Checks if a function exists by name.
|
|
191
|
+
*/
|
|
192
|
+
hasFunction(name) {
|
|
193
|
+
return this.functions.some((f) => f.name === name);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Gets a function by name.
|
|
197
|
+
*/
|
|
198
|
+
getFunction(name) {
|
|
199
|
+
return this.functions.find((f) => f.name === name);
|
|
200
|
+
}
|
|
201
|
+
// ============= Runtime Operations =============
|
|
202
|
+
/**
|
|
203
|
+
* Adds a runtime configuration.
|
|
204
|
+
* @param runtime - The runtime configuration object.
|
|
205
|
+
*/
|
|
206
|
+
addRuntime(runtime) {
|
|
207
|
+
if (!this._data.runtimes) {
|
|
208
|
+
this._data.runtimes = [];
|
|
209
|
+
}
|
|
210
|
+
this._data.runtimes.push(runtime);
|
|
211
|
+
this.markDirty();
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Adds an OpenAPI runtime.
|
|
216
|
+
* @param specUrl - URL or relative path to the OpenAPI spec.
|
|
217
|
+
* @param authType - Authentication type.
|
|
218
|
+
* @param runForFunctions - Optional array of function names or "*" for all.
|
|
219
|
+
*/
|
|
220
|
+
addOpenApiRuntime(specUrl, authType = "None", runForFunctions) {
|
|
221
|
+
return this.addRuntime({
|
|
222
|
+
type: exports.RuntimeType.OpenApi,
|
|
223
|
+
auth: { type: authType },
|
|
224
|
+
spec: { url: specUrl },
|
|
225
|
+
run_for_functions: runForFunctions !== null && runForFunctions !== void 0 ? runForFunctions : ["*"],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Adds a LocalPlugin runtime.
|
|
230
|
+
* @param localEndpoint - The local endpoint identifier.
|
|
231
|
+
* @param runForFunctions - Optional array of function names.
|
|
232
|
+
*/
|
|
233
|
+
addLocalPluginRuntime(localEndpoint, runForFunctions) {
|
|
234
|
+
return this.addRuntime({
|
|
235
|
+
type: exports.RuntimeType.LocalPlugin,
|
|
236
|
+
auth: { type: "None" },
|
|
237
|
+
spec: { local_endpoint: localEndpoint },
|
|
238
|
+
run_for_functions: runForFunctions !== null && runForFunctions !== void 0 ? runForFunctions : ["*"],
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Removes a runtime by spec URL.
|
|
243
|
+
* @param specUrl - The spec URL of the runtime to remove.
|
|
244
|
+
*/
|
|
245
|
+
removeRuntimeBySpecUrl(specUrl) {
|
|
246
|
+
if (this._data.runtimes) {
|
|
247
|
+
const runtimes = this._data.runtimes;
|
|
248
|
+
this._data.runtimes = runtimes.filter((rt) => { var _a; return !(((_a = rt.spec) === null || _a === void 0 ? void 0 : _a.url) === specUrl); });
|
|
249
|
+
this.markDirty();
|
|
250
|
+
}
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
// ============= Query Operations =============
|
|
254
|
+
/**
|
|
255
|
+
* Returns all API spec paths/URLs from runtimes.
|
|
256
|
+
*/
|
|
257
|
+
getApiSpecPaths() {
|
|
258
|
+
return this.runtimes
|
|
259
|
+
.filter((rt) => rt.type === exports.RuntimeType.OpenApi)
|
|
260
|
+
.map((rt) => { var _a; return (_a = rt.spec) === null || _a === void 0 ? void 0 : _a.url; })
|
|
261
|
+
.filter((url) => typeof url === "string");
|
|
262
|
+
}
|
|
263
|
+
// ============= Validation =============
|
|
264
|
+
/**
|
|
265
|
+
* Validates the manifest against its JSON schema.
|
|
266
|
+
* @returns Array of validation error messages, empty if valid.
|
|
267
|
+
*/
|
|
268
|
+
async validate() {
|
|
269
|
+
return generated_types_1.AppManifestUtils.validateAgainstSchema(this._data);
|
|
270
|
+
}
|
|
271
|
+
// ============= Serialization =============
|
|
272
|
+
/**
|
|
273
|
+
* Converts the manifest to a formatted JSON string.
|
|
274
|
+
*/
|
|
275
|
+
toJSON() {
|
|
276
|
+
return generated_types_1.ApiPluginManifestConverter.manifestToJson(this._data);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Creates a deep clone of this manifest.
|
|
280
|
+
*/
|
|
281
|
+
clone() {
|
|
282
|
+
const clonedData = JSON.parse(this.toJSON());
|
|
283
|
+
return new APIPluginManifestWrapper(clonedData);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Creates a deep clone with partial modifications applied.
|
|
287
|
+
* Useful for creating a modified copy without mutating the original.
|
|
288
|
+
* @param changes - Partial manifest data to merge into the clone. Allows additional properties for extensibility.
|
|
289
|
+
* @returns A new APIPluginManifestWrapper with the changes applied.
|
|
290
|
+
*/
|
|
291
|
+
cloneWith(changes) {
|
|
292
|
+
const clonedData = JSON.parse(this.toJSON());
|
|
293
|
+
Object.assign(clonedData, changes);
|
|
294
|
+
const wrapper = new APIPluginManifestWrapper(clonedData);
|
|
295
|
+
wrapper.markDirty();
|
|
296
|
+
return wrapper;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns a mutable reference to the manifest data for direct modification.
|
|
300
|
+
* Use with caution - prefer using the fluent API methods when possible.
|
|
301
|
+
* Changes made through this reference will be tracked as dirty.
|
|
302
|
+
*/
|
|
303
|
+
get mutableData() {
|
|
304
|
+
this.markDirty();
|
|
305
|
+
return this._data;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
exports.APIPluginManifestWrapper = APIPluginManifestWrapper;
|
|
309
|
+
//# sourceMappingURL=APIPluginManifestWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIPluginManifestWrapper.js","sourceRoot":"","sources":["../../src/wrappers/APIPluginManifestWrapper.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,wDAK4B;AAC5B,iDAA8C;AAkB9C;;;;GAIG;AACU,QAAA,WAAW,GAA4C;IAClE,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,wBAAyB,SAAQ,2BAA+B;IAC3E,YAAoB,IAAuB,EAAE,QAAiB;QAC5D,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxB,CAAC;IAED,qDAAqD;IAErD;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAgB;QAChC,MAAM,IAAI,GAAG,MAAM,kCAAgB,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACpE,OAAO,IAAI,wBAAwB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAgB;QAC9B,MAAM,IAAI,GAAG,2BAAY,CAAC,gBAAgB,CAAoB,QAAQ,CAAC,CAAC;QACxE,MAAM,IAAI,G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CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,yCAAyC;IAEzC;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACZ,OAAO,kCAAgB,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,4CAA4C;IAE5C;;OAEG;IACH,MAAM;QACJ,OAAO,4CAA0B,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAsB,CAAC;QAClE,OAAO,IAAI,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,SAAS,CACP,OAA6D;QAE7D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAsB,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACzD,OAAO,CAAC,SAAS,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA3TD,4DA2TC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract base class for manifest wrappers.
|
|
3
|
+
* Provides common functionality for reading, writing, and tracking changes to manifest files.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The manifest type this wrapper handles
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseManifest<T extends Record<string, unknown>> {
|
|
8
|
+
protected _data: T;
|
|
9
|
+
protected _filePath?: string;
|
|
10
|
+
protected _isDirty: boolean;
|
|
11
|
+
protected constructor(data: T, filePath?: string);
|
|
12
|
+
/**
|
|
13
|
+
* Returns the raw manifest data.
|
|
14
|
+
*/
|
|
15
|
+
get data(): Readonly<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the file path if the manifest was loaded from a file.
|
|
18
|
+
*/
|
|
19
|
+
get filePath(): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates whether the manifest has unsaved changes.
|
|
22
|
+
*/
|
|
23
|
+
get isDirty(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Marks the manifest as having unsaved changes.
|
|
26
|
+
*/
|
|
27
|
+
protected markDirty(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Saves the manifest to the specified file path or the original file path.
|
|
30
|
+
* @param filePath - Optional path to save to. If not provided, uses the original file path.
|
|
31
|
+
* @throws Error if no file path is available.
|
|
32
|
+
*/
|
|
33
|
+
save(filePath?: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Validates the manifest against its schema.
|
|
36
|
+
* @returns Array of validation error messages, empty if valid.
|
|
37
|
+
*/
|
|
38
|
+
abstract validate(): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Converts the manifest to a JSON string.
|
|
41
|
+
*/
|
|
42
|
+
abstract toJSON(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a deep clone of this manifest wrapper.
|
|
45
|
+
*/
|
|
46
|
+
abstract clone(): BaseManifest<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Reads a JSON file and returns the parsed object.
|
|
49
|
+
* @param filePath - Path to the JSON file
|
|
50
|
+
*/
|
|
51
|
+
protected static readJsonFile<U>(filePath: string): Promise<U>;
|
|
52
|
+
/**
|
|
53
|
+
* Reads a JSON file synchronously and returns the parsed object.
|
|
54
|
+
* @param filePath - Path to the JSON file
|
|
55
|
+
*/
|
|
56
|
+
protected static readJsonFileSync<U>(filePath: string): U;
|
|
57
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BaseManifest = void 0;
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const strip_bom_1 = __importDefault(require("strip-bom"));
|
|
11
|
+
/**
|
|
12
|
+
* Abstract base class for manifest wrappers.
|
|
13
|
+
* Provides common functionality for reading, writing, and tracking changes to manifest files.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The manifest type this wrapper handles
|
|
16
|
+
*/
|
|
17
|
+
class BaseManifest {
|
|
18
|
+
constructor(data, filePath) {
|
|
19
|
+
this._isDirty = false;
|
|
20
|
+
this._data = data;
|
|
21
|
+
this._filePath = filePath;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the raw manifest data.
|
|
25
|
+
*/
|
|
26
|
+
get data() {
|
|
27
|
+
return this._data;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the file path if the manifest was loaded from a file.
|
|
31
|
+
*/
|
|
32
|
+
get filePath() {
|
|
33
|
+
return this._filePath;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Indicates whether the manifest has unsaved changes.
|
|
37
|
+
*/
|
|
38
|
+
get isDirty() {
|
|
39
|
+
return this._isDirty;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Marks the manifest as having unsaved changes.
|
|
43
|
+
*/
|
|
44
|
+
markDirty() {
|
|
45
|
+
this._isDirty = true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Saves the manifest to the specified file path or the original file path.
|
|
49
|
+
* @param filePath - Optional path to save to. If not provided, uses the original file path.
|
|
50
|
+
* @throws Error if no file path is available.
|
|
51
|
+
*/
|
|
52
|
+
async save(filePath) {
|
|
53
|
+
const targetPath = filePath !== null && filePath !== void 0 ? filePath : this._filePath;
|
|
54
|
+
if (!targetPath) {
|
|
55
|
+
throw new Error("No file path specified for saving.");
|
|
56
|
+
}
|
|
57
|
+
await fs_extra_1.default.writeFile(targetPath, this.toJSON(), "utf-8");
|
|
58
|
+
this._filePath = targetPath;
|
|
59
|
+
this._isDirty = false;
|
|
60
|
+
}
|
|
61
|
+
// ============= Static Helpers =============
|
|
62
|
+
/**
|
|
63
|
+
* Reads a JSON file and returns the parsed object.
|
|
64
|
+
* @param filePath - Path to the JSON file
|
|
65
|
+
*/
|
|
66
|
+
static async readJsonFile(filePath) {
|
|
67
|
+
const content = await fs_extra_1.default.readFile(filePath, "utf-8");
|
|
68
|
+
// Strip BOM to handle UTF-8 BOM encoded files
|
|
69
|
+
const cleanContent = (0, strip_bom_1.default)(content);
|
|
70
|
+
return JSON.parse(cleanContent);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reads a JSON file synchronously and returns the parsed object.
|
|
74
|
+
* @param filePath - Path to the JSON file
|
|
75
|
+
*/
|
|
76
|
+
static readJsonFileSync(filePath) {
|
|
77
|
+
const content = fs_extra_1.default.readFileSync(filePath, "utf-8");
|
|
78
|
+
// Strip BOM to handle UTF-8 BOM encoded files
|
|
79
|
+
const cleanContent = (0, strip_bom_1.default)(content);
|
|
80
|
+
return JSON.parse(cleanContent);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.BaseManifest = BaseManifest;
|
|
84
|
+
//# sourceMappingURL=BaseManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseManifest.js","sourceRoot":"","sources":["../../src/wrappers/BaseManifest.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,wDAA0B;AAC1B,0DAAiC;AAEjC;;;;;GAKG;AACH,MAAsB,Y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