@pelatform/starter 0.1.5 → 0.1.6

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.
@@ -0,0 +1,234 @@
1
+ // src/config/query.ts
2
+ var defaultAuthQueryOptions = {
3
+ sessionQueryOptions: {
4
+ staleTime: 60 * 1e3
5
+ },
6
+ optimistic: true,
7
+ refetchOnMutate: true,
8
+ queryKey: {
9
+ accountInfo: ["account-info"],
10
+ invitationKey: ["invitation"],
11
+ listAccounts: ["list-accounts"],
12
+ listApiKeys: ["list-api-keys"],
13
+ listDeviceSessions: ["list-device-sessions"],
14
+ listPasskeys: ["list-passkeys"],
15
+ listSessions: ["list-sessions"],
16
+ session: ["session"]
17
+ }
18
+ };
19
+
20
+ // src/lib/images.ts
21
+ async function resizeAndCropImage(file, name, size, extension) {
22
+ const image = await loadImage(file);
23
+ const canvas = document.createElement("canvas");
24
+ canvas.width = canvas.height = size;
25
+ const ctx = canvas.getContext("2d");
26
+ const minEdge = Math.min(image.width, image.height);
27
+ const sx = (image.width - minEdge) / 2;
28
+ const sy = (image.height - minEdge) / 2;
29
+ const sWidth = minEdge;
30
+ const sHeight = minEdge;
31
+ ctx?.drawImage(image, sx, sy, sWidth, sHeight, 0, 0, size, size);
32
+ const resizedImageBlob = await new Promise(
33
+ (resolve) => canvas.toBlob(resolve, `image/${extension}`)
34
+ );
35
+ return new File([resizedImageBlob], `${name}.${extension}`, {
36
+ type: `image/${extension}`
37
+ });
38
+ }
39
+ async function loadImage(file) {
40
+ return new Promise((resolve, reject) => {
41
+ const image = new Image();
42
+ const reader = new FileReader();
43
+ reader.onload = (e) => {
44
+ image.src = e.target?.result;
45
+ };
46
+ image.onload = () => resolve(image);
47
+ image.onerror = (err) => reject(err);
48
+ reader.readAsDataURL(file);
49
+ });
50
+ }
51
+ async function fileToBase64(file) {
52
+ return new Promise((resolve, reject) => {
53
+ const reader = new FileReader();
54
+ reader.onloadend = () => resolve(reader.result);
55
+ reader.onerror = reject;
56
+ reader.readAsDataURL(file);
57
+ });
58
+ }
59
+
60
+ // src/lib/password-schema.ts
61
+ import { z } from "zod";
62
+ function getPasswordSchema(t) {
63
+ const getError = (key, fallback) => {
64
+ return t ? t(`systems.${key}`) : fallback;
65
+ };
66
+ const minLength = 8;
67
+ const maxLength = 32;
68
+ const regex = void 0;
69
+ let schema = z.string().min(1, {
70
+ error: getError("PASSWORD_REQUIRED", "Password is required")
71
+ });
72
+ schema = schema.min(minLength, {
73
+ error: getError("PASSWORD_TOO_SHORT", "Password is too short")
74
+ });
75
+ schema = schema.max(maxLength, {
76
+ error: getError("PASSWORD_TOO_LONG", "Password is too long")
77
+ });
78
+ if (regex) {
79
+ schema = schema.regex(regex, {
80
+ error: getError("INVALID_PASSWORD", "Invalid password")
81
+ });
82
+ }
83
+ return schema;
84
+ }
85
+
86
+ // src/lib/social-providers.ts
87
+ import { Icons } from "pelatform-ui";
88
+ var socialProviders = [
89
+ {
90
+ provider: "apple",
91
+ name: "Apple",
92
+ icon: Icons.Apple
93
+ },
94
+ {
95
+ provider: "discord",
96
+ name: "Discord",
97
+ icon: Icons.Discord
98
+ },
99
+ {
100
+ provider: "dropbox",
101
+ name: "Dropbox",
102
+ icon: Icons.Dropbox
103
+ },
104
+ {
105
+ provider: "facebook",
106
+ name: "Facebook",
107
+ icon: Icons.FacebookColorful
108
+ },
109
+ {
110
+ provider: "github",
111
+ name: "GitHub",
112
+ icon: Icons.Github
113
+ },
114
+ {
115
+ provider: "gitlab",
116
+ name: "GitLab",
117
+ icon: Icons.Gitlab
118
+ },
119
+ {
120
+ provider: "google",
121
+ name: "Google",
122
+ icon: Icons.GoogleColorful
123
+ },
124
+ {
125
+ provider: "huggingface",
126
+ name: "Hugging Face",
127
+ icon: Icons.Huggingface
128
+ },
129
+ {
130
+ provider: "kick",
131
+ name: "Kick",
132
+ icon: Icons.Kick
133
+ },
134
+ {
135
+ provider: "linear",
136
+ name: "Linear",
137
+ icon: Icons.Linear
138
+ },
139
+ {
140
+ provider: "linkedin",
141
+ name: "LinkedIn",
142
+ icon: Icons.LinkedinColorful
143
+ },
144
+ {
145
+ provider: "microsoft",
146
+ name: "Microsoft",
147
+ icon: Icons.Microsoft
148
+ },
149
+ {
150
+ provider: "notion",
151
+ name: "Notion",
152
+ icon: Icons.Notion
153
+ },
154
+ {
155
+ provider: "reddit",
156
+ name: "Reddit",
157
+ icon: Icons.Reddit
158
+ },
159
+ {
160
+ provider: "roblox",
161
+ name: "Roblox",
162
+ icon: Icons.Roblox
163
+ },
164
+ {
165
+ provider: "slack",
166
+ name: "Slack",
167
+ icon: Icons.Slack
168
+ },
169
+ {
170
+ provider: "spotify",
171
+ name: "Spotify",
172
+ icon: Icons.Spotify
173
+ },
174
+ {
175
+ provider: "tiktok",
176
+ name: "TikTok",
177
+ icon: Icons.Tiktok
178
+ },
179
+ {
180
+ provider: "twitch",
181
+ name: "Twitch",
182
+ icon: Icons.Twitch
183
+ },
184
+ {
185
+ provider: "vk",
186
+ name: "VK",
187
+ icon: Icons.Vk
188
+ },
189
+ {
190
+ provider: "twitter",
191
+ name: "X",
192
+ icon: Icons.X
193
+ },
194
+ {
195
+ provider: "zoom",
196
+ name: "Zoom",
197
+ icon: Icons.Zoom
198
+ }
199
+ ];
200
+
201
+ // src/lib/translations.ts
202
+ function getTranslations({
203
+ error,
204
+ t
205
+ }) {
206
+ if (typeof error === "string") {
207
+ const translated = t(`systems.${error}`);
208
+ if (translated && translated !== `systems.${error}`) {
209
+ return translated;
210
+ }
211
+ return error;
212
+ }
213
+ if (error?.error) {
214
+ if (error.error.code) {
215
+ const errorCode = error.error.code;
216
+ const translated = t(`systems.${errorCode}`);
217
+ if (translated && translated !== `systems.${errorCode}`) {
218
+ return translated;
219
+ }
220
+ return errorCode;
221
+ }
222
+ return error.error.message || error.error.code || error.error.statusText || t("systems.REQUEST_FAILED");
223
+ }
224
+ return error?.message || t("systems.REQUEST_FAILED") || "Request failed";
225
+ }
226
+
227
+ export {
228
+ defaultAuthQueryOptions,
229
+ resizeAndCropImage,
230
+ fileToBase64,
231
+ getPasswordSchema,
232
+ socialProviders,
233
+ getTranslations
234
+ };
package/dist/extend.d.ts CHANGED
@@ -1,118 +1,115 @@
1
- import { j as ProviderIcon } from './ui-DhgTAR3u.js';
2
- export { t as ActiveOrganization, b as AnyAuthClient, e as ApiKey, l as AppConfig, A as AuthClient, o as AuthConfig, a as AuthQueryOptions, n as AuthenticationConfig, x as AvatarClassNames, i as AvatarProps, B as BetterFetchRequest, d as CardClassNames, c as CardComponentProps, C as Config, z as DialogClassNames, D as DialogComponentProps, p as FeaturesConfig, w as FetchError, F as FieldType, m as I18nConfig, I as ImageOptions, v as Invitation, u as Locale, L as LocaleConfig, N as NonThrowableResult, P as PasswordValidation, f as PathConfig, h as Profile, g as Provider, R as Refetch, S as Session, s as SessionData, T as ThrowableResult, q as UIConfig, U as User, y as ViewClassNames, V as ViewProps, r as authClient, k as defaultAuthQueryOptions } from './ui-DhgTAR3u.js';
3
- import { z } from '@pelatform/ui/re/zod';
1
+ export { j as ActiveOrganization, e as AnyAuthClient, p as ApiKey, a as AppConfig, g as AuthClient, c as AuthConfig, A as AuthQueryOptions, b as AuthenticationConfig, u as AvatarClassNames, w as AvatarProps, B as BetterFetchRequest, v as CardClassNames, z as CardComponentProps, C as Config, D as DialogClassNames, y as DialogComponentProps, F as FeaturesConfig, t as FetchError, l as FieldType, I as I18nConfig, m as ImageOptions, q as Invitation, k as Locale, L as LocaleConfig, N as NonThrowableResult, r as PasswordValidation, P as PathConfig, s as Profile, o as Provider, n as ProviderIcon, R as Refetch, h as Session, S as SessionData, T as ThrowableResult, U as UIConfig, i as User, V as ViewClassNames, x as ViewProps, f as authClient, d as defaultAuthQueryOptions } from './ui-BjeCRH96.js';
2
+ import { z } from 'zod';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import * as react from 'react';
4
5
  import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies';
