aegis-platform-sdk 1.0.0 → 1.3.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/dist/cli.js CHANGED
@@ -755,6 +755,44 @@ var GeoResource = class {
755
755
  deleteZone(zoneId) {
756
756
  return this.t.request("DELETE", `/api/v1/geo/zones/${zoneId}`);
757
757
  }
758
+ // ── Reference Layer Builder (the AEGIS "My Maps") ──────────────────────
759
+ //
760
+ // Each layer is one editable dataset + one DAG board + one dedicated
761
+ // node_type. Publishing runs the board; the materialized nodes show up on
762
+ // their own under the map's "Reference layers" tab.
763
+ // Read: `security.geo.view`; write: `security.geo.camada.manage`.
764
+ /** Builder layers of the tenant, grouped by "map" (the project). */
765
+ layers() {
766
+ return this.t.request("GET", "/api/v1/geo/layers");
767
+ }
768
+ /** Creates a layer (empty inline dataset + published board). The
769
+ * `node_type` derives from the name and is IMMUTABLE. */
770
+ createLayer(input) {
771
+ return this.t.request("POST", "/api/v1/geo/layers", { json: input });
772
+ }
773
+ layerFeatures(boardId) {
774
+ return this.t.request("GET", `/api/v1/geo/layers/${boardId}/features`);
775
+ }
776
+ /** Saves the drawing as a versioned SNAPSHOT. `geometry` is GeoJSON
777
+ * `[lng,lat]`; `geo_style` travels PER FEATURE (colour/alpha/extrusion). */
778
+ saveLayerFeatures(boardId, rows) {
779
+ return this.t.request("PUT", `/api/v1/geo/layers/${boardId}/features`, {
780
+ json: { rows }
781
+ });
782
+ }
783
+ /** Runs the board and RECONCILES — a feature deleted in the builder leaves
784
+ * the map (the engine is upsert-only). */
785
+ publishLayer(boardId) {
786
+ return this.t.request("POST", `/api/v1/geo/layers/${boardId}/publish`);
787
+ }
788
+ /** Renames / regroups. Never changes the `node_type`; `mapa: ""` ungroups. */
789
+ patchLayer(boardId, changes) {
790
+ return this.t.request("PATCH", `/api/v1/geo/layers/${boardId}`, { json: changes });
791
+ }
792
+ /** Deletes the whole layer: materialized nodes + dataset + board. */
793
+ deleteLayer(boardId) {
794
+ return this.t.request("DELETE", `/api/v1/geo/layers/${boardId}`);
795
+ }
758
796
  };
