@milaboratories/pl-middle-layer 1.30.28 → 1.30.30

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.
@@ -1,6 +1,6 @@
1
1
  import { ComputableCtx, Computable } from '@milaboratories/computable';
2
2
  import { ArchiveFormat, CommonFieldTraverseOps as CommonFieldTraverseOpsFromSDK, FieldTraversalStep as FieldTraversalStepFromSDK, Option, PColumn, PColumnValues, PFrameDef, PFrameHandle, PObject, PObjectSpec, PSpecPredicate, PTableDef, PTableHandle, ResourceType as ResourceTypeFromSDK, ResultCollection, ValueOrError, JsRenderInternal } from '@platforma-sdk/model';
3
- import { QuickJSContext, QuickJSHandle, Scope } from 'quickjs-emscripten';
3
+ import { QuickJSContext, QuickJSHandle, Scope, errors } from 'quickjs-emscripten';
4
4
  import { Optional } from 'utility-types';
5
5
  import { BlockContextAny } from '../middle_layer/block_ctx';
6
6
  import { MiddleLayerEnvironment } from '../middle_layer/middle_layer';
@@ -16,6 +16,7 @@ export declare class JsExecutionContext implements JsRenderInternal.GlobalCfgRen
16
16
  private computableCtx;
17
17
  private readonly accessors;
18
18
  private readonly meta;
19
+ private readonly errorRepo;
19
20
  constructor(scope: Scope, vm: QuickJSContext, blockCtx: BlockContextAny, env: MiddleLayerEnvironment, computableCtx: ComputableCtx);
20
21
  resetComputableCtx(): void;
21
22
  private static cleanErrorContext;
@@ -70,4 +71,23 @@ export declare class JsExecutionContext implements JsRenderInternal.GlobalCfgRen
70
71
  importObjectViaJson(handle: QuickJSHandle): unknown;
71
72
  private injectCtx;
72
73
  }
74
+ /** Holds errors that happened in the host code (like in middle-layer's drivers)
75
+ * and then throws it where the error from quick JS is needed.
76
+ * QuickJS couldn't throw custom errors, so we store them here, and rethrow them when we exit QuickJS side. */
77
+ export declare class ErrorRepository {
78
+ private readonly errorIdToError;
79
+ /** Sets the error to the repository and returns a mimicrated error that also has uuid key of the original error. */
80
+ setAndRecreateForQuickJS(error: unknown): {
81
+ name: string;
82
+ message: string;
83
+ };
84
+ /** Returns the original error that was stored by parsing uuid of mimicrated error. */
85
+ getOriginal(quickJSError: unknown): unknown;
86
+ }
87
+ /** The error that comes from model. */
88
+ export declare class ModelError extends Error {
89
+ stack: string;
90
+ constructor(quickJSError: errors.QuickJSUnwrapError, cause: Error);
91
+ toString(): string;
92
+ }
73
93
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/js_render/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,IAAI,6BAA6B,EACvD,kBAAkB,IAAI,yBAAyB,EAC/C,MAAM,EACN,OAAO,EACP,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,YAAY,IAAI,mBAAmB,EACnC,gBAAgB,EAChB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAIjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAA4B,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAa3E,qBAAa,kBACb,YAAW,gBAAgB,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC;IAajE,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CA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AAM,EAAE,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAqB7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-middle-layer",
3
- "version": "1.30.28",
3
+ "version": "1.30.30",
4
4
  "description": "Pl Middle Layer",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "keywords": [],
20
20
  "license": "UNLICENSED",
