@iglo.tech/iglo.base 0.0.0-stage → 1.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/CHANGELOG.md +18 -0
- package/LICENSE +18 -0
- package/README.md +778 -2
- package/dist/iglo-base.es.mjs +4 -0
- package/dist/iglo-base.es.mjs.map +34 -0
- package/dist/ssr-astro.es.mjs +4 -0
- package/dist/ssr-astro.es.mjs.map +12 -0
- package/dist/ssr-browser-client.es.mjs +4 -0
- package/dist/ssr-browser-client.es.mjs.map +13 -0
- package/dist/ssr-browser.es.mjs +4 -0
- package/dist/ssr-browser.es.mjs.map +10 -0
- package/dist/ssr-next.es.mjs +4 -0
- package/dist/ssr-next.es.mjs.map +12 -0
- package/dist/ssr-nuxt.es.mjs +4 -0
- package/dist/ssr-nuxt.es.mjs.map +12 -0
- package/dist/ssr-react-router.es.mjs +4 -0
- package/dist/ssr-react-router.es.mjs.map +12 -0
- package/dist/ssr-sveltekit.es.mjs +4 -0
- package/dist/ssr-sveltekit.es.mjs.map +12 -0
- package/dist/ssr.es.mjs +4 -0
- package/dist/ssr.es.mjs.map +22 -0
- package/dist/types/src/Client.d.ts +233 -0
- package/dist/types/src/ClientResponseError.d.ts +22 -0
- package/dist/types/src/index.d.ts +18 -0
- package/dist/types/src/services/BackupService.d.ts +59 -0
- package/dist/types/src/services/BaseService.d.ts +8 -0
- package/dist/types/src/services/BatchService.d.ts +56 -0
- package/dist/types/src/services/CollectionService.d.ts +47 -0
- package/dist/types/src/services/CronService.d.ts +20 -0
- package/dist/types/src/services/CrudService.d.ts +85 -0
- package/dist/types/src/services/FileService.d.ts +19 -0
- package/dist/types/src/services/HealthService.d.ts +16 -0
- package/dist/types/src/services/LogService.d.ts +35 -0
- package/dist/types/src/services/RealtimeService.d.ts +124 -0
- package/dist/types/src/services/RecordService.d.ts +374 -0
- package/dist/types/src/services/SQLService.d.ts +21 -0
- package/dist/types/src/services/SettingsService.d.ts +46 -0
- package/dist/types/src/ssr/adapter.d.ts +133 -0
- package/dist/types/src/ssr/astro.d.ts +27 -0
- package/dist/types/src/ssr/browser-client.d.ts +100 -0
- package/dist/types/src/ssr/browser-token.d.ts +29 -0
- package/dist/types/src/ssr/browser.d.ts +1 -0
- package/dist/types/src/ssr/cache.d.ts +9 -0
- package/dist/types/src/ssr/cookies.d.ts +68 -0
- package/dist/types/src/ssr/csrf.d.ts +38 -0
- package/dist/types/src/ssr/index.d.ts +12 -0
- package/dist/types/src/ssr/next.d.ts +53 -0
- package/dist/types/src/ssr/no-store-fetch.d.ts +7 -0
- package/dist/types/src/ssr/nuxt.d.ts +41 -0
- package/dist/types/src/ssr/oauth2.d.ts +56 -0
- package/dist/types/src/ssr/popup.d.ts +14 -0
- package/dist/types/src/ssr/react-router.d.ts +53 -0
- package/dist/types/src/ssr/renew.d.ts +25 -0
- package/dist/types/src/ssr/server-client.d.ts +83 -0
- package/dist/types/src/ssr/superuser-client.d.ts +24 -0
- package/dist/types/src/ssr/sveltekit.d.ts +44 -0
- package/dist/types/src/ssr/types.d.ts +118 -0
- package/dist/types/src/stores/AsyncAuthStore.d.ts +52 -0
- package/dist/types/src/stores/BaseAuthStore.d.ts +104 -0
- package/dist/types/src/stores/LocalAuthStore.d.ts +48 -0
- package/dist/types/src/tools/cookie.d.ts +31 -0
- package/dist/types/src/tools/dtos.d.ts +122 -0
- package/dist/types/src/tools/formdata.d.ts +30 -0
- package/dist/types/src/tools/jwt.d.ts +14 -0
- package/dist/types/src/tools/legacy.d.ts +2 -0
- package/dist/types/src/tools/loose.d.ts +5 -0
- package/dist/types/src/tools/options.d.ts +91 -0
- package/dist/types/src/tools/refresh.d.ts +3 -0
- package/package.json +73 -4
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Loose, LooseObject } from "./loose.js";
|
|
2
|
+
export interface ListResult<T> {
|
|
3
|
+
page: number;
|
|
4
|
+
perPage: number;
|
|
5
|
+
totalItems: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
items: Array<T>;
|
|
8
|
+
}
|
|
9
|
+
export interface BaseModel {
|
|
10
|
+
[key: string]: Loose;
|
|
11
|
+
id: string;
|
|
12
|
+
}
|
|
13
|
+
export interface LogModel extends BaseModel {
|
|
14
|
+
level: string;
|
|
15
|
+
message: string;
|
|
16
|
+
created: string;
|
|
17
|
+
updated: string;
|
|
18
|
+
data: LooseObject;
|
|
19
|
+
}
|
|
20
|
+
export interface RecordModel extends BaseModel {
|
|
21
|
+
collectionId: string;
|
|
22
|
+
collectionName: string;
|
|
23
|
+
expand?: LooseObject;
|
|
24
|
+
}
|
|
25
|
+
export interface CollectionField {
|
|
26
|
+
[key: string]: Loose;
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
system: boolean;
|
|
31
|
+
hidden: boolean;
|
|
32
|
+
presentable: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface TokenConfig {
|
|
35
|
+
duration: number;
|
|
36
|
+
secret?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface AuthAlertConfig {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
emailTemplate: EmailTemplate;
|
|
41
|
+
}
|
|
42
|
+
export interface OTPConfig {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
duration: number;
|
|
45
|
+
length: number;
|
|
46
|
+
emailTemplate: EmailTemplate;
|
|
47
|
+
}
|
|
48
|
+
export interface MFAConfig {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
duration: number;
|
|
51
|
+
rule: string;
|
|
52
|
+
}
|
|
53
|
+
export interface PasswordAuthConfig {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
identityFields: Array<string>;
|
|
56
|
+
}
|
|
57
|
+
export interface OAuth2Provider {
|
|
58
|
+
pkce?: boolean;
|
|
59
|
+
clientId: string;
|
|
60
|
+
name: string;
|
|
61
|
+
clientSecret: string;
|
|
62
|
+
authURL: string;
|
|
63
|
+
tokenURL: string;
|
|
64
|
+
userInfoURL: string;
|
|
65
|
+
displayName: string;
|
|
66
|
+
logo: string;
|
|
67
|
+
extra?: LooseObject;
|
|
68
|
+
}
|
|
69
|
+
export interface ConfigurableOAuth2Provider {
|
|
70
|
+
name: string;
|
|
71
|
+
displayName: string;
|
|
72
|
+
logo: string;
|
|
73
|
+
}
|
|
74
|
+
export interface OAuth2Config {
|
|
75
|
+
enabled: boolean;
|
|
76
|
+
mappedFields: {
|
|
77
|
+
[key: string]: string;
|
|
78
|
+
};
|
|
79
|
+
providers: Array<OAuth2Provider>;
|
|
80
|
+
}
|
|
81
|
+
export interface EmailTemplate {
|
|
82
|
+
subject: string;
|
|
83
|
+
body: string;
|
|
84
|
+
}
|
|
85
|
+
interface collection extends BaseModel {
|
|
86
|
+
name: string;
|
|
87
|
+
fields: Array<CollectionField>;
|
|
88
|
+
indexes: Array<string>;
|
|
89
|
+
system: boolean;
|
|
90
|
+
listRule?: string;
|
|
91
|
+
viewRule?: string;
|
|
92
|
+
createRule?: string;
|
|
93
|
+
updateRule?: string;
|
|
94
|
+
deleteRule?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface BaseCollectionModel extends collection {
|
|
97
|
+
type: "base";
|
|
98
|
+
}
|
|
99
|
+
export interface ViewCollectionModel extends collection {
|
|
100
|
+
type: "view";
|
|
101
|
+
viewQuery: string;
|
|
102
|
+
}
|
|
103
|
+
export interface AuthCollectionModel extends collection {
|
|
104
|
+
type: "auth";
|
|
105
|
+
authRule?: string;
|
|
106
|
+
manageRule?: string;
|
|
107
|
+
authAlert: AuthAlertConfig;
|
|
108
|
+
oauth2: OAuth2Config;
|
|
109
|
+
passwordAuth: PasswordAuthConfig;
|
|
110
|
+
mfa: MFAConfig;
|
|
111
|
+
otp: OTPConfig;
|
|
112
|
+
authToken: TokenConfig;
|
|
113
|
+
passwordResetToken: TokenConfig;
|
|
114
|
+
emailChangeToken: TokenConfig;
|
|
115
|
+
verificationToken: TokenConfig;
|
|
116
|
+
fileToken: TokenConfig;
|
|
117
|
+
verificationTemplate: EmailTemplate;
|
|
118
|
+
resetPasswordTemplate: EmailTemplate;
|
|
119
|
+
confirmEmailChangeTemplate: EmailTemplate;
|
|
120
|
+
}
|
|
121
|
+
export type CollectionModel = BaseCollectionModel | ViewCollectionModel | AuthCollectionModel;
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the specified value is a file (aka. File, Blob, RN file object).
|
|
3
|
+
*/
|
|
4
|
+
export declare function isFile(val: unknown): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Loosely checks if the specified body is a FormData instance.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isFormData(body: unknown): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the submitted body object has at least one Blob/File field value.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasFileField(body: unknown): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Converts analyzes the provided body and converts it to FormData
|
|
15
|
+
* in case a plain object with File/Blob values is used.
|
|
16
|
+
*/
|
|
17
|
+
export declare function convertToFormDataIfNeeded(body: unknown): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Converts the provided FormData instance into a plain object.
|
|
20
|
+
*
|
|
21
|
+
* For consistency with the server multipart/form-data inferring,
|
|
22
|
+
* the following normalization rules are applied for plain multipart string values:
|
|
23
|
+
* - "true" is converted to the json "true"
|
|
24
|
+
* - "false" is converted to the json "false"
|
|
25
|
+
* - numeric strings are converted to json number ONLY if the resulted
|
|
26
|
+
* minimal number string representation is the same as the provided raw string
|
|
27
|
+
* (aka. scientific notations, "Infinity", "0.0", "0001", etc. are kept as string)
|
|
28
|
+
* - any other string (empty string too) is left as it is
|
|
29
|
+
*/
|
|
30
|
+
export declare function convertFormDataToObject(formData: FormData): Record<string, unknown>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LooseObject } from "./loose.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns JWT token's payload data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getTokenPayload(token: string): LooseObject;
|
|
6
|
+
/**
|
|
7
|
+
* Checks whether a JWT token is expired or not.
|
|
8
|
+
* Tokens without `exp` payload key are considered valid.
|
|
9
|
+
* Tokens with empty payload (eg. invalid token strings) are considered expired.
|
|
10
|
+
*
|
|
11
|
+
* @param token The token to check.
|
|
12
|
+
* @param [expirationThreshold] Time in seconds that will be subtracted from the token `exp` property.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isTokenExpired(token: string, expirationThreshold?: number): boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Loose, LooseObject } from "./loose.js";
|
|
2
|
+
export interface SendOptions extends RequestInit {
|
|
3
|
+
[key: string]: Loose;
|
|
4
|
+
/**
|
|
5
|
+
* Optional custom fetch function to use for sending the request.
|
|
6
|
+
*/
|
|
7
|
+
fetch?: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response>;
|
|
8
|
+
/**
|
|
9
|
+
* Custom headers to send with the requests.
|
|
10
|
+
*/
|
|
11
|
+
headers?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The body of the request (serialized automatically for json requests).
|
|
16
|
+
*/
|
|
17
|
+
body?: Loose;
|
|
18
|
+
/**
|
|
19
|
+
* Query parameters that will be appended to the request url.
|
|
20
|
+
*/
|
|
21
|
+
query?: LooseObject;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use `query` instead
|
|
24
|
+
*
|
|
25
|
+
* for backward-compatibility `params` values are merged with `query`,
|
|
26
|
+
* but this option may get removed in the final v1 release
|
|
27
|
+
*/
|
|
28
|
+
params?: LooseObject;
|
|
29
|
+
/**
|
|
30
|
+
* The request identifier that can be used to cancel pending requests.
|
|
31
|
+
*/
|
|
32
|
+
requestKey?: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated use `requestKey:string` instead
|
|
35
|
+
*/
|
|
36
|
+
$cancelKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use `requestKey:null` instead
|
|
39
|
+
*/
|
|
40
|
+
$autoCancel?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface CommonOptions extends SendOptions {
|
|
43
|
+
fields?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ListOptions extends CommonOptions {
|
|
46
|
+
page?: number;
|
|
47
|
+
perPage?: number;
|
|
48
|
+
sort?: string;
|
|
49
|
+
filter?: string;
|
|
50
|
+
skipTotal?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface FullListOptions extends ListOptions {
|
|
53
|
+
batch?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface RecordOptions extends CommonOptions {
|
|
56
|
+
expand?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface RecordListOptions extends ListOptions, RecordOptions {
|
|
59
|
+
}
|
|
60
|
+
export interface RecordFullListOptions extends FullListOptions, RecordOptions {
|
|
61
|
+
}
|
|
62
|
+
export interface RecordSubscribeOptions extends SendOptions {
|
|
63
|
+
fields?: string;
|
|
64
|
+
filter?: string;
|
|
65
|
+
expand?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface LogStatsOptions extends CommonOptions {
|
|
68
|
+
filter?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface FileOptions extends CommonOptions {
|
|
71
|
+
thumb?: string;
|
|
72
|
+
download?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface AuthOptions extends CommonOptions {
|
|
75
|
+
/**
|
|
76
|
+
* If autoRefreshThreshold is set it will take care to auto refresh
|
|
77
|
+
* when necessary the auth data before each request to ensure that
|
|
78
|
+
* the auth state is always valid.
|
|
79
|
+
*
|
|
80
|
+
* The value must be in seconds, aka. the amount of seconds
|
|
81
|
+
* that will be subtracted from the current token `exp` claim in order
|
|
82
|
+
* to determine whether it is going to expire within the specified time threshold.
|
|
83
|
+
*
|
|
84
|
+
* For example, if you want to auto refresh the token if it is
|
|
85
|
+
* going to expire in the next 30mins (or already has expired),
|
|
86
|
+
* it can be set to `1800`
|
|
87
|
+
*/
|
|
88
|
+
autoRefreshThreshold?: number;
|
|
89
|
+
}
|
|
90
|
+
export declare function normalizeUnknownQueryParams(options?: SendOptions): void;
|
|
91
|
+
export declare function serializeQueryParams(params: LooseObject): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iglo.tech/iglo.base",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JavaScript SDK for iglo.base (fork of the PocketBase JavaScript SDK v0.28.1)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"iglo.base",
|
|
7
|
+
"javascript-sdk",
|
|
8
|
+
"js-sdk",
|
|
9
|
+
"pocketbase",
|
|
10
|
+
"pocketbase-js"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Gani Georgiev",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/iglo-tech/iglo.base.git",
|
|
17
|
+
"directory": "sdk"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"CHANGELOG.md"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/iglo-base.es.mjs",
|
|
28
|
+
"module": "./dist/iglo-base.es.mjs",
|
|
29
|
+
"types": "./dist/types/src/index.d.ts",
|
|
30
|
+
"react-native": "./dist/iglo-base.es.mjs",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/types/src/index.d.ts",
|
|
34
|
+
"default": "./dist/iglo-base.es.mjs"
|
|
35
|
+
},
|
|
36
|
+
"./ssr": {
|
|
37
|
+
"types": "./dist/types/src/ssr/index.d.ts",
|
|
38
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
39
|
+
"default": "./dist/ssr.es.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./ssr/browser": {
|
|
42
|
+
"types": "./dist/types/src/ssr/browser-client.d.ts",
|
|
43
|
+
"default": "./dist/ssr-browser-client.es.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./ssr/next": {
|
|
46
|
+
"types": "./dist/types/src/ssr/next.d.ts",
|
|
47
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
48
|
+
"default": "./dist/ssr-next.es.mjs"
|
|
49
|
+
},
|
|
50
|
+
"./ssr/sveltekit": {
|
|
51
|
+
"types": "./dist/types/src/ssr/sveltekit.d.ts",
|
|
52
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
53
|
+
"default": "./dist/ssr-sveltekit.es.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./ssr/nuxt": {
|
|
56
|
+
"types": "./dist/types/src/ssr/nuxt.d.ts",
|
|
57
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
58
|
+
"default": "./dist/ssr-nuxt.es.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./ssr/astro": {
|
|
61
|
+
"types": "./dist/types/src/ssr/astro.d.ts",
|
|
62
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
63
|
+
"default": "./dist/ssr-astro.es.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./ssr/react-router": {
|
|
66
|
+
"types": "./dist/types/src/ssr/react-router.d.ts",
|
|
67
|
+
"browser": "./dist/ssr-browser.es.mjs",
|
|
68
|
+
"default": "./dist/ssr-react-router.es.mjs"
|
|
69
|
+
},
|
|
70
|
+
"./package.json": "./package.json"
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
}
|
|
75
|
+
}
|