@milaboratories/pl-tree 1.8.46 → 1.8.48

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.
Files changed (57) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/accessors.cjs +236 -273
  3. package/dist/accessors.cjs.map +1 -1
  4. package/dist/accessors.d.ts +93 -93
  5. package/dist/accessors.js +235 -271
  6. package/dist/accessors.js.map +1 -1
  7. package/dist/dump.cjs +79 -80
  8. package/dist/dump.cjs.map +1 -1
  9. package/dist/dump.d.ts +16 -18
  10. package/dist/dump.js +79 -79
  11. package/dist/dump.js.map +1 -1
  12. package/dist/index.cjs +31 -35
  13. package/dist/index.d.ts +10 -10
  14. package/dist/index.js +9 -8
  15. package/dist/snapshot.cjs +50 -71
  16. package/dist/snapshot.cjs.map +1 -1
  17. package/dist/snapshot.d.ts +36 -38
  18. package/dist/snapshot.js +49 -69
  19. package/dist/snapshot.js.map +1 -1
  20. package/dist/state.cjs +487 -624
  21. package/dist/state.cjs.map +1 -1
  22. package/dist/state.d.ts +117 -116
  23. package/dist/state.js +486 -622
  24. package/dist/state.js.map +1 -1
  25. package/dist/sync.cjs +113 -131
  26. package/dist/sync.cjs.map +1 -1
  27. package/dist/sync.d.ts +37 -33
  28. package/dist/sync.js +111 -129
  29. package/dist/sync.js.map +1 -1
  30. package/dist/synchronized_tree.cjs +167 -232
  31. package/dist/synchronized_tree.cjs.map +1 -1
  32. package/dist/synchronized_tree.d.ts +66 -68
  33. package/dist/synchronized_tree.js +165 -211
  34. package/dist/synchronized_tree.js.map +1 -1
  35. package/dist/traversal_ops.d.ts +42 -42
  36. package/dist/value_and_error.cjs +9 -12
  37. package/dist/value_and_error.cjs.map +1 -1
  38. package/dist/value_and_error.d.ts +8 -5
  39. package/dist/value_and_error.js +9 -11
  40. package/dist/value_and_error.js.map +1 -1
  41. package/dist/value_or_error.d.ts +8 -5
  42. package/package.json +10 -9
  43. package/src/sync.ts +5 -3
  44. package/dist/accessors.d.ts.map +0 -1
  45. package/dist/dump.d.ts.map +0 -1
  46. package/dist/index.cjs.map +0 -1
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js.map +0 -1
  49. package/dist/snapshot.d.ts.map +0 -1
  50. package/dist/state.d.ts.map +0 -1
  51. package/dist/sync.d.ts.map +0 -1
  52. package/dist/synchronized_tree.d.ts.map +0 -1
  53. package/dist/test_utils.d.ts +0 -25
  54. package/dist/test_utils.d.ts.map +0 -1
  55. package/dist/traversal_ops.d.ts.map +0 -1
  56. package/dist/value_and_error.d.ts.map +0 -1
  57. package/dist/value_or_error.d.ts.map +0 -1
@@ -0,0 +1,29 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,291 +1,254 @@
1
- 'use strict';
2
-
3
- var plClient = require('@milaboratories/pl-client');
4
- var value_and_error = require('./value_and_error.cjs');
5
- var plErrors = require('@milaboratories/pl-errors');
6
- var tsHelpers = require('@milaboratories/ts-helpers');
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ const require_value_and_error = require('./value_and_error.cjs');
3
+ let _milaboratories_pl_client = require("@milaboratories/pl-client");
4
+ let _milaboratories_pl_errors = require("@milaboratories/pl-errors");
5
+ let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
7
6
 
7
+ //#region src/accessors.ts
8
8
  /** Error encountered during traversal in field or resource. */