21
21
  "dependencies": {
22
- "@milaboratories/pframes-node": "2.1.17",
22
+ "@milaboratories/pframes-node": "2.1.19",
23
23
  "@milaboratories/pframes-rs-node": "1.0.22",
24
24
  "canonicalize": "~2.1.0",
25
25
  "denque": "^2.1.0",
@@ -30,20 +30,21 @@
30
30
  "yaml": "^2.6.1",
31
31
  "zod": "~3.23.8",
32
32
  "@milaboratories/pl-http": "^1.1.0",
33
- "@milaboratories/computable": "^2.4.0",
33
+ "@platforma-sdk/block-tools": "^2.5.22",
34
+ "@milaboratories/computable": "^2.4.1",
34
35
  "@milaboratories/resolve-helper": "^1.1.0",
35
- "@milaboratories/pl-drivers": "^1.5.27",
36
+ "@milaboratories/pl-drivers": "^1.5.28",
36
37
  "@milaboratories/pl-client": "^2.7.12",
37
38
  "@milaboratories/pl-model-common": "^1.11.0",
38
- "@milaboratories/pl-model-middle-layer": "^1.7.9",
39
39
  "@milaboratories/pl-model-backend": "^1.0.2",
40
- "@milaboratories/pl-tree": "^1.4.32",
41
- "@platforma-sdk/block-tools": "^2.5.22",
40
+ "@milaboratories/pl-tree": "^1.4.33",
42
41
  "@platforma-sdk/model": "^1.23.4",
43
- "@platforma-sdk/workflow-tengo": "2.16.1",
44
- "@milaboratories/ts-helpers": "^1.1.4",
42
+ "@platforma-sdk/workflow-tengo": "3.0.0",
43
+ "@milaboratories/pl-model-middle-layer": "^1.7.9",
44
+ "@milaboratories/pl-errors": "^1.0.1",
45
+ "@milaboratories/pl-config": "^1.4.3",
45
46
  "@milaboratories/pl-deployments": "^1.6.0",
46
- "@milaboratories/pl-config": "^1.4.3"
47
+ "@milaboratories/ts-helpers": "^1.1.4"
47
48
  },
48
49
  "devDependencies": {
49
50
  "semver": "^7.6.3",
@@ -28,13 +28,14 @@ import {
28
28
  import { notEmpty } from '@milaboratories/ts-helpers';
29
29
  import { randomUUID } from 'node:crypto';
30
30
  import type { QuickJSContext, QuickJSHandle, VmFunctionImplementation } from 'quickjs-emscripten';
31
- import { Scope } from 'quickjs-emscripten';
31
+ import { Scope, errors } from 'quickjs-emscripten';
32
32
  import type { Optional } from 'utility-types';
33
33
  import type { BlockContextAny } from '../middle_layer/block_ctx';
34
34
  import type { MiddleLayerEnvironment } from '../middle_layer/middle_layer';
35
35
  import type { Block } from '../model/project_model';
36
36
  import { parseFinalPObjectCollection } from '../pool/p_object_collection';
37
37
  import type { ResultPool } from '../pool/result_pool';
38
+ import { stringifyWithResourceId } from '@milaboratories/pl-client';
38
39
 
39
40
  function isArrayBufferOrView(obj: unknown): obj is ArrayBufferLike {
40
41
  return obj instanceof ArrayBuffer || ArrayBuffer.isView(obj);
@@ -57,6 +58,8 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
57
58
 
58
59
  private readonly meta: Map<string, Block>;
59
60
 
61
+ private readonly errorRepo = new ErrorRepository();
62
+
60
63
  constructor(
61
64
  private readonly scope: Scope,
62
65
  private readonly vm: QuickJSContext,
@@ -121,7 +124,8 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
121
124
  });
122
125
  } catch (err: unknown) {
123
126
  JsExecutionContext.cleanErrorContext(err);
124
- throw err;
127
+ const original = this.errorRepo.getOriginal(err);
128
+ throw original;
125
129
  }
126
130
  }
127
131
 
@@ -600,7 +604,20 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
600
604
  name: string,
601
605
  fn: VmFunctionImplementation<QuickJSHandle>,
602
606
  ): void => {
603
- this.vm.newFunction(name, fn).consume((fnh) => this.vm.setProp(configCtx, name, fnh));
607
+ const withCachedError: VmFunctionImplementation<QuickJSHandle> = (...args) => {
608
+ // QuickJS strips all fields from errors apart from 'name' and 'message'.
609
+ // That's why here we need to store them, and rethrow them when we exit
610
+ // from QuickJS code.
611
+ try {
612
+ return (fn as any)(...args);
613
+ } catch (e: unknown) {
614
+ const newErr = this.errorRepo.setAndRecreateForQuickJS(e);
615
+ throw this.vm.newError(newErr);
616
+ }
617
+ }
618
+
619
+ this.vm.newFunction(name, withCachedError).consume((fnh) => this.vm.setProp(configCtx, name, fnh));
620
+ this.vm.newFunction(name, fn).consume((fnh) => this.vm.setProp(configCtx, name + '__internal__', fnh));
604
621
  };
605
622
 
606
623
  //
@@ -870,3 +887,85 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
870
887
  });
871
888
  }
872
889
  }
