@pelatform/starter 0.1.7 → 0.1.8
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/{chunk-2ZAZ77F6.js → chunk-IEJXTIKE.js} +51 -44
- package/dist/extend.d.ts +2 -7
- package/dist/extend.js +4 -39
- package/dist/index.d.ts +117 -163
- package/dist/index.js +1040 -290
- package/dist/{ui-DxCTGGLe.d.ts → workspace-CcGHPtq0.d.ts} +74 -218
- package/package.json +34 -13
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lastVisitedWorkspace
|
|
3
|
+
} from "./chunk-K5RU54UL.js";
|
|
4
|
+
|
|
1
5
|
// src/config/query.ts
|
|
2
6
|
var defaultAuthQueryOptions = {
|
|
3
7
|
sessionQueryOptions: {
|
|
@@ -13,50 +17,18 @@ var defaultAuthQueryOptions = {
|
|
|
13
17
|
listDeviceSessions: ["list-device-sessions"],
|
|
14
18
|
listPasskeys: ["list-passkeys"],
|
|
15
19
|
listSessions: ["list-sessions"],
|
|
16
|
-
session: ["session"]
|
|
20
|
+
session: ["session"],
|
|
21
|
+
// Workspace
|
|
22
|
+
workspaceById: (id) => ["workspace", id],
|
|
23
|
+
workspaceBySlug: (slug) => ["workspace_by_slug", slug],
|
|
24
|
+
workspaceList: ["workspaces"],
|
|
25
|
+
// Workspace-scoped resources
|
|
26
|
+
webhooks: (workspaceId) => ["webhooks", workspaceId],
|
|
27
|
+
billings: (workspaceId) => ["billings", workspaceId],
|
|
28
|
+
billingUsage: (workspaceId) => ["billing-usage", workspaceId]
|
|
17
29
|
}
|
|
18
30
|
};
|
|
19
31
|
|
|
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
32
|
// src/lib/password-schema.ts
|
|
61
33
|
import { z } from "zod";
|
|
62
34
|
function getPasswordSchema(t) {
|
|
@@ -83,6 +55,34 @@ function getPasswordSchema(t) {
|
|
|
83
55
|
return schema;
|
|
84
56
|
}
|
|
85
57
|
|
|
58
|
+
// src/lib/request.ts
|
|
59
|
+
async function request(endpoint, method = "GET", body, log) {
|
|
60
|
+
const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
|
|
61
|
+
const headers = {};
|
|
62
|
+
let payload;
|
|
63
|
+
if (body !== void 0) {
|
|
64
|
+
if (isFormData) {
|
|
65
|
+
payload = body;
|
|
66
|
+
} else {
|
|
67
|
+
headers["Content-Type"] = "application/json";
|
|
68
|
+
payload = JSON.stringify(body);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const response = await fetch(endpoint, {
|
|
72
|
+
method,
|
|
73
|
+
headers,
|
|
74
|
+
body: payload
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(response.statusText);
|
|
78
|
+
}
|
|
79
|
+
const data = await response.json();
|
|
80
|
+
if (log) {
|
|
81
|
+
console.log(endpoint, data);
|
|
82
|
+
}
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
86
|
// src/lib/social-providers.ts
|
|
87
87
|
import { Icons } from "pelatform-ui";
|
|
88
88
|
var socialProviders = [
|
|
@@ -224,11 +224,18 @@ function getTranslations({
|
|
|
224
224
|
return error?.message || t("systems.REQUEST_FAILED") || "Request failed";
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
// src/lib/workspace/client.ts
|
|
228
|
+
var setLastVisitedWorkspace = (workspace, maxAge = 30 * 86400) => {
|
|
229
|
+
document.cookie = `${lastVisitedWorkspace}=${workspace}; max-age=${maxAge}; path=/`;
|
|
230
|
+
};
|
|
231
|
+
var getLastVisitedWorkspace = (cookies) => cookies.get(lastVisitedWorkspace)?.value;
|
|
232
|
+
|
|
227
233
|
export {
|
|
228
234
|
defaultAuthQueryOptions,
|
|
229
|
-
resizeAndCropImage,
|
|
230
|
-
fileToBase64,
|
|
231
235
|
getPasswordSchema,
|
|
236
|
+
request,
|
|
232
237
|
socialProviders,
|
|
233
|
-
getTranslations
|
|
238
|
+
getTranslations,
|
|
239
|
+
setLastVisitedWorkspace,
|
|
240
|
+
getLastVisitedWorkspace
|
|
234
241
|
};
|
package/dist/extend.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 './
|
|
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, W as Workspace, f as authClient, d as defaultAuthQueryOptions } from './workspace-CcGHPtq0.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
@@ -10,13 +10,8 @@ export { Member, Organization } from 'better-auth/plugins/organization';
|
|
|
10
10
|
export { SocialProvider } from 'better-auth/social-providers';
|
|
11
11
|
import '@tanstack/react-query';
|
|
12
12
|
import 'better-auth/client/plugins';
|
|
13
|
-
import '@simplewebauthn/server';
|
|
14
|
-
import '@better-fetch/fetch';
|
|
15
13
|
import 'pelatform-ui/default';
|
|
16
14
|
|
|
17
|
-
declare function resizeAndCropImage(file: File, name: string, size: number, extension: string): Promise<File>;
|
|
18
|
-
declare function fileToBase64(file: File): Promise<string>;
|
|
19
|
-
|
|
20
15
|
declare function getPasswordSchema(t: (key: string) => string): z.ZodString;
|
|
21
16
|
|
|
22
17
|
type RequestMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
@@ -138,4 +133,4 @@ declare const lastVisitedWorkspace = "last-visited-workspace";
|
|
|
138
133
|
declare const WORKSPACE_SCOPED_PREFIXES: readonly ["webhooks"];
|
|
139
134
|
type WorkspaceScopedPrefix = (typeof WORKSPACE_SCOPED_PREFIXES)[number];
|
|
140
135
|
|
|
141
|
-
export { WORKSPACE_SCOPED_PREFIXES, type WorkspaceScopedPrefix,
|
|
136
|
+
export { WORKSPACE_SCOPED_PREFIXES, type WorkspaceScopedPrefix, getLastVisitedWorkspace, getPasswordSchema, getTranslations, lastVisitedWorkspace, request, setLastVisitedWorkspace, socialProviders };
|
package/dist/extend.js
CHANGED
|
@@ -1,59 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultAuthQueryOptions,
|
|
3
|
-
|
|
3
|
+
getLastVisitedWorkspace,
|
|
4
4
|
getPasswordSchema,
|
|
5
5
|
getTranslations,
|
|
6
|
-
|
|
6
|
+
request,
|
|
7
|
+
setLastVisitedWorkspace,
|
|
7
8
|
socialProviders
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-IEJXTIKE.js";
|
|
9
10
|
import {
|
|
10
11
|
WORKSPACE_SCOPED_PREFIXES,
|
|
11
12
|
lastVisitedWorkspace
|
|
12
13
|
} from "./chunk-K5RU54UL.js";
|
|
13
|
-
|
|
14
|
-
// src/lib/request.ts
|
|
15
|
-
async function request(endpoint, method = "GET", body, log) {
|
|
16
|
-
const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
|
|
17
|
-
const headers = {};
|
|
18
|
-
let payload;
|
|
19
|
-
if (body !== void 0) {
|
|
20
|
-
if (isFormData) {
|
|
21
|
-
payload = body;
|
|
22
|
-
} else {
|
|
23
|
-
headers["Content-Type"] = "application/json";
|
|
24
|
-
payload = JSON.stringify(body);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const response = await fetch(endpoint, {
|
|
28
|
-
method,
|
|
29
|
-
headers,
|
|
30
|
-
body: payload
|
|
31
|
-
});
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
throw new Error(response.statusText);
|
|
34
|
-
}
|
|
35
|
-
const data = await response.json();
|
|
36
|
-
if (log) {
|
|
37
|
-
console.log(endpoint, data);
|
|
38
|
-
}
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/lib/workspace/client.ts
|
|
43
|
-
var setLastVisitedWorkspace = (workspace, maxAge = 30 * 86400) => {
|
|
44
|
-
document.cookie = `${lastVisitedWorkspace}=${workspace}; max-age=${maxAge}; path=/`;
|
|
45
|
-
};
|
|
46
|
-
var getLastVisitedWorkspace = (cookies) => cookies.get(lastVisitedWorkspace)?.value;
|
|
47
14
|
export {
|
|
48
15
|
WORKSPACE_SCOPED_PREFIXES,
|
|
49
16
|
defaultAuthQueryOptions,
|
|
50
|
-
fileToBase64,
|
|
51
17
|
getLastVisitedWorkspace,
|
|
52
18
|
getPasswordSchema,
|
|
53
19
|
getTranslations,
|
|
54
20
|
lastVisitedWorkspace,
|
|
55
21
|
request,
|
|
56
|
-
resizeAndCropImage,
|
|
57
22
|
setLastVisitedWorkspace,
|
|
58
23
|
socialProviders
|
|
59
24
|
};
|