9
- class PlError extends Error {
10
- constructor(message) {
11
- super(message);
12
- }
13
- }
9
+ var PlError = class extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ }
13
+ };
14
14
  function isPlTreeEntry(obj) {
15
- return (typeof obj === "object" &&
16
- obj !== null &&
17
- obj["__pl_tree_type_marker__"] === "PlTreeEntry");
15
+ return typeof obj === "object" && obj !== null && obj["__pl_tree_type_marker__"] === "PlTreeEntry";
18
16
  }
19
17
  function isPlTreeEntryAccessor(obj) {
20
- return (typeof obj === "object" &&
21
- obj !== null &&
22
- obj["__pl_tree_type_marker__"] === "PlTreeEntryAccessor");
18
+ return typeof obj === "object" && obj !== null && obj["__pl_tree_type_marker__"] === "PlTreeEntryAccessor";
23
19
  }
24
20
  function isPlTreeNodeAccessor(obj) {
25
- return (typeof obj === "object" &&
26
- obj !== null &&
27
- obj["__pl_tree_type_marker__"] === "PlTreeNodeAccessor");
21
+ return typeof obj === "object" && obj !== null && obj["__pl_tree_type_marker__"] === "PlTreeNodeAccessor";
28
22
  }
29
23
  /** Main entry point for using PlTree in reactive setting */
30
- class PlTreeEntry {
31
- accessorData;
32
- rid;
33
- __pl_tree_type_marker__ = "PlTreeEntry";
34
- constructor(accessorData, rid) {
35
- this.accessorData = accessorData;
36
- this.rid = rid;
37
- }
38
- createAccessor(ctx, guard) {
39
- return new PlTreeEntryAccessor(this.accessorData, this.accessorData.treeProvider(), this.rid, {
40
- ctx,
41
- guard,
42
- });
43
- }
44
- toJSON() {
45
- return this.toString();
46
- }
47
- toString() {
48
- return `[ENTRY:${plClient.resourceIdToString(this.rid)}]`;
49
- }
50
- }
24
+ var PlTreeEntry = class {
25
+ __pl_tree_type_marker__ = "PlTreeEntry";
26
+ constructor(accessorData, rid) {
27
+ this.accessorData = accessorData;
28
+ this.rid = rid;
29
+ }
30
+ createAccessor(ctx, guard) {
31
+ return new PlTreeEntryAccessor(this.accessorData, this.accessorData.treeProvider(), this.rid, {
32
+ ctx,
33
+ guard
34
+ });
35
+ }
36
+ toJSON() {
37
+ return this.toString();
38
+ }
39
+ toString() {
40
+ return `[ENTRY:${(0, _milaboratories_pl_client.resourceIdToString)(this.rid)}]`;
41
+ }
42
+ };
51
43
  function getResourceFromTree(accessorData, tree, instanceData, rid, ops) {
52
- const acc = new PlTreeNodeAccessor(accessorData, tree, tree.get(instanceData.ctx.watcher, rid), instanceData);
53
- if (!ops.ignoreError) {
54
- const err = acc.getError();
55
- if (err !== undefined)
56
- throw plErrors.parsePlError(tsHelpers.notEmpty(err.getDataAsString()), acc.id, acc.resourceType);
57
- }
58
- if (ops.assertResourceType !== undefined &&
59
- (Array.isArray(ops.assertResourceType)
60
- ? ops.assertResourceType.findIndex((rt) => plClient.resourceTypesEqual(rt, acc.resourceType)) === -1
61
- : !plClient.resourceTypesEqual(ops.assertResourceType, acc.resourceType)))
62
- throw new Error(
63
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
64
- `wrong resource type ${plClient.resourceTypeToString(acc.resourceType)} but expected ${ops.assertResourceType}`);
65
- return acc;
66
- }
67
- class PlTreeEntryAccessor {
68
- accessorData;
69
- tree;
70
- rid;
71
- instanceData;
72
- __pl_tree_type_marker__ = "PlTreeEntryAccessor";
73
- constructor(accessorData, tree, rid, instanceData) {
74
- this.accessorData = accessorData;
75
- this.tree = tree;
76
- this.rid = rid;
77
- this.instanceData = instanceData;
78
- }
79
- node(ops = {}) {
80
- this.instanceData.guard();
81
- // this is the only entry point to acquire a PlTreeNodeAccessor,
82
- // so this is the only point where we should attach the hooks
83
- if (this.accessorData.hooks !== undefined)
84
- this.instanceData.ctx.attacheHooks(this.accessorData.hooks);
85
- return getResourceFromTree(this.accessorData, this.tree, this.instanceData, this.rid, ops);
86
- }
44
+ const acc = new PlTreeNodeAccessor(accessorData, tree, tree.get(instanceData.ctx.watcher, rid), instanceData);
45
+ if (!ops.ignoreError) {
46
+ const err = acc.getError();
47
+ if (err !== void 0) throw (0, _milaboratories_pl_errors.parsePlError)((0, _milaboratories_ts_helpers.notEmpty)(err.getDataAsString()), acc.id, acc.resourceType);
48
+ }
49
+ if (ops.assertResourceType !== void 0 && (Array.isArray(ops.assertResourceType) ? ops.assertResourceType.findIndex((rt) => (0, _milaboratories_pl_client.resourceTypesEqual)(rt, acc.resourceType)) === -1 : !(0, _milaboratories_pl_client.resourceTypesEqual)(ops.assertResourceType, acc.resourceType))) throw new Error(`wrong resource type ${(0, _milaboratories_pl_client.resourceTypeToString)(acc.resourceType)} but expected ${ops.assertResourceType}`);
50
+ return acc;
87
51
  }
