@geolonia/geonicdb-sdk 0.16.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 +39 -8
- package/geonicdb.cjs +28 -8
- package/geonicdb.cjs.map +2 -2
- package/geonicdb.d.ts +115 -10
- package/geonicdb.iife.js +28 -8
- package/geonicdb.iife.js.map +2 -2
- package/geonicdb.mjs +28 -8
- package/geonicdb.mjs.map +2 -2
- package/package.json +1 -1
- package/react/index.d.ts +115 -10
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,46 @@ 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;
|
|
283
374
|
}
|
|
284
375
|
/**
|
|
285
376
|
* `GET /ngsi-ld/v1/types`(`details` 未指定)のレスポンス。
|
|
@@ -528,8 +619,22 @@ export declare class GeonicDB extends EventEmitter {
|
|
|
528
619
|
getTemporalEntity(entityId: string): Promise<Record<string, unknown>>;
|
|
529
620
|
/** Create multiple entities in a single request. */
|
|
530
621
|
batchCreate(entities: Record<string, unknown>[]): Promise<Record<string, unknown>>;
|
|
531
|
-
/**
|
|
532
|
-
|
|
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>>;
|
|
533
638
|
/** Update multiple entities in a single request. */
|
|
534
639
|
batchUpdate(entities: Record<string, unknown>[]): Promise<Record<string, unknown>>;
|
|
535
640
|
/** Delete multiple entities by ID. */
|
package/geonicdb.iife.js
CHANGED
|
@@ -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) {
|
|
@@ -2028,7 +2034,21 @@ var GeonicDBModule = (() => {
|
|
|
2028
2034
|
"Batch create failed"
|
|
2029
2035
|
);
|
|
2030
2036
|
}
|
|
2031
|
-
/**
|
|
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
|
+
*/
|
|
2032
2052
|
async batchUpsert(entities) {
|
|
2033
2053
|
return this._jsonPost(
|
|
2034
2054
|
"/ngsi-ld/v1/entityOperations/upsert",
|