@kinevolution/appwrite-functions-shared-utils 0.1.13 → 0.1.15
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/appwrite.d.ts +67 -108
- package/dist/appwrite.js +23 -0
- package/dist/utils.js +19 -25
- package/package.json +6 -3
package/dist/appwrite.d.ts
CHANGED
|
@@ -1,108 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
hasVehicle: boolean;
|
|
69
|
-
ratingCount: number;
|
|
70
|
-
ratingAvg: number;
|
|
71
|
-
user: Roles;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type CompanionZones = BaseRow & {
|
|
75
|
-
label: string;
|
|
76
|
-
priority: number;
|
|
77
|
-
active: boolean;
|
|
78
|
-
notes: string | null;
|
|
79
|
-
zone: string | null;
|
|
80
|
-
profilesCompanion: ProfilesCompanion;
|
|
81
|
-
center: string | null;
|
|
82
|
-
radius: number | null;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type Roles = BaseRow & {
|
|
86
|
-
userId: string;
|
|
87
|
-
role: Role;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export type ProfilesExtras = BaseRow & {
|
|
91
|
-
user: Roles;
|
|
92
|
-
bio: string | null;
|
|
93
|
-
photoIds: string[] | null;
|
|
94
|
-
activities: Activities[] | null;
|
|
95
|
-
locale: string | null;
|
|
96
|
-
timezone: string | null;
|
|
97
|
-
marketingOptIn: boolean;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type ProfilesCore = BaseRow & {
|
|
101
|
-
pushTokens: string[] | null;
|
|
102
|
-
termsAcceptedAt: string;
|
|
103
|
-
birthDate: string;
|
|
104
|
-
firstName: string;
|
|
105
|
-
lastName: string;
|
|
106
|
-
sex: Sex;
|
|
107
|
-
user: Roles;
|
|
108
|
-
};
|
|
1
|
+
import type { Models } from 'appwrite';
|
|
2
|
+
export declare enum Role {
|
|
3
|
+
REQUESTER = "requester",
|
|
4
|
+
COMPANION = "companion"
|
|
5
|
+
}
|
|
6
|
+
export declare enum Activities {
|
|
7
|
+
CHAT = "chat",
|
|
8
|
+
WALK = "walk",
|
|
9
|
+
GAMES = "games",
|
|
10
|
+
HOME_HELP = "home_help",
|
|
11
|
+
READING = "reading",
|
|
12
|
+
SHOPPING = "shopping"
|
|
13
|
+
}
|
|
14
|
+
export declare enum Sex {
|
|
15
|
+
FEMALE = "female",
|
|
16
|
+
MALE = "male",
|
|
17
|
+
PREFER_NOT_SAY = "prefer_not_say",
|
|
18
|
+
OTHER = "other"
|
|
19
|
+
}
|
|
20
|
+
export type ProfilesRequester = Models.Row & {
|
|
21
|
+
phone: string;
|
|
22
|
+
contactByPhone: boolean;
|
|
23
|
+
approxLocationLabel: string;
|
|
24
|
+
homeLocation: string;
|
|
25
|
+
notesForCompanions: string | null;
|
|
26
|
+
emergencyContactName: string | null;
|
|
27
|
+
emergencyContactPhone: string | null;
|
|
28
|
+
user: Roles;
|
|
29
|
+
};
|
|
30
|
+
export type ProfilesCompanion = Models.Row & {
|
|
31
|
+
hasVehicle: boolean;
|
|
32
|
+
ratingCount: number;
|
|
33
|
+
ratingAvg: number;
|
|
34
|
+
user: Roles;
|
|
35
|
+
};
|
|
36
|
+
export type CompanionZones = Models.Row & {
|
|
37
|
+
label: string;
|
|
38
|
+
priority: number;
|
|
39
|
+
active: boolean;
|
|
40
|
+
notes: string | null;
|
|
41
|
+
zone: string | null;
|
|
42
|
+
profilesCompanion: ProfilesCompanion;
|
|
43
|
+
center: string | null;
|
|
44
|
+
radius: number | null;
|
|
45
|
+
};
|
|
46
|
+
export type Roles = Models.Row & {
|
|
47
|
+
userId: string;
|
|
48
|
+
role: Role;
|
|
49
|
+
};
|
|
50
|
+
export type ProfilesExtras = Models.Row & {
|
|
51
|
+
user: Roles;
|
|
52
|
+
bio: string | null;
|
|
53
|
+
photoIds: string[] | null;
|
|
54
|
+
activities: Activities[] | null;
|
|
55
|
+
locale: string | null;
|
|
56
|
+
timezone: string | null;
|
|
57
|
+
marketingOptIn: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type ProfilesCore = Models.Row & {
|
|
60
|
+
pushTokens: string[] | null;
|
|
61
|
+
termsAcceptedAt: string;
|
|
62
|
+
birthDate: string;
|
|
63
|
+
firstName: string;
|
|
64
|
+
lastName: string;
|
|
65
|
+
sex: Sex;
|
|
66
|
+
user: Roles;
|
|
67
|
+
};
|
package/dist/appwrite.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// This file is auto-generated by the Appwrite CLI.
|
|
2
|
+
// You can regenerate it by running `appwrite types -l ts appwrite.ts`.
|
|
3
|
+
export var Role;
|
|
4
|
+
(function (Role) {
|
|
5
|
+
Role["REQUESTER"] = "requester";
|
|
6
|
+
Role["COMPANION"] = "companion";
|
|
7
|
+
})(Role || (Role = {}));
|
|
8
|
+
export var Activities;
|
|
9
|
+
(function (Activities) {
|
|
10
|
+
Activities["CHAT"] = "chat";
|
|
11
|
+
Activities["WALK"] = "walk";
|
|
12
|
+
Activities["GAMES"] = "games";
|
|
13
|
+
Activities["HOME_HELP"] = "home_help";
|
|
14
|
+
Activities["READING"] = "reading";
|
|
15
|
+
Activities["SHOPPING"] = "shopping";
|
|
16
|
+
})(Activities || (Activities = {}));
|
|
17
|
+
export var Sex;
|
|
18
|
+
(function (Sex) {
|
|
19
|
+
Sex["FEMALE"] = "female";
|
|
20
|
+
Sex["MALE"] = "male";
|
|
21
|
+
Sex["PREFER_NOT_SAY"] = "prefer_not_say";
|
|
22
|
+
Sex["OTHER"] = "other";
|
|
23
|
+
})(Sex || (Sex = {}));
|
package/dist/utils.js
CHANGED
|
@@ -21,32 +21,26 @@ export function validateInput(config, req) {
|
|
|
21
21
|
error: `Invalid request method: expected ${config.method}, received ${req.method}`,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
error: `Validation error: ${validation.error}`,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
24
|
+
if (!req.bodyJson) {
|
|
25
|
+
return {
|
|
26
|
+
valid: false,
|
|
27
|
+
error: 'No body provided in the request',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Validate the request body
|
|
31
|
+
const validation = validateRequestBody(req.bodyJson, config.fields);
|
|
32
|
+
if (validation.valid) {
|
|
33
|
+
return {
|
|
34
|
+
valid: true,
|
|
35
|
+
data: validation.data,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return {
|
|
40
|
+
valid: false,
|
|
41
|
+
error: `Validation error: ${validation.error}`,
|
|
42
|
+
};
|
|
46
43
|
}
|
|
47
|
-
return {
|
|
48
|
-
valid: true,
|
|
49
|
-
};
|
|
50
44
|
}
|
|
51
45
|
/**
|
|
52
46
|
* Validates and parses the JSON body of the request
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.15",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"author": "Nicolas Forêt <nicolas4@gmail.com>",
|
|
9
9
|
"description": "Shared utilities for Appwrite functions",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": "./dist/utils.js",
|
|
16
16
|
"./utils": "./dist/utils.js",
|
|
17
|
-
"./appwrite": "./dist/appwrite.
|
|
17
|
+
"./appwrite": "./dist/appwrite.js"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"bat-update": "cd .. && shared-update.bat",
|
|
24
|
-
"build": "tsc -p tsconfig.json
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
25
|
"bump-version": "npm run bump-version:patch",
|
|
26
26
|
"bump-version:major": "gulp bump-version --type=major",
|
|
27
27
|
"bump-version:minor": "gulp bump-version --type=minor",
|
|
@@ -35,5 +35,8 @@
|
|
|
35
35
|
"gulp-replace": "1.1.4",
|
|
36
36
|
"minimist": "1.2.8",
|
|
37
37
|
"typescript": "5.9.3"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"appwrite": "21.4.0"
|
|
38
41
|
}
|
|
39
42
|
}
|