@milaboratories/pl-client 3.14.7 → 3.16.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.
Files changed (114) hide show
  1. package/dist/core/PromiseTracker.d.ts +1 -2
  2. package/dist/core/PromiseTracker.d.ts.map +1 -1
  3. package/dist/core/abstract_stream.d.ts +2 -3
  4. package/dist/core/abstract_stream.d.ts.map +1 -1
  5. package/dist/core/auth.d.ts +2 -4
  6. package/dist/core/auth.d.ts.map +1 -1
  7. package/dist/core/cache.d.ts +1 -3
  8. package/dist/core/cache.d.ts.map +1 -1
  9. package/dist/core/capabilities.d.ts +2 -3
  10. package/dist/core/capabilities.d.ts.map +1 -1
  11. package/dist/core/client.cjs +7 -0
  12. package/dist/core/client.cjs.map +1 -1
  13. package/dist/core/client.d.ts +8 -5
  14. package/dist/core/client.d.ts.map +1 -1
  15. package/dist/core/client.js +7 -0
  16. package/dist/core/client.js.map +1 -1
  17. package/dist/core/config.d.ts +29 -31
  18. package/dist/core/config.d.ts.map +1 -1
  19. package/dist/core/default_client.d.ts +2 -4
  20. package/dist/core/default_client.d.ts.map +1 -1
  21. package/dist/core/driver.d.ts +4 -6
  22. package/dist/core/driver.d.ts.map +1 -1
  23. package/dist/core/errors.d.ts +20 -22
  24. package/dist/core/errors.d.ts.map +1 -1
  25. package/dist/core/final.d.ts +4 -5
  26. package/dist/core/final.d.ts.map +1 -1
  27. package/dist/core/ll_client.cjs +45 -18
  28. package/dist/core/ll_client.cjs.map +1 -1
  29. package/dist/core/ll_client.d.ts +21 -10
  30. package/dist/core/ll_client.d.ts.map +1 -1
  31. package/dist/core/ll_client.js +45 -18
  32. package/dist/core/ll_client.js.map +1 -1
  33. package/dist/core/ll_transaction.d.ts +4 -6
  34. package/dist/core/ll_transaction.d.ts.map +1 -1
  35. package/dist/core/stat.d.ts +2 -3
  36. package/dist/core/stat.d.ts.map +1 -1
  37. package/dist/core/transaction.cjs +2 -1
  38. package/dist/core/transaction.cjs.map +1 -1
  39. package/dist/core/transaction.d.ts +30 -32
  40. package/dist/core/transaction.d.ts.map +1 -1
  41. package/dist/core/transaction.js +2 -1
  42. package/dist/core/transaction.js.map +1 -1
  43. package/dist/core/tree_filter.d.ts +14 -10
  44. package/dist/core/tree_filter.d.ts.map +1 -1
  45. package/dist/core/types.d.ts +54 -55
  46. package/dist/core/types.d.ts.map +1 -1
  47. package/dist/core/unauth_client.cjs +79 -32
  48. package/dist/core/unauth_client.cjs.map +1 -1
  49. package/dist/core/unauth_client.d.ts +53 -20
  50. package/dist/core/unauth_client.d.ts.map +1 -1
  51. package/dist/core/unauth_client.js +79 -32
  52. package/dist/core/unauth_client.js.map +1 -1
  53. package/dist/core/user_resources.cjs +23 -0
  54. package/dist/core/user_resources.cjs.map +1 -1
  55. package/dist/core/user_resources.d.ts +33 -7
  56. package/dist/core/user_resources.d.ts.map +1 -1
  57. package/dist/core/user_resources.js +23 -0
  58. package/dist/core/user_resources.js.map +1 -1
  59. package/dist/core/wire.d.ts +5 -7
  60. package/dist/core/wire.d.ts.map +1 -1
  61. package/dist/helpers/pl.d.ts +32 -34
  62. package/dist/helpers/pl.d.ts.map +1 -1
  63. package/dist/helpers/poll.d.ts +8 -9
  64. package/dist/helpers/poll.d.ts.map +1 -1
  65. package/dist/helpers/tx_helpers.d.ts +2 -4
  66. package/dist/helpers/tx_helpers.d.ts.map +1 -1
  67. package/dist/index.d.ts +3 -3
  68. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts +2 -4
  69. package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -1
  70. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +310 -15
  71. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
  72. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +19 -3
  73. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
  74. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +29 -5
  75. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -1
  76. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +19 -3
  77. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
  78. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +2336 -429
  79. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
  80. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +309 -16
  81. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
  82. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +51 -30
  83. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -1
  84. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +7 -9
  85. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -1
  86. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +6 -8
  87. package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -1
  88. package/dist/proto-grpc/google/protobuf/any.d.ts +2 -4
  89. package/dist/proto-grpc/google/protobuf/any.d.ts.map +1 -1
  90. package/dist/proto-grpc/google/protobuf/duration.d.ts +2 -4
  91. package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -1
  92. package/dist/proto-grpc/google/protobuf/timestamp.d.ts +2 -4
  93. package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -1
  94. package/dist/proto-grpc/google/rpc/code.d.ts +1 -2
  95. package/dist/proto-grpc/google/rpc/code.d.ts.map +1 -1
  96. package/dist/proto-rest/index.d.ts +6 -8
  97. package/dist/proto-rest/index.d.ts.map +1 -1
  98. package/dist/proto-rest/plapi.d.ts +248 -123
  99. package/dist/proto-rest/plapi.d.ts.map +1 -1
  100. package/dist/test/tcp-proxy.d.ts +3 -5
  101. package/dist/test/tcp-proxy.d.ts.map +1 -1
  102. package/dist/test/test_config.d.ts +13 -14
  103. package/dist/test/test_config.d.ts.map +1 -1
  104. package/package.json +6 -6
  105. package/src/core/client.ts +9 -0
  106. package/src/core/ll_client.ts +40 -13
  107. package/src/core/transaction.ts +2 -0
  108. package/src/core/unauth_client.test.ts +69 -1
  109. package/src/core/unauth_client.ts +108 -34
  110. package/src/core/unauth_client_branch.test.ts +416 -5
  111. package/src/core/user_resources.ts +39 -0
  112. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +34 -3
  113. package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +431 -15
  114. package/src/proto-rest/plapi.ts +8 -2
@@ -4,7 +4,7 @@
4
4
  * Useful for coordinating async operations, preventing premature completion,
5
5
  * and avoiding unhandled promise rejections.
6
6
  */
