@vitrine-kit/payload-blueprint 0.2.3 → 0.3.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 +4 -2
- package/dist/index.js +29 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlueprintFieldDef, Extend } from '@vitrine-kit/contracts';
|
|
2
2
|
|
|
3
|
-
declare const PAYLOAD_BLUEPRINT_VERSION: "0.
|
|
3
|
+
declare const PAYLOAD_BLUEPRINT_VERSION: "0.3.0";
|
|
4
4
|
|
|
5
5
|
interface BlueprintCollectionConfig {
|
|
6
6
|
slug: string;
|
|
@@ -20,7 +20,9 @@ declare const baseCollections: BlueprintCollectionConfig[];
|
|
|
20
20
|
|
|
21
21
|
interface Blueprint {
|
|
22
22
|
extend: Extend;
|
|
23
|
-
/**
|
|
23
|
+
/** Add a collection that is not in the base set (e.g. storefront customers). */
|
|
24
|
+
addCollection(config: BlueprintCollectionConfig): void;
|
|
25
|
+
/** Assembles the base collections + additive extensions + extras. */
|
|
24
26
|
build(): BlueprintCollectionConfig[];
|
|
25
27
|
}
|
|
26
28
|
declare function createBlueprint(): Blueprint;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.generated.ts
|
|
2
|
-
var PAYLOAD_BLUEPRINT_VERSION = "0.
|
|
2
|
+
var PAYLOAD_BLUEPRINT_VERSION = "0.3.0";
|
|
3
3
|
|
|
4
4
|
// src/collections.ts
|
|
5
5
|
var f = (name, type, extra = {}) => ({ name, type, ...extra });
|
|
@@ -11,9 +11,9 @@ var categoriesCollection = {
|
|
|
11
11
|
admin: { useAsTitle: "title" },
|
|
12
12
|
access: publicRead,
|
|
13
13
|
fields: [
|
|
14
|
-
f("title", "text", { required: true }),
|
|
14
|
+
f("title", "text", { required: true, localized: true }),
|
|
15
15
|
f("slug", "text", { required: true, unique: true, index: true }),
|
|
16
|
-
f("description", "textarea"),
|
|
16
|
+
f("description", "textarea", { localized: true }),
|
|
17
17
|
f("parent", "relationship", { relationTo: "categories" })
|
|
18
18
|
]
|
|
19
19
|
};
|
|
@@ -26,9 +26,11 @@ var mediaCollection = {
|
|
|
26
26
|
var usersCollection = {
|
|
27
27
|
slug: "users",
|
|
28
28
|
// maxLoginAttempts/lockTime — Payload's built-in brute-force lockout on the login endpoint.
|
|
29
|
+
// Auth already provides `email` + `password` — do not redeclare email (Payload 3 treats a
|
|
30
|
+
// second required email field as empty on create → "Email is required" during ensureDevAdmin).
|
|
29
31
|
auth: { maxLoginAttempts: 5, lockTime: 10 * 60 * 1e3 },
|
|
30
32
|
access: adminOnly,
|
|
31
|
-
fields: [
|
|
33
|
+
fields: []
|
|
32
34
|
};
|
|
33
35
|
var variantsCollection = {
|
|
34
36
|
slug: "variants",
|
|
@@ -49,13 +51,17 @@ var productsCollection = {
|
|
|
49
51
|
admin: { useAsTitle: "title" },
|
|
50
52
|
access: publicRead,
|
|
51
53
|
fields: [
|
|
52
|
-
f("title", "text", { required: true }),
|
|
54
|
+
f("title", "text", { required: true, localized: true }),
|
|
53
55
|
f("slug", "text", { required: true, unique: true, index: true }),
|
|
54
|
-
f("description", "richText"),
|
|
56
|
+
f("description", "richText", { localized: true }),
|
|
55
57
|
f("categories", "relationship", { relationTo: "categories", hasMany: true }),
|
|
56
58
|
f("images", "relationship", { relationTo: "media", hasMany: true }),
|
|
57
59
|
f("seo", "group", {
|
|
58
|
-
fields: [
|
|
60
|
+
fields: [
|
|
61
|
+
f("title", "text", { localized: true }),
|
|
62
|
+
f("description", "textarea", { localized: true }),
|
|
63
|
+
f("image", "relationship", { relationTo: "media" })
|
|
64
|
+
]
|
|
59
65
|
})
|
|
60
66
|
]
|
|
61
67
|
};
|
|
@@ -119,14 +125,27 @@ var SLUG_BY_COLLECTION = {
|
|
|
119
125
|
};
|
|
120
126
|
function createBlueprint() {
|
|
121
127
|
const additions = /* @__PURE__ */ new Map();
|
|
128
|
+
const extras = [];
|
|
122
129
|
const extend = (collection, patch) => {
|
|
123
130
|
const slug = SLUG_BY_COLLECTION[collection];
|
|
124
131
|
const list = additions.get(slug) ?? [];
|
|
125
132
|
list.push(...patch.addFields);
|
|
126
133
|
additions.set(slug, list);
|
|
127
134
|
};
|
|
135
|
+
function addCollection(config) {
|
|
136
|
+
const taken = /* @__PURE__ */ new Set([
|
|
137
|
+
...baseCollections.map((c) => c.slug),
|
|
138
|
+
...extras.map((c) => c.slug)
|
|
139
|
+
]);
|
|
140
|
+
if (taken.has(config.slug)) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`[vitrine] blueprint: collection "${config.slug}" already exists \u2014 addCollection() is additive only`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
extras.push(config);
|
|
146
|
+
}
|
|
128
147
|
function build() {
|
|
129
|
-
|
|
148
|
+
const extended = baseCollections.map((base) => {
|
|
130
149
|
const adds = additions.get(base.slug) ?? [];
|
|
131
150
|
if (adds.length === 0) return base;
|
|
132
151
|
const existing = new Set(base.fields.map((field) => field.name));
|
|
@@ -140,8 +159,9 @@ function createBlueprint() {
|
|
|
140
159
|
}
|
|
141
160
|
return { ...base, fields: [...base.fields, ...adds] };
|
|
142
161
|
});
|
|
162
|
+
return [...extended, ...extras];
|
|
143
163
|
}
|
|
144
|
-
return { extend, build };
|
|
164
|
+
return { extend, addCollection, build };
|
|
145
165
|
}
|
|
146
166
|
export {
|
|
147
167
|
PAYLOAD_BLUEPRINT_VERSION,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrine-kit/payload-blueprint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Vitrine — base Payload collections + additive extend().",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"directory": "packages/payload-blueprint"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@vitrine-kit/contracts": "1.
|
|
32
|
+
"@vitrine-kit/contracts": "1.3.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "node scripts/generate-version.mjs && tsup src/index.ts --format esm --dts --clean",
|