52
+ var PlTreeEntryAccessor = class {
53
+ __pl_tree_type_marker__ = "PlTreeEntryAccessor";
54
+ constructor(accessorData, tree, rid, instanceData) {
55
+ this.accessorData = accessorData;
56
+ this.tree = tree;
57
+ this.rid = rid;
58
+ this.instanceData = instanceData;
59
+ }
60
+ node(ops = {}) {
61
+ this.instanceData.guard();
62
+ if (this.accessorData.hooks !== void 0) this.instanceData.ctx.attacheHooks(this.accessorData.hooks);
63
+ return getResourceFromTree(this.accessorData, this.tree, this.instanceData, this.rid, ops);
64
+ }
65
+ };
88
66
  /**
89
- * Can be called only when a ctx is provided, because pl tree entry is a computable entity.
90
- * @deprecated
91
- * */
67
+ * Can be called only when a ctx is provided, because pl tree entry is a computable entity.
68
+ * @deprecated
69
+ * */
92
70
  function treeEntryToResourceInfo(res, ctx) {
93
- if (res instanceof PlTreeEntry)
94
- return ctx.accessor(res).node().resourceInfo;
95
- return res;
71
+ if (res instanceof PlTreeEntry) return ctx.accessor(res).node().resourceInfo;
72
+ return res;
96
73
  }
