@webda/azure 0.0.0-stage → 4.0.0-beta.14
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/LICENSE +166 -0
- package/README.md +248 -2
- package/lib/auth.d.ts +36 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +70 -0
- package/lib/auth.js.map +1 -0
- package/lib/deployers/arm.service.d.ts +177 -0
- package/lib/deployers/arm.service.d.ts.map +1 -0
- package/lib/deployers/arm.service.js +307 -0
- package/lib/deployers/arm.service.js.map +1 -0
- package/lib/deployers/containerapps.service.d.ts +186 -0
- package/lib/deployers/containerapps.service.d.ts.map +1 -0
- package/lib/deployers/containerapps.service.js +482 -0
- package/lib/deployers/containerapps.service.js.map +1 -0
- package/lib/deployers/functions-entrypoint.d.ts +60 -0
- package/lib/deployers/functions-entrypoint.d.ts.map +1 -0
- package/lib/deployers/functions-entrypoint.js +78 -0
- package/lib/deployers/functions-entrypoint.js.map +1 -0
- package/lib/deployers/functions.service.d.ts +96 -0
- package/lib/deployers/functions.service.d.ts.map +1 -0
- package/lib/deployers/functions.service.js +340 -0
- package/lib/deployers/functions.service.js.map +1 -0
- package/lib/deployers/functionspackager.service.d.ts +82 -0
- package/lib/deployers/functionspackager.service.d.ts.map +1 -0
- package/lib/deployers/functionspackager.service.js +157 -0
- package/lib/deployers/functionspackager.service.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/services/azure-parameters.d.ts +56 -0
- package/lib/services/azure-parameters.d.ts.map +1 -0
- package/lib/services/azure-parameters.js +43 -0
- package/lib/services/azure-parameters.js.map +1 -0
- package/lib/services/blob.service.d.ts +196 -0
- package/lib/services/blob.service.d.ts.map +1 -0
- package/lib/services/blob.service.js +450 -0
- package/lib/services/blob.service.js.map +1 -0
- package/lib/services/contributors.d.ts +50 -0
- package/lib/services/contributors.d.ts.map +1 -0
- package/lib/services/contributors.js +2 -0
- package/lib/services/contributors.js.map +1 -0
- package/lib/services/cosmos.service.d.ts +253 -0
- package/lib/services/cosmos.service.d.ts.map +1 -0
- package/lib/services/cosmos.service.js +566 -0
- package/lib/services/cosmos.service.js.map +1 -0
- package/lib/services/functionserver.service.d.ts +51 -0
- package/lib/services/functionserver.service.d.ts.map +1 -0
- package/lib/services/functionserver.service.js +232 -0
- package/lib/services/functionserver.service.js.map +1 -0
- package/lib/services/keyvault.service.d.ts +106 -0
- package/lib/services/keyvault.service.d.ts.map +1 -0
- package/lib/services/keyvault.service.js +228 -0
- package/lib/services/keyvault.service.js.map +1 -0
- package/lib/services/monitorlogger.service.d.ts +117 -0
- package/lib/services/monitorlogger.service.d.ts.map +1 -0
- package/lib/services/monitorlogger.service.js +149 -0
- package/lib/services/monitorlogger.service.js.map +1 -0
- package/lib/services/servicebus.service.d.ts +224 -0
- package/lib/services/servicebus.service.d.ts.map +1 -0
- package/lib/services/servicebus.service.js +351 -0
- package/lib/services/servicebus.service.js.map +1 -0
- package/lib/template.d.ts +68 -0
- package/lib/template.d.ts.map +1 -0
- package/lib/template.js +74 -0
- package/lib/template.js.map +1 -0
- package/package.json +77 -3
- package/webda.module.json +1891 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Application, Deployer, PackageOptions, Service, ServiceParameters } from "@webda/core";
|
|
2
|
+
import type { AzureTrigger } from "./functions-entrypoint.js";
|
|
3
|
+
/**
|
|
4
|
+
* Azure functions package options interface
|
|
5
|
+
*/
|
|
6
|
+
export interface AzureFunctionsPackageOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Zip path
|
|
9
|
+
*/
|
|
10
|
+
zipPath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Package
|
|
13
|
+
*/
|
|
14
|
+
package?: PackageOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Crons
|
|
17
|
+
*/
|
|
18
|
+
crons?: {
|
|
19
|
+
id: string;
|
|
20
|
+
schedule: string;
|
|
21
|
+
}[];
|
|
22
|
+
/**
|
|
23
|
+
* Triggers
|
|
24
|
+
*/
|
|
25
|
+
triggers?: AzureTrigger[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Azure functions package result interface
|
|
29
|
+
*/
|
|
30
|
+
export interface AzureFunctionsPackageResult {
|
|
31
|
+
/**
|
|
32
|
+
* Zip path
|
|
33
|
+
*/
|
|
34
|
+
zipPath: string;
|
|
35
|
+
/**
|
|
36
|
+
* Files
|
|
37
|
+
*/
|
|
38
|
+
files: number;
|
|
39
|
+
/**
|
|
40
|
+
* Size
|
|
41
|
+
*/
|
|
42
|
+
size: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Package a Webda application for the Azure Functions Node v4 programming model.
|
|
46
|
+
* @param application - Webda application to package
|
|
47
|
+
* @param options - Encryption or packaging options
|
|
48
|
+
* @returns Archive path, size and file count
|
|
49
|
+
*/
|
|
50
|
+
export declare function createAzureFunctionsPackage(application: Application, options?: AzureFunctionsPackageOptions): Promise<AzureFunctionsPackageResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Configuration parameters for AzureFunctionsPackager
|
|
53
|
+
*/
|
|
54
|
+
export declare class AzureFunctionsPackagerParameters extends ServiceParameters implements AzureFunctionsPackageOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Zip path
|
|
57
|
+
*/
|
|
58
|
+
zipPath: string;
|
|
59
|
+
/**
|
|
60
|
+
* Package
|
|
61
|
+
*/
|
|
62
|
+
package?: PackageOptions;
|
|
63
|
+
/**
|
|
64
|
+
* Triggers
|
|
65
|
+
*/
|
|
66
|
+
triggers?: AzureTrigger[];
|
|
67
|
+
}
|
|
68
|
+
/** Build a reproducible Azure Functions deployment archive.
|
|
69
|
+
* @WebdaModda
|
|
70
|
+
*/
|
|
71
|
+
export declare class AzureFunctionsPackager extends Service<AzureFunctionsPackagerParameters> implements Deployer {
|
|
72
|
+
/**
|
|
73
|
+
* Parameters
|
|
74
|
+
*/
|
|
75
|
+
static Parameters: typeof AzureFunctionsPackagerParameters;
|
|
76
|
+
/**
|
|
77
|
+
* Create the Functions archive with the declared cron timers.
|
|
78
|
+
* @returns The package result
|
|
79
|
+
*/
|
|
80
|
+
package(): Promise<AzureFunctionsPackageResult>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=functionspackager.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionspackager.service.d.ts","sources":["../../src/deployers/functionspackager.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAGX,QAAQ,EAIR,cAAc,EAEd,OAAO,EACP,iBAAiB,EAIlB,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AACD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,2BAA2B,CAAC,CAkEtC;AAED;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,iBAAkB,YAAW,4BAA4B;IAC7G;;OAEG;IACH,OAAO,SAA8B;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,OAAO,CAAC,gCAAgC,CAAE,YAAW,QAAQ;IACvG;;OAEG;IACH,MAAM,CAAC,UAAU,0CAAoC;IAErD;;;OAGG;IAEG,OAAO,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAOpD;CACF"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Command, CronService, getDeploymentVariables, PACKAGED_CONFIGURATION, packageApplication, resolveDeploymentVariables, Service, ServiceParameters, useApplication, writeZip } from "@webda/core";
|
|
36
|
+
import { readFileSync, statSync } from "node:fs";
|
|
37
|
+
import { relative, resolve, sep } from "node:path";
|
|
38
|
+
import { functionsSchedule } from "../template.js";
|
|
39
|
+
/**
|
|
40
|
+
* Package a Webda application for the Azure Functions Node v4 programming model.
|
|
41
|
+
* @param application - Webda application to package
|
|
42
|
+
* @param options - Encryption or packaging options
|
|
43
|
+
* @returns Archive path, size and file count
|
|
44
|
+
*/
|
|
45
|
+
export async function createAzureFunctionsPackage(application, options = {}) {
|
|
46
|
+
const zipPath = resolve(application.applicationPath, options.zipPath ?? "dist/azure-functions.zip");
|
|
47
|
+
const packaged = await packageApplication(application, {
|
|
48
|
+
...options.package,
|
|
49
|
+
ignores: [...(options.package?.ignores ?? []), relative(application.applicationPath, zipPath).split(sep)[0]],
|
|
50
|
+
modules: {
|
|
51
|
+
includes: [...new Set(["@webda/azure", "@azure/functions", ...(options.package?.modules?.includes ?? [])])],
|
|
52
|
+
excludes: options.package?.modules?.excludes
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const configuration = packaged.configuration;
|
|
56
|
+
// Packaging can be called for an app that has not loaded this module. Install the generated server
|
|
57
|
+
// definition in its cached modules so the default adapter resolves during packaged boot.
|
|
58
|
+
const manifest = JSON.parse(readFileSync(new URL("../../webda.module.json", import.meta.url), "utf8"));
|
|
59
|
+
const modules = (configuration.cachedModules ?? (configuration.cachedModules = {}));
|
|
60
|
+
modules.moddas ?? (modules.moddas = {});
|
|
61
|
+
if (!modules.moddas["Webda/AzureFunctionServer"]) {
|
|
62
|
+
const definition = { ...manifest.moddas["Webda/AzureFunctionServer"] };
|
|
63
|
+
for (const key of ["Import", "Configuration"])
|
|
64
|
+
definition[key] = `node_modules/@webda/azure/${definition[key]}`;
|
|
65
|
+
modules.moddas["Webda/AzureFunctionServer"] = definition;
|
|
66
|
+
}
|
|
67
|
+
configuration.services ?? (configuration.services = {});
|
|
68
|
+
if (!Object.values(configuration.services).some(service => ["AzureFunctionServer", "Webda/AzureFunctionServer"].includes(service?.type)))
|
|
69
|
+
configuration.services.AzureFunctionServer = { type: "Webda/AzureFunctionServer" };
|
|
70
|
+
const crons = (options.crons ?? []).map(cron => ({ ...cron, schedule: functionsSchedule(cron.schedule) }));
|
|
71
|
+
const triggers = (options.triggers ?? []).map(trigger => trigger.type === "timer" ? { ...trigger, schedule: functionsSchedule(trigger.schedule) } : trigger);
|
|
72
|
+
const entries = [];
|
|
73
|
+
for (const file of packaged.files) {
|
|
74
|
+
if (["host.json", "webda-functions.mjs", "local.settings.json"].includes(file.target))
|
|
75
|
+
continue;
|
|
76
|
+
if (file.target === PACKAGED_CONFIGURATION)
|
|
77
|
+
entries.push({ target: file.target, content: JSON.stringify(configuration, null, 2) });
|
|
78
|
+
else if (file.target === "package.json") {
|
|
79
|
+
const descriptor = JSON.parse(file.content ?? readFileSync(file.source, "utf8"));
|
|
80
|
+
// Dependencies are already packaged; prevent a host-side install of workspace/dev references.
|
|
81
|
+
delete descriptor.devDependencies;
|
|
82
|
+
delete descriptor.scripts;
|
|
83
|
+
delete descriptor.workspaces;
|
|
84
|
+
delete descriptor.packageManager;
|
|
85
|
+
descriptor.main = "webda-functions.mjs";
|
|
86
|
+
entries.push({ target: "package.json", content: JSON.stringify(descriptor, null, 2) });
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
entries.push(file);
|
|
90
|
+
}
|
|
91
|
+
entries.push({
|
|
92
|
+
target: "host.json",
|
|
93
|
+
content: JSON.stringify({
|
|
94
|
+
version: "2.0",
|
|
95
|
+
extensions: { http: { routePrefix: "" } },
|
|
96
|
+
extensionBundle: { id: "Microsoft.Azure.Functions.ExtensionBundle", version: "[4.*, 5.0.0)" }
|
|
97
|
+
}, null, 2)
|
|
98
|
+
});
|
|
99
|
+
entries.push({
|
|
100
|
+
target: "webda-functions.mjs",
|
|
101
|
+
content: `import "@webda/azure";\nimport { registerAzureFunctions } from "@webda/azure/lib/deployers/functions-entrypoint.js";\nregisterAzureFunctions(${JSON.stringify(crons)}, ${JSON.stringify(triggers)});\n`
|
|
102
|
+
});
|
|
103
|
+
writeZip(zipPath, entries);
|
|
104
|
+
return { zipPath, files: entries.length, size: statSync(zipPath).size };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configuration parameters for AzureFunctionsPackager
|
|
108
|
+
*/
|
|
109
|
+
export class AzureFunctionsPackagerParameters extends ServiceParameters {
|
|
110
|
+
constructor() {
|
|
111
|
+
super(...arguments);
|
|
112
|
+
/**
|
|
113
|
+
* Zip path
|
|
114
|
+
*/
|
|
115
|
+
this.zipPath = "dist/azure-functions.zip";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Build a reproducible Azure Functions deployment archive.
|
|
119
|
+
* @WebdaModda
|
|
120
|
+
*/
|
|
121
|
+
let AzureFunctionsPackager = (() => {
|
|
122
|
+
var _a;
|
|
123
|
+
let _classSuper = Service;
|
|
124
|
+
let _instanceExtraInitializers = [];
|
|
125
|
+
let _package_decorators;
|
|
126
|
+
return _a = class AzureFunctionsPackager extends _classSuper {
|
|
127
|
+
/**
|
|
128
|
+
* Create the Functions archive with the declared cron timers.
|
|
129
|
+
* @returns The package result
|
|
130
|
+
*/
|
|
131
|
+
async package() {
|
|
132
|
+
const options = resolveDeploymentVariables(this.parameters, getDeploymentVariables(this));
|
|
133
|
+
const crons = CronService.resolveCrons().map(cron => ({
|
|
134
|
+
id: CronService.getExportId(cron),
|
|
135
|
+
schedule: cron.cron
|
|
136
|
+
}));
|
|
137
|
+
return createAzureFunctionsPackage(useApplication(), { ...options, crons });
|
|
138
|
+
}
|
|
139
|
+
constructor() {
|
|
140
|
+
super(...arguments);
|
|
141
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
(() => {
|
|
145
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
146
|
+
_package_decorators = [Command("azure package", { description: "Package the application for Azure Functions" })];
|
|
147
|
+
__esDecorate(_a, null, _package_decorators, { kind: "method", name: "package", static: false, private: false, access: { has: obj => "package" in obj, get: obj => obj.package }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
148
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
149
|
+
})(),
|
|
150
|
+
/**
|
|
151
|
+
* Parameters
|
|
152
|
+
*/
|
|
153
|
+
_a.Parameters = AzureFunctionsPackagerParameters,
|
|
154
|
+
_a;
|
|
155
|
+
})();
|
|
156
|
+
export { AzureFunctionsPackager };
|
|
157
|
+
//# sourceMappingURL=functionspackager.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionspackager.service.js","sources":["../../src/deployers/functionspackager.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,OAAO,EACP,WAAW,EAEX,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAElB,0BAA0B,EAC1B,OAAO,EACP,iBAAiB,EAC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,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9E,CAAC;;;gBAlBU,mDAAsB;;;;;mCAUhC,OAAO,CAAC,eAAe,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;YACzF,sKAAM,OAAO,6DAOZ;;;QAjBD;;WAEG;QACI,aAAU,GAAG,gCAAiC;;;SAJ1C,sBAAsB"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./services/azure-parameters.js";
|
|
2
|
+
export * from "./services/contributors.js";
|
|
3
|
+
export * from "./services/keyvault.service.js";
|
|
4
|
+
export * from "./services/monitorlogger.service.js";
|
|
5
|
+
export * from "./services/servicebus.service.js";
|
|
6
|
+
export * from "./services/blob.service.js";
|
|
7
|
+
export * from "./services/cosmos.service.js";
|
|
8
|
+
export * from "./services/functionserver.service.js";
|
|
9
|
+
export * from "./auth.js";
|
|
10
|
+
export * from "./template.js";
|
|
11
|
+
export * from "./deployers/arm.service.js";
|
|
12
|
+
export * from "./deployers/containerapps.service.js";
|
|
13
|
+
export * from "./deployers/functionspackager.service.js";
|
|
14
|
+
export * from "./deployers/functions.service.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { registerWebdaPackage } from "@webda/utils";
|
|
2
|
+
export * from "./services/azure-parameters.js";
|
|
3
|
+
export * from "./services/contributors.js";
|
|
4
|
+
export * from "./services/keyvault.service.js";
|
|
5
|
+
export * from "./services/monitorlogger.service.js";
|
|
6
|
+
export * from "./services/servicebus.service.js";
|
|
7
|
+
export * from "./services/blob.service.js";
|
|
8
|
+
export * from "./services/cosmos.service.js";
|
|
9
|
+
export * from "./services/functionserver.service.js";
|
|
10
|
+
export * from "./auth.js";
|
|
11
|
+
export * from "./template.js";
|
|
12
|
+
export * from "./deployers/arm.service.js";
|
|
13
|
+
export * from "./deployers/containerapps.service.js";
|
|
14
|
+
export * from "./deployers/functionspackager.service.js";
|
|
15
|
+
export * from "./deployers/functions.service.js";
|
|
16
|
+
// Refuse a second copy of the package, see registerWebdaPackage
|
|
17
|
+
registerWebdaPackage("@webda/azure", import.meta.url);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AAEjD,gEAAgE;AAChE,oBAAoB,CAAC,cAAc,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TokenCredential } from "@azure/core-auth";
|
|
2
|
+
import { SecretString, ServiceParameters } from "@webda/core";
|
|
3
|
+
/** Authentication and endpoint parameters shared by Azure services and deployers. */
|
|
4
|
+
export interface AzureServiceParameters {
|
|
5
|
+
/** Microsoft Entra tenant; defaults to AZURE_TENANT_ID. */
|
|
6
|
+
tenantId?: string;
|
|
7
|
+
/** Service principal or user-assigned managed identity client id; defaults to AZURE_CLIENT_ID. */
|
|
8
|
+
clientId?: string;
|
|
9
|
+
/** Service principal secret; defaults to AZURE_CLIENT_SECRET. Prefer managed/workload identity. */
|
|
10
|
+
clientSecret?: string | SecretString;
|
|
11
|
+
/** Subscription containing the resources; defaults to AZURE_SUBSCRIPTION_ID. */
|
|
12
|
+
subscriptionId?: string;
|
|
13
|
+
/** Service-specific endpoint override, for example Azurite. This is not an identity authority URL. */
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Common parameters for services using Microsoft Entra authentication. */
|
|
17
|
+
export declare class AzureParameters extends ServiceParameters implements AzureServiceParameters {
|
|
18
|
+
/**
|
|
19
|
+
* Tenant ID
|
|
20
|
+
*/
|
|
21
|
+
tenantId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Client ID
|
|
24
|
+
*/
|
|
25
|
+
clientId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Client secret
|
|
28
|
+
*/
|
|
29
|
+
clientSecret?: string | SecretString;
|
|
30
|
+
/**
|
|
31
|
+
* Subscription ID
|
|
32
|
+
*/
|
|
33
|
+
subscriptionId?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Endpoint
|
|
36
|
+
*/
|
|
37
|
+
endpoint?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Apply the standard Azure environment defaults.
|
|
40
|
+
* @override
|
|
41
|
+
*/
|
|
42
|
+
load(params?: Partial<AzureParameters>): this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Fill absent Azure parameters from the standard Azure environment variables. Explicit values always win. Service parameter classes can call this from load(); it preserves SecretString instances.
|
|
46
|
+
* @param params - Raw configuration parameters
|
|
47
|
+
* @returns The load azure parameters result
|
|
48
|
+
*/
|
|
49
|
+
export declare function loadAzureParameters<T extends AzureServiceParameters>(params: T): T;
|
|
50
|
+
/**
|
|
51
|
+
* Select a service principal when all three credential fields are nonempty, otherwise use Azure's default chain. Constructing the credential performs no network I/O. Secrets are unwrapped only for the SDK constructor and clear-text values produce SecretString's value-free warning. The input and process environment are unchanged.
|
|
52
|
+
* @param params - Raw configuration parameters
|
|
53
|
+
* @returns The azure credential result
|
|
54
|
+
*/
|
|
55
|
+
export declare function getAzureCredential(params?: AzureServiceParameters): TokenCredential;
|
|
56
|
+
//# sourceMappingURL=azure-parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-parameters.d.ts","sources":["../../src/services/azure-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE9D,qFAAqF;AACrF,MAAM,WAAW,sBAAsB;IACrC,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2EAA2E;AAC3E,qBAAa,eAAgB,SAAQ,iBAAkB,YAAW,sBAAsB;IACtF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,IAAI,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,IAAI,CAGhD;CACF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,sBAAsB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAMlF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,sBAA2B,GAAG,eAAe,CAYvF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ClientSecretCredential, DefaultAzureCredential } from "@azure/identity";
|
|
2
|
+
import { SecretString, ServiceParameters } from "@webda/core";
|
|
3
|
+
/** Common parameters for services using Microsoft Entra authentication. */
|
|
4
|
+
export class AzureParameters extends ServiceParameters {
|
|
5
|
+
/**
|
|
6
|
+
* Apply the standard Azure environment defaults.
|
|
7
|
+
* @override
|
|
8
|
+
*/
|
|
9
|
+
load(params = {}) {
|
|
10
|
+
super.load(params);
|
|
11
|
+
return loadAzureParameters(this);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Fill absent Azure parameters from the standard Azure environment variables. Explicit values always win. Service parameter classes can call this from load(); it preserves SecretString instances.
|
|
16
|
+
* @param params - Raw configuration parameters
|
|
17
|
+
* @returns The load azure parameters result
|
|
18
|
+
*/
|
|
19
|
+
export function loadAzureParameters(params) {
|
|
20
|
+
params.tenantId ?? (params.tenantId = process.env.AZURE_TENANT_ID || undefined);
|
|
21
|
+
params.clientId ?? (params.clientId = process.env.AZURE_CLIENT_ID || undefined);
|
|
22
|
+
params.clientSecret ?? (params.clientSecret = process.env.AZURE_CLIENT_SECRET || undefined);
|
|
23
|
+
params.subscriptionId ?? (params.subscriptionId = process.env.AZURE_SUBSCRIPTION_ID || undefined);
|
|
24
|
+
return params;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Select a service principal when all three credential fields are nonempty, otherwise use Azure's default chain. Constructing the credential performs no network I/O. Secrets are unwrapped only for the SDK constructor and clear-text values produce SecretString's value-free warning. The input and process environment are unchanged.
|
|
28
|
+
* @param params - Raw configuration parameters
|
|
29
|
+
* @returns The azure credential result
|
|
30
|
+
*/
|
|
31
|
+
export function getAzureCredential(params = {}) {
|
|
32
|
+
const resolved = loadAzureParameters({ ...params });
|
|
33
|
+
const secret = resolved.clientSecret === undefined ? undefined : SecretString.from(resolved.clientSecret, "clientSecret");
|
|
34
|
+
if (resolved.tenantId && resolved.clientId && secret) {
|
|
35
|
+
return new ClientSecretCredential(resolved.tenantId, resolved.clientId, secret);
|
|
36
|
+
}
|
|
37
|
+
return new DefaultAzureCredential({
|
|
38
|
+
tenantId: resolved.tenantId || undefined,
|
|
39
|
+
managedIdentityClientId: resolved.clientId || undefined,
|
|
40
|
+
workloadIdentityClientId: resolved.clientId || undefined
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=azure-parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azure-parameters.js","sources":["../../src/services/azure-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgB9D,2EAA2E;AAC3E,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAsBpD;;;OAGG;IACH,IAAI,CAAC,MAAM,GAA6B,EAAE;QACxC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,mBA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
1
|
+
import { BlobServiceClient } from "@azure/storage-blob";
|
|
2
|
+
import { BinaryFile, BinaryFileInfo, BinaryMap, CloudBinary, CloudBinaryParameters, CoreModelWithBinary, OperationContext, SecretString } from "@webda/core";
|
|
3
|
+
import { ContentBody, ContentGetOptions, ContentInfo, ContentPutOptions } from "@webda/utils";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { AzureServiceParameters } from "./azure-parameters.js";
|
|
6
|
+
import { AzureContributor, AzureDeployerInfo, AzureResourceContribution } from "./contributors.js";
|
|
7
|
+
/** Blob storage settings. Shared keys are optional; managed identity is preferred. */
|
|
8
|
+
export declare class AzureBlobBinaryParameters extends CloudBinaryParameters implements AzureServiceParameters {
|
|
9
|
+
/**
|
|
10
|
+
* Account
|
|
11
|
+
*/
|
|
12
|
+
account?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Connection string
|
|
15
|
+
*/
|
|
16
|
+
connectionString?: string | SecretString;
|
|
17
|
+
/**
|
|
18
|
+
* Container
|
|
19
|
+
*/
|
|
20
|
+
container: string;
|
|
21
|
+
/**
|
|
22
|
+
* Endpoint
|
|
23
|
+
*/
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Tenant ID
|
|
27
|
+
*/
|
|
28
|
+
tenantId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Client ID
|
|
31
|
+
*/
|
|
32
|
+
clientId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Client secret
|
|
35
|
+
*/
|
|
36
|
+
clientSecret?: string | SecretString;
|
|
37
|
+
/**
|
|
38
|
+
* Subscription ID
|
|
39
|
+
*/
|
|
40
|
+
subscriptionId?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Create container
|
|
43
|
+
*/
|
|
44
|
+
createContainer: boolean;
|
|
45
|
+
/** Override the Blob API/SAS version for older Azurite installations. */
|
|
46
|
+
serviceVersion?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Pending timeout
|
|
49
|
+
*/
|
|
50
|
+
pendingTimeout: number;
|
|
51
|
+
/**
|
|
52
|
+
* Perform load.
|
|
53
|
+
* @override
|
|
54
|
+
*/
|
|
55
|
+
load(params?: any): this;
|
|
56
|
+
}
|
|
57
|
+
/** Blob-backed binaries with verified direct uploads and exact ownership markers.
|
|
58
|
+
* @WebdaModda
|
|
59
|
+
*/
|
|
60
|
+
export declare class AzureBlobBinary extends CloudBinary<AzureBlobBinaryParameters> implements AzureContributor {
|
|
61
|
+
/**
|
|
62
|
+
* Parameters
|
|
63
|
+
*/
|
|
64
|
+
static Parameters: typeof AzureBlobBinaryParameters;
|
|
65
|
+
/**
|
|
66
|
+
* Schemes
|
|
67
|
+
*/
|
|
68
|
+
readonly schemes: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Client
|
|
71
|
+
*/
|
|
72
|
+
protected client: BlobServiceClient;
|
|
73
|
+
/**
|
|
74
|
+
* Perform init.
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
init(): Promise<this>;
|
|
78
|
+
/**
|
|
79
|
+
* Perform get content bucket.
|
|
80
|
+
* @override
|
|
81
|
+
*/
|
|
82
|
+
getContentBucket(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Resolve a content URL to a configured Blob SDK client.
|
|
85
|
+
* @param url - Content URL
|
|
86
|
+
* @returns The blob result
|
|
87
|
+
*/
|
|
88
|
+
protected blob(url: string): import("@azure/storage-blob").BlockBlobClient;
|
|
89
|
+
/**
|
|
90
|
+
* Perform get content.
|
|
91
|
+
* @override
|
|
92
|
+
*/
|
|
93
|
+
getContent(url: string, options?: ContentGetOptions): Promise<Readable>;
|
|
94
|
+
/**
|
|
95
|
+
* Perform put content.
|
|
96
|
+
* @override
|
|
97
|
+
*/
|
|
98
|
+
putContent(url: string, body: ContentBody, options?: ContentPutOptions): Promise<ContentInfo>;
|
|
99
|
+
/**
|
|
100
|
+
* Perform head content.
|
|
101
|
+
* @override
|
|
102
|
+
*/
|
|
103
|
+
headContent(url: string): Promise<ContentInfo | undefined>;
|
|
104
|
+
/**
|
|
105
|
+
* Perform delete content.
|
|
106
|
+
* @override
|
|
107
|
+
*/
|
|
108
|
+
deleteContent(url: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Perform _get.
|
|
111
|
+
* @override
|
|
112
|
+
*/
|
|
113
|
+
_get(info: BinaryMap): Promise<Readable>;
|
|
114
|
+
/**
|
|
115
|
+
* Perform get signed url from map.
|
|
116
|
+
* @override
|
|
117
|
+
*/
|
|
118
|
+
getSignedUrlFromMap(map: BinaryMap, expires: number, _context: OperationContext): Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Issue narrowly scoped SAS credentials. Direct uploads only create isolated staging blobs.
|
|
121
|
+
* @param key - Object key within the container
|
|
122
|
+
* @param permissions - Permissions granted by the SAS
|
|
123
|
+
* @param expires - SAS lifetime in seconds
|
|
124
|
+
* @returns The signed url result
|
|
125
|
+
*/
|
|
126
|
+
getSignedUrl(key: string, permissions?: "r" | "c", expires?: number): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Validate a hash before using it in a storage key.
|
|
129
|
+
* @param hash - Normalized content hash
|
|
130
|
+
* @returns The check hash result
|
|
131
|
+
*/
|
|
132
|
+
protected checkHash(hash?: string): asserts hash is string;
|
|
133
|
+
/**
|
|
134
|
+
* Build an injective ownership marker from the model, attribute and key.
|
|
135
|
+
* @param model - Model class or model identifier
|
|
136
|
+
* @param property - Binary or model attribute
|
|
137
|
+
* @param uuid - Owner primary key
|
|
138
|
+
* @returns The marker result
|
|
139
|
+
*/
|
|
140
|
+
protected marker(model: string, property: string, uuid: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* Build the private pending-upload record key.
|
|
143
|
+
* @param object - Model owning the binary
|
|
144
|
+
* @param property - Binary or model attribute
|
|
145
|
+
* @param hash - Normalized content hash
|
|
146
|
+
* @returns The pending key result
|
|
147
|
+
*/
|
|
148
|
+
protected pendingKey(object: CoreModelWithBinary, property: string, hash: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Persist an exact ownership marker and attach the verified file.
|
|
151
|
+
* @param object - Model owning the binary
|
|
152
|
+
* @param property - Binary or model attribute
|
|
153
|
+
* @param info - Binary metadata or increment specification
|
|
154
|
+
*/
|
|
155
|
+
protected attach(object: CoreModelWithBinary, property: string, info: BinaryFileInfo): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Perform store.
|
|
158
|
+
* @override
|
|
159
|
+
*/
|
|
160
|
+
store(object: CoreModelWithBinary, property: string, file: BinaryFile): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Perform put redirect url.
|
|
163
|
+
* @override
|
|
164
|
+
*/
|
|
165
|
+
putRedirectUrl(object: CoreModelWithBinary, property: string, info?: BinaryFileInfo, context?: OperationContext<BinaryFileInfo>): Promise<{
|
|
166
|
+
url: string;
|
|
167
|
+
method: string;
|
|
168
|
+
headers: {
|
|
169
|
+
"x-ms-blob-type": string;
|
|
170
|
+
"Content-Type": string;
|
|
171
|
+
"Content-MD5": string;
|
|
172
|
+
};
|
|
173
|
+
} | undefined>;
|
|
174
|
+
/**
|
|
175
|
+
* Verify the bytes before copying them to the content hash and attaching them to the owner.
|
|
176
|
+
* @override
|
|
177
|
+
*/
|
|
178
|
+
completeUpload(object: CoreModelWithBinary, property: string, hash: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Perform get usage count.
|
|
181
|
+
* @override
|
|
182
|
+
*/
|
|
183
|
+
getUsageCount(hash: string): Promise<number>;
|
|
184
|
+
/**
|
|
185
|
+
* Perform _clean usage.
|
|
186
|
+
* @override
|
|
187
|
+
*/
|
|
188
|
+
_cleanUsage(hash: string, uuid: string, attribute: string, model: string): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Describe the Azure resources and identity permissions required by this service.
|
|
191
|
+
* @param deployer - Deployment scope and identity helpers
|
|
192
|
+
* @returns The azure resources result
|
|
193
|
+
*/
|
|
194
|
+
getAzureResources(deployer: AzureDeployerInfo): AzureResourceContribution;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=blob.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.service.d.ts","sources":["../../src/services/blob.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAIlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EAKb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,WAAW,EAEX,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,sBAAsB,EAA2C,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnG,sFAAsF;AACtF,qBAAa,yBAA0B,SAAQ,qBAAsB,YAAW,sBAAsB;IACpG;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACzC;;OAEG;IACH,SAAS,EAAG,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,UAAS;IACxB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,cAAc,SAAQ;IAEtB;;;OAGG;IAC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