@manablox/api-public 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -1
- package/dist/index.js +13 -2
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetCrop, FocalPoint, Manablox } from "@manablox/core";
|
|
1
|
+
import { AssetCrop, BlockGridSettings, BlockLayout, FocalPoint, Manablox } from "@manablox/core";
|
|
2
2
|
import { Loaders, MenuService } from "@manablox/services";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { MediaService } from "@manablox/media";
|
|
@@ -78,6 +78,13 @@ export interface PublicBlock {
|
|
|
78
78
|
blockId: string;
|
|
79
79
|
type: string;
|
|
80
80
|
fields: Record<string, unknown>;
|
|
81
|
+
/** Grid position, present only where the field lays blocks out on a grid. */
|
|
82
|
+
layout?: BlockLayout;
|
|
83
|
+
}
|
|
84
|
+
/** A `blocks` field as delivered: the grid per breakpoint, or `null` for a plain list, and the blocks. */
|
|
85
|
+
export interface PublicBlocks {
|
|
86
|
+
grid: BlockGridSettings | null;
|
|
87
|
+
blocks: PublicBlock[];
|
|
81
88
|
}
|
|
82
89
|
/** Which relation fields to inline rather than leave as ids. */
|
|
83
90
|
export type ExpandSet = ReadonlySet<string>;
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,15 @@ import { ManabloxError, TRANSPORT_CODE, fieldBlocks, resolveGraphQL } from "@man
|
|
|
2
2
|
import { toPublicListQuery } from "@manablox/services";
|
|
3
3
|
import { ORPCError, os } from "@orpc/server";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
import { isBlockGrid, resolveBlockGrid } from "@manablox/fields";
|
|
5
6
|
import { absoluteMediaUrl, readImageEdits } from "@manablox/media";
|
|
6
7
|
//#region src/serialize.ts
|
|
8
|
+
function blockGridOf(value) {
|
|
9
|
+
const raw = value?.grid;
|
|
10
|
+
if (!raw) return null;
|
|
11
|
+
const grid = resolveBlockGrid(raw);
|
|
12
|
+
return isBlockGrid(grid) ? grid : null;
|
|
13
|
+
}
|
|
7
14
|
function parseExpand(raw) {
|
|
8
15
|
if (!raw) return /* @__PURE__ */ new Set();
|
|
9
16
|
return new Set(raw.split(",").map((name) => name.trim()).filter(Boolean));
|
|
@@ -127,10 +134,14 @@ function buildFields(type, values, ctx, expand, resolved, depth) {
|
|
|
127
134
|
return {
|
|
128
135
|
blockId: block.blockId,
|
|
129
136
|
type: blockType?.name ?? "unknown",
|
|
130
|
-
fields: blockType ? buildFields(blockType, block.fields, ctx, expand, resolved, depth + 1) : {}
|
|
137
|
+
fields: blockType ? buildFields(blockType, block.fields, ctx, expand, resolved, depth + 1) : {},
|
|
138
|
+
...block.layout ? { layout: block.layout } : {}
|
|
131
139
|
};
|
|
132
140
|
});
|
|
133
|
-
out[field.name] = spec.list === false ? blocks[0] ?? null :
|
|
141
|
+
out[field.name] = spec.list === false ? blocks[0] ?? null : {
|
|
142
|
+
grid: blockGridOf(value),
|
|
143
|
+
blocks
|
|
144
|
+
};
|
|
134
145
|
continue;
|
|
135
146
|
}
|
|
136
147
|
if (spec.type.kind === "ref" && expand.has(field.name)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manablox/api-public",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@manablox/core": "0.
|
|
15
|
-
"@manablox/db": "0.
|
|
16
|
-
"@manablox/media": "0.
|
|
17
|
-
"@manablox/services": "0.
|
|
14
|
+
"@manablox/core": "0.5.0",
|
|
15
|
+
"@manablox/db": "0.5.0",
|
|
16
|
+
"@manablox/media": "0.5.0",
|
|
17
|
+
"@manablox/services": "0.5.0",
|
|
18
18
|
"@orpc/server": "^1.15.0",
|
|
19
19
|
"zod": "^4.5.4"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@manablox/config-typescript": "0.0.0",
|
|
23
|
-
"@manablox/fields": "0.
|
|
23
|
+
"@manablox/fields": "0.5.0",
|
|
24
24
|
"@types/node": "^26.4.1",
|
|
25
25
|
"tsdown": "^0.23.0",
|
|
26
26
|
"typescript": "^7.0.2",
|