97
74
  /**
98
- * API contracts:
99
- * - API never return {@link NullResourceId}, absence of link is always modeled as `undefined`
100
- *
101
- * Important: never store instances of this class, always get fresh instance from {@link PlTreeState} accessor.
102
- * */
103
- class PlTreeNodeAccessor {
104
- accessorData;
105
- tree;
106
- resource;
107
- instanceData;
108
- __pl_tree_type_marker__ = "PlTreeNodeAccessor";
109
- constructor(accessorData, tree, resource, instanceData) {
110
- this.accessorData = accessorData;
111
- this.tree = tree;
112
- this.resource = resource;
113
- this.instanceData = instanceData;
114
- }
115
- get id() {
116
- this.instanceData.guard();
117
- return this.resource.id;
118
- }
119
- get originalId() {
120
- this.instanceData.guard();
121
- return this.resource.originalResourceId;
122
- }
123
- get resourceType() {
124
- this.instanceData.guard();
125
- return this.resource.type;
126
- }
127
- get resourceInfo() {
128
- return { id: this.id, type: this.resourceType };
129
- }
130
- getResourceFromTree(rid, ops) {
131
- return getResourceFromTree(this.accessorData, this.tree, this.instanceData, rid, ops);
132
- }
133
- traverse(...steps) {
134
- return this.traverseWithCommon({}, ...steps);
135
- }
136
- traverseOrError(...steps) {
137
- return this.traverseOrErrorWithCommon({}, ...steps);
138
- }
139
- traverseWithCommon(commonOptions, ...steps) {
140
- const result = this.traverseOrErrorWithCommon(commonOptions, ...steps);
141
- if (result === undefined)
142
- return undefined;
143
- if (!result.ok)
144
- throw result.error;
145
- return result.value;
146
- }
147
- traverseOrErrorWithCommon(commonOptions, ...steps) {
148
- // eslint-disable-next-line @typescript-eslint/no-this-alias
149
- let current = this;
150
- for (const _step of steps) {
151
- const step = typeof _step === "string"
152
- ? {
153
- ...commonOptions,
154
- field: _step,
155
- }
156
- : { ...commonOptions, ..._step };
157
- const next = current.getField(_step);
158
- if (next === undefined)
159
- return undefined;
160
- if (step.pureFieldErrorToUndefined && next.value === undefined && next.error !== undefined)
161
- return undefined;
162
- if ((!step.ignoreError || next.value === undefined) && next.error !== undefined)
163
- return {
164
- ok: false,
165
- // FIXME: in next tickets we'll allow Errors to be thrown.
166
- error: plErrors.parsePlError(tsHelpers.notEmpty(next.error.getDataAsString()), current.id, current.resourceType, step.field),
167
- };
168
- if (next.value === undefined) {
169
- if (step.errorIfFieldNotSet)
170
- return {
171
- ok: false,
172
- error: new Error(`field have no assigned value ${step.field} of ${plClient.resourceIdToString(current.id)}`),
173
- };
174
- // existing but unpopulated field is unstable because it must be resolved at some point
175
- this.onUnstableLambda("unpopulated_field:" + step.field);
176
- return undefined;
177
- }
178
- current = next.value;
179
- }
180
- return { ok: true, value: current };
181
- }
182
- onUnstableLambda = (marker) => {
183
- this.instanceData.ctx.markUnstable(marker);
184
- };
185
- getField(_step) {
186
- this.instanceData.guard();
187
- const step = typeof _step === "string" ? { field: _step } : _step;
188
- const ve = this.resource.getField(this.instanceData.ctx.watcher, step, this.onUnstableLambda);
189
- if (ve === undefined)
190
- return undefined;
191
- return value_and_error.mapValueAndError(ve, (rid) => this.getResourceFromTree(rid, { ignoreError: true }));
192
- }
193
- getInputsLocked() {
194
- this.instanceData.guard();
195
- const result = this.resource.getInputsLocked(this.instanceData.ctx.watcher);
196
- if (!result)
197
- this.instanceData.ctx.markUnstable("inputs_unlocked:" + this.resourceType.name);
198
- return result;
199
- }
200
- getOutputsLocked() {
201
- this.instanceData.guard();
202
- const result = this.resource.getOutputsLocked(this.instanceData.ctx.watcher);
203
- if (!result)
204
- this.instanceData.ctx.markUnstable("outputs_unlocked:" + this.resourceType.name);
205
- return result;
206
- }
207
- getIsReadyOrError() {
208
- this.instanceData.guard();
209
- const result = this.resource.getIsReadyOrError(this.instanceData.ctx.watcher);
210
- if (!result)
211
- this.instanceData.ctx.markUnstable("not_ready:" + this.resourceType.name);
212
- return result;
213
- }
214
- getIsFinal() {
215
- this.instanceData.guard();
216
- return this.resource.getIsFinal(this.instanceData.ctx.watcher);
217
- }
218
- getError() {
219
- this.instanceData.guard();
220
- const rid = this.resource.getError(this.instanceData.ctx.watcher);
221
- if (rid === undefined)
222
- // absence of error always considered as stable
223
- return undefined;
224
- return this.getResourceFromTree(rid, {});
225
- }
226
- getData() {
227
- return this.resource.data;
228
- }
229
- getDataAsString() {
230
- return this.resource.getDataAsString();
231
- }
232
- getDataAsJson() {
233
- return this.resource.getDataAsJson();
234
- }
235
- listInputFields() {
236
- this.instanceData.guard();
237
- this.getInputsLocked(); // will set unstable if not locked
238
- return this.resource.listInputFields(this.instanceData.ctx.watcher);
239
- }
240
- listOutputFields() {
241
- this.instanceData.guard();
242
- this.getOutputsLocked(); // will set unstable if not locked
243
- return this.resource.listOutputFields(this.instanceData.ctx.watcher);
244
- }
245
- listDynamicFields() {
246
- this.instanceData.guard();
247
- return this.resource.listDynamicFields(this.instanceData.ctx.watcher);
248
- }
249
- getKeyValue(key, unstableIfNotFound = false) {
250
- this.instanceData.guard();
251
- const result = this.resource.getKeyValue(this.instanceData.ctx.watcher, key);
252
- if (result === undefined && unstableIfNotFound)
253
- this.instanceData.ctx.markUnstable("key_not_found_b:" + key);
254
- return result;
255
- }
256
- /** @deprecated */
257
- getKeyValueString(key) {
258
- return this.getKeyValueAsString(key);
259
- }
260
- getKeyValueAsString(key, unstableIfNotFound = false) {
261
- this.instanceData.guard();
262
- const result = this.resource.getKeyValueString(this.instanceData.ctx.watcher, key);
263
- if (result === undefined && unstableIfNotFound)
264
- this.instanceData.ctx.markUnstable("key_not_found_s:" + key);
265
- return result;
266
- }
267
- getKeyValueAsJson(key, unstableIfNotFound = false) {
268
- const result = this.resource.getKeyValueAsJson(this.instanceData.ctx.watcher, key);
269
- if (result === undefined) {
270
- if (unstableIfNotFound)
271
- this.instanceData.ctx.markUnstable("key_not_found_j:" + key);
272
- return undefined;
273
- }
274
- return result;
275
- }
276
- /**
277
- * Can be used to pass a higher level accessor that will wrap the resource and throw its
278
- * errors on node resolution.
279
- * */
280
- toEntryAccessor() {
281
- return new PlTreeEntryAccessor(this.accessorData, this.tree, this.id, this.instanceData);
282
- }
283
- /** Can be passed to nested computable. */
284
- persist() {
285
- return new PlTreeEntry(this.accessorData, this.resource.id);
286
- }
287
- }
75
+ * API contracts:
76
+ * - API never return {@link NullResourceId}, absence of link is always modeled as `undefined`
77
+ *
78
+ * Important: never store instances of this class, always get fresh instance from {@link PlTreeState} accessor.
79
+ * */
80
+ var PlTreeNodeAccessor = class {
81
+ __pl_tree_type_marker__ = "PlTreeNodeAccessor";
82
+ constructor(accessorData, tree, resource, instanceData) {
83
+ this.accessorData = accessorData;
84
+ this.tree = tree;
85
+ this.resource = resource;
86
+ this.instanceData = instanceData;
87
+ }
88
+ get id() {
89
+ this.instanceData.guard();
90
+ return this.resource.id;
91
+ }
92
+ get originalId() {
93
+ this.instanceData.guard();
94
+ return this.resource.originalResourceId;
95
+ }
96
+ get resourceType() {
97
+ this.instanceData.guard();
98
+ return this.resource.type;
99
+ }
100
+ get resourceInfo() {
101
+ return {
102
+ id: this.id,
103
+ type: this.resourceType
104
+ };
105
+ }
106
+ getResourceFromTree(rid, ops) {
107
+ return getResourceFromTree(this.accessorData, this.tree, this.instanceData, rid, ops);
108
+ }
109
+ traverse(...steps) {
110
+ return this.traverseWithCommon({}, ...steps);
111
+ }
112
+ traverseOrError(...steps) {
113
+ return this.traverseOrErrorWithCommon({}, ...steps);
114
+ }
115
+ traverseWithCommon(commonOptions, ...steps) {
116
+ const result = this.traverseOrErrorWithCommon(commonOptions, ...steps);
117
+ if (result === void 0) return void 0;
118
+ if (!result.ok) throw result.error;
119
+ return result.value;
120
+ }
121
+ traverseOrErrorWithCommon(commonOptions, ...steps) {
122
+ let current = this;
123
+ for (const _step of steps) {
124
+ const step = typeof _step === "string" ? {
125
+ ...commonOptions,
126
+ field: _step
127
+ } : {
128
+ ...commonOptions,
129
+ ..._step
130
+ };
131
+ const next = current.getField(_step);
132
+ if (next === void 0) return void 0;
133
+ if (step.pureFieldErrorToUndefined && next.value === void 0 && next.error !== void 0) return void 0;
134
+ if ((!step.ignoreError || next.value === void 0) && next.error !== void 0) return {
135
+ ok: false,
136
+ error: (0, _milaboratories_pl_errors.parsePlError)((0, _milaboratories_ts_helpers.notEmpty)(next.error.getDataAsString()), current.id, current.resourceType, step.field)
137
+ };
138
+ if (next.value === void 0) {
139
+ if (step.errorIfFieldNotSet) return {
140
+ ok: false,
141
+ error: /* @__PURE__ */ new Error(`field have no assigned value ${step.field} of ${(0, _milaboratories_pl_client.resourceIdToString)(current.id)}`)
142
+ };
143
+ this.onUnstableLambda("unpopulated_field:" + step.field);
144
+ return;
145
+ }
146
+ current = next.value;
147
+ }
148
+ return {
149
+ ok: true,
150
+ value: current
151
+ };
152
+ }
153
+ onUnstableLambda = (marker) => {
154
+ this.instanceData.ctx.markUnstable(marker);
155
+ };
156
+ getField(_step) {
157
+ this.instanceData.guard();
158
+ const step = typeof _step === "string" ? { field: _step } : _step;
159
+ const ve = this.resource.getField(this.instanceData.ctx.watcher, step, this.onUnstableLambda);
160
+ if (ve === void 0) return void 0;
161
+ return require_value_and_error.mapValueAndError(ve, (rid) => this.getResourceFromTree(rid, { ignoreError: true }));
162
+ }
163
+ getInputsLocked() {
164
+ this.instanceData.guard();
165
+ const result = this.resource.getInputsLocked(this.instanceData.ctx.watcher);
166
+ if (!result) this.instanceData.ctx.markUnstable("inputs_unlocked:" + this.resourceType.name);
167
+ return result;
168
+ }
169
+ getOutputsLocked() {
170
+ this.instanceData.guard();
171
+ const result = this.resource.getOutputsLocked(this.instanceData.ctx.watcher);
172
+ if (!result) this.instanceData.ctx.markUnstable("outputs_unlocked:" + this.resourceType.name);
173
+ return result;
174
+ }
175
+ getIsReadyOrError() {
176
+ this.instanceData.guard();
177
+ const result = this.resource.getIsReadyOrError(this.instanceData.ctx.watcher);
178
+ if (!result) this.instanceData.ctx.markUnstable("not_ready:" + this.resourceType.name);
179
+ return result;
180
+ }
181
+ getIsFinal() {
182
+ this.instanceData.guard();
183
+ return this.resource.getIsFinal(this.instanceData.ctx.watcher);
184
+ }
185
+ getError() {
186
+ this.instanceData.guard();
187
+ const rid = this.resource.getError(this.instanceData.ctx.watcher);
188
+ if (rid === void 0) return void 0;
189
+ return this.getResourceFromTree(rid, {});
190
+ }
191
+ getData() {
192
+ return this.resource.data;
193
+ }
194
+ getDataAsString() {
195
+ return this.resource.getDataAsString();
196
+ }
197
+ getDataAsJson() {
198
+ return this.resource.getDataAsJson();
199
+ }
200
+ listInputFields() {
201
+ this.instanceData.guard();
202
+ this.getInputsLocked();
203
+ return this.resource.listInputFields(this.instanceData.ctx.watcher);
204
+ }
205
+ listOutputFields() {
206
+ this.instanceData.guard();
207
+ this.getOutputsLocked();
208
+ return this.resource.listOutputFields(this.instanceData.ctx.watcher);
209
+ }
210
+ listDynamicFields() {
211
+ this.instanceData.guard();
212
+ return this.resource.listDynamicFields(this.instanceData.ctx.watcher);
213
+ }
214
+ getKeyValue(key, unstableIfNotFound = false) {
215
+ this.instanceData.guard();
216
+ const result = this.resource.getKeyValue(this.instanceData.ctx.watcher, key);
217
+ if (result === void 0 && unstableIfNotFound) this.instanceData.ctx.markUnstable("key_not_found_b:" + key);
218
+ return result;
219
+ }
220
+ /** @deprecated */
221
+ getKeyValueString(key) {
222
+ return this.getKeyValueAsString(key);
223
+ }
224
+ getKeyValueAsString(key, unstableIfNotFound = false) {
225
+ this.instanceData.guard();
226
+ const result = this.resource.getKeyValueString(this.instanceData.ctx.watcher, key);
227
+ if (result === void 0 && unstableIfNotFound) this.instanceData.ctx.markUnstable("key_not_found_s:" + key);
228
+ return result;
229
+ }
230
+ getKeyValueAsJson(key, unstableIfNotFound = false) {
231
+ const result = this.resource.getKeyValueAsJson(this.instanceData.ctx.watcher, key);
232
+ if (result === void 0) {
233
+ if (unstableIfNotFound) this.instanceData.ctx.markUnstable("key_not_found_j:" + key);
234
+ return;
235
+ }
236
+ return result;
237
+ }
238
+ /**
239
+ * Can be used to pass a higher level accessor that will wrap the resource and throw its
240
+ * errors on node resolution.
241
+ * */
242
+ toEntryAccessor() {
243
+ return new PlTreeEntryAccessor(this.accessorData, this.tree, this.id, this.instanceData);
244
+ }
245
+ /** Can be passed to nested computable. */
246
+ persist() {
247
+ return new PlTreeEntry(this.accessorData, this.resource.id);
248
+ }
249
+ };
288
250
 
251
+ //#endregion
289
252
  exports.PlError = PlError;
290
253
  exports.PlTreeEntry = PlTreeEntry;
291
254
  exports.PlTreeEntryAccessor = PlTreeEntryAccessor;
@@ -294,4 +257,4 @@ exports.isPlTreeEntry = isPlTreeEntry;
294
257
  exports.isPlTreeEntryAccessor = isPlTreeEntryAccessor;
295
258
  exports.isPlTreeNodeAccessor = isPlTreeNodeAccessor;
296
259
  exports.treeEntryToResourceInfo = treeEntryToResourceInfo;
297
- //# sourceMappingURL=accessors.cjs.map
260
+ //# sourceMappingURL=accessors.cjs.map