7
- declare class PromiseTracker {
7
+ export declare class PromiseTracker {
8
8
  private promises;
9
9
  private _draining;
10
10
  get draining(): boolean;
@@ -13,5 +13,4 @@ declare class PromiseTracker {
13
13
  awaitAll(): Promise<unknown[]>;
14
14
  }
15
15
  //#endregion
16
- export { PromiseTracker };
17
16
  //# sourceMappingURL=PromiseTracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PromiseTracker.d.ts","names":[],"sources":["../../src/core/PromiseTracker.ts"],"mappings":";;AAOA;;;;cAAa,cAAA;EAAA,QACH,QAAA;EAAA,QACA,SAAA;EAAA,IAEJ,QAAA;EAAA,IAIA,IAAA;EAIJ,KAAA,IAAS,iBAAA,EAAmB,OAAA,CAAQ,CAAA,WAAY,OAAA,CAAQ,CAAA,KAAM,OAAA,CAAQ,CAAA;EAWhE,QAAA,IAAQ,OAAA;AAAA"}
1
+ {"version":3,"file":"PromiseTracker.d.ts","names":[],"sources":["../../src/core/PromiseTracker.ts"],"mappings":";;;;;;qBAOa;UACH;UACA;MAEJ;MAIA;EAIJ,MAAM,GAAG,mBAAmB,QAAQ,YAAY,QAAQ,MAAM,QAAQ;EAWhE,YAAQ"}
@@ -1,5 +1,5 @@
1
1
  //#region src/core/abstract_stream.d.ts
2
- interface RequestsStream<T> {
2
+ export interface RequestsStream<T> {
3
3
  /**
4
4
  * Send a message down the stream.
5
5
  * Only one message can be send at a time.
@@ -12,10 +12,9 @@ interface RequestsStream<T> {
12
12
  */
13
13
  complete(): Promise<void>;
14
14
  }
15
- interface BiDiStream<I extends object, O extends object> {
15
+ export interface BiDiStream<I extends object, O extends object> {
16
16
  requests: RequestsStream<I>;
17
17
  responses: AsyncIterable<O>;
18
18
  }
19
19
  //#endregion
20
- export { BiDiStream, RequestsStream };
21
20
  //# sourceMappingURL=abstract_stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abstract_stream.d.ts","names":[],"sources":["../../src/core/abstract_stream.ts"],"mappings":";UAEiB,cAAA;EAAA;;;;EAKf,IAAA,CAAK,OAAA,EAAS,CAAA,GAAI,OAAA;EAMN;;;;;EAAZ,QAAA,IAAY,OAAA;AAAA;AAAA,UAGG,UAAA;EACf,QAAA,EAAU,cAAA,CAAe,CAAA;EACzB,SAAA,EAAW,aAAA,CAAc,CAAA;AAAA"}
1
+ {"version":3,"file":"abstract_stream.d.ts","names":[],"sources":["../../src/core/abstract_stream.ts"],"mappings":";iBAEiB,eAAe;;;;;EAK9B,KAAK,SAAS,IAAI;;;;;;EAMlB,YAAY;;iBAGG,WAAW,kBAAkB;EAC5C,UAAU,eAAe;EACzB,WAAW,cAAc"}
@@ -1,10 +1,8 @@
1
1
  import { AuthInformation } from "./config.js";
2
-
3
2
  //#region src/core/auth.d.ts
4
3
  /** Returns a timestamp when current authorization information should be refreshed.
5
4
  * Compare the value with Date.now(). */
6
- declare function inferAuthRefreshTime(info: AuthInformation, maxRefreshSeconds: number): number | undefined;
7
- declare function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined;
5
+ export declare function inferAuthRefreshTime(info: AuthInformation, maxRefreshSeconds: number): number | undefined;
6
+ export declare function expirationFromAuthInformation(authInfo: AuthInformation): number | undefined;
8
7
  //#endregion
9
- export { expirationFromAuthInformation, inferAuthRefreshTime };
10
8
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","names":[],"sources":["../../src/core/auth.ts"],"mappings":";;;;;iBAKgB,oBAAA,CACd,IAAA,EAAM,eAAe,EACrB,iBAAA;AAAA,iBAec,6BAAA,CAA8B,QAAyB,EAAf,eAAe"}
1
+ {"version":3,"file":"auth.d.ts","names":[],"sources":["../../src/core/auth.ts"],"mappings":";;;;wBAKgB,qBACd,MAAM,iBACN;wBAec,8BAA8B,UAAU"}
@@ -1,7 +1,6 @@
1
1
  import { BasicResourceData, ResourceData } from "./types.js";
2
-
3
2
  //#region src/core/cache.d.ts
4
- type ResourceDataCacheRecord = {
3
+ export type ResourceDataCacheRecord = {
5
4
  /** There is a slight chance of inconsistent data retrieval from tx if we allow later transactions to leak resource data into earlier transactions.
6
5
  * This field allows to prevent this. */
7
6
  cacheTxOpenTimestamp: number;
@@ -9,5 +8,4 @@ type ResourceDataCacheRecord = {
9
8
  readonly basicData: BasicResourceData;
10
9
  };
11
10
  //#endregion
12
- export { ResourceDataCacheRecord };
13
11
  //# sourceMappingURL=cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","names":[],"sources":["../../src/core/cache.ts"],"mappings":";;;KAEY,uBAAA;;AAAZ;EAGE,oBAAA;EACA,IAAA,EAAM,YAAA;EAAA,SACG,SAAA,EAAW,iBAAiB;AAAA"}
1
+ {"version":3,"file":"cache.d.ts","names":[],"sources":["../../src/core/cache.ts"],"mappings":";;YAEY;;;EAGV;EACA,MAAM;WACG,WAAW"}
@@ -15,9 +15,8 @@
15
15
  * - `@platforma-sdk/block-tools` — copies it onto the published manifest
16
16
  * - `@milaboratories/pl-middle-layer` — checks it at install time
17
17
  */
18
- type BackendCapability = "auth:v2" | "treeFilter:v2" | "wasm:v1" | "crossTreeRefs:v1" | "userListing:v1" | "publicGrants:v1" | "txListGrants:v1";
18
+ export type BackendCapability = "auth:v2" | "treeFilter:v2" | "wasm:v1" | "crossTreeRefs:v1" | "userListing:v1" | "publicGrants:v1" | "txListGrants:v1";
19
19
  /** True iff `capabilities` advertises the requested token. */
20
- declare function hasCapability(capabilities: readonly string[] | undefined, capability: BackendCapability): boolean;
20
+ export declare function hasCapability(capabilities: readonly string[] | undefined, capability: BackendCapability): boolean;
21
21
  //#endregion
22
- export { BackendCapability, hasCapability };
23
22
  //# sourceMappingURL=capabilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","names":[],"sources":["../../src/core/capabilities.ts"],"mappings":";;AAgBA;;;;AAA6B;AAW7B;;;;;;;;AAE+B;;KAbnB,iBAAA;;iBAWI,aAAA,CACd,YAAA,iCACA,UAAA,EAAY,iBAAiB"}
1
+ {"version":3,"file":"capabilities.d.ts","names":[],"sources":["../../src/core/capabilities.ts"],"mappings":";;;;;;;;;;;;;;;;;YAgBY;;wBAWI,cACd,6CACA,YAAY"}
@@ -126,6 +126,13 @@ var PlClient = class PlClient {
126
126
  async listUsers() {
127
127
  return await this.ll.listUsers();
128
128
  }
129
+ /**
130
+ * Deletes a user account and its root resource — with the root, everything still attached
131
+ * under it. Destructive and irreversible; see {@link UserResources.deleteUser}.
132
+ */
133
+ async deleteUser(login) {
134
+ return await this.userResources.deleteUser(login);
135
+ }
129
136
  async getUserRoot(opts = {}) {
130
137
  return this.userResources.getUserRoot(opts);
131
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs","names":["initialTxStat","plAddressToConfig","LLPlClient","DefaultFinalResourceDataPredicate","LRUCache","addStat","isNullSignedResourceId","ensureSignedResourceIdNotNull","UserResources","ClientRoot","advisoryLock","PlTransaction","parseSignedResourceId","TxCommitConflict","tp"],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport { PlTransaction, TxCommitConflict } from \"./transaction\";\nimport type { Role } from \"./transaction\";\nimport type { OptionalSignedResourceId, SignedResourceId } from \"./types\";\nimport {\n ensureSignedResourceIdNotNull,\n isNullSignedResourceId,\n NullSignedResourceId,\n parseSignedResourceId,\n} from \"./types\";\nimport type { ColorProof } from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n AuthAPI_User,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\nimport { UserResources } from \"./user_resources\";\nimport type { BackendCapability } from \"./capabilities\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalSignedResourceId = NullSignedResourceId;\n\n private _userResources?: UserResources;\n\n /** Cached effective role of the authenticated session, fetched once during\n * init via the GetSessionInfo RPC. `null` for an anonymous (no-auth)\n * connection — mirrors {@link authUser}. Read through {@link currentUserRole}. */\n private _currentUserRole: Role | null = null;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<SignedResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n // An empty or whitespace-only asUser means \"no impersonation\"; normalize to undefined so a\n // directly-constructed { asUser: \"\" } does not slip through as an empty login.\n if (conf.asUser !== undefined && conf.asUser.trim() === \"\") conf.asUser = undefined;\n\n // asUser (impersonation) and alternativeRoot both repoint the client root, so they cannot be\n // combined. Validate here, before init() touches the network, so a misconfiguration fails fast.\n if (conf.asUser !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"PlClient: asUser and alternativeRoot cannot be combined.\");\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n /** Smoothed round-trip estimate in ms from ping timings, or undefined before the first\n * ping. Exposed so latency-sensitive consumers (e.g. the tree-sync poll cadence) can scale\n * their timing to the link instead of assuming a local server. */\n public get rttEstimateMs(): number | undefined {\n return this.ll.rttEstimateMs;\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n /** Lists the users known to the server (login only on the wire). See {@link LLPlClient.listUsers}. */\n public async listUsers(): Promise<AuthAPI_User[]> {\n return await this.ll.listUsers();\n }\n\n /**\n * Returns the user root SignedResourceId via ListUserResources.\n * @param opts.login - target user login; omit for the authenticated user.\n * @returns SignedResourceId of the user root, or undefined if the server returned no userRoot entry.\n * @throws if the backend does not implement ListUserResources (callers should catch with isUnimplementedError).\n */\n public async getUserRoot(opts: {\n login?: string;\n createIfNotExists: true;\n }): Promise<SignedResourceId>;\n public async getUserRoot(opts?: {\n login?: string;\n createIfNotExists?: boolean;\n }): Promise<SignedResourceId | undefined>;\n public async getUserRoot(\n opts: { login?: string; createIfNotExists?: boolean } = {},\n ): Promise<SignedResourceId | undefined> {\n return this.userResources.getUserRoot(opts);\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullSignedResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): SignedResourceId {\n this.checkInitialized();\n return ensureSignedResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._ll!.serverInfo;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n this.checkInitialized();\n return this._ll!.hasCapability(capability);\n }\n\n /** Effective role of the authenticated session, resolved once during init via\n * the GetSessionInfo RPC and cached. `null` for an anonymous (no-auth)\n * connection, or when the backend predates GetSessionInfo. Mirrors\n * {@link authUser}'s null contract. */\n public get currentUserRole(): Role | null {\n this.checkInitialized();\n return this._currentUserRole;\n }\n\n /** Login of the authenticated user, or `null` for an anonymous connection. */\n public get authUser(): string | null {\n this.checkInitialized();\n return this.userResources.authUser;\n }\n\n /**\n * True if the backend honors per-file `permissions` on workdir fill rules.\n * See {@link LLPlClient.supportsWritableWorkdirFiles} for the full definition.\n */\n public get supportsWritableWorkdirFiles(): boolean {\n this.checkInitialized();\n return this._ll!.supportsWritableWorkdirFiles;\n }\n\n /** User resources index for discovering data libraries and other shared resources. */\n public get userResources(): UserResources {\n if (!this._ll) throw new Error(\"Client not initialized\");\n\n if (!this._userResources) {\n this._userResources = new UserResources(this._ll, this._withTx.bind(this), this._ll.authUser);\n }\n\n return this._userResources;\n }\n\n /** Discovers or creates the user's root resource via UserResources,\n * then handles alternativeRoot if configured. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n // LLPlClient.build() guarantees a successful ping; read the cached response instead of pinging again.\n const info = this._ll.serverInfo;\n if (info.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n // Resolve the client root. Normally the caller's own root; when `asUser` is set (admin impersonation),\n // the target user's root instead. The backend authorizes impersonation by role and silently returns the\n // caller's own root for non-admins, so no client-side role gate is needed here.\n let userRoot: SignedResourceId;\n if (this.conf.asUser === undefined) {\n userRoot = await this.userResources.getUserRoot({ createIfNotExists: true });\n } else {\n const impersonatedRoot = await this.userResources.getUserRoot({ login: this.conf.asUser });\n if (impersonatedRoot === undefined)\n throw new Error(\n `PlClient: cannot open root of user '${this.conf.asUser}': no root found (the user may have never logged in).`,\n );\n userRoot = impersonatedRoot;\n }\n\n // Resolve the caller's role once; only the publicGrants-gated share-with-everybody check uses it,\n // so skip it for anonymous connections or when publicGrants:v1 is absent. Use _ll.hasCapability,\n // not this.hasCapability: we are mid-init, so this.checkInitialized() would throw.\n if (this.userResources.authUser !== null && this._ll.hasCapability(\"publicGrants:v1\")) {\n this._currentUserRole = (await this._ll.getSessionInfo()).role;\n }\n\n if (this.conf.alternativeRoot === undefined) {\n this._clientRoot = userRoot;\n } else {\n this._clientRoot = await this._withTx(\"initialization\", true, userRoot, async (tx) => {\n const aFId = {\n resourceId: userRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot!),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n });\n }\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalSignedResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n // Auto-set default color proof from the client root's signature.\n // Skip when backend doesn't implement the `set_default_color` TX request.\n if (this.ll.supportsResourceSignatures && !isNullSignedResourceId(clientRoot) && writable) {\n const parsed = parseSignedResourceId(clientRoot);\n if (parsed.signature) {\n tx.setDefaultColor(parsed.signature as ColorProof);\n }\n }\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n /**\n * Runs a write transaction whose default color is `root`'s signature instead of the client\n * root's, and whose `tx.clientRoot` is `root`. For admin cross-root operations (e.g. copying a\n * project into another user's root so the copy is minted in that user's color). The backend\n * still authorizes the write by role.\n */\n public async withWriteTxOnRoot<T>(\n root: SignedResourceId,\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, true, root, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,MAAM,eAAe,EACnB,MAAM,MACR;AAEA,SAAS,yBAAyB,iBAAiC;CACjE,OAAO,oBAAoB;AAC7B;;AAGA,IAAa,WAAb,MAAa,SAAS;CACpB,0BAA2B,IAAI,IAAsB;;;CAIrD;;CAGA;;CAGA;CAE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QA,MAAa,kBACX,MACA,MACA,MACA,MAAsB,CAAC,GACX;EACZ,KAAK,iBAAiB;EACtB,OAAO,MAAM,KAAK,QAAQ,MAAM,MAAM,MAAM,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CAC/E;CAEA,MAAa,WACX,MACA,MACA,MAAsB,CAAC,GACX;EACZ,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CACzE;CAEA,UAAuC,YAA0C;EAC/E,MAAM,WAAW,KAAK,QAAQ,IAAI,WAAW,IAAI;EACjD,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK,cAAc;EACjE,KAAK,QAAQ,IAAI,WAAW,MAAM,MAAM;EACxC,OAAO;CACT;;CAGA,MAAa,QAAQ;EACnB,MAAM,KAAK,GAAG,MAAM;CACtB;CAEA,aAAoB,KAClB,iBACA,MACA,MAGI,CAAC,GACL;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,GAAG;EAClD,MAAM,GAAG,KAAK;EACd,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"client.cjs","names":["initialTxStat","plAddressToConfig","LLPlClient","DefaultFinalResourceDataPredicate","LRUCache","addStat","isNullSignedResourceId","ensureSignedResourceIdNotNull","UserResources","ClientRoot","advisoryLock","PlTransaction","parseSignedResourceId","TxCommitConflict","tp"],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport { PlTransaction, TxCommitConflict } from \"./transaction\";\nimport type { Role } from \"./transaction\";\nimport type { OptionalSignedResourceId, SignedResourceId } from \"./types\";\nimport {\n ensureSignedResourceIdNotNull,\n isNullSignedResourceId,\n NullSignedResourceId,\n parseSignedResourceId,\n} from \"./types\";\nimport type { ColorProof } from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n AuthAPI_User,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\nimport { UserResources } from \"./user_resources\";\nimport type { UserDeletionReport } from \"./user_resources\";\nimport type { BackendCapability } from \"./capabilities\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalSignedResourceId = NullSignedResourceId;\n\n private _userResources?: UserResources;\n\n /** Cached effective role of the authenticated session, fetched once during\n * init via the GetSessionInfo RPC. `null` for an anonymous (no-auth)\n * connection — mirrors {@link authUser}. Read through {@link currentUserRole}. */\n private _currentUserRole: Role | null = null;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<SignedResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n // An empty or whitespace-only asUser means \"no impersonation\"; normalize to undefined so a\n // directly-constructed { asUser: \"\" } does not slip through as an empty login.\n if (conf.asUser !== undefined && conf.asUser.trim() === \"\") conf.asUser = undefined;\n\n // asUser (impersonation) and alternativeRoot both repoint the client root, so they cannot be\n // combined. Validate here, before init() touches the network, so a misconfiguration fails fast.\n if (conf.asUser !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"PlClient: asUser and alternativeRoot cannot be combined.\");\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n /** Smoothed round-trip estimate in ms from ping timings, or undefined before the first\n * ping. Exposed so latency-sensitive consumers (e.g. the tree-sync poll cadence) can scale\n * their timing to the link instead of assuming a local server. */\n public get rttEstimateMs(): number | undefined {\n return this.ll.rttEstimateMs;\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n /** Lists the users known to the server (login only on the wire). See {@link LLPlClient.listUsers}. */\n public async listUsers(): Promise<AuthAPI_User[]> {\n return await this.ll.listUsers();\n }\n\n /**\n * Deletes a user account and its root resource — with the root, everything still attached\n * under it. Destructive and irreversible; see {@link UserResources.deleteUser}.\n */\n public async deleteUser(login: string): Promise<UserDeletionReport> {\n return await this.userResources.deleteUser(login);\n }\n\n /**\n * Returns the user root SignedResourceId via ListUserResources.\n * @param opts.login - target user login; omit for the authenticated user.\n * @returns SignedResourceId of the user root, or undefined if the server returned no userRoot entry.\n * @throws if the backend does not implement ListUserResources (callers should catch with isUnimplementedError).\n */\n public async getUserRoot(opts: {\n login?: string;\n createIfNotExists: true;\n }): Promise<SignedResourceId>;\n public async getUserRoot(opts?: {\n login?: string;\n createIfNotExists?: boolean;\n }): Promise<SignedResourceId | undefined>;\n public async getUserRoot(\n opts: { login?: string; createIfNotExists?: boolean } = {},\n ): Promise<SignedResourceId | undefined> {\n return this.userResources.getUserRoot(opts);\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullSignedResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): SignedResourceId {\n this.checkInitialized();\n return ensureSignedResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._ll!.serverInfo;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n this.checkInitialized();\n return this._ll!.hasCapability(capability);\n }\n\n /** Effective role of the authenticated session, resolved once during init via\n * the GetSessionInfo RPC and cached. `null` for an anonymous (no-auth)\n * connection, or when the backend predates GetSessionInfo. Mirrors\n * {@link authUser}'s null contract. */\n public get currentUserRole(): Role | null {\n this.checkInitialized();\n return this._currentUserRole;\n }\n\n /** Login of the authenticated user, or `null` for an anonymous connection. */\n public get authUser(): string | null {\n this.checkInitialized();\n return this.userResources.authUser;\n }\n\n /**\n * True if the backend honors per-file `permissions` on workdir fill rules.\n * See {@link LLPlClient.supportsWritableWorkdirFiles} for the full definition.\n */\n public get supportsWritableWorkdirFiles(): boolean {\n this.checkInitialized();\n return this._ll!.supportsWritableWorkdirFiles;\n }\n\n /** User resources index for discovering data libraries and other shared resources. */\n public get userResources(): UserResources {\n if (!this._ll) throw new Error(\"Client not initialized\");\n\n if (!this._userResources) {\n this._userResources = new UserResources(this._ll, this._withTx.bind(this), this._ll.authUser);\n }\n\n return this._userResources;\n }\n\n /** Discovers or creates the user's root resource via UserResources,\n * then handles alternativeRoot if configured. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n // LLPlClient.build() guarantees a successful ping; read the cached response instead of pinging again.\n const info = this._ll.serverInfo;\n if (info.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n // Resolve the client root. Normally the caller's own root; when `asUser` is set (admin impersonation),\n // the target user's root instead. The backend authorizes impersonation by role and silently returns the\n // caller's own root for non-admins, so no client-side role gate is needed here.\n let userRoot: SignedResourceId;\n if (this.conf.asUser === undefined) {\n userRoot = await this.userResources.getUserRoot({ createIfNotExists: true });\n } else {\n const impersonatedRoot = await this.userResources.getUserRoot({ login: this.conf.asUser });\n if (impersonatedRoot === undefined)\n throw new Error(\n `PlClient: cannot open root of user '${this.conf.asUser}': no root found (the user may have never logged in).`,\n );\n userRoot = impersonatedRoot;\n }\n\n // Resolve the caller's role once; only the publicGrants-gated share-with-everybody check uses it,\n // so skip it for anonymous connections or when publicGrants:v1 is absent. Use _ll.hasCapability,\n // not this.hasCapability: we are mid-init, so this.checkInitialized() would throw.\n if (this.userResources.authUser !== null && this._ll.hasCapability(\"publicGrants:v1\")) {\n this._currentUserRole = (await this._ll.getSessionInfo()).role;\n }\n\n if (this.conf.alternativeRoot === undefined) {\n this._clientRoot = userRoot;\n } else {\n this._clientRoot = await this._withTx(\"initialization\", true, userRoot, async (tx) => {\n const aFId = {\n resourceId: userRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot!),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n });\n }\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalSignedResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n // Auto-set default color proof from the client root's signature.\n // Skip when backend doesn't implement the `set_default_color` TX request.\n if (this.ll.supportsResourceSignatures && !isNullSignedResourceId(clientRoot) && writable) {\n const parsed = parseSignedResourceId(clientRoot);\n if (parsed.signature) {\n tx.setDefaultColor(parsed.signature as ColorProof);\n }\n }\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n /**\n * Runs a write transaction whose default color is `root`'s signature instead of the client\n * root's, and whose `tx.clientRoot` is `root`. For admin cross-root operations (e.g. copying a\n * project into another user's root so the copy is minted in that user's color). The backend\n * still authorizes the write by role.\n */\n public async withWriteTxOnRoot<T>(\n root: SignedResourceId,\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, true, root, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,eAAe,EACnB,MAAM,MACR;AAEA,SAAS,yBAAyB,iBAAiC;CACjE,OAAO,oBAAoB;AAC7B;;AAGA,IAAa,WAAb,MAAa,SAAS;CACpB,0BAA2B,IAAI,IAAsB;;;CAIrD;;CAGA;;CAGA;CAEA;CAIA;CAEA,IAAY,KAAiB;EAC3B,IAAI,KAAK,QAAQ,KAAA,GACf,MAAM,IAAI,MAAM,4BAA4B;EAE9C,OAAO,KAAK;CACd;;CAGA,cAAQ;CAER;;;;CAKA,mBAAwC;CAExC,mBAAmCA,aAAAA,cAAc;CACjD,kBAAkCA,aAAAA,cAAc;CAChD,eAA+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AAG;EAAa,CAAC;CAC/E;CAEA,MAAa,WACX,MACA,MACA,MAAsB,CAAC,GACX;EACZ,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CACzE;CAEA,UAAuC,YAA0C;EAC/E,MAAM,WAAW,KAAK,QAAQ,IAAI,WAAW,IAAI;EACjD,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK,cAAc;EACjE,KAAK,QAAQ,IAAI,WAAW,MAAM,MAAM;EACxC,OAAO;CACT;;CAGA,MAAa,QAAQ;EACnB,MAAM,KAAK,GAAG,MAAM;CACtB;CAEA,aAAoB,KAClB,iBACA,MACA,MAGI,CAAC,GACL;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,GAAG;EAClD,MAAM,GAAG,KAAK;EACd,OAAO;CACT;AACF"}
@@ -8,19 +8,18 @@ import { BackendCapability } from "./capabilities.js";
8
8
  import { WireConnection } from "./wire.js";
9
9
  import { PlCallOps } from "./ll_client.js";
10
10
  import { PlDriver, PlDriverDefinition } from "./driver.js";
11
- import { UserResources } from "./user_resources.js";
11
+ import { UserDeletionReport, UserResources } from "./user_resources.js";
12
12
  import { MiLogger, RetryOptions } from "@milaboratories/ts-helpers";
13
13
  import { Dispatcher } from "undici";
14
-
15
14
  //#region src/core/client.d.ts
16
- type TxOps = PlCallOps & {
15
+ export type TxOps = PlCallOps & {
17
16
  sync?: boolean;
18
17
  retryOptions?: RetryOptions;
19
18
  name?: string;
20
19
  lockId?: string;
21
20
  };
22
21
  /** Client to access core PL API. */
23
- declare class PlClient {
22
+ export declare class PlClient {
24
23
  private readonly drivers;
25
24
  /** Artificial delay introduced after write transactions completion, to
26
25
  * somewhat throttle the load on pl. Delay introduced after sync, if requested. */
@@ -60,6 +59,11 @@ declare class PlClient {
60
59
  license(): Promise<MaintenanceAPI_License_Response>;
61
60
  /** Lists the users known to the server (login only on the wire). See {@link LLPlClient.listUsers}. */
62
61
  listUsers(): Promise<AuthAPI_User[]>;
62
+ /**
63
+ * Deletes a user account and its root resource — with the root, everything still attached
64
+ * under it. Destructive and irreversible; see {@link UserResources.deleteUser}.
65
+ */
66
+ deleteUser(login: string): Promise<UserDeletionReport>;
63
67
  /**
64
68
  * Returns the user root SignedResourceId via ListUserResources.
65
69
  * @param opts.login - target user login; omit for the authenticated user.
@@ -121,5 +125,4 @@ declare class PlClient {
121
125
  }): Promise<PlClient>;
122
126
  }
123
127
  //#endregion
124
- export { PlClient, TxOps };
125
128
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/core/client.ts"],"mappings":";;;;;;;;;;;;;;;KAqCY,KAAA,GAAQ,SAAA;EAClB,IAAA;EACA,YAAA,GAAe,YAAY;EAC3B,IAAA;EACA,MAAA;AAAA;;cAYW,QAAA;EAAA,iBACM,OAAA;EAdjB;;EAAA,iBAkBiB,OAAA;EAjBX;EAAA,iBAoBW,SAAA;EARE;EAAA,iBAWF,mBAAA;EAAA,iBAEA,eAAA;EAAA,QAIT,GAAA;EAAA,YAEI,EAAA;EAqGc;EAAA,QA7FlB,WAAA;EAAA,QAEA,cAAA;EAkHqB;;;EAAA,QA7GrB,gBAAA;EAAA,QAEA,gBAAA;EAAA,QACA,eAAA;EAAA,QACA,YAAA;EA+HJ;EAAA,SAxHY,cAAA,EAAgB,0BAAA;EA4H5B;EAAA,iBAzHa,iBAAA;EAAA,QAEV,WAAA;EAAA,IA8DI,eAAA,IAAmB,MAAA;EAAA,IAInB,cAAA,IAAkB,MAAA;EAAA,IAIlB,WAAA,IAAe,MAAA;EAAA,IAIf,WAAA,IAAe,MAAA;EAAA,IAIf,SAAA,IAAa,SAAA;EA4GI;;;EAAA,IAjGjB,aAAA;EAIE,IAAA,IAAQ,OAAA,CAAQ,4BAAA;EAIhB,OAAA,IAAW,OAAA,CAAQ,+BAAA;EA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YAAY,mBAAmB,OAAO;;EAShE,SAAK;SAIE,KAClB,iBAAiB,yBACjB,MAAM,SACN;IACE,iBAAiB;IACjB,SAAS;MACL,QAAA"}
@@ -124,6 +124,13 @@ var PlClient = class PlClient {
124
124
  async listUsers() {
125
125
  return await this.ll.listUsers();
126
126
  }
127
+ /**
128
+ * Deletes a user account and its root resource — with the root, everything still attached
129
+ * under it. Destructive and irreversible; see {@link UserResources.deleteUser}.
130
+ */
131
+ async deleteUser(login) {
132
+ return await this.userResources.deleteUser(login);
133
+ }
127
134
  async getUserRoot(opts = {}) {
128
135
  return this.userResources.getUserRoot(opts);
129
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport { PlTransaction, TxCommitConflict } from \"./transaction\";\nimport type { Role } from \"./transaction\";\nimport type { OptionalSignedResourceId, SignedResourceId } from \"./types\";\nimport {\n ensureSignedResourceIdNotNull,\n isNullSignedResourceId,\n NullSignedResourceId,\n parseSignedResourceId,\n} from \"./types\";\nimport type { ColorProof } from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n AuthAPI_User,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\nimport { UserResources } from \"./user_resources\";\nimport type { BackendCapability } from \"./capabilities\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalSignedResourceId = NullSignedResourceId;\n\n private _userResources?: UserResources;\n\n /** Cached effective role of the authenticated session, fetched once during\n * init via the GetSessionInfo RPC. `null` for an anonymous (no-auth)\n * connection — mirrors {@link authUser}. Read through {@link currentUserRole}. */\n private _currentUserRole: Role | null = null;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<SignedResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n // An empty or whitespace-only asUser means \"no impersonation\"; normalize to undefined so a\n // directly-constructed { asUser: \"\" } does not slip through as an empty login.\n if (conf.asUser !== undefined && conf.asUser.trim() === \"\") conf.asUser = undefined;\n\n // asUser (impersonation) and alternativeRoot both repoint the client root, so they cannot be\n // combined. Validate here, before init() touches the network, so a misconfiguration fails fast.\n if (conf.asUser !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"PlClient: asUser and alternativeRoot cannot be combined.\");\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n /** Smoothed round-trip estimate in ms from ping timings, or undefined before the first\n * ping. Exposed so latency-sensitive consumers (e.g. the tree-sync poll cadence) can scale\n * their timing to the link instead of assuming a local server. */\n public get rttEstimateMs(): number | undefined {\n return this.ll.rttEstimateMs;\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n /** Lists the users known to the server (login only on the wire). See {@link LLPlClient.listUsers}. */\n public async listUsers(): Promise<AuthAPI_User[]> {\n return await this.ll.listUsers();\n }\n\n /**\n * Returns the user root SignedResourceId via ListUserResources.\n * @param opts.login - target user login; omit for the authenticated user.\n * @returns SignedResourceId of the user root, or undefined if the server returned no userRoot entry.\n * @throws if the backend does not implement ListUserResources (callers should catch with isUnimplementedError).\n */\n public async getUserRoot(opts: {\n login?: string;\n createIfNotExists: true;\n }): Promise<SignedResourceId>;\n public async getUserRoot(opts?: {\n login?: string;\n createIfNotExists?: boolean;\n }): Promise<SignedResourceId | undefined>;\n public async getUserRoot(\n opts: { login?: string; createIfNotExists?: boolean } = {},\n ): Promise<SignedResourceId | undefined> {\n return this.userResources.getUserRoot(opts);\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullSignedResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): SignedResourceId {\n this.checkInitialized();\n return ensureSignedResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._ll!.serverInfo;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n this.checkInitialized();\n return this._ll!.hasCapability(capability);\n }\n\n /** Effective role of the authenticated session, resolved once during init via\n * the GetSessionInfo RPC and cached. `null` for an anonymous (no-auth)\n * connection, or when the backend predates GetSessionInfo. Mirrors\n * {@link authUser}'s null contract. */\n public get currentUserRole(): Role | null {\n this.checkInitialized();\n return this._currentUserRole;\n }\n\n /** Login of the authenticated user, or `null` for an anonymous connection. */\n public get authUser(): string | null {\n this.checkInitialized();\n return this.userResources.authUser;\n }\n\n /**\n * True if the backend honors per-file `permissions` on workdir fill rules.\n * See {@link LLPlClient.supportsWritableWorkdirFiles} for the full definition.\n */\n public get supportsWritableWorkdirFiles(): boolean {\n this.checkInitialized();\n return this._ll!.supportsWritableWorkdirFiles;\n }\n\n /** User resources index for discovering data libraries and other shared resources. */\n public get userResources(): UserResources {\n if (!this._ll) throw new Error(\"Client not initialized\");\n\n if (!this._userResources) {\n this._userResources = new UserResources(this._ll, this._withTx.bind(this), this._ll.authUser);\n }\n\n return this._userResources;\n }\n\n /** Discovers or creates the user's root resource via UserResources,\n * then handles alternativeRoot if configured. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n // LLPlClient.build() guarantees a successful ping; read the cached response instead of pinging again.\n const info = this._ll.serverInfo;\n if (info.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n // Resolve the client root. Normally the caller's own root; when `asUser` is set (admin impersonation),\n // the target user's root instead. The backend authorizes impersonation by role and silently returns the\n // caller's own root for non-admins, so no client-side role gate is needed here.\n let userRoot: SignedResourceId;\n if (this.conf.asUser === undefined) {\n userRoot = await this.userResources.getUserRoot({ createIfNotExists: true });\n } else {\n const impersonatedRoot = await this.userResources.getUserRoot({ login: this.conf.asUser });\n if (impersonatedRoot === undefined)\n throw new Error(\n `PlClient: cannot open root of user '${this.conf.asUser}': no root found (the user may have never logged in).`,\n );\n userRoot = impersonatedRoot;\n }\n\n // Resolve the caller's role once; only the publicGrants-gated share-with-everybody check uses it,\n // so skip it for anonymous connections or when publicGrants:v1 is absent. Use _ll.hasCapability,\n // not this.hasCapability: we are mid-init, so this.checkInitialized() would throw.\n if (this.userResources.authUser !== null && this._ll.hasCapability(\"publicGrants:v1\")) {\n this._currentUserRole = (await this._ll.getSessionInfo()).role;\n }\n\n if (this.conf.alternativeRoot === undefined) {\n this._clientRoot = userRoot;\n } else {\n this._clientRoot = await this._withTx(\"initialization\", true, userRoot, async (tx) => {\n const aFId = {\n resourceId: userRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot!),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n });\n }\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalSignedResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n // Auto-set default color proof from the client root's signature.\n // Skip when backend doesn't implement the `set_default_color` TX request.\n if (this.ll.supportsResourceSignatures && !isNullSignedResourceId(clientRoot) && writable) {\n const parsed = parseSignedResourceId(clientRoot);\n if (parsed.signature) {\n tx.setDefaultColor(parsed.signature as ColorProof);\n }\n }\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n /**\n * Runs a write transaction whose default color is `root`'s signature instead of the client\n * root's, and whose `tx.clientRoot` is `root`. For admin cross-root operations (e.g. copying a\n * project into another user's root so the copy is minted in that user's color). The backend\n * still authorizes the write by role.\n */\n public async withWriteTxOnRoot<T>(\n root: SignedResourceId,\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, true, root, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA4CA,MAAM,eAAe,EACnB,MAAM,MACR;AAEA,SAAS,yBAAyB,iBAAiC;CACjE,OAAO,oBAAoB;AAC7B;;AAGA,IAAa,WAAb,MAAa,SAAS;CACpB,0BAA2B,IAAI,IAAsB;;;CAIrD;;CAGA;;CAGA;CAEA;CAIA;CAEA,IAAY,KAAiB;EAC3B,IAAI,KAAK,QAAQ,KAAA,GACf,MAAM,IAAI,MAAM,4BAA4B;EAE9C,OAAO,KAAK;CACd;;CAGA,cAAQ;CAER;;;;CAKA,mBAAwC;CAExC,mBAAmC,cAAc;CACjD,kBAAkC,cAAc;CAChD,eAA+B,cAAc;;CAO7C;;CAGA;CAEA,YACE,iBACA,MACA,MAII,CAAC,GACL;EACA,MAAM,OACJ,OAAO,oBAAoB,WAAW,kBAAkB,eAAe,IAAI;EAI7E,IAAI,KAAK,WAAW,KAAA,KAAa,KAAK,OAAO,KAAK,MAAM,IAAI,KAAK,SAAS,KAAA;EAI1E,IAAI,KAAK,WAAW,KAAA,KAAa,KAAK,oBAAoB,KAAA,GACxD,MAAM,IAAI,MAAM,0DAA0D;EAE5E,KAAK,kBAAkB,OACrB,eACA,iBACwB;GACxB,IAAI,cAAc,KAAK,eAAe;GACtC,OAAO,MAAM,WAAW,MAAM,MAAM;IAAE;IAAM,GAAG;IAAK;GAAc,CAAC;EACrE;EAEA,KAAK,UAAU,KAAK;EACpB,KAAK,YAAY,KAAK;EACtB,KAAK,iBAAiB,IAAI,kBAAkB;EAC5C,KAAK,oBAAoB,IAAI,SAAS;GACpC,SAAS,KAAK;GACd,kBAAkB,OAAO,EAAE,UAAU,MAAM,UAAU,KAAK;EAC5D,CAAC;EACD,QAAQ,KAAK,uBA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MAAsB,CAAC,GACX;EACZ,OAAO,MAAM,KAAK,OAAO,MAAM,MAAM,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CACxE;;;;;;;CAQA,MAAa,kBACX,MACA,MACA,MACA,MAAsB,CAAC,GACX;EACZ,KAAK,iBAAiB;EACtB,OAAO,MAAM,KAAK,QAAQ,MAAM,MAAM,MAAM,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CAC/E;CAEA,MAAa,WACX,MACA,MACA,MAAsB,CAAC,GACX;EACZ,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM;GAAE,GAAG;GAAK,GAAG;EAAa,CAAC;CACzE;CAEA,UAAuC,YAA0C;EAC/E,MAAM,WAAW,KAAK,QAAQ,IAAI,WAAW,IAAI;EACjD,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,KAAK,cAAc;EACjE,KAAK,QAAQ,IAAI,WAAW,MAAM,MAAM;EACxC,OAAO;CACT;;CAGA,MAAa,QAAQ;EACnB,MAAM,KAAK,GAAG,MAAM;CACtB;CAEA,aAAoB,KAClB,iBACA,MACA,MAGI,CAAC,GACL;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,GAAG;EAClD,MAAM,GAAG,KAAK;EACd,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/core/client.ts"],"sourcesContent":["import type { AuthOps, PlClientConfig, PlConnectionStatusListener, wireProtocol } from \"./config\";\nimport type { PlCallOps } from \"./ll_client\";\nimport { LLPlClient } from \"./ll_client\";\nimport { PlTransaction, TxCommitConflict } from \"./transaction\";\nimport type { Role } from \"./transaction\";\nimport type { OptionalSignedResourceId, SignedResourceId } from \"./types\";\nimport {\n ensureSignedResourceIdNotNull,\n isNullSignedResourceId,\n NullSignedResourceId,\n parseSignedResourceId,\n} from \"./types\";\nimport type { ColorProof } from \"./types\";\nimport { ClientRoot } from \"../helpers/pl\";\nimport type { MiLogger, RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { assertNever, createRetryState, nextRetryStateOrError } from \"@milaboratories/ts-helpers\";\nimport type { PlDriver, PlDriverDefinition } from \"./driver\";\nimport type {\n MaintenanceAPI_Ping_Response,\n MaintenanceAPI_License_Response,\n AuthAPI_User,\n} from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport { MaintenanceAPI_Ping_Response_Compression } from \"../proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api\";\nimport * as tp from \"node:timers/promises\";\nimport type { Dispatcher } from \"undici\";\nimport { LRUCache } from \"lru-cache\";\nimport type { ResourceDataCacheRecord } from \"./cache\";\nimport type { FinalResourceDataPredicate } from \"./final\";\nimport { DefaultFinalResourceDataPredicate } from \"./final\";\nimport type { AllTxStat, TxStat } from \"./stat\";\nimport { addStat, initialTxStat } from \"./stat\";\nimport type { WireConnection } from \"./wire\";\nimport { advisoryLock } from \"./advisory_locks\";\nimport { plAddressToConfig } from \"./config\";\nimport { UserResources } from \"./user_resources\";\nimport type { UserDeletionReport } from \"./user_resources\";\nimport type { BackendCapability } from \"./capabilities\";\n\nexport type TxOps = PlCallOps & {\n sync?: boolean;\n retryOptions?: RetryOptions;\n name?: string;\n lockId?: string;\n};\n\nconst defaultTxOps = {\n sync: false,\n};\n\nfunction alternativeRootFieldName(alternativeRoot: string): string {\n return `alternative_root_${alternativeRoot}`;\n}\n\n/** Client to access core PL API. */\nexport class PlClient {\n private readonly drivers = new Map<string, PlDriver>();\n\n /** Artificial delay introduced after write transactions completion, to\n * somewhat throttle the load on pl. Delay introduced after sync, if requested. */\n private readonly txDelay: number;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly forceSync: boolean;\n\n /** Last resort measure to solve complicated race conditions in pl. */\n private readonly defaultRetryOptions: RetryOptions;\n\n private readonly buildLLPlClient: (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ) => Promise<LLPlClient>;\n private _ll?: LLPlClient;\n\n private get ll(): LLPlClient {\n if (this._ll === undefined) {\n throw new Error(\"LLPlClient not initialized\");\n }\n return this._ll;\n }\n\n /** Stores client root (this abstraction is intended for future implementation of the security model) */\n private _clientRoot: OptionalSignedResourceId = NullSignedResourceId;\n\n private _userResources?: UserResources;\n\n /** Cached effective role of the authenticated session, fetched once during\n * init via the GetSessionInfo RPC. `null` for an anonymous (no-auth)\n * connection — mirrors {@link authUser}. Read through {@link currentUserRole}. */\n private _currentUserRole: Role | null = null;\n\n private _txCommittedStat: TxStat = initialTxStat();\n private _txConflictStat: TxStat = initialTxStat();\n private _txErrorStat: TxStat = initialTxStat();\n\n //\n // Caching\n //\n\n /** This function determines whether resource data can be cached */\n public readonly finalPredicate: FinalResourceDataPredicate;\n\n /** Resource data cache, to minimize redundant data rereading from remote db */\n private readonly resourceDataCache: LRUCache<SignedResourceId, ResourceDataCacheRecord>;\n\n private constructor(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n finalPredicate?: FinalResourceDataPredicate;\n logger?: MiLogger;\n } = {},\n ) {\n const conf =\n typeof configOrAddress === \"string\" ? plAddressToConfig(configOrAddress) : configOrAddress;\n\n // An empty or whitespace-only asUser means \"no impersonation\"; normalize to undefined so a\n // directly-constructed { asUser: \"\" } does not slip through as an empty login.\n if (conf.asUser !== undefined && conf.asUser.trim() === \"\") conf.asUser = undefined;\n\n // asUser (impersonation) and alternativeRoot both repoint the client root, so they cannot be\n // combined. Validate here, before init() touches the network, so a misconfiguration fails fast.\n if (conf.asUser !== undefined && conf.alternativeRoot !== undefined)\n throw new Error(\"PlClient: asUser and alternativeRoot cannot be combined.\");\n\n this.buildLLPlClient = async (\n shouldUseGzip: boolean,\n wireProtocol?: wireProtocol,\n ): Promise<LLPlClient> => {\n if (wireProtocol) conf.wireProtocol = wireProtocol;\n return await LLPlClient.build(conf, { auth, ...ops, shouldUseGzip });\n };\n\n this.txDelay = conf.txDelay;\n this.forceSync = conf.forceSync;\n this.finalPredicate = ops.finalPredicate ?? DefaultFinalResourceDataPredicate;\n this.resourceDataCache = new LRUCache({\n maxSize: conf.maxCacheBytes,\n sizeCalculation: (v) => (v.basicData.data?.length ?? 0) + 64,\n });\n switch (conf.retryBackoffAlgorithm) {\n case \"exponential\":\n this.defaultRetryOptions = {\n type: \"exponentialBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffMultiplier: conf.retryExponentialBackoffMultiplier,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n case \"linear\":\n this.defaultRetryOptions = {\n type: \"linearBackoff\",\n initialDelay: conf.retryInitialDelay,\n maxAttempts: conf.retryMaxAttempts,\n backoffStep: conf.retryLinearBackoffStep,\n jitter: conf.retryJitter,\n maxDelay: conf.retryMaxDelay,\n };\n break;\n default:\n assertNever(conf.retryBackoffAlgorithm);\n }\n }\n\n public get txCommittedStat(): TxStat {\n return { ...this._txCommittedStat };\n }\n\n public get txConflictStat(): TxStat {\n return { ...this._txConflictStat };\n }\n\n public get txErrorStat(): TxStat {\n return { ...this._txErrorStat };\n }\n\n public get txTotalStat(): TxStat {\n return addStat(addStat(this._txCommittedStat, this._txConflictStat), this._txErrorStat);\n }\n\n public get allTxStat(): AllTxStat {\n return {\n committed: this.txCommittedStat,\n conflict: this.txConflictStat,\n error: this.txErrorStat,\n };\n }\n\n /** Smoothed round-trip estimate in ms from ping timings, or undefined before the first\n * ping. Exposed so latency-sensitive consumers (e.g. the tree-sync poll cadence) can scale\n * their timing to the link instead of assuming a local server. */\n public get rttEstimateMs(): number | undefined {\n return this.ll.rttEstimateMs;\n }\n\n public async ping(): Promise<MaintenanceAPI_Ping_Response> {\n return await this.ll.ping();\n }\n\n public async license(): Promise<MaintenanceAPI_License_Response> {\n return await this.ll.license();\n }\n\n /** Lists the users known to the server (login only on the wire). See {@link LLPlClient.listUsers}. */\n public async listUsers(): Promise<AuthAPI_User[]> {\n return await this.ll.listUsers();\n }\n\n /**\n * Deletes a user account and its root resource — with the root, everything still attached\n * under it. Destructive and irreversible; see {@link UserResources.deleteUser}.\n */\n public async deleteUser(login: string): Promise<UserDeletionReport> {\n return await this.userResources.deleteUser(login);\n }\n\n /**\n * Returns the user root SignedResourceId via ListUserResources.\n * @param opts.login - target user login; omit for the authenticated user.\n * @returns SignedResourceId of the user root, or undefined if the server returned no userRoot entry.\n * @throws if the backend does not implement ListUserResources (callers should catch with isUnimplementedError).\n */\n public async getUserRoot(opts: {\n login?: string;\n createIfNotExists: true;\n }): Promise<SignedResourceId>;\n public async getUserRoot(opts?: {\n login?: string;\n createIfNotExists?: boolean;\n }): Promise<SignedResourceId | undefined>;\n public async getUserRoot(\n opts: { login?: string; createIfNotExists?: boolean } = {},\n ): Promise<SignedResourceId | undefined> {\n return this.userResources.getUserRoot(opts);\n }\n\n public get conf(): PlClientConfig {\n return this.ll.conf;\n }\n\n public get httpDispatcher(): Dispatcher {\n return this.ll.httpDispatcher;\n }\n\n public get connectionOpts(): WireConnection {\n return this.ll.wireConnection;\n }\n\n private get initialized() {\n return !isNullSignedResourceId(this._clientRoot);\n }\n\n private checkInitialized() {\n if (!this.initialized) throw new Error(\"Client not initialized\");\n }\n\n public get clientRoot(): SignedResourceId {\n this.checkInitialized();\n return ensureSignedResourceIdNotNull(this._clientRoot);\n }\n\n public get serverInfo(): MaintenanceAPI_Ping_Response {\n this.checkInitialized();\n return this._ll!.serverInfo;\n }\n\n public hasCapability(capability: BackendCapability): boolean {\n this.checkInitialized();\n return this._ll!.hasCapability(capability);\n }\n\n /** Effective role of the authenticated session, resolved once during init via\n * the GetSessionInfo RPC and cached. `null` for an anonymous (no-auth)\n * connection, or when the backend predates GetSessionInfo. Mirrors\n * {@link authUser}'s null contract. */\n public get currentUserRole(): Role | null {\n this.checkInitialized();\n return this._currentUserRole;\n }\n\n /** Login of the authenticated user, or `null` for an anonymous connection. */\n public get authUser(): string | null {\n this.checkInitialized();\n return this.userResources.authUser;\n }\n\n /**\n * True if the backend honors per-file `permissions` on workdir fill rules.\n * See {@link LLPlClient.supportsWritableWorkdirFiles} for the full definition.\n */\n public get supportsWritableWorkdirFiles(): boolean {\n this.checkInitialized();\n return this._ll!.supportsWritableWorkdirFiles;\n }\n\n /** User resources index for discovering data libraries and other shared resources. */\n public get userResources(): UserResources {\n if (!this._ll) throw new Error(\"Client not initialized\");\n\n if (!this._userResources) {\n this._userResources = new UserResources(this._ll, this._withTx.bind(this), this._ll.authUser);\n }\n\n return this._userResources;\n }\n\n /** Discovers or creates the user's root resource via UserResources,\n * then handles alternativeRoot if configured. */\n private async init() {\n if (this.initialized) throw new Error(\"Already initialized\");\n\n // Initial client is created without gzip to perform server ping and detect optimal wire protocol.\n // LLPlClient.build() internally calls detectOptimalWireProtocol() which starts with default 'grpc',\n // then retries with 'rest' if ping fails, alternating until a working protocol is found.\n // We save the detected wireProtocol here because if the server supports gzip compression,\n // we'll need to reinitialize the client with gzip enabled - passing the already-detected\n // wireProtocol avoids redundant protocol detection on reinit.\n this._ll = await this.buildLLPlClient(false);\n const wireProtocol = this._ll.wireProtocol;\n\n // LLPlClient.build() guarantees a successful ping; read the cached response instead of pinging again.\n const info = this._ll.serverInfo;\n if (info.compression === MaintenanceAPI_Ping_Response_Compression.GZIP) {\n await this._ll.close();\n this._ll = await this.buildLLPlClient(true, wireProtocol);\n }\n\n // Resolve the client root. Normally the caller's own root; when `asUser` is set (admin impersonation),\n // the target user's root instead. The backend authorizes impersonation by role and silently returns the\n // caller's own root for non-admins, so no client-side role gate is needed here.\n let userRoot: SignedResourceId;\n if (this.conf.asUser === undefined) {\n userRoot = await this.userResources.getUserRoot({ createIfNotExists: true });\n } else {\n const impersonatedRoot = await this.userResources.getUserRoot({ login: this.conf.asUser });\n if (impersonatedRoot === undefined)\n throw new Error(\n `PlClient: cannot open root of user '${this.conf.asUser}': no root found (the user may have never logged in).`,\n );\n userRoot = impersonatedRoot;\n }\n\n // Resolve the caller's role once; only the publicGrants-gated share-with-everybody check uses it,\n // so skip it for anonymous connections or when publicGrants:v1 is absent. Use _ll.hasCapability,\n // not this.hasCapability: we are mid-init, so this.checkInitialized() would throw.\n if (this.userResources.authUser !== null && this._ll.hasCapability(\"publicGrants:v1\")) {\n this._currentUserRole = (await this._ll.getSessionInfo()).role;\n }\n\n if (this.conf.alternativeRoot === undefined) {\n this._clientRoot = userRoot;\n } else {\n this._clientRoot = await this._withTx(\"initialization\", true, userRoot, async (tx) => {\n const aFId = {\n resourceId: userRoot,\n fieldName: alternativeRootFieldName(this.conf.alternativeRoot!),\n };\n\n const altRoot = tx.createEphemeral(ClientRoot);\n tx.lock(altRoot);\n tx.createField(aFId, \"Dynamic\");\n tx.setField(aFId, altRoot);\n await tx.commit();\n\n return await altRoot.globalId;\n });\n }\n }\n\n /** Returns true if field existed */\n public async deleteAlternativeRoot(alternativeRootName: string): Promise<boolean> {\n this.checkInitialized();\n if (this.ll.conf.alternativeRoot !== undefined)\n throw new Error(\"Initialized with alternative root.\");\n return await this.withWriteTx(\"delete-alternative-root\", async (tx) => {\n const fId = {\n resourceId: tx.clientRoot,\n fieldName: alternativeRootFieldName(alternativeRootName),\n };\n const exists = tx.fieldExists(fId);\n tx.removeField(fId);\n await tx.commit();\n return await exists;\n });\n }\n\n private async _withTx<T>(\n name: string,\n writable: boolean,\n clientRoot: OptionalSignedResourceId,\n body: (tx: PlTransaction) => Promise<T>,\n ops?: TxOps,\n ): Promise<T> {\n // for exponential / linear backoff\n let retryState = createRetryState(ops?.retryOptions ?? this.defaultRetryOptions);\n\n while (true) {\n const release = ops?.lockId ? await advisoryLock(ops.lockId) : () => {};\n\n try {\n // opening low-level tx\n const llTx = this.ll.createTx(writable, ops);\n // wrapping it into high-level tx (this also asynchronously sends initialization message)\n const tx = new PlTransaction(\n llTx,\n name,\n writable,\n clientRoot,\n this.finalPredicate,\n this.resourceDataCache,\n );\n\n // Auto-set default color proof from the client root's signature.\n // Skip when backend doesn't implement the `set_default_color` TX request.\n if (this.ll.supportsResourceSignatures && !isNullSignedResourceId(clientRoot) && writable) {\n const parsed = parseSignedResourceId(clientRoot);\n if (parsed.signature) {\n tx.setDefaultColor(parsed.signature as ColorProof);\n }\n }\n\n let ok = false;\n let result: T | undefined = undefined;\n let txId;\n\n try {\n // executing transaction body\n result = await body(tx);\n // collecting stat\n this._txCommittedStat = addStat(this._txCommittedStat, tx.stat);\n ok = true;\n } catch (e: unknown) {\n // the only recoverable\n if (e instanceof TxCommitConflict) {\n // ignoring\n // collecting stat\n this._txConflictStat = addStat(this._txConflictStat, tx.stat);\n } else {\n // collecting stat\n this._txErrorStat = addStat(this._txErrorStat, tx.stat);\n throw e;\n }\n } finally {\n // close underlying grpc stream, if not yet done\n\n // even though we can skip two lines below for read-only transactions,\n // we don't do it to simplify reasoning about what is going on in\n // concurrent code, especially in significant latency situations\n await tx.complete();\n await tx.await();\n\n txId = await tx.getGlobalTxId();\n }\n\n if (ok) {\n // syncing on transaction if requested\n if (ops?.sync === undefined ? this.forceSync : ops?.sync) await this.ll.txSync(txId);\n\n // introducing artificial delay, if requested\n if (writable && this.txDelay > 0)\n await tp.setTimeout(this.txDelay, undefined, { signal: ops?.abortSignal });\n\n return result!;\n }\n } finally {\n release();\n }\n\n // we only get here after TxCommitConflict error,\n // all other errors terminate this loop instantly\n\n await tp.setTimeout(retryState.nextDelay, undefined, { signal: ops?.abortSignal });\n retryState = nextRetryStateOrError(retryState);\n }\n }\n\n private async withTx<T>(\n name: string,\n writable: boolean,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, writable, this.clientRoot, body, { ...ops, ...defaultTxOps });\n }\n\n public async withWriteTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, true, body, { ...ops, ...defaultTxOps });\n }\n\n /**\n * Runs a write transaction whose default color is `root`'s signature instead of the client\n * root's, and whose `tx.clientRoot` is `root`. For admin cross-root operations (e.g. copying a\n * project into another user's root so the copy is minted in that user's color). The backend\n * still authorizes the write by role.\n */\n public async withWriteTxOnRoot<T>(\n root: SignedResourceId,\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n this.checkInitialized();\n return await this._withTx(name, true, root, body, { ...ops, ...defaultTxOps });\n }\n\n public async withReadTx<T>(\n name: string,\n body: (tx: PlTransaction) => Promise<T>,\n ops: Partial<TxOps> = {},\n ): Promise<T> {\n return await this.withTx(name, false, body, { ...ops, ...defaultTxOps });\n }\n\n public getDriver<Drv extends PlDriver>(definition: PlDriverDefinition<Drv>): Drv {\n const attached = this.drivers.get(definition.name);\n if (attached !== undefined) return attached as Drv;\n const driver = definition.init(this, this.ll, this.httpDispatcher);\n this.drivers.set(definition.name, driver);\n return driver;\n }\n\n /** Closes underlying transport */\n public async close() {\n await this.ll.close();\n }\n\n public static async init(\n configOrAddress: PlClientConfig | string,\n auth: AuthOps,\n ops: {\n statusListener?: PlConnectionStatusListener;\n logger?: MiLogger;\n } = {},\n ) {\n const pl = new PlClient(configOrAddress, auth, ops);\n await pl.init();\n return pl;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,MAAM,eAAe,EACnB,MAAM,MACR;AAEA,SAAS,yBAAyB,iBAAiC;CACjE,OAAO,oBAAoB;AAC7B;;AAGA,IAAa,WAAb,MAAa,SAAS;CACpB,0BAA2B,IAAI,IAAsB;;;CAIrD;;CAGA;;CAGA;CAEA;CAIA;CAEA,IAAY,KAAiB;EAC3B,IAAI,KAAK,QAAQ,KAAA,GACf,MAAM,IAAI,MAAM,4BAA4B;EAE9C,OAAO,KAAK;CACd;;CAGA,cAAQ;CAER;;;;CAKA,mBAAwC;CAExC,mBAAmC,cAAc;CACjD,kBAAkC,cAAc;CAChD,eAA+B,cAAc;;CAO7C;;CAGA;CAEA,YACE,iBACA,MACA,MAII,CAA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AAW,KAAK,MAAM,KAAK,IAAI,KAAK,cAAc;EACjE,KAAK,QAAQ,IAAI,WAAW,MAAM,MAAM;EACxC,OAAO;CACT;;CAGA,MAAa,QAAQ;EACnB,MAAM,KAAK,GAAG,MAAM;CACtB;CAEA,aAAoB,KAClB,iBACA,MACA,MAGI,CAAC,GACL;EACA,MAAM,KAAK,IAAI,SAAS,iBAAiB,MAAM,GAAG;EAClD,MAAM,GAAG,KAAK;EACd,OAAO;CACT;AACF"}
@@ -1,11 +1,10 @@
1
1
  import { ExponentialBackoffRetryOptions } from "@milaboratories/ts-helpers";
2
2
  import { ProxySettings } from "@milaboratories/pl-http";
3
-
4
3
  //#region src/core/config.d.ts
5
- declare const SUPPORTED_WIRE_PROTOCOLS: readonly ["grpc", "rest"];
6
- type wireProtocol = (typeof SUPPORTED_WIRE_PROTOCOLS)[number];
4
+ export declare const SUPPORTED_WIRE_PROTOCOLS: readonly ["grpc", "rest"];
5
+ export type wireProtocol = (typeof SUPPORTED_WIRE_PROTOCOLS)[number];
7
6
  /** Base configuration structure for PL client */
8
- interface PlClientConfig {
7
+ export interface PlClientConfig {
9
8
  /** Port and host of remote pl server */
10
9
  hostAndPort: string;
11
10
  /** Type of wire connection (protocol server uses for communication) */
@@ -70,54 +69,54 @@ interface PlClientConfig {
70
69
  * alone reaches ~66s (~150s once jitter compounds). */
71
70
  retryMaxDelay: number;
72
71
  }
73
- declare const DEFAULT_REQUEST_TIMEOUT = 5000;
74
- declare const DEFAULT_RO_TX_TIMEOUT = 300000;
75
- declare const DEFAULT_RW_TX_TIMEOUT = 60000;
76
- declare const DEFAULT_TOKEN_TTL_SECONDS: number;
77
- declare const DEFAULT_AUTH_MAX_REFRESH: number;
78
- declare const DEFAULT_MAX_CACHE_BYTES = 128000000;
79
- declare const DEFAULT_RETRY_BACKOFF_ALGORITHM = "exponential";
80
- declare const DEFAULT_RETRY_MAX_ATTEMPTS = 21;
81
- declare const DEFAULT_RETRY_INITIAL_DELAY = 20;
82
- declare const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5;
83
- declare const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50;
84
- declare const DEFAULT_RETRY_JITTER = 0.3;
85
- declare const DEFAULT_RETRY_MAX_DELAY = 5000;
72
+ export declare const DEFAULT_REQUEST_TIMEOUT = 5000;
73
+ export declare const DEFAULT_RO_TX_TIMEOUT = 300000;
74
+ export declare const DEFAULT_RW_TX_TIMEOUT = 60000;
75
+ export declare const DEFAULT_TOKEN_TTL_SECONDS: number;
76
+ export declare const DEFAULT_AUTH_MAX_REFRESH: number;
77
+ export declare const DEFAULT_MAX_CACHE_BYTES = 128000000;
78
+ export declare const DEFAULT_RETRY_BACKOFF_ALGORITHM = "exponential";
79
+ export declare const DEFAULT_RETRY_MAX_ATTEMPTS = 21;
80
+ export declare const DEFAULT_RETRY_INITIAL_DELAY = 20;
81
+ export declare const DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER = 1.5;
82
+ export declare const DEFAULT_RETRY_LINEAR_BACKOFF_STEP = 50;
83
+ export declare const DEFAULT_RETRY_JITTER = 0.3;
84
+ export declare const DEFAULT_RETRY_MAX_DELAY = 5000;
86
85
  /** Multiplier applied to the observed RTT when deriving the unary deadline. A unary call
87
86
  * costs at least one round trip, plus connect/DNS/LB and server work on top, so the
88
87
  * deadline needs sizeable headroom over the bare RTT. */
89
- declare const RTT_DEADLINE_MULTIPLIER = 8;
88
+ export declare const RTT_DEADLINE_MULTIPLIER = 8;
90
89
  /** Ceiling for the RTT-derived unary deadline. Beyond this a call is stuck rather than
91
90
  * slow, and waiting longer only delays the retry. */
92
- declare const MAX_ADAPTIVE_REQUEST_TIMEOUT = 60000;
91
+ export declare const MAX_ADAPTIVE_REQUEST_TIMEOUT = 60000;
93
92
  /** Weight of the newest RTT sample in the smoothed estimate. Low enough that one unlucky
94
93
  * sample cannot swing the deadline, high enough to follow a real change. */
95
- declare const RTT_SMOOTHING_ALPHA = 0.3;
94
+ export declare const RTT_SMOOTHING_ALPHA = 0.3;
96
95
  /** Login runs password hashing (and possibly an external IdP round trip) server side, so
97
96
  * it is legitimately slow and gets its own deadline instead of the unary default. */
98
- declare const DEFAULT_LOGIN_TIMEOUT = 120000;
97
+ export declare const DEFAULT_LOGIN_TIMEOUT = 120000;
99
98
  /** Unary deadline for a given RTT estimate: floored by the configured timeout so a fast
100
99
  * link behaves exactly as before, capped by {@link MAX_ADAPTIVE_REQUEST_TIMEOUT}.
101
100
  * An undefined `rttMs` (no ping yet) yields the configured value unchanged. */
102
- declare function deriveUnaryDeadline(configuredMs: number, rttMs: number | undefined): number;
101
+ export declare function deriveUnaryDeadline(configuredMs: number, rttMs: number | undefined): number;
103
102
  /** Folds a new round-trip sample into an exponentially smoothed estimate. */
104
- declare function smoothRtt(previousMs: number | undefined, sampleMs: number): number;
105
- declare const DefaultRetryOptions: ExponentialBackoffRetryOptions;
103
+ export declare function smoothRtt(previousMs: number | undefined, sampleMs: number): number;
104
+ export declare const DefaultRetryOptions: ExponentialBackoffRetryOptions;
106
105
  type PlConfigOverrides = Partial<Pick<PlClientConfig, "ssl" | "defaultRequestTimeout" | "defaultROTransactionTimeout" | "defaultRWTransactionTimeout" | "httpProxy" | "grpcProxy">>;
107
106
  /** Parses pl url and creates a config object that can be passed to
108
107
  * {@link PlClient} of {@link UnauthenticatedPlClient}. */
109
- declare function plAddressToConfig(address: string, overrides?: PlConfigOverrides): PlClientConfig;
108
+ export declare function plAddressToConfig(address: string, overrides?: PlConfigOverrides): PlClientConfig;
110
109
  /**
111
110
  * Authorization data / JWT Token.
112
111
  * Absent JWT Token tells the client to connect as anonymous user.
113
112
  */
114
- interface AuthInformation {
113
+ export interface AuthInformation {
115
114
  /** Absent token means anonymous access */
116
115
  jwtToken?: string;
117
116
  }
118
- declare const AnonymousAuthInformation: AuthInformation;
117
+ export declare const AnonymousAuthInformation: AuthInformation;
119
118
  /** Authorization related settings to pass to {@link PlClient}. */
120
- interface AuthOps {
119
+ export interface AuthOps {
121
120
  /** Initial authorization information */
122
121
  authInformation: AuthInformation;
123
122
  /** Will be executed after successful authorization information refresh */
@@ -128,9 +127,8 @@ interface AuthOps {
128
127
  readonly onUpdateError?: (error: unknown) => void;
129
128
  }
130
129
  /** Connection status. */
131
- type PlConnectionStatus = "OK" | "Disconnected" | "Unauthenticated";
130
+ export type PlConnectionStatus = "OK" | "Disconnected" | "Unauthenticated";
132
131
  /** Listener that will be called each time connection status changes. */
133
- type PlConnectionStatusListener = (status: PlConnectionStatus) => void;
132
+ export type PlConnectionStatusListener = (status: PlConnectionStatus) => void;
134
133
  //#endregion
135
- export { AnonymousAuthInformation, AuthInformation, AuthOps, DEFAULT_AUTH_MAX_REFRESH, DEFAULT_LOGIN_TIMEOUT, DEFAULT_MAX_CACHE_BYTES, DEFAULT_REQUEST_TIMEOUT, DEFAULT_RETRY_BACKOFF_ALGORITHM, DEFAULT_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER, DEFAULT_RETRY_INITIAL_DELAY, DEFAULT_RETRY_JITTER, DEFAULT_RETRY_LINEAR_BACKOFF_STEP, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_MAX_DELAY, DEFAULT_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultRetryOptions, MAX_ADAPTIVE_REQUEST_TIMEOUT, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, RTT_DEADLINE_MULTIPLIER, RTT_SMOOTHING_ALPHA, SUPPORTED_WIRE_PROTOCOLS, deriveUnaryDeadline, plAddressToConfig, smoothRtt, wireProtocol };
136
134
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/core/config.ts"],"mappings":";;;;cAGa,wBAAA;AAAA,KACD,YAAA,WAAuB,wBAAwB;AAD3D;AAAA,UAIiB,cAAA;;EAEf,WAAA;EAN+D;EAS/D,YAAA,G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iB,OAAA;;EAEf,eAAA,EAAiB,eAAA;EApLiB;EAAA,SAsLzB,QAAA,IAAY,OAAA,EAAS,eAAe;EAlLN;EAAA,SAoL9B,WAAA;EApL8B;EAAA,SAsL9B,aAAA,IAAiB,KAAA;AAAA;;KAIhB,kBAAA;;KAGA,0BAAA,IAA8B,MAA0B,EAAlB,kBAAkB"}
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/core/config.ts"],"mappings":";;;qBAGa;YACD,uBAAuB;;iBAGlB;;EAEf;;EAGA,eAAe;;;EAIf;;;;EAKA;;;EAOA;;EAGA;;;EAIA;;;EAGA;;;EAIA;;;EAGA;;EAGA,qBAAqB;;;EAGrB,qBAAqB;;EAGrB;;EAEA;;;EAIA;;EAGA;;EAGA;;;;;EAUA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;;;EAKA;;qBAGW;qBACA;qBACA;qBACA;qBACA;qBAEA;qBAEA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;;;;qBAKA;;;qBAIA;;;qBAIA;;;qBAIA;;;;wBAKG,oBAAoB,sBAAsB;;wBAS1C,UAAU,gCAAgC;qBAK7C,qBAAqB;KAS7B,oBAAoB,QACvB,KACE;;;wBAmBY,kBACd,iBACA,YAAW,oBACV;;;;;iBA0Gc;;EAEf;;qBAGW,0BAA0B;;iBAGtB;;EAEf,iBAAiB;;WAER,YAAY,SAAS;;WAErB;;WAEA,iBAAiB;;;YAIhB;;YAGA,8BAA8B,QAAQ"}
@@ -1,14 +1,12 @@
1
1
  import { PlClientConfig } from "./config.js";
2
2
  import { PlClient } from "./client.js";
3
-
4
3
  //#region src/core/default_client.d.ts
5
4
  type FileConfigOverrideFields = "grpcProxy" | "httpProxy" | "user" | "password" | "alternativeRoot" | "defaultROTransactionTimeout" | "defaultRWTransactionTimeout" | "defaultRequestTimeout" | "authTTLSeconds" | "authMaxRefreshSeconds";
6
5
  type PlConfigFile = {
7
6
  address: string;
8
7
  } & Partial<Pick<PlClientConfig, FileConfigOverrideFields>>;
9
- declare function tryGetFileConfig(): [PlConfigFile, string] | undefined;
8
+ export declare function tryGetFileConfig(): [PlConfigFile, string] | undefined;
10
9
  /** Uses default algorithm to construct a pl client from the environment */
11
- declare function defaultPlClient(): Promise<PlClient>;
10
+ export declare function defaultPlClient(): Promise<PlClient>;
12
11
  //#endregion
13
- export { defaultPlClient, tryGetFileConfig };
14
12
  //# sourceMappingURL=default_client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default_client.d.ts","names":[],"sources":["../../src/core/default_client.ts"],"mappings":";;;;KA0BK,wBAAA;AAAA,KAwBA,YAAA;EACH,OAAA;AAAA,IACE,OAAA,CAAQ,IAAA,CAAK,cAAA,EAAgB,wBAAA;AAAA,iBASjB,gBAAA,KAAqB,YAAY;;iBAkC3B,eAAA,IAAmB,OAAO,CAAC,QAAA"}
1
+ {"version":3,"file":"default_client.d.ts","names":[],"sources":["../../src/core/default_client.ts"],"mappings":";;;KA0BK;KAwBA;EACH;IACE,QAAQ,KAAK,gBAAgB;wBASjB,qBAAqB;;wBAkCf,mBAAmB,QAAQ"}