@pmate/cli 0.35.13 → 0.36.1

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
@@ -971,6 +971,7 @@ type ServiceCommandArgs = {
971
971
  } | {
972
972
  type: Command.Service;
973
973
  action: "log";
974
+ category?: "app" | "web";
974
975
  topic?: string;
975
976
  fields?: Record<string, string | number | boolean>;
976
977
  app?: string;
package/dist/index.js CHANGED
@@ -18934,7 +18934,7 @@ async function queryDeveloperLogs(input, fetcher = fetch) {
18934
18934
  if (!Number.isSafeInteger(input.page) || input.page < 0) throw new Error("Invalid log page");
18935
18935
  if (input.sinceMs !== void 0 && (!Number.isSafeInteger(input.sinceMs) || input.sinceMs < 0)) throw new Error("Invalid log time");
18936
18936
  if (input.keyword && input.keyword.length > 256) throw new Error("Log search must be at most 256 characters");
18937
- const params = new URLSearchParams({ service: input.service, page: String(input.page), topic: input.topic ?? "application" });
18937
+ const params = new URLSearchParams({ service: input.service, page: String(input.page), category: input.category ?? "app", topic: input.topic ?? (input.category === "web" ? "pv" : "application") });
18938
18938
  if (input.environment) params.set("environment", input.environment);
18939
18939
  if (input.fields) params.set("fields", JSON.stringify(input.fields));
18940
18940
  if (input.keyword) params.set("keyword", input.keyword);
@@ -20014,6 +20014,7 @@ var ServiceRuntimeRunner = class {
20014
20014
  service: `${namespace}:${appName}`,
20015
20015
  page: options.page,
20016
20016
  keyword: options.search,
20017
+ category: options.category,
20017
20018
  topic: options.topic,
20018
20019
  fields: options.fields,
20019
20020
  environment: options.envName,
@@ -20705,8 +20706,8 @@ var ServiceRuntimeRunner = class {
20705
20706
  }
20706
20707
  };
20707
20708
  function resolveLogChainId(env = process.env) {
20708
- if (env.APP_LOG_CHAIN_ID && env.APP_LOG_CHAIN_ID !== "log") throw new Error("Logs require log chain");
20709
- return "log";
20709
+ if (env.APP_LOG_CHAIN_ID && env.APP_LOG_CHAIN_ID !== "app-logs") throw new Error("Logs require log chain");
20710
+ return "app-logs";
20710
20711
  }
20711
20712
  function shellQuote2(value) {
20712
20713
  return `'${value.replace(/'/g, `'\\''`)}'`;
@@ -20918,7 +20919,7 @@ var ServiceCommandHandler = class {
20918
20919
  }
20919
20920
  case "log": {
20920
20921
  if (args.app) {
20921
- const result = await queryDeveloperLogs({ app: args.app, service: `${args.namespace}:${args.name}`, page: args.page, keyword: args.search, sinceMs: args.sinceMs, topic: args.topic, fields: args.fields, environment: args.env });
20922
+ const result = await queryDeveloperLogs({ app: args.app, service: `${args.namespace}:${args.name}`, page: args.page, keyword: args.search, sinceMs: args.sinceMs, category: args.category, topic: args.topic, fields: args.fields, environment: args.env });
20922
20923
  console.log(JSON.stringify(result, null, args.json ? void 0 : 2));
20923
20924
  return;
20924
20925
  }
@@ -20930,6 +20931,7 @@ var ServiceCommandHandler = class {
20930
20931
  search: args.search,
20931
20932
  follow: args.follow,
20932
20933
  envName: args.env,
20934
+ category: args.category,
20933
20935
  topic: args.topic,
20934
20936
  fields: args.fields,
20935
20937
  sinceMs: args.sinceMs,
@@ -24212,6 +24214,13 @@ function parseServiceArgs(tokens) {
24212
24214
  while (rest.length > 0) {
24213
24215
  const token = rest.shift();
24214
24216
  switch (token) {
24217
+ case "--category": {
24218
+ if (action !== "log") throw new Error(`Unknown service ${action} option: ${token}`);
24219
+ const value = rest.shift();
24220
+ if (value !== "app" && value !== "web") throw new Error("Invalid --category");
24221
+ logFilters.category = value;
24222
+ break;
24223
+ }
24215
24224
  case "--topic": {
24216
24225
  if (action !== "log") throw new Error(`Unknown service ${action} option: ${token}`);
24217
24226
  const value = requireValue4(rest, token);
@@ -24965,7 +24974,7 @@ function parseLogsArgs(input) {
24965
24974
  const params = {}, fields = {};
24966
24975
  let json = false, actorProfileId;
24967
24976
  if (rest[0] && !rest[0].startsWith("--")) params.service = parseNamespacedRef(rest.shift(), { entityLabel: "service" }).fullId;
24968
- const keys = { "--metric": "metric", "--topic": "topic", "--env": "environment", "--search": "keyword", "--group-by": "groupBy", "--interval": "interval", "--timezone": "timezone", "--request-id": "requestId", "--page": "page" };
24977
+ const keys = { "--category": "category", "--metric": "metric", "--topic": "topic", "--env": "environment", "--search": "keyword", "--group-by": "groupBy", "--interval": "interval", "--timezone": "timezone", "--request-id": "requestId", "--page": "page" };
24969
24978
  const times = { "--from": "from", "--to": "to", "--compare-from": "compareFrom", "--compare-to": "compareTo" };
24970
24979
  while (rest.length) {
24971
24980
  const flag = rest.shift();
@@ -24997,6 +25006,7 @@ function parseLogsArgs(input) {
24997
25006
  } else if (keys[flag]) params[keys[flag]] = value;
24998
25007
  else throw Error(`Unknown log option: ${flag}`);
24999
25008
  }
25009
+ if (params.category && !["app", "web"].includes(params.category)) throw Error("Invalid --category");
25000
25010
  if (tool !== "schema" && !params.service) throw Error("Service reference required");
25001
25011
  if (tool === "schema" && (Object.keys(params).length || Object.keys(fields).length)) throw Error("logs schema only accepts --json");
25002
25012
  if (tool === "aggregate" || tool === "compare") {
@@ -1,4 +1,4 @@
1
- const { createUpdateChecker } = require('./updates.cjs')
1
+ const { createUpdateChecker, installUpdateHandlers } = require('./updates.cjs')
2
2
  const { app, BrowserWindow, session, shell, Menu, desktopCapturer, ipcMain, Notification, dialog } = require('electron')
3
3
  const path = require('node:path')
4
4
  const { installNotificationSettings } = require('./notification-settings.cjs')
@@ -72,6 +72,7 @@ else {
72
72
  mainWindow.show(); mainWindow.focus()
73
73
  return mainWindow
74
74
  } })
75
+ installUpdateHandlers({ ipcMain, app, shell, appId: config.app, trusted: event => desktopNotifications.trusted(event) })
75
76
  const instanceId = desktopInstanceId(app.getPath('userData'))
76
77
  const rendererReach = createRendererReach({ ipcMain, getWindow: () => mainWindow, trusted: event => desktopNotifications.trusted(event) })
77
78
  if (config.app === 'pmate:hello') desktopCalls = createDesktopCalls({ appId: config.app, instanceId, origin: config.origin, BrowserWindow, ipcMain, dialog })
@@ -1,6 +1,10 @@
1
1
  const { contextBridge, ipcRenderer } = require('electron')
2
2
  contextBridge.exposeInMainWorld('pmateDesktop', Object.freeze({
3
3
  runtime: Object.freeze({ platform: process.platform, appVersion: process.argv.find(value => value.startsWith('--pmate-app-version='))?.slice('--pmate-app-version='.length), electronVersion: process.versions.electron }),
4
+ updates: Object.freeze({
5
+ check: () => ipcRenderer.invoke('pmate:update:check'),
6
+ download: () => ipcRenderer.invoke('pmate:update:download'),
7
+ }),
4
8
  openScreenSettings: () => ipcRenderer.invoke('pmate:screen-settings'),
5
9
  reach: Object.freeze({
6
10
  onEvent: handler => {
@@ -48,4 +48,24 @@ function createUpdateChecker({ app, dialog, shell, appId, platform = process.pla
48
48
  } finally { checking = false }
49
49
  }
50
50
  }
51
- module.exports = { compareVersions, findUpdate, createUpdateChecker }
51
+ function installUpdateHandlers({ ipcMain, app, shell, appId, trusted, platform = process.platform, arch = process.arch, fetchImpl = fetch }) {
52
+ let checking
53
+ let available
54
+ ipcMain.handle('pmate:update:check', async event => {
55
+ if (!trusted(event)) throw new Error('Untrusted update sender')
56
+ if (!checking) {
57
+ available = undefined
58
+ checking = findUpdate({ appId, currentVersion: app.getVersion(), platform, arch, fetchImpl })
59
+ .then(update => { available = update; return update ? { version: update.version } : null })
60
+ .finally(() => { checking = undefined })
61
+ }
62
+ return checking
63
+ })
64
+ ipcMain.handle('pmate:update:download', async event => {
65
+ if (!trusted(event)) throw new Error('Untrusted update sender')
66
+ if (!available) throw new Error('Check for updates first')
67
+ await shell.openExternal(available.downloadUrl)
68
+ return true
69
+ })
70
+ }
71
+ module.exports = { compareVersions, findUpdate, createUpdateChecker, installUpdateHandlers }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.35.13",
3
+ "version": "0.36.1",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {