@mdbase-dev/pickle 0.1.0-beta.21 → 0.1.0-beta.23
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/index.d.ts +3 -3
- package/dist/index.js +7 -12
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionContractDescriptor, CollectionDescription, CollectionTypeDescriptor, JsonObject, RecordDocument } from "@mdbase-dev/connect-protocol";
|
|
2
|
-
import type
|
|
2
|
+
import { type MdbaseConnection } from "@mdbase-dev/connect";
|
|
3
3
|
export { PICKLE_ACK_RESPONSE_TYPE_DOCUMENT, PICKLE_APPROVAL_RESPONSE_TYPE_DOCUMENT, PICKLE_REQUEST_CONTRACT_DOCUMENT, PICKLE_TYPE_PACK_PROVISION, PICKLE_REQUEST_TYPE_DOCUMENT } from "./resources.js";
|
|
4
4
|
export declare const PICKLE_REQUEST_CONTRACT = "pickle.request";
|
|
5
5
|
export declare const PICKLE_REQUEST_CONTRACT_VERSION = "1.0.0";
|
|
@@ -77,8 +77,8 @@ export interface RespondOptions {
|
|
|
77
77
|
responder?: string;
|
|
78
78
|
}
|
|
79
79
|
export interface PickleClient {
|
|
80
|
-
describe():
|
|
81
|
-
queryAll(input: Parameters<MdbaseConnection<PickleFrontmatter>["queryAll"]>[0]):
|
|
80
|
+
describe(): ReturnType<MdbaseConnection<PickleFrontmatter>["describe"]>;
|
|
81
|
+
queryAll(input: Parameters<MdbaseConnection<PickleFrontmatter>["queryAll"]>[0]): ReturnType<MdbaseConnection<PickleFrontmatter>["queryAll"]>;
|
|
82
82
|
create(input: Parameters<MdbaseConnection<PickleFrontmatter>["create"]>[0]): ReturnType<MdbaseConnection<PickleFrontmatter>["create"]>;
|
|
83
83
|
}
|
|
84
84
|
export declare function resolvePickleContract(description: CollectionDescription): PickleContract;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unwrapConnectOutcome } from "@mdbase-dev/connect";
|
|
1
2
|
export { PICKLE_ACK_RESPONSE_TYPE_DOCUMENT, PICKLE_APPROVAL_RESPONSE_TYPE_DOCUMENT, PICKLE_REQUEST_CONTRACT_DOCUMENT, PICKLE_TYPE_PACK_PROVISION, PICKLE_REQUEST_TYPE_DOCUMENT } from "./resources.js";
|
|
2
3
|
export const PICKLE_REQUEST_CONTRACT = "pickle.request";
|
|
3
4
|
export const PICKLE_REQUEST_CONTRACT_VERSION = "1.0.0";
|
|
@@ -43,17 +44,17 @@ export class PickleCollection {
|
|
|
43
44
|
this.connect = connect;
|
|
44
45
|
}
|
|
45
46
|
async describe() {
|
|
46
|
-
this.description ??= await this.connect.describe();
|
|
47
|
+
this.description ??= unwrapConnectOutcome(await this.connect.describe());
|
|
47
48
|
this.contract ??= resolvePickleContract(this.description);
|
|
48
49
|
return { collection: this.description, contract: this.contract };
|
|
49
50
|
}
|
|
50
51
|
async list() {
|
|
51
52
|
const { collection, contract } = await this.describe();
|
|
52
|
-
const requestQuery = await this.connect.queryAll({
|
|
53
|
+
const requestQuery = unwrapConnectOutcome(await this.connect.queryAll({
|
|
53
54
|
types: contract.implementations.map(({ typeName }) => typeName),
|
|
54
55
|
include_body: true,
|
|
55
56
|
frontmatter_mode: "effective"
|
|
56
|
-
});
|
|
57
|
+
}));
|
|
57
58
|
const requests = requestQuery.results.map(requireEffectiveFrontmatter);
|
|
58
59
|
const responseTypes = [
|
|
59
60
|
...new Set(requests
|
|
@@ -64,11 +65,11 @@ export class PickleCollection {
|
|
|
64
65
|
.filter(Boolean))
|
|
65
66
|
];
|
|
66
67
|
const responses = responseTypes.length
|
|
67
|
-
? (await this.connect.queryAll({
|
|
68
|
+
? (unwrapConnectOutcome(await this.connect.queryAll({
|
|
68
69
|
types: responseTypes,
|
|
69
70
|
include_body: true,
|
|
70
71
|
frontmatter_mode: "effective"
|
|
71
|
-
})).results.map(requireEffectiveFrontmatter)
|
|
72
|
+
}))).results.map(requireEffectiveFrontmatter)
|
|
72
73
|
: [];
|
|
73
74
|
return requests
|
|
74
75
|
.map((record) => normalizeRequest(record, responses, collection, contract))
|
|
@@ -98,8 +99,7 @@ export class PickleCollection {
|
|
|
98
99
|
frontmatter,
|
|
99
100
|
body: ""
|
|
100
101
|
});
|
|
101
|
-
|
|
102
|
-
return created.result;
|
|
102
|
+
return unwrapConnectOutcome(created);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
export class PickleContractError extends Error {
|
|
@@ -256,11 +256,6 @@ function validFieldPath(value) {
|
|
|
256
256
|
function trimSlashes(value) {
|
|
257
257
|
return value.replace(/^\/+|\/+$/g, "");
|
|
258
258
|
}
|
|
259
|
-
function assertValid(value) {
|
|
260
|
-
if (value.valid)
|
|
261
|
-
return;
|
|
262
|
-
throw new PickleContractError(value.diagnostics[0]?.message ?? "Pickle operation failed.");
|
|
263
|
-
}
|
|
264
259
|
function asObject(value) {
|
|
265
260
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
266
261
|
? value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdbase-dev/pickle",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mdbase-dev/connect": "0.1.0-beta.
|
|
26
|
-
"@mdbase-dev/connect-protocol": "0.1.0-beta.
|
|
25
|
+
"@mdbase-dev/connect": "0.1.0-beta.23",
|
|
26
|
+
"@mdbase-dev/connect-protocol": "0.1.0-beta.23"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "^7.0.2",
|
|
30
30
|
"vitest": "^4.1.10",
|
|
31
|
-
"@mdbase-dev/connect-dev": "0.1.0-beta.
|
|
31
|
+
"@mdbase-dev/connect-dev": "0.1.0-beta.23"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|