@milaboratories/pl-client 2.11.8 → 2.11.10
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/auth.cjs +24 -0
- package/dist/core/auth.cjs.map +1 -0
- package/dist/core/auth.d.ts +1 -1
- package/dist/core/auth.js +21 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/cache.d.ts +1 -1
- package/dist/core/client.cjs +288 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.ts +10 -10
- package/dist/core/client.js +267 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/config.cjs +111 -0
- package/dist/core/config.cjs.map +1 -0
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +95 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/default_client.cjs +143 -0
- package/dist/core/default_client.cjs.map +1 -0
- package/dist/core/default_client.d.ts +1 -1
- package/dist/core/default_client.js +120 -0
- package/dist/core/default_client.js.map +1 -0
- package/dist/core/driver.cjs +14 -0
- package/dist/core/driver.cjs.map +1 -0
- package/dist/core/driver.d.ts +5 -5
- package/dist/core/driver.js +12 -0
- package/dist/core/driver.js.map +1 -0
- package/dist/core/error_resource.cjs +9 -0
- package/dist/core/error_resource.cjs.map +1 -0
- package/dist/core/error_resource.d.ts +1 -1
- package/dist/core/error_resource.js +7 -0
- package/dist/core/error_resource.js.map +1 -0
- package/dist/core/errors.cjs +106 -0
- package/dist/core/errors.cjs.map +1 -0
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.js +93 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/final.cjs +98 -0
- package/dist/core/final.cjs.map +1 -0
- package/dist/core/final.d.ts +2 -2
- package/dist/core/final.js +96 -0
- package/dist/core/final.js.map +1 -0
- package/dist/core/grpc.d.ts +1 -1
- package/dist/core/http.d.ts +1 -0
- package/dist/core/ll_client.cjs +266 -0
- package/dist/core/ll_client.cjs.map +1 -0
- package/dist/core/ll_client.d.ts +3 -3
- package/dist/core/ll_client.js +264 -0
- package/dist/core/ll_client.js.map +1 -0
- package/dist/core/ll_transaction.cjs +236 -0
- package/dist/core/ll_transaction.cjs.map +1 -0
- package/dist/core/ll_transaction.d.ts +2 -2
- package/dist/core/ll_transaction.js +233 -0
- package/dist/core/ll_transaction.js.map +1 -0
- package/dist/core/stat.cjs +74 -0
- package/dist/core/stat.cjs.map +1 -0
- package/dist/core/stat.js +70 -0
- package/dist/core/stat.js.map +1 -0
- package/dist/core/transaction.cjs +626 -0
- package/dist/core/transaction.cjs.map +1 -0
- package/dist/core/transaction.d.ts +6 -6
- package/dist/core/transaction.js +613 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/core/type_conversion.cjs +106 -0
- package/dist/core/type_conversion.cjs.map +1 -0
- package/dist/core/type_conversion.d.ts +2 -2
- package/dist/core/type_conversion.js +102 -0
- package/dist/core/type_conversion.js.map +1 -0
- package/dist/core/types.cjs +159 -0
- package/dist/core/types.cjs.map +1 -0
- package/dist/core/types.js +134 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/unauth_client.cjs +43 -0
- package/dist/core/unauth_client.cjs.map +1 -0
- package/dist/core/unauth_client.d.ts +2 -2
- package/dist/core/unauth_client.js +41 -0
- package/dist/core/unauth_client.js.map +1 -0
- package/dist/helpers/pl.cjs +124 -0
- package/dist/helpers/pl.cjs.map +1 -0
- package/dist/helpers/pl.d.ts +10 -2
- package/dist/helpers/pl.js +94 -0
- package/dist/helpers/pl.js.map +1 -0
- package/dist/helpers/poll.cjs +148 -0
- package/dist/helpers/poll.cjs.map +1 -0
- package/dist/helpers/poll.d.ts +4 -4
- package/dist/helpers/poll.js +123 -0
- package/dist/helpers/poll.js.map +1 -0
- package/dist/helpers/rich_resource_types.d.ts +1 -0
- package/dist/helpers/smart_accessors.d.ts +1 -0
- package/dist/helpers/state_helpers.d.ts +1 -1
- package/dist/helpers/tx_helpers.cjs +25 -0
- package/dist/helpers/tx_helpers.cjs.map +1 -0
- package/dist/helpers/tx_helpers.d.ts +2 -2
- package/dist/helpers/tx_helpers.js +23 -0
- package/dist/helpers/tx_helpers.js.map +1 -0
- package/dist/index.cjs +99 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.cjs +71 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.d.ts +7 -2
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.js +69 -0
- package/dist/proto/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.client.d.ts +8 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/downloadapi/protocol.d.ts +7 -2
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.client.d.ts +8 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.d.ts +8 -3
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.client.d.ts +11 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/progressapi/protocol.d.ts +8 -3
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.client.d.ts +13 -5
- package/dist/proto/github.com/milaboratory/pl/controllers/shared/grpc/streamingapi/protocol.d.ts +7 -2
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12238 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +223 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +57 -5
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +221 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +21 -7
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.js +12086 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1127 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +11 -4
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1113 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +152 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +6 -1
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +149 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +22 -7
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +500 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +7 -2
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +496 -0
- package/dist/proto/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -0
- package/dist/proto/google/api/http.d.ts +6 -1
- package/dist/proto/google/protobuf/any.cjs +151 -0
- package/dist/proto/google/protobuf/any.cjs.map +1 -0
- package/dist/proto/google/protobuf/any.d.ts +10 -1
- package/dist/proto/google/protobuf/any.js +149 -0
- package/dist/proto/google/protobuf/any.js.map +1 -0
- package/dist/proto/google/protobuf/descriptor.d.ts +6 -1
- package/dist/proto/google/protobuf/duration.cjs +105 -0
- package/dist/proto/google/protobuf/duration.cjs.map +1 -0
- package/dist/proto/google/protobuf/duration.d.ts +9 -1
- package/dist/proto/google/protobuf/duration.js +103 -0
- package/dist/proto/google/protobuf/duration.js.map +1 -0
- package/dist/proto/google/protobuf/empty.d.ts +6 -1
- package/dist/proto/google/protobuf/struct.d.ts +9 -1
- package/dist/proto/google/protobuf/timestamp.cjs +133 -0
- package/dist/proto/google/protobuf/timestamp.cjs.map +1 -0
- package/dist/proto/google/protobuf/timestamp.d.ts +9 -1
- package/dist/proto/google/protobuf/timestamp.js +131 -0
- package/dist/proto/google/protobuf/timestamp.js.map +1 -0
- package/dist/proto/google/protobuf/wrappers.d.ts +9 -1
- package/dist/test/test_config.cjs +149 -0
- package/dist/test/test_config.cjs.map +1 -0
- package/dist/test/test_config.d.ts +1 -1
- package/dist/test/test_config.js +123 -0
- package/dist/test/test_config.js.map +1 -0
- package/dist/util/pl.cjs +8 -0
- package/dist/util/pl.cjs.map +1 -0
- package/dist/util/pl.js +6 -0
- package/dist/util/pl.js.map +1 -0
- package/dist/util/util.cjs +17 -0
- package/dist/util/util.cjs.map +1 -0
- package/dist/util/util.js +15 -0
- package/dist/util/util.js.map +1 -0
- package/package.json +14 -11
- package/src/core/client.test.ts +1 -0
- package/src/core/config.test.ts +1 -0
- package/src/core/error.test.ts +1 -0
- package/src/core/ll_client.test.ts +1 -0
- package/src/core/ll_transaction.test.ts +1 -0
- package/src/core/transaction.test.ts +1 -0
- package/src/core/types.test.ts +1 -0
- package/src/core/unauth_client.test.ts +1 -0
- package/src/helpers/rich_resource_types.test.ts +2 -0
- package/src/test/test_config.test.ts +1 -0
- package/src/util/util.test.ts +1 -0
- package/dist/index.mjs +0 -14537
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var types = require('./types.cjs');
|
|
4
|
+
|
|
5
|
+
function readyOrDuplicateOrError(r) {
|
|
6
|
+
return (r.resourceReady || types.isNotNullResourceId(r.originalResourceId) || types.isNotNullResourceId(r.error));
|
|
7
|
+
}
|
|
8
|
+
function readyAndHasAllOutputsFilled(r) {
|
|
9
|
+
if (!readyOrDuplicateOrError(r))
|
|
10
|
+
return false;
|
|
11
|
+
if (!r.outputsLocked)
|
|
12
|
+
return false;
|
|
13
|
+
if (r.fields === undefined)
|
|
14
|
+
return true; // if fields are not provided basic resource state is not expected to change in the future
|
|
15
|
+
for (const f of r.fields)
|
|
16
|
+
if (types.isNullResourceId(f.error) && (types.isNullResourceId(f.value) || !f.valueIsFinal))
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
// solely for logging
|
|
21
|
+
const unknownResourceTypeNames = new Set();
|
|
22
|
+
/** Default implementation, defining behaviour for built-in resource types. */
|
|
23
|
+
const DefaultFinalResourceDataPredicate = (r) => {
|
|
24
|
+
switch (r.type.name) {
|
|
25
|
+
case 'StreamManager': {
|
|
26
|
+
if (!readyOrDuplicateOrError(r))
|
|
27
|
+
return false;
|
|
28
|
+
if (r.fields === undefined)
|
|
29
|
+
return true; // if fields are not provided basic resource state is not expected to change in the future
|
|
30
|
+
if (types.isNotNullResourceId(r.error))
|
|
31
|
+
return true;
|
|
32
|
+
const downloadable = types.getField(r, 'downloadable');
|
|
33
|
+
const stream = types.getField(r, 'stream');
|
|
34
|
+
return stream.value === downloadable.value;
|
|
35
|
+
}
|
|
36
|
+
case 'StdMap':
|
|
37
|
+
case 'std/map':
|
|
38
|
+
case 'EphStdMap':
|
|
39
|
+
case 'PFrame':
|
|
40
|
+
case 'BContext':
|
|
41
|
+
case 'BlockPackCustom':
|
|
42
|
+
case 'BinaryMap':
|
|
43
|
+
case 'BinaryValue':
|
|
44
|
+
case 'BlobMap':
|
|
45
|
+
case 'BResolveSingle':
|
|
46
|
+
case 'BResolveSingleNoResult':
|
|
47
|
+
case 'BQueryResult':
|
|
48
|
+
case 'TengoTemplate':
|
|
49
|
+
case 'TengoLib':
|
|
50
|
+
case 'SoftwareInfo':
|
|
51
|
+
case 'Dummy':
|
|
52
|
+
return readyOrDuplicateOrError(r);
|
|
53
|
+
case 'json/resourceError':
|
|
54
|
+
return r.type.version === '1';
|
|
55
|
+
case 'json/object':
|
|
56
|
+
case 'json-gz/object':
|
|
57
|
+
case 'json/string':
|
|
58
|
+
case 'json/array':
|
|
59
|
+
case 'json/number':
|
|
60
|
+
case 'BContextEnd':
|
|
61
|
+
case 'Frontend/FromUrl':
|
|
62
|
+
case 'Frontend/FromFolder':
|
|
63
|
+
case 'BObjectSpec':
|
|
64
|
+
case 'Blob':
|
|
65
|
+
case 'Null':
|
|
66
|
+
case 'binary':
|
|
67
|
+
case 'LSProvider':
|
|
68
|
+
return true;
|
|
69
|
+
case 'UserProject':
|
|
70
|
+
case 'Projects':
|
|
71
|
+
case 'ClientRoot':
|
|
72
|
+
return false;
|
|
73
|
+
default:
|
|
74
|
+
if (r.type.name.startsWith('Blob/'))
|
|
75
|
+
return true;
|
|
76
|
+
else if (r.type.name.startsWith('BlobUpload/') || r.type.name.startsWith('BlobIndex/')) {
|
|
77
|
+
return readyAndHasAllOutputsFilled(r);
|
|
78
|
+
}
|
|
79
|
+
else if (r.type.name.startsWith('PColumnData/')) {
|
|
80
|
+
return readyOrDuplicateOrError(r);
|
|
81
|
+
}
|
|
82
|
+
else if (r.type.name.startsWith('StreamWorkdir/')) {
|
|
83
|
+
return readyOrDuplicateOrError(r);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Unknonw resource type detected
|
|
87
|
+
// Set used to log this message only once
|
|
88
|
+
if (!unknownResourceTypeNames.has(r.type.name)) {
|
|
89
|
+
console.log('UNKNOWN RESOURCE TYPE: ' + r.type.name);
|
|
90
|
+
unknownResourceTypeNames.add(r.type.name);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.DefaultFinalResourceDataPredicate = DefaultFinalResourceDataPredicate;
|
|
98
|
+
//# sourceMappingURL=final.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final.cjs","sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from 'utility-types';\nimport type {\n BasicResourceData,\n ResourceData,\n} from './types';\nimport {\n getField,\n isNotNullResourceId,\n isNullResourceId,\n} from './types';\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, 'fields'>\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady || isNotNullResourceId(r.originalResourceId) || isNotNullResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, 'fields'>): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullResourceId(f.error) && (isNullResourceId(f.value) || !f.valueIsFinal)) return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case 'StreamManager': {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, 'downloadable');\n const stream = getField(r as ResourceData, 'stream');\n return stream.value === downloadable.value;\n }\n case 'StdMap':\n case 'std/map':\n case 'EphStdMap':\n case 'PFrame':\n case 'BContext':\n case 'BlockPackCustom':\n case 'BinaryMap':\n case 'BinaryValue':\n case 'BlobMap':\n case 'BResolveSingle':\n case 'BResolveSingleNoResult':\n case 'BQueryResult':\n case 'TengoTemplate':\n case 'TengoLib':\n case 'SoftwareInfo':\n case 'Dummy':\n return readyOrDuplicateOrError(r);\n case 'json/resourceError':\n return r.type.version === '1';\n case 'json/object':\n case 'json-gz/object':\n case 'json/string':\n case 'json/array':\n case 'json/number':\n case 'BContextEnd':\n case 'Frontend/FromUrl':\n case 'Frontend/FromFolder':\n case 'BObjectSpec':\n case 'Blob':\n case 'Null':\n case 'binary':\n case 'LSProvider':\n return true;\n case 'UserProject':\n case 'Projects':\n case 'ClientRoot':\n return false;\n default:\n if (r.type.name.startsWith('Blob/')) return true;\n else if (r.type.name.startsWith('BlobUpload/') || r.type.name.startsWith('BlobIndex/')) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith('PColumnData/')) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith('StreamWorkdir/')) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknonw resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log('UNKNOWN RESOURCE TYPE: ' + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"names":["isNotNullResourceId","isNullResourceId","getField"],"mappings":";;;;AAwBA,SAAS,uBAAuB,CAAC,CAAmC,EAAA;AAClE,IAAA,QACE,CAAC,CAAC,aAAa,IAAIA,yBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAIA,yBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;AAEhG;AAEA,SAAS,2BAA2B,CAAC,CAAmC,EAAA;AACtE,IAAA,IAAI,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AAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACnD,gBAAA,OAAO,uBAAuB,CAAC,CAAC,CAAC;YACnC;iBAAO;;;AAGL,gBAAA,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC9C,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;oBACpD,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC3C;YACF;;AAEJ,IAAA,OAAO,KAAK;AACd;;;;"}
|
package/dist/core/final.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Optional } from 'utility-types';
|
|
2
|
-
import { ResourceData } from './types';
|
|
1
|
+
import type { Optional } from 'utility-types';
|
|
2
|
+
import type { ResourceData } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Function is used to guide multiple layers of caching in pl-client and derived pl-tree.
|
|
5
5
|
*
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { isNotNullResourceId, getField, isNullResourceId } from './types.js';
|
|
2
|
+
|
|
3
|
+
function readyOrDuplicateOrError(r) {
|
|
4
|
+
return (r.resourceReady || isNotNullResourceId(r.originalResourceId) || isNotNullResourceId(r.error));
|
|
5
|
+
}
|
|
6
|
+
function readyAndHasAllOutputsFilled(r) {
|
|
7
|
+
if (!readyOrDuplicateOrError(r))
|
|
8
|
+
return false;
|
|
9
|
+
if (!r.outputsLocked)
|
|
10
|
+
return false;
|
|
11
|
+
if (r.fields === undefined)
|
|
12
|
+
return true; // if fields are not provided basic resource state is not expected to change in the future
|
|
13
|
+
for (const f of r.fields)
|
|
14
|
+
if (isNullResourceId(f.error) && (isNullResourceId(f.value) || !f.valueIsFinal))
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
// solely for logging
|
|
19
|
+
const unknownResourceTypeNames = new Set();
|
|
20
|
+
/** Default implementation, defining behaviour for built-in resource types. */
|
|
21
|
+
const DefaultFinalResourceDataPredicate = (r) => {
|
|
22
|
+
switch (r.type.name) {
|
|
23
|
+
case 'StreamManager': {
|
|
24
|
+
if (!readyOrDuplicateOrError(r))
|
|
25
|
+
return false;
|
|
26
|
+
if (r.fields === undefined)
|
|
27
|
+
return true; // if fields are not provided basic resource state is not expected to change in the future
|
|
28
|
+
if (isNotNullResourceId(r.error))
|
|
29
|
+
return true;
|
|
30
|
+
const downloadable = getField(r, 'downloadable');
|
|
31
|
+
const stream = getField(r, 'stream');
|
|
32
|
+
return stream.value === downloadable.value;
|
|
33
|
+
}
|
|
34
|
+
case 'StdMap':
|
|
35
|
+
case 'std/map':
|
|
36
|
+
case 'EphStdMap':
|
|
37
|
+
case 'PFrame':
|
|
38
|
+
case 'BContext':
|
|
39
|
+
case 'BlockPackCustom':
|
|
40
|
+
case 'BinaryMap':
|
|
41
|
+
case 'BinaryValue':
|
|
42
|
+
case 'BlobMap':
|
|
43
|
+
case 'BResolveSingle':
|
|
44
|
+
case 'BResolveSingleNoResult':
|
|
45
|
+
case 'BQueryResult':
|
|
46
|
+
case 'TengoTemplate':
|
|
47
|
+
case 'TengoLib':
|
|
48
|
+
case 'SoftwareInfo':
|
|
49
|
+
case 'Dummy':
|
|
50
|
+
return readyOrDuplicateOrError(r);
|
|
51
|
+
case 'json/resourceError':
|
|
52
|
+
return r.type.version === '1';
|
|
53
|
+
case 'json/object':
|
|
54
|
+
case 'json-gz/object':
|
|
55
|
+
case 'json/string':
|
|
56
|
+
case 'json/array':
|
|
57
|
+
case 'json/number':
|
|
58
|
+
case 'BContextEnd':
|
|
59
|
+
case 'Frontend/FromUrl':
|
|
60
|
+
case 'Frontend/FromFolder':
|
|
61
|
+
case 'BObjectSpec':
|
|
62
|
+
case 'Blob':
|
|
63
|
+
case 'Null':
|
|
64
|
+
case 'binary':
|
|
65
|
+
case 'LSProvider':
|
|
66
|
+
return true;
|
|
67
|
+
case 'UserProject':
|
|
68
|
+
case 'Projects':
|
|
69
|
+
case 'ClientRoot':
|
|
70
|
+
return false;
|
|
71
|
+
default:
|
|
72
|
+
if (r.type.name.startsWith('Blob/'))
|
|
73
|
+
return true;
|
|
74
|
+
else if (r.type.name.startsWith('BlobUpload/') || r.type.name.startsWith('BlobIndex/')) {
|
|
75
|
+
return readyAndHasAllOutputsFilled(r);
|
|
76
|
+
}
|
|
77
|
+
else if (r.type.name.startsWith('PColumnData/')) {
|
|
78
|
+
return readyOrDuplicateOrError(r);
|
|
79
|
+
}
|
|
80
|
+
else if (r.type.name.startsWith('StreamWorkdir/')) {
|
|
81
|
+
return readyOrDuplicateOrError(r);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Unknonw resource type detected
|
|
85
|
+
// Set used to log this message only once
|
|
86
|
+
if (!unknownResourceTypeNames.has(r.type.name)) {
|
|
87
|
+
console.log('UNKNOWN RESOURCE TYPE: ' + r.type.name);
|
|
88
|
+
unknownResourceTypeNames.add(r.type.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { DefaultFinalResourceDataPredicate };
|
|
96
|
+
//# sourceMappingURL=final.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final.js","sources":["../../src/core/final.ts"],"sourcesContent":["import type { Optional } from 'utility-types';\nimport type {\n BasicResourceData,\n ResourceData,\n} from './types';\nimport {\n getField,\n isNotNullResourceId,\n isNullResourceId,\n} from './types';\n\n/**\n * Function is used to guide multiple layers of caching in pl-client and derived pl-tree.\n *\n * This function defines expected resource-specific state mutation behaviour,\n * if it returns true, system will expect that this data will never change as long as resource exist.\n *\n * If resource data contain information about fields, if should be taken into account, fields are undefined,\n * \"final\" state should be calculated for \"basic\" part of resource data only.\n */\nexport type FinalResourceDataPredicate = (\n resourceData: Optional<ResourceData, 'fields'>\n) => boolean;\n\nfunction readyOrDuplicateOrError(r: ResourceData | BasicResourceData): boolean {\n return (\n r.resourceReady || isNotNullResourceId(r.originalResourceId) || isNotNullResourceId(r.error)\n );\n}\n\nfunction readyAndHasAllOutputsFilled(r: Optional<ResourceData, 'fields'>): boolean {\n if (!readyOrDuplicateOrError(r)) return false;\n if (!r.outputsLocked) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n for (const f of r.fields)\n if (isNullResourceId(f.error) && (isNullResourceId(f.value) || !f.valueIsFinal)) return false;\n return true;\n}\n\n// solely for logging\nconst unknownResourceTypeNames = new Set<string>();\n\n/** Default implementation, defining behaviour for built-in resource types. */\nexport const DefaultFinalResourceDataPredicate: FinalResourceDataPredicate = (r): boolean => {\n switch (r.type.name) {\n case 'StreamManager': {\n if (!readyOrDuplicateOrError(r)) return false;\n if (r.fields === undefined) return true; // if fields are not provided basic resource state is not expected to change in the future\n if (isNotNullResourceId(r.error)) return true;\n const downloadable = getField(r as ResourceData, 'downloadable');\n const stream = getField(r as ResourceData, 'stream');\n return stream.value === downloadable.value;\n }\n case 'StdMap':\n case 'std/map':\n case 'EphStdMap':\n case 'PFrame':\n case 'BContext':\n case 'BlockPackCustom':\n case 'BinaryMap':\n case 'BinaryValue':\n case 'BlobMap':\n case 'BResolveSingle':\n case 'BResolveSingleNoResult':\n case 'BQueryResult':\n case 'TengoTemplate':\n case 'TengoLib':\n case 'SoftwareInfo':\n case 'Dummy':\n return readyOrDuplicateOrError(r);\n case 'json/resourceError':\n return r.type.version === '1';\n case 'json/object':\n case 'json-gz/object':\n case 'json/string':\n case 'json/array':\n case 'json/number':\n case 'BContextEnd':\n case 'Frontend/FromUrl':\n case 'Frontend/FromFolder':\n case 'BObjectSpec':\n case 'Blob':\n case 'Null':\n case 'binary':\n case 'LSProvider':\n return true;\n case 'UserProject':\n case 'Projects':\n case 'ClientRoot':\n return false;\n default:\n if (r.type.name.startsWith('Blob/')) return true;\n else if (r.type.name.startsWith('BlobUpload/') || r.type.name.startsWith('BlobIndex/')) {\n return readyAndHasAllOutputsFilled(r);\n } else if (r.type.name.startsWith('PColumnData/')) {\n return readyOrDuplicateOrError(r);\n } else if (r.type.name.startsWith('StreamWorkdir/')) {\n return readyOrDuplicateOrError(r);\n } else {\n // Unknonw resource type detected\n // Set used to log this message only once\n if (!unknownResourceTypeNames.has(r.type.name)) {\n console.log('UNKNOWN RESOURCE TYPE: ' + r.type.name);\n unknownResourceTypeNames.add(r.type.name);\n }\n }\n }\n return false;\n};\n"],"names":[],"mappings":";;AAwBA,SAAS,uBAAuB,CAAC,CAAmC,EAAA;AAClE,IAAA,QACE,CAAC,CAAC,aAAa,IAAI,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;AAEhG;AAEA,SAAS,2BAA2B,CAAC,CAAmC,EAAA;AACtE,IAAA,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAAE,QAAA,OAAO,KAAK;IAC7C,IAAI,CAAC,CAAC,CAAC,aAAa;AAAE,QAAA,OAAO,KAAK;AAClC,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;AACxC,IAAA,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM;AACtB,QAAA,IAAI,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;AAAE,YAAA,OAAO,KAAK;AAC/F,IAAA,OAAO,IAAI;AACb;AAEA;AACA,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAU;AAElD;AACO,MAAM,iCAAiC,GAA+B,CAAC,CAAC,KAAa;AAC1F,IAAA,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI;QACjB,KAAK,eAAe,EAAE;AACpB,YAAA,IAAI,CAAC,uBAAuB,CAAC,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AAA,OAAO,IAAI;AACb,QAAA,KAAK,aAAa;AAClB,QAAA,KAAK,UAAU;AACf,QAAA,KAAK,YAAY;AACf,YAAA,OAAO,KAAK;AACd,QAAA;YACE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AAAE,gBAAA,OAAO,IAAI;iBAC3C,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;AACtF,gBAAA,OAAO,2BAA2B,CAAC,CAAC,CAAC;YACvC;iBAAO,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;AACjD,gBAAA,OAAO,uBAAuB,CAAC,CAAC,CAAC;YACnC;iBAAO,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;AACnD,gBAAA,OAAO,uBAAuB,CAAC,CAAC,CAAC;YACnC;iBAAO;;;AAGL,gBAAA,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC9C,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;oBACpD,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC3C;YACF;;AAEJ,IAAA,OAAO,KAAK;AACd;;;;"}
|
package/dist/core/grpc.d.ts
CHANGED
package/dist/core/http.d.ts
CHANGED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var api_client = require('../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs');
|
|
4
|
+
var grpcJs = require('@grpc/grpc-js');
|
|
5
|
+
var config = require('./config.cjs');
|
|
6
|
+
var grpcTransport = require('@protobuf-ts/grpc-transport');
|
|
7
|
+
var ll_transaction = require('./ll_transaction.cjs');
|
|
8
|
+
var pl = require('../util/pl.cjs');
|
|
9
|
+
var auth = require('./auth.cjs');
|
|
10
|
+
var plHttp = require('@milaboratories/pl-http');
|
|
11
|
+
|
|
12
|
+
class GrpcClientProviderImpl {
|
|
13
|
+
grpcTransport;
|
|
14
|
+
clientConstructor;
|
|
15
|
+
client = undefined;
|
|
16
|
+
constructor(grpcTransport, clientConstructor) {
|
|
17
|
+
this.grpcTransport = grpcTransport;
|
|
18
|
+
this.clientConstructor = clientConstructor;
|
|
19
|
+
}
|
|
20
|
+
reset() {
|
|
21
|
+
this.client = undefined;
|
|
22
|
+
}
|
|
23
|
+
get() {
|
|
24
|
+
if (this.client === undefined)
|
|
25
|
+
this.client = this.clientConstructor(this.grpcTransport());
|
|
26
|
+
return this.client;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Abstract out low level networking and authorization details */
|
|
30
|
+
class LLPlClient {
|
|
31
|
+
ops;
|
|
32
|
+
conf;
|
|
33
|
+
/** Initial authorization information */
|
|
34
|
+
authInformation;
|
|
35
|
+
/** Will be executed by the client when it is required */
|
|
36
|
+
onAuthUpdate;
|
|
37
|
+
/** Will be executed if auth-related error happens during normal client operation */
|
|
38
|
+
onAuthError;
|
|
39
|
+
/** Will be executed by the client when it is required */
|
|
40
|
+
onAuthRefreshProblem;
|
|
41
|
+
/** Threshold after which auth info refresh is required */
|
|
42
|
+
refreshTimestamp;
|
|
43
|
+
_status = 'OK';
|
|
44
|
+
statusListener;
|
|
45
|
+
grpcInterceptors;
|
|
46
|
+
_grpcTransport;
|
|
47
|
+
providers = [];
|
|
48
|
+
grpcPl;
|
|
49
|
+
httpDispatcher;
|
|
50
|
+
constructor(configOrAddress, ops = {}) {
|
|
51
|
+
this.ops = ops;
|
|
52
|
+
this.conf
|
|
53
|
+
= typeof configOrAddress === 'string' ? config.plAddressToConfig(configOrAddress) : configOrAddress;
|
|
54
|
+
this.grpcInterceptors = [];
|
|
55
|
+
const { auth: auth$1, statusListener, shouldUseGzip } = ops;
|
|
56
|
+
if (auth$1 !== undefined) {
|
|
57
|
+
this.refreshTimestamp = auth.inferAuthRefreshTime(auth$1.authInformation, this.conf.authMaxRefreshSeconds);
|
|
58
|
+
this.grpcInterceptors.push(this.createAuthInterceptor());
|
|
59
|
+
this.authInformation = auth$1.authInformation;
|
|
60
|
+
this.onAuthUpdate = auth$1.onUpdate;
|
|
61
|
+
this.onAuthRefreshProblem = auth$1.onUpdateError;
|
|
62
|
+
this.onAuthError = auth$1.onAuthError;
|
|
63
|
+
}
|
|
64
|
+
this.grpcInterceptors.push(this.createErrorInterceptor());
|
|
65
|
+
// initialize _grpcTransport and _grpcPl
|
|
66
|
+
this.initGrpc(shouldUseGzip ?? false);
|
|
67
|
+
this.httpDispatcher = plHttp.defaultHttpDispatcher(this.conf.httpProxy);
|
|
68
|
+
if (statusListener !== undefined) {
|
|
69
|
+
this.statusListener = statusListener;
|
|
70
|
+
statusListener(this._status);
|
|
71
|
+
}
|
|
72
|
+
this.grpcPl = this.createGrpcClientProvider((transport) => new api_client.PlatformClient(transport));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Initializes (or reinitializes) _grpcTransport and _grpcPl
|
|
76
|
+
* @param gzip - whether to enable gzip compression
|
|
77
|
+
*/
|
|
78
|
+
initGrpc(gzip) {
|
|
79
|
+
const clientOptions = {
|
|
80
|
+
'grpc.keepalive_time_ms': 30_000, // 30 seconds
|
|
81
|
+
'interceptors': this.grpcInterceptors,
|
|
82
|
+
};
|
|
83
|
+
if (gzip)
|
|
84
|
+
clientOptions['grpc.default_compression_algorithm'] = grpcJs.compressionAlgorithms.gzip;
|
|
85
|
+
//
|
|
86
|
+
// Leaving it here for now
|
|
87
|
+
// https://github.com/grpc/grpc-node/issues/2788
|
|
88
|
+
//
|
|
89
|
+
// We should implement message pooling algorithm to overcome hardcoded NO_DELAY behaviour
|
|
90
|
+
// of HTTP/2 and allow our small messages to batch together.
|
|
91
|
+
//
|
|
92
|
+
const grpcOptions = {
|
|
93
|
+
host: this.conf.hostAndPort,
|
|
94
|
+
timeout: this.conf.defaultRequestTimeout,
|
|
95
|
+
channelCredentials: this.conf.ssl
|
|
96
|
+
? grpcJs.ChannelCredentials.createSsl()
|
|
97
|
+
: grpcJs.ChannelCredentials.createInsecure(),
|
|
98
|
+
clientOptions,
|
|
99
|
+
};
|
|
100
|
+
if (this.conf.grpcProxy)
|
|
101
|
+
process.env.grpc_proxy = this.conf.grpcProxy;
|
|
102
|
+
else
|
|
103
|
+
delete process.env.grpc_proxy;
|
|
104
|
+
const oldTransport = this._grpcTransport;
|
|
105
|
+
this._grpcTransport = new grpcTransport.GrpcTransport(grpcOptions);
|
|
106
|
+
// Reset all providers to let them reinitialize their clients
|
|
107
|
+
for (let i = 0; i < this.providers.length; i++) {
|
|
108
|
+
const provider = this.providers[i].deref();
|
|
109
|
+
if (provider === undefined) {
|
|
110
|
+
// at the same time we need to remove providers that are no longer valid
|
|
111
|
+
this.providers.splice(i, 1);
|
|
112
|
+
i--;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
provider.reset();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (oldTransport !== undefined)
|
|
119
|
+
oldTransport.close();
|
|
120
|
+
}
|
|
121
|
+
providerCleanupCounter = 0;
|
|
122
|
+
/**
|
|
123
|
+
* Creates a provider for a grpc client. Returned provider will create fresh client whenever the underlying transport is reset.
|
|
124
|
+
*
|
|
125
|
+
* @param clientConstructor - a factory function that creates a grpc client
|
|
126
|
+
*/
|
|
127
|
+
createGrpcClientProvider(clientConstructor) {
|
|
128
|
+
// We need to cleanup providers periodically to avoid memory leaks.
|
|
129
|
+
// This is a simple heuristic to avoid memory leaks.
|
|
130
|
+
// We could use a more sophisticated algorithm, but this is good enough for now.
|
|
131
|
+
this.providerCleanupCounter++;
|
|
132
|
+
if (this.providerCleanupCounter >= 16) {
|
|
133
|
+
for (let i = 0; i < this.providers.length; i++) {
|
|
134
|
+
const provider = this.providers[i].deref();
|
|
135
|
+
if (provider === undefined) {
|
|
136
|
+
this.providers.splice(i, 1);
|
|
137
|
+
i--;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.providerCleanupCounter = 0;
|
|
141
|
+
}
|
|
142
|
+
const provider = new GrpcClientProviderImpl(() => this._grpcTransport, clientConstructor);
|
|
143
|
+
this.providers.push(new WeakRef(provider));
|
|
144
|
+
return provider;
|
|
145
|
+
}
|
|
146
|
+
get grpcTransport() {
|
|
147
|
+
return this._grpcTransport;
|
|
148
|
+
}
|
|
149
|
+
/** Returns true if client is authenticated. Even with anonymous auth information
|
|
150
|
+
* connection is considered authenticated. Unauthenticated clients are used for
|
|
151
|
+
* login and similar tasks, see {@link UnauthenticatedPlClient}. */
|
|
152
|
+
get authenticated() {
|
|
153
|
+
return this.authInformation !== undefined;
|
|
154
|
+
}
|
|
155
|
+
/** null means anonymous connection */
|
|
156
|
+
get authUser() {
|
|
157
|
+
if (!this.authenticated)
|
|
158
|
+
throw new Error('Client is not authenticated');
|
|
159
|
+
if (this.authInformation?.jwtToken)
|
|
160
|
+
return pl.parsePlJwt(this.authInformation?.jwtToken).user.login;
|
|
161
|
+
else
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
updateStatus(newStatus) {
|
|
165
|
+
process.nextTick(() => {
|
|
166
|
+
if (this._status !== newStatus) {
|
|
167
|
+
this._status = newStatus;
|
|
168
|
+
if (this.statusListener !== undefined)
|
|
169
|
+
this.statusListener(this._status);
|
|
170
|
+
if (this.onAuthError !== undefined)
|
|
171
|
+
this.onAuthError();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
get status() {
|
|
176
|
+
return this._status;
|
|
177
|
+
}
|
|
178
|
+
authRefreshInProgress = false;
|
|
179
|
+
refreshAuthInformationIfNeeded() {
|
|
180
|
+
if (this.refreshTimestamp === undefined
|
|
181
|
+
|| Date.now() < this.refreshTimestamp
|
|
182
|
+
|| this.authRefreshInProgress
|
|
183
|
+
|| this._status === 'Unauthenticated')
|
|
184
|
+
return;
|
|
185
|
+
// Running refresh in background`
|
|
186
|
+
this.authRefreshInProgress = true;
|
|
187
|
+
void (async () => {
|
|
188
|
+
try {
|
|
189
|
+
const response = await this.grpcPl.get().getJWTToken({
|
|
190
|
+
expiration: {
|
|
191
|
+
seconds: BigInt(this.conf.authTTLSeconds),
|
|
192
|
+
nanos: 0,
|
|
193
|
+
},
|
|
194
|
+
}).response;
|
|
195
|
+
this.authInformation = { jwtToken: response.token };
|
|
196
|
+
this.refreshTimestamp = auth.inferAuthRefreshTime(this.authInformation, this.conf.authMaxRefreshSeconds);
|
|
197
|
+
if (this.onAuthUpdate)
|
|
198
|
+
this.onAuthUpdate(this.authInformation);
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
if (this.onAuthRefreshProblem)
|
|
202
|
+
this.onAuthRefreshProblem(e);
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
this.authRefreshInProgress = false;
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
}
|
|
209
|
+
/** Detects certain errors and update client status accordingly */
|
|
210
|
+
createErrorInterceptor() {
|
|
211
|
+
return (options, nextCall) => {
|
|
212
|
+
return new grpcJs.InterceptingCall(nextCall(options), {
|
|
213
|
+
start: (metadata, listener, next) => {
|
|
214
|
+
next(metadata, {
|
|
215
|
+
onReceiveStatus: (status, next) => {
|
|
216
|
+
if (status.code == grpcJs.status.UNAUTHENTICATED)
|
|
217
|
+
// (!!!) don't change to "==="
|
|
218
|
+
this.updateStatus('Unauthenticated');
|
|
219
|
+
if (status.code == grpcJs.status.UNAVAILABLE)
|
|
220
|
+
// (!!!) don't change to "==="
|
|
221
|
+
this.updateStatus('Disconnected');
|
|
222
|
+
next(status);
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/** Injects authentication information if needed */
|
|
230
|
+
createAuthInterceptor() {
|
|
231
|
+
return (options, nextCall) => {
|
|
232
|
+
return new grpcJs.InterceptingCall(nextCall(options), {
|
|
233
|
+
start: (metadata, listener, next) => {
|
|
234
|
+
if (this.authInformation?.jwtToken !== undefined) {
|
|
235
|
+
metadata.set('authorization', 'Bearer ' + this.authInformation.jwtToken);
|
|
236
|
+
this.refreshAuthInformationIfNeeded();
|
|
237
|
+
next(metadata, listener);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
next(metadata, listener);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
createTx(rw, ops = {}) {
|
|
247
|
+
return new ll_transaction.LLPlTransaction((abortSignal) => {
|
|
248
|
+
let totalAbortSignal = abortSignal;
|
|
249
|
+
if (ops.abortSignal)
|
|
250
|
+
totalAbortSignal = AbortSignal.any([totalAbortSignal, ops.abortSignal]);
|
|
251
|
+
return this.grpcPl.get().tx({
|
|
252
|
+
abort: totalAbortSignal,
|
|
253
|
+
timeout: ops.timeout
|
|
254
|
+
?? (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout),
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** Closes underlying transport */
|
|
259
|
+
async close() {
|
|
260
|
+
this.grpcTransport.close();
|
|
261
|
+
await this.httpDispatcher.destroy();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
exports.LLPlClient = LLPlClient;
|
|
266
|
+
//# sourceMappingURL=ll_client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ll_client.cjs","sources":["../../src/core/ll_client.ts"],"sourcesContent":["import { PlatformClient } from '../proto/github.com/milaboratory/pl/plapi/plapiproto/api.client';\nimport type { ClientOptions, Interceptor } from '@grpc/grpc-js';\nimport {\n ChannelCredentials,\n InterceptingCall,\n status as GrpcStatus,\n compressionAlgorithms,\n} from '@grpc/grpc-js';\nimport type {\n AuthInformation,\n AuthOps,\n PlClientConfig,\n PlConnectionStatus,\n PlConnectionStatusListener,\n} from './config';\nimport { plAddressToConfig } from './config';\nimport type { GrpcOptions } from '@protobuf-ts/grpc-transport';\nimport { GrpcTransport } from '@protobuf-ts/grpc-transport';\nimport { LLPlTransaction } from './ll_transaction';\nimport { parsePlJwt } from '../util/pl';\nimport type { Dispatcher } from 'undici';\nimport { inferAuthRefreshTime } from './auth';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\nimport type { GrpcClientProvider, GrpcClientProviderFactory } from './grpc';\n\nexport interface PlCallOps {\n timeout?: number;\n abortSignal?: AbortSignal;\n}\n\nclass GrpcClientProviderImpl<Client> implements GrpcClientProvider<Client> {\n private client: Client | undefined = undefined;\n\n constructor(private readonly grpcTransport: () => GrpcTransport, private readonly clientConstructor: (transport: GrpcTransport) => Client) {}\n\n public reset(): void {\n this.client = undefined;\n }\n\n public get(): Client {\n if (this.client === undefined)\n this.client = this.clientConstructor(this.grpcTransport());\n return this.client;\n }\n}\n\n/** Abstract out low level networking and authorization details */\nexport class LLPlClient implements GrpcClientProviderFactory {\n public readonly conf: PlClientConfig;\n\n /** Initial authorization information */\n private authInformation?: AuthInformation;\n /** Will be executed by the client when it is required */\n private readonly onAuthUpdate?: (newInfo: AuthInformation) => void;\n /** Will be executed if auth-related error happens during normal client operation */\n private readonly onAuthError?: () => void;\n /** Will be executed by the client when it is required */\n private readonly onAuthRefreshProblem?: (error: unknown) => void;\n /** Threshold after which auth info refresh is required */\n private refreshTimestamp?: number;\n\n private _status: PlConnectionStatus = 'OK';\n private readonly statusListener?: PlConnectionStatusListener;\n\n private readonly grpcInterceptors: Interceptor[];\n private _grpcTransport!: GrpcTransport;\n private readonly providers: WeakRef<GrpcClientProviderImpl<any>>[] = [];\n\n public readonly grpcPl: GrpcClientProvider<PlatformClient>;\n\n public readonly httpDispatcher: Dispatcher;\n\n constructor(\n configOrAddress: PlClientConfig | string,\n private readonly ops: {\n auth?: AuthOps;\n statusListener?: PlConnectionStatusListener;\n shouldUseGzip?: boolean;\n } = {},\n ) {\n this.conf\n = typeof configOrAddress === 'string' ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n this.grpcInterceptors = [];\n\n const { auth, statusListener, shouldUseGzip } = ops;\n\n if (auth !== undefined) {\n this.refreshTimestamp = inferAuthRefreshTime(\n auth.authInformation,\n this.conf.authMaxRefreshSeconds,\n );\n this.grpcInterceptors.push(this.createAuthInterceptor());\n this.authInformation = auth.authInformation;\n this.onAuthUpdate = auth.onUpdate;\n this.onAuthRefreshProblem = auth.onUpdateError;\n this.onAuthError = auth.onAuthError;\n }\n\n this.grpcInterceptors.push(this.createErrorInterceptor());\n\n // initialize _grpcTransport and _grpcPl\n this.initGrpc(shouldUseGzip ?? false);\n\n this.httpDispatcher = defaultHttpDispatcher(this.conf.httpProxy);\n\n if (statusListener !== undefined) {\n this.statusListener = statusListener;\n statusListener(this._status);\n }\n\n this.grpcPl = this.createGrpcClientProvider((transport) => new PlatformClient(transport));\n }\n\n /**\n * Initializes (or reinitializes) _grpcTransport and _grpcPl\n * @param gzip - whether to enable gzip compression\n */\n private initGrpc(gzip: boolean) {\n const clientOptions: ClientOptions = {\n 'grpc.keepalive_time_ms': 30_000, // 30 seconds\n 'interceptors': this.grpcInterceptors,\n };\n\n if (gzip) clientOptions['grpc.default_compression_algorithm'] = compressionAlgorithms.gzip;\n\n //\n // Leaving it here for now\n // https://github.com/grpc/grpc-node/issues/2788\n //\n // We should implement message pooling algorithm to overcome hardcoded NO_DELAY behaviour\n // of HTTP/2 and allow our small messages to batch together.\n //\n const grpcOptions: GrpcOptions = {\n host: this.conf.hostAndPort,\n timeout: this.conf.defaultRequestTimeout,\n channelCredentials: this.conf.ssl\n ? ChannelCredentials.createSsl()\n : ChannelCredentials.createInsecure(),\n clientOptions,\n };\n\n if (this.conf.grpcProxy) process.env.grpc_proxy = this.conf.grpcProxy;\n else delete process.env.grpc_proxy;\n\n const oldTransport = this._grpcTransport;\n\n this._grpcTransport = new GrpcTransport(grpcOptions);\n\n // Reset all providers to let them reinitialize their clients\n for (let i = 0; i < this.providers.length; i++) {\n const provider = this.providers[i].deref();\n if (provider === undefined) {\n // at the same time we need to remove providers that are no longer valid\n this.providers.splice(i, 1);\n i--;\n } else {\n provider.reset();\n }\n }\n\n if (oldTransport !== undefined) oldTransport.close();\n }\n\n private providerCleanupCounter = 0;\n\n /**\n * Creates a provider for a grpc client. Returned provider will create fresh client whenever the underlying transport is reset.\n *\n * @param clientConstructor - a factory function that creates a grpc client\n */\n public createGrpcClientProvider<Client>(clientConstructor: (transport: GrpcTransport) => Client): GrpcClientProvider<Client> {\n // We need to cleanup providers periodically to avoid memory leaks.\n // This is a simple heuristic to avoid memory leaks.\n // We could use a more sophisticated algorithm, but this is good enough for now.\n this.providerCleanupCounter++;\n if (this.providerCleanupCounter >= 16) {\n for (let i = 0; i < this.providers.length; i++) {\n const provider = this.providers[i].deref();\n if (provider === undefined) {\n this.providers.splice(i, 1);\n i--;\n }\n }\n this.providerCleanupCounter = 0;\n }\n\n const provider = new GrpcClientProviderImpl<Client>(() => this._grpcTransport, clientConstructor);\n this.providers.push(new WeakRef(provider));\n return provider;\n }\n\n public get grpcTransport(): GrpcTransport {\n return this._grpcTransport;\n }\n\n /** Returns true if client is authenticated. Even with anonymous auth information\n * connection is considered authenticated. Unauthenticated clients are used for\n * login and similar tasks, see {@link UnauthenticatedPlClient}. */\n public get authenticated(): boolean {\n return this.authInformation !== undefined;\n }\n\n /** null means anonymous connection */\n public get authUser(): string | null {\n if (!this.authenticated) throw new Error('Client is not authenticated');\n if (this.authInformation?.jwtToken)\n return parsePlJwt(this.authInformation?.jwtToken).user.login;\n else return null;\n }\n\n private updateStatus(newStatus: PlConnectionStatus) {\n process.nextTick(() => {\n if (this._status !== newStatus) {\n this._status = newStatus;\n if (this.statusListener !== undefined) this.statusListener(this._status);\n if (this.onAuthError !== undefined) this.onAuthError();\n }\n });\n }\n\n public get status(): PlConnectionStatus {\n return this._status;\n }\n\n private authRefreshInProgress: boolean = false;\n\n private refreshAuthInformationIfNeeded(): void {\n if (\n this.refreshTimestamp === undefined\n || Date.now() < this.refreshTimestamp\n || this.authRefreshInProgress\n || this._status === 'Unauthenticated'\n )\n return;\n\n // Running refresh in background`\n this.authRefreshInProgress = true;\n void (async () => {\n try {\n const response = await this.grpcPl.get().getJWTToken({\n expiration: {\n seconds: BigInt(this.conf.authTTLSeconds),\n nanos: 0,\n },\n }).response;\n this.authInformation = { jwtToken: response.token };\n this.refreshTimestamp = inferAuthRefreshTime(\n this.authInformation,\n this.conf.authMaxRefreshSeconds,\n );\n if (this.onAuthUpdate) this.onAuthUpdate(this.authInformation);\n } catch (e: unknown) {\n if (this.onAuthRefreshProblem) this.onAuthRefreshProblem(e);\n } finally {\n this.authRefreshInProgress = false;\n }\n })();\n }\n\n /** Detects certain errors and update client status accordingly */\n private createErrorInterceptor(): Interceptor {\n return (options, nextCall) => {\n return new InterceptingCall(nextCall(options), {\n start: (metadata, listener, next) => {\n next(metadata, {\n onReceiveStatus: (status, next) => {\n if (status.code == GrpcStatus.UNAUTHENTICATED)\n // (!!!) don't change to \"===\"\n this.updateStatus('Unauthenticated');\n if (status.code == GrpcStatus.UNAVAILABLE)\n // (!!!) don't change to \"===\"\n this.updateStatus('Disconnected');\n next(status);\n },\n });\n },\n });\n };\n }\n\n /** Injects authentication information if needed */\n private createAuthInterceptor(): Interceptor {\n return (options, nextCall) => {\n return new InterceptingCall(nextCall(options), {\n start: (metadata, listener, next) => {\n if (this.authInformation?.jwtToken !== undefined) {\n metadata.set('authorization', 'Bearer ' + this.authInformation.jwtToken);\n this.refreshAuthInformationIfNeeded();\n next(metadata, listener);\n } else {\n next(metadata, listener);\n }\n },\n });\n };\n }\n\n createTx(rw: boolean, ops: PlCallOps = {}): LLPlTransaction {\n return new LLPlTransaction((abortSignal) => {\n let totalAbortSignal = abortSignal;\n if (ops.abortSignal) totalAbortSignal = AbortSignal.any([totalAbortSignal, ops.abortSignal]);\n return this.grpcPl.get().tx({\n abort: totalAbortSignal,\n timeout:\n ops.timeout\n ?? (rw ? this.conf.defaultRWTransactionTimeout : this.conf.defaultROTransactionTimeout),\n });\n });\n }\n\n /** Closes underlying transport */\n public async close() {\n this.grpcTransport.close();\n await this.httpDispatcher.destroy();\n }\n}\n"],"names":["plAddressToConfig","auth","inferAuthRefreshTime","defaultHttpDispatcher","PlatformClient","compressionAlgorithms","ChannelCredentials","GrpcTransport","parsePlJwt","InterceptingCall","GrpcStatus","LLPlTransaction"],"mappings":";;;;;;;;;;;AA8BA,MAAM,sBAAsB,CAAA;AAGG,IAAA,aAAA;AAAqD,IAAA,iBAAA;IAF1E,MAAM,GAAuB,SAAS;IAE9C,WAAA,CAA6B,aAAkC,EAAmB,iBAAuD,EAAA;QAA5G,IAAA,CAAA,aAAa,GAAb,aAAa;QAAwC,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;IAAyC;IAErI,KAAK,GAAA;AACV,QAAA,IAAI,CAAC,MAAM,GAAG,SAAS;IACzB;IAEO,GAAG,GAAA;AACR,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;AAC3B,YAAA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC,MAAM;IACpB;AACD;AAED;MACa,UAAU,CAAA;AA2BF,IAAA,GAAA;AA1BH,IAAA,IAAI;;AAGZ,IAAA,eAAe;;AAEN,IAAA,YAAY;;AAEZ,IAAA,WAAW;;AAEX,IAAA,oBAAoB;;AAE7B,IAAA,gBAAgB;IAEhB,OAAO,GAAuB,IAAI;AACzB,IAAA,cAAc;AAEd,IAAA,gBAAgB;AACzB,IAAA,cAAc;IACL,SAAS,GAA2C,EAAE;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apiproto/api.client';
|
|
2
|
-
import { AuthOps, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener } from './config';
|
|
2
|
+
import type { AuthOps, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener } from './config';
|
|
3
3
|
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
4
|
import { LLPlTransaction } from './ll_transaction';
|
|
5
|
-
import { Dispatcher } from 'undici';
|
|
6
|
-
import { GrpcClientProvider, GrpcClientProviderFactory } from './grpc';
|
|
5
|
+
import type { Dispatcher } from 'undici';
|
|
6
|
+
import type { GrpcClientProvider, GrpcClientProviderFactory } from './grpc';
|
|
7
7
|
export interface PlCallOps {
|
|
8
8
|
timeout?: number;
|
|
9
9
|
abortSignal?: AbortSignal;
|