5
6
  import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies';
6
7
  export { Account } from 'better-auth';
7
8
  export { BetterFetchOption } from 'better-auth/react';
8
9
  export { Member, Organization } from 'better-auth/plugins/organization';
9
10
  export { SocialProvider } from 'better-auth/social-providers';
10
- import 'node_modules/better-auth/dist/index-BLP8lbCx.mjs';
11
- import 'node_modules/better-auth/dist/index-CfImj7fH.mjs';
12
- import '@simplewebauthn/server';
11
+ import '@tanstack/react-query';
13
12
  import 'better-auth/client/plugins';
13
+ import '@simplewebauthn/server';
14
14
  import '@better-fetch/fetch';
15
- import 'node_modules/@better-auth/passkey/dist/index-BosVYrMJ.mjs';
16
- import '@pelatform/ui/re/tanstack-query';
17
- import 'react';
18
- import '@pelatform/ui/default';
15
+ import 'pelatform-ui/default';
19
16
 
20
17
  declare function resizeAndCropImage(file: File, name: string, size: number, extension: string): Promise<File>;
21
18
  declare function fileToBase64(file: File): Promise<string>;
22
19
 
23
20
  declare function getPasswordSchema(t: (key: string) => string): z.ZodString;
24
21
 
25
- type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
22
+ type RequestMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
26
23
  declare function request(endpoint: string, method?: RequestMethod, body?: unknown, log?: boolean): Promise<any>;
27
24
 
28
25
  declare const socialProviders: readonly [{
29
26
  readonly provider: "apple";
30
27
  readonly name: "Apple";
31
- readonly icon: ProviderIcon;
28
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
32
29
  }, {
33
30
  readonly provider: "discord";
34
31
  readonly name: "Discord";
35
- readonly icon: ProviderIcon;
32
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
36
33
  }, {
37
34
  readonly provider: "dropbox";
38
35
  readonly name: "Dropbox";
39
- readonly icon: ProviderIcon;
36
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
40
37
  }, {
41
38
  readonly provider: "facebook";
42
39
  readonly name: "Facebook";
43
- readonly icon: ProviderIcon;
40
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
44
41
  }, {
45
42
  readonly provider: "github";
46
43
  readonly name: "GitHub";
47
- readonly icon: ProviderIcon;
44
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
48
45
  }, {
49
46
  readonly provider: "gitlab";
50
47
  readonly name: "GitLab";
51
- readonly icon: ProviderIcon;
48
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
52
49
  }, {
53
50
  readonly provider: "google";
54
51
  readonly name: "Google";
55
- readonly icon: ProviderIcon;
52
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
56
53
  }, {
57
54
  readonly provider: "huggingface";
58
55
  readonly name: "Hugging Face";
59
- readonly icon: ProviderIcon;
56
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
60
57
  }, {
61
58
  readonly provider: "kick";
62
59
  readonly name: "Kick";
63
- readonly icon: ProviderIcon;
60
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
64
61
  }, {
65
62
  readonly provider: "linear";
66
63
  readonly name: "Linear";
67
- readonly icon: ProviderIcon;
64
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
68
65
  }, {
69
66
  readonly provider: "linkedin";
70
67
  readonly name: "LinkedIn";
71
- readonly icon: ProviderIcon;
68
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
72
69
  }, {
73
70
  readonly provider: "microsoft";
74
71
  readonly name: "Microsoft";
75
- readonly icon: ProviderIcon;
72
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
76
73
  }, {
77
74
  readonly provider: "notion";
78
75
  readonly name: "Notion";
79
- readonly icon: ProviderIcon;
76
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
80
77
  }, {
81
78
  readonly provider: "reddit";
82
79
  readonly name: "Reddit";
83
- readonly icon: ProviderIcon;
80
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
84
81
  }, {
85
82
  readonly provider: "roblox";
86
83
  readonly name: "Roblox";
87
- readonly icon: ProviderIcon;
84
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
88
85
  }, {
89
86
  readonly provider: "slack";
90
87
  readonly name: "Slack";
91
- readonly icon: ProviderIcon;
88
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
92
89
  }, {
93
90
  readonly provider: "spotify";
94
91
  readonly name: "Spotify";
95
- readonly icon: ProviderIcon;
92
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
96
93
  }, {
97
94
  readonly provider: "tiktok";
98
95
  readonly name: "TikTok";
99
- readonly icon: ProviderIcon;
96
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
100
97
  }, {
101
98
  readonly provider: "twitch";
102
99
  readonly name: "Twitch";
103
- readonly icon: ProviderIcon;
100
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
104
101
  }, {
105
102
  readonly provider: "vk";
106
103
  readonly name: "VK";
107
- readonly icon: ProviderIcon;
104
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
108
105
  }, {
109
106
  readonly provider: "twitter";
110
107
  readonly name: "X";
111
- readonly icon: ProviderIcon;
108
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
112
109
  }, {
113
110
  readonly provider: "zoom";
114
111
  readonly name: "Zoom";
115
- readonly icon: ProviderIcon;
112
+ readonly icon: (props: react.HTMLAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
116
113
  }];
117
114
 
118
115
  /**
@@ -141,4 +138,4 @@ declare const lastVisitedWorkspace = "last-visited-workspace";
141
138
  declare const WORKSPACE_SCOPED_PREFIXES: readonly ["webhooks"];
142
139
  type WorkspaceScopedPrefix = (typeof WORKSPACE_SCOPED_PREFIXES)[number];
143
140
 
144
- export { ProviderIcon, WORKSPACE_SCOPED_PREFIXES, type WorkspaceScopedPrefix, fileToBase64, getLastVisitedWorkspace, getPasswordSchema, getTranslations, lastVisitedWorkspace, request, resizeAndCropImage, setLastVisitedWorkspace, socialProviders };
141
+ export { WORKSPACE_SCOPED_PREFIXES, type WorkspaceScopedPrefix, fileToBase64, getLastVisitedWorkspace, getPasswordSchema, getTranslations, lastVisitedWorkspace, request, resizeAndCropImage, setLastVisitedWorkspace, socialProviders };
package/dist/extend.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  getTranslations,
6
6
  resizeAndCropImage,
7
7
  socialProviders
8
- } from "./chunk-ZWKHMRY6.js";
8
+ } from "./chunk-2ZAZ77F6.js";
9
9
  import {
10
10
  WORKSPACE_SCOPED_PREFIXES,
11
11
  lastVisitedWorkspace