@milaboratories/pl-client 3.11.5 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/PromiseTracker.cjs.map +1 -1
- package/dist/core/PromiseTracker.d.ts.map +1 -1
- package/dist/core/PromiseTracker.js.map +1 -1
- package/dist/core/StatefulPromise.cjs +2 -0
- package/dist/core/StatefulPromise.cjs.map +1 -1
- package/dist/core/StatefulPromise.js +2 -0
- package/dist/core/StatefulPromise.js.map +1 -1
- package/dist/core/abstract_stream.d.ts +1 -1
- package/dist/core/advisory_locks.cjs.map +1 -1
- package/dist/core/advisory_locks.js.map +1 -1
- package/dist/core/auth.cjs.map +1 -1
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js.map +1 -1
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/capabilities.cjs.map +1 -1
- package/dist/core/capabilities.d.ts +2 -3
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js.map +1 -1
- package/dist/core/client.cjs +23 -6
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +14 -4
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +22 -5
- package/dist/core/client.js.map +1 -1
- package/dist/core/config.cjs.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/default_client.cjs +5 -5
- package/dist/core/default_client.cjs.map +1 -1
- package/dist/core/default_client.d.ts.map +1 -1
- package/dist/core/default_client.js.map +1 -1
- package/dist/core/driver.cjs.map +1 -1
- package/dist/core/driver.d.ts.map +1 -1
- package/dist/core/driver.js.map +1 -1
- package/dist/core/error_resource.cjs.map +1 -1
- package/dist/core/error_resource.js.map +1 -1
- package/dist/core/errors.cjs +11 -11
- package/dist/core/errors.cjs.map +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +11 -10
- package/dist/core/errors.js.map +1 -1
- package/dist/core/final.cjs +6 -2
- package/dist/core/final.cjs.map +1 -1
- package/dist/core/final.d.ts.map +1 -1
- package/dist/core/final.js +4 -1
- package/dist/core/final.js.map +1 -1
- package/dist/core/ll_client.cjs +60 -16
- package/dist/core/ll_client.cjs.map +1 -1
- package/dist/core/ll_client.d.ts +23 -7
- package/dist/core/ll_client.d.ts.map +1 -1
- package/dist/core/ll_client.js +62 -17
- package/dist/core/ll_client.js.map +1 -1
- package/dist/core/ll_transaction.cjs +3 -1
- package/dist/core/ll_transaction.cjs.map +1 -1
- package/dist/core/ll_transaction.d.ts +1 -1
- package/dist/core/ll_transaction.d.ts.map +1 -1
- package/dist/core/ll_transaction.js +2 -1
- package/dist/core/ll_transaction.js.map +1 -1
- package/dist/core/stat.cjs.map +1 -1
- package/dist/core/stat.js.map +1 -1
- package/dist/core/transaction.cjs +91 -4
- package/dist/core/transaction.cjs.map +1 -1
- package/dist/core/transaction.d.ts +52 -2
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +90 -5
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/tree_filter.cjs +73 -18
- package/dist/core/tree_filter.cjs.map +1 -1
- package/dist/core/tree_filter.d.ts +1 -1
- package/dist/core/tree_filter.d.ts.map +1 -1
- package/dist/core/tree_filter.js +72 -19
- package/dist/core/tree_filter.js.map +1 -1
- package/dist/core/type_conversion.cjs +19 -20
- package/dist/core/type_conversion.cjs.map +1 -1
- package/dist/core/type_conversion.js +19 -19
- package/dist/core/type_conversion.js.map +1 -1
- package/dist/core/types.cjs +2 -3
- package/dist/core/types.cjs.map +1 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +2 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/unauth_client.cjs +7 -6
- package/dist/core/unauth_client.cjs.map +1 -1
- package/dist/core/unauth_client.d.ts +9 -0
- package/dist/core/unauth_client.d.ts.map +1 -1
- package/dist/core/unauth_client.js +7 -5
- package/dist/core/unauth_client.js.map +1 -1
- package/dist/core/user_resources.cjs +57 -1
- package/dist/core/user_resources.cjs.map +1 -1
- package/dist/core/user_resources.d.ts +55 -1
- package/dist/core/user_resources.d.ts.map +1 -1
- package/dist/core/user_resources.js +57 -0
- package/dist/core/user_resources.js.map +1 -1
- package/dist/core/websocket_stream.cjs +17 -20
- package/dist/core/websocket_stream.cjs.map +1 -1
- package/dist/core/websocket_stream.js +16 -19
- package/dist/core/websocket_stream.js.map +1 -1
- package/dist/core/wire.d.ts.map +1 -1
- package/dist/helpers/pl.cjs +25 -0
- package/dist/helpers/pl.cjs.map +1 -1
- package/dist/helpers/pl.d.ts +1 -1
- package/dist/helpers/pl.d.ts.map +1 -1
- package/dist/helpers/pl.js +1 -1
- package/dist/helpers/pl.js.map +1 -1
- package/dist/helpers/poll.cjs +5 -1
- package/dist/helpers/poll.cjs.map +1 -1
- package/dist/helpers/poll.d.ts.map +1 -1
- package/dist/helpers/poll.js +4 -0
- package/dist/helpers/poll.js.map +1 -1
- package/dist/helpers/retry_strategy.cjs +1 -0
- package/dist/helpers/retry_strategy.cjs.map +1 -1
- package/dist/helpers/retry_strategy.js +1 -1
- package/dist/helpers/retry_strategy.js.map +1 -1
- package/dist/helpers/tx_helpers.cjs +0 -1
- package/dist/helpers/tx_helpers.cjs.map +1 -1
- package/dist/helpers/tx_helpers.d.ts.map +1 -1
- package/dist/helpers/tx_helpers.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +0 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +537 -83
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +11 -4
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +12 -6
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +11 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +112 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +336 -83
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +23 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +10 -3
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +18 -7
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +1 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +2 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +2 -2
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.cjs +1 -2
- package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.d.ts.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.js +1 -1
- package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.cjs +0 -1
- package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.cjs +0 -1
- package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto-grpc/google/rpc/code.d.ts.map +1 -1
- package/dist/proto-rest/index.cjs +1 -1
- package/dist/proto-rest/index.cjs.map +1 -1
- package/dist/proto-rest/index.d.ts +1 -1
- package/dist/proto-rest/index.d.ts.map +1 -1
- package/dist/proto-rest/index.js.map +1 -1
- package/dist/proto-rest/plapi.d.ts +30 -9
- package/dist/proto-rest/plapi.d.ts.map +1 -1
- package/dist/test/tcp-proxy.cjs +2 -2
- package/dist/test/tcp-proxy.cjs.map +1 -1
- package/dist/test/tcp-proxy.d.ts +1 -1
- package/dist/test/tcp-proxy.js.map +1 -1
- package/dist/test/test_config.cjs +8 -2
- package/dist/test/test_config.cjs.map +1 -1
- package/dist/test/test_config.d.ts +1 -1
- package/dist/test/test_config.d.ts.map +1 -1
- package/dist/test/test_config.js +1 -1
- package/dist/test/test_config.js.map +1 -1
- package/dist/util/pl.cjs.map +1 -1
- package/dist/util/pl.js.map +1 -1
- package/dist/util/util.cjs.map +1 -1
- package/dist/util/util.js.map +1 -1
- package/package.json +4 -4
- package/src/core/capabilities.ts +10 -3
- package/src/core/client.ts +30 -3
- package/src/core/errors.ts +2 -0
- package/src/core/final.ts +4 -0
- package/src/core/ll_client.test.ts +15 -2
- package/src/core/ll_client.ts +66 -11
- package/src/core/transaction.ts +103 -3
- package/src/core/unauth_client.ts +17 -2
- package/src/core/user_resources.ts +85 -0
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.ts +16 -3
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.ts +335 -12
- package/src/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.ts +21 -7
- package/src/proto-rest/plapi.ts +29 -8
- package/dist/proto-grpc/google/rpc/code.cjs +0 -224
- package/dist/proto-grpc/google/rpc/code.cjs.map +0 -1
- package/dist/proto-grpc/google/rpc/code.js +0 -224
- package/dist/proto-grpc/google/rpc/code.js.map +0 -1
package/dist/helpers/pl.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.cjs","names":["field"],"sources":["../../src/helpers/pl.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * This file is exported under Pl \"namespace\" to the client users.\n *\n * It defines well known pl types, and methods to manipulate them.\n *\n */\n\nimport type { FutureFieldType, ResourceType } from \"../core/types\";\nimport type { AnyRef, FieldRef, PlTransaction, ResourceRef } from \"../core/transaction\";\nimport { field } from \"../core/transaction\";\n\nfunction rt(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport const ClientRoot = rt(\"ClientRoot\", \"1\");\n\nexport const StructTestResource = rt(\"StructTest\", \"1\");\nexport const ValueTestResource = rt(\"ValueTest\", \"1\");\n\nexport const JsonString = rt(\"json/string\", \"1\");\nexport const JsonBool = rt(\"json/bool\", \"1\");\nexport const JsonObject = rt(\"json/object\", \"1\");\nexport const JsonGzObject = rt(\"json-gz/object\", \"1\");\nexport const JsonArray = rt(\"json/array\", \"1\");\nexport const JsonNumber = rt(\"json/number\", \"1\");\nexport const JsonNull = rt(\"json/null\", \"1\");\n\nexport const RNull = rt(\"Null\", \"1\");\n\nexport const EphStdMap: ResourceType = rt(\"EphStdMap\", \"1\");\nexport const StdMap: ResourceType = rt(\"StdMap\", \"1\");\n\n//\n// Standard value resources\n//\n\nexport function createPlNull(tx: PlTransaction): ResourceRef {\n return tx.createValue(JsonNull, Buffer.from(JSON.stringify(null)));\n}\n\nexport function createPlBool(tx: PlTransaction, val: boolean): ResourceRef {\n return tx.createValue(JsonBool, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlNumber(tx: PlTransaction, val: number): ResourceRef {\n return tx.createValue(JsonNumber, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlString(tx: PlTransaction, val: string): ResourceRef {\n return tx.createValue(JsonString, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlArray(tx: PlTransaction, val: any[]): ResourceRef {\n return tx.createValue(JsonArray, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlObject(tx: PlTransaction, val: object): ResourceRef {\n return tx.createValue(JsonObject, Buffer.from(JSON.stringify(val)));\n}\n\n//\n// Pl Map\n//\n\nexport type PlRecordEntry<Key extends string = string, Ref extends AnyRef = AnyRef> = [Key, Ref];\n\nexport type PlRecord<Key extends string = string, Ref extends AnyRef = AnyRef> = Record<Key, Ref>;\n\nexport function plEntry<Key extends string = string, Ref extends AnyRef = AnyRef>(\n key: Key,\n ref: Ref,\n): PlRecordEntry<Key, Ref> {\n return [key, ref];\n}\n\nexport function plEntries<Key extends string = string, Ref extends AnyRef = AnyRef>(\n record: PlRecord<Key, Ref>,\n fields?: Key[],\n): PlRecordEntry<Key, Ref>[] {\n return fields === undefined\n ? (Object.entries(record) as PlRecordEntry<Key, Ref>[])\n : fields.map((key) => plEntry(key, record[key]));\n}\n\n/** Helper method to build standard pl map from a set of entries */\nexport function createPlMap(\n tx: PlTransaction,\n entries: PlRecordEntry[] | PlRecord,\n ephemeral: boolean,\n type?: ResourceType,\n): ResourceRef {\n const actualType = type ?? (ephemeral ? EphStdMap : StdMap);\n const rId = ephemeral ? tx.createEphemeral(actualType) : tx.createStruct(actualType);\n\n for (const [name, value] of Array.isArray(entries) ? entries : plEntries(entries))\n tx.createField(field(rId, name), \"Input\", value);\n\n tx.lock(rId);\n\n return rId;\n}\n\nexport function futureRecord<Key extends string>(\n tx: PlTransaction,\n rId: AnyRef,\n keys: Key[],\n fieldType: FutureFieldType,\n prefix: string = \"\",\n): PlRecord<Key, FieldRef> {\n return Object.fromEntries(\n keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType))),\n ) as PlRecord<Key, FieldRef>;\n}\n\n//\n// Holder\n//\n\n/** Name of the field in block holder, that references the actual block-pack. */\nexport const Holder = StdMap;\nexport const EphHolder = EphStdMap;\nexport const HolderRefField = \"ref\";\n\nexport function wrapInHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createStruct(Holder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function wrapInEphHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createEphemeral(EphHolder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function unwrapHolder(tx: PlTransaction, ref: AnyRef): FieldRef {\n return tx.getFutureFieldValue(ref, HolderRefField, \"Input\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,GAAG,MAAc,SAA+B;
|
|
1
|
+
{"version":3,"file":"pl.cjs","names":["field"],"sources":["../../src/helpers/pl.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * This file is exported under Pl \"namespace\" to the client users.\n *\n * It defines well known pl types, and methods to manipulate them.\n *\n */\n\nimport type { FutureFieldType, ResourceType } from \"../core/types\";\nimport type { AnyRef, FieldRef, PlTransaction, ResourceRef } from \"../core/transaction\";\nimport { field } from \"../core/transaction\";\n\nfunction rt(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport const ClientRoot = rt(\"ClientRoot\", \"1\");\n\nexport const StructTestResource = rt(\"StructTest\", \"1\");\nexport const ValueTestResource = rt(\"ValueTest\", \"1\");\n\nexport const JsonString = rt(\"json/string\", \"1\");\nexport const JsonBool = rt(\"json/bool\", \"1\");\nexport const JsonObject = rt(\"json/object\", \"1\");\nexport const JsonGzObject = rt(\"json-gz/object\", \"1\");\nexport const JsonArray = rt(\"json/array\", \"1\");\nexport const JsonNumber = rt(\"json/number\", \"1\");\nexport const JsonNull = rt(\"json/null\", \"1\");\n\nexport const RNull = rt(\"Null\", \"1\");\n\nexport const EphStdMap: ResourceType = rt(\"EphStdMap\", \"1\");\nexport const StdMap: ResourceType = rt(\"StdMap\", \"1\");\n\n//\n// Standard value resources\n//\n\nexport function createPlNull(tx: PlTransaction): ResourceRef {\n return tx.createValue(JsonNull, Buffer.from(JSON.stringify(null)));\n}\n\nexport function createPlBool(tx: PlTransaction, val: boolean): ResourceRef {\n return tx.createValue(JsonBool, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlNumber(tx: PlTransaction, val: number): ResourceRef {\n return tx.createValue(JsonNumber, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlString(tx: PlTransaction, val: string): ResourceRef {\n return tx.createValue(JsonString, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlArray(tx: PlTransaction, val: any[]): ResourceRef {\n return tx.createValue(JsonArray, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlObject(tx: PlTransaction, val: object): ResourceRef {\n return tx.createValue(JsonObject, Buffer.from(JSON.stringify(val)));\n}\n\n//\n// Pl Map\n//\n\nexport type PlRecordEntry<Key extends string = string, Ref extends AnyRef = AnyRef> = [Key, Ref];\n\nexport type PlRecord<Key extends string = string, Ref extends AnyRef = AnyRef> = Record<Key, Ref>;\n\nexport function plEntry<Key extends string = string, Ref extends AnyRef = AnyRef>(\n key: Key,\n ref: Ref,\n): PlRecordEntry<Key, Ref> {\n return [key, ref];\n}\n\nexport function plEntries<Key extends string = string, Ref extends AnyRef = AnyRef>(\n record: PlRecord<Key, Ref>,\n fields?: Key[],\n): PlRecordEntry<Key, Ref>[] {\n return fields === undefined\n ? (Object.entries(record) as PlRecordEntry<Key, Ref>[])\n : fields.map((key) => plEntry(key, record[key]));\n}\n\n/** Helper method to build standard pl map from a set of entries */\nexport function createPlMap(\n tx: PlTransaction,\n entries: PlRecordEntry[] | PlRecord,\n ephemeral: boolean,\n type?: ResourceType,\n): ResourceRef {\n const actualType = type ?? (ephemeral ? EphStdMap : StdMap);\n const rId = ephemeral ? tx.createEphemeral(actualType) : tx.createStruct(actualType);\n\n for (const [name, value] of Array.isArray(entries) ? entries : plEntries(entries))\n tx.createField(field(rId, name), \"Input\", value);\n\n tx.lock(rId);\n\n return rId;\n}\n\nexport function futureRecord<Key extends string>(\n tx: PlTransaction,\n rId: AnyRef,\n keys: Key[],\n fieldType: FutureFieldType,\n prefix: string = \"\",\n): PlRecord<Key, FieldRef> {\n return Object.fromEntries(\n keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType))),\n ) as PlRecord<Key, FieldRef>;\n}\n\n//\n// Holder\n//\n\n/** Name of the field in block holder, that references the actual block-pack. */\nexport const Holder = StdMap;\nexport const EphHolder = EphStdMap;\nexport const HolderRefField = \"ref\";\n\nexport function wrapInHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createStruct(Holder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function wrapInEphHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createEphemeral(EphHolder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function unwrapHolder(tx: PlTransaction, ref: AnyRef): FieldRef {\n return tx.getFutureFieldValue(ref, HolderRefField, \"Input\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,GAAG,MAAc,SAA+B;CACvD,OAAO;EAAE;EAAM;CAAQ;AACzB;AAEA,MAAa,aAAa,GAAG,cAAc,GAAG;AAE9C,MAAa,qBAAqB,GAAG,cAAc,GAAG;AACtD,MAAa,oBAAoB,GAAG,aAAa,GAAG;AAEpD,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,WAAW,GAAG,aAAa,GAAG;AAC3C,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,eAAe,GAAG,kBAAkB,GAAG;AACpD,MAAa,YAAY,GAAG,cAAc,GAAG;AAC7C,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,WAAW,GAAG,aAAa,GAAG;AAE3C,MAAa,QAAQ,GAAG,QAAQ,GAAG;AAEnC,MAAa,YAA0B,GAAG,aAAa,GAAG;AAC1D,MAAa,SAAuB,GAAG,UAAU,GAAG;AAMpD,SAAgB,aAAa,IAAgC;CAC3D,OAAO,GAAG,YAAY,UAAU,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,CAAC;AACnE;AAEA,SAAgB,aAAa,IAAmB,KAA2B;CACzE,OAAO,GAAG,YAAY,UAAU,OAAO,KAAK,KAAK,UAAU,GAAG,CAAC,CAAC;AAClE;AAEA,SAAgB,eAAe,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GAAG,aAAa,MAAM;CACrC,MAAM,kBAAkBA,oBAAAA,MAAM,QAAA,KAAsB;CACpD,GAAG,YAAY,iBAAiB,SAAS,GAAG;CAC5C,GAAG,KAAK,MAAM;CACd,OAAO;AACT;AAEA,SAAgB,gBAAgB,IAAmB,KAA0B;CAC3E,MAAM,SAAS,GAAG,gBAAgB,SAAS;CAC3C,MAAM,kBAAkBA,oBAAAA,MAAM,QAAA,KAAsB;CACpD,GAAG,YAAY,iBAAiB,SAAS,GAAG;CAC5C,GAAG,KAAK,MAAM;CACd,OAAO;AACT;AAEA,SAAgB,aAAa,IAAmB,KAAuB;CACrE,OAAO,GAAG,oBAAoB,KAAA,OAAqB,OAAO;AAC5D"}
|
package/dist/helpers/pl.d.ts
CHANGED
|
@@ -39,5 +39,5 @@ declare function wrapInHolder(tx: PlTransaction, ref: AnyRef): ResourceRef;
|
|
|
39
39
|
declare function wrapInEphHolder(tx: PlTransaction, ref: AnyRef): ResourceRef;
|
|
40
40
|
declare function unwrapHolder(tx: PlTransaction, ref: AnyRef): FieldRef;
|
|
41
41
|
//#endregion
|
|
42
|
-
export { pl_d_exports };
|
|
42
|
+
export { ClientRoot, EphHolder, EphStdMap, Holder, HolderRefField, JsonArray, JsonBool, JsonGzObject, JsonNull, JsonNumber, JsonObject, JsonString, PlRecord, PlRecordEntry, RNull, StdMap, StructTestResource, ValueTestResource, createPlArray, createPlBool, createPlMap, createPlNull, createPlNumber, createPlObject, createPlString, futureRecord, plEntries, plEntry, pl_d_exports, unwrapHolder, wrapInEphHolder, wrapInHolder };
|
|
43
43
|
//# sourceMappingURL=pl.d.ts.map
|
package/dist/helpers/pl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.d.ts","names":[],"sources":["../../src/helpers/pl.ts"],"mappings":";;;;;;;cAiBa,UAAA,EAAU,
|
|
1
|
+
{"version":3,"file":"pl.d.ts","names":[],"sources":["../../src/helpers/pl.ts"],"mappings":";;;;;;;cA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c,GAAA,EAAK,GAAA;;iBAON,WAAA,CACd,EAAA,EAAI,aAAA,EACJ,OAAA,EAAS,aAAA,KAAkB,QAAA,EAC3B,SAAA,WACA,IAAA,GAAO,YAAA,GACN,WAAA;AAAA,iBAYa,YAAA,qBACd,EAAA,EAAI,aAAA,EACJ,GAAA,EAAK,MAAA,EACL,IAAA,EAAM,GAAA,IACN,SAAA,EAAW,eAAA,EACX,MAAA,YACC,QAAA,CAAS,GAAA,EAAK,QAAA;;cAWJ,MAAA,EAAM,YAAS;AAAA,cACf,SAAA,EAAS,YAAY;AAAA,cACrB,cAAA;AAAA,iBAEG,YAAA,CAAa,EAAA,EAAI,aAAA,EAAe,GAAA,EAAK,MAAA,GAAS,WAAA;AAAA,iBAQ9C,eAAA,CAAgB,EAAA,EAAI,aAAA,EAAe,GAAA,EAAK,MAAA,GAAS,WAAA;AAAA,iBAQjD,YAAA,CAAa,EAAA,EAAI,aAAA,EAAe,GAAA,EAAK,MAAA,GAAS,QAAA"}
|
package/dist/helpers/pl.js
CHANGED
|
@@ -107,6 +107,6 @@ function unwrapHolder(tx, ref) {
|
|
|
107
107
|
return tx.getFutureFieldValue(ref, "ref", "Input");
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
|
-
export { ClientRoot, JsonGzObject, JsonObject, pl_exports };
|
|
110
|
+
export { ClientRoot, EphHolder, EphStdMap, Holder, JsonArray, JsonBool, JsonGzObject, JsonNull, JsonNumber, JsonObject, JsonString, RNull, StdMap, StructTestResource, ValueTestResource, createPlArray, createPlBool, createPlMap, createPlNull, createPlNumber, createPlObject, createPlString, futureRecord, plEntries, plEntry, pl_exports, unwrapHolder, wrapInEphHolder, wrapInHolder };
|
|
111
111
|
|
|
112
112
|
//# sourceMappingURL=pl.js.map
|
package/dist/helpers/pl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.js","names":[],"sources":["../../src/helpers/pl.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * This file is exported under Pl \"namespace\" to the client users.\n *\n * It defines well known pl types, and methods to manipulate them.\n *\n */\n\nimport type { FutureFieldType, ResourceType } from \"../core/types\";\nimport type { AnyRef, FieldRef, PlTransaction, ResourceRef } from \"../core/transaction\";\nimport { field } from \"../core/transaction\";\n\nfunction rt(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport const ClientRoot = rt(\"ClientRoot\", \"1\");\n\nexport const StructTestResource = rt(\"StructTest\", \"1\");\nexport const ValueTestResource = rt(\"ValueTest\", \"1\");\n\nexport const JsonString = rt(\"json/string\", \"1\");\nexport const JsonBool = rt(\"json/bool\", \"1\");\nexport const JsonObject = rt(\"json/object\", \"1\");\nexport const JsonGzObject = rt(\"json-gz/object\", \"1\");\nexport const JsonArray = rt(\"json/array\", \"1\");\nexport const JsonNumber = rt(\"json/number\", \"1\");\nexport const JsonNull = rt(\"json/null\", \"1\");\n\nexport const RNull = rt(\"Null\", \"1\");\n\nexport const EphStdMap: ResourceType = rt(\"EphStdMap\", \"1\");\nexport const StdMap: ResourceType = rt(\"StdMap\", \"1\");\n\n//\n// Standard value resources\n//\n\nexport function createPlNull(tx: PlTransaction): ResourceRef {\n return tx.createValue(JsonNull, Buffer.from(JSON.stringify(null)));\n}\n\nexport function createPlBool(tx: PlTransaction, val: boolean): ResourceRef {\n return tx.createValue(JsonBool, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlNumber(tx: PlTransaction, val: number): ResourceRef {\n return tx.createValue(JsonNumber, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlString(tx: PlTransaction, val: string): ResourceRef {\n return tx.createValue(JsonString, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlArray(tx: PlTransaction, val: any[]): ResourceRef {\n return tx.createValue(JsonArray, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlObject(tx: PlTransaction, val: object): ResourceRef {\n return tx.createValue(JsonObject, Buffer.from(JSON.stringify(val)));\n}\n\n//\n// Pl Map\n//\n\nexport type PlRecordEntry<Key extends string = string, Ref extends AnyRef = AnyRef> = [Key, Ref];\n\nexport type PlRecord<Key extends string = string, Ref extends AnyRef = AnyRef> = Record<Key, Ref>;\n\nexport function plEntry<Key extends string = string, Ref extends AnyRef = AnyRef>(\n key: Key,\n ref: Ref,\n): PlRecordEntry<Key, Ref> {\n return [key, ref];\n}\n\nexport function plEntries<Key extends string = string, Ref extends AnyRef = AnyRef>(\n record: PlRecord<Key, Ref>,\n fields?: Key[],\n): PlRecordEntry<Key, Ref>[] {\n return fields === undefined\n ? (Object.entries(record) as PlRecordEntry<Key, Ref>[])\n : fields.map((key) => plEntry(key, record[key]));\n}\n\n/** Helper method to build standard pl map from a set of entries */\nexport function createPlMap(\n tx: PlTransaction,\n entries: PlRecordEntry[] | PlRecord,\n ephemeral: boolean,\n type?: ResourceType,\n): ResourceRef {\n const actualType = type ?? (ephemeral ? EphStdMap : StdMap);\n const rId = ephemeral ? tx.createEphemeral(actualType) : tx.createStruct(actualType);\n\n for (const [name, value] of Array.isArray(entries) ? entries : plEntries(entries))\n tx.createField(field(rId, name), \"Input\", value);\n\n tx.lock(rId);\n\n return rId;\n}\n\nexport function futureRecord<Key extends string>(\n tx: PlTransaction,\n rId: AnyRef,\n keys: Key[],\n fieldType: FutureFieldType,\n prefix: string = \"\",\n): PlRecord<Key, FieldRef> {\n return Object.fromEntries(\n keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType))),\n ) as PlRecord<Key, FieldRef>;\n}\n\n//\n// Holder\n//\n\n/** Name of the field in block holder, that references the actual block-pack. */\nexport const Holder = StdMap;\nexport const EphHolder = EphStdMap;\nexport const HolderRefField = \"ref\";\n\nexport function wrapInHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createStruct(Holder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function wrapInEphHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createEphemeral(EphHolder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function unwrapHolder(tx: PlTransaction, ref: AnyRef): FieldRef {\n return tx.getFutureFieldValue(ref, HolderRefField, \"Input\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,GAAG,MAAc,SAA+B;
|
|
1
|
+
{"version":3,"file":"pl.js","names":[],"sources":["../../src/helpers/pl.ts"],"sourcesContent":["/**\n * @packageDocumentation\n *\n * This file is exported under Pl \"namespace\" to the client users.\n *\n * It defines well known pl types, and methods to manipulate them.\n *\n */\n\nimport type { FutureFieldType, ResourceType } from \"../core/types\";\nimport type { AnyRef, FieldRef, PlTransaction, ResourceRef } from \"../core/transaction\";\nimport { field } from \"../core/transaction\";\n\nfunction rt(name: string, version: string): ResourceType {\n return { name, version };\n}\n\nexport const ClientRoot = rt(\"ClientRoot\", \"1\");\n\nexport const StructTestResource = rt(\"StructTest\", \"1\");\nexport const ValueTestResource = rt(\"ValueTest\", \"1\");\n\nexport const JsonString = rt(\"json/string\", \"1\");\nexport const JsonBool = rt(\"json/bool\", \"1\");\nexport const JsonObject = rt(\"json/object\", \"1\");\nexport const JsonGzObject = rt(\"json-gz/object\", \"1\");\nexport const JsonArray = rt(\"json/array\", \"1\");\nexport const JsonNumber = rt(\"json/number\", \"1\");\nexport const JsonNull = rt(\"json/null\", \"1\");\n\nexport const RNull = rt(\"Null\", \"1\");\n\nexport const EphStdMap: ResourceType = rt(\"EphStdMap\", \"1\");\nexport const StdMap: ResourceType = rt(\"StdMap\", \"1\");\n\n//\n// Standard value resources\n//\n\nexport function createPlNull(tx: PlTransaction): ResourceRef {\n return tx.createValue(JsonNull, Buffer.from(JSON.stringify(null)));\n}\n\nexport function createPlBool(tx: PlTransaction, val: boolean): ResourceRef {\n return tx.createValue(JsonBool, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlNumber(tx: PlTransaction, val: number): ResourceRef {\n return tx.createValue(JsonNumber, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlString(tx: PlTransaction, val: string): ResourceRef {\n return tx.createValue(JsonString, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlArray(tx: PlTransaction, val: any[]): ResourceRef {\n return tx.createValue(JsonArray, Buffer.from(JSON.stringify(val)));\n}\n\nexport function createPlObject(tx: PlTransaction, val: object): ResourceRef {\n return tx.createValue(JsonObject, Buffer.from(JSON.stringify(val)));\n}\n\n//\n// Pl Map\n//\n\nexport type PlRecordEntry<Key extends string = string, Ref extends AnyRef = AnyRef> = [Key, Ref];\n\nexport type PlRecord<Key extends string = string, Ref extends AnyRef = AnyRef> = Record<Key, Ref>;\n\nexport function plEntry<Key extends string = string, Ref extends AnyRef = AnyRef>(\n key: Key,\n ref: Ref,\n): PlRecordEntry<Key, Ref> {\n return [key, ref];\n}\n\nexport function plEntries<Key extends string = string, Ref extends AnyRef = AnyRef>(\n record: PlRecord<Key, Ref>,\n fields?: Key[],\n): PlRecordEntry<Key, Ref>[] {\n return fields === undefined\n ? (Object.entries(record) as PlRecordEntry<Key, Ref>[])\n : fields.map((key) => plEntry(key, record[key]));\n}\n\n/** Helper method to build standard pl map from a set of entries */\nexport function createPlMap(\n tx: PlTransaction,\n entries: PlRecordEntry[] | PlRecord,\n ephemeral: boolean,\n type?: ResourceType,\n): ResourceRef {\n const actualType = type ?? (ephemeral ? EphStdMap : StdMap);\n const rId = ephemeral ? tx.createEphemeral(actualType) : tx.createStruct(actualType);\n\n for (const [name, value] of Array.isArray(entries) ? entries : plEntries(entries))\n tx.createField(field(rId, name), \"Input\", value);\n\n tx.lock(rId);\n\n return rId;\n}\n\nexport function futureRecord<Key extends string>(\n tx: PlTransaction,\n rId: AnyRef,\n keys: Key[],\n fieldType: FutureFieldType,\n prefix: string = \"\",\n): PlRecord<Key, FieldRef> {\n return Object.fromEntries(\n keys.map((k) => plEntry(k, tx.getFutureFieldValue(rId, `${prefix}${k}`, fieldType))),\n ) as PlRecord<Key, FieldRef>;\n}\n\n//\n// Holder\n//\n\n/** Name of the field in block holder, that references the actual block-pack. */\nexport const Holder = StdMap;\nexport const EphHolder = EphStdMap;\nexport const HolderRefField = \"ref\";\n\nexport function wrapInHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createStruct(Holder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function wrapInEphHolder(tx: PlTransaction, ref: AnyRef): ResourceRef {\n const holder = tx.createEphemeral(EphHolder);\n const mainHolderField = field(holder, HolderRefField);\n tx.createField(mainHolderField, \"Input\", ref);\n tx.lock(holder);\n return holder;\n}\n\nexport function unwrapHolder(tx: PlTransaction, ref: AnyRef): FieldRef {\n return tx.getFutureFieldValue(ref, HolderRefField, \"Input\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAAS,GAAG,MAAc,SAA+B;CACvD,OAAO;EAAE;EAAM;CAAQ;AACzB;AAEA,MAAa,aAAa,GAAG,cAAc,GAAG;AAE9C,MAAa,qBAAqB,GAAG,cAAc,GAAG;AACtD,MAAa,oBAAoB,GAAG,aAAa,GAAG;AAEpD,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,WAAW,GAAG,aAAa,GAAG;AAC3C,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,eAAe,GAAG,kBAAkB,GAAG;AACpD,MAAa,YAAY,GAAG,cAAc,GAAG;AAC7C,MAAa,aAAa,GAAG,eAAe,GAAG;AAC/C,MAAa,WAAW,GAAG,aAAa,GAAG;AAE3C,MAAa,QAAQ,GAAG,QAAQ,GAAG;AAEnC,MAAa,YAA0B,GAAG,aAAa,GAAG;AAC1D,MAAa,SAAuB,GAAG,UAAU,GAAG;AAMpD,SAAgB,aAAa,IAAgC;C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AAO,YACZ,KAAK,KAAK,MAAM,QAAQ,GAAG,GAAG,oBAAoB,KAAK,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CACrF;AACF;;AAOA,MAAa,SAAS;AACtB,MAAa,YAAY;AAGzB,SAAgB,aAAa,IAAmB,KAA0B;CACxE,MAAM,SAAS,GAAG,aAAa,MAAM;CACrC,MAAM,kBAAkB,MAAM,QAAA,KAAsB;CACpD,GAAG,YAAY,iBAAiB,SAAS,GAAG;CAC5C,GAAG,KAAK,MAAM;CACd,OAAO;AACT;AAEA,SAAgB,gBAAgB,IAAmB,KAA0B;CAC3E,MAAM,SAAS,GAAG,gBAAgB,SAAS;CAC3C,MAAM,kBAAkB,MAAM,QAAA,KAAsB;CACpD,GAAG,YAAY,iBAAiB,SAAS,GAAG;CAC5C,GAAG,KAAK,MAAM;CACd,OAAO;AACT;AAEA,SAAgB,aAAa,IAAmB,KAAuB;CACrE,OAAO,GAAG,oBAAoB,KAAA,OAAqB,OAAO;AAC5D"}
|
package/dist/helpers/poll.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_types = require("../core/types.cjs");
|
|
3
3
|
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
4
4
|
let node_timers_promises = require("node:timers/promises");
|
|
5
|
-
node_timers_promises = require_runtime.__toESM(node_timers_promises);
|
|
5
|
+
node_timers_promises = require_runtime.__toESM(node_timers_promises, 1);
|
|
6
6
|
//#region src/helpers/poll.ts
|
|
7
7
|
/** This error tells state assertion mechanism that required state is not yet ready */
|
|
8
8
|
var ContinuePolling = class extends Error {
|
|
@@ -13,6 +13,9 @@ const DefaultPollFieldTraverseOps = {
|
|
|
13
13
|
onlyFinal: false
|
|
14
14
|
};
|
|
15
15
|
var PollResourceAccessor = class {
|
|
16
|
+
tx;
|
|
17
|
+
data;
|
|
18
|
+
path;
|
|
16
19
|
constructor(tx, data, path) {
|
|
17
20
|
this.tx = tx;
|
|
18
21
|
this.data = data;
|
|
@@ -66,6 +69,7 @@ var PollResourceAccessor = class {
|
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
var PollTxAccessor = class {
|
|
72
|
+
tx;
|
|
69
73
|
constructor(tx) {
|
|
70
74
|
this.tx = tx;
|
|
71
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.cjs","names":["isNullSignedResourceId","isNotNullSignedResourceId","resourceIdToString","tp"],"sources":["../../src/helpers/poll.ts"],"sourcesContent":["import type { PlClient } from \"../core/client\";\nimport type { RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { createRetryState, nextRetryStateOrError, notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { FieldData, FieldType, ResourceData, SignedResourceId } from \"../core/types\";\nimport {\n isNotNullSignedResourceId,\n isNullSignedResourceId,\n resourceIdToString,\n} from \"../core/types\";\nimport type { PlTransaction } from \"../core/transaction\";\nimport * as tp from \"node:timers/promises\";\n\n/** This error tells state assertion mechanism that required state is not yet ready */\nexport class ContinuePolling extends Error {\n name = \"ContinuePolling\";\n}\n\nexport type PollFieldTraverseOps = {\n expectedType?: FieldType;\n /** Fail if error present along with the value, if value not present,\n * but error do, exception will be thrown anyway. */\n failOnError: boolean;\n /** Traverse only if field report its value as final. */\n onlyFinal: boolean;\n};\n\nconst DefaultPollFieldTraverseOps: PollFieldTraverseOps = {\n failOnError: true,\n onlyFinal: false,\n};\n\nexport class PollResourceAccessor {\n constructor(\n public readonly tx: PollTxAccessor,\n public readonly data: ResourceData,\n public readonly path: string[],\n ) {}\n\n public final(): PollResourceAccessor {\n if (!this.data.final) throw new ContinuePolling();\n return this;\n }\n\n public async requireNoError(): Promise<PollResourceAccessor> {\n if (isNullSignedResourceId(this.data.error)) return this;\n await this.tx.throwError(this.data.error, this.path);\n // hmm... https://github.com/microsoft/TypeScript/issues/34955\n return this;\n }\n\n public getFieldData(name: string, expectedType?: FieldType): FieldData {\n const fieldData = this.data.fields.find((f) => f.name === name);\n\n if (fieldData !== undefined) {\n if (expectedType !== undefined && fieldData.type !== expectedType)\n throw new Error(`Unexpected field type. Expected ${expectedType}, found ${fieldData.type}`);\n return fieldData;\n }\n\n if (\n ((expectedType === \"Input\" || expectedType === \"Service\") && this.data.inputsLocked) ||\n (expectedType === \"Output\" && this.data.outputsLocked)\n )\n throw new Error(\n // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions\n `Field \"${name}\" not found. Expected type: ${expectedType}, state: ${this.data}`,\n );\n\n throw new ContinuePolling();\n }\n\n public async get(\n name: string,\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<PollResourceAccessor> {\n const { expectedType, failOnError } = { ...DefaultPollFieldTraverseOps, ...ops };\n const path = [...this.path, name];\n\n const fieldData = this.getFieldData(name, expectedType);\n if (\n isNotNullSignedResourceId(fieldData.error) &&\n (failOnError || isNullSignedResourceId(fieldData.value))\n )\n await this.tx.throwError(fieldData.error, path);\n\n if (isNullSignedResourceId(fieldData.value)) throw new ContinuePolling();\n\n return await this.tx.get(fieldData.value, failOnError, path);\n }\n\n public async getMulti(\n ops: Partial<PollFieldTraverseOps>,\n ...names: string[]\n ): Promise<PollResourceAccessor[]> {\n return await Promise.all(names.map((name) => this.get(name, ops)));\n }\n\n public async getMultiObj<Key extends string>(\n ops: Partial<PollFieldTraverseOps>,\n ...names: Key[]\n ): Promise<Record<Key, PollResourceAccessor>> {\n return Object.fromEntries(\n await Promise.all(names.map(async (name) => [name, await this.get(name, ops)])),\n );\n }\n\n public async getAllFinal(\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<Record<string, PollResourceAccessor>> {\n return await this.getMultiObj(\n ops,\n ...this.data.fields\n .filter((f) => f.valueIsFinal || isNotNullSignedResourceId(f.error))\n .map((f) => f.name),\n );\n }\n\n public async getKValue(key: string): Promise<string> {\n const value = await this.tx.tx.getKValueStringIfExists(this.data.id, key);\n if (value === undefined) throw new ContinuePolling();\n return value;\n }\n\n public async getKValueObj<T>(key: string): Promise<T> {\n return JSON.parse(await this.getKValue(key)) as T;\n }\n}\n\nexport class PollTxAccessor {\n constructor(public readonly tx: PlTransaction) {}\n\n public async get(\n rid: SignedResourceId,\n failOnError: boolean = true,\n path: string[] = [],\n ): Promise<PollResourceAccessor> {\n const data = await this.tx.getResourceData(rid, true);\n const accessor = new PollResourceAccessor(this, data, [...path, resourceIdToString(rid)]);\n if (failOnError) await accessor.requireNoError();\n return accessor;\n }\n\n async throwError(error: SignedResourceId, path: string[] = []): Promise<never> {\n const errorRes = await this.get(error);\n const errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();\n throw new Error(`${path.join(\" -> \")} = ${errorText}`);\n }\n}\n\nexport const DefaultPollingRetryOptions: RetryOptions = {\n type: \"linearBackoff\",\n jitter: 0,\n maxAttempts: 100,\n backoffStep: 10,\n initialDelay: 10,\n};\n\nexport async function poll<T>(\n cl: PlClient,\n cb: (tx: PollTxAccessor) => Promise<T>,\n retryOptions: RetryOptions = DefaultPollingRetryOptions,\n txName: string = \"polling\",\n): Promise<T> {\n let retryState = createRetryState(retryOptions);\n while (true) {\n try {\n return await cl.withReadTx(txName, async (tx) => {\n return await cb(new PollTxAccessor(tx));\n });\n } catch (e: any) {\n // Rethrowing any error except the \"not ready yet\"\n if (!(e instanceof ContinuePolling)) throw e;\n }\n await tp.setTimeout(retryState.nextDelay);\n retryState = nextRetryStateOrError(retryState);\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAO
|
|
1
|
+
{"version":3,"file":"poll.cjs","names":["isNullSignedResourceId","isNotNullSignedResourceId","resourceIdToString","tp"],"sources":["../../src/helpers/poll.ts"],"sourcesContent":["import type { PlClient } from \"../core/client\";\nimport type { RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { createRetryState, nextRetryStateOrError, notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { FieldData, FieldType, ResourceData, SignedResourceId } from \"../core/types\";\nimport {\n isNotNullSignedResourceId,\n isNullSignedResourceId,\n resourceIdToString,\n} from \"../core/types\";\nimport type { PlTransaction } from \"../core/transaction\";\nimport * as tp from \"node:timers/promises\";\n\n/** This error tells state assertion mechanism that required state is not yet ready */\nexport class ContinuePolling extends Error {\n name = \"ContinuePolling\";\n}\n\nexport type PollFieldTraverseOps = {\n expectedType?: FieldType;\n /** Fail if error present along with the value, if value not present,\n * but error do, exception will be thrown anyway. */\n failOnError: boolean;\n /** Traverse only if field report its value as final. */\n onlyFinal: boolean;\n};\n\nconst DefaultPollFieldTraverseOps: PollFieldTraverseOps = {\n failOnError: true,\n onlyFinal: false,\n};\n\nexport class PollResourceAccessor {\n constructor(\n public readonly tx: PollTxAccessor,\n public readonly data: ResourceData,\n public readonly path: string[],\n ) {}\n\n public final(): PollResourceAccessor {\n if (!this.data.final) throw new ContinuePolling();\n return this;\n }\n\n public async requireNoError(): Promise<PollResourceAccessor> {\n if (isNullSignedResourceId(this.data.error)) return this;\n await this.tx.throwError(this.data.error, this.path);\n // hmm... https://github.com/microsoft/TypeScript/issues/34955\n return this;\n }\n\n public getFieldData(name: string, expectedType?: FieldType): FieldData {\n const fieldData = this.data.fields.find((f) => f.name === name);\n\n if (fieldData !== undefined) {\n if (expectedType !== undefined && fieldData.type !== expectedType)\n throw new Error(`Unexpected field type. Expected ${expectedType}, found ${fieldData.type}`);\n return fieldData;\n }\n\n if (\n ((expectedType === \"Input\" || expectedType === \"Service\") && this.data.inputsLocked) ||\n (expectedType === \"Output\" && this.data.outputsLocked)\n )\n throw new Error(\n // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions\n `Field \"${name}\" not found. Expected type: ${expectedType}, state: ${this.data}`,\n );\n\n throw new ContinuePolling();\n }\n\n public async get(\n name: string,\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<PollResourceAccessor> {\n const { expectedType, failOnError } = { ...DefaultPollFieldTraverseOps, ...ops };\n const path = [...this.path, name];\n\n const fieldData = this.getFieldData(name, expectedType);\n if (\n isNotNullSignedResourceId(fieldData.error) &&\n (failOnError || isNullSignedResourceId(fieldData.value))\n )\n await this.tx.throwError(fieldData.error, path);\n\n if (isNullSignedResourceId(fieldData.value)) throw new ContinuePolling();\n\n return await this.tx.get(fieldData.value, failOnError, path);\n }\n\n public async getMulti(\n ops: Partial<PollFieldTraverseOps>,\n ...names: string[]\n ): Promise<PollResourceAccessor[]> {\n return await Promise.all(names.map((name) => this.get(name, ops)));\n }\n\n public async getMultiObj<Key extends string>(\n ops: Partial<PollFieldTraverseOps>,\n ...names: Key[]\n ): Promise<Record<Key, PollResourceAccessor>> {\n return Object.fromEntries(\n await Promise.all(names.map(async (name) => [name, await this.get(name, ops)])),\n );\n }\n\n public async getAllFinal(\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<Record<string, PollResourceAccessor>> {\n return await this.getMultiObj(\n ops,\n ...this.data.fields\n .filter((f) => f.valueIsFinal || isNotNullSignedResourceId(f.error))\n .map((f) => f.name),\n );\n }\n\n public async getKValue(key: string): Promise<string> {\n const value = await this.tx.tx.getKValueStringIfExists(this.data.id, key);\n if (value === undefined) throw new ContinuePolling();\n return value;\n }\n\n public async getKValueObj<T>(key: string): Promise<T> {\n return JSON.parse(await this.getKValue(key)) as T;\n }\n}\n\nexport class PollTxAccessor {\n constructor(public readonly tx: PlTransaction) {}\n\n public async get(\n rid: SignedResourceId,\n failOnError: boolean = true,\n path: string[] = [],\n ): Promise<PollResourceAccessor> {\n const data = await this.tx.getResourceData(rid, true);\n const accessor = new PollResourceAccessor(this, data, [...path, resourceIdToString(rid)]);\n if (failOnError) await accessor.requireNoError();\n return accessor;\n }\n\n async throwError(error: SignedResourceId, path: string[] = []): Promise<never> {\n const errorRes = await this.get(error);\n const errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();\n throw new Error(`${path.join(\" -> \")} = ${errorText}`);\n }\n}\n\nexport const DefaultPollingRetryOptions: RetryOptions = {\n type: \"linearBackoff\",\n jitter: 0,\n maxAttempts: 100,\n backoffStep: 10,\n initialDelay: 10,\n};\n\nexport async function poll<T>(\n cl: PlClient,\n cb: (tx: PollTxAccessor) => Promise<T>,\n retryOptions: RetryOptions = DefaultPollingRetryOptions,\n txName: string = \"polling\",\n): Promise<T> {\n let retryState = createRetryState(retryOptions);\n while (true) {\n try {\n return await cl.withReadTx(txName, async (tx) => {\n return await cb(new PollTxAccessor(tx));\n });\n } catch (e: any) {\n // Rethrowing any error except the \"not ready yet\"\n if (!(e instanceof ContinuePolling)) throw e;\n }\n await tp.setTimeout(retryState.nextDelay);\n retryState = nextRetryStateOrError(retryState);\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAO;AACT;AAWA,MAAM,8BAAoD;CACxD,aAAa;CACb,WAAW;AACb;AAEA,IAAa,uBAAb,MAAkC;CAEd;CACA;CACA;CAHlB,YACE,IACA,MACA,MACA;EAHgB,KAAA,KAAA;EACA,KAAA,OAAA;EACA,KAAA,OAAA;CACf;CAEH,QAAqC;EACnC,IAAI,CAAC,KAAK,KAAK,OAAO,MAAM,IAAI,gBAAgB;EAChD,OAAO;CACT;CAEA,MAAa,iBAAgD;EAC3D,IAAIA,cAAAA,uBAAuB,KAAK,KAAK,KAAK,GAAG,OAAO;EACpD,MAAM,KAAK,GAAG,WAAW,KAAK,KAAK,OAAO,KAAK,IAAI;EAEnD,OAAO;CACT;CAEA,aAAoB,MAAc,cAAqC;EACrE,MAAM,YAAY,KAAK,KAAK,OAAO,MAAM,MAAM,EAAE,SAAS,IAAI;EAE9D,IAAI,cAAc,KAAA,GAAW;GAC3B,IAAI,iBAAiB,KAAA,KAAa,UAAU,SAAS,cACnD,MAAM,IAAI,MAAM,mCAAmC,aAAa,UAAU,UAAU,MAAM;GAC5F,OAAO;EACT;EAEA,KACI,iBAAiB,WAAW,iBAAiB,cAAc,KAAK,KAAK,gBACtE,iBAAiB,YAAY,KAAK,KAA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{"version":3,"file":"poll.d.ts","names":[],"sources":["../../src/helpers/poll.ts"],"mappings":";;;;;;;cAaa,eAAA,SAAwB,
|
|
1
|
+
{"version":3,"file":"poll.d.ts","names":[],"sources":["../../src/helpers/poll.ts"],"mappings":";;;;;;;cAaa,eAAA,SAAwB,KAAK;EACxC,IAAI;AAAA;AAAA,KAGM,oBAAA;EACV,YAAA,GAAe,SAAS;EAJpB;AAGN;EAIE,WAAA;EAEA,SAAA;AAAA;AAAA,cAQW,oBAAA;EAAA,SAEO,EAAA,EAAI,cAAA;EAAA,SACJ,IAAA,EAAM,YAAA;EAAA,SACN,IAAA;cAFA,EAAA,EAAI,cAAA,EACJ,IAAA,EAAM,YAAA,EACN,IAAA;EAGX,KAAA,IAAS,oBAAA;EAKH,cAAA,IAAkB,OAAA,CAAQ,oBAAA;EAOhC,YAAA,CAAa,IAAA,UAAc,YAAA,GAAe,SAAA,GAAY,SAAA;EAqBhD,GAAA,CACX,IAAA,UACA,GAAA,GAAK,OAAA,CAAQ,oBAAA,IACZ,OAAA,CAAQ,oBAAA;EAgBE,QAAA,CACX,GAAA,EAAK,OAAA,CAAQ,oBAAA,MACV,KAAA,aACF,OAAA,CAAQ,oBAAA;EAIE,WAAA,qBACX,GAAA,EAAK,OAAA,CAAQ,oBAAA,MACV,KAAA,EAAO,GAAA,KACT,OAAA,CAAQ,MAAA,CAAO,GAAA,EAAK,oBAAA;EAMV,WAAA,CACX,GAAA,GAAK,OAAA,CAAQ,oBAAA,IACZ,OAAA,CAAQ,MAAA,SAAe,oBAAA;EASb,SAAA,CAAU,GAAA,WAAc,OAAA;EAMxB,YAAA,IAAgB,GAAA,WAAc,OAAA,CAAQ,CAAA;AAAA;AAAA,cAKxC,cAAA;EAAA,SACiB,EAAA,EAAI,aAAA;cAAJ,EAAA,EAAI,aAAA;EAEnB,GAAA,CACX,GAAA,EAAK,gBAAA,EACL,WAAA,YACA,IAAA,cACC,OAAA,CAAQ,oBAAA;EAOL,UAAA,CAAW,KAAA,EAAO,gBAAA,EAAkB,IAAA,cAAsB,OAAA;AAAA;AAAA,cAOrD,0BAAA,EAA4B,YAMxC;AAAA,iBAEqB,IAAA,IACpB,EAAA,EAAI,QAAA,EACJ,EAAA,GAAK,EAAA,EAAI,cAAA,KAAmB,OAAA,CAAQ,CAAA,GACpC,YAAA,GAAc,YAAA,EACd,MAAA,YACC,OAAA,CAAQ,CAAA"}
|
package/dist/helpers/poll.js
CHANGED
|
@@ -11,6 +11,9 @@ const DefaultPollFieldTraverseOps = {
|
|
|
11
11
|
onlyFinal: false
|
|
12
12
|
};
|
|
13
13
|
var PollResourceAccessor = class {
|
|
14
|
+
tx;
|
|
15
|
+
data;
|
|
16
|
+
path;
|
|
14
17
|
constructor(tx, data, path) {
|
|
15
18
|
this.tx = tx;
|
|
16
19
|
this.data = data;
|
|
@@ -64,6 +67,7 @@ var PollResourceAccessor = class {
|
|
|
64
67
|
}
|
|
65
68
|
};
|
|
66
69
|
var PollTxAccessor = class {
|
|
70
|
+
tx;
|
|
67
71
|
constructor(tx) {
|
|
68
72
|
this.tx = tx;
|
|
69
73
|
}
|
package/dist/helpers/poll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":[],"sources":["../../src/helpers/poll.ts"],"sourcesContent":["import type { PlClient } from \"../core/client\";\nimport type { RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { createRetryState, nextRetryStateOrError, notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { FieldData, FieldType, ResourceData, SignedResourceId } from \"../core/types\";\nimport {\n isNotNullSignedResourceId,\n isNullSignedResourceId,\n resourceIdToString,\n} from \"../core/types\";\nimport type { PlTransaction } from \"../core/transaction\";\nimport * as tp from \"node:timers/promises\";\n\n/** This error tells state assertion mechanism that required state is not yet ready */\nexport class ContinuePolling extends Error {\n name = \"ContinuePolling\";\n}\n\nexport type PollFieldTraverseOps = {\n expectedType?: FieldType;\n /** Fail if error present along with the value, if value not present,\n * but error do, exception will be thrown anyway. */\n failOnError: boolean;\n /** Traverse only if field report its value as final. */\n onlyFinal: boolean;\n};\n\nconst DefaultPollFieldTraverseOps: PollFieldTraverseOps = {\n failOnError: true,\n onlyFinal: false,\n};\n\nexport class PollResourceAccessor {\n constructor(\n public readonly tx: PollTxAccessor,\n public readonly data: ResourceData,\n public readonly path: string[],\n ) {}\n\n public final(): PollResourceAccessor {\n if (!this.data.final) throw new ContinuePolling();\n return this;\n }\n\n public async requireNoError(): Promise<PollResourceAccessor> {\n if (isNullSignedResourceId(this.data.error)) return this;\n await this.tx.throwError(this.data.error, this.path);\n // hmm... https://github.com/microsoft/TypeScript/issues/34955\n return this;\n }\n\n public getFieldData(name: string, expectedType?: FieldType): FieldData {\n const fieldData = this.data.fields.find((f) => f.name === name);\n\n if (fieldData !== undefined) {\n if (expectedType !== undefined && fieldData.type !== expectedType)\n throw new Error(`Unexpected field type. Expected ${expectedType}, found ${fieldData.type}`);\n return fieldData;\n }\n\n if (\n ((expectedType === \"Input\" || expectedType === \"Service\") && this.data.inputsLocked) ||\n (expectedType === \"Output\" && this.data.outputsLocked)\n )\n throw new Error(\n // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions\n `Field \"${name}\" not found. Expected type: ${expectedType}, state: ${this.data}`,\n );\n\n throw new ContinuePolling();\n }\n\n public async get(\n name: string,\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<PollResourceAccessor> {\n const { expectedType, failOnError } = { ...DefaultPollFieldTraverseOps, ...ops };\n const path = [...this.path, name];\n\n const fieldData = this.getFieldData(name, expectedType);\n if (\n isNotNullSignedResourceId(fieldData.error) &&\n (failOnError || isNullSignedResourceId(fieldData.value))\n )\n await this.tx.throwError(fieldData.error, path);\n\n if (isNullSignedResourceId(fieldData.value)) throw new ContinuePolling();\n\n return await this.tx.get(fieldData.value, failOnError, path);\n }\n\n public async getMulti(\n ops: Partial<PollFieldTraverseOps>,\n ...names: string[]\n ): Promise<PollResourceAccessor[]> {\n return await Promise.all(names.map((name) => this.get(name, ops)));\n }\n\n public async getMultiObj<Key extends string>(\n ops: Partial<PollFieldTraverseOps>,\n ...names: Key[]\n ): Promise<Record<Key, PollResourceAccessor>> {\n return Object.fromEntries(\n await Promise.all(names.map(async (name) => [name, await this.get(name, ops)])),\n );\n }\n\n public async getAllFinal(\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<Record<string, PollResourceAccessor>> {\n return await this.getMultiObj(\n ops,\n ...this.data.fields\n .filter((f) => f.valueIsFinal || isNotNullSignedResourceId(f.error))\n .map((f) => f.name),\n );\n }\n\n public async getKValue(key: string): Promise<string> {\n const value = await this.tx.tx.getKValueStringIfExists(this.data.id, key);\n if (value === undefined) throw new ContinuePolling();\n return value;\n }\n\n public async getKValueObj<T>(key: string): Promise<T> {\n return JSON.parse(await this.getKValue(key)) as T;\n }\n}\n\nexport class PollTxAccessor {\n constructor(public readonly tx: PlTransaction) {}\n\n public async get(\n rid: SignedResourceId,\n failOnError: boolean = true,\n path: string[] = [],\n ): Promise<PollResourceAccessor> {\n const data = await this.tx.getResourceData(rid, true);\n const accessor = new PollResourceAccessor(this, data, [...path, resourceIdToString(rid)]);\n if (failOnError) await accessor.requireNoError();\n return accessor;\n }\n\n async throwError(error: SignedResourceId, path: string[] = []): Promise<never> {\n const errorRes = await this.get(error);\n const errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();\n throw new Error(`${path.join(\" -> \")} = ${errorText}`);\n }\n}\n\nexport const DefaultPollingRetryOptions: RetryOptions = {\n type: \"linearBackoff\",\n jitter: 0,\n maxAttempts: 100,\n backoffStep: 10,\n initialDelay: 10,\n};\n\nexport async function poll<T>(\n cl: PlClient,\n cb: (tx: PollTxAccessor) => Promise<T>,\n retryOptions: RetryOptions = DefaultPollingRetryOptions,\n txName: string = \"polling\",\n): Promise<T> {\n let retryState = createRetryState(retryOptions);\n while (true) {\n try {\n return await cl.withReadTx(txName, async (tx) => {\n return await cb(new PollTxAccessor(tx));\n });\n } catch (e: any) {\n // Rethrowing any error except the \"not ready yet\"\n if (!(e instanceof ContinuePolling)) throw e;\n }\n await tp.setTimeout(retryState.nextDelay);\n retryState = nextRetryStateOrError(retryState);\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAO
|
|
1
|
+
{"version":3,"file":"poll.js","names":[],"sources":["../../src/helpers/poll.ts"],"sourcesContent":["import type { PlClient } from \"../core/client\";\nimport type { RetryOptions } from \"@milaboratories/ts-helpers\";\nimport { createRetryState, nextRetryStateOrError, notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { FieldData, FieldType, ResourceData, SignedResourceId } from \"../core/types\";\nimport {\n isNotNullSignedResourceId,\n isNullSignedResourceId,\n resourceIdToString,\n} from \"../core/types\";\nimport type { PlTransaction } from \"../core/transaction\";\nimport * as tp from \"node:timers/promises\";\n\n/** This error tells state assertion mechanism that required state is not yet ready */\nexport class ContinuePolling extends Error {\n name = \"ContinuePolling\";\n}\n\nexport type PollFieldTraverseOps = {\n expectedType?: FieldType;\n /** Fail if error present along with the value, if value not present,\n * but error do, exception will be thrown anyway. */\n failOnError: boolean;\n /** Traverse only if field report its value as final. */\n onlyFinal: boolean;\n};\n\nconst DefaultPollFieldTraverseOps: PollFieldTraverseOps = {\n failOnError: true,\n onlyFinal: false,\n};\n\nexport class PollResourceAccessor {\n constructor(\n public readonly tx: PollTxAccessor,\n public readonly data: ResourceData,\n public readonly path: string[],\n ) {}\n\n public final(): PollResourceAccessor {\n if (!this.data.final) throw new ContinuePolling();\n return this;\n }\n\n public async requireNoError(): Promise<PollResourceAccessor> {\n if (isNullSignedResourceId(this.data.error)) return this;\n await this.tx.throwError(this.data.error, this.path);\n // hmm... https://github.com/microsoft/TypeScript/issues/34955\n return this;\n }\n\n public getFieldData(name: string, expectedType?: FieldType): FieldData {\n const fieldData = this.data.fields.find((f) => f.name === name);\n\n if (fieldData !== undefined) {\n if (expectedType !== undefined && fieldData.type !== expectedType)\n throw new Error(`Unexpected field type. Expected ${expectedType}, found ${fieldData.type}`);\n return fieldData;\n }\n\n if (\n ((expectedType === \"Input\" || expectedType === \"Service\") && this.data.inputsLocked) ||\n (expectedType === \"Output\" && this.data.outputsLocked)\n )\n throw new Error(\n // eslint-disable-next-line @typescript-eslint/no-base-to-string, @typescript-eslint/restrict-template-expressions\n `Field \"${name}\" not found. Expected type: ${expectedType}, state: ${this.data}`,\n );\n\n throw new ContinuePolling();\n }\n\n public async get(\n name: string,\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<PollResourceAccessor> {\n const { expectedType, failOnError } = { ...DefaultPollFieldTraverseOps, ...ops };\n const path = [...this.path, name];\n\n const fieldData = this.getFieldData(name, expectedType);\n if (\n isNotNullSignedResourceId(fieldData.error) &&\n (failOnError || isNullSignedResourceId(fieldData.value))\n )\n await this.tx.throwError(fieldData.error, path);\n\n if (isNullSignedResourceId(fieldData.value)) throw new ContinuePolling();\n\n return await this.tx.get(fieldData.value, failOnError, path);\n }\n\n public async getMulti(\n ops: Partial<PollFieldTraverseOps>,\n ...names: string[]\n ): Promise<PollResourceAccessor[]> {\n return await Promise.all(names.map((name) => this.get(name, ops)));\n }\n\n public async getMultiObj<Key extends string>(\n ops: Partial<PollFieldTraverseOps>,\n ...names: Key[]\n ): Promise<Record<Key, PollResourceAccessor>> {\n return Object.fromEntries(\n await Promise.all(names.map(async (name) => [name, await this.get(name, ops)])),\n );\n }\n\n public async getAllFinal(\n ops: Partial<PollFieldTraverseOps> = {},\n ): Promise<Record<string, PollResourceAccessor>> {\n return await this.getMultiObj(\n ops,\n ...this.data.fields\n .filter((f) => f.valueIsFinal || isNotNullSignedResourceId(f.error))\n .map((f) => f.name),\n );\n }\n\n public async getKValue(key: string): Promise<string> {\n const value = await this.tx.tx.getKValueStringIfExists(this.data.id, key);\n if (value === undefined) throw new ContinuePolling();\n return value;\n }\n\n public async getKValueObj<T>(key: string): Promise<T> {\n return JSON.parse(await this.getKValue(key)) as T;\n }\n}\n\nexport class PollTxAccessor {\n constructor(public readonly tx: PlTransaction) {}\n\n public async get(\n rid: SignedResourceId,\n failOnError: boolean = true,\n path: string[] = [],\n ): Promise<PollResourceAccessor> {\n const data = await this.tx.getResourceData(rid, true);\n const accessor = new PollResourceAccessor(this, data, [...path, resourceIdToString(rid)]);\n if (failOnError) await accessor.requireNoError();\n return accessor;\n }\n\n async throwError(error: SignedResourceId, path: string[] = []): Promise<never> {\n const errorRes = await this.get(error);\n const errorText = Buffer.from(notEmpty(errorRes.data.data)).toString();\n throw new Error(`${path.join(\" -> \")} = ${errorText}`);\n }\n}\n\nexport const DefaultPollingRetryOptions: RetryOptions = {\n type: \"linearBackoff\",\n jitter: 0,\n maxAttempts: 100,\n backoffStep: 10,\n initialDelay: 10,\n};\n\nexport async function poll<T>(\n cl: PlClient,\n cb: (tx: PollTxAccessor) => Promise<T>,\n retryOptions: RetryOptions = DefaultPollingRetryOptions,\n txName: string = \"polling\",\n): Promise<T> {\n let retryState = createRetryState(retryOptions);\n while (true) {\n try {\n return await cl.withReadTx(txName, async (tx) => {\n return await cb(new PollTxAccessor(tx));\n });\n } catch (e: any) {\n // Rethrowing any error except the \"not ready yet\"\n if (!(e instanceof ContinuePolling)) throw e;\n }\n await tp.setTimeout(retryState.nextDelay);\n retryState = nextRetryStateOrError(retryState);\n }\n}\n"],"mappings":";;;;;AAaA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAO;AACT;AAWA,MAAM,8BAAoD;CACxD,aAAa;CACb,WAAW;AACb;AAEA,IAAa,uBAAb,MAAkC;CAEd;CACA;CACA;CAHlB,YACE,IACA,MACA,MACA;EAHgB,KAAA,KAAA;EACA,KAAA,OAAA;EACA,KAAA,OAAA;CACf;CAEH,QAAqC;EACnC,IAAI,CAAC,KAAK,KAAK,OAAO,MAAM,IAAI,gBAAgB;EAChD,OAAO;CACT;CAEA,MAAa,iBAAgD;EAC3D,IAAI,uBAAuB,KAAK,KAAK,KAAK,GAAG,OAAO;EAC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,MAAM;EACX,IAAI;GACF,OAAO,MAAM,GAAG,WAAW,QAAQ,OAAO,OAAO;IAC/C,OAAO,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;GACxC,CAAC;EACH,SAAS,GAAQ;GAEf,IAAI,EAAE,aAAa,kBAAkB,MAAM;EAC7C;EACA,MAAM,GAAG,WAAW,WAAW,SAAS;EACxC,aAAa,sBAAsB,UAAU;CAC/C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry_strategy.cjs","names":[],"sources":["../../src/helpers/retry_strategy.ts"],"sourcesContent":["export interface RetryConfig {\n maxAttempts: number;\n initialDelay: number;\n maxDelay: number;\n}\n\nexport const DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxAttempts: 10,\n initialDelay: 100,\n maxDelay: 30000,\n};\n\nexport interface RetryCallbacks {\n onRetry: () => void;\n onMaxAttemptsReached: (error: Error) => void;\n}\n\nexport class RetryStrategy {\n private attempts = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n private readonly config: RetryConfig;\n private readonly callbacks: RetryCallbacks;\n private readonly backoff: ExponentialBackoff;\n\n constructor(config: Partial<RetryConfig>, callbacks: RetryCallbacks) {\n this.config = { ...DEFAULT_RETRY_CONFIG, ...config };\n this.callbacks = callbacks;\n this.backoff = new ExponentialBackoff({\n initialDelay: this.config.initialDelay,\n maxDelay: this.config.maxDelay,\n factor: 2,\n jitter: 0.1,\n });\n }\n\n schedule(): void {\n if (this.timer) return;\n if (this.hasExceededLimit()) {\n this.notifyMaxAttemptsReached();\n return;\n }\n\n this.timer = setTimeout(() => {\n this.timer = null;\n this.attempts++;\n this.callbacks.onRetry();\n }, this.backoff.delay());\n }\n\n cancel(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n reset(): void {\n this.attempts = 0;\n this.backoff.reset();\n }\n\n private hasExceededLimit(): boolean {\n return this.attempts >= this.config.maxAttempts;\n }\n\n private notifyMaxAttemptsReached(): void {\n const error = new Error(`Max retry attempts (${this.config.maxAttempts}) reached`);\n this.callbacks.onMaxAttemptsReached(error);\n }\n}\n\ninterface ExponentialBackoffConfig {\n initialDelay: number;\n maxDelay: number;\n factor: number;\n jitter: number;\n}\n\nclass ExponentialBackoff {\n private readonly initialDelay: number;\n private readonly maxDelay: number;\n\n private currentDelay: number;\n\n private readonly factor: number;\n private readonly jitter: number;\n\n constructor(config: ExponentialBackoffConfig) {\n this.initialDelay = config.initialDelay;\n this.maxDelay = config.maxDelay;\n this.factor = config.factor;\n this.jitter = config.jitter;\n this.currentDelay = config.initialDelay;\n }\n\n delay(): number {\n if (this.currentDelay >= this.maxDelay) {\n return this.applyJitter(this.maxDelay);\n }\n\n this.currentDelay = this.currentDelay * this.factor;\n\n if (this.currentDelay > this.maxDelay) {\n this.currentDelay = this.maxDelay;\n }\n\n return this.applyJitter(this.currentDelay);\n }\n\n reset(): void {\n this.currentDelay = this.initialDelay;\n }\n\n private applyJitter(delay: number): number {\n if (delay === 0 || this.jitter === 0) {\n return delay;\n }\n const delayFactor = 1 - this.jitter / 2 + Math.random() * this.jitter;\n return delay * delayFactor;\n }\n}\n"],"mappings":";AAMA,MAAa,uBAAoC;CAC/C,aAAa;CACb,cAAc;CACd,UAAU;
|
|
1
|
+
{"version":3,"file":"retry_strategy.cjs","names":[],"sources":["../../src/helpers/retry_strategy.ts"],"sourcesContent":["export interface RetryConfig {\n maxAttempts: number;\n initialDelay: number;\n maxDelay: number;\n}\n\nexport const DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxAttempts: 10,\n initialDelay: 100,\n maxDelay: 30000,\n};\n\nexport interface RetryCallbacks {\n onRetry: () => void;\n onMaxAttemptsReached: (error: Error) => void;\n}\n\nexport class RetryStrategy {\n private attempts = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n private readonly config: RetryConfig;\n private readonly callbacks: RetryCallbacks;\n private readonly backoff: ExponentialBackoff;\n\n constructor(config: Partial<RetryConfig>, callbacks: RetryCallbacks) {\n this.config = { ...DEFAULT_RETRY_CONFIG, ...config };\n this.callbacks = callbacks;\n this.backoff = new ExponentialBackoff({\n initialDelay: this.config.initialDelay,\n maxDelay: this.config.maxDelay,\n factor: 2,\n jitter: 0.1,\n });\n }\n\n schedule(): void {\n if (this.timer) return;\n if (this.hasExceededLimit()) {\n this.notifyMaxAttemptsReached();\n return;\n }\n\n this.timer = setTimeout(() => {\n this.timer = null;\n this.attempts++;\n this.callbacks.onRetry();\n }, this.backoff.delay());\n }\n\n cancel(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n reset(): void {\n this.attempts = 0;\n this.backoff.reset();\n }\n\n private hasExceededLimit(): boolean {\n return this.attempts >= this.config.maxAttempts;\n }\n\n private notifyMaxAttemptsReached(): void {\n const error = new Error(`Max retry attempts (${this.config.maxAttempts}) reached`);\n this.callbacks.onMaxAttemptsReached(error);\n }\n}\n\ninterface ExponentialBackoffConfig {\n initialDelay: number;\n maxDelay: number;\n factor: number;\n jitter: number;\n}\n\nclass ExponentialBackoff {\n private readonly initialDelay: number;\n private readonly maxDelay: number;\n\n private currentDelay: number;\n\n private readonly factor: number;\n private readonly jitter: number;\n\n constructor(config: ExponentialBackoffConfig) {\n this.initialDelay = config.initialDelay;\n this.maxDelay = config.maxDelay;\n this.factor = config.factor;\n this.jitter = config.jitter;\n this.currentDelay = config.initialDelay;\n }\n\n delay(): number {\n if (this.currentDelay >= this.maxDelay) {\n return this.applyJitter(this.maxDelay);\n }\n\n this.currentDelay = this.currentDelay * this.factor;\n\n if (this.currentDelay > this.maxDelay) {\n this.currentDelay = this.maxDelay;\n }\n\n return this.applyJitter(this.currentDelay);\n }\n\n reset(): void {\n this.currentDelay = this.initialDelay;\n }\n\n private applyJitter(delay: number): number {\n if (delay === 0 || this.jitter === 0) {\n return delay;\n }\n const delayFactor = 1 - this.jitter / 2 + Math.random() * this.jitter;\n return delay * delayFactor;\n }\n}\n"],"mappings":";AAMA,MAAa,uBAAo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,KAAK,UAC3B,KAAK,eAAe,KAAK;EAG3B,OAAO,KAAK,YAAY,KAAK,YAAY;CAC3C;CAEA,QAAc;EACZ,KAAK,eAAe,KAAK;CAC3B;CAEA,YAAoB,OAAuB;EACzC,IAAI,UAAU,KAAK,KAAK,WAAW,GACjC,OAAO;EAGT,OAAO,SADa,IAAI,KAAK,SAAS,IAAI,KAAK,OAAO,IAAI,KAAK;CAEjE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry_strategy.js","names":[],"sources":["../../src/helpers/retry_strategy.ts"],"sourcesContent":["export interface RetryConfig {\n maxAttempts: number;\n initialDelay: number;\n maxDelay: number;\n}\n\nexport const DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxAttempts: 10,\n initialDelay: 100,\n maxDelay: 30000,\n};\n\nexport interface RetryCallbacks {\n onRetry: () => void;\n onMaxAttemptsReached: (error: Error) => void;\n}\n\nexport class RetryStrategy {\n private attempts = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n private readonly config: RetryConfig;\n private readonly callbacks: RetryCallbacks;\n private readonly backoff: ExponentialBackoff;\n\n constructor(config: Partial<RetryConfig>, callbacks: RetryCallbacks) {\n this.config = { ...DEFAULT_RETRY_CONFIG, ...config };\n this.callbacks = callbacks;\n this.backoff = new ExponentialBackoff({\n initialDelay: this.config.initialDelay,\n maxDelay: this.config.maxDelay,\n factor: 2,\n jitter: 0.1,\n });\n }\n\n schedule(): void {\n if (this.timer) return;\n if (this.hasExceededLimit()) {\n this.notifyMaxAttemptsReached();\n return;\n }\n\n this.timer = setTimeout(() => {\n this.timer = null;\n this.attempts++;\n this.callbacks.onRetry();\n }, this.backoff.delay());\n }\n\n cancel(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n reset(): void {\n this.attempts = 0;\n this.backoff.reset();\n }\n\n private hasExceededLimit(): boolean {\n return this.attempts >= this.config.maxAttempts;\n }\n\n private notifyMaxAttemptsReached(): void {\n const error = new Error(`Max retry attempts (${this.config.maxAttempts}) reached`);\n this.callbacks.onMaxAttemptsReached(error);\n }\n}\n\ninterface ExponentialBackoffConfig {\n initialDelay: number;\n maxDelay: number;\n factor: number;\n jitter: number;\n}\n\nclass ExponentialBackoff {\n private readonly initialDelay: number;\n private readonly maxDelay: number;\n\n private currentDelay: number;\n\n private readonly factor: number;\n private readonly jitter: number;\n\n constructor(config: ExponentialBackoffConfig) {\n this.initialDelay = config.initialDelay;\n this.maxDelay = config.maxDelay;\n this.factor = config.factor;\n this.jitter = config.jitter;\n this.currentDelay = config.initialDelay;\n }\n\n delay(): number {\n if (this.currentDelay >= this.maxDelay) {\n return this.applyJitter(this.maxDelay);\n }\n\n this.currentDelay = this.currentDelay * this.factor;\n\n if (this.currentDelay > this.maxDelay) {\n this.currentDelay = this.maxDelay;\n }\n\n return this.applyJitter(this.currentDelay);\n }\n\n reset(): void {\n this.currentDelay = this.initialDelay;\n }\n\n private applyJitter(delay: number): number {\n if (delay === 0 || this.jitter === 0) {\n return delay;\n }\n const delayFactor = 1 - this.jitter / 2 + Math.random() * this.jitter;\n return delay * delayFactor;\n }\n}\n"],"mappings":";AAMA,MAAa,uBAAoC;CAC/C,aAAa;CACb,cAAc;CACd,UAAU;
|
|
1
|
+
{"version":3,"file":"retry_strategy.js","names":[],"sources":["../../src/helpers/retry_strategy.ts"],"sourcesContent":["export interface RetryConfig {\n maxAttempts: number;\n initialDelay: number;\n maxDelay: number;\n}\n\nexport const DEFAULT_RETRY_CONFIG: RetryConfig = {\n maxAttempts: 10,\n initialDelay: 100,\n maxDelay: 30000,\n};\n\nexport interface RetryCallbacks {\n onRetry: () => void;\n onMaxAttemptsReached: (error: Error) => void;\n}\n\nexport class RetryStrategy {\n private attempts = 0;\n private timer: ReturnType<typeof setTimeout> | null = null;\n private readonly config: RetryConfig;\n private readonly callbacks: RetryCallbacks;\n private readonly backoff: ExponentialBackoff;\n\n constructor(config: Partial<RetryConfig>, callbacks: RetryCallbacks) {\n this.config = { ...DEFAULT_RETRY_CONFIG, ...config };\n this.callbacks = callbacks;\n this.backoff = new ExponentialBackoff({\n initialDelay: this.config.initialDelay,\n maxDelay: this.config.maxDelay,\n factor: 2,\n jitter: 0.1,\n });\n }\n\n schedule(): void {\n if (this.timer) return;\n if (this.hasExceededLimit()) {\n this.notifyMaxAttemptsReached();\n return;\n }\n\n this.timer = setTimeout(() => {\n this.timer = null;\n this.attempts++;\n this.callbacks.onRetry();\n }, this.backoff.delay());\n }\n\n cancel(): void {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n reset(): void {\n this.attempts = 0;\n this.backoff.reset();\n }\n\n private hasExceededLimit(): boolean {\n return this.attempts >= this.config.maxAttempts;\n }\n\n private notifyMaxAttemptsReached(): void {\n const error = new Error(`Max retry attempts (${this.config.maxAttempts}) reached`);\n this.callbacks.onMaxAttemptsReached(error);\n }\n}\n\ninterface ExponentialBackoffConfig {\n initialDelay: number;\n maxDelay: number;\n factor: number;\n jitter: number;\n}\n\nclass ExponentialBackoff {\n private readonly initialDelay: number;\n private readonly maxDelay: number;\n\n private currentDelay: number;\n\n private readonly factor: number;\n private readonly jitter: number;\n\n constructor(config: ExponentialBackoffConfig) {\n this.initialDelay = config.initialDelay;\n this.maxDelay = config.maxDelay;\n this.factor = config.factor;\n this.jitter = config.jitter;\n this.currentDelay = config.initialDelay;\n }\n\n delay(): number {\n if (this.currentDelay >= this.maxDelay) {\n return this.applyJitter(this.maxDelay);\n }\n\n this.currentDelay = this.currentDelay * this.factor;\n\n if (this.currentDelay > this.maxDelay) {\n this.currentDelay = this.maxDelay;\n }\n\n return this.applyJitter(this.currentDelay);\n }\n\n reset(): void {\n this.currentDelay = this.initialDelay;\n }\n\n private applyJitter(delay: number): number {\n if (delay === 0 || this.jitter === 0) {\n return delay;\n }\n const delayFactor = 1 - this.jitter / 2 + Math.random() * this.jitter;\n return delay * delayFactor;\n }\n}\n"],"mappings":";AAMA,MAAa,uBAAoC;C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AK,UAC3B,KAAK,eAAe,KAAK;EAG3B,OAAO,KAAK,YAAY,KAAK,YAAY;CAC3C;CAEA,QAAc;EACZ,KAAK,eAAe,KAAK;CAC3B;CAEA,YAAoB,OAAuB;EACzC,IAAI,UAAU,KAAK,KAAK,WAAW,GACjC,OAAO;EAGT,OAAO,SADa,IAAI,KAAK,SAAS,IAAI,KAAK,OAAO,IAAI,KAAK;CAEjE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_helpers.cjs","names":["isNotNullSignedResourceId"],"sources":["../../src/helpers/tx_helpers.ts"],"sourcesContent":["import type { PlTransaction } from \"../core/transaction\";\nimport type { FieldData, OptionalSignedResourceId } from \"../core/types\";\nimport { isNotNullSignedResourceId } from \"../core/types\";\nimport { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\nexport interface ValErr {\n valueId: OptionalSignedResourceId;\n errorId: OptionalSignedResourceId;\n error?: string;\n}\n\nexport async function valErr(tx: PlTransaction, f: FieldData): Promise<ValErr> {\n const result = {\n valueId: f.value,\n errorId: f.error,\n error: \"\",\n };\n\n if (isNotNullSignedResourceId(f.error)) {\n const e = await tx.getResourceData(f.error, true);\n const deserializationResult = cachedDeserialize(notEmpty(e.data));\n if (typeof deserializationResult !== \"string\") {\n const dataStr = notEmpty(e.data).toString();\n throw new Error(\n `Unexpected error structure: ${dataStr.substring(0, Math.min(dataStr.length, 100))}...`,\n );\n }\n result.error = deserializationResult;\n }\n\n return result;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tx_helpers.cjs","names":["isNotNullSignedResourceId"],"sources":["../../src/helpers/tx_helpers.ts"],"sourcesContent":["import type { PlTransaction } from \"../core/transaction\";\nimport type { FieldData, OptionalSignedResourceId } from \"../core/types\";\nimport { isNotNullSignedResourceId } from \"../core/types\";\nimport { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\nexport interface ValErr {\n valueId: OptionalSignedResourceId;\n errorId: OptionalSignedResourceId;\n error?: string;\n}\n\nexport async function valErr(tx: PlTransaction, f: FieldData): Promise<ValErr> {\n const result = {\n valueId: f.value,\n errorId: f.error,\n error: \"\",\n };\n\n if (isNotNullSignedResourceId(f.error)) {\n const e = await tx.getResourceData(f.error, true);\n const deserializationResult = cachedDeserialize(notEmpty(e.data));\n if (typeof deserializationResult !== \"string\") {\n const dataStr = notEmpty(e.data).toString();\n throw new Error(\n `Unexpected error structure: ${dataStr.substring(0, Math.min(dataStr.length, 100))}...`,\n );\n }\n result.error = deserializationResult;\n }\n\n return result;\n}\n"],"mappings":";;;AAWA,eAAsB,OAAO,IAAmB,GAA+B;CAC7E,MAAM,SAAS;EACb,SAAS,EAAE;EACX,SAAS,EAAE;EACX,OAAO;CACT;CAEA,IAAIA,cAAAA,0BAA0B,EAAE,KAAK,GAAG;EACtC,MAAM,IAAI,MAAM,GAAG,gBAAgB,EAAE,OAAO,IAAI;EAChD,MAAM,yBAAA,GAAA,2BAAA,kBAAA,EAAA,GAAA,2BAAA,SAAA,CAAmD,EAAE,IAAI,CAAC;EAChE,IAAI,OAAO,0BAA0B,UAAU;GAC7C,MAAM,WAAA,GAAA,2BAAA,SAAA,CAAmB,EAAE,IAAI,CAAC,CAAC,SAAS;GAC1C,MAAM,IAAI,MACR,+BAA+B,QAAQ,UAAU,GAAG,KAAK,IAAI,QAAQ,QAAQ,GAAG,CAAC,EAAE,IACrF;EACF;EACA,OAAO,QAAQ;CACjB;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_helpers.d.ts","names":[],"sources":["../../src/helpers/tx_helpers.ts"],"mappings":";;;;UAKiB,MAAA;EACf,OAAA,EAAS,wBAAA;EACT,OAAA,EAAS,
|
|
1
|
+
{"version":3,"file":"tx_helpers.d.ts","names":[],"sources":["../../src/helpers/tx_helpers.ts"],"mappings":";;;;UAKiB,MAAA;EACf,OAAA,EAAS,wBAAA;EACT,OAAA,EAAS,wBAAwB;EACjC,KAAA;AAAA;AAAA,iBAGoB,MAAA,CAAO,EAAA,EAAI,aAAA,EAAe,CAAA,EAAG,SAAA,GAAY,OAAA,CAAQ,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_helpers.js","names":[],"sources":["../../src/helpers/tx_helpers.ts"],"sourcesContent":["import type { PlTransaction } from \"../core/transaction\";\nimport type { FieldData, OptionalSignedResourceId } from \"../core/types\";\nimport { isNotNullSignedResourceId } from \"../core/types\";\nimport { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\nexport interface ValErr {\n valueId: OptionalSignedResourceId;\n errorId: OptionalSignedResourceId;\n error?: string;\n}\n\nexport async function valErr(tx: PlTransaction, f: FieldData): Promise<ValErr> {\n const result = {\n valueId: f.value,\n errorId: f.error,\n error: \"\",\n };\n\n if (isNotNullSignedResourceId(f.error)) {\n const e = await tx.getResourceData(f.error, true);\n const deserializationResult = cachedDeserialize(notEmpty(e.data));\n if (typeof deserializationResult !== \"string\") {\n const dataStr = notEmpty(e.data).toString();\n throw new Error(\n `Unexpected error structure: ${dataStr.substring(0, Math.min(dataStr.length, 100))}...`,\n );\n }\n result.error = deserializationResult;\n }\n\n return result;\n}\n"],"mappings":";;;AAWA,eAAsB,OAAO,IAAmB,GAA+B;CAC7E,MAAM,SAAS;EACb,SAAS,EAAE;EACX,SAAS,EAAE;EACX,OAAO;
|
|
1
|
+
{"version":3,"file":"tx_helpers.js","names":[],"sources":["../../src/helpers/tx_helpers.ts"],"sourcesContent":["import type { PlTransaction } from \"../core/transaction\";\nimport type { FieldData, OptionalSignedResourceId } from \"../core/types\";\nimport { isNotNullSignedResourceId } from \"../core/types\";\nimport { cachedDeserialize, notEmpty } from \"@milaboratories/ts-helpers\";\n\nexport interface ValErr {\n valueId: OptionalSignedResourceId;\n errorId: OptionalSignedResourceId;\n error?: string;\n}\n\nexport async function valErr(tx: PlTransaction, f: FieldData): Promise<ValErr> {\n const result = {\n valueId: f.value,\n errorId: f.error,\n error: \"\",\n };\n\n if (isNotNullSignedResourceId(f.error)) {\n const e = await tx.getResourceData(f.error, true);\n const deserializationResult = cachedDeserialize(notEmpty(e.data));\n if (typeof deserializationResult !== \"string\") {\n const dataStr = notEmpty(e.data).toString();\n throw new Error(\n `Unexpected error structure: ${dataStr.substring(0, Math.min(dataStr.length, 100))}...`,\n );\n }\n result.error = deserializationResult;\n }\n\n return result;\n}\n"],"mappings":";;;AAWA,eAAsB,OAAO,IAAmB,GAA+B;CAC7E,MAAM,SAAS;EACb,SAAS,EAAE;EACX,SAAS,EAAE;EACX,OAAO;CACT;CAEA,IAAI,0BAA0B,EAAE,KAAK,GAAG;EACtC,MAAM,IAAI,MAAM,GAAG,gBAAgB,EAAE,OAAO,IAAI;EAChD,MAAM,wBAAwB,kBAAkB,SAAS,EAAE,IAAI,CAAC;EAChE,IAAI,OAAO,0BAA0B,UAAU;GAC7C,MAAM,UAAU,SAAS,EAAE,IAAI,CAAC,CAAC,SAAS;GAC1C,MAAM,IAAI,MACR,+BAA+B,QAAQ,UAAU,GAAG,KAAK,IAAI,QAAQ,QAAQ,GAAG,CAAC,EAAE,IACrF;EACF;EACA,OAAO,QAAQ;CACjB;CAEA,OAAO;AACT"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_types = require("./core/types.cjs");
|
|
4
3
|
const require_api = require("./proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs");
|
|
5
4
|
const require_errors = require("./core/errors.cjs");
|
|
@@ -40,6 +39,7 @@ exports.DefaultRetryOptions = require_config.DefaultRetryOptions;
|
|
|
40
39
|
exports.DisconnectedError = require_errors.DisconnectedError;
|
|
41
40
|
exports.FilterOperatorType = require_api.ResourceAPI_Tree_Filter_OperatorType;
|
|
42
41
|
exports.FilterProperty = require_api.ResourceAPI_Tree_Filter_Property;
|
|
42
|
+
exports.GrantType = require_transaction.GrantType;
|
|
43
43
|
exports.MaxLocalId = require_types.MaxLocalId;
|
|
44
44
|
exports.MaxTxId = require_types.MaxTxId;
|
|
45
45
|
exports.NullResourceId = require_types.NullResourceId;
|
|
@@ -67,6 +67,7 @@ Object.defineProperty(exports, "RestAPI", {
|
|
|
67
67
|
return require_index.proto_rest_exports;
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
+
exports.Role = require_transaction.Role;
|
|
70
71
|
exports.SUPPORTED_WIRE_PROTOCOLS = require_config.SUPPORTED_WIRE_PROTOCOLS;
|
|
71
72
|
Object.defineProperty(exports, "TestHelpers", {
|
|
72
73
|
enumerable: true,
|
|
@@ -101,6 +102,7 @@ exports.isAbortedError = require_errors.isAbortedError;
|
|
|
101
102
|
exports.isAnyResourceId = require_types.isAnyResourceId;
|
|
102
103
|
exports.isCancelError = require_errors.isCancelError;
|
|
103
104
|
exports.isConnectionProblem = require_errors.isConnectionProblem;
|
|
105
|
+
exports.isEveryoneUserLogin = require_transaction.isEveryoneUserLogin;
|
|
104
106
|
exports.isField = require_transaction.isField;
|
|
105
107
|
exports.isFieldRef = require_transaction.isFieldRef;
|
|
106
108
|
exports.isLocalResourceId = require_types.isLocalResourceId;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AnyResourceId, BasicResourceData, ColorProof, FieldData, FieldStatus, FieldType, FutureFieldType, GlobalResourceId, LocalResourceId, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, OptionalAnyResourceId, OptionalSignedResourceId, ResourceData, ResourceKind, ResourceSignature, ResourceType, SignedResourceId, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createSignedResourceId, ensureSignedResourceIdNotNull, extractBasicResourceData, extractTxId, getField, isAnyResourceId, isLocalResourceId, isNotNullSignedResourceId, isNullSignedResourceId, isRootResourceId, isSignedResourceId, jsonToData, parseResourceType, parseSignedResourceId, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, toResourceSignature } from "./core/types.js";
|
|
2
2
|
import { ResourceAPI_Tree_Filter, ResourceAPI_Tree_Filter_OperatorType, ResourceAPI_Tree_Filter_Property } from "./proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js";
|
|
3
3
|
import { DefaultFinalResourceDataPredicate, FinalResourceDataPredicate, ResourceTypeName, ResourceTypePrefix } from "./core/final.js";
|
|
4
|
-
import { AnyFieldId, AnyFieldRef, AnyRef, AnyResourceRef, FieldId, FieldRef, KeyValue, KeyValueString, LocalFieldId, PlTransaction, ResourceIdWithSignature, ResourceRef, ResourceTreeFrame, ResourceTreeItem, TxCommitConflict, field, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId } from "./core/transaction.js";
|
|
4
|
+
import { AnyFieldId, AnyFieldRef, AnyRef, AnyResourceRef, FieldId, FieldRef, GrantPermissions, GrantType, KeyValue, KeyValueString, LocalFieldId, PlTransaction, ResourceIdWithSignature, ResourceRef, ResourceTreeFrame, ResourceTreeItem, Role, TxCommitConflict, field, isEveryoneUserLogin, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId } from "./core/transaction.js";
|
|
5
5
|
import { pl_d_exports } from "./helpers/pl.js";
|
|
6
6
|
import { AnonymousAuthInformation, AuthInformation, AuthOps, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultRetryOptions, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, SUPPORTED_WIRE_PROTOCOLS, plAddressToConfig, wireProtocol } from "./core/config.js";
|
|
7
7
|
import { BackendCapability, hasCapability } from "./core/capabilities.js";
|
|
8
8
|
import { GrpcConnection, RestConnection, WireClientProvider, WireClientProviderFactory, WireConnection } from "./core/wire.js";
|
|
9
9
|
import { index_d_exports } from "./proto-rest/index.js";
|
|
10
10
|
import { PlDriver, PlDriverDefinition, addRTypeToMetadata, createRTypeRoutingHeader } from "./core/driver.js";
|
|
11
|
-
import { StorageInfo, TxRunner, UserResources } from "./core/user_resources.js";
|
|
11
|
+
import { GrantEntry, StorageInfo, TxRunner, UserEntry, UserResources } from "./core/user_resources.js";
|
|
12
12
|
import { PlClient, TxOps } from "./core/client.js";
|
|
13
13
|
import { DisconnectedError, PermissionDeniedError, PlError, PlErrorCodeNotFound, RESTError, RecoverablePlError, UnauthenticatedError, UnrecoverablePlError, isAbortedError, isCancelError, isConnectionProblem, isNotFoundError, isPermissionDenied, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, rethrowMeaningfulError, throwPlNotFoundError } from "./core/errors.js";
|
|
14
14
|
import { defaultPlClient, tryGetFileConfig } from "./core/default_client.js";
|
|
@@ -18,4 +18,4 @@ import { Filter, Property, treeFilter } from "./core/tree_filter.js";
|
|
|
18
18
|
import { ValErr, valErr } from "./helpers/tx_helpers.js";
|
|
19
19
|
import { ContinuePolling, DefaultPollingRetryOptions, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, poll } from "./helpers/poll.js";
|
|
20
20
|
import { test_config_d_exports } from "./test/test_config.js";
|
|
21
|
-
export { AnonymousAuthInformation, AnyFieldId, AnyFieldRef, AnyRef, AnyResourceId, AnyResourceRef, AuthInformation, AuthOps, BackendCapability, BasicResourceData, ColorProof, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, FieldData, FieldId, FieldRef, FieldStatus, FieldType, Filter, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, FinalResourceDataPredicate, FutureFieldType, GlobalResourceId, GrpcConnection, KeyValue, KeyValueString, LocalFieldId, LocalResourceId, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, OptionalAnyResourceId, OptionalSignedResourceId, PermissionDeniedError, pl_d_exports as Pl, PlClient, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, PlDriver, PlDriverDefinition, PlError, PlErrorCodeNotFound, PlTransaction, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, Property, RESTError, RecoverablePlError, ResourceAPI_Tree_Filter, ResourceData, ResourceIdWithSignature, ResourceKind, ResourceRef, ResourceSignature, ResourceTreeFrame, ResourceTreeItem, ResourceType, ResourceTypeName, ResourceTypePrefix, index_d_exports as RestAPI, RestConnection, SSOAuthMethod, SSOFlowType, SSOLoginAttempt, SUPPORTED_WIRE_PROTOCOLS, SignedResourceId, StorageInfo, test_config_d_exports as TestHelpers, TxCommitConflict, TxOps, TxRunner, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserResources, ValErr, WireClientProvider, WireClientProviderFactory, WireConnection, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr, wireProtocol };
|
|
21
|
+
export { AnonymousAuthInformation, AnyFieldId, AnyFieldRef, AnyRef, AnyResourceId, AnyResourceRef, AuthInformation, AuthOps, BackendCapability, BasicResourceData, ColorProof, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, FieldData, FieldId, FieldRef, FieldStatus, FieldType, Filter, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, FinalResourceDataPredicate, FutureFieldType, GlobalResourceId, GrantEntry, GrantPermissions, GrantType, GrpcConnection, KeyValue, KeyValueString, LocalFieldId, LocalResourceId, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, OptionalAnyResourceId, OptionalSignedResourceId, PermissionDeniedError, pl_d_exports as Pl, PlClient, PlClientConfig, PlConnectionStatus, PlConnectionStatusListener, PlDriver, PlDriverDefinition, PlError, PlErrorCodeNotFound, PlTransaction, PollFieldTraverseOps, PollResourceAccessor, PollTxAccessor, Property, RESTError, RecoverablePlError, type ResourceAPI_Tree_Filter, ResourceData, ResourceIdWithSignature, ResourceKind, ResourceRef, ResourceSignature, ResourceTreeFrame, ResourceTreeItem, ResourceType, ResourceTypeName, ResourceTypePrefix, index_d_exports as RestAPI, RestConnection, Role, SSOAuthMethod, SSOFlowType, SSOLoginAttempt, SUPPORTED_WIRE_PROTOCOLS, SignedResourceId, StorageInfo, test_config_d_exports as TestHelpers, TxCommitConflict, TxOps, TxRunner, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserEntry, UserResources, ValErr, WireClientProvider, WireClientProviderFactory, WireConnection, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isEveryoneUserLogin, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr, wireProtocol };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createSignedResourceId, ensureSignedResourceIdNotNull, extractBasicResourceData, extractTxId, getField, isAnyResourceId, isLocalResourceId, isNotNullSignedResourceId, isNullSignedResourceId, isRootResourceId, isSignedResourceId, jsonToData, parseResourceType, parseSignedResourceId, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, toResourceSignature } from "./core/types.js";
|
|
2
2
|
import { ResourceAPI_Tree_Filter_OperatorType, ResourceAPI_Tree_Filter_Property } from "./proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js";
|
|
3
3
|
import { DisconnectedError, PermissionDeniedError, PlError, PlErrorCodeNotFound, RESTError, RecoverablePlError, UnauthenticatedError, UnrecoverablePlError, isAbortedError, isCancelError, isConnectionProblem, isNotFoundError, isPermissionDenied, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, rethrowMeaningfulError, throwPlNotFoundError } from "./core/errors.js";
|
|
4
|
-
import { PlTransaction, TxCommitConflict, field, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId } from "./core/transaction.js";
|
|
4
|
+
import { GrantType, PlTransaction, Role, TxCommitConflict, field, isEveryoneUserLogin, isField, isFieldRef, isResource, isResourceId, isResourceRef, toFieldId, toGlobalFieldId, toGlobalResourceId } from "./core/transaction.js";
|
|
5
5
|
import { pl_exports } from "./helpers/pl.js";
|
|
6
6
|
import { AnonymousAuthInformation, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultRetryOptions, SUPPORTED_WIRE_PROTOCOLS, plAddressToConfig } from "./core/config.js";
|
|
7
7
|
import { expirationFromAuthInformation, inferAuthRefreshTime } from "./core/auth.js";
|
|
@@ -17,4 +17,4 @@ import { treeFilter } from "./core/tree_filter.js";
|
|
|
17
17
|
import { valErr } from "./helpers/tx_helpers.js";
|
|
18
18
|
import { ContinuePolling, DefaultPollingRetryOptions, PollResourceAccessor, PollTxAccessor, poll } from "./helpers/poll.js";
|
|
19
19
|
import { test_config_exports } from "./test/test_config.js";
|
|
20
|
-
export { AnonymousAuthInformation, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, PermissionDeniedError, pl_exports as Pl, PlClient, PlError, PlErrorCodeNotFound, PlTransaction, PollResourceAccessor, PollTxAccessor, RESTError, RecoverablePlError, ResourceTypeName, ResourceTypePrefix, proto_rest_exports as RestAPI, SUPPORTED_WIRE_PROTOCOLS, test_config_exports as TestHelpers, TxCommitConflict, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserResources, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr };
|
|
20
|
+
export { AnonymousAuthInformation, ContinuePolling, DEFAULT_AUTH_MAX_REFRESH, 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_RO_TX_TIMEOUT, DEFAULT_RW_TX_TIMEOUT, DEFAULT_TOKEN_TTL_SECONDS, DefaultFinalResourceDataPredicate, DefaultPollingRetryOptions, DefaultRetryOptions, DisconnectedError, ResourceAPI_Tree_Filter_OperatorType as FilterOperatorType, ResourceAPI_Tree_Filter_Property as FilterProperty, GrantType, MaxLocalId, MaxTxId, NullResourceId, NullSignedResourceId, PermissionDeniedError, pl_exports as Pl, PlClient, PlError, PlErrorCodeNotFound, PlTransaction, PollResourceAccessor, PollTxAccessor, RESTError, RecoverablePlError, ResourceTypeName, ResourceTypePrefix, proto_rest_exports as RestAPI, Role, SUPPORTED_WIRE_PROTOCOLS, test_config_exports as TestHelpers, TxCommitConflict, UnauthenticatedError, UnauthenticatedPlClient, UnrecoverablePlError, UserResources, addRTypeToMetadata, anyResourceIdToBigint, asSignedResourceId, base64UrlToSignature, checkLocalityOfResourceId, createGlobalResourceId, createLocalResourceId, createRTypeRoutingHeader, createSignedResourceId, defaultPlClient, ensureSignedResourceIdNotNull, expirationFromAuthInformation, extractBasicResourceData, extractTxId, field, getField, hasCapability, inferAuthRefreshTime, isAbortedError, isAnyResourceId, isCancelError, isConnectionProblem, isEveryoneUserLogin, isField, isFieldRef, isLocalResourceId, isNotFoundError, isNotNullSignedResourceId, isNullSignedResourceId, isPermissionDenied, isResource, isResourceId, isResourceRef, isRootResourceId, isSignedResourceId, isTimeoutError, isTimeoutOrCancelError, isUnauthenticated, isUnimplementedError, jsonToData, parseResourceType, parseSignedResourceId, plAddressToConfig, poll, resDataToJson, resourceIdFromString, resourceIdToString, resourceType, resourceTypeToString, resourceTypesEqual, rethrowMeaningfulError, setResourceSignaturesRequired, signatureToBase64Url, stringifyWithResourceId, throwPlNotFoundError, toFieldId, toGlobalFieldId, toGlobalResourceId, toResourceSignature, treeFilter, tryGetFileConfig, valErr };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("../../../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_any = require("../../../../../google/protobuf/any.cjs");
|
|
3
2
|
let _protobuf_ts_runtime = require("@protobuf-ts/runtime");
|
|
4
3
|
//#region src/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.cjs","names":["MessageType","Any","UnknownFieldHandler","WireType"],"sources":["../../../../../../../src/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.ts"],"sourcesContent":["// @generated by protobuf-ts 2.11.1 with parameter client_generic,optimize_speed,generate_dependencies,force_server_none\n// @generated from protobuf file \"github.com/googleapis/googleapis/google/rpc/status.proto\" (package \"google.rpc\", syntax proto3)\n// tslint:disable\n//\n// Copyright 2025 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport type { BinaryWriteOptions } from \"@protobuf-ts/runtime\";\nimport type { IBinaryWriter } from \"@protobuf-ts/runtime\";\nimport { WireType } from \"@protobuf-ts/runtime\";\nimport type { BinaryReadOptions } from \"@protobuf-ts/runtime\";\nimport type { IBinaryReader } from \"@protobuf-ts/runtime\";\nimport { UnknownFieldHandler } from \"@protobuf-ts/runtime\";\nimport type { PartialMessage } from \"@protobuf-ts/runtime\";\nimport { reflectionMergePartial } from \"@protobuf-ts/runtime\";\nimport { MessageType } from \"@protobuf-ts/runtime\";\nimport { Any } from \"../../../../../google/protobuf/any\";\n/**\n * The `Status` type defines a logical error model that is suitable for\n * different programming environments, including REST APIs and RPC APIs. It is\n * used by [gRPC](https://github.com/grpc). Each `Status` message contains\n * three pieces of data: error code, error message, and error details.\n *\n * You can find out more about this error model and how to work with it in the\n * [API Design Guide](https://cloud.google.com/apis/design/errors).\n *\n * @generated from protobuf message google.rpc.Status\n */\nexport interface Status {\n /**\n * The status code, which should be an enum value of\n * [google.rpc.Code][google.rpc.Code].\n *\n * @generated from protobuf field: int32 code = 1\n */\n code: number;\n /**\n * A developer-facing error message, which should be in English. Any\n * user-facing error message should be localized and sent in the\n * [google.rpc.Status.details][google.rpc.Status.details] field, or localized\n * by the client.\n *\n * @generated from protobuf field: string message = 2\n */\n message: string;\n /**\n * A list of messages that carry the error details. There is a common set of\n * message types for APIs to use.\n *\n * @generated from protobuf field: repeated google.protobuf.Any details = 3\n */\n details: Any[];\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Status$Type extends MessageType<Status> {\n constructor() {\n super(\"google.rpc.Status\", [\n { no: 1, name: \"code\", kind: \"scalar\", T: 5 /*ScalarType.INT32*/ },\n { no: 2, name: \"message\", kind: \"scalar\", T: 9 /*ScalarType.STRING*/ },\n { no: 3, name: \"details\", kind: \"message\", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Any }\n ]);\n }\n create(value?: PartialMessage<Status>): Status {\n const message = globalThis.Object.create((this.messagePrototype!));\n message.code = 0;\n message.message = \"\";\n message.details = [];\n if (value !== undefined)\n reflectionMergePartial<Status>(this, message, value);\n return message;\n }\n internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Status): Status {\n let message = target ?? this.create(), end = reader.pos + length;\n while (reader.pos < end) {\n let [fieldNo, wireType] = reader.tag();\n switch (fieldNo) {\n case /* int32 code */ 1:\n message.code = reader.int32();\n break;\n case /* string message */ 2:\n message.message = reader.string();\n break;\n case /* repeated google.protobuf.Any details */ 3:\n message.details.push(Any.internalBinaryRead(reader, reader.uint32(), options));\n break;\n default:\n let u = options.readUnknownField;\n if (u === \"throw\")\n throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);\n let d = reader.skip(wireType);\n if (u !== false)\n (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);\n }\n }\n return message;\n }\n internalBinaryWrite(message: Status, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {\n /* int32 code = 1; */\n if (message.code !== 0)\n writer.tag(1, WireType.Varint).int32(message.code);\n /* string message = 2; */\n if (message.message !== \"\")\n writer.tag(2, WireType.LengthDelimited).string(message.message);\n /* repeated google.protobuf.Any details = 3; */\n for (let i = 0; i < message.details.length; i++)\n Any.internalBinaryWrite(message.details[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();\n let u = options.writeUnknownFields;\n if (u !== false)\n (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);\n return writer;\n }\n}\n/**\n * @generated MessageType for protobuf message google.rpc.Status\n */\nexport const Status = new Status$Type();\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.cjs","names":["MessageType","Any","UnknownFieldHandler","WireType"],"sources":["../../../../../../../src/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.ts"],"sourcesContent":["// @generated by protobuf-ts 2.11.1 with parameter client_generic,optimize_speed,generate_dependencies,force_server_none\n// @generated from protobuf file \"github.com/googleapis/googleapis/google/rpc/status.proto\" (package \"google.rpc\", syntax proto3)\n// tslint:disable\n//\n// Copyright 2025 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\nimport type { BinaryWriteOptions } from \"@protobuf-ts/runtime\";\nimport type { IBinaryWriter } from \"@protobuf-ts/runtime\";\nimport { WireType } from \"@protobuf-ts/runtime\";\nimport type { BinaryReadOptions } from \"@protobuf-ts/runtime\";\nimport type { IBinaryReader } from \"@protobuf-ts/runtime\";\nimport { UnknownFieldHandler } from \"@protobuf-ts/runtime\";\nimport type { PartialMessage } from \"@protobuf-ts/runtime\";\nimport { reflectionMergePartial } from \"@protobuf-ts/runtime\";\nimport { MessageType } from \"@protobuf-ts/runtime\";\nimport { Any } from \"../../../../../google/protobuf/any\";\n/**\n * The `Status` type defines a logical error model that is suitable for\n * different programming environments, including REST APIs and RPC APIs. It is\n * used by [gRPC](https://github.com/grpc). Each `Status` message contains\n * three pieces of data: error code, error message, and error details.\n *\n * You can find out more about this error model and how to work with it in the\n * [API Design Guide](https://cloud.google.com/apis/design/errors).\n *\n * @generated from protobuf message google.rpc.Status\n */\nexport interface Status {\n /**\n * The status code, which should be an enum value of\n * [google.rpc.Code][google.rpc.Code].\n *\n * @generated from protobuf field: int32 code = 1\n */\n code: number;\n /**\n * A developer-facing error message, which should be in English. Any\n * user-facing error message should be localized and sent in the\n * [google.rpc.Status.details][google.rpc.Status.details] field, or localized\n * by the client.\n *\n * @generated from protobuf field: string message = 2\n */\n message: string;\n /**\n * A list of messages that carry the error details. There is a common set of\n * message types for APIs to use.\n *\n * @generated from protobuf field: repeated google.protobuf.Any details = 3\n */\n details: Any[];\n}\n// @generated message type with reflection information, may provide speed optimized methods\nclass Status$Type extends MessageType<Status> {\n constructor() {\n super(\"google.rpc.Status\", [\n { no: 1, name: \"code\", kind: \"scalar\", T: 5 /*ScalarType.INT32*/ },\n { no: 2, name: \"message\", kind: \"scalar\", T: 9 /*ScalarType.STRING*/ },\n { no: 3, name: \"details\", kind: \"message\", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Any }\n ]);\n }\n create(value?: PartialMessage<Status>): Status {\n const message = globalThis.Object.create((this.messagePrototype!));\n message.code = 0;\n message.message = \"\";\n message.details = [];\n if (value !== undefined)\n reflectionMergePartial<Status>(this, message, value);\n return message;\n }\n internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Status): Status {\n let message = target ?? this.create(), end = reader.pos + length;\n while (reader.pos < end) {\n let [fieldNo, wireType] = reader.tag();\n switch (fieldNo) {\n case /* int32 code */ 1:\n message.code = reader.int32();\n break;\n case /* string message */ 2:\n message.message = reader.string();\n break;\n case /* repeated google.protobuf.Any details */ 3:\n message.details.push(Any.internalBinaryRead(reader, reader.uint32(), options));\n break;\n default:\n let u = options.readUnknownField;\n if (u === \"throw\")\n throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);\n let d = reader.skip(wireType);\n if (u !== false)\n (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);\n }\n }\n return message;\n }\n internalBinaryWrite(message: Status, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {\n /* int32 code = 1; */\n if (message.code !== 0)\n writer.tag(1, WireType.Varint).int32(message.code);\n /* string message = 2; */\n if (message.message !== \"\")\n writer.tag(2, WireType.LengthDelimited).string(message.message);\n /* repeated google.protobuf.Any details = 3; */\n for (let i = 0; i < message.details.length; i++)\n Any.internalBinaryWrite(message.details[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();\n let u = options.writeUnknownFields;\n if (u !== false)\n (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);\n return writer;\n }\n}\n/**\n * @generated MessageType for protobuf message google.rpc.Status\n */\nexport const Status = new Status$Type();\n"],"mappings":";;;AAiEA,IAAM,cAAN,cAA0BA,qBAAAA,YAAoB;CAC1C,cAAc;EACV,MAAM,qBAAqB;GACvB;IAAE,IAAI;IAAG,MAAM;IAAQ,MAAM;IAAU,GAAG;GAAuB;GACjE;IAAE,IAAI;IAAG,MAAM;IAAW,MAAM;IAAU,GAAG;GAAwB;GACrE;IAAE,IAAI;IAAG,MAAM;IAAW,MAAM;IAAW,QAAQ;IAA2B,SAASC,YAAAA;GAAI;EAC/F,CAAC;CACL;CACA,OAAO,OAAwC;EAC3C,MAAM,UAAU,WAAW,OAAO,OAAQ,KAAK,gBAAkB;EACjE,QAAQ,OAAO;EACf,QAAQ,UAAU;EAClB,Q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,OAAO,CAAC,CAAC,KAAK;EAC9G,IAAI,IAAI,QAAQ;EAChB,IAAI,MAAM,OACN,CAAC,KAAK,OAAOD,qBAAAA,oBAAoB,UAAU,EAAA,CAAG,KAAK,UAAU,SAAS,MAAM;EAChF,OAAO;CACX;AACJ;;;;AAIA,MAAa,SAAS,IAAI,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","names":[],"sources":["../../../../../../../src/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"status.d.ts","names":[],"sources":["../../../../../../../src/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.ts"],"mappings":";;;;;;;;;;AA8DgB;AACf;;;;UAxBgB,MAAA;EAkCE;;;;;;EA3Bf,IAAA;EA6D6C;;;;;;;;EApD7C,OAAA;EAkBA;;;;;;EAXA,OAAA,EAAS,GAAG;AAAA;AAAA,cAGV,WAAA,SAAoB,WAAA,CAAY,MAAA;;EAQlC,MAAA,CAAO,KAAA,GAAQ,cAAA,CAAe,MAAA,IAAU,MAAA;EASxC,kBAAA,CAAmB,MAAA,EAAQ,aAAA,EAAe,MAAA,UAAgB,OAAA,EAAS,iBAAA,EAAmB,MAAA,GAAS,MAAA,GAAS,MAAA;EAyBxG,mBAAA,CAAoB,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAQ,aAAA,EAAe,OAAA,EAAS,kBAAA,GAAqB,aAAA;AAAA;;;;cAmBjF,MAAA,EAAM,WAAoB"}
|