890
+
891
+ /** Holds errors that happened in the host code (like in middle-layer's drivers)
892
+ * and then throws it where the error from quick JS is needed.
893
+ * QuickJS couldn't throw custom errors, so we store them here, and rethrow them when we exit QuickJS side. */
894
+ export class ErrorRepository {
895
+ private readonly errorIdToError = new Map<string, unknown>();
896
+
897
+ /** Sets the error to the repository and returns a mimicrated error that also has uuid key of the original error. */
898
+ public setAndRecreateForQuickJS(error: unknown): {
899
+ name: string;
900
+ message: string;
901
+ } {
902
+ const errorId = randomUUID();
903
+ this.errorIdToError.set(errorId, error);
904
+
905
+ if (error instanceof Error) {
906
+ return {
907
+ name: `${error.name}/uuid:${errorId}`,
908
+ message: error.message,
909
+ };
910
+ }
911
+
912
+ return {
913
+ name: `UnknownErrorQuickJS/uuid:${errorId}`,
914
+ message: `${error as any}`,
915
+ };
916
+ }
917
+
918
+ /** Returns the original error that was stored by parsing uuid of mimicrated error. */
919
+ public getOriginal(quickJSError: unknown): unknown {
920
+ if (!(quickJSError instanceof errors.QuickJSUnwrapError)) {
921
+ console.warn('ErrorRepo: quickJSError is not a QuickJSUnwrapError', stringifyWithResourceId(quickJSError));
922
+ return quickJSError;
923
+ }
924
+
925
+ if (!('name' in (quickJSError.cause as any))) {
926
+ console.warn('ErrorRepo: quickJSError.cause is not an Error', stringifyWithResourceId(quickJSError));
927
+ return quickJSError;
928
+ }
929
+
930
+ const causeName = (quickJSError.cause as any).name;
931
+ const errorId = causeName.slice(causeName.indexOf('/uuid:') + '/uuid:'.length);
932
+ if (!errorId) {
933
+ throw new Error(`ErrorRepo: quickJSError.cause.name does not contain errorId: ${causeName}, ${stringifyWithResourceId(quickJSError)}`);
934
+ }
935
+
936
+ const error = this.errorIdToError.get(errorId);
937
+ if (error === undefined) {
938
+ throw new Error(`ErrorRepo: errorId not found: ${errorId}, ${stringifyWithResourceId(quickJSError)}`);
939
+ }
940
+
941
+ return new ModelError(quickJSError, error as Error);
942
+ }
943
+ }
944
+
945
+ /** The error that comes from model. */
946
+ export class ModelError extends Error {
947
+ public stack: string;
948
+
949
+ constructor(
950
+ quickJSError: errors.QuickJSUnwrapError,
951
+ cause: Error,
952
+ ) {
953
+ super('', { cause });
954
+ this.name = 'ModelError';
955
+
956
+ // QuickJS wraps the error with the name and the message,
957
+ // but we need another format.
958
+ this.stack = quickJSError.stack?.replace(quickJSError.message, '') ?? '';
959
+ this.stack = this.stack.replace(cause.message, '');
960
+
961
+ this.message = this.toString();
962
+ }
963
+
964
+ toString() {
965
+ const msg = `ModelError: ${(this.cause as any)?.message}
966
+ QuickJS stacktrace:
967
+ ${this.stack}
968
+ `;
969
+ return msg;
970
+ }
971
+ }
@@ -1,5 +1,5 @@
1
- import type { PlTreeNodeAccessor } from '@milaboratories/pl-tree';
2
- import { PlError } from '@milaboratories/pl-tree';
1
+ import { type PlTreeNodeAccessor } from '@milaboratories/pl-tree';
2
+ import { parsePlError } from '@milaboratories/pl-errors';
3
3
  import type { PObject, PObjectSpec, ValueOrError } from '@platforma-sdk/model';
4
4
  import { notEmpty } from '@milaboratories/ts-helpers';
5
5
  import assert from 'node:assert';
@@ -110,7 +110,7 @@ export function parseFinalPObjectCollection(
110
110
  throw new Error(`no data for key ${outputName}`);
111
111
  const data = result.data();
112
112
  if (data === undefined) throw new Error(`no data for key ${outputName}`);
113
- if (!data.ok) throw new PlError(data.error);
113
+ if (!data.ok) throw parsePlError(data.error);
114
114
  collection[outputName] = {
115
115
  id: resolvePath.length === 0
116
116
  ? deriveLegacyPObjectId(result.spec, data.value) // for old blocks opened in new desktop