759
797
  var MapTemplatesResource = class {
760
798
  constructor(t) {
@@ -892,6 +930,82 @@ var TimeSeriesResource = class {
892
930
  }
893
931
  };
894
932
 
933
+ // src/resources/publicGuest.ts
934
+ var PublicGuestResource = class {
935
+ constructor(t) {
936
+ this.t = t;
937
+ }
938
+ t;
939
+ base(token) {
940
+ return `/public/v1/guest/${encodeURIComponent(token)}`;
941
+ }
942
+ /** Menu/resumo do token: label, subject, status, geo, ações permitidas. */
943
+ menu(token) {
944
+ return this.t.request("GET", this.base(token));
945
+ }
946
+ /** Reporta uma posição GPS; o backend avalia cerca/rota/destino. */
947
+ fix(token, body) {
948
+ return this.t.request("POST", `${this.base(token)}/fix`, { json: body });
949
+ }
950
+ /** Invoca uma ação permitida do token (ex.: abrir portão). */
951
+ invoke(token, actionId, input = {}) {
952
+ return this.t.request(
953
+ "POST",
954
+ `${this.base(token)}/actions/${encodeURIComponent(actionId)}`,
955
+ { json: { input } }
956
+ );
957
+ }
958
+ /**
959
+ * Onda 2 — última posição do VISITANTE amarrado a um token de MORADOR
960
+ * (`geo.live_ref`). Sem push: a SPA do morador faz polling desta rota. O
961
+ * morador só vê ESSA visita (least-privilege). Retorna `{available, lat,
962
+ * lng, ts, inside_fence, arrived, deviated, distance_to_target_m,
963
+ * visit_status}`; `available:false` enquanto o visitante não mandou fix.
964
+ */
965
+ position(token) {
966
+ return this.t.request("GET", `${this.base(token)}/position`);
967
+ }
968
+ /** Documento vinculado ao token (se `geo.document_id`). */
969
+ document(token) {
970
+ return this.t.request("GET", `${this.base(token)}/document`);
971
+ }
972
+ /** Consulta um object-set embutido no documento do token. */
973
+ queryObjectSet(token, body) {
974
+ return this.t.request(
975
+ "POST",
976
+ `${this.base(token)}/document/object-sets/query`,
977
+ { json: body }
978
+ );
979
+ }
980
+ /** Um nó da ontologia referenciado pelo documento (mascarado por ABAC). */
981
+ documentNode(token, nodeId) {
982
+ return this.t.request("GET", `${this.base(token)}/document/node`, {
983
+ params: { node_id: nodeId }
984
+ });
985
+ }
986
+ /** Descritor da Page vinculada ao token (`geo.page_slug`). */
987
+ page(token, slug) {
988
+ return this.t.request("GET", `${this.base(token)}/pages/${encodeURIComponent(slug)}`);
989
+ }
990
+ /** Avalia as variáveis da Page (com overrides só de variáveis estáticas). */
991
+ evaluatePage(token, slug, overrides = {}) {
992
+ return this.t.request(
993
+ "POST",
994
+ `${this.base(token)}/pages/${encodeURIComponent(slug)}/evaluate`,
995
+ { json: { overrides } }
996
+ );
997
+ }
998
+ /**
999
+ * URL absoluta de um objeto de mídia do documento (bytes servidos com
1000
+ * `Cache-Control: private`). Retorna string p/ `<img src>`/`<a href>` —
1001
+ * NÃO faz request (o transporte é JSON-cêntrico). A `key` deve começar
1002
+ * com `notepad/{doc_id}/` (validado no backend).
1003
+ */
1004
+ mediaUrl(token, key) {
1005
+ return buildUrl(this.t.baseUrl, `${this.base(token)}/media`, { key });
1006
+ }
1007
+ };
1008
+
895
1009
  // src/resources/operational.ts
896
1010
  var AlertFeedsResource = class {
897
1011
  constructor(t) {
@@ -1053,6 +1167,31 @@ var AlertsResource = class {
1053
1167
  channels() {
1054
1168
  return this.t.request("GET", "/alerts/channels");
1055
1169
  }
1170
+ /**
1171
+ * `PUT /alerts/channels/{ref}` — point a delivery channel at its
1172
+ * destination.
1173
+ *
1174
+ * Exists so this is a GESTURE: before it, sending alerts to the team's
1175
+ * Discord (or any webhook) meant editing the tenant's JSONB in the
1176
+ * database. Audited as `alert_channel.configured`.
1177
+ *
1178
+ * `ref` is the channel name (`"discord"`) or a named ref
1179
+ * (`"discord-plantao"`, then pass `channel: "discord"`). Fields are open
1180
+ * because the vocabulary belongs to the CHANNEL, not the core.
1181
+ *
1182
+ * The response returns the config MASKED — a webhook URL is the
1183
+ * credential, and reads never hand it back whole.
1184
+ * Perm: `alerts.routes.manage`.
1185
+ */
1186
+ setChannel(ref, config) {
1187
+ return this.t.request("PUT", `/alerts/channels/${encodeURIComponent(ref)}`, {
1188
+ json: config
1189
+ });
1190
+ }
1191
+ /** `DELETE /alerts/channels/{ref}` — audited as `alert_channel.removed`. */
1192
+ deleteChannel(ref) {
1193
+ return this.t.request("DELETE", `/alerts/channels/${encodeURIComponent(ref)}`);
1194
+ }
1056
1195
  };
1057
1196
  var AlarmsResource = class {
1058
1197
  constructor(t) {
@@ -1159,10 +1298,43 @@ var ConnectorsResource = class {
1159
1298
  json: { skill_key: "connector.http" }
1160
1299
  });
1161
1300
  }
1301
+ /**
1302
+ * Start/renew QR pairing for a skill with the `pairing` capability (WhatsApp
1303
+ * station). Pass `{ refresh: true }` to force a fresh code.
1304
+ */
1305
+ pairingStart(agentId, skillKey, opts = {}) {
1306
+ const { target, ...json } = opts;
1307
+ return this.t.request("POST", `/governance/agents/${agentId}/skills/${skillKey}/pairing`, {
1308
+ json,
1309
+ params: target ? { target } : void 0
1310
+ });
1311
+ }
1312
+ /** Read-only poll of the pairing state (no side effects). `target` aims a pool number. */
1313
+ pairingPoll(agentId, skillKey, opts = {}) {
1314
+ return this.t.request("GET", `/governance/agents/${agentId}/skills/${skillKey}/pairing`, {
1315
+ params: opts.target ? { target: opts.target } : void 0
1316
+ });
1317
+ }
1318
+ /**
1319
+ * Add / correct / remove a sub-unit administered by a connector that
1320
+ * declares the `inventory` capability — e.g. one number of a WhatsApp
1321
+ * number-station.
1322
+ *
1323
+ * Reading is NOT here: the inventory already reaches callers through the
1324
+ * snapshot the tick publishes on the device mirror (`GET /api/v1/edge/nodes`
1325
+ * → `nodes[].pool`). A second read path would drift between ticks.
1326
+ */
1327
+ applyInventory(agentId, skillKey, op, item) {
1328
+ return this.t.request(
1329
+ "POST",
1330
+ `/governance/agents/${agentId}/skills/${skillKey}/inventory`,
1331
+ { json: { op, item } }
1332
+ );
1333
+ }
1162
1334
  schedulerTick() {
1163
1335
  return this.t.request("POST", "/governance/agents/scheduler/tick");
1164
1336
  }
1165
- /** source ∈ native|clawhub */
1337
+ /** source ∈ native|clawhub. Rows carry an additive `capabilities` field. */
1166
1338
  skillCatalog(source) {
1167
1339
  return this.t.request("GET", "/governance/agents/skills", { params: { source } });
1168
1340
  }
@@ -2006,9 +2178,24 @@ var EdgeResource = class {
2006
2178
  this.t = t;
2007
2179
  }
2008
2180
  t;
2181
+ /**
2182
+ * Issue a single-use pairing code (short TTL). The plaintext `code` appears
2183
+ * ONLY in this response (hash at rest).
2184
+ *
2185
+ * `grants` GRANTS gestures to whichever device redeems the code (allowlist;
2186
+ * today `["retry"]`, so a desk app can ask the station to reconnect a
2187
+ * number). Empty — the default — is **read only**: least privilege, and
2188
+ * granting has to be a choice. The grant travels from the code to the node
2189
+ * and dies with it on `revoke`.
2190
+ *
2191
+ * Even when granted, the device never receives the gesture's ADDRESS
2192
+ * (`agent_id`/`skill_key`): it sends the verb and the server routes it.
2193
+ * Perm: `connectors.manage`.
2194
+ */
2009
2195
  createPairingCode(opts = {}) {
2010
2196
  return this.t.request("POST", "/api/v1/edge/pairing-codes", { json: opts });
2011
2197
  }
2198
+ /** Nodes carry an additive `kind` field — see {@link EdgeNode}. */
2012
2199
  listNodes() {
2013
2200
  return this.t.request("GET", "/api/v1/edge/nodes");
2014
2201
  }
@@ -3290,6 +3477,8 @@ var AegisClient = class {
3290
3477
  pages;
3291
3478
  dossier;
3292
3479
  timeseries;
3480
+ /** Public guest-token consumer surface (`/public/v1/guest/{token}/*`). */
3481
+ publicGuest;
3293
3482
  // Operational
3294
3483
  alerts;
3295
3484
  alarms;
@@ -3375,6 +3564,7 @@ var AegisClient = class {
3375
3564
  this.pages = new PagesResource(this);
3376
3565
  this.dossier = new DossierResource(this);
3377
3566
  this.timeseries = new TimeSeriesResource(this);
3567
+ this.publicGuest = new PublicGuestResource(this);
3378
3568
  this.alerts = new AlertsResource(this);
3379
3569
  this.alarms = new AlarmsResource(this);
3380
3570
  this.events = new EventsResource(this);