@webda/azure 0.0.0-stage → 4.0.0-beta.13
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 +30 -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 +108 -0
- package/lib/deployers/arm.service.d.ts.map +1 -0
- package/lib/deployers/arm.service.js +280 -0
- package/lib/deployers/arm.service.js.map +1 -0
- package/lib/deployers/containerapps.service.d.ts +156 -0
- package/lib/deployers/containerapps.service.d.ts.map +1 -0
- package/lib/deployers/containerapps.service.js +455 -0
- package/lib/deployers/containerapps.service.js.map +1 -0
- package/lib/deployers/functions-entrypoint.d.ts +48 -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 +66 -0
- package/lib/deployers/functions.service.d.ts.map +1 -0
- package/lib/deployers/functions.service.js +322 -0
- package/lib/deployers/functions.service.js.map +1 -0
- package/lib/deployers/functionspackager.service.d.ts +43 -0
- package/lib/deployers/functionspackager.service.d.ts.map +1 -0
- package/lib/deployers/functionspackager.service.js +151 -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 +41 -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 +157 -0
- package/lib/services/blob.service.d.ts.map +1 -0
- package/lib/services/blob.service.js +428 -0
- package/lib/services/blob.service.js.map +1 -0
- package/lib/services/contributors.d.ts +47 -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 +211 -0
- package/lib/services/cosmos.service.d.ts.map +1 -0
- package/lib/services/cosmos.service.js +554 -0
- package/lib/services/cosmos.service.js.map +1 -0
- package/lib/services/functionserver.service.d.ts +42 -0
- package/lib/services/functionserver.service.d.ts.map +1 -0
- package/lib/services/functionserver.service.js +223 -0
- package/lib/services/functionserver.service.js.map +1 -0
- package/lib/services/keyvault.service.d.ts +91 -0
- package/lib/services/keyvault.service.d.ts.map +1 -0
- package/lib/services/keyvault.service.js +225 -0
- package/lib/services/keyvault.service.js.map +1 -0
- package/lib/services/monitorlogger.service.d.ts +66 -0
- package/lib/services/monitorlogger.service.d.ts.map +1 -0
- package/lib/services/monitorlogger.service.js +131 -0
- package/lib/services/monitorlogger.service.js.map +1 -0
- package/lib/services/servicebus.service.d.ts +128 -0
- package/lib/services/servicebus.service.d.ts.map +1 -0
- package/lib/services/servicebus.service.js +324 -0
- package/lib/services/servicebus.service.js.map +1 -0
- package/lib/template.d.ts +53 -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 +1817 -0
|
@@ -0,0 +1,554 @@
|
|
|
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 { CosmosClient } from "@azure/cosmos";
|
|
36
|
+
import { EventRepository, InstanceCache, MemoryRepository, SecretString, Store, StoreNotFoundError, StoreParameters, UpdateConditionFailError, useModelMetadata, WebdaError } from "@webda/core";
|
|
37
|
+
import * as QL from "@webda/ql";
|
|
38
|
+
import { getAzureCredential, loadAzureParameters } from "./azure-parameters.js";
|
|
39
|
+
import { armLiteral, armValue } from "../template.js";
|
|
40
|
+
/** Cosmos DB NoSQL settings. All models in the store share a typed container. */
|
|
41
|
+
export class CosmosStoreParameters extends StoreParameters {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.partitionKey = "/id";
|
|
45
|
+
this.createIfNotExists = false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Perform load.
|
|
49
|
+
* @override
|
|
50
|
+
*/
|
|
51
|
+
load(params = {}) {
|
|
52
|
+
super.load(params);
|
|
53
|
+
return loadAzureParameters(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Translate the supported WebdaQL filter subset with bound values and quoted field identifiers.
|
|
58
|
+
* @param query - WebdaQL query or parsed filter
|
|
59
|
+
* @returns SQL text and bound parameters
|
|
60
|
+
*/
|
|
61
|
+
export function cosmosQuery(query) {
|
|
62
|
+
const parameters = [];
|
|
63
|
+
const field = (path) => (path[0] === "__type" ? "c" : 'c["value"]') + path.map(part => `[${JSON.stringify(part)}]`).join("");
|
|
64
|
+
const bind = (value) => {
|
|
65
|
+
const name = `@p${parameters.length}`;
|
|
66
|
+
parameters.push({ name, value });
|
|
67
|
+
return name;
|
|
68
|
+
};
|
|
69
|
+
const translate = (expression) => {
|
|
70
|
+
if (expression instanceof QL.BooleanExpression)
|
|
71
|
+
return expression.value ? "true" : "false";
|
|
72
|
+
if (expression instanceof QL.AndExpression || expression instanceof QL.OrExpression) {
|
|
73
|
+
return expression.children.length
|
|
74
|
+
? `(${expression.children.map(translate).join(` ${expression.operator} `)})`
|
|
75
|
+
: expression.operator === "AND"
|
|
76
|
+
? "true"
|
|
77
|
+
: "false";
|
|
78
|
+
}
|
|
79
|
+
if (!(expression instanceof QL.ComparisonExpression))
|
|
80
|
+
throw new WebdaError.NotImplemented("Unsupported Cosmos query expression");
|
|
81
|
+
const attribute = field(expression.attribute), value = expression.value;
|
|
82
|
+
switch (expression.operator) {
|
|
83
|
+
case "=":
|
|
84
|
+
case "!=":
|
|
85
|
+
case ">":
|
|
86
|
+
case ">=":
|
|
87
|
+
case "<":
|
|
88
|
+
case "<=":
|
|
89
|
+
return `${attribute} ${expression.operator} ${bind(value)}`;
|
|
90
|
+
case "IN":
|
|
91
|
+
return `ARRAY_CONTAINS(${bind(value)}, ${attribute})`;
|
|
92
|
+
case "CONTAINS":
|
|
93
|
+
return `ARRAY_CONTAINS(${attribute}, ${bind(value)})`;
|
|
94
|
+
case "LIKE":
|
|
95
|
+
return `${attribute} LIKE ${bind(value)}`;
|
|
96
|
+
case "IS NULL":
|
|
97
|
+
return `(NOT IS_DEFINED(${attribute}) OR IS_NULL(${attribute}))`;
|
|
98
|
+
case "IS NOT NULL":
|
|
99
|
+
return `(IS_DEFINED(${attribute}) AND NOT IS_NULL(${attribute}))`;
|
|
100
|
+
default:
|
|
101
|
+
throw new WebdaError.NotImplemented(`Unsupported Cosmos query operator ${expression.operator}`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const filter = translate(query.filter);
|
|
105
|
+
const order = query.orderBy?.map(item => `${field(item.field.split("."))} ${item.direction}`).join(", ");
|
|
106
|
+
return { query: `SELECT * FROM c WHERE ${filter}${order ? ` ORDER BY ${order}` : ""}`, parameters };
|
|
107
|
+
}
|
|
108
|
+
/** Typed Cosmos repository. A serializer envelope preserves dates, behaviors and concrete model types. */
|
|
109
|
+
export class CosmosRepository extends MemoryRepository {
|
|
110
|
+
/**
|
|
111
|
+
* Initialize the Azure integration.
|
|
112
|
+
* @param model - Model class or model identifier
|
|
113
|
+
* @param pks - Primary key field names
|
|
114
|
+
* @param container - Lazy Cosmos container accessor
|
|
115
|
+
* @param partitionKey - Cosmos partition key path
|
|
116
|
+
* @param separator - Composite primary key separator
|
|
117
|
+
*/
|
|
118
|
+
constructor(model, pks, container, partitionKey = "/id", separator) {
|
|
119
|
+
super(model, pks, separator);
|
|
120
|
+
this.container = container;
|
|
121
|
+
this.partitionKey = partitionKey;
|
|
122
|
+
if (partitionKey !== "/id" &&
|
|
123
|
+
(!/^\/[a-zA-Z]\w*$/.test(partitionKey) ||
|
|
124
|
+
!pks.includes(partitionKey.slice(1)) ||
|
|
125
|
+
["value", "__type", "constructor", "prototype"].includes(partitionKey.slice(1)))) {
|
|
126
|
+
throw new WebdaError.BadRequest("A custom Cosmos partition key must name a top-level primary key field");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Encode the model primary key as a Cosmos item identifier.
|
|
131
|
+
* @param primaryKey - Model primary key
|
|
132
|
+
* @returns The key result
|
|
133
|
+
*/
|
|
134
|
+
key(primaryKey) {
|
|
135
|
+
return Buffer.from(this.getPrimaryKey(primaryKey).toString()).toString("base64url");
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Resolve the partition value from the primary key.
|
|
139
|
+
* @param primaryKey - Model primary key
|
|
140
|
+
* @returns The partition result
|
|
141
|
+
*/
|
|
142
|
+
partition(primaryKey) {
|
|
143
|
+
if (this.partitionKey === "/id")
|
|
144
|
+
return this.key(primaryKey);
|
|
145
|
+
const value = this.getPrimaryKey(primaryKey, true)[this.partitionKey.slice(1)];
|
|
146
|
+
if (!["string", "number", "boolean"].includes(typeof value))
|
|
147
|
+
throw new WebdaError.BadRequest("Cosmos partition key requires a scalar value");
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Address a Cosmos document by its item and partition keys.
|
|
152
|
+
* @param primaryKey - Model primary key
|
|
153
|
+
* @returns The item result
|
|
154
|
+
*/
|
|
155
|
+
item(primaryKey) {
|
|
156
|
+
return this.container().item(this.key(primaryKey), this.partition(primaryKey));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Serialize a model into a typed Cosmos document.
|
|
160
|
+
* @param item - Collection item or model instance
|
|
161
|
+
* @returns The document result
|
|
162
|
+
*/
|
|
163
|
+
document(item) {
|
|
164
|
+
return {
|
|
165
|
+
...JSON.parse(this.serialize(item)),
|
|
166
|
+
id: this.key(item),
|
|
167
|
+
...(this.partitionKey === "/id" ? {} : { [this.partitionKey.slice(1)]: this.partition(item) })
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Restore a typed model from a Cosmos document.
|
|
172
|
+
* @param document - Stored Cosmos document
|
|
173
|
+
* @returns The from document result
|
|
174
|
+
*/
|
|
175
|
+
fromDocument(document) {
|
|
176
|
+
const { id: _id, _etag: _etag, _rid: _rid, _self: _self, _attachments: _attachments, _ts: _ts, ...envelope } = document;
|
|
177
|
+
if (this.partitionKey !== "/id")
|
|
178
|
+
delete envelope[this.partitionKey.slice(1)];
|
|
179
|
+
return this.deserialize(JSON.stringify(envelope));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Map Cosmos storage errors to Webda errors.
|
|
183
|
+
* @param primaryKey - Model primary key
|
|
184
|
+
* @param error - Azure SDK error
|
|
185
|
+
*/
|
|
186
|
+
translateError(primaryKey, error) {
|
|
187
|
+
const code = error.code;
|
|
188
|
+
if (code === 404)
|
|
189
|
+
throw new StoreNotFoundError(primaryKey, this.container().id);
|
|
190
|
+
if (code === 412)
|
|
191
|
+
throw new UpdateConditionFailError(primaryKey, "_etag", "current version");
|
|
192
|
+
if (code === 409)
|
|
193
|
+
throw new WebdaError.Conflict("Cosmos item already exists");
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Read a Cosmos document or raise the store not-found error.
|
|
198
|
+
* @param primaryKey - Model primary key
|
|
199
|
+
* @returns The read result
|
|
200
|
+
*/
|
|
201
|
+
async read(primaryKey) {
|
|
202
|
+
try {
|
|
203
|
+
const { resource } = await this.item(primaryKey).read();
|
|
204
|
+
if (!resource)
|
|
205
|
+
throw new StoreNotFoundError(primaryKey, this.container().id);
|
|
206
|
+
return resource;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
this.translateError(primaryKey, error);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Perform get.
|
|
214
|
+
* @override
|
|
215
|
+
*/
|
|
216
|
+
async get(primaryKey) {
|
|
217
|
+
return this.fromDocument(await this.read(primaryKey));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Perform exists.
|
|
221
|
+
* @override
|
|
222
|
+
*/
|
|
223
|
+
async exists(primaryKey) {
|
|
224
|
+
try {
|
|
225
|
+
await this.read(primaryKey);
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
if (error instanceof StoreNotFoundError)
|
|
230
|
+
return false;
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Perform create.
|
|
236
|
+
* @override
|
|
237
|
+
*/
|
|
238
|
+
async create(data, save = true) {
|
|
239
|
+
const item = this.buildItem(data);
|
|
240
|
+
if (save) {
|
|
241
|
+
try {
|
|
242
|
+
await this.container().items.create(this.document(item));
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
this.translateError(this.getPrimaryKey(item), error);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return item;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validate a write condition against the current document.
|
|
252
|
+
* @param primaryKey - Model primary key
|
|
253
|
+
* @param document - Stored Cosmos document
|
|
254
|
+
* @param field - Conditional write field
|
|
255
|
+
* @param expected - Expected field value
|
|
256
|
+
*/
|
|
257
|
+
checkWriteCondition(primaryKey, document, field, expected) {
|
|
258
|
+
if (!field)
|
|
259
|
+
return;
|
|
260
|
+
const actual = field === "_etag"
|
|
261
|
+
? document._etag
|
|
262
|
+
: field.split(".").reduce((value, key) => value?.[key], this.fromDocument(document));
|
|
263
|
+
if ((actual instanceof Date ? actual.toISOString() : actual) !==
|
|
264
|
+
(expected instanceof Date ? expected.toISOString() : expected)) {
|
|
265
|
+
throw new UpdateConditionFailError(primaryKey, field, expected);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Use the shared model mutation helpers, then submit the complete change atomically under the read ETag.
|
|
270
|
+
* @param primaryKey - Model primary key
|
|
271
|
+
* @param change - Model mutation applied through shared repository helpers
|
|
272
|
+
* @param conditionField - Conditional write field
|
|
273
|
+
* @param condition - Expected write condition
|
|
274
|
+
* @param native - Native atomic Cosmos patch operations
|
|
275
|
+
*/
|
|
276
|
+
async mutate(primaryKey, change, conditionField, condition, native) {
|
|
277
|
+
const original = await this.read(primaryKey);
|
|
278
|
+
this.checkWriteCondition(primaryKey, original, conditionField, condition);
|
|
279
|
+
const key = this.getPrimaryKey(primaryKey).toString();
|
|
280
|
+
const memory = new MemoryRepository(this.model, this.pks, this.separator, new Map([[key, this.serialize(this.fromDocument(original))]]));
|
|
281
|
+
await change(memory);
|
|
282
|
+
const updated = this.document((await memory.get(primaryKey)));
|
|
283
|
+
if (updated.id !== original.id)
|
|
284
|
+
throw new WebdaError.BadRequest("Cannot change a Cosmos primary key");
|
|
285
|
+
const operations = native ?? [];
|
|
286
|
+
const path = (name) => `/value/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
287
|
+
if (!native) {
|
|
288
|
+
for (const [name, value] of Object.entries(updated.value)) {
|
|
289
|
+
if (JSON.stringify(value) !== JSON.stringify(original.value[name]))
|
|
290
|
+
operations.push({ op: "set", path: path(name), value });
|
|
291
|
+
}
|
|
292
|
+
for (const name of Object.keys(original.value))
|
|
293
|
+
if (!(name in updated.value))
|
|
294
|
+
operations.push({ op: "remove", path: path(name) });
|
|
295
|
+
}
|
|
296
|
+
if (JSON.stringify(updated.$serializer) !== JSON.stringify(original.$serializer))
|
|
297
|
+
operations.push({ op: "set", path: "/$serializer", value: updated.$serializer });
|
|
298
|
+
if (!operations.length)
|
|
299
|
+
return;
|
|
300
|
+
if (operations.length > 10)
|
|
301
|
+
throw new WebdaError.BadRequest("Cosmos supports at most ten atomic patch operations; use update() for larger changes");
|
|
302
|
+
try {
|
|
303
|
+
await this.item(primaryKey).patch(operations, {
|
|
304
|
+
accessCondition: { type: "IfMatch", condition: original._etag }
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
this.translateError(primaryKey, error);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Perform update.
|
|
313
|
+
* @override
|
|
314
|
+
*/
|
|
315
|
+
async update(data, conditionField, condition) {
|
|
316
|
+
const original = await this.read(data);
|
|
317
|
+
this.checkWriteCondition(data, original, conditionField, condition);
|
|
318
|
+
const existing = this.fromDocument(original);
|
|
319
|
+
const clazz = (data instanceof this.model ? data.constructor : existing.constructor);
|
|
320
|
+
const memory = new MemoryRepository(clazz, this.pks, this.separator);
|
|
321
|
+
const replacement = this.document((await memory.create(data, false)));
|
|
322
|
+
if (replacement.id !== original.id)
|
|
323
|
+
throw new WebdaError.BadRequest("Cannot change a Cosmos primary key");
|
|
324
|
+
try {
|
|
325
|
+
await this.item(data).replace(replacement, { accessCondition: { type: "IfMatch", condition: original._etag } });
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
this.translateError(data, error);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Perform patch.
|
|
333
|
+
* @override
|
|
334
|
+
*/
|
|
335
|
+
async patch(primaryKey, data, field, expected) {
|
|
336
|
+
const key = this.getPrimaryKey(primaryKey, true);
|
|
337
|
+
if (this.pks.some(name => Object.prototype.hasOwnProperty.call(data, name) && data[name] !== key[name])) {
|
|
338
|
+
throw new WebdaError.BadRequest("Cannot change a Cosmos primary key");
|
|
339
|
+
}
|
|
340
|
+
await this.mutate(primaryKey, repo => repo.patch(primaryKey, data), field, expected);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Perform delete.
|
|
344
|
+
* @override
|
|
345
|
+
*/
|
|
346
|
+
async delete(primaryKey, field, expected) {
|
|
347
|
+
const original = await this.read(primaryKey);
|
|
348
|
+
this.checkWriteCondition(primaryKey, original, field, expected);
|
|
349
|
+
try {
|
|
350
|
+
await this.item(primaryKey).delete({ accessCondition: { type: "IfMatch", condition: original._etag } });
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
this.translateError(primaryKey, error);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Perform remove attribute.
|
|
358
|
+
* @override
|
|
359
|
+
*/
|
|
360
|
+
async removeAttribute(primaryKey, attribute, field, expected) {
|
|
361
|
+
await this.mutate(primaryKey, repo => repo.removeAttribute(primaryKey, attribute), field, expected);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Perform increment attributes.
|
|
365
|
+
* @override
|
|
366
|
+
*/
|
|
367
|
+
async incrementAttributes(primaryKey, info, field, expected) {
|
|
368
|
+
const entries = Array.isArray(info)
|
|
369
|
+
? info.map(entry => (typeof entry === "string" ? [entry, 1] : [entry.property, entry.value ?? 1]))
|
|
370
|
+
: Object.entries(info);
|
|
371
|
+
const operations = entries.map(([property, value]) => {
|
|
372
|
+
if (!Number.isFinite(value) ||
|
|
373
|
+
property.split(".").some(part => ["__proto__", "constructor", "prototype"].includes(part)))
|
|
374
|
+
throw new WebdaError.BadRequest("Invalid Cosmos increment");
|
|
375
|
+
return {
|
|
376
|
+
op: "incr",
|
|
377
|
+
path: "/value/" +
|
|
378
|
+
property
|
|
379
|
+
.split(".")
|
|
380
|
+
.map(part => part.replace(/~/g, "~0").replace(/\//g, "~1"))
|
|
381
|
+
.join("/"),
|
|
382
|
+
value
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
let updated = {};
|
|
386
|
+
await this.mutate(primaryKey, async (repo) => {
|
|
387
|
+
updated = (await repo.incrementAttributes(primaryKey, info));
|
|
388
|
+
}, field, expected, operations);
|
|
389
|
+
return updated;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Perform upsert item to collection.
|
|
393
|
+
* @override
|
|
394
|
+
*/
|
|
395
|
+
async upsertItemToCollection(primaryKey, collection, item, index, field, expected) {
|
|
396
|
+
await this.mutate(primaryKey, repo => repo.upsertItemToCollection(primaryKey, collection, item, index, field, expected));
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Perform delete item from collection.
|
|
400
|
+
* @override
|
|
401
|
+
*/
|
|
402
|
+
async deleteItemFromCollection(primaryKey, collection, index, field, expected) {
|
|
403
|
+
await this.mutate(primaryKey, repo => repo.deleteItemFromCollection(primaryKey, collection, index, field, expected));
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Perform query.
|
|
407
|
+
* @override
|
|
408
|
+
*/
|
|
409
|
+
async query(query, params) {
|
|
410
|
+
const parsed = typeof query === "string" ? QL.parse(params ? QL.bind(query, params) : query) : QL.normalizeQuery(query);
|
|
411
|
+
QL.assertFilterQuery(parsed);
|
|
412
|
+
const types = this.acceptedTypes();
|
|
413
|
+
if (types.length)
|
|
414
|
+
parsed.filter = new QL.AndExpression([new QL.ComparisonExpression("IN", "__type", types), parsed.filter]);
|
|
415
|
+
const result = await this.container()
|
|
416
|
+
.items.query(cosmosQuery(parsed), {
|
|
417
|
+
maxItemCount: parsed.limit,
|
|
418
|
+
continuationToken: parsed.continuationToken
|
|
419
|
+
})
|
|
420
|
+
.fetchNext();
|
|
421
|
+
return {
|
|
422
|
+
results: result.resources.map(document => this.fromDocument(document)),
|
|
423
|
+
continuationToken: result.continuationToken
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Perform iterate.
|
|
428
|
+
* @override
|
|
429
|
+
*/
|
|
430
|
+
async *iterate(query, params) {
|
|
431
|
+
const parsed = QL.parse(params ? QL.bind(query, params) : query);
|
|
432
|
+
do {
|
|
433
|
+
const page = await this.query(parsed);
|
|
434
|
+
yield* page.results;
|
|
435
|
+
parsed.continuationToken = page.continuationToken;
|
|
436
|
+
} while (parsed.continuationToken);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Perform delete many.
|
|
440
|
+
* @override
|
|
441
|
+
*/
|
|
442
|
+
async deleteMany() {
|
|
443
|
+
throw new WebdaError.NotImplemented("Cosmos bulk delete is not supported");
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Perform update many.
|
|
447
|
+
* @override
|
|
448
|
+
*/
|
|
449
|
+
async updateMany() {
|
|
450
|
+
throw new WebdaError.NotImplemented("Cosmos bulk update is not supported");
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/** Cosmos DB NoSQL store using optimistic ETags and atomic document patches.
|
|
454
|
+
* @WebdaModda
|
|
455
|
+
*/
|
|
456
|
+
let CosmosStore = (() => {
|
|
457
|
+
var _a;
|
|
458
|
+
let _classSuper = Store;
|
|
459
|
+
let _instanceExtraInitializers = [];
|
|
460
|
+
let _getRepository_decorators;
|
|
461
|
+
return _a = class CosmosStore extends _classSuper {
|
|
462
|
+
constructor() {
|
|
463
|
+
super(...arguments);
|
|
464
|
+
this.client = __runInitializers(this, _instanceExtraInitializers);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Perform init.
|
|
468
|
+
* @override
|
|
469
|
+
*/
|
|
470
|
+
async init() {
|
|
471
|
+
const p = this.parameters;
|
|
472
|
+
this.client = new CosmosClient({
|
|
473
|
+
endpoint: p.endpoint,
|
|
474
|
+
...(p.key !== undefined ? { key: SecretString.from(p.key, "key") } : { aadCredentials: getAzureCredential(p) })
|
|
475
|
+
});
|
|
476
|
+
if (p.createIfNotExists) {
|
|
477
|
+
await this.client.databases.createIfNotExists({ id: p.database });
|
|
478
|
+
await this.client
|
|
479
|
+
.database(p.database)
|
|
480
|
+
.containers.createIfNotExists({ id: p.container, partitionKey: { paths: [p.partitionKey] } }, { offerThroughput: p.throughput });
|
|
481
|
+
}
|
|
482
|
+
await super.init();
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Perform get repository.
|
|
487
|
+
* @override
|
|
488
|
+
*/
|
|
489
|
+
getRepository(model) {
|
|
490
|
+
const meta = useModelMetadata(model);
|
|
491
|
+
const repository = new CosmosRepository(model, meta.PrimaryKey, () => this.client.database(this.parameters.database).container(this.parameters.container), this.parameters.partitionKey, meta.PrimaryKeySeparator);
|
|
492
|
+
return new EventRepository(model, meta.PrimaryKey, repository, meta.PrimaryKeySeparator);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Perform stop.
|
|
496
|
+
* @override
|
|
497
|
+
*/
|
|
498
|
+
async stop() {
|
|
499
|
+
this.client?.dispose();
|
|
500
|
+
await super.stop();
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Describe the Azure resources and identity permissions required by this service.
|
|
504
|
+
* @param deployer - Deployment scope and identity helpers
|
|
505
|
+
* @returns The azure resources result
|
|
506
|
+
*/
|
|
507
|
+
getAzureResources(deployer) {
|
|
508
|
+
const p = this.parameters, account = new URL(p.endpoint).hostname.split(".")[0];
|
|
509
|
+
const accountId = `/subscriptions/${deployer.resources.subscriptionId}/resourceGroups/${deployer.resources.resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${account}`;
|
|
510
|
+
const databaseId = `${accountId}/sqlDatabases/${p.database}`;
|
|
511
|
+
return {
|
|
512
|
+
resources: [
|
|
513
|
+
{
|
|
514
|
+
type: "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
|
|
515
|
+
apiVersion: "2024-11-15",
|
|
516
|
+
name: `${account}/${p.database}`,
|
|
517
|
+
properties: { resource: { id: p.database } }
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
type: "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
|
|
521
|
+
apiVersion: "2024-11-15",
|
|
522
|
+
name: `${account}/${p.database}/${p.container}`,
|
|
523
|
+
dependsOn: [databaseId],
|
|
524
|
+
properties: {
|
|
525
|
+
resource: { id: p.container, partitionKey: { paths: [p.partitionKey], kind: "Hash" } },
|
|
526
|
+
options: p.throughput ? { throughput: p.throughput } : {}
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
type: "Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments",
|
|
531
|
+
apiVersion: "2024-11-15",
|
|
532
|
+
name: `[concat(${armLiteral(`${account}/`)}, guid(${armLiteral(accountId)}, ${armLiteral(`${p.database}/${p.container}`)}, ${armValue(deployer.getAppPrincipalId())}))]`,
|
|
533
|
+
dependsOn: [`${databaseId}/containers/${p.container}`],
|
|
534
|
+
properties: {
|
|
535
|
+
roleDefinitionId: `${accountId}/sqlRoleDefinitions/00000000-0000-0000-0000-000000000002`,
|
|
536
|
+
scope: `${accountId}/dbs/${p.database}/colls/${p.container}`,
|
|
537
|
+
principalId: deployer.getAppPrincipalId()
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
]
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
(() => {
|
|
545
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
546
|
+
_getRepository_decorators = [InstanceCache()];
|
|
547
|
+
__esDecorate(_a, null, _getRepository_decorators, { kind: "method", name: "getRepository", static: false, private: false, access: { has: obj => "getRepository" in obj, get: obj => obj.getRepository }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
548
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
549
|
+
})(),
|
|
550
|
+
_a.Parameters = CosmosStoreParameters,
|
|
551
|
+
_a;
|
|
552
|
+
})();
|
|
553
|
+
export { CosmosStore };
|
|
554
|
+
//# sourceMappingURL=cosmos.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosmos.service.js","sources":["../../src/services/cosmos.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAa,YAAY,EAAgC,MAAM,eAAe,CAA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,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;gCACtF,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE;6BAC1D;yBACF;wBACD;4BACE,IAAI,EAAE,0DAA0D;4BAChE,UAAU,EAAE,YAAY;4BACxB,IAAI,EAAE,WAAW,UAAU,CAAC,GAAG,OAAO,GAAG,CAAC,UAAU,UAAU,CAAC,SAAS,CAAC,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KAAK;4BACxK,SAAS,EAAE,CAAC,GAAG,UAAU,eAAe,CAAC,CAAC,SAAS,EAAE,CAAC;4BACtD,UAAU,EAAE;gCACV,gBAAgB,EAAE,GAAG,SAAS,0DAA0D;gCACxF,KAAK,EAAE,GAAG,SAAS,QAAQ,CAAC,CAAC,QAAQ,UAAU,CAAC,CAAC,SAAS,EAAE;gCAC5D,WAAW,EAAE,QAAQ,CAAC,iBAAiB,EAAE;6BAC1C;yBACF;qBACF;iBACF,CAAC;YACJ,CAAC;;;;yCApEA,aAAa,EAAE;YAChB,wLAAA,aAAa,6DAeZ;;;QA9CM,aAAU,GAAG,qBAAsB;;;SAD/B,WAAW"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";
|
|
2
|
+
import { Service, ServiceParameters } from "@webda/core";
|
|
3
|
+
/** Non-HTTP bindings dispatch to services implementing this contract. */
|
|
4
|
+
export interface AzureEventsHandler {
|
|
5
|
+
handleAzureEvent(source: "servicebus" | "blob" | "timer", event: unknown, context: InvocationContext): Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
/** Azure Functions HTTP adapter settings. */
|
|
8
|
+
export declare class AzureFunctionServerParameters extends ServiceParameters {
|
|
9
|
+
requestIdHeader: string;
|
|
10
|
+
}
|
|
11
|
+
/** Run Webda routes and event handlers inside the Azure Functions v4 runtime.
|
|
12
|
+
* @WebdaModda
|
|
13
|
+
*/
|
|
14
|
+
export declare class AzureFunctionServer extends Service<AzureFunctionServerParameters> {
|
|
15
|
+
static Parameters: typeof AzureFunctionServerParameters;
|
|
16
|
+
/**
|
|
17
|
+
* Execute an Azure HTTP request through the Webda router.
|
|
18
|
+
* @param request - Azure Functions HTTP request
|
|
19
|
+
* @param invocation - Azure invocation metadata
|
|
20
|
+
* @returns The handle request result
|
|
21
|
+
*/
|
|
22
|
+
handleRequest(request: HttpRequest, invocation: InvocationContext): Promise<HttpResponseInit>;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the client address from the rightmost X-Forwarded-For entry, without any port. Never throws.
|
|
25
|
+
* @param headers - the request headers
|
|
26
|
+
* @returns the address, undefined if unknown or invalid
|
|
27
|
+
*/
|
|
28
|
+
protected getClientIp(headers: Record<string, string>): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Dispatch an Azure binding event to configured handler services.
|
|
31
|
+
* @param source - Azure binding event source
|
|
32
|
+
* @param event - Received event payload
|
|
33
|
+
* @param context - Webda or Azure invocation context
|
|
34
|
+
*/
|
|
35
|
+
handleEvent(source: "servicebus" | "blob" | "timer", event: unknown, context: InvocationContext): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Execute only the declared cron matching the exported identifier, through its operation
|
|
38
|
+
* @param id - Secret name or exported cron identifier
|
|
39
|
+
*/
|
|
40
|
+
handleCron(id: string): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=functionserver.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functionserver.service.d.ts","sources":["../../src/services/functionserver.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIzF,OAAO,EAML,OAAO,EACP,iBAAiB,EAMlB,MAAM,aAAa,CAAC;AAErB,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,CACd,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,EACvC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,6CAA6C;AAC7C,qBAAa,6BAA8B,SAAQ,iBAAiB;IAClE,eAAe,SAAkB;CAClC;AA6DD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,OAAO,CAAC,6BAA6B,CAAC;IAC7E,MAAM,CAAC,UAAU,uCAAiC;IAElD;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoGlG;IAED;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAiBzE;IAED;;;;;OAKG;IACG,WAAW,CACf,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,OAAO,EACvC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CASf;IAED;;;OAGG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;CACF"}
|