@milaboratories/pl-client 3.2.5 → 3.3.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/dist/core/client.cjs +24 -56
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +12 -8
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +26 -58
- package/dist/core/client.js.map +1 -1
- package/dist/core/errors.cjs +20 -0
- package/dist/core/errors.cjs.map +1 -1
- package/dist/core/errors.d.ts +6 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +19 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/final.cjs +6 -5
- package/dist/core/final.cjs.map +1 -1
- package/dist/core/final.d.ts.map +1 -1
- package/dist/core/final.js +7 -6
- package/dist/core/final.js.map +1 -1
- package/dist/core/ll_client.cjs +18 -1
- package/dist/core/ll_client.cjs.map +1 -1
- package/dist/core/ll_client.d.ts +6 -2
- package/dist/core/ll_client.d.ts.map +1 -1
- package/dist/core/ll_client.js +19 -2
- package/dist/core/ll_client.js.map +1 -1
- package/dist/core/transaction.cjs +109 -75
- package/dist/core/transaction.cjs.map +1 -1
- package/dist/core/transaction.d.ts +30 -22
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +111 -76
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/type_conversion.cjs +14 -6
- package/dist/core/type_conversion.cjs.map +1 -1
- package/dist/core/type_conversion.js +14 -6
- package/dist/core/type_conversion.js.map +1 -1
- package/dist/core/types.cjs +77 -17
- package/dist/core/types.cjs.map +1 -1
- package/dist/core/types.d.ts +49 -26
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +66 -14
- package/dist/core/types.js.map +1 -1
- package/dist/core/user_resources.cjs +181 -0
- package/dist/core/user_resources.cjs.map +1 -0
- package/dist/core/user_resources.d.ts +75 -0
- package/dist/core/user_resources.d.ts.map +1 -0
- package/dist/core/user_resources.js +180 -0
- package/dist/core/user_resources.js.map +1 -0
- package/dist/helpers/poll.cjs +4 -4
- package/dist/helpers/poll.cjs.map +1 -1
- package/dist/helpers/poll.d.ts +3 -3
- package/dist/helpers/poll.d.ts.map +1 -1
- package/dist/helpers/poll.js +5 -5
- package/dist/helpers/poll.js.map +1 -1
- package/dist/helpers/tx_helpers.cjs +1 -1
- package/dist/helpers/tx_helpers.cjs.map +1 -1
- package/dist/helpers/tx_helpers.d.ts +3 -3
- package/dist/helpers/tx_helpers.d.ts.map +1 -1
- package/dist/helpers/tx_helpers.js +2 -2
- package/dist/helpers/tx_helpers.js.map +1 -1
- package/dist/index.cjs +16 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +724 -188
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +34 -9
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +37 -5
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +34 -9
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +326 -136
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +724 -188
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +18 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +11 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +18 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +57 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +26 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +57 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
- package/dist/proto-rest/plapi.d.ts +421 -207
- package/dist/proto-rest/plapi.d.ts.map +1 -1
- package/dist/test/test_config.cjs +6 -3
- package/dist/test/test_config.cjs.map +1 -1
- package/dist/test/test_config.d.ts.map +1 -1
- package/dist/test/test_config.js +7 -4
- package/dist/test/test_config.js.map +1 -1
- package/package.json +5 -5
- package/src/core/client.ts +58 -103
- package/src/core/errors.ts +23 -0
- package/src/core/final.ts +16 -6
- package/src/core/ll_client.ts +39 -3
- package/src/core/ll_transaction.test.ts +41 -6
- package/src/core/transaction.ts +176 -86
- package/src/core/type_conversion.ts +24 -9
- package/src/core/types.ts +147 -41
- package/src/core/user_resources.ts +332 -0
- package/src/helpers/poll.ts +15 -8
- package/src/helpers/state_helpers.ts +2 -2
- package/src/helpers/tx_helpers.ts +5 -5
- package/src/index.ts +1 -0
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +61 -14
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +1045 -379
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +33 -18
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.ts +75 -6
- package/src/proto-grpc/google/protobuf/descriptor.ts +5 -2
- package/src/proto-rest/plapi.ts +447 -225
- package/src/test/test_config.ts +8 -5
package/dist/core/transaction.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLocalResourceId,
|
|
1
|
+
import { createLocalResourceId, createSignedResourceId, ensureSignedResourceIdNotNull, extractBasicResourceData, isLocalResourceId, isSignedResourceId, parseSignedResourceId, toResourceSignature } from "./types.js";
|
|
2
2
|
import { TxAPI_Open_Request_WritableTx } from "../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js";
|
|
3
3
|
import { toBytes } from "../util/util.js";
|
|
4
4
|
import { isNotFoundError } from "./errors.js";
|
|
@@ -13,16 +13,18 @@ function isField(ref) {
|
|
|
13
13
|
return ref.hasOwnProperty("resourceId") && ref.hasOwnProperty("fieldName");
|
|
14
14
|
}
|
|
15
15
|
function isResource(ref) {
|
|
16
|
-
|
|
16
|
+
if (typeof ref === "bigint") return true;
|
|
17
|
+
if (typeof ref === "string") return true;
|
|
18
|
+
return isResourceRef(ref);
|
|
17
19
|
}
|
|
18
20
|
function isResourceId(ref) {
|
|
19
|
-
return typeof ref === "
|
|
21
|
+
return typeof ref === "string" && isSignedResourceId(ref);
|
|
20
22
|
}
|
|
21
23
|
function isFieldRef(ref) {
|
|
22
24
|
return isResourceRef(ref.resourceId);
|
|
23
25
|
}
|
|
24
26
|
function isResourceRef(ref) {
|
|
25
|
-
return ref.hasOwnProperty("globalId") && ref.hasOwnProperty("localId");
|
|
27
|
+
return typeof ref === "object" && ref !== null && ref.hasOwnProperty("globalId") && ref.hasOwnProperty("localId");
|
|
26
28
|
}
|
|
27
29
|
function toFieldId(ref) {
|
|
28
30
|
if (isFieldRef(ref)) return {
|
|
@@ -36,15 +38,30 @@ async function toGlobalFieldId(ref) {
|
|
|
36
38
|
resourceId: await ref.resourceId.globalId,
|
|
37
39
|
fieldName: ref.fieldName
|
|
38
40
|
};
|
|
39
|
-
|
|
41
|
+
return ref;
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const emptySignature = toResourceSignature(new Uint8Array(0));
|
|
44
|
+
function toResourceIdAndSignature(ref) {
|
|
45
|
+
if (isResourceRef(ref)) return {
|
|
46
|
+
resourceId: ref.localId,
|
|
47
|
+
resourceSignature: emptySignature
|
|
48
|
+
};
|
|
49
|
+
if (isResourceId(ref)) {
|
|
50
|
+
const { globalId, signature } = parseSignedResourceId(ref);
|
|
51
|
+
return {
|
|
52
|
+
resourceId: globalId,
|
|
53
|
+
resourceSignature: signature
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
resourceId: ref,
|
|
58
|
+
resourceSignature: emptySignature
|
|
59
|
+
};
|
|
44
60
|
}
|
|
45
61
|
async function toGlobalResourceId(ref) {
|
|
46
62
|
if (isResourceRef(ref)) return await ref.globalId;
|
|
47
|
-
|
|
63
|
+
if (isLocalResourceId(ref)) return createSignedResourceId(ref);
|
|
64
|
+
return ref;
|
|
48
65
|
}
|
|
49
66
|
function field(resourceId, fieldName) {
|
|
50
67
|
return {
|
|
@@ -146,6 +163,32 @@ var PlTransaction = class PlTransaction {
|
|
|
146
163
|
sendVoidAsync(r) {
|
|
147
164
|
this.track(this.sendVoidSync(r));
|
|
148
165
|
}
|
|
166
|
+
/** Set default color proof for subsequent resource creation requests */
|
|
167
|
+
setDefaultColor(colorProof) {
|
|
168
|
+
this.sendVoidAsync({
|
|
169
|
+
oneofKind: "setDefaultColor",
|
|
170
|
+
setDefaultColor: { colorProof }
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
toSignedResourceId(rId) {
|
|
174
|
+
return toResourceIdAndSignature(rId);
|
|
175
|
+
}
|
|
176
|
+
toSignedFieldId(fId) {
|
|
177
|
+
const base = toFieldId(fId);
|
|
178
|
+
const signed = toResourceIdAndSignature(base.resourceId);
|
|
179
|
+
return {
|
|
180
|
+
resourceId: signed.resourceId,
|
|
181
|
+
fieldName: base.fieldName,
|
|
182
|
+
resourceSignature: signed.resourceSignature
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
toSignedErrorRef(rId) {
|
|
186
|
+
const { resourceId, resourceSignature } = this.toSignedResourceId(rId);
|
|
187
|
+
return {
|
|
188
|
+
errorResourceId: resourceId,
|
|
189
|
+
errorResourceSignature: resourceSignature
|
|
190
|
+
};
|
|
191
|
+
}
|
|
149
192
|
checkTxOpen() {
|
|
150
193
|
if (this._completed) throw new Error("Transaction already closed");
|
|
151
194
|
}
|
|
@@ -189,25 +232,19 @@ var PlTransaction = class PlTransaction {
|
|
|
189
232
|
await this.ll.await();
|
|
190
233
|
}
|
|
191
234
|
get clientRoot() {
|
|
192
|
-
return
|
|
235
|
+
return ensureSignedResourceIdNotNull(this._clientRoot);
|
|
193
236
|
}
|
|
194
|
-
createSingleton(name, type, errorIfExists = false) {
|
|
195
|
-
|
|
196
|
-
const globalId = this.sendSingleAndParse({
|
|
237
|
+
createSingleton(name, type, errorIfExists = false, color) {
|
|
238
|
+
return this.createResource(false, (localId) => ({
|
|
197
239
|
oneofKind: "resourceCreateSingleton",
|
|
198
240
|
resourceCreateSingleton: {
|
|
199
241
|
type,
|
|
200
242
|
id: localId,
|
|
201
243
|
data: Buffer.from(name),
|
|
202
244
|
errorIfExists,
|
|
203
|
-
colorProof:
|
|
245
|
+
colorProof: color ?? emptySignature
|
|
204
246
|
}
|
|
205
|
-
}, (r) => r.resourceCreateSingleton.resourceId);
|
|
206
|
-
this.track(globalId);
|
|
207
|
-
return {
|
|
208
|
-
globalId,
|
|
209
|
-
localId
|
|
210
|
-
};
|
|
247
|
+
}), (r) => r.resourceCreateSingleton.resourceId, (r) => r.resourceCreateSingleton.resourceSignature);
|
|
211
248
|
}
|
|
212
249
|
getSingleton(name, loadFields = true) {
|
|
213
250
|
return this.sendSingleAndParse({
|
|
@@ -218,9 +255,11 @@ var PlTransaction = class PlTransaction {
|
|
|
218
255
|
}
|
|
219
256
|
}, (r) => protoToResource(notEmpty(r.resourceGetSingleton.resource)));
|
|
220
257
|
}
|
|
221
|
-
createResource(root, req, parser) {
|
|
258
|
+
createResource(root, req, parser, sigExtractor) {
|
|
222
259
|
const localId = this.nextLocalResourceId(root);
|
|
223
|
-
const globalId = this.sendSingleAndParse(req(localId), (r) =>
|
|
260
|
+
const globalId = this.sendSingleAndParse(req(localId), (r) => {
|
|
261
|
+
return createSignedResourceId(parser(r), sigExtractor ? toResourceSignature(sigExtractor(r)) : void 0);
|
|
262
|
+
});
|
|
224
263
|
this.track(globalId);
|
|
225
264
|
return {
|
|
226
265
|
globalId,
|
|
@@ -235,9 +274,9 @@ var PlTransaction = class PlTransaction {
|
|
|
235
274
|
type,
|
|
236
275
|
id: localId
|
|
237
276
|
}
|
|
238
|
-
}), (r) => r.resourceCreateRoot.resourceId);
|
|
277
|
+
}), (r) => r.resourceCreateRoot.resourceId, (r) => r.resourceCreateRoot.resourceSignature);
|
|
239
278
|
}
|
|
240
|
-
createStruct(type, data) {
|
|
279
|
+
createStruct(type, data, color) {
|
|
241
280
|
this._stat.structsCreated++;
|
|
242
281
|
this._stat.structsCreatedDataBytes += data?.length ?? 0;
|
|
243
282
|
return this.createResource(false, (localId) => ({
|
|
@@ -246,11 +285,11 @@ var PlTransaction = class PlTransaction {
|
|
|
246
285
|
type,
|
|
247
286
|
id: localId,
|
|
248
287
|
data: data === void 0 ? void 0 : typeof data === "string" ? Buffer.from(data) : data,
|
|
249
|
-
colorProof:
|
|
288
|
+
colorProof: color ?? emptySignature
|
|
250
289
|
}
|
|
251
|
-
}), (r) => r.resourceCreateStruct.resourceId);
|
|
290
|
+
}), (r) => r.resourceCreateStruct.resourceId, (r) => r.resourceCreateStruct.resourceSignature);
|
|
252
291
|
}
|
|
253
|
-
createEphemeral(type, data) {
|
|
292
|
+
createEphemeral(type, data, color) {
|
|
254
293
|
this._stat.ephemeralsCreated++;
|
|
255
294
|
this._stat.ephemeralsCreatedDataBytes += data?.length ?? 0;
|
|
256
295
|
return this.createResource(false, (localId) => ({
|
|
@@ -259,11 +298,11 @@ var PlTransaction = class PlTransaction {
|
|
|
259
298
|
type,
|
|
260
299
|
id: localId,
|
|
261
300
|
data: data === void 0 ? void 0 : typeof data === "string" ? Buffer.from(data) : data,
|
|
262
|
-
colorProof:
|
|
301
|
+
colorProof: color ?? emptySignature
|
|
263
302
|
}
|
|
264
|
-
}), (r) => r.resourceCreateEphemeral.resourceId);
|
|
303
|
+
}), (r) => r.resourceCreateEphemeral.resourceId, (r) => r.resourceCreateEphemeral.resourceSignature);
|
|
265
304
|
}
|
|
266
|
-
createValue(type, data, errorIfExists = false) {
|
|
305
|
+
createValue(type, data, errorIfExists = false, color) {
|
|
267
306
|
this._stat.valuesCreated++;
|
|
268
307
|
this._stat.valuesCreatedDataBytes += data?.length ?? 0;
|
|
269
308
|
return this.createResource(false, (localId) => ({
|
|
@@ -273,26 +312,26 @@ var PlTransaction = class PlTransaction {
|
|
|
273
312
|
id: localId,
|
|
274
313
|
data: typeof data === "string" ? Buffer.from(data) : data,
|
|
275
314
|
errorIfExists,
|
|
276
|
-
colorProof:
|
|
315
|
+
colorProof: color ?? emptySignature
|
|
277
316
|
}
|
|
278
|
-
}), (r) => r.resourceCreateValue.resourceId);
|
|
317
|
+
}), (r) => r.resourceCreateValue.resourceId, (r) => r.resourceCreateValue.resourceSignature);
|
|
279
318
|
}
|
|
280
|
-
createJsonValue(data) {
|
|
319
|
+
createJsonValue(data, color) {
|
|
281
320
|
const jsonData = canonicalJsonBytes(data);
|
|
282
|
-
return this.createValue(JsonObject, jsonData, false);
|
|
321
|
+
return this.createValue(JsonObject, jsonData, false, color);
|
|
283
322
|
}
|
|
284
|
-
createJsonGzValue(data, minSizeToGzip = 16384) {
|
|
323
|
+
createJsonGzValue(data, minSizeToGzip = 16384, color) {
|
|
285
324
|
const { data: jsonData, isGzipped } = canonicalJsonGzBytes(data, minSizeToGzip);
|
|
286
|
-
return this.createValue(isGzipped ? JsonGzObject : JsonObject, jsonData, false);
|
|
325
|
+
return this.createValue(isGzipped ? JsonGzObject : JsonObject, jsonData, false, color);
|
|
287
326
|
}
|
|
288
|
-
createError(message) {
|
|
289
|
-
return this.createValue(ErrorResourceType, JSON.stringify({ message }));
|
|
327
|
+
createError(message, color) {
|
|
328
|
+
return this.createValue(ErrorResourceType, JSON.stringify({ message }), false, color);
|
|
290
329
|
}
|
|
291
330
|
setResourceName(name, rId) {
|
|
292
331
|
this.sendVoidAsync({
|
|
293
332
|
oneofKind: "resourceNameSet",
|
|
294
333
|
resourceNameSet: {
|
|
295
|
-
|
|
334
|
+
...this.toSignedResourceId(rId),
|
|
296
335
|
name
|
|
297
336
|
}
|
|
298
337
|
});
|
|
@@ -307,7 +346,11 @@ var PlTransaction = class PlTransaction {
|
|
|
307
346
|
return this.sendSingleAndParse({
|
|
308
347
|
oneofKind: "resourceNameGet",
|
|
309
348
|
resourceNameGet: { name }
|
|
310
|
-
}, (r) =>
|
|
349
|
+
}, (r) => {
|
|
350
|
+
const rawId = r.resourceNameGet.resourceId;
|
|
351
|
+
if (rawId === 0n) throw new Error("null resource id from getResourceByName");
|
|
352
|
+
return createSignedResourceId(rawId, toResourceSignature(r.resourceNameGet.resourceSignature));
|
|
353
|
+
});
|
|
311
354
|
}
|
|
312
355
|
checkResourceNameExists(name) {
|
|
313
356
|
return this.sendSingleAndParse({
|
|
@@ -318,18 +361,18 @@ var PlTransaction = class PlTransaction {
|
|
|
318
361
|
removeResource(rId) {
|
|
319
362
|
this.sendVoidAsync({
|
|
320
363
|
oneofKind: "resourceRemove",
|
|
321
|
-
resourceRemove:
|
|
364
|
+
resourceRemove: this.toSignedResourceId(rId)
|
|
322
365
|
});
|
|
323
366
|
}
|
|
324
367
|
resourceExists(rId) {
|
|
325
368
|
return this.sendSingleAndParse({
|
|
326
369
|
oneofKind: "resourceExists",
|
|
327
|
-
resourceExists:
|
|
370
|
+
resourceExists: this.toSignedResourceId(rId)
|
|
328
371
|
}, (r) => r.resourceExists.exists);
|
|
329
372
|
}
|
|
330
373
|
async getResourceData(rId, loadFields = true, ignoreCache = false) {
|
|
331
374
|
return this.track(async () => {
|
|
332
|
-
if (!ignoreCache &&
|
|
375
|
+
if (!ignoreCache && isResourceId(rId)) {
|
|
333
376
|
const fromCache = this.sharedResourceDataCache.get(rId);
|
|
334
377
|
if (fromCache && fromCache.cacheTxOpenTimestamp < this.txOpenTimestamp) {
|
|
335
378
|
if (!loadFields) {
|
|
@@ -347,14 +390,14 @@ var PlTransaction = class PlTransaction {
|
|
|
347
390
|
const result = await this.sendSingleAndParse({
|
|
348
391
|
oneofKind: "resourceGet",
|
|
349
392
|
resourceGet: {
|
|
350
|
-
|
|
393
|
+
...this.toSignedResourceId(rId),
|
|
351
394
|
loadFields
|
|
352
395
|
}
|
|
353
396
|
}, (r) => protoToResource(notEmpty(r.resourceGet.resource)));
|
|
354
397
|
this._stat.rGetDataNetRequests++;
|
|
355
398
|
this._stat.rGetDataNetBytes += result.data?.length ?? 0;
|
|
356
399
|
this._stat.rGetDataNetFields += result.fields.length;
|
|
357
|
-
if (
|
|
400
|
+
if (isResourceId(rId) && this.finalPredicate(result)) {
|
|
358
401
|
deepFreeze(result);
|
|
359
402
|
const fromCache = this.sharedResourceDataCache.get(rId);
|
|
360
403
|
if (fromCache) {
|
|
@@ -383,7 +426,7 @@ var PlTransaction = class PlTransaction {
|
|
|
383
426
|
async getResourceDataIfExists(rId, loadFields = true) {
|
|
384
427
|
return this.track(async () => {
|
|
385
428
|
const result = await notFoundToUndefined(async () => await this.getResourceData(rId, loadFields, true));
|
|
386
|
-
if (result === void 0 &&
|
|
429
|
+
if (result === void 0 && isResourceId(rId)) this.sharedResourceDataCache.delete(rId);
|
|
387
430
|
return result;
|
|
388
431
|
});
|
|
389
432
|
}
|
|
@@ -398,10 +441,7 @@ var PlTransaction = class PlTransaction {
|
|
|
398
441
|
this._stat.inputsLocked++;
|
|
399
442
|
this.sendVoidAsync({
|
|
400
443
|
oneofKind: "resourceLockInputs",
|
|
401
|
-
resourceLockInputs:
|
|
402
|
-
resourceId: toResourceId(rId),
|
|
403
|
-
resourceSignature: new Uint8Array(0)
|
|
404
|
-
}
|
|
444
|
+
resourceLockInputs: this.toSignedResourceId(rId)
|
|
405
445
|
});
|
|
406
446
|
}
|
|
407
447
|
/**
|
|
@@ -412,10 +452,7 @@ var PlTransaction = class PlTransaction {
|
|
|
412
452
|
this._stat.outputsLocked++;
|
|
413
453
|
this.sendVoidAsync({
|
|
414
454
|
oneofKind: "resourceLockOutputs",
|
|
415
|
-
resourceLockOutputs:
|
|
416
|
-
resourceId: toResourceId(rId),
|
|
417
|
-
resourceSignature: new Uint8Array(0)
|
|
418
|
-
}
|
|
455
|
+
resourceLockOutputs: this.toSignedResourceId(rId)
|
|
419
456
|
});
|
|
420
457
|
}
|
|
421
458
|
lock(rID) {
|
|
@@ -426,8 +463,8 @@ var PlTransaction = class PlTransaction {
|
|
|
426
463
|
this.sendVoidAsync({
|
|
427
464
|
oneofKind: "resourceSetError",
|
|
428
465
|
resourceSetError: {
|
|
429
|
-
|
|
430
|
-
|
|
466
|
+
...this.toSignedResourceId(rId),
|
|
467
|
+
...this.toSignedErrorRef(ref)
|
|
431
468
|
}
|
|
432
469
|
});
|
|
433
470
|
}
|
|
@@ -437,7 +474,7 @@ var PlTransaction = class PlTransaction {
|
|
|
437
474
|
oneofKind: "fieldCreate",
|
|
438
475
|
fieldCreate: {
|
|
439
476
|
type: fieldTypeToProto(fieldType),
|
|
440
|
-
id:
|
|
477
|
+
id: this.toSignedFieldId(fId)
|
|
441
478
|
}
|
|
442
479
|
});
|
|
443
480
|
if (value !== void 0) this.setField(fId, value);
|
|
@@ -445,7 +482,7 @@ var PlTransaction = class PlTransaction {
|
|
|
445
482
|
fieldExists(fId) {
|
|
446
483
|
return this.sendSingleAndParse({
|
|
447
484
|
oneofKind: "fieldExists",
|
|
448
|
-
fieldExists: { field:
|
|
485
|
+
fieldExists: { field: this.toSignedFieldId(fId) }
|
|
449
486
|
}, (r) => r.fieldExists.exists);
|
|
450
487
|
}
|
|
451
488
|
setField(fId, ref) {
|
|
@@ -453,9 +490,9 @@ var PlTransaction = class PlTransaction {
|
|
|
453
490
|
if (isResource(ref)) this.sendVoidAsync({
|
|
454
491
|
oneofKind: "fieldSet",
|
|
455
492
|
fieldSet: {
|
|
456
|
-
field:
|
|
493
|
+
field: this.toSignedFieldId(fId),
|
|
457
494
|
value: {
|
|
458
|
-
|
|
495
|
+
...this.toSignedResourceId(ref),
|
|
459
496
|
fieldName: ""
|
|
460
497
|
}
|
|
461
498
|
}
|
|
@@ -463,8 +500,8 @@ var PlTransaction = class PlTransaction {
|
|
|
463
500
|
else this.sendVoidAsync({
|
|
464
501
|
oneofKind: "fieldSet",
|
|
465
502
|
fieldSet: {
|
|
466
|
-
field:
|
|
467
|
-
value:
|
|
503
|
+
field: this.toSignedFieldId(fId),
|
|
504
|
+
value: this.toSignedFieldId(ref)
|
|
468
505
|
}
|
|
469
506
|
});
|
|
470
507
|
}
|
|
@@ -473,8 +510,8 @@ var PlTransaction = class PlTransaction {
|
|
|
473
510
|
this.sendVoidAsync({
|
|
474
511
|
oneofKind: "fieldSetError",
|
|
475
512
|
fieldSetError: {
|
|
476
|
-
field:
|
|
477
|
-
|
|
513
|
+
field: this.toSignedFieldId(fId),
|
|
514
|
+
...this.toSignedErrorRef(ref)
|
|
478
515
|
}
|
|
479
516
|
});
|
|
480
517
|
}
|
|
@@ -482,7 +519,7 @@ var PlTransaction = class PlTransaction {
|
|
|
482
519
|
this._stat.fieldsGet++;
|
|
483
520
|
return this.sendSingleAndParse({
|
|
484
521
|
oneofKind: "fieldGet",
|
|
485
|
-
fieldGet: { field:
|
|
522
|
+
fieldGet: { field: this.toSignedFieldId(fId) }
|
|
486
523
|
}, (r) => protoToField(notEmpty(r.fieldGet.field)));
|
|
487
524
|
}
|
|
488
525
|
async getFieldIfExists(fId) {
|
|
@@ -491,13 +528,13 @@ var PlTransaction = class PlTransaction {
|
|
|
491
528
|
resetField(fId) {
|
|
492
529
|
this.sendVoidAsync({
|
|
493
530
|
oneofKind: "fieldReset",
|
|
494
|
-
fieldReset: { field:
|
|
531
|
+
fieldReset: { field: this.toSignedFieldId(fId) }
|
|
495
532
|
});
|
|
496
533
|
}
|
|
497
534
|
removeField(fId) {
|
|
498
535
|
this.sendVoidAsync({
|
|
499
536
|
oneofKind: "fieldRemove",
|
|
500
|
-
fieldRemove: { field:
|
|
537
|
+
fieldRemove: { field: this.toSignedFieldId(fId) }
|
|
501
538
|
});
|
|
502
539
|
}
|
|
503
540
|
async listKeyValues(rId) {
|
|
@@ -505,7 +542,7 @@ var PlTransaction = class PlTransaction {
|
|
|
505
542
|
const result = await this.sendMultiAndParse({
|
|
506
543
|
oneofKind: "resourceKeyValueList",
|
|
507
544
|
resourceKeyValueList: {
|
|
508
|
-
|
|
545
|
+
...this.toSignedResourceId(rId),
|
|
509
546
|
startFrom: "",
|
|
510
547
|
limit: 0
|
|
511
548
|
}
|
|
@@ -534,8 +571,7 @@ var PlTransaction = class PlTransaction {
|
|
|
534
571
|
this.sendVoidAsync({
|
|
535
572
|
oneofKind: "resourceKeyValueSet",
|
|
536
573
|
resourceKeyValueSet: {
|
|
537
|
-
|
|
538
|
-
resourceSignature: new Uint8Array(0),
|
|
574
|
+
...this.toSignedResourceId(rId),
|
|
539
575
|
key,
|
|
540
576
|
value: toBytes(value)
|
|
541
577
|
}
|
|
@@ -545,8 +581,7 @@ var PlTransaction = class PlTransaction {
|
|
|
545
581
|
this.sendVoidAsync({
|
|
546
582
|
oneofKind: "resourceKeyValueDelete",
|
|
547
583
|
resourceKeyValueDelete: {
|
|
548
|
-
|
|
549
|
-
resourceSignature: new Uint8Array(0),
|
|
584
|
+
...this.toSignedResourceId(rId),
|
|
550
585
|
key
|
|
551
586
|
}
|
|
552
587
|
});
|
|
@@ -556,7 +591,7 @@ var PlTransaction = class PlTransaction {
|
|
|
556
591
|
const result = await this.sendSingleAndParse({
|
|
557
592
|
oneofKind: "resourceKeyValueGet",
|
|
558
593
|
resourceKeyValueGet: {
|
|
559
|
-
|
|
594
|
+
...this.toSignedResourceId(rId),
|
|
560
595
|
key
|
|
561
596
|
}
|
|
562
597
|
}, (r) => r.resourceKeyValueGet.value);
|
|
@@ -576,7 +611,7 @@ var PlTransaction = class PlTransaction {
|
|
|
576
611
|
const result = await this.sendSingleAndParse({
|
|
577
612
|
oneofKind: "resourceKeyValueGetIfExists",
|
|
578
613
|
resourceKeyValueGetIfExists: {
|
|
579
|
-
|
|
614
|
+
...this.toSignedResourceId(rId),
|
|
580
615
|
key
|
|
581
616
|
}
|
|
582
617
|
}, (r) => r.resourceKeyValueGetIfExists.exists ? r.resourceKeyValueGetIfExists.value : void 0);
|
|
@@ -593,7 +628,7 @@ var PlTransaction = class PlTransaction {
|
|
|
593
628
|
}
|
|
594
629
|
async getKValueJsonIfExists(rId, key) {
|
|
595
630
|
return this.track(async () => {
|
|
596
|
-
const str = await this.
|
|
631
|
+
const str = await this.getKValueStringIfExists(rId, key);
|
|
597
632
|
if (str === void 0) return void 0;
|
|
598
633
|
return JSON.parse(str);
|
|
599
634
|
});
|
|
@@ -645,6 +680,6 @@ var PlTransaction = class PlTransaction {
|
|
|
645
680
|
}
|
|
646
681
|
};
|
|
647
682
|
//#endregion
|
|
648
|
-
export { PlTransaction, TxCommitConflict, field, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId
|
|
683
|
+
export { PlTransaction, TxCommitConflict, field, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId };
|
|
649
684
|
|
|
650
685
|
//# sourceMappingURL=transaction.js.map
|