@vestcards/shared 1.0.2 → 1.1.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/colors-G1GHbBJq.js +120 -0
- package/dist/colors-c6Q-ORB_.cjs +1 -0
- package/dist/date.cjs +1 -1
- package/dist/date.js +14 -14
- package/dist/fsrs-DEA3eLGO.cjs +1 -0
- package/dist/fsrs-sJJWxUiC.js +14 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +211 -11
- package/dist/index.js +191 -23
- package/dist/spaced-repetition.cjs +1 -1
- package/dist/spaced-repetition.d.ts +9 -7
- package/dist/spaced-repetition.js +1 -1
- package/dist/theme.cjs +1 -1
- package/dist/theme.d.ts +48 -27
- package/dist/theme.js +16 -111
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.ts +15 -0
- package/dist/utils.js +36 -0
- package/package.json +10 -3
- package/dist/fsrs-C8QUsZ5l.js +0 -10
- package/dist/fsrs-HJutnIWm.cjs +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as c from "@radix-ui/colors";
|
|
2
|
+
const a = (r, e) => {
|
|
3
|
+
var o;
|
|
4
|
+
const g = e.charAt(0) === "a" && !Number.isNaN(Number(e.slice(1))) ? `${r}A` : r, s = `${r}${e.charAt(0).toUpperCase() + e.slice(1)}`;
|
|
5
|
+
return ((o = c[g]) == null ? void 0 : o[s]) ?? `var(--${r}-${e})`;
|
|
6
|
+
}, t = (r, e, b) => [r, a(e, b)];
|
|
7
|
+
function n(r) {
|
|
8
|
+
const e = Array.from({ length: 12 }, (b, g) => {
|
|
9
|
+
const s = g + 1;
|
|
10
|
+
return [t(s.toString(), r, s.toString()), t(`a${s}`, r, `a${s}`)];
|
|
11
|
+
}).flat();
|
|
12
|
+
return e.push(t("DEFAULT", r, "9")), e.push(t("hover", r, "10")), e.push(t("dark", r, "11")), e.push(t("light", r, "4")), e.push(t("lightness", r, "2")), Object.fromEntries(e);
|
|
13
|
+
}
|
|
14
|
+
const d = {
|
|
15
|
+
transparent: "transparent",
|
|
16
|
+
current: "currentColor",
|
|
17
|
+
brand: {
|
|
18
|
+
DEFAULT: "#FF7824"
|
|
19
|
+
},
|
|
20
|
+
primary: {
|
|
21
|
+
...n("orange")
|
|
22
|
+
},
|
|
23
|
+
secondary: {
|
|
24
|
+
...n("blue")
|
|
25
|
+
},
|
|
26
|
+
tertiary: {
|
|
27
|
+
...n("amber")
|
|
28
|
+
},
|
|
29
|
+
quaternary: {
|
|
30
|
+
...n("crimson")
|
|
31
|
+
},
|
|
32
|
+
quinary: {
|
|
33
|
+
...n("jade")
|
|
34
|
+
},
|
|
35
|
+
gray: {
|
|
36
|
+
...n("sand")
|
|
37
|
+
},
|
|
38
|
+
success: {
|
|
39
|
+
...n("grass")
|
|
40
|
+
},
|
|
41
|
+
warning: {
|
|
42
|
+
...n("amber")
|
|
43
|
+
},
|
|
44
|
+
danger: {
|
|
45
|
+
...n("red")
|
|
46
|
+
},
|
|
47
|
+
black: {
|
|
48
|
+
DEFAULT: "#000000",
|
|
49
|
+
a1: "rgba(0, 0, 0, 0.05)",
|
|
50
|
+
a2: "rgba(0, 0, 0, 0.1)",
|
|
51
|
+
a3: "rgba(0, 0, 0, 0.15)",
|
|
52
|
+
a4: "rgba(0, 0, 0, 0.2)",
|
|
53
|
+
a5: "rgba(0, 0, 0, 0.3)",
|
|
54
|
+
a6: "rgba(0, 0, 0, 0.4)",
|
|
55
|
+
a7: "rgba(0, 0, 0, 0.5)",
|
|
56
|
+
a8: "rgba(0, 0, 0, 0.6)",
|
|
57
|
+
a9: "rgba(0, 0, 0, 0.7)",
|
|
58
|
+
a10: "rgba(0, 0, 0, 0.8)",
|
|
59
|
+
a11: "rgba(0, 0, 0, 0.9)",
|
|
60
|
+
a12: "rgba(0, 0, 0, 0.95)"
|
|
61
|
+
},
|
|
62
|
+
white: {
|
|
63
|
+
DEFAULT: "#FFFFFF",
|
|
64
|
+
a1: "rgba(255, 255, 255, 0.05)",
|
|
65
|
+
a2: "rgba(255, 255, 255, 0.1)",
|
|
66
|
+
a3: "rgba(255, 255, 255, 0.15)",
|
|
67
|
+
a4: "rgba(255, 255, 255, 0.2)",
|
|
68
|
+
a5: "rgba(255, 255, 255, 0.3)",
|
|
69
|
+
a6: "rgba(255, 255, 255, 0.4)",
|
|
70
|
+
a7: "rgba(255, 255, 255, 0.5)",
|
|
71
|
+
a8: "rgba(255, 255, 255, 0.6)",
|
|
72
|
+
a9: "rgba(255, 255, 255, 0.7)",
|
|
73
|
+
a10: "rgba(255, 255, 255, 0.8)",
|
|
74
|
+
a11: "rgba(255, 255, 255, 0.9)",
|
|
75
|
+
a12: "rgba(255, 255, 255, 0.95)"
|
|
76
|
+
},
|
|
77
|
+
data: {
|
|
78
|
+
1: "#1d4aff",
|
|
79
|
+
2: "#621da6",
|
|
80
|
+
3: "#42827e",
|
|
81
|
+
4: "#ce0e74",
|
|
82
|
+
5: "#f14f58",
|
|
83
|
+
6: "#7c440e",
|
|
84
|
+
7: "#529a0a",
|
|
85
|
+
8: "#0476fb",
|
|
86
|
+
9: "#fe729e",
|
|
87
|
+
10: "#35416b",
|
|
88
|
+
11: "#41cbc4",
|
|
89
|
+
12: "#b64b02",
|
|
90
|
+
13: "#e4a604",
|
|
91
|
+
14: "#a56eff",
|
|
92
|
+
15: "#30d5c8"
|
|
93
|
+
},
|
|
94
|
+
// shadcn colors
|
|
95
|
+
foreground: a("sand", "12"),
|
|
96
|
+
background: a("sand", "2"),
|
|
97
|
+
ring: a("blue", "6"),
|
|
98
|
+
muted: {
|
|
99
|
+
DEFAULT: a("sand", "3"),
|
|
100
|
+
foreground: a("sand", "10")
|
|
101
|
+
},
|
|
102
|
+
border: a("sand", "5"),
|
|
103
|
+
input: a("sand", "4"),
|
|
104
|
+
accent: a("blue", "2"),
|
|
105
|
+
sidebar: {
|
|
106
|
+
DEFAULT: a("sand", "3"),
|
|
107
|
+
foreground: a("sand", "11"),
|
|
108
|
+
accent: "white",
|
|
109
|
+
"accent-foreground": a("orange", "11"),
|
|
110
|
+
border: a("sand", "6"),
|
|
111
|
+
ring: a("blue", "6")
|
|
112
|
+
},
|
|
113
|
+
popover: {
|
|
114
|
+
DEFAULT: "#FFFFFF",
|
|
115
|
+
foreground: a("sand", "11")
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
d as c
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("@radix-ui/colors");function u(a){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const b=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(r,n,b.get?b:{enumerable:!0,get:()=>a[n]})}}return r.default=a,Object.freeze(r)}const d=u(c),e=(a,r)=>{var g;const b=r.charAt(0)==="a"&&!Number.isNaN(Number(r.slice(1)))?`${a}A`:a,o=`${a}${r.charAt(0).toUpperCase()+r.slice(1)}`;return((g=d[b])==null?void 0:g[o])??`var(--${a}-${r})`},s=(a,r,n)=>[a,e(r,n)];function t(a){const r=Array.from({length:12},(n,b)=>{const o=b+1;return[s(o.toString(),a,o.toString()),s(`a${o}`,a,`a${o}`)]}).flat();return r.push(s("DEFAULT",a,"9")),r.push(s("hover",a,"10")),r.push(s("dark",a,"11")),r.push(s("light",a,"4")),r.push(s("lightness",a,"2")),Object.fromEntries(r)}const i={transparent:"transparent",current:"currentColor",brand:{DEFAULT:"#FF7824"},primary:{...t("orange")},secondary:{...t("blue")},tertiary:{...t("amber")},quaternary:{...t("crimson")},quinary:{...t("jade")},gray:{...t("sand")},success:{...t("grass")},warning:{...t("amber")},danger:{...t("red")},black:{DEFAULT:"#000000",a1:"rgba(0, 0, 0, 0.05)",a2:"rgba(0, 0, 0, 0.1)",a3:"rgba(0, 0, 0, 0.15)",a4:"rgba(0, 0, 0, 0.2)",a5:"rgba(0, 0, 0, 0.3)",a6:"rgba(0, 0, 0, 0.4)",a7:"rgba(0, 0, 0, 0.5)",a8:"rgba(0, 0, 0, 0.6)",a9:"rgba(0, 0, 0, 0.7)",a10:"rgba(0, 0, 0, 0.8)",a11:"rgba(0, 0, 0, 0.9)",a12:"rgba(0, 0, 0, 0.95)"},white:{DEFAULT:"#FFFFFF",a1:"rgba(255, 255, 255, 0.05)",a2:"rgba(255, 255, 255, 0.1)",a3:"rgba(255, 255, 255, 0.15)",a4:"rgba(255, 255, 255, 0.2)",a5:"rgba(255, 255, 255, 0.3)",a6:"rgba(255, 255, 255, 0.4)",a7:"rgba(255, 255, 255, 0.5)",a8:"rgba(255, 255, 255, 0.6)",a9:"rgba(255, 255, 255, 0.7)",a10:"rgba(255, 255, 255, 0.8)",a11:"rgba(255, 255, 255, 0.9)",a12:"rgba(255, 255, 255, 0.95)"},data:{1:"#1d4aff",2:"#621da6",3:"#42827e",4:"#ce0e74",5:"#f14f58",6:"#7c440e",7:"#529a0a",8:"#0476fb",9:"#fe729e",10:"#35416b",11:"#41cbc4",12:"#b64b02",13:"#e4a604",14:"#a56eff",15:"#30d5c8"},foreground:e("sand","12"),background:e("sand","2"),ring:e("blue","6"),muted:{DEFAULT:e("sand","3"),foreground:e("sand","10")},border:e("sand","5"),input:e("sand","4"),accent:e("blue","2"),sidebar:{DEFAULT:e("sand","3"),foreground:e("sand","11"),accent:"white","accent-foreground":e("orange","11"),border:e("sand","6"),ring:e("blue","6")},popover:{DEFAULT:"#FFFFFF",foreground:e("sand","11")}};exports.colors=i;
|
package/dist/date.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("date-fns/locale"),o=require("date-fns"),s=require("date-fns-tz"),a=m.ptBR,u="America/Sao_Paulo";function n(e){return e instanceof Date?e:typeof e=="number"?new Date(e):typeof e=="string"?o.parseISO(e):e}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("date-fns/locale"),o=require("date-fns"),s=require("date-fns-tz"),a=m.ptBR,u="America/Sao_Paulo";function n(e){return e instanceof Date?e:typeof e=="number"?new Date(e):typeof e=="string"?o.parseISO(e):e}function d(e,t=new Date,r){return o.formatDistance(n(e),n(t),{locale:a,...r})}function w(e,t){return o.formatDistanceToNow(n(e),{locale:a,...t})}function D(e,t,r){return o.format(n(e),t,{locale:a,...r})}function p(e,t=new Date,r){return o.formatRelative(n(e),n(t),{locale:a,...r})}function R(e,t,r=u){const c=s.toZonedTime(n(e),r);return D(c,t,{locale:a})}const y=e=>{const t=new Date,r=o.differenceInMinutes(e,t);if(r<1)return"<1m";if(r<10)return`<${Math.ceil(r/10)*10}m`;if(o.differenceInHours(e,t)<1)return"<1h";const i=o.differenceInDays(e,t);if(i<1)return"<1d";if(i<7)return`${i}d`;const f=o.differenceInMonths(e,t);return f<1?`${Math.ceil(i/30)}M`:f<12?`${f}M`:`${o.differenceInYears(e,t)}y`};function b(e,t=new Date,r="às",c=u){const i=s.toZonedTime(n(e),c),f=s.toZonedTime(n(t),c),l=o.formatRelative(i,f,{locale:a}).replace(/às/g,r);return`${l.charAt(0).toUpperCase()}${l.slice(1)}`}function O(e,t){const r=s.toZonedTime(n(e),u);return o.formatDistanceToNow(r,{locale:m.ptBR,...t})}exports.DEFAULT_LOCALE=a;exports.DEFAULT_TZ=u;exports.format=D;exports.formatDateTZ=R;exports.formatDistance=d;exports.formatDistanceToNow=w;exports.formatRelative=p;exports.formatRelativeDate=b;exports.formatRelativeDateToNow=O;exports.formatRelativeReviewDate=y;exports.toDate=n;Object.keys(o).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})});
|
package/dist/date.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { ptBR as u } from "date-fns/locale";
|
|
2
|
-
import { parseISO as
|
|
2
|
+
import { parseISO as w, format as $, formatDistance as h, formatDistanceToNow as l, formatRelative as D, differenceInMinutes as T, differenceInHours as d, differenceInDays as R, differenceInMonths as y, differenceInYears as b } from "date-fns";
|
|
3
3
|
export * from "date-fns";
|
|
4
4
|
import { toZonedTime as c } from "date-fns-tz";
|
|
5
5
|
const a = u, s = "America/Sao_Paulo";
|
|
6
6
|
function n(t) {
|
|
7
|
-
return t instanceof Date ? t : typeof t == "number" ? new Date(t) : typeof t == "string" ?
|
|
7
|
+
return t instanceof Date ? t : typeof t == "number" ? new Date(t) : typeof t == "string" ? w(t) : t;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function j(t, e = /* @__PURE__ */ new Date(), r) {
|
|
10
10
|
return h(n(t), n(e), {
|
|
11
11
|
locale: a,
|
|
12
12
|
...r
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function L(t, e) {
|
|
16
|
+
return l(n(t), {
|
|
17
17
|
locale: a,
|
|
18
18
|
...e
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function I(t, e, r) {
|
|
22
|
+
return $(n(t), e, {
|
|
23
23
|
locale: a,
|
|
24
24
|
...r
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
function N(t, e = /* @__PURE__ */ new Date(), r) {
|
|
28
|
-
return
|
|
28
|
+
return D(n(t), n(e), {
|
|
29
29
|
locale: a,
|
|
30
30
|
...r
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function v(t, e, r = s) {
|
|
34
34
|
const f = c(n(t), r);
|
|
35
|
-
return
|
|
35
|
+
return I(f, e, {
|
|
36
36
|
locale: a
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -48,22 +48,22 @@ const E = (t) => {
|
|
|
48
48
|
return i < 1 ? `${Math.ceil(o / 30)}M` : i < 12 ? `${i}M` : `${b(t, e)}y`;
|
|
49
49
|
};
|
|
50
50
|
function S(t, e = /* @__PURE__ */ new Date(), r = "às", f = s) {
|
|
51
|
-
const o = c(n(t), f), i = c(n(e), f), m =
|
|
51
|
+
const o = c(n(t), f), i = c(n(e), f), m = D(o, i, {
|
|
52
52
|
locale: a
|
|
53
53
|
}).replace(/às/g, r);
|
|
54
54
|
return `${m.charAt(0).toUpperCase()}${m.slice(1)}`;
|
|
55
55
|
}
|
|
56
56
|
function U(t, e) {
|
|
57
57
|
const r = c(n(t), s);
|
|
58
|
-
return
|
|
58
|
+
return l(r, { locale: u, ...e });
|
|
59
59
|
}
|
|
60
60
|
export {
|
|
61
61
|
a as DEFAULT_LOCALE,
|
|
62
62
|
s as DEFAULT_TZ,
|
|
63
|
-
|
|
63
|
+
I as format,
|
|
64
64
|
v as formatDateTZ,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
j as formatDistance,
|
|
66
|
+
L as formatDistanceToNow,
|
|
67
67
|
N as formatRelative,
|
|
68
68
|
S as formatRelativeDate,
|
|
69
69
|
U as formatRelativeDateToNow,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=(e=>(e.New="New",e.Learning="Learning",e.Review="Review",e.Relearning="Relearning",e))(a||{});const n=["New","Learning","Review","Relearning"],i={Manual:"Manual",Again:"Again",Hard:"Hard",Good:"Good",Easy:"Easy"},r=["Manual","Again","Hard","Good","Easy"];exports.ReviewRating=i;exports.ReviewState=a;exports.reviewRatings=r;exports.reviewStates=n;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var n = /* @__PURE__ */ ((a) => (a.New = "New", a.Learning = "Learning", a.Review = "Review", a.Relearning = "Relearning", a))(n || {});
|
|
2
|
+
const e = ["New", "Learning", "Review", "Relearning"], r = {
|
|
3
|
+
Manual: "Manual",
|
|
4
|
+
Again: "Again",
|
|
5
|
+
Hard: "Hard",
|
|
6
|
+
Good: "Good",
|
|
7
|
+
Easy: "Easy"
|
|
8
|
+
}, i = ["Manual", "Again", "Hard", "Good", "Easy"];
|
|
9
|
+
export {
|
|
10
|
+
r as R,
|
|
11
|
+
n as a,
|
|
12
|
+
e as b,
|
|
13
|
+
i as r
|
|
14
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./fsrs-DEA3eLGO.cjs"),P=require("./colors-c6Q-ORB_.cjs"),C=9999;function I({data:e,error:r},a){if(r){const t=r.value,n=t&&typeof t=="object"&&t!==null&&"message"in t?String(t.message):a;throw new Error(n||a)}if(!e||typeof e=="object"&&"error"in e)throw new Error(a);return e}var R=(e=>(e.Draft="draft",e.Published="published",e))(R||{});const N=["not-reviewed","card-updated","demand-rejected","card-removed"];var s=(e=>(e.Draft="draft",e.Review="to_review",e.Published="published",e.Archived="archived",e))(s||{});const m=["matemática","geografia","física","biologia","história","literatura","gramática","sociologia","química","filosofia","redação","artes","inglês"];var i=(e=>(e.Admin="admin",e.Moderator="moderator",e.User="user",e))(i||{}),c=(e=>(e.Owner="owner",e.Admin="admin",e.Member="member",e))(c||{}),D=(e=>(e.Premium="premium",e))(D||{}),_=(e=>(e.Active="active",e.Canceled="canceled",e.Pending="pending",e.Expired="expired",e))(_||{});const E={DECK:{CREATE_OWN:"deck:create:own",CREATE_PUBLIC:"deck:create:public",READ_OWN:"deck:read:own",READ_OTHERS:"deck:read:others",READ_UNPUBLISHED:"deck:read:unpublished",READ_FREE:"deck:read:free",READ_PREMIUM:"deck:read:premium",READ_PRIVATE:"deck:read:private",UPDATE_OWN:"deck:update:own",UPDATE_PUBLIC:"deck:update:public",DELETE_OWN:"deck:delete:own",DELETE_PUBLIC:"deck:delete:public"},CARD_DEMAND:{READ_ALL:"card-demand:read:*",CREATE:"card-demand:create",ACTION:"card-demand:action"},USER:{UPDATE_OWN:"user:update:own",UPDATE_ALL:"user:update:*",DELETE_OWN:"user:delete:own",DELETE_ALL:"user:delete:*",READ_OWN:"user:read:own",READ_ALL:"user:read:*"},STATS:{VIEW:"stats:view"},MEMBERSHIP:{MANAGE:"membership:manage"},PLAN:{CREATE:"plan:create",UPDATE:"plan:update",DELETE:"plan:delete"},BLOGPOST:{CREATE:"blogpost:create",UPDATE:"blogpost:update",DELETE:"blogpost:delete"},VESTY:{CHAT:"vesty:chat"},STUDY:{READ:"study:read",WRITE:"study:write"},LIBRARY:{READ:"library:read",WRITE:"library:write",WRITE_PREMIUM:"library:write:premium"},ADMIN_PANEL:{VIEW:"admin-panel:view"}},U={DECK_CREATE_OWN:E.DECK.CREATE_OWN,DECK_CREATE_PUBLIC:E.DECK.CREATE_PUBLIC,DECK_READ_OWN:E.DECK.READ_OWN,DECK_READ_OTHERS:E.DECK.READ_OTHERS,DECK_READ_UNPUBLISHED:E.DECK.READ_UNPUBLISHED,DECK_READ_FREE:E.DECK.READ_FREE,DECK_READ_PREMIUM:E.DECK.READ_PREMIUM,DECK_READ_PRIVATE:E.DECK.READ_PRIVATE,DECK_UPDATE_OWN:E.DECK.UPDATE_OWN,DECK_UPDATE_PUBLIC:E.DECK.UPDATE_PUBLIC,DECK_DELETE_OWN:E.DECK.DELETE_OWN,DECK_DELETE_PUBLIC:E.DECK.DELETE_PUBLIC,CARD_DEMAND_READ_ALL:E.CARD_DEMAND.READ_ALL,CARD_DEMAND_CREATE:E.CARD_DEMAND.CREATE,CARD_DEMAND_ACTION:E.CARD_DEMAND.ACTION,USER_UPDATE_OWN:E.USER.UPDATE_OWN,USER_UPDATE_ALL:E.USER.UPDATE_ALL,USER_DELETE_OWN:E.USER.DELETE_OWN,USER_DELETE_ALL:E.USER.DELETE_ALL,USER_READ_OWN:E.USER.READ_OWN,USER_READ_ALL:E.USER.READ_ALL,STATS_VIEW:E.STATS.VIEW,MEMBERSHIP_MANAGE:E.MEMBERSHIP.MANAGE,PLAN_CREATE:E.PLAN.CREATE,PLAN_UPDATE:E.PLAN.UPDATE,PLAN_DELETE:E.PLAN.DELETE,BLOGPOST_CREATE:E.BLOGPOST.CREATE,BLOGPOST_UPDATE:E.BLOGPOST.UPDATE,BLOGPOST_DELETE:E.BLOGPOST.DELETE,VESTY_CHAT:E.VESTY.CHAT,STUDY_READ:E.STUDY.READ,STUDY_WRITE:E.STUDY.WRITE,LIBRARY_READ:E.LIBRARY.READ,LIBRARY_WRITE:E.LIBRARY.WRITE,LIBRARY_WRITE_PREMIUM:E.LIBRARY.WRITE_PREMIUM,ADMIN_PANEL_VIEW:E.ADMIN_PANEL.VIEW},T=Object.values(E).flatMap(e=>Object.values(e)),u={[i.User]:["deck:read:free","deck:read:own","deck:delete:own","study:read","study:write","library:read","library:write","card-demand:create","user:update:own","user:delete:own","user:read:own"],[i.Moderator]:["deck:read:free","deck:read:own","deck:read:premium","deck:read:private","deck:read:unpublished","deck:delete:own","card-demand:read:*","card-demand:create","card-demand:action","study:read","study:write","library:read","library:write","library:write:premium","user:update:own","user:delete:own","user:read:own","admin-panel:view"],[i.Admin]:T},S={[D.Premium]:["deck:create:own","deck:update:own","deck:read:premium","stats:view","vesty:chat","library:write:premium"]},O=(e,r,a)=>{if(!r)return!1;if(u[r].includes(e))return!0;for(const n of a??[])if((S[n]??[]).includes(e))return!0;return!1};var l=(e=>(e.Published="published",e.Draft="draft",e.Archived="archived",e))(l||{});const A={história:"quaternary",geografia:"tertiary",matemática:"secondary",biologia:"primary",física:"quinary",gramática:"tertiary",literatura:"secondary",química:"primary",filosofia:"quaternary",sociologia:"quinary",redação:"secondary",artes:"tertiary",inglês:"quinary",default:"default"},o={matemática:"radical",gramática:"spell-check",literatura:"book-open",biologia:"dna",química:"test-tube-diagonal",física:"atom",história:"scroll",geografia:"earth",filosofia:"brain",sociologia:"users-round",redação:"notebook-pen",artes:"palette",inglês:"languages",default:"graduation-cap"},p=e=>o[e]||o.default,L=e=>A[e]||A.default,w=e=>{const r=L(e),a=r==="default"?"gray":r;return P.colors[a].DEFAULT};exports.ReviewRating=d.ReviewRating;exports.ReviewState=d.ReviewState;exports.reviewRatings=d.reviewRatings;exports.reviewStates=d.reviewStates;exports.ALL_PERMISSIONS=T;exports.BlogPostStatus=R;exports.DeckStatus=s;exports.ENTITLEMENT_PERMISSIONS=S;exports.Entitlement=D;exports.EntranceExamProgramStatus=l;exports.MembershipStatus=_;exports.OrganizationRole=c;exports.PERMISSIONS=E;exports.Permission=U;exports.ROLE_PERMISSIONS=u;exports.SUBJECTS=m;exports.SUBJECT_COLORS=A;exports.SUBJECT_ICONS=o;exports.UNPAGINATED_SIZE=C;exports.UserRole=i;exports.cardDemandStatus=N;exports.getSubjectCSSColor=w;exports.getSubjectColor=L;exports.getSubjectIcon=p;exports.hasPermission=O;exports.unwrapApiResponse=I;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
export declare const ALL_PERMISSIONS: Permission[];
|
|
2
|
+
|
|
1
3
|
export declare type BillingType = 'PIX' | 'CREDIT_CARD' | 'BOLETO';
|
|
2
4
|
|
|
5
|
+
export declare type BlogPostQuestion = {
|
|
6
|
+
question: string;
|
|
7
|
+
answer: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export declare enum BlogPostStatus {
|
|
11
|
+
Draft = "draft",
|
|
12
|
+
Published = "published"
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export declare type CardDemandStatus = (typeof cardDemandStatus)[number];
|
|
4
16
|
|
|
5
17
|
export declare const cardDemandStatus: readonly ["not-reviewed", "card-updated", "demand-rejected", "card-removed"];
|
|
@@ -11,15 +23,59 @@ export declare enum DeckStatus {
|
|
|
11
23
|
Archived = "archived"
|
|
12
24
|
}
|
|
13
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Extracts the success data type from an Eden Treaty endpoint function.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ```ts
|
|
31
|
+
* type PaginatedDecks = EdenData<typeof server.v1.decks.get>;
|
|
32
|
+
* // → { data: IDeck[]; pageCount: number; total: number; }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare type EdenData<T extends (...args: never) => unknown> = Awaited<ReturnType<T>> extends {
|
|
36
|
+
data: infer D;
|
|
37
|
+
} ? NonNullable<D> : never;
|
|
38
|
+
|
|
39
|
+
declare interface EdenError {
|
|
40
|
+
value: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Extracts the parameters object from an Eden Treaty endpoint function.
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
* ```ts
|
|
48
|
+
* type DeckFilters = EdenParams<typeof server.v1.decks.get>['query'];
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare type EdenParams<T extends (...args: never) => unknown> = Parameters<T>[0];
|
|
52
|
+
|
|
53
|
+
declare interface EdenResponse<T> {
|
|
54
|
+
data: T | null;
|
|
55
|
+
error: EdenError | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
14
58
|
export declare enum Entitlement {
|
|
15
59
|
Premium = "premium"
|
|
16
60
|
}
|
|
17
61
|
|
|
62
|
+
export declare const ENTITLEMENT_PERMISSIONS: Record<Entitlement, Permission[]>;
|
|
63
|
+
|
|
18
64
|
export declare type EntityType = 'user' | 'organization' | 'official';
|
|
19
65
|
|
|
66
|
+
export declare enum EntranceExamProgramStatus {
|
|
67
|
+
Published = "published",
|
|
68
|
+
Draft = "draft",
|
|
69
|
+
Archived = "archived"
|
|
70
|
+
}
|
|
71
|
+
|
|
20
72
|
export declare const getSubjectColor: (subject: string) => SemanticColor;
|
|
21
73
|
|
|
22
|
-
export declare const
|
|
74
|
+
export declare const getSubjectCSSColor: (subject: string) => string;
|
|
75
|
+
|
|
76
|
+
export declare const getSubjectIcon: (subject: string) => SubjectIcon;
|
|
77
|
+
|
|
78
|
+
export declare const hasPermission: (required: Permission, userRole?: UserRole, userEntitlements?: Entitlement[]) => boolean;
|
|
23
79
|
|
|
24
80
|
export declare interface IArchivedLibraryItem {
|
|
25
81
|
deckId: string;
|
|
@@ -71,6 +127,7 @@ export declare interface IDeck {
|
|
|
71
127
|
subject: Subject;
|
|
72
128
|
topic?: string;
|
|
73
129
|
topicIcon?: string | null;
|
|
130
|
+
ownerId: string;
|
|
74
131
|
}
|
|
75
132
|
|
|
76
133
|
export declare interface IDeckDetail extends IDeck {
|
|
@@ -93,10 +150,10 @@ export declare interface IGroupedLibraryItem {
|
|
|
93
150
|
}
|
|
94
151
|
|
|
95
152
|
export declare interface IOwnerInfo {
|
|
96
|
-
type: EntityType;
|
|
97
153
|
id: string;
|
|
98
154
|
name: string;
|
|
99
155
|
image: string | null;
|
|
156
|
+
type: EntityType;
|
|
100
157
|
}
|
|
101
158
|
|
|
102
159
|
export declare interface IReviewLog {
|
|
@@ -150,17 +207,123 @@ export declare enum OrganizationRole {
|
|
|
150
207
|
|
|
151
208
|
export declare type OrganizationScopeRole = (typeof OrganizationRole)[keyof typeof OrganizationRole];
|
|
152
209
|
|
|
153
|
-
export declare
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
210
|
+
export declare type Permission = ValueOf<{
|
|
211
|
+
[K in keyof typeof PERMISSIONS]: ValueOf<(typeof PERMISSIONS)[K]>;
|
|
212
|
+
}>;
|
|
213
|
+
|
|
214
|
+
export declare const Permission: {
|
|
215
|
+
readonly DECK_CREATE_OWN: "deck:create:own";
|
|
216
|
+
readonly DECK_CREATE_PUBLIC: "deck:create:public";
|
|
217
|
+
readonly DECK_READ_OWN: "deck:read:own";
|
|
218
|
+
readonly DECK_READ_OTHERS: "deck:read:others";
|
|
219
|
+
readonly DECK_READ_UNPUBLISHED: "deck:read:unpublished";
|
|
220
|
+
readonly DECK_READ_FREE: "deck:read:free";
|
|
221
|
+
readonly DECK_READ_PREMIUM: "deck:read:premium";
|
|
222
|
+
readonly DECK_READ_PRIVATE: "deck:read:private";
|
|
223
|
+
readonly DECK_UPDATE_OWN: "deck:update:own";
|
|
224
|
+
readonly DECK_UPDATE_PUBLIC: "deck:update:public";
|
|
225
|
+
readonly DECK_DELETE_OWN: "deck:delete:own";
|
|
226
|
+
readonly DECK_DELETE_PUBLIC: "deck:delete:public";
|
|
227
|
+
readonly CARD_DEMAND_READ_ALL: "card-demand:read:*";
|
|
228
|
+
readonly CARD_DEMAND_CREATE: "card-demand:create";
|
|
229
|
+
readonly CARD_DEMAND_ACTION: "card-demand:action";
|
|
230
|
+
readonly USER_UPDATE_OWN: "user:update:own";
|
|
231
|
+
readonly USER_UPDATE_ALL: "user:update:*";
|
|
232
|
+
readonly USER_DELETE_OWN: "user:delete:own";
|
|
233
|
+
readonly USER_DELETE_ALL: "user:delete:*";
|
|
234
|
+
readonly USER_READ_OWN: "user:read:own";
|
|
235
|
+
readonly USER_READ_ALL: "user:read:*";
|
|
236
|
+
readonly STATS_VIEW: "stats:view";
|
|
237
|
+
readonly MEMBERSHIP_MANAGE: "membership:manage";
|
|
238
|
+
readonly PLAN_CREATE: "plan:create";
|
|
239
|
+
readonly PLAN_UPDATE: "plan:update";
|
|
240
|
+
readonly PLAN_DELETE: "plan:delete";
|
|
241
|
+
readonly BLOGPOST_CREATE: "blogpost:create";
|
|
242
|
+
readonly BLOGPOST_UPDATE: "blogpost:update";
|
|
243
|
+
readonly BLOGPOST_DELETE: "blogpost:delete";
|
|
244
|
+
readonly VESTY_CHAT: "vesty:chat";
|
|
245
|
+
readonly STUDY_READ: "study:read";
|
|
246
|
+
readonly STUDY_WRITE: "study:write";
|
|
247
|
+
readonly LIBRARY_READ: "library:read";
|
|
248
|
+
readonly LIBRARY_WRITE: "library:write";
|
|
249
|
+
readonly LIBRARY_WRITE_PREMIUM: "library:write:premium";
|
|
250
|
+
readonly ADMIN_PANEL_VIEW: "admin-panel:view";
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export declare const PERMISSIONS: {
|
|
254
|
+
readonly DECK: {
|
|
255
|
+
readonly CREATE_OWN: "deck:create:own";
|
|
256
|
+
readonly CREATE_PUBLIC: "deck:create:public";
|
|
257
|
+
readonly READ_OWN: "deck:read:own";
|
|
258
|
+
readonly READ_OTHERS: "deck:read:others";
|
|
259
|
+
readonly READ_UNPUBLISHED: "deck:read:unpublished";
|
|
260
|
+
readonly READ_FREE: "deck:read:free";
|
|
261
|
+
readonly READ_PREMIUM: "deck:read:premium";
|
|
262
|
+
readonly READ_PRIVATE: "deck:read:private";
|
|
263
|
+
readonly UPDATE_OWN: "deck:update:own";
|
|
264
|
+
readonly UPDATE_PUBLIC: "deck:update:public";
|
|
265
|
+
readonly DELETE_OWN: "deck:delete:own";
|
|
266
|
+
readonly DELETE_PUBLIC: "deck:delete:public";
|
|
267
|
+
};
|
|
268
|
+
readonly CARD_DEMAND: {
|
|
269
|
+
readonly READ_ALL: "card-demand:read:*";
|
|
270
|
+
readonly CREATE: "card-demand:create";
|
|
271
|
+
readonly ACTION: "card-demand:action";
|
|
272
|
+
};
|
|
273
|
+
readonly USER: {
|
|
274
|
+
readonly UPDATE_OWN: "user:update:own";
|
|
275
|
+
readonly UPDATE_ALL: "user:update:*";
|
|
276
|
+
readonly DELETE_OWN: "user:delete:own";
|
|
277
|
+
readonly DELETE_ALL: "user:delete:*";
|
|
278
|
+
readonly READ_OWN: "user:read:own";
|
|
279
|
+
readonly READ_ALL: "user:read:*";
|
|
280
|
+
};
|
|
281
|
+
readonly STATS: {
|
|
282
|
+
readonly VIEW: "stats:view";
|
|
283
|
+
};
|
|
284
|
+
readonly MEMBERSHIP: {
|
|
285
|
+
readonly MANAGE: "membership:manage";
|
|
286
|
+
};
|
|
287
|
+
readonly PLAN: {
|
|
288
|
+
readonly CREATE: "plan:create";
|
|
289
|
+
readonly UPDATE: "plan:update";
|
|
290
|
+
readonly DELETE: "plan:delete";
|
|
291
|
+
};
|
|
292
|
+
readonly BLOGPOST: {
|
|
293
|
+
readonly CREATE: "blogpost:create";
|
|
294
|
+
readonly UPDATE: "blogpost:update";
|
|
295
|
+
readonly DELETE: "blogpost:delete";
|
|
296
|
+
};
|
|
297
|
+
readonly VESTY: {
|
|
298
|
+
readonly CHAT: "vesty:chat";
|
|
299
|
+
};
|
|
300
|
+
readonly STUDY: {
|
|
301
|
+
readonly READ: "study:read";
|
|
302
|
+
readonly WRITE: "study:write";
|
|
303
|
+
};
|
|
304
|
+
readonly LIBRARY: {
|
|
305
|
+
readonly READ: "library:read";
|
|
306
|
+
readonly WRITE: "library:write";
|
|
307
|
+
readonly WRITE_PREMIUM: "library:write:premium";
|
|
308
|
+
};
|
|
309
|
+
readonly ADMIN_PANEL: {
|
|
310
|
+
readonly VIEW: "admin-panel:view";
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export declare const ReviewRating: {
|
|
315
|
+
readonly Manual: "Manual";
|
|
316
|
+
readonly Again: "Again";
|
|
317
|
+
readonly Hard: "Hard";
|
|
318
|
+
readonly Good: "Good";
|
|
319
|
+
readonly Easy: "Easy";
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export declare type ReviewRating = (typeof ReviewRating)[keyof typeof ReviewRating];
|
|
160
323
|
|
|
161
324
|
export declare const reviewRatings: readonly ["Manual", "Again", "Hard", "Good", "Easy"];
|
|
162
325
|
|
|
163
|
-
export declare type ReviewRatingType =
|
|
326
|
+
export declare type ReviewRatingType = ReviewRating;
|
|
164
327
|
|
|
165
328
|
export declare enum ReviewState {
|
|
166
329
|
New = "New",
|
|
@@ -173,6 +336,8 @@ export declare const reviewStates: readonly ["New", "Learning", "Review", "Relea
|
|
|
173
336
|
|
|
174
337
|
export declare type ReviewStateType = keyof typeof ReviewState;
|
|
175
338
|
|
|
339
|
+
export declare const ROLE_PERMISSIONS: Record<UserRole, Permission[]>;
|
|
340
|
+
|
|
176
341
|
export declare type SemanticColor = 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary' | 'default';
|
|
177
342
|
|
|
178
343
|
export declare type StudyStatus = 'not-started' | 'suspended' | 'has-cards' | 'no-cards';
|
|
@@ -183,7 +348,24 @@ export declare type Subject = (typeof SUBJECTS)[number];
|
|
|
183
348
|
|
|
184
349
|
export declare const SUBJECT_COLORS: Record<SubjectWithDefault, SemanticColor>;
|
|
185
350
|
|
|
186
|
-
export declare const SUBJECT_ICONS:
|
|
351
|
+
export declare const SUBJECT_ICONS: {
|
|
352
|
+
readonly matemática: "radical";
|
|
353
|
+
readonly gramática: "spell-check";
|
|
354
|
+
readonly literatura: "book-open";
|
|
355
|
+
readonly biologia: "dna";
|
|
356
|
+
readonly química: "test-tube-diagonal";
|
|
357
|
+
readonly física: "atom";
|
|
358
|
+
readonly história: "scroll";
|
|
359
|
+
readonly geografia: "earth";
|
|
360
|
+
readonly filosofia: "brain";
|
|
361
|
+
readonly sociologia: "users-round";
|
|
362
|
+
readonly redação: "notebook-pen";
|
|
363
|
+
readonly artes: "palette";
|
|
364
|
+
readonly inglês: "languages";
|
|
365
|
+
readonly default: "graduation-cap";
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
declare type SubjectIcon = (typeof SUBJECT_ICONS)[SubjectWithDefault];
|
|
187
369
|
|
|
188
370
|
export declare const SUBJECTS: readonly ["matemática", "geografia", "física", "biologia", "história", "literatura", "gramática", "sociologia", "química", "filosofia", "redação", "artes", "inglês"];
|
|
189
371
|
|
|
@@ -196,6 +378,22 @@ export declare interface Topic {
|
|
|
196
378
|
subject: Subject;
|
|
197
379
|
}
|
|
198
380
|
|
|
381
|
+
export declare const UNPAGINATED_SIZE = 9999;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Unwraps an Eden API response, throwing on error and returning the typed success data.
|
|
385
|
+
*
|
|
386
|
+
* Usage:
|
|
387
|
+
* ```ts
|
|
388
|
+
* queryFn: async (): Promise<IDeckDetail> => {
|
|
389
|
+
* return unwrapApiResponse(await api.v1.decks({ deckId }).get(), 'Erro ao buscar deck.');
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare function unwrapApiResponse<T>({ data, error }: EdenResponse<T>, message: string): Exclude<NonNullable<T>, {
|
|
394
|
+
error: string;
|
|
395
|
+
}>;
|
|
396
|
+
|
|
199
397
|
export declare enum UserRole {
|
|
200
398
|
Admin = "admin",
|
|
201
399
|
Moderator = "moderator",
|
|
@@ -204,4 +402,6 @@ export declare enum UserRole {
|
|
|
204
402
|
|
|
205
403
|
export declare type UserScopeRole = (typeof UserRole)[keyof typeof UserRole];
|
|
206
404
|
|
|
405
|
+
declare type ValueOf<T> = T[keyof T];
|
|
406
|
+
|
|
207
407
|
export { }
|