Skip to content

feat: add NGSI-LD scope/scopeQ support#110

Merged
miya0001 merged 6 commits into
mainfrom
feat/scope-support
Apr 23, 2026
Merged

feat: add NGSI-LD scope/scopeQ support#110
miya0001 merged 6 commits into
mainfrom
feat/scope-support

Conversation

@miya0001

@miya0001 miya0001 commented Apr 23, 2026

Copy link
Copy Markdown
Member

Summary

  • entities list--scope-q オプションを追加 — NGSI-LD scopeQ パラメータでスコープベースのフィルタリングに対応(全子孫 /#、完全一致、1階層 /+
  • テーブル出力で scope プロパティを id, type の直後に表示、配列をカンマ区切りでフォーマット
  • entities create のヘルプ description / examples に scope プロパティの使用例を追加
  • devDependency geonicdb を v0.2.1 に更新(#966 scope/servicePath 統一を含む)

Closes #109

Test plan

  • --scope-q オプションが scopeQ クエリパラメータとして送信されることを確認(ユニットテスト)
  • テーブル表示で scope カラムが id, type の直後に表示されることを確認(ユニットテスト)
  • scope 配列がカンマ区切り文字列にフォーマットされることを確認(ユニットテスト)
  • E2E: scope 付きエンティティの作成・取得・scopeQ フィルタリング(全子孫・完全一致・1階層)
  • lint / typecheck / 708 ユニットテスト全パス

Summary by CodeRabbit

  • 新機能

    • entities list--scope-q オプションを追加し、NGSI-LD の scopeQ によるスコープフィルタ(子孫・完全一致・一段階一致)をサポート。
    • 出力テーブルに scope 列を追加し、id と type の直後に表示。配列値は適切にフォーマットして表示。
    • entities create ヘルプに scope の使用例を追加。
  • ドキュメント

    • 変更履歴に日付付きの未リリースエントリを追加。
  • テスト

    • CLI と出力フォーマットに関する E2E/単体テストを追加・拡充。

Add --scope-q option to entities list for hierarchical scope filtering,
display scope property in table output, and update geonicdb to v0.2.1.
@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@miya0001 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 12fef618-4145-4d26-9d12-63e9774b64c3

📥 Commits

Reviewing files that changed from the base of the PR and between cabc937 and bd07caa.

📒 Files selected for processing (2)
  • .github/workflows/geonicdb-compat.yml
  • CHANGELOG.md
📝 Walkthrough

Walkthrough

entities list に NGSI‑LD の --scope-q オプションを追加して API に scopeQ を渡す。出力テーブルで scope 列を idtype の直後に配置し、配列値はスカラ要素ならカンマ区切りで表示。entities create ヘルプ例に scope を追記し、E2E/ユニットテストを追加。

Changes

Cohort / File(s) Summary
CHANGELOG
CHANGELOG.md
Unreleased2026-04-24 項を追加:--scope-q、テーブル列順、entities create ヘルプ例を記録。
CLI コマンド
src/commands/entities.ts
entities list--scope-q <expr> フラグを追加し、クライアント呼び出しで params.scopeQ を送信。entities create のヘルプ例に scope を追加。
出力整形
src/output.ts
列優先順に scopeid/type の直後へ移動。セルレンダリングで配列を処理:スカラ要素はカンマ区切り、オブジェクト要素を含む配列は JSON.stringify
E2E テスト
tests/e2e/features/entities.feature, tests/e2e/support/hooks.ts
scope を含むエンティティ作成/取得/--scope-q フィルタのシナリオを追加。テストセットアップで /admin/usersprimaryTenantId を送信するよう修正。
ユニットテスト
tests/entities.test.ts, tests/output.test.ts
--scope-qclient.getscopeQ として渡されること、テーブル出力で scope 配列整形(複数要素はカンマ区切り、単一はそのまま、オブジェクト配列は JSON 化)を検証するテストを追加。
CI / Dev deps
.github/workflows/geonicdb-compat.yml, package.json
geonicdb 開発依存を特定コミットにピン留め。新しいワークフローを追加し、依存更新→テスト→失敗時に issue を自動作成するステップを導入。

Sequence Diagram

sequenceDiagram
    participant User as "ユーザー"
    participant CLI as "geonic CLI"
    participant Client as "HTTP クライアント"
    participant Backend as "Backend API"
    participant Formatter as "出力フォーマッタ"

    User->>CLI: geonic entities list --scope-q "/restaurants/#"
    CLI->>Client: GET /entities?scopeQ=/restaurants/%23
    Client->>Backend: HTTP GET (scopeQ)
    Backend-->>Client: 200 OK (entities[] with scope)
    Client-->>CLI: results
    CLI->>Formatter: format table (place scope after id/type)
    Formatter-->>User: 表形式出力 (scope: "/A, /B")
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 新しい scope の小道を跳ねるよ
フラグひとつで森を辿り
列は並び替えられ、葉は並ぶ(scope)
テストが見守る小径の灯り
にんじんひとつで祝杯をどうぞ 🍃

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、NGSI-LD scope/scopeQ サポート機能の追加という主要な変更を簡潔かつ明確に要約しており、変更セット全体の主な目的を正確に反映しています。
Linked Issues check ✅ Passed プルリクエストは #109 で要求されたすべてのコーディング関連要件を満たしています: entities list に --scope-q オプションを追加、scope プロパティの表示、entities create での scope 用例の記載、および GeonicDB の依存関係更新が実装されています。
Out of Scope Changes check ✅ Passed GitHub Actions ワークフローの追加と geonicdb 依存関係のピン留めは、CI/CD メンテナンスのためのサポート的な変更であり、#109 の要件外ですが、プロジェクトの安定性を確保するための関連する改善です。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/scope-support

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 11-13: Update the CHANGELOG.md entries for the three bullets about
entities list/table/create so their suffixes include the PR number `#110` (either
replace or append to the current `#109`), i.e., adjust the three lines
mentioning `entities list`, table `scope` display, and `entities create` help
examples to include `#110` per PR-number convention.

In `@src/output.ts`:
- Around line 135-138: The cellValue function currently maps every array element
with String which turns object elements into "[object Object]"; update cellValue
(the Array.isArray branch) to detect if all elements are scalars
(string|number|boolean|null|undefined) and only then return elements.join(", "),
otherwise fallback to JSON.stringify the whole array (or each element) so object
arrays are preserved (e.g., keep the scalar-friendly join for scope-like arrays
and JSON for object-containing arrays).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bf0d642-7c76-49c5-8604-0b6c78d72b34

📥 Commits

Reviewing files that changed from the base of the PR and between eb249f2 and ead2308.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • CHANGELOG.md
  • src/commands/entities.ts
  • src/output.ts
  • tests/e2e/features/entities.feature
  • tests/entities.test.ts
  • tests/output.test.ts

Comment thread CHANGELOG.md Outdated
Comment thread src/output.ts Outdated
User creation endpoint now expects primaryTenantId instead of tenantId.
Pin geonicdb dependency to specific commit (326b12a) to prevent
unexpected breakage from upstream changes. Add scheduled CI workflow
that tests against latest geonicdb weekly and creates an issue on failure.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/geonicdb-compat.yml:
- Around line 3-10: The workflow must explicitly grant the GITHUB_TOKEN the
rights to create issues; add a permissions block that includes issues: write (so
gh issue create can succeed) — place this at the workflow or job level in the
YAML (e.g., add a top-level permissions: { issues: write } or under jobs.check)
to ensure the GITHUB_TOKEN used by gh issue create has write access when the
check job runs.
- Around line 63-70: The issue is the heredoc opener <<'EOF' disables shell
variable expansion so ${GEONICDB_VERSION}, ${GITHUB_SERVER_URL},
${GITHUB_REPOSITORY}, and ${GITHUB_RUN_ID} are left literal; fix by changing the
heredoc delimiter from <<'EOF' to an unquoted <<EOF (i.e., remove the single
quotes around EOF) so the variables inside the body are expanded when cat runs,
verifying the body string still remains wrapped in the outer --body "$(cat <<EOF
... EOF)" construct.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f5ab7d1-7cab-4e91-8e50-b2023a9337db

📥 Commits

Reviewing files that changed from the base of the PR and between 96d23e5 and cabc937.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • .github/workflows/geonicdb-compat.yml
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

Comment thread .github/workflows/geonicdb-compat.yml
Comment thread .github/workflows/geonicdb-compat.yml Outdated
@miya0001
miya0001 merged commit 536cacb into main Apr 23, 2026
11 of 13 checks passed
@miya0001
miya0001 deleted the feat/scope-support branch April 23, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: NGSI-LD scope / scopeQ サポート

1 participant