ironflock 1.5.1 → 1.5.3

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/index.d.ts CHANGED
@@ -28,6 +28,24 @@ export declare interface CallParams {
28
28
  kwargs?: Record<string, unknown>;
29
29
  }
30
30
 
31
+ export declare interface ConnectToAllAppsOptions {
32
+ /** Provider stage to connect to. Defaults to this app's own stage (ENV). */
33
+ stage?: "dev" | "prod";
34
+ /**
35
+ * Invoked with the failure of each provider that could not be opened (only
36
+ * when continueOnError is true — otherwise the first failure rejects), and
37
+ * with a {@link CrossAppAccessError} if an already-opened provider connection
38
+ * is later fatally denied (grant revoked → refused reconnect).
39
+ */
40
+ onError?: (error: unknown) => void;
41
+ /**
42
+ * When true (the default) a provider that fails to open is reported via
43
+ * onError and omitted from the result. When false the first failure rejects
44
+ * connectToAllApps.
45
+ */
46
+ continueOnError?: boolean;
47
+ }
48
+
31
49
  export declare interface ConnectToAppOptions {
32
50
  /** Provider stage to connect to. Defaults to this app's own stage (ENV). */
33
51
  stage?: "dev" | "prod";
@@ -200,7 +218,39 @@ export declare class IronFlock {
200
218
  * UNKNOWN_APP | NOT_AUTHORIZED
201
219
  */
202
220
  connectToApp(appName: string, opts?: ConnectToAppOptions): Promise<ConsumedApp>;
221
+ /**
222
+ * Lists every non-private provider catalog in this project for an app holding
223
+ * the wildcard consume grant (`consumes: [{app: "*"}]`). One
224
+ * `sys.appaccess.list` call; opens no consumed-app connections. A picker (e.g.
225
+ * a Node-RED node) renders the returned catalogs, then calls
226
+ * {@link connectToApp} per chosen provider; {@link connectToAllApps} opens
227
+ * them all eagerly.
228
+ *
229
+ * @throws {CrossAppAccessError} NO_GRANT when this app holds no wildcard grant.
230
+ */
231
+ listConsumableApps(): Promise<ConsumedAppInfo[]>;
232
+ /**
233
+ * Opens read-only connections to every non-private provider in this project
234
+ * (wildcard consumers only). Enumerates providers via {@link listConsumableApps}
235
+ * and opens each directly from its resolved info — no per-app resolve
236
+ * round-trip. Each handle is cached under the same `${app}:${stage}` key
237
+ * {@link connectToApp} uses, so a later `connectToApp(name)` returns the warmed
238
+ * handle. Providers lacking a data backend for the requested stage are skipped.
239
+ *
240
+ * @throws {CrossAppAccessError} NO_GRANT when this app holds no wildcard grant.
241
+ */
242
+ connectToAllApps(opts?: ConnectToAllAppsOptions): Promise<ConsumedApp[]>;
203
243
  private openConsumedApp;
244
+ /** Caches (or reuses) a connection opened directly from a resolved provider
245
+ * info, using the same `${app}:${stage}` key as {@link connectToApp}. */
246
+ private openCachedFromInfo;
247
+ /**
248
+ * Opens the second CrossbarConnection to a provider realm from an already
249
+ * resolved {@link ConsumedAppInfo} — everything after the sys.appaccess.resolve
250
+ * round-trip. Shared by {@link connectToApp} (which resolves one provider) and
251
+ * {@link connectToAllApps} (which lists every provider in one call).
252
+ */
253
+ private openFromInfo;
204
254
  publish(topic: string, args?: unknown[], kwargs?: Record<string, unknown>): Promise<unknown>;
205
255
  publishToTable(tablename: string, args?: unknown[], kwargs?: Record<string, unknown>): Promise<unknown>;
206
256
  /**
@@ -255,7 +305,37 @@ export declare class IronFlock {
255
305
  */
256
306
  getSeriesHistory(tablename: string, params: SeriesQueryParams): Promise<unknown>;
257
307
  setDeviceLocation(long: number, lat: number): Promise<unknown>;
258
- getRemoteAccessUrlForPort(port: number): string | null;
308
+ /**
309
+ * Public URL under which a declared port (port-template.yml) is reachable
310
+ * from the internet once its tunnel is active.
311
+ *
312
+ * For `http`/`https` ports, composes the platform's tunnel label
313
+ * `{device_key}-{app_name}-{port}` (`https` ports carry the platform's
314
+ * `secure-` prefix) on the tunnel domain the device agent injects
315
+ * (`TUNNEL_DOMAIN`; the cloud edge, or the operator's appliance domain).
316
+ * On devices that belong to an instance (appliance), the agent injects
317
+ * `INSTANCE_KEY` and the cloud-forwarded route
318
+ * `https://i{instance_key}-{label}.{cloud edge}` is returned instead —
319
+ * reachable while the instance forwards its tunnels to the cloud.
320
+ *
321
+ * For `tcp`/`udp` ports, the URL uses the tunnel-assigned public port,
322
+ * which the platform injects under the port-template's
323
+ * `remote_port_environment` name — pass that name here. On instance
324
+ * devices the internet-facing port arrives as `{name}_CLOUD`; when it is
325
+ * not (yet) present, the instance-local URL built from `{name}` is
326
+ * returned as a fallback.
327
+ *
328
+ * Port values are read live from the agent-maintained files under
329
+ * `/data/env` (falling back to the process environment), so this method
330
+ * returns the CURRENT url: the instance cloud port is allocated shortly
331
+ * after the tunnel first connects and appears here within seconds — call
332
+ * the method again rather than caching its result.
333
+ *
334
+ * Returns null when the identity or required env vars are unavailable,
335
+ * the protocol is unknown, or the label is not a valid DNS label (longer
336
+ * than 63 characters, or a dot in the app name).
337
+ */
338
+ getRemoteAccessUrlForPort(port: number, protocol?: string, remotePortEnvironment?: string): string | null;
259
339
  /**
260
340
  * Create an IronFlock instance by fetching configuration from a server endpoint.
261
341
  * The endpoint should return JSON matching `IronFlockOptions`.