@nexload-sdk/payload-fields 3.1.0 → 4.0.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/README.md +196 -17
- package/dist/address/index.d.ts +13 -0
- package/dist/address/index.d.ts.map +1 -0
- package/dist/admin/formatted-cell.d.ts +6 -0
- package/dist/admin/formatted-cell.d.ts.map +1 -0
- package/dist/admin/formatted-cell.js +18 -0
- package/dist/admin/formatted-cell.js.map +7 -0
- package/dist/admin/jalali-date-cell.d.ts +3 -3
- package/dist/admin/jalali-date-cell.d.ts.map +1 -1
- package/dist/admin/jalali-date-cell.js +27 -0
- package/dist/admin/jalali-date-cell.js.map +7 -0
- package/dist/admin/jalali-date-field.d.ts +4 -3
- package/dist/admin/jalali-date-field.d.ts.map +1 -1
- package/dist/admin/jalali-date-field.js +250 -0
- package/dist/admin/jalali-date-field.js.map +7 -0
- package/dist/admin/money-cell.d.ts +10 -0
- package/dist/admin/money-cell.d.ts.map +1 -0
- package/dist/admin/money-cell.js +124 -0
- package/dist/admin/money-cell.js.map +7 -0
- package/dist/admin/money-field.d.ts +3 -2
- package/dist/admin/money-field.d.ts.map +1 -1
- package/dist/admin/money-field.js +183 -0
- package/dist/admin/money-field.js.map +7 -0
- package/dist/admin/slug-field.d.ts.map +1 -1
- package/dist/admin/slug-field.js +210 -0
- package/dist/admin/slug-field.js.map +7 -0
- package/dist/admin/validated-text-field.d.ts +6 -0
- package/dist/admin/validated-text-field.d.ts.map +1 -0
- package/dist/admin/validated-text-field.js +35 -0
- package/dist/admin/validated-text-field.js.map +7 -0
- package/dist/bank/index.d.ts +7 -0
- package/dist/bank/index.d.ts.map +1 -0
- package/dist/common/index.d.ts +35 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/contact/index.d.ts +9 -0
- package/dist/contact/index.d.ts.map +1 -0
- package/dist/date/format-date.d.ts.map +1 -1
- package/dist/date/index.d.ts +37 -4
- package/dist/date/index.d.ts.map +1 -1
- package/dist/date/index.js +258 -0
- package/dist/date/index.js.map +7 -0
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +97 -0
- package/dist/i18n/messages.js.map +7 -0
- package/dist/identity/index.d.ts +9 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1038 -0
- package/dist/index.js.map +7 -0
- package/dist/internal/protect.d.ts +7 -0
- package/dist/internal/protect.d.ts.map +1 -0
- package/dist/internal/validated-text.d.ts +24 -0
- package/dist/internal/validated-text.d.ts.map +1 -0
- package/dist/internal/validated-text.js +161 -0
- package/dist/internal/validated-text.js.map +7 -0
- package/dist/money/index.d.ts +6 -0
- package/dist/money/index.d.ts.map +1 -1
- package/dist/money/index.js +212 -0
- package/dist/money/index.js.map +7 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/schema/index.d.ts +51 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +735 -0
- package/dist/schema/index.js.map +7 -0
- package/dist/slug/format-slug.d.ts +1 -1
- package/dist/slug/format-slug.d.ts.map +1 -1
- package/dist/slug/index.d.ts +1 -0
- package/dist/slug/index.d.ts.map +1 -1
- package/dist/slug/{index.mjs → index.js} +47 -43
- package/dist/slug/index.js.map +7 -0
- package/package.json +64 -27
- package/dist/admin/jalali-date-cell.cjs +0 -58
- package/dist/admin/jalali-date-cell.cjs.map +0 -7
- package/dist/admin/jalali-date-cell.mjs +0 -32
- package/dist/admin/jalali-date-cell.mjs.map +0 -7
- package/dist/admin/jalali-date-field.cjs +0 -159
- package/dist/admin/jalali-date-field.cjs.map +0 -7
- package/dist/admin/jalali-date-field.mjs +0 -135
- package/dist/admin/jalali-date-field.mjs.map +0 -7
- package/dist/admin/jalali-picker-value.cjs +0 -42
- package/dist/admin/jalali-picker-value.cjs.map +0 -7
- package/dist/admin/jalali-picker-value.d.ts +0 -3
- package/dist/admin/jalali-picker-value.d.ts.map +0 -1
- package/dist/admin/jalali-picker-value.mjs +0 -18
- package/dist/admin/jalali-picker-value.mjs.map +0 -7
- package/dist/admin/money-field.cjs +0 -146
- package/dist/admin/money-field.cjs.map +0 -7
- package/dist/admin/money-field.mjs +0 -122
- package/dist/admin/money-field.mjs.map +0 -7
- package/dist/admin/slug-field.cjs +0 -135
- package/dist/admin/slug-field.cjs.map +0 -7
- package/dist/admin/slug-field.mjs +0 -115
- package/dist/admin/slug-field.mjs.map +0 -7
- package/dist/date/index.cjs +0 -117
- package/dist/date/index.cjs.map +0 -7
- package/dist/date/index.mjs +0 -86
- package/dist/date/index.mjs.map +0 -7
- package/dist/index.cjs +0 -469
- package/dist/index.cjs.map +0 -7
- package/dist/index.mjs +0 -425
- package/dist/index.mjs.map +0 -7
- package/dist/money/index.cjs +0 -147
- package/dist/money/index.cjs.map +0 -7
- package/dist/money/index.mjs +0 -117
- package/dist/money/index.mjs.map +0 -7
- package/dist/slug/index.cjs +0 -183
- package/dist/slug/index.cjs.map +0 -7
- package/dist/slug/index.mjs.map +0 -7
package/dist/date/index.mjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/date/format-date.ts", "../../src/date/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type JalaliDateValue = Date | string | number | null | undefined;\nexport type JalaliDateDisplayOptions = {\n dateStyle?: \"short\" | \"medium\" | \"long\" | \"full\"\n timeStyle?: \"short\" | \"medium\"\n digits?: \"persian\" | \"latin\"\n timeZone?: string\n};\n\nexport function formatJalaliDate (\n value: JalaliDateValue, options: JalaliDateDisplayOptions = {}\n): string | null {\n if (value === null || value === undefined) return null;\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n const locale = options.digits === \"latin\" ? \"fa-IR-u-ca-persian-nu-latn\" : \"fa-IR-u-ca-persian\";\n return new Intl.DateTimeFormat(\n locale, {\n dateStyle: options.dateStyle ?? \"medium\",\n ...(options.timeStyle ? { timeStyle: options.timeStyle, } : {}),\n ...(options.timeZone ? { timeZone: options.timeZone, } : {}),\n }\n ).format(date);\n}\n", "import { formatJalaliDate } from \"./format-date\";\n\nimport type { JalaliPickerAppearance } from \"./picker-types\";\nimport type { DateField, Field, TextField } from \"payload\";\n\nexport type { JalaliDateDisplayOptions, JalaliDateValue } from \"./format-date\";\nexport type { JalaliPickerAppearance } from \"./picker-types\";\nexport type JalaliDateFieldOptions = {\n name: string\n pickerAppearance?: JalaliPickerAppearance\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: Partial<DateField>\n};\nexport type JalaliTimestampsOptions = {\n createdAt?: boolean\n updatedAt?: boolean\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: { createdAt?: Partial<TextField>, updatedAt?: Partial<TextField> }\n};\n\nexport function jalaliDateField (options: JalaliDateFieldOptions): DateField {\n const overrides = options.overrides ?? {};\n if (overrides.name && overrides.name !== options.name) throw new Error(\"Jalali date field name is protected.\");\n if (overrides.type && overrides.type !== \"date\") throw new Error(\"Jalali date field type is protected.\");\n const appearance = options.pickerAppearance ?? \"dayOnly\";\n const display = {\n digits: \"persian\" as const,\n dateStyle: \"medium\" as const,\n ...(\n appearance === \"dayAndTime\" || appearance === \"timeOnly\"\n ? { timeStyle: \"short\" as const, }\n : {}\n ),\n ...options.display,\n };\n return {\n ...overrides,\n name: options.name,\n type: \"date\",\n admin: {\n ...overrides.admin,\n date: { ...overrides.admin?.date, pickerAppearance: appearance, },\n components: {\n ...overrides.admin?.components,\n Field: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-field#JalaliDateFieldComponent\", clientProps: { appearance, display, }, },\n Cell: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-cell#JalaliDateCell\", clientProps: { display, }, },\n },\n },\n custom: { ...overrides.custom, nexload: { ...(overrides.custom?.nexload as object), jalaliDate: { appearance, display, }, }, },\n } as DateField;\n}\n\nexport function withJalaliTimestamps<T extends Field[]> (\n fields: T, options: JalaliTimestampsOptions = {}\n): Field[] {\n const output = [...fields];\n const add = (\n name: \"createdAtJalali\" | \"updatedAtJalali\", source: \"createdAt\" | \"updatedAt\", override?: Partial<TextField>\n ) => {\n if (output.some((field) => \"name\" in field && field.name === name)) throw new Error(`Duplicate Jalali timestamp field: ${name}`);\n output.push({\n ...override,\n name,\n type: \"text\",\n virtual: true,\n admin: { ...override?.admin, readOnly: true, },\n hooks: {\n ...override?.hooks, afterRead: [\n ...(override?.hooks?.afterRead ?? []),\n ({ siblingData, }) => formatJalaliDate(\n siblingData?.[source] as import(\"./format-date\").JalaliDateValue, options.display\n )\n ],\n },\n } as TextField);\n };\n if (options.createdAt !== false) add(\n \"createdAtJalali\", \"createdAt\", options.overrides?.createdAt\n );\n if (options.updatedAt !== false) add(\n \"updatedAtJalali\", \"updatedAt\", options.overrides?.updatedAt\n );\n return output;\n}\n\nexport { formatJalaliDate };\n"],
|
|
5
|
-
"mappings": ";;;AAQO,SAAS,iBACd,OAAwB,UAAoC,CAAC,GAC9C;AACf,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,QAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;AAC3D,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,QAAM,SAAS,QAAQ,WAAW,UAAU,+BAA+B;AAC3E,SAAO,IAAI,KAAK;AAAA,IACd;AAAA,IAAQ;AAAA,MACN,WAAW,QAAQ,aAAa;AAAA,MAChC,GAAI,QAAQ,YAAY,EAAE,WAAW,QAAQ,UAAW,IAAI,CAAC;AAAA,MAC7D,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAU,IAAI,CAAC;AAAA,IAC5D;AAAA,EACF,EAAE,OAAO,IAAI;AACf;;;ACFO,SAAS,gBAAiB,SAA4C;AAC3E,QAAM,YAAY,QAAQ,aAAa,CAAC;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C,OAAO;AAAA,QACL,GAAG,UAAU;AAAA,QAAO,WAAW;AAAA,UAC7B,GAAI,UAAU,OAAO,aAAa,CAAC;AAAA,UACnC,CAAC,EAAE,YAAa,MAAM;AAAA,YACpB,cAAc,MAAM;AAAA,YAA8C,QAAQ;AAAA,UAC5E;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAc;AAAA,EAChB;AACA,MAAI,QAAQ,cAAc,MAAO;AAAA,IAC/B;AAAA,IAAmB;AAAA,IAAa,QAAQ,WAAW;AAAA,EACrD;AACA,MAAI,QAAQ,cAAc,MAAO;AAAA,IAC/B;AAAA,IAAmB;AAAA,IAAa,QAAQ,WAAW;AAAA,EACrD;AACA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/index.cjs
DELETED
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
// @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:57.614Z)
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var index_exports = {};
|
|
23
|
-
__export(index_exports, {
|
|
24
|
-
IRR: () => IRR,
|
|
25
|
-
IRT: () => IRT,
|
|
26
|
-
formatJalaliDate: () => formatJalaliDate,
|
|
27
|
-
formatMoney: () => formatMoney,
|
|
28
|
-
formatSlug: () => formatSlug,
|
|
29
|
-
formatSlugHook: () => formatSlugHook,
|
|
30
|
-
jalaliDateField: () => jalaliDateField,
|
|
31
|
-
moneyField: () => moneyField,
|
|
32
|
-
parseMoneyToMinorUnits: () => parseMoneyToMinorUnits,
|
|
33
|
-
payloadFieldsPlugin: () => payloadFieldsPlugin,
|
|
34
|
-
resolveCurrency: () => resolveCurrency,
|
|
35
|
-
slugField: () => slugField,
|
|
36
|
-
withJalaliTimestamps: () => withJalaliTimestamps
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
|
|
40
|
-
// src/slug/format-slug.ts
|
|
41
|
-
var persianDigits = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
|
|
42
|
-
var arabicDigits = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
|
|
43
|
-
function normalizeDigits(value) {
|
|
44
|
-
return value.replace(
|
|
45
|
-
/[۰-۹٠-٩]/g,
|
|
46
|
-
(digit) => {
|
|
47
|
-
const index = persianDigits.indexOf(digit);
|
|
48
|
-
return String(index >= 0 ? index : arabicDigits.indexOf(digit));
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
function getPath(value, path) {
|
|
53
|
-
return path.split(".").reduce(
|
|
54
|
-
(current, key) => {
|
|
55
|
-
if (current && typeof current === "object") return current[key];
|
|
56
|
-
return void 0;
|
|
57
|
-
},
|
|
58
|
-
value
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
function hasPath(value, path) {
|
|
62
|
-
return path.split(".").every((key) => {
|
|
63
|
-
if (!value || typeof value !== "object" || !(key in value)) return false;
|
|
64
|
-
value = value[key];
|
|
65
|
-
return true;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function formatSlug(value) {
|
|
69
|
-
return normalizeDigits(value.normalize("NFKC")).replace(
|
|
70
|
-
/[يى]/g,
|
|
71
|
-
"\u06CC"
|
|
72
|
-
).replace(
|
|
73
|
-
/ك/g,
|
|
74
|
-
"\u06A9"
|
|
75
|
-
).replace(
|
|
76
|
-
/[\u064B-\u065F\u0670]/g,
|
|
77
|
-
""
|
|
78
|
-
).replace(
|
|
79
|
-
/[\s_]+/g,
|
|
80
|
-
"-"
|
|
81
|
-
).replace(
|
|
82
|
-
/[^\p{L}\p{N}-]+/gu,
|
|
83
|
-
""
|
|
84
|
-
).replace(
|
|
85
|
-
/-+/g,
|
|
86
|
-
"-"
|
|
87
|
-
).replace(
|
|
88
|
-
/^-+|-+$/g,
|
|
89
|
-
""
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
var formatSlugHook = (options) => ({
|
|
93
|
-
data,
|
|
94
|
-
operation,
|
|
95
|
-
originalDoc,
|
|
96
|
-
siblingData,
|
|
97
|
-
previousSiblingDoc,
|
|
98
|
-
value
|
|
99
|
-
}) => {
|
|
100
|
-
const lock = (siblingData == null ? void 0 : siblingData[options.lockName]) ?? (data == null ? void 0 : data[options.lockName]);
|
|
101
|
-
const previousSlug = (previousSiblingDoc == null ? void 0 : previousSiblingDoc[options.name]) ?? (originalDoc == null ? void 0 : originalDoc[options.name]);
|
|
102
|
-
const sourceChanged = hasPath(
|
|
103
|
-
data,
|
|
104
|
-
options.source
|
|
105
|
-
) && getPath(
|
|
106
|
-
data,
|
|
107
|
-
options.source
|
|
108
|
-
) !== getPath(
|
|
109
|
-
originalDoc,
|
|
110
|
-
options.source
|
|
111
|
-
);
|
|
112
|
-
const source = hasPath(
|
|
113
|
-
data,
|
|
114
|
-
options.source
|
|
115
|
-
) ? getPath(
|
|
116
|
-
data,
|
|
117
|
-
options.source
|
|
118
|
-
) : getPath(
|
|
119
|
-
originalDoc,
|
|
120
|
-
options.source
|
|
121
|
-
);
|
|
122
|
-
if (lock !== false && typeof source === "string" && source.trim() && (operation === "create" || options.regenerateOnSourceChange && sourceChanged)) {
|
|
123
|
-
return formatSlug(source);
|
|
124
|
-
}
|
|
125
|
-
if (operation === "update" && lock !== false && sourceChanged && !source && previousSlug !== void 0) {
|
|
126
|
-
return previousSlug;
|
|
127
|
-
}
|
|
128
|
-
if (lock !== false && operation === "update" && previousSlug !== void 0) return previousSlug;
|
|
129
|
-
if (typeof value === "string") return formatSlug(value);
|
|
130
|
-
return value;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// src/slug/index.ts
|
|
134
|
-
function slugField(options = {}) {
|
|
135
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
136
|
-
const name = options.name ?? "slug";
|
|
137
|
-
const lockName = options.lockName ?? `${name}Lock`;
|
|
138
|
-
const source = options.source ?? "title";
|
|
139
|
-
const localized = ((_b = (_a = options.overrides) == null ? void 0 : _a.slug) == null ? void 0 : _b.localized) === true;
|
|
140
|
-
if (((_d = (_c = options.overrides) == null ? void 0 : _c.slug) == null ? void 0 : _d.name) && options.overrides.slug.name !== name) throw new Error("Slug field name is protected.");
|
|
141
|
-
if (((_f = (_e = options.overrides) == null ? void 0 : _e.lock) == null ? void 0 : _f.name) && options.overrides.lock.name !== lockName) throw new Error("Slug lock name is protected.");
|
|
142
|
-
if (((_h = (_g = options.overrides) == null ? void 0 : _g.lock) == null ? void 0 : _h.localized) !== void 0 && options.overrides.lock.localized !== localized) throw new Error("Slug lock localization must match slug localization.");
|
|
143
|
-
if (((_j = (_i = options.overrides) == null ? void 0 : _i.slug) == null ? void 0 : _j.type) && options.overrides.slug.type !== "text") throw new Error("Slug field type is protected.");
|
|
144
|
-
if (((_l = (_k = options.overrides) == null ? void 0 : _k.lock) == null ? void 0 : _l.type) && options.overrides.lock.type !== "checkbox") throw new Error("Slug lock type is protected.");
|
|
145
|
-
const slugOverrides = ((_m = options.overrides) == null ? void 0 : _m.slug) ?? {};
|
|
146
|
-
const lockOverrides = ((_n = options.overrides) == null ? void 0 : _n.lock) ?? {};
|
|
147
|
-
const consumerHooks = ((_o = slugOverrides.hooks) == null ? void 0 : _o.beforeValidate) ?? [];
|
|
148
|
-
const slug = {
|
|
149
|
-
...slugOverrides,
|
|
150
|
-
name,
|
|
151
|
-
type: "text",
|
|
152
|
-
index: slugOverrides.index ?? true,
|
|
153
|
-
localized,
|
|
154
|
-
admin: {
|
|
155
|
-
...slugOverrides.admin,
|
|
156
|
-
position: ((_p = slugOverrides.admin) == null ? void 0 : _p.position) ?? "sidebar",
|
|
157
|
-
components: {
|
|
158
|
-
...(_q = slugOverrides.admin) == null ? void 0 : _q.components,
|
|
159
|
-
Field: {
|
|
160
|
-
path: "@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent",
|
|
161
|
-
clientProps: { source, lockName, generator: options.generator }
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
custom: { ...slugOverrides.custom, nexload: { ...(_r = slugOverrides.custom) == null ? void 0 : _r.nexload, slug: { source, lockName, generator: options.generator } } },
|
|
166
|
-
hooks: {
|
|
167
|
-
...slugOverrides.hooks,
|
|
168
|
-
beforeValidate: [
|
|
169
|
-
...consumerHooks,
|
|
170
|
-
formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true })
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const lock = {
|
|
175
|
-
...lockOverrides,
|
|
176
|
-
name: lockName,
|
|
177
|
-
type: "checkbox",
|
|
178
|
-
localized,
|
|
179
|
-
defaultValue: true,
|
|
180
|
-
admin: { ...lockOverrides.admin, hidden: true, position: ((_s = lockOverrides.admin) == null ? void 0 : _s.position) ?? "sidebar" }
|
|
181
|
-
};
|
|
182
|
-
return [
|
|
183
|
-
slug,
|
|
184
|
-
lock
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// src/date/format-date.ts
|
|
189
|
-
function formatJalaliDate(value, options = {}) {
|
|
190
|
-
if (value === null || value === void 0) return null;
|
|
191
|
-
const date = value instanceof Date ? value : new Date(value);
|
|
192
|
-
if (Number.isNaN(date.getTime())) return null;
|
|
193
|
-
const locale = options.digits === "latin" ? "fa-IR-u-ca-persian-nu-latn" : "fa-IR-u-ca-persian";
|
|
194
|
-
return new Intl.DateTimeFormat(
|
|
195
|
-
locale,
|
|
196
|
-
{
|
|
197
|
-
dateStyle: options.dateStyle ?? "medium",
|
|
198
|
-
...options.timeStyle ? { timeStyle: options.timeStyle } : {},
|
|
199
|
-
...options.timeZone ? { timeZone: options.timeZone } : {}
|
|
200
|
-
}
|
|
201
|
-
).format(date);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/date/index.ts
|
|
205
|
-
function jalaliDateField(options) {
|
|
206
|
-
var _a, _b, _c;
|
|
207
|
-
const overrides = options.overrides ?? {};
|
|
208
|
-
if (overrides.name && overrides.name !== options.name) throw new Error("Jalali date field name is protected.");
|
|
209
|
-
if (overrides.type && overrides.type !== "date") throw new Error("Jalali date field type is protected.");
|
|
210
|
-
const appearance = options.pickerAppearance ?? "dayOnly";
|
|
211
|
-
const display = {
|
|
212
|
-
digits: "persian",
|
|
213
|
-
dateStyle: "medium",
|
|
214
|
-
...appearance === "dayAndTime" || appearance === "timeOnly" ? { timeStyle: "short" } : {},
|
|
215
|
-
...options.display
|
|
216
|
-
};
|
|
217
|
-
return {
|
|
218
|
-
...overrides,
|
|
219
|
-
name: options.name,
|
|
220
|
-
type: "date",
|
|
221
|
-
admin: {
|
|
222
|
-
...overrides.admin,
|
|
223
|
-
date: { ...(_a = overrides.admin) == null ? void 0 : _a.date, pickerAppearance: appearance },
|
|
224
|
-
components: {
|
|
225
|
-
...(_b = overrides.admin) == null ? void 0 : _b.components,
|
|
226
|
-
Field: { path: "@nexload-sdk/payload-fields/admin/jalali-date-field#JalaliDateFieldComponent", clientProps: { appearance, display } },
|
|
227
|
-
Cell: { path: "@nexload-sdk/payload-fields/admin/jalali-date-cell#JalaliDateCell", clientProps: { display } }
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
custom: { ...overrides.custom, nexload: { ...(_c = overrides.custom) == null ? void 0 : _c.nexload, jalaliDate: { appearance, display } } }
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
function withJalaliTimestamps(fields, options = {}) {
|
|
234
|
-
var _a, _b;
|
|
235
|
-
const output = [...fields];
|
|
236
|
-
const add = (name, source, override) => {
|
|
237
|
-
var _a2;
|
|
238
|
-
if (output.some((field) => "name" in field && field.name === name)) throw new Error(`Duplicate Jalali timestamp field: ${name}`);
|
|
239
|
-
output.push({
|
|
240
|
-
...override,
|
|
241
|
-
name,
|
|
242
|
-
type: "text",
|
|
243
|
-
virtual: true,
|
|
244
|
-
admin: { ...override == null ? void 0 : override.admin, readOnly: true },
|
|
245
|
-
hooks: {
|
|
246
|
-
...override == null ? void 0 : override.hooks,
|
|
247
|
-
afterRead: [
|
|
248
|
-
...((_a2 = override == null ? void 0 : override.hooks) == null ? void 0 : _a2.afterRead) ?? [],
|
|
249
|
-
({ siblingData }) => formatJalaliDate(
|
|
250
|
-
siblingData == null ? void 0 : siblingData[source],
|
|
251
|
-
options.display
|
|
252
|
-
)
|
|
253
|
-
]
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
if (options.createdAt !== false) add(
|
|
258
|
-
"createdAtJalali",
|
|
259
|
-
"createdAt",
|
|
260
|
-
(_a = options.overrides) == null ? void 0 : _a.createdAt
|
|
261
|
-
);
|
|
262
|
-
if (options.updatedAt !== false) add(
|
|
263
|
-
"updatedAtJalali",
|
|
264
|
-
"updatedAt",
|
|
265
|
-
(_b = options.overrides) == null ? void 0 : _b.updatedAt
|
|
266
|
-
);
|
|
267
|
-
return output;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// src/money/index.ts
|
|
271
|
-
var IRR = { code: "IRR", label: "\u0631\u06CC\u0627\u0644", fractionDigits: 0 };
|
|
272
|
-
var IRT = { code: "IRT", label: "\u062A\u0648\u0645\u0627\u0646", fractionDigits: 0 };
|
|
273
|
-
function resolveCurrency(currency) {
|
|
274
|
-
const result = currency === "IRR" ? IRR : currency === "IRT" ? IRT : currency;
|
|
275
|
-
if (!result.code.trim() || !result.label.trim() || !Number.isInteger(result.fractionDigits) || result.fractionDigits < 0 || result.fractionDigits > 20) throw new Error("Invalid money currency definition.");
|
|
276
|
-
return result;
|
|
277
|
-
}
|
|
278
|
-
function normalizedNumber(value) {
|
|
279
|
-
const persian = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
|
|
280
|
-
const arabic = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
|
|
281
|
-
return value.trim().replace(
|
|
282
|
-
/[۰-۹٠-٩]/g,
|
|
283
|
-
(digit) => String(Math.max(
|
|
284
|
-
persian.indexOf(digit),
|
|
285
|
-
arabic.indexOf(digit)
|
|
286
|
-
) % 10)
|
|
287
|
-
).replace(
|
|
288
|
-
/[٬,\s]/g,
|
|
289
|
-
""
|
|
290
|
-
).replace(
|
|
291
|
-
/٫/g,
|
|
292
|
-
"."
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
function parseMoneyToMinorUnits(input, currency) {
|
|
296
|
-
const definition = resolveCurrency(currency);
|
|
297
|
-
const value = normalizedNumber(input);
|
|
298
|
-
if (!/^-?\d+(?:\.\d+)?$/.test(value)) throw new TypeError("Invalid money input.");
|
|
299
|
-
const negative = value.startsWith("-");
|
|
300
|
-
const [
|
|
301
|
-
whole,
|
|
302
|
-
fraction = ""
|
|
303
|
-
] = (negative ? value.slice(1) : value).split(".");
|
|
304
|
-
if (fraction.length > definition.fractionDigits) throw new RangeError("Money input has unsupported precision.");
|
|
305
|
-
const digits = `${whole}${fraction.padEnd(
|
|
306
|
-
definition.fractionDigits,
|
|
307
|
-
"0"
|
|
308
|
-
)}`.replace(
|
|
309
|
-
/^0+(?=\d)/,
|
|
310
|
-
""
|
|
311
|
-
) || "0";
|
|
312
|
-
const minor = Number(`${negative ? "-" : ""}${digits}`);
|
|
313
|
-
if (!Number.isSafeInteger(minor)) throw new RangeError("Money value is outside the safe integer range.");
|
|
314
|
-
return minor;
|
|
315
|
-
}
|
|
316
|
-
function formatMoney(value, currency, display = {}) {
|
|
317
|
-
if (value === null || value === void 0) return null;
|
|
318
|
-
if (!Number.isSafeInteger(value)) throw new RangeError("Money value is outside the safe integer range.");
|
|
319
|
-
const definition = resolveCurrency(currency);
|
|
320
|
-
const locale = display.locale ?? (display.digits === "latin" ? "fa-IR-u-nu-latn" : "fa-IR");
|
|
321
|
-
const major = value / 10 ** definition.fractionDigits;
|
|
322
|
-
const formatted = new Intl.NumberFormat(
|
|
323
|
-
locale,
|
|
324
|
-
{ useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits }
|
|
325
|
-
).format(major);
|
|
326
|
-
return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;
|
|
327
|
-
}
|
|
328
|
-
function moneyField(options) {
|
|
329
|
-
var _a, _b;
|
|
330
|
-
const overrides = options.overrides ?? {};
|
|
331
|
-
if (overrides.name && overrides.name !== options.name) throw new Error("Money field name is protected.");
|
|
332
|
-
if (overrides.type && overrides.type !== "number") throw new Error("Money field type is protected.");
|
|
333
|
-
const currency = resolveCurrency(options.currency);
|
|
334
|
-
if (options.minMinorUnits !== void 0 && (!Number.isSafeInteger(options.minMinorUnits) || options.maxMinorUnits !== void 0 && options.minMinorUnits > options.maxMinorUnits)) throw new Error("Invalid money bounds.");
|
|
335
|
-
if (options.maxMinorUnits !== void 0 && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error("Invalid money bounds.");
|
|
336
|
-
const consumerValidate = overrides.validate;
|
|
337
|
-
const validate = (value, args) => {
|
|
338
|
-
if (value === null || value === void 0 || value === "") return (args == null ? void 0 : args.required) ? "\u0648\u0627\u0631\u062F \u06A9\u0631\u062F\u0646 \u0645\u0628\u0644\u063A \u0627\u0644\u0632\u0627\u0645\u06CC \u0627\u0633\u062A." : true;
|
|
339
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value)) return "\u0645\u0628\u0644\u063A \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F.";
|
|
340
|
-
if (!options.allowNegative && value < 0) return "\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.";
|
|
341
|
-
if (options.minMinorUnits !== void 0 && value < options.minMinorUnits) return "\u0645\u0628\u0644\u063A \u06A9\u0645\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.";
|
|
342
|
-
if (options.maxMinorUnits !== void 0 && value > options.maxMinorUnits) return "\u0645\u0628\u0644\u063A \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.";
|
|
343
|
-
return consumerValidate ? consumerValidate(
|
|
344
|
-
value,
|
|
345
|
-
args
|
|
346
|
-
) : true;
|
|
347
|
-
};
|
|
348
|
-
const display = {
|
|
349
|
-
locale: "fa-IR",
|
|
350
|
-
digits: "persian",
|
|
351
|
-
grouping: true,
|
|
352
|
-
showCurrency: true,
|
|
353
|
-
...options.display
|
|
354
|
-
};
|
|
355
|
-
return {
|
|
356
|
-
...overrides,
|
|
357
|
-
name: options.name,
|
|
358
|
-
type: "number",
|
|
359
|
-
validate,
|
|
360
|
-
admin: {
|
|
361
|
-
...overrides.admin,
|
|
362
|
-
components: {
|
|
363
|
-
...(_a = overrides.admin) == null ? void 0 : _a.components,
|
|
364
|
-
Field: {
|
|
365
|
-
path: "@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent",
|
|
366
|
-
clientProps: {
|
|
367
|
-
currency,
|
|
368
|
-
display,
|
|
369
|
-
allowNegative: options.allowNegative ?? false
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
custom: { ...overrides.custom, nexload: { ...(_b = overrides.custom) == null ? void 0 : _b.nexload, money: currency } }
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// src/plugin.ts
|
|
379
|
-
function failure(code, message, status) {
|
|
380
|
-
return Response.json(
|
|
381
|
-
{ error: { code, message } },
|
|
382
|
-
{ status }
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
function payloadFieldsPlugin(options = {}) {
|
|
386
|
-
return (config) => ({
|
|
387
|
-
...config,
|
|
388
|
-
endpoints: [
|
|
389
|
-
...config.endpoints ?? [],
|
|
390
|
-
{
|
|
391
|
-
path: "/payload-fields/generate-slug",
|
|
392
|
-
method: "post",
|
|
393
|
-
handler: async (req) => {
|
|
394
|
-
var _a;
|
|
395
|
-
if (!req.user) return failure(
|
|
396
|
-
"PAYLOAD_FIELDS_UNAUTHENTICATED",
|
|
397
|
-
"\u0628\u0631\u0627\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627\u06CC\u062F \u0648\u0627\u0631\u062F \u0634\u0648\u06CC\u062F.",
|
|
398
|
-
401
|
|
399
|
-
);
|
|
400
|
-
if (options.generateSlugAccess && !await options.generateSlugAccess({ req })) return failure(
|
|
401
|
-
"PAYLOAD_FIELDS_FORBIDDEN",
|
|
402
|
-
"\u0627\u062C\u0627\u0632\u0647 \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0631\u0627 \u0646\u062F\u0627\u0631\u06CC\u062F.",
|
|
403
|
-
403
|
|
404
|
-
);
|
|
405
|
-
let body;
|
|
406
|
-
try {
|
|
407
|
-
body = await ((_a = req.json) == null ? void 0 : _a.call(req));
|
|
408
|
-
} catch {
|
|
409
|
-
return failure(
|
|
410
|
-
"PAYLOAD_FIELDS_INVALID_INPUT",
|
|
411
|
-
"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
|
|
412
|
-
400
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
if (!body || typeof body !== "object" || Array.isArray(body)) return failure(
|
|
416
|
-
"PAYLOAD_FIELDS_INVALID_INPUT",
|
|
417
|
-
"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
|
|
418
|
-
400
|
|
419
|
-
);
|
|
420
|
-
const input = body;
|
|
421
|
-
if (typeof input.generator !== "string" || typeof input.sourceValue !== "string" || input.currentSlug !== void 0 && typeof input.currentSlug !== "string") return failure(
|
|
422
|
-
"PAYLOAD_FIELDS_INVALID_INPUT",
|
|
423
|
-
"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
|
|
424
|
-
400
|
|
425
|
-
);
|
|
426
|
-
const generator = options.slugGenerators && Object.prototype.hasOwnProperty.call(
|
|
427
|
-
options.slugGenerators,
|
|
428
|
-
input.generator
|
|
429
|
-
) ? options.slugGenerators[input.generator] : void 0;
|
|
430
|
-
if (!generator) return failure(
|
|
431
|
-
"PAYLOAD_FIELDS_GENERATOR_NOT_FOUND",
|
|
432
|
-
"\u062A\u0648\u0644\u06CC\u062F\u06A9\u0646\u0646\u062F\u0647 \u0627\u0633\u0644\u0627\u06AF \u067E\u06CC\u062F\u0627 \u0646\u0634\u062F.",
|
|
433
|
-
404
|
|
434
|
-
);
|
|
435
|
-
try {
|
|
436
|
-
const result = await generator(
|
|
437
|
-
{ sourceValue: input.sourceValue, currentSlug: input.currentSlug },
|
|
438
|
-
{ req }
|
|
439
|
-
);
|
|
440
|
-
return Response.json({ slug: formatSlug(result) });
|
|
441
|
-
} catch {
|
|
442
|
-
return failure(
|
|
443
|
-
"PAYLOAD_FIELDS_GENERATION_FAILED",
|
|
444
|
-
"\u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627 \u062E\u0637\u0627 \u0645\u0648\u0627\u062C\u0647 \u0634\u062F.",
|
|
445
|
-
500
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
]
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
454
|
-
0 && (module.exports = {
|
|
455
|
-
IRR,
|
|
456
|
-
IRT,
|
|
457
|
-
formatJalaliDate,
|
|
458
|
-
formatMoney,
|
|
459
|
-
formatSlug,
|
|
460
|
-
formatSlugHook,
|
|
461
|
-
jalaliDateField,
|
|
462
|
-
moneyField,
|
|
463
|
-
parseMoneyToMinorUnits,
|
|
464
|
-
payloadFieldsPlugin,
|
|
465
|
-
resolveCurrency,
|
|
466
|
-
slugField,
|
|
467
|
-
withJalaliTimestamps
|
|
468
|
-
});
|
|
469
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/slug/format-slug.ts", "../src/slug/index.ts", "../src/date/format-date.ts", "../src/date/index.ts", "../src/money/index.ts", "../src/plugin.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./slug\";\nexport * from \"./date\";\nexport * from \"./money\";\nexport * from \"./plugin\";\n", "import type { FieldHook } from \"payload\";\n\nexport type SlugHookOptions = {\n name: string\n lockName: string\n source: string\n regenerateOnSourceChange: boolean\n};\n\nconst persianDigits = \"\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\";\nconst arabicDigits = \"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\";\n\nfunction normalizeDigits (value: string): string {\n return value.replace(\n /[\u06F0-\u06F9\u0660-\u0669]/g, (digit) => {\n const index = persianDigits.indexOf(digit);\n return String(index >= 0 ? index : arabicDigits.indexOf(digit));\n }\n );\n}\n\nfunction getPath (\n value: unknown, path: string\n): unknown {\n return path.split(\".\").reduce<unknown>(\n (\n current, key\n ) => {\n if (current && typeof current === \"object\") return (current as Record<string, unknown>)[key];\n return undefined;\n }, value\n );\n}\n\nfunction hasPath (\n value: unknown, path: string\n): boolean {\n return path.split(\".\").every((key) => {\n if (!value || typeof value !== \"object\" || !(key in value)) return false;\n value = (value as Record<string, unknown>)[key];\n return true;\n });\n}\n\nexport function formatSlug (value: string): string {\n return normalizeDigits(value.normalize(\"NFKC\"))\n .replace(\n /[\u064A\u0649]/g, \"\u06CC\"\n )\n .replace(\n /\u0643/g, \"\u06A9\"\n )\n .replace(\n /[\\u064B-\\u065F\\u0670]/g, \"\"\n )\n .replace(\n /[\\s_]+/g, \"-\"\n )\n .replace(\n /[^\\p{L}\\p{N}-]+/gu, \"\"\n )\n .replace(\n /-+/g, \"-\"\n )\n .replace(\n /^-+|-+$/g, \"\"\n );\n}\n\nexport const formatSlugHook = (options: SlugHookOptions): FieldHook => ({\n data,\n operation,\n originalDoc,\n siblingData,\n previousSiblingDoc,\n value,\n}) => {\n const lock = siblingData?.[options.lockName] ?? data?.[options.lockName];\n const previousSlug = previousSiblingDoc?.[options.name] ?? originalDoc?.[options.name];\n const sourceChanged = hasPath(\n data, options.source\n )\n && getPath(\n data, options.source\n ) !== getPath(\n originalDoc, options.source\n );\n const source = hasPath(\n data, options.source\n )\n ? getPath(\n data, options.source\n )\n : getPath(\n originalDoc, options.source\n );\n\n if (lock !== false && typeof source === \"string\" && source.trim() && (operation === \"create\" || (options.regenerateOnSourceChange && sourceChanged))) {\n return formatSlug(source);\n }\n\n if (operation === \"update\" && lock !== false && sourceChanged && !source && previousSlug !== undefined) {\n return previousSlug;\n }\n\n if (lock !== false && operation === \"update\" && previousSlug !== undefined) return previousSlug;\n if (typeof value === \"string\") return formatSlug(value);\n return value;\n};\n", "import { formatSlugHook } from \"./format-slug\";\n\nimport type { CheckboxField, TextField } from \"payload\";\n\nexport type SlugFieldOptions = {\n name?: string\n lockName?: string\n source?: string\n generator?: string\n regenerateOnSourceChange?: boolean\n overrides?: { slug?: Partial<TextField>, lock?: Partial<CheckboxField> }\n};\n\nexport type SlugFieldResult = readonly [TextField, CheckboxField];\n\nexport function slugField (options: SlugFieldOptions = {}): SlugFieldResult {\n const name = options.name ?? \"slug\";\n const lockName = options.lockName ?? `${name}Lock`;\n const source = options.source ?? \"title\";\n const localized = options.overrides?.slug?.localized === true;\n if (options.overrides?.slug?.name && options.overrides.slug.name !== name) throw new Error(\"Slug field name is protected.\");\n if (options.overrides?.lock?.name && options.overrides.lock.name !== lockName) throw new Error(\"Slug lock name is protected.\");\n if (options.overrides?.lock?.localized !== undefined && options.overrides.lock.localized !== localized) throw new Error(\"Slug lock localization must match slug localization.\");\n if (options.overrides?.slug?.type && options.overrides.slug.type !== \"text\") throw new Error(\"Slug field type is protected.\");\n if (options.overrides?.lock?.type && options.overrides.lock.type !== \"checkbox\") throw new Error(\"Slug lock type is protected.\");\n\n const slugOverrides = options.overrides?.slug ?? {};\n const lockOverrides = options.overrides?.lock ?? {};\n const consumerHooks = slugOverrides.hooks?.beforeValidate ?? [];\n const slug: TextField = {\n ...slugOverrides,\n name,\n type: \"text\",\n index: slugOverrides.index ?? true,\n localized,\n admin: {\n ...slugOverrides.admin,\n position: slugOverrides.admin?.position ?? \"sidebar\",\n components: {\n ...slugOverrides.admin?.components,\n Field: {\n path: \"@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent\",\n clientProps: { source, lockName, generator: options.generator, },\n },\n },\n },\n custom: { ...slugOverrides.custom, nexload: { ...(slugOverrides.custom?.nexload as object), slug: { source, lockName, generator: options.generator, }, }, },\n hooks: {\n ...slugOverrides.hooks, beforeValidate: [\n ...consumerHooks,\n formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true, })\n ],\n },\n } as TextField;\n const lock: CheckboxField = {\n ...lockOverrides,\n name: lockName,\n type: \"checkbox\",\n localized,\n defaultValue: true,\n admin: { ...lockOverrides.admin, hidden: true, position: lockOverrides.admin?.position ?? \"sidebar\", },\n } as CheckboxField;\n return [\n slug,\n lock\n ];\n}\n\nexport * from \"./format-slug\";\n", "export type JalaliDateValue = Date | string | number | null | undefined;\nexport type JalaliDateDisplayOptions = {\n dateStyle?: \"short\" | \"medium\" | \"long\" | \"full\"\n timeStyle?: \"short\" | \"medium\"\n digits?: \"persian\" | \"latin\"\n timeZone?: string\n};\n\nexport function formatJalaliDate (\n value: JalaliDateValue, options: JalaliDateDisplayOptions = {}\n): string | null {\n if (value === null || value === undefined) return null;\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n const locale = options.digits === \"latin\" ? \"fa-IR-u-ca-persian-nu-latn\" : \"fa-IR-u-ca-persian\";\n return new Intl.DateTimeFormat(\n locale, {\n dateStyle: options.dateStyle ?? \"medium\",\n ...(options.timeStyle ? { timeStyle: options.timeStyle, } : {}),\n ...(options.timeZone ? { timeZone: options.timeZone, } : {}),\n }\n ).format(date);\n}\n", "import { formatJalaliDate } from \"./format-date\";\n\nimport type { JalaliPickerAppearance } from \"./picker-types\";\nimport type { DateField, Field, TextField } from \"payload\";\n\nexport type { JalaliDateDisplayOptions, JalaliDateValue } from \"./format-date\";\nexport type { JalaliPickerAppearance } from \"./picker-types\";\nexport type JalaliDateFieldOptions = {\n name: string\n pickerAppearance?: JalaliPickerAppearance\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: Partial<DateField>\n};\nexport type JalaliTimestampsOptions = {\n createdAt?: boolean\n updatedAt?: boolean\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: { createdAt?: Partial<TextField>, updatedAt?: Partial<TextField> }\n};\n\nexport function jalaliDateField (options: JalaliDateFieldOptions): DateField {\n const overrides = options.overrides ?? {};\n if (overrides.name && overrides.name !== options.name) throw new Error(\"Jalali date field name is protected.\");\n if (overrides.type && overrides.type !== \"date\") throw new Error(\"Jalali date field type is protected.\");\n const appearance = options.pickerAppearance ?? \"dayOnly\";\n const display = {\n digits: \"persian\" as const,\n dateStyle: \"medium\" as const,\n ...(\n appearance === \"dayAndTime\" || appearance === \"timeOnly\"\n ? { timeStyle: \"short\" as const, }\n : {}\n ),\n ...options.display,\n };\n return {\n ...overrides,\n name: options.name,\n type: \"date\",\n admin: {\n ...overrides.admin,\n date: { ...overrides.admin?.date, pickerAppearance: appearance, },\n components: {\n ...overrides.admin?.components,\n Field: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-field#JalaliDateFieldComponent\", clientProps: { appearance, display, }, },\n Cell: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-cell#JalaliDateCell\", clientProps: { display, }, },\n },\n },\n custom: { ...overrides.custom, nexload: { ...(overrides.custom?.nexload as object), jalaliDate: { appearance, display, }, }, },\n } as DateField;\n}\n\nexport function withJalaliTimestamps<T extends Field[]> (\n fields: T, options: JalaliTimestampsOptions = {}\n): Field[] {\n const output = [...fields];\n const add = (\n name: \"createdAtJalali\" | \"updatedAtJalali\", source: \"createdAt\" | \"updatedAt\", override?: Partial<TextField>\n ) => {\n if (output.some((field) => \"name\" in field && field.name === name)) throw new Error(`Duplicate Jalali timestamp field: ${name}`);\n output.push({\n ...override,\n name,\n type: \"text\",\n virtual: true,\n admin: { ...override?.admin, readOnly: true, },\n hooks: {\n ...override?.hooks, afterRead: [\n ...(override?.hooks?.afterRead ?? []),\n ({ siblingData, }) => formatJalaliDate(\n siblingData?.[source] as import(\"./format-date\").JalaliDateValue, options.display\n )\n ],\n },\n } as TextField);\n };\n if (options.createdAt !== false) add(\n \"createdAtJalali\", \"createdAt\", options.overrides?.createdAt\n );\n if (options.updatedAt !== false) add(\n \"updatedAtJalali\", \"updatedAt\", options.overrides?.updatedAt\n );\n return output;\n}\n\nexport { formatJalaliDate };\n", "import type { NumberField } from \"payload\";\n\nexport type MoneyCurrencyDefinition = {\n code: string\n label: string\n fractionDigits: number\n};\nexport type MoneyCurrency = \"IRR\" | \"IRT\" | MoneyCurrencyDefinition;\nexport type MoneyDisplayOptions = {\n locale?: string\n digits?: \"persian\" | \"latin\"\n grouping?: boolean\n showCurrency?: boolean\n};\nexport type MoneyFieldOptions = {\n name: string\n currency: MoneyCurrency\n minMinorUnits?: number\n maxMinorUnits?: number\n allowNegative?: boolean\n display?: MoneyDisplayOptions\n overrides?: Partial<NumberField>\n};\n\nexport const IRR: Readonly<MoneyCurrencyDefinition> = { code: \"IRR\", label: \"\u0631\u06CC\u0627\u0644\", fractionDigits: 0, };\nexport const IRT: Readonly<MoneyCurrencyDefinition> = { code: \"IRT\", label: \"\u062A\u0648\u0645\u0627\u0646\", fractionDigits: 0, };\n\nexport function resolveCurrency (currency: MoneyCurrency): MoneyCurrencyDefinition {\n const result = currency === \"IRR\" ? IRR : currency === \"IRT\" ? IRT : currency;\n if (\n !result.code.trim()\n || !result.label.trim()\n || !Number.isInteger(result.fractionDigits)\n || result.fractionDigits < 0\n || result.fractionDigits > 20\n ) throw new Error(\"Invalid money currency definition.\");\n return result;\n}\n\nfunction normalizedNumber (value: string): string {\n const persian = \"\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\";\n const arabic = \"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\";\n return value.trim().replace(\n /[\u06F0-\u06F9\u0660-\u0669]/g, (digit) => String(Math.max(\n persian.indexOf(digit), arabic.indexOf(digit)\n ) % 10)\n )\n .replace(\n /[\u066C,\\s]/g, \"\"\n )\n .replace(\n /\u066B/g, \".\"\n );\n}\n\nexport function parseMoneyToMinorUnits (\n input: string, currency: MoneyCurrency\n): number {\n const definition = resolveCurrency(currency);\n const value = normalizedNumber(input);\n if (!(/^-?\\d+(?:\\.\\d+)?$/).test(value)) throw new TypeError(\"Invalid money input.\");\n const negative = value.startsWith(\"-\");\n const [\n whole,\n fraction = \"\"\n ] = (negative ? value.slice(1) : value).split(\".\");\n if (fraction.length > definition.fractionDigits) throw new RangeError(\"Money input has unsupported precision.\");\n const digits = `${whole}${fraction.padEnd(\n definition.fractionDigits, \"0\"\n )}`.replace(\n /^0+(?=\\d)/, \"\"\n ) || \"0\";\n const minor = Number(`${negative ? \"-\" : \"\"}${digits}`);\n if (!Number.isSafeInteger(minor)) throw new RangeError(\"Money value is outside the safe integer range.\");\n return minor;\n}\n\nexport function formatMoney (\n value: number | null | undefined,\n currency: MoneyCurrency,\n display: MoneyDisplayOptions = {}\n): string | null {\n if (value === null || value === undefined) return null;\n if (!Number.isSafeInteger(value)) throw new RangeError(\"Money value is outside the safe integer range.\");\n const definition = resolveCurrency(currency);\n const locale = display.locale ?? (display.digits === \"latin\" ? \"fa-IR-u-nu-latn\" : \"fa-IR\");\n const major = value / 10 ** definition.fractionDigits;\n const formatted = new Intl.NumberFormat(\n locale, { useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits, }\n ).format(major);\n return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;\n}\n\nexport function moneyField (options: MoneyFieldOptions): NumberField {\n const overrides = options.overrides ?? {};\n if (overrides.name && overrides.name !== options.name) throw new Error(\"Money field name is protected.\");\n if (overrides.type && overrides.type !== \"number\") throw new Error(\"Money field type is protected.\");\n const currency = resolveCurrency(options.currency);\n if (\n options.minMinorUnits !== undefined\n && (\n !Number.isSafeInteger(options.minMinorUnits)\n || (\n options.maxMinorUnits !== undefined\n && options.minMinorUnits > options.maxMinorUnits\n )\n )\n ) throw new Error(\"Invalid money bounds.\");\n if (options.maxMinorUnits !== undefined && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error(\"Invalid money bounds.\");\n const consumerValidate = overrides.validate;\n const validate: NumberField[\"validate\"] = (\n value: unknown, args: { required?: boolean } | undefined\n ) => {\n if (value === null || value === undefined || value === \"\") return args?.required ? \"\u0648\u0627\u0631\u062F \u06A9\u0631\u062F\u0646 \u0645\u0628\u0644\u063A \u0627\u0644\u0632\u0627\u0645\u06CC \u0627\u0633\u062A.\" : true;\n if (typeof value !== \"number\" || !Number.isSafeInteger(value)) return \"\u0645\u0628\u0644\u063A \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F.\";\n if (!options.allowNegative && value < 0) return \"\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.\";\n if (options.minMinorUnits !== undefined && value < options.minMinorUnits) return \"\u0645\u0628\u0644\u063A \u06A9\u0645\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.\";\n if (options.maxMinorUnits !== undefined && value > options.maxMinorUnits) return \"\u0645\u0628\u0644\u063A \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.\";\n return consumerValidate\n ? (consumerValidate as (value: number, args: unknown) => string | true)(\n value, args\n )\n : true;\n };\n const display = {\n locale: \"fa-IR\", digits: \"persian\" as const, grouping: true, showCurrency: true, ...options.display,\n };\n return {\n ...overrides,\n name: options.name,\n type: \"number\",\n validate,\n admin: {\n ...overrides.admin,\n components: {\n ...overrides.admin?.components,\n Field: {\n path: \"@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent\",\n clientProps: {\n currency,\n display,\n allowNegative: options.allowNegative ?? false,\n },\n },\n },\n },\n custom: { ...overrides.custom, nexload: { ...(overrides.custom?.nexload as object), money: currency, }, },\n } as NumberField;\n}\n", "import { formatSlug } from \"./slug/format-slug\";\n\nimport type { PayloadRequest, Plugin } from \"payload\";\n\nexport type SlugGeneratorInput = { sourceValue: string, currentSlug?: string };\nexport type SlugGeneratorContext = { req: PayloadRequest };\nexport type SlugGenerator = (input: SlugGeneratorInput, context: SlugGeneratorContext) => Promise<string>;\nexport type SlugGenerationAccess = (context: SlugGeneratorContext) => boolean | Promise<boolean>;\nexport type PayloadFieldsPluginOptions = { slugGenerators?: Record<string, SlugGenerator>, generateSlugAccess?: SlugGenerationAccess };\n\nfunction failure (\n code: string, message: string, status: number\n): Response {\n return Response.json(\n { error: { code, message, }, }, { status, }\n );\n}\n\nexport function payloadFieldsPlugin (options: PayloadFieldsPluginOptions = {}): Plugin {\n return (config) => ({\n ...config,\n endpoints: [\n ...(config.endpoints ?? []),\n {\n path: \"/payload-fields/generate-slug\",\n method: \"post\" as const,\n handler: async (req: PayloadRequest) => {\n if (!req.user) return failure(\n \"PAYLOAD_FIELDS_UNAUTHENTICATED\", \"\u0628\u0631\u0627\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627\u06CC\u062F \u0648\u0627\u0631\u062F \u0634\u0648\u06CC\u062F.\", 401\n );\n if (options.generateSlugAccess && !await options.generateSlugAccess({ req, })) return failure(\n \"PAYLOAD_FIELDS_FORBIDDEN\", \"\u0627\u062C\u0627\u0632\u0647 \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0631\u0627 \u0646\u062F\u0627\u0631\u06CC\u062F.\", 403\n );\n let body: unknown;\n try {\n body = await req.json?.();\n } catch {\n return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n }\n if (!body || typeof body !== \"object\" || Array.isArray(body)) return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n const input = body as {\n generator?: unknown\n sourceValue?: unknown\n currentSlug?: unknown\n };\n if (\n typeof input.generator !== \"string\"\n || typeof input.sourceValue !== \"string\"\n || (input.currentSlug !== undefined && typeof input.currentSlug !== \"string\")\n ) return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n const generator = options.slugGenerators && Object.prototype.hasOwnProperty.call(\n options.slugGenerators, input.generator\n )\n ? options.slugGenerators[input.generator]\n : undefined;\n if (!generator) return failure(\n \"PAYLOAD_FIELDS_GENERATOR_NOT_FOUND\", \"\u062A\u0648\u0644\u06CC\u062F\u06A9\u0646\u0646\u062F\u0647 \u0627\u0633\u0644\u0627\u06AF \u067E\u06CC\u062F\u0627 \u0646\u0634\u062F.\", 404\n );\n try {\n const result = await generator(\n { sourceValue: input.sourceValue, currentSlug: input.currentSlug, }, { req, }\n );\n return Response.json({ slug: formatSlug(result), });\n } catch {\n return failure(\n \"PAYLOAD_FIELDS_GENERATION_FAILED\", \"\u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627 \u062E\u0637\u0627 \u0645\u0648\u0627\u062C\u0647 \u0634\u062F.\", 500\n );\n }\n },\n }\n ],\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;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