querysub 0.28.0 → 0.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -27,7 +27,7 @@ export async function replaceFunctions(config: {
27
27
  debugName: "replaceFunctions",
28
28
  watchFunction() {
29
29
  function debugFunction(func: FunctionSpec) {
30
- return `${func.DomainName}:${func.FilePath}:${func.FunctionId}`;
30
+ return `${func.DomainName}:${func.FilePath}:${func.ModuleId}:${func.FunctionId}`;
31
31
  }
32
32
 
33
33
  let { domainName, functions } = config;
@@ -21,6 +21,7 @@ import { SocketFunction } from "socket-function/SocketFunction";
21
21
  import { requiresNetworkTrustHook } from "../-d-trust/NetworkTrust2";
22
22
  import { getControllerNodeId, getControllerNodeIdList } from "../-g-core-values/NodeCapabilities";
23
23
  import { sha256 } from "js-sha256";
24
+ import os from "os";
24
25
 
25
26
  // Get localPathRemappings using yargs, so it is easy to configure in multiple entry points
26
27
  let yargObj = isNodeTrue() && yargs(process.argv)
@@ -118,6 +119,9 @@ export function setGitURLMapping(config: {
118
119
  spec: FunctionSpec;
119
120
  resolvedPath: string;
120
121
  }) {
122
+ if (os.platform() === "win32" && config.resolvedPath.startsWith("/root")) {
123
+ devDebugbreak();
124
+ }
121
125
  gitURLRefMappings.set(getSpecKey(config.spec), config.resolvedPath);
122
126
  }
123
127
 
@@ -497,7 +497,7 @@ export async function getCallWrites(config: {
497
497
  // }
498
498
  let moduleObject = domainObject.PathFunctionRunner[call.ModuleId];
499
499
  if (!(call.FunctionId in moduleObject.Sources) && Querysub.isAllSynced()) {
500
- throw new Error(`Function not found ${call.DomainName}.${call.ModuleId}.${call.FunctionId}`);
500
+ throw new Error(`Function not found in database ${call.DomainName}.${call.ModuleId}.${call.FunctionId}, have ${JSON.stringify(Object.keys(moduleObject.Sources))}`);
501
501
  }
502
502
  let functionSpec = atomicObjectRead(moduleObject.Sources[call.FunctionId]);
503
503
  return { functionSpec };
@@ -42,7 +42,9 @@ export type LogObj = {
42
42
  time: number;
43
43
  };
44
44
 
45
- export const noDiskLogPrefix = "\u200C";
45
+ // NOTE: This is visible, otherwise it's easy to accidentally copy it, and not know why
46
+ // the text is behaving strangely (not === other seemingly equal text, etc).
47
+ export const noDiskLogPrefix = "█ ";
46
48
 
47
49
  export const diskLog = logDisk;
48
50
  export function logDisk(...args: unknown[]) {
@@ -35,17 +35,21 @@ let pages: {
35
35
  }[] = [];
36
36
 
37
37
  let __schema: SchemaObject<unknown, {
38
- schemaIsManagementUser: () => boolean;
38
+ isManagementUser: () => boolean;
39
39
  }> | undefined = undefined;
40
40
  function getSchema() {
41
41
  if (!__schema) throw new Error(`registerManagementPages2 must be called for management functions to be accessed`);
42
42
  return __schema;
43
43
  }
44
44
 
45
+ let functionId = "isManagementUser" as const;
46
+
45
47
  let registeredModule: NodeJS.Module | undefined = undefined;
46
48
  export async function registerManagementPages2(config: {
47
49
  module: NodeJS.Module;
48
- isManagementUser: () => boolean;
50
+ schema: SchemaObject<unknown, {
51
+ isManagementUser: () => boolean;
52
+ }>;
49
53
  pages: {
50
54
  componentName: string;
51
55
  controllerName?: string;
@@ -94,13 +98,11 @@ export async function registerManagementPages2(config: {
94
98
  // NOTE: We don't store the UI in the database (here, or anywhere else, at least
95
99
  // not yet), but we do want to store the permission function call, as we may
96
100
  // need to update it immediately, across all servers.
97
- __schema = Querysub.createSchema()({
98
- module: config.module,
99
- moduleId: "managementPages",
100
- functions: {
101
- schemaIsManagementUser: config.isManagementUser,
102
- },
103
- });
101
+ __schema = config.schema;
102
+
103
+ if (!__schema.functions[functionId]) {
104
+ throw new Error(`Required function isManagementUser not found in schema`);
105
+ }
104
106
 
105
107
  if (isServer()) {
106
108
  for (let page of inputPages) {
@@ -142,8 +144,6 @@ export async function isManagementUser() {
142
144
  // have every endpoint protected by isManagementUser.
143
145
  if (await isTrusted(callerMachineId)) return true;
144
146
  let schema = getSchema();
145
- let functionId = "schemaIsManagementUser" as const;
146
- if (!schema.functions[functionId]) throw new Error(`Function ${functionId} not found in schema`);
147
147
 
148
148
  let testCall: CallSpec = {
149
149
  callerIP: IdentityController_getSecureIP(caller),