@vitrine-kit/payload-blueprint 0.2.0 → 0.2.2
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/README.md +2 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# @vitrine-kit/payload-blueprint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vitrine's base Payload collections and the `extend()` API for **additively** extending their fields from features (contract 5, spec §5).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Скелет (M0). Наполняется в M2.
|
|
5
|
+
A feature adds fields (`extend('product', { addFields })`) without breaking existing ones. Shipped as a versioned package.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { BlueprintFieldDef, Extend } from '@vitrine-kit/contracts';
|
|
2
2
|
|
|
3
|
+
declare const PAYLOAD_BLUEPRINT_VERSION: "0.2.2";
|
|
4
|
+
|
|
3
5
|
interface BlueprintCollectionConfig {
|
|
4
6
|
slug: string;
|
|
5
7
|
fields: BlueprintFieldDef[];
|
|
6
|
-
/**
|
|
8
|
+
/** Other Payload collection options (admin, access, hooks, upload, auth, …). */
|
|
7
9
|
[option: string]: unknown;
|
|
8
10
|
}
|
|
9
11
|
declare const categoriesCollection: BlueprintCollectionConfig;
|
|
@@ -13,16 +15,14 @@ declare const variantsCollection: BlueprintCollectionConfig;
|
|
|
13
15
|
declare const productsCollection: BlueprintCollectionConfig;
|
|
14
16
|
declare const ordersCollection: BlueprintCollectionConfig;
|
|
15
17
|
declare const cartsCollection: BlueprintCollectionConfig;
|
|
16
|
-
/**
|
|
18
|
+
/** Base collections in a stable order. */
|
|
17
19
|
declare const baseCollections: BlueprintCollectionConfig[];
|
|
18
20
|
|
|
19
21
|
interface Blueprint {
|
|
20
22
|
extend: Extend;
|
|
21
|
-
/**
|
|
23
|
+
/** Assembles the base collections + additive extensions. */
|
|
22
24
|
build(): BlueprintCollectionConfig[];
|
|
23
25
|
}
|
|
24
26
|
declare function createBlueprint(): Blueprint;
|
|
25
27
|
|
|
26
|
-
declare const PAYLOAD_BLUEPRINT_VERSION: "0.1.0";
|
|
27
|
-
|
|
28
28
|
export { type Blueprint, type BlueprintCollectionConfig, PAYLOAD_BLUEPRINT_VERSION, baseCollections, cartsCollection, categoriesCollection, createBlueprint, mediaCollection, ordersCollection, productsCollection, usersCollection, variantsCollection };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/version.generated.ts
|
|
2
|
+
var PAYLOAD_BLUEPRINT_VERSION = "0.2.2";
|
|
3
|
+
|
|
1
4
|
// src/collections.ts
|
|
2
5
|
var f = (name, type, extra = {}) => ({ name, type, ...extra });
|
|
3
6
|
var authenticated = ({ req }) => Boolean(req?.user);
|
|
@@ -29,7 +32,7 @@ var variantsCollection = {
|
|
|
29
32
|
f("sku", "text", { required: true, unique: true, index: true }),
|
|
30
33
|
f("product", "relationship", { relationTo: "products", required: true }),
|
|
31
34
|
f("price", "number", { required: true }),
|
|
32
|
-
//
|
|
35
|
+
// minor units (e.g. cents)
|
|
33
36
|
f("stock", "number"),
|
|
34
37
|
f("options", "json")
|
|
35
38
|
// { size: 'M', color: 'red' }
|
|
@@ -66,7 +69,7 @@ var ordersCollection = {
|
|
|
66
69
|
f("paymentProvider", "text"),
|
|
67
70
|
// 'stripe' | 'paddle' | 'yookassa'
|
|
68
71
|
f("paymentRef", "text", { index: true }),
|
|
69
|
-
//
|
|
72
|
+
// webhook idempotency (dedup by payment reference)
|
|
70
73
|
f("createdAt", "date")
|
|
71
74
|
]
|
|
72
75
|
};
|
|
@@ -76,7 +79,7 @@ var cartsCollection = {
|
|
|
76
79
|
access: adminOnly,
|
|
77
80
|
fields: [
|
|
78
81
|
f("lines", "json"),
|
|
79
|
-
// CartLine[] (
|
|
82
|
+
// CartLine[] (contract); arithmetic lives in @vitrine-kit/core
|
|
80
83
|
f("currency", "text"),
|
|
81
84
|
f("subtotal", "number"),
|
|
82
85
|
f("discountTotal", "number"),
|
|
@@ -123,7 +126,7 @@ function createBlueprint() {
|
|
|
123
126
|
for (const field of adds) {
|
|
124
127
|
if (existing.has(field.name)) {
|
|
125
128
|
throw new Error(
|
|
126
|
-
`[vitrine] blueprint:
|
|
129
|
+
`[vitrine] blueprint: field "${field.name}" already exists in "${base.slug}" \u2014 extend() is additive only`
|
|
127
130
|
);
|
|
128
131
|
}
|
|
129
132
|
existing.add(field.name);
|
|
@@ -133,9 +136,6 @@ function createBlueprint() {
|
|
|
133
136
|
}
|
|
134
137
|
return { extend, build };
|
|
135
138
|
}
|
|
136
|
-
|
|
137
|
-
// src/index.ts
|
|
138
|
-
var PAYLOAD_BLUEPRINT_VERSION = "0.1.0";
|
|
139
139
|
export {
|
|
140
140
|
PAYLOAD_BLUEPRINT_VERSION,
|
|
141
141
|
baseCollections,
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrine-kit/payload-blueprint",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Vitrine —
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Vitrine — base Payload collections + additive extend().",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
7
11
|
"types": "./dist/index.d.ts",
|
|
8
12
|
"main": "./dist/index.js",
|
|
9
13
|
"module": "./dist/index.js",
|
|
@@ -25,11 +29,11 @@
|
|
|
25
29
|
"directory": "packages/payload-blueprint"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
|
-
"@vitrine-kit/contracts": "1.1
|
|
32
|
+
"@vitrine-kit/contracts": "1.2.1"
|
|
29
33
|
},
|
|
30
34
|
"scripts": {
|
|
31
|
-
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
32
|
-
"typecheck": "tsc --noEmit",
|
|
35
|
+
"build": "node scripts/generate-version.mjs && tsup src/index.ts --format esm --dts --clean",
|
|
36
|
+
"typecheck": "node scripts/generate-version.mjs && tsc --noEmit",
|
|
33
37
|
"test": "vitest run --passWithNoTests"
|
|
34
38
|
}
|
|
35
39
|
}
|