@geolonia/geonicdb-sdk 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -12
- package/geonicdb.cjs +43 -11
- package/geonicdb.cjs.map +2 -2
- package/geonicdb.d.ts +155 -14
- package/geonicdb.iife.js +43 -11
- package/geonicdb.iife.js.map +2 -2
- package/geonicdb.mjs +43 -11
- package/geonicdb.mjs.map +2 -2
- package/package.json +1 -1
- package/react/index.d.ts +156 -15
package/geonicdb.d.ts
CHANGED
|
@@ -103,6 +103,12 @@ export interface GetEntitiesParams {
|
|
|
103
103
|
geometry?: string;
|
|
104
104
|
/** Coordinates string (semicolon-delimited pairs or flat comma-separated) */
|
|
105
105
|
coordinates?: string;
|
|
106
|
+
/**
|
|
107
|
+
* 多重属性のインスタンス絞り込み (`datasetId` クエリ、ETSI GS CIM 009 clause 4.5.5.1)。
|
|
108
|
+
* カンマ区切りで複数指定可。既定インスタンスは `@none`。一致が 1 件なら単一要素、
|
|
109
|
+
* 0 件ならその属性は応答から落ちる。
|
|
110
|
+
*/
|
|
111
|
+
datasetId?: string;
|
|
106
112
|
/** Comma-separated attribute names to retrieve */
|
|
107
113
|
attrs?: string;
|
|
108
114
|
/** Comma-separated attribute names to keep (alternative to attrs) */
|
|
@@ -124,13 +130,24 @@ export interface GetEntitiesParams {
|
|
|
124
130
|
/**
|
|
125
131
|
* NGSI-LD representation options (`options` query param)。カンマ区切りで複数指定可。
|
|
126
132
|
* - `sysAttrs` — システム属性 (`createdAt` / `modifiedAt`) を含める
|
|
127
|
-
* - `keyValues` — 簡易表現 (属性を値だけに圧縮)
|
|
133
|
+
* - `keyValues` — 簡易表現 (属性を値だけに圧縮)。多重属性 (`datasetId` 付きインスタンス) は
|
|
134
|
+
* 一致が複数のときだけ `dataset` マップになる (既定インスタンスのキーは `@none`)。
|
|
135
|
+
* 1 件なら素の値 (ETSI GS CIM 009 clause 4.5.4 / 4.5.5.1)
|
|
128
136
|
* - `concise` — concise 表現
|
|
129
137
|
* - `normalized` — 正規化表現 (デフォルト)
|
|
130
138
|
*
|
|
131
139
|
* 例: `'sysAttrs'`, `'keyValues,sysAttrs'`。
|
|
132
140
|
*/
|
|
133
141
|
options?: string;
|
|
142
|
+
/**
|
|
143
|
+
* ローカルスコープに限定する (`local` クエリパラメータ、ETSI GS CIM 009 clause 5.5.13 / Table 6.3.18-1)。
|
|
144
|
+
*
|
|
145
|
+
* **#2278**: `GET /ngsi-ld/v1/entities` は clause 5.7.2.4 により
|
|
146
|
+
* `type` / `attrs` (非システム属性を含む) / `q` (非システム属性を含む) / geoquery / local scope の
|
|
147
|
+
* いずれかを必須とする。**絞り込み無しで全件を取りたい場合は `local: true` を指定する**
|
|
148
|
+
* (指定しないと `400 BadRequestData` = too wide query)。
|
|
149
|
+
*/
|
|
150
|
+
local?: boolean;
|
|
134
151
|
}
|
|
135
152
|
/** Parameters for counting entities. */
|
|
136
153
|
export interface CountEntitiesParams {
|
|
@@ -140,15 +157,42 @@ export interface CountEntitiesParams {
|
|
|
140
157
|
q?: string;
|
|
141
158
|
/** NGSI-LD scope query expression (#1132) */
|
|
142
159
|
scopeQ?: string;
|
|
160
|
+
/**
|
|
161
|
+
* ローカルスコープに限定する (`local` クエリパラメータ、ETSI GS CIM 009 clause 5.5.13 / Table 6.3.18-1)。
|
|
162
|
+
*
|
|
163
|
+
* **#2278**: `GET /ngsi-ld/v1/entities` は clause 5.7.2.4 により
|
|
164
|
+
* `type` / `attrs` (非システム属性を含む) / `q` (非システム属性を含む) / geoquery / local scope の
|
|
165
|
+
* いずれかを必須とする。**絞り込み無しで全件を取りたい場合は `local: true` を指定する**
|
|
166
|
+
* (指定しないと `400 BadRequestData` = too wide query)。
|
|
167
|
+
*/
|
|
168
|
+
local?: boolean;
|
|
143
169
|
}
|
|
144
170
|
/** Options for subscribing to entity events via WebSocket. */
|
|
145
171
|
export interface SubscribeOptions {
|
|
146
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Entity types to subscribe to.
|
|
174
|
+
*
|
|
175
|
+
* **#2055.** Matched against the canonical stored form: the supplied `@context` is
|
|
176
|
+
* resolved once at `subscribe` time and these names are expanded before matching,
|
|
177
|
+
* so a term defined by a custom `@context` changes which entities match.
|
|
178
|
+
*/
|
|
147
179
|
entityTypes?: string[];
|
|
148
|
-
/** Entity ID regex pattern */
|
|
180
|
+
/** Entity ID regex pattern. Matched against the stored form verbatim (no `@context` expansion). */
|
|
149
181
|
idPattern?: string;
|
|
150
182
|
/** NGSI-LD scope query expression (#1132). Server-side filter; only events whose entity scope matches are delivered. */
|
|
151
183
|
scopeQ?: string;
|
|
184
|
+
/**
|
|
185
|
+
* JSON-LD `@context` used to render delivered events (#2026).
|
|
186
|
+
*
|
|
187
|
+
* The entity type and attribute names are compacted against it (ETSI GS CIM 009 clause 5.5.7)
|
|
188
|
+
* and the value is echoed back in each event's `@context`. Omit for the core `@context`.
|
|
189
|
+
* URL string / array of URL strings only — inline context objects are rejected.
|
|
190
|
+
*
|
|
191
|
+
* **#2055: it also governs `entityTypes` matching** — the context is resolved once at
|
|
192
|
+
* `subscribe` time to expand `entityTypes` into the canonical stored form. `idPattern`
|
|
193
|
+
* alone is matched against the stored form verbatim.
|
|
194
|
+
*/
|
|
195
|
+
"@context"?: string | string[];
|
|
152
196
|
}
|
|
153
197
|
/** Entity event received via WebSocket. */
|
|
154
198
|
export interface EntityEvent {
|
|
@@ -160,14 +204,20 @@ export interface EntityEvent {
|
|
|
160
204
|
servicePath: string;
|
|
161
205
|
/** Entity ID */
|
|
162
206
|
entityId: string;
|
|
163
|
-
/** Entity type */
|
|
207
|
+
/** Entity type, compacted with the subscription `@context` (#2026) */
|
|
164
208
|
entityType: string;
|
|
165
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* Entity attributes in NGSI-LD normalized representation (clause 4.5.2, #2026 / #2044).
|
|
211
|
+
* Attribute names are compacted with the subscription `@context`; sub-attributes are inline;
|
|
212
|
+
* multi-attributes appear as an instance array carrying `datasetId` (clause 4.5.5).
|
|
213
|
+
*/
|
|
166
214
|
data: Record<string, unknown>;
|
|
167
215
|
/** Complete NGSI-LD entity (id + type + attributes from data). Undefined when data is unavailable (e.g. some delete events). */
|
|
168
216
|
entity?: Record<string, unknown>;
|
|
169
217
|
/** Changed attribute names (update only) */
|
|
170
218
|
changedAttributes?: string[];
|
|
219
|
+
/** Vocabulary the names in this event were rendered with (#2026) */
|
|
220
|
+
"@context"?: string | string[];
|
|
171
221
|
/** ISO 8601 timestamp */
|
|
172
222
|
timestamp: string;
|
|
173
223
|
}
|
|
@@ -235,6 +285,14 @@ export interface GeonicDBEventMap {
|
|
|
235
285
|
};
|
|
236
286
|
disconnected: undefined;
|
|
237
287
|
reconnecting: ReconnectingEvent;
|
|
288
|
+
/**
|
|
289
|
+
* #2055: 購読フィルタがサーバ側で有効になった (`{"type":"subscribed"}` の受信)。
|
|
290
|
+
*
|
|
291
|
+
* `subscribe()` の適用は非同期 — サーバは渡された `@context` を解決して `entityTypes` を
|
|
292
|
+
* 照合用の canonical 形へ展開する (ETSI GS CIM 009 clause 5.5.7)。このイベントより前に
|
|
293
|
+
* 発生した更新は配信が保証されない。
|
|
294
|
+
*/
|
|
295
|
+
subscribed: undefined;
|
|
238
296
|
error: Error;
|
|
239
297
|
message: Record<string, unknown>;
|
|
240
298
|
tokenRefresh: RefreshedCredentials;
|
|
@@ -273,13 +331,70 @@ export interface GetTemporalEntitiesParams {
|
|
|
273
331
|
offset?: number;
|
|
274
332
|
/**
|
|
275
333
|
* NGSI-LD representation options (`options` query param)。カンマ区切りで複数指定可。
|
|
276
|
-
* - `sysAttrs` — システム属性 (`createdAt` / `modifiedAt`) を含める
|
|
277
334
|
* - `temporalValues` — 時系列を簡易配列表現で返す
|
|
278
|
-
* - `
|
|
335
|
+
* - `simplified` — `temporalValues` の同義語 (GeonicDB 拡張)
|
|
336
|
+
* - `aggregatedValues` — 集約表現で返す (ETSI clause 4.5.19 の「メソッド名をキー +
|
|
337
|
+
* [値, 開始, 終了] の 3 要素配列」形。#1815 で独自形から是正)
|
|
338
|
+
* - `sysAttrs` — システム時相属性 (`createdAt` / `modifiedAt`、TTL 設定時は `expiresAt`) を
|
|
339
|
+
* normalized 表現の各インスタンスへ含める (ETSI 6.3.11、#1817)。簡易表現・集約表現には
|
|
340
|
+
* 載せる場所が無いため受理して無視される (400 にはならない)
|
|
279
341
|
*
|
|
280
|
-
*
|
|
342
|
+
* 注:
|
|
343
|
+
* - この SDK では `aggregatedValues` は `options` で指定し、`aggrMethods` との併用が必須
|
|
344
|
+
* - サーバ側では `format=aggregatedValues` に対しても同じ必須条件が適用される
|
|
345
|
+
* - `options` は ETSI 6.3.12 で deprecated。`format` を併用した場合は **`format` が優先される**
|
|
346
|
+
*
|
|
347
|
+
* 例: `'temporalValues'`, `'aggregatedValues'`。
|
|
281
348
|
*/
|
|
282
349
|
options?: string;
|
|
350
|
+
/**
|
|
351
|
+
* #1814: 表現形式 (`format` query param、ETSI GS CIM 009 clause 6.3.12)。
|
|
352
|
+
* `'temporalValues'` / `'aggregatedValues'` のいずれか (`'simplified'` は `'temporalValues'` の
|
|
353
|
+
* 別名として受理される GeonicDB 拡張)。**未知値はサーバが 400 InvalidRequest で拒否する。**
|
|
354
|
+
* `options` と併用した場合は **`format` が優先される**。
|
|
355
|
+
*
|
|
356
|
+
* SDK は npm 向けに単独ビルドされ本体の `@config/defaults` を import しないため、
|
|
357
|
+
* 許可値はここでリテラル union として持つ。**本体の
|
|
358
|
+
* `NGSI_LD.TEMPORAL_REPRESENTATION_FORMATS` を変えたらこの union も同期すること**
|
|
359
|
+
* (SDK Consistency)。
|
|
360
|
+
*/
|
|
361
|
+
format?: "temporalValues" | "aggregatedValues" | "simplified";
|
|
362
|
+
/**
|
|
363
|
+
* #1815: 集約メソッド (カンマ区切り)。`totalCount` / `distinctCount` / `sum` / `avg` / `min` /
|
|
364
|
+
* `max` / `stddev` / `sumsq`。`aggregatedValues` を `format` か `options` で指定する場合は必須。
|
|
365
|
+
* 応答は clause 4.5.19 形 (メソッド名がキー、各期間は `[値, 開始, 終了]` の 3 要素配列)。
|
|
366
|
+
*/
|
|
367
|
+
aggrMethods?: string;
|
|
368
|
+
/**
|
|
369
|
+
* 集約期間 (ISO 8601 duration。例 `'PT1H'`)。
|
|
370
|
+
* ETSI GS CIM 009 Table 5.2.21-1 の cardinality は 0..1 で**任意**。省略時は `PT0S` として
|
|
371
|
+
* 扱われ、クエリの時間範囲全体が 1 期間として集約される (clause 4.5.19.1)。
|
|
372
|
+
*/
|
|
373
|
+
aggrPeriodDuration?: string;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* `GET /ngsi-ld/v1/types`(`details` 未指定)のレスポンス。
|
|
377
|
+
* ETSI GS CIM 009 / OpenAPI v1.8.1 の `EntityTypeList`(5.2.24)。
|
|
378
|
+
* `details=true` の場合は代わりに `EntityType` の配列が返る(本 SDK では未対応)。
|
|
379
|
+
*/
|
|
380
|
+
export interface EntityTypeList {
|
|
381
|
+
id: string;
|
|
382
|
+
type: "EntityTypeList";
|
|
383
|
+
/** 利用可能なエンティティ型名の配列 */
|
|
384
|
+
typeList: string[];
|
|
385
|
+
"@context"?: string | string[];
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* `GET /ngsi-ld/v1/attributes`(`details` 未指定)のレスポンス。
|
|
389
|
+
* ETSI GS CIM 009 / OpenAPI v1.8.1 の `AttributeList`(5.2.27)。
|
|
390
|
+
* `details=true` の場合は代わりに `Attribute` の配列が返る(本 SDK では未対応)。
|
|
391
|
+
*/
|
|
392
|
+
export interface AttributeList {
|
|
393
|
+
id: string;
|
|
394
|
+
type: "AttributeList";
|
|
395
|
+
/** 利用可能な属性名の配列 */
|
|
396
|
+
attributeList: string[];
|
|
397
|
+
"@context"?: string | string[];
|
|
283
398
|
}
|
|
284
399
|
export type Listener<T> = (data: T) => void;
|
|
285
400
|
declare class EventEmitter {
|
|
@@ -478,12 +593,24 @@ export declare class GeonicDB extends EventEmitter {
|
|
|
478
593
|
deleteEntity(entityId: string): Promise<{
|
|
479
594
|
deleted: true;
|
|
480
595
|
}>;
|
|
481
|
-
/**
|
|
482
|
-
|
|
596
|
+
/**
|
|
597
|
+
* List all entity types.
|
|
598
|
+
*
|
|
599
|
+
* `details` 未指定の `GET /types` は ETSI OpenAPI v1.8.1 準拠の
|
|
600
|
+
* `EntityTypeList` オブジェクト(`{ id, type: 'EntityTypeList', typeList }`)を返す。
|
|
601
|
+
* 型名の一覧は `typeList` から取得する。
|
|
602
|
+
*/
|
|
603
|
+
getTypes(): Promise<EntityTypeList>;
|
|
483
604
|
/** Get details for a specific entity type. */
|
|
484
605
|
getType(typeName: string): Promise<Record<string, unknown>>;
|
|
485
|
-
/**
|
|
486
|
-
|
|
606
|
+
/**
|
|
607
|
+
* List all attributes.
|
|
608
|
+
*
|
|
609
|
+
* `details` 未指定の `GET /attributes` は ETSI OpenAPI v1.8.1 準拠の
|
|
610
|
+
* `AttributeList` オブジェクト(`{ id, type: 'AttributeList', attributeList }`)を返す。
|
|
611
|
+
* 属性名の一覧は `attributeList` から取得する。
|
|
612
|
+
*/
|
|
613
|
+
getAttributes(): Promise<AttributeList>;
|
|
487
614
|
/** Get details for a specific attribute. */
|
|
488
615
|
getAttribute(attrName: string): Promise<Record<string, unknown>>;
|
|
489
616
|
/** Query temporal entities. */
|
|
@@ -492,8 +619,22 @@ export declare class GeonicDB extends EventEmitter {
|
|
|
492
619
|
getTemporalEntity(entityId: string): Promise<Record<string, unknown>>;
|
|
493
620
|
/** Create multiple entities in a single request. */
|
|
494
621
|
batchCreate(entities: Record<string, unknown>[]): Promise<Record<string, unknown>>;
|
|
495
|
-
/**
|
|
496
|
-
|
|
622
|
+
/**
|
|
623
|
+
* Upsert multiple entities in a single request.
|
|
624
|
+
*
|
|
625
|
+
* #1742: the server follows ETSI GS CIM 009 clause 5.6.8.5 / Table 6.15.3.1-1:
|
|
626
|
+
* - **201** with a `string[]` of the **created** entity IDs, when at least one entity
|
|
627
|
+
* was newly created and none failed (merely updated entities are not listed);
|
|
628
|
+
* - **204** with no body, when every entity already existed and was updated
|
|
629
|
+
* (`_jsonPost` maps this to `{}`);
|
|
630
|
+
* - **207** with a `BatchOperationResult` (`{ created, updated, errors }`), on partial
|
|
631
|
+
* or total failure.
|
|
632
|
+
*
|
|
633
|
+
* The return type reflects all three shapes. Narrow with `Array.isArray(result)` to
|
|
634
|
+
* detect the "something was created" case.
|
|
635
|
+
* https://cim.etsi.org/NGSI-LD/official/clause-6.html
|
|
636
|
+
*/
|
|
637
|
+
batchUpsert(entities: Record<string, unknown>[]): Promise<string[] | Record<string, unknown>>;
|
|
497
638
|
/** Update multiple entities in a single request. */
|
|
498
639
|
batchUpdate(entities: Record<string, unknown>[]): Promise<Record<string, unknown>>;
|
|
499
640
|
/** Delete multiple entities by ID. */
|
package/geonicdb.iife.js
CHANGED
|
@@ -82,7 +82,7 @@ var GeonicDBModule = (() => {
|
|
|
82
82
|
var RECONNECT_BASE_MS = 1e3;
|
|
83
83
|
var RECONNECT_MAX_DELAY_MS = 3e4;
|
|
84
84
|
var SUB_PROTOCOL = "access_token";
|
|
85
|
-
var NGSI_LD_CORE_CONTEXT = "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld";
|
|
85
|
+
var NGSI_LD_CORE_CONTEXT = "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.9.jsonld";
|
|
86
86
|
var SDK_CACHE_MAX_ENTRIES_DEFAULT = 1e3;
|
|
87
87
|
var SDK_POLL_INTERVAL_MS_DEFAULT = 5e3;
|
|
88
88
|
var DPOP_IDB_NAME = "geonicdb-sdk";
|
|
@@ -1246,13 +1246,12 @@ var GeonicDBModule = (() => {
|
|
|
1246
1246
|
}
|
|
1247
1247
|
const url = this._baseUrl + path;
|
|
1248
1248
|
const isDPoP = this._tokenType === "DPoP" && !!this._dpopKeyPair && token !== null;
|
|
1249
|
-
const
|
|
1249
|
+
const pathname = path.split("?")[0];
|
|
1250
|
+
const isNgsiLdWrite = pathname.startsWith("/ngsi-ld/v1/") && pathname !== "/ngsi-ld/v1/jsonldContexts";
|
|
1251
|
+
const withCoreContext = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !("@context" in value) ? { ...value, "@context": NGSI_LD_CORE_CONTEXT } : value;
|
|
1250
1252
|
let effectiveBody = body;
|
|
1251
|
-
if (
|
|
1252
|
-
effectiveBody =
|
|
1253
|
-
...effectiveBody,
|
|
1254
|
-
"@context": NGSI_LD_CORE_CONTEXT
|
|
1255
|
-
};
|
|
1253
|
+
if (isNgsiLdWrite && effectiveBody !== void 0) {
|
|
1254
|
+
effectiveBody = Array.isArray(effectiveBody) ? effectiveBody.map(withCoreContext) : withCoreContext(effectiveBody);
|
|
1256
1255
|
}
|
|
1257
1256
|
const bodyStr = effectiveBody !== void 0 ? JSON.stringify(effectiveBody) : void 0;
|
|
1258
1257
|
const doRequest = async (reqToken, dpopNonce) => {
|
|
@@ -1398,6 +1397,7 @@ var GeonicDBModule = (() => {
|
|
|
1398
1397
|
if (options.entityTypes) msg.entityTypes = options.entityTypes;
|
|
1399
1398
|
if (options.idPattern) msg.idPattern = options.idPattern;
|
|
1400
1399
|
if (options.scopeQ) msg.scopeQ = options.scopeQ;
|
|
1400
|
+
if (options["@context"]) msg["@context"] = options["@context"];
|
|
1401
1401
|
}
|
|
1402
1402
|
this._subscription = msg;
|
|
1403
1403
|
if (this._pendingSubscription) return;
|
|
@@ -1465,6 +1465,10 @@ var GeonicDBModule = (() => {
|
|
|
1465
1465
|
return;
|
|
1466
1466
|
}
|
|
1467
1467
|
if (msg.type === "pong") return;
|
|
1468
|
+
if (msg.type === "subscribed") {
|
|
1469
|
+
this._emit("subscribed", void 0);
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1468
1472
|
if (msg.type === "dpop_verified") {
|
|
1469
1473
|
this._pendingSubscription = false;
|
|
1470
1474
|
if (this._subscription) {
|
|
@@ -1931,7 +1935,9 @@ var GeonicDBModule = (() => {
|
|
|
1931
1935
|
limit: 0,
|
|
1932
1936
|
type: params?.type,
|
|
1933
1937
|
q: params?.q,
|
|
1934
|
-
scopeQ: params?.scopeQ
|
|
1938
|
+
scopeQ: params?.scopeQ,
|
|
1939
|
+
// #2278: clause 5.7.2.4 の "too wide query" 免除条件 (e) local scope。
|
|
1940
|
+
local: params?.local
|
|
1935
1941
|
});
|
|
1936
1942
|
const res = await this._auth.request("GET", path);
|
|
1937
1943
|
if (!res.ok) {
|
|
@@ -1967,7 +1973,13 @@ var GeonicDBModule = (() => {
|
|
|
1967
1973
|
return { deleted: true };
|
|
1968
1974
|
}
|
|
1969
1975
|
// --- Types / Attributes Discovery ---
|
|
1970
|
-
/**
|
|
1976
|
+
/**
|
|
1977
|
+
* List all entity types.
|
|
1978
|
+
*
|
|
1979
|
+
* `details` 未指定の `GET /types` は ETSI OpenAPI v1.8.1 準拠の
|
|
1980
|
+
* `EntityTypeList` オブジェクト(`{ id, type: 'EntityTypeList', typeList }`)を返す。
|
|
1981
|
+
* 型名の一覧は `typeList` から取得する。
|
|
1982
|
+
*/
|
|
1971
1983
|
async getTypes() {
|
|
1972
1984
|
return this._jsonGet("/ngsi-ld/v1/types", "Types query failed");
|
|
1973
1985
|
}
|
|
@@ -1978,7 +1990,13 @@ var GeonicDBModule = (() => {
|
|
|
1978
1990
|
"Type not found"
|
|
1979
1991
|
);
|
|
1980
1992
|
}
|
|
1981
|
-
/**
|
|
1993
|
+
/**
|
|
1994
|
+
* List all attributes.
|
|
1995
|
+
*
|
|
1996
|
+
* `details` 未指定の `GET /attributes` は ETSI OpenAPI v1.8.1 準拠の
|
|
1997
|
+
* `AttributeList` オブジェクト(`{ id, type: 'AttributeList', attributeList }`)を返す。
|
|
1998
|
+
* 属性名の一覧は `attributeList` から取得する。
|
|
1999
|
+
*/
|
|
1982
2000
|
async getAttributes() {
|
|
1983
2001
|
return this._jsonGet("/ngsi-ld/v1/attributes", "Attributes query failed");
|
|
1984
2002
|
}
|
|
@@ -2016,7 +2034,21 @@ var GeonicDBModule = (() => {
|
|
|
2016
2034
|
"Batch create failed"
|
|
2017
2035
|
);
|
|
2018
2036
|
}
|
|
2019
|
-
/**
|
|
2037
|
+
/**
|
|
2038
|
+
* Upsert multiple entities in a single request.
|
|
2039
|
+
*
|
|
2040
|
+
* #1742: the server follows ETSI GS CIM 009 clause 5.6.8.5 / Table 6.15.3.1-1:
|
|
2041
|
+
* - **201** with a `string[]` of the **created** entity IDs, when at least one entity
|
|
2042
|
+
* was newly created and none failed (merely updated entities are not listed);
|
|
2043
|
+
* - **204** with no body, when every entity already existed and was updated
|
|
2044
|
+
* (`_jsonPost` maps this to `{}`);
|
|
2045
|
+
* - **207** with a `BatchOperationResult` (`{ created, updated, errors }`), on partial
|
|
2046
|
+
* or total failure.
|
|
2047
|
+
*
|
|
2048
|
+
* The return type reflects all three shapes. Narrow with `Array.isArray(result)` to
|
|
2049
|
+
* detect the "something was created" case.
|
|
2050
|
+
* https://cim.etsi.org/NGSI-LD/official/clause-6.html
|
|
2051
|
+
*/
|
|
2020
2052
|
async batchUpsert(entities) {
|
|
2021
2053
|
return this._jsonPost(
|
|
2022
2054
|
"/ngsi-ld/v1/entityOperations/upsert",
|