parse-server 8.1.1-alpha.1 → 8.2.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.
@@ -0,0 +1,251 @@
1
+ // This file is manually updated to match src/Options/index.js until typed
2
+ import { AnalyticsAdapter } from '../Adapters/Analytics/AnalyticsAdapter';
3
+ import { CacheAdapter } from '../Adapters/Cache/CacheAdapter';
4
+ import { MailAdapter } from '../Adapters/Email/MailAdapter';
5
+ import { FilesAdapter } from '../Adapters/Files/FilesAdapter';
6
+ import { LoggerAdapter } from '../Adapters/Logger/LoggerAdapter';
7
+ import { PubSubAdapter } from '../Adapters/PubSub/PubSubAdapter';
8
+ import { StorageAdapter } from '../Adapters/Storage/StorageAdapter';
9
+ import { WSSAdapter } from '../Adapters/WebSocketServer/WSSAdapter';
10
+ import { CheckGroup } from '../Security/CheckGroup';
11
+ export interface SchemaOptions {
12
+ definitions: any;
13
+ strict?: boolean;
14
+ deleteExtraFields?: boolean;
15
+ recreateModifiedFields?: boolean;
16
+ lockSchemas?: boolean;
17
+ beforeMigration?: () => void | Promise<void>;
18
+ afterMigration?: () => void | Promise<void>;
19
+ }
20
+ type Adapter<T> = string | T;
21
+ type NumberOrBoolean = number | boolean;
22
+ type NumberOrString = number | string;
23
+ type ProtectedFields = any;
24
+ type StringOrStringArray = string | string[];
25
+ type RequestKeywordDenylist = {
26
+ key: string;
27
+ value: any;
28
+ };
29
+ export interface ParseServerOptions {
30
+ appId: string;
31
+ masterKey: (() => void) | string;
32
+ masterKeyTtl?: number;
33
+ maintenanceKey: string;
34
+ serverURL: string;
35
+ masterKeyIps?: (string[]);
36
+ maintenanceKeyIps?: (string[]);
37
+ appName?: string;
38
+ allowHeaders?: (string[]);
39
+ allowOrigin?: StringOrStringArray;
40
+ analyticsAdapter?: Adapter<AnalyticsAdapter>;
41
+ filesAdapter?: Adapter<FilesAdapter>;
42
+ push?: any;
43
+ scheduledPush?: boolean;
44
+ loggerAdapter?: Adapter<LoggerAdapter>;
45
+ jsonLogs?: boolean;
46
+ logsFolder?: string;
47
+ verbose?: boolean;
48
+ logLevel?: string;
49
+ logLevels?: LogLevels;
50
+ maxLogFiles?: NumberOrString;
51
+ silent?: boolean;
52
+ databaseURI: string;
53
+ databaseOptions?: DatabaseOptions;
54
+ databaseAdapter?: Adapter<StorageAdapter>;
55
+ enableCollationCaseComparison?: boolean;
56
+ convertEmailToLowercase?: boolean;
57
+ convertUsernameToLowercase?: boolean;
58
+ cloud?: string;
59
+ collectionPrefix?: string;
60
+ clientKey?: string;
61
+ javascriptKey?: string;
62
+ dotNetKey?: string;
63
+ encryptionKey?: string;
64
+ restAPIKey?: string;
65
+ readOnlyMasterKey?: string;
66
+ webhookKey?: string;
67
+ fileKey?: string;
68
+ preserveFileName?: boolean;
69
+ userSensitiveFields?: (string[]);
70
+ protectedFields?: ProtectedFields;
71
+ enableAnonymousUsers?: boolean;
72
+ allowClientClassCreation?: boolean;
73
+ allowCustomObjectId?: boolean;
74
+ auth?: Record<string, AuthAdapter>;
75
+ enableInsecureAuthAdapters?: boolean;
76
+ maxUploadSize?: string;
77
+ verifyUserEmails?: (boolean | void);
78
+ preventLoginWithUnverifiedEmail?: boolean;
79
+ preventSignupWithUnverifiedEmail?: boolean;
80
+ emailVerifyTokenValidityDuration?: number;
81
+ emailVerifyTokenReuseIfValid?: boolean;
82
+ sendUserEmailVerification?: (boolean | void);
83
+ accountLockout?: AccountLockoutOptions;
84
+ passwordPolicy?: PasswordPolicyOptions;
85
+ cacheAdapter?: Adapter<CacheAdapter>;
86
+ emailAdapter?: Adapter<MailAdapter>;
87
+ encodeParseObjectInCloudFunction?: boolean;
88
+ publicServerURL?: string;
89
+ pages?: PagesOptions;
90
+ customPages?: CustomPagesOptions;
91
+ liveQuery?: LiveQueryOptions;
92
+ sessionLength?: number;
93
+ extendSessionOnUse?: boolean;
94
+ defaultLimit?: number;
95
+ maxLimit?: number;
96
+ expireInactiveSessions?: boolean;
97
+ revokeSessionOnPasswordReset?: boolean;
98
+ cacheTTL?: number;
99
+ cacheMaxSize?: number;
100
+ directAccess?: boolean;
101
+ enableExpressErrorHandler?: boolean;
102
+ objectIdSize?: number;
103
+ port?: number;
104
+ host?: string;
105
+ mountPath?: string;
106
+ cluster?: NumberOrBoolean;
107
+ middleware?: ((() => void) | string);
108
+ trustProxy?: any;
109
+ startLiveQueryServer?: boolean;
110
+ liveQueryServerOptions?: LiveQueryServerOptions;
111
+ idempotencyOptions?: IdempotencyOptions;
112
+ fileUpload?: FileUploadOptions;
113
+ graphQLSchema?: string;
114
+ mountGraphQL?: boolean;
115
+ graphQLPath?: string;
116
+ mountPlayground?: boolean;
117
+ playgroundPath?: string;
118
+ schema?: SchemaOptions;
119
+ serverCloseComplete?: () => void;
120
+ security?: SecurityOptions;
121
+ enforcePrivateUsers?: boolean;
122
+ allowExpiredAuthDataToken?: boolean;
123
+ requestKeywordDenylist?: (RequestKeywordDenylist[]);
124
+ rateLimit?: (RateLimitOptions[]);
125
+ }
126
+ export interface RateLimitOptions {
127
+ requestPath: string;
128
+ requestTimeWindow?: number;
129
+ requestCount?: number;
130
+ errorResponseMessage?: string;
131
+ requestMethods?: (string[]);
132
+ includeMasterKey?: boolean;
133
+ includeInternalRequests?: boolean;
134
+ redisUrl?: string;
135
+ zone?: string;
136
+ }
137
+ export interface SecurityOptions {
138
+ enableCheck?: boolean;
139
+ enableCheckLog?: boolean;
140
+ checkGroups?: (CheckGroup[]);
141
+ }
142
+ export interface PagesOptions {
143
+ enableRouter?: boolean;
144
+ enableLocalization?: boolean;
145
+ localizationJsonPath?: string;
146
+ localizationFallbackLocale?: string;
147
+ placeholders?: any;
148
+ forceRedirect?: boolean;
149
+ pagesPath?: string;
150
+ pagesEndpoint?: string;
151
+ customUrls?: PagesCustomUrlsOptions;
152
+ customRoutes?: (PagesRoute[]);
153
+ }
154
+ export interface PagesRoute {
155
+ path: string;
156
+ method: string;
157
+ handler: () => void;
158
+ }
159
+ export interface PagesCustomUrlsOptions {
160
+ passwordReset?: string;
161
+ passwordResetLinkInvalid?: string;
162
+ passwordResetSuccess?: string;
163
+ emailVerificationSuccess?: string;
164
+ emailVerificationSendFail?: string;
165
+ emailVerificationSendSuccess?: string;
166
+ emailVerificationLinkInvalid?: string;
167
+ emailVerificationLinkExpired?: string;
168
+ }
169
+ export interface CustomPagesOptions {
170
+ invalidLink?: string;
171
+ linkSendFail?: string;
172
+ choosePassword?: string;
173
+ linkSendSuccess?: string;
174
+ verifyEmailSuccess?: string;
175
+ passwordResetSuccess?: string;
176
+ invalidVerificationLink?: string;
177
+ expiredVerificationLink?: string;
178
+ invalidPasswordResetLink?: string;
179
+ parseFrameURL?: string;
180
+ }
181
+ export interface LiveQueryOptions {
182
+ classNames?: (string[]);
183
+ redisOptions?: any;
184
+ redisURL?: string;
185
+ pubSubAdapter?: Adapter<PubSubAdapter>;
186
+ wssAdapter?: Adapter<WSSAdapter>;
187
+ }
188
+ export interface LiveQueryServerOptions {
189
+ appId?: string;
190
+ masterKey?: string;
191
+ serverURL?: string;
192
+ keyPairs?: any;
193
+ websocketTimeout?: number;
194
+ cacheTimeout?: number;
195
+ logLevel?: string;
196
+ port?: number;
197
+ redisOptions?: any;
198
+ redisURL?: string;
199
+ pubSubAdapter?: Adapter<PubSubAdapter>;
200
+ wssAdapter?: Adapter<WSSAdapter>;
201
+ }
202
+ export interface IdempotencyOptions {
203
+ paths?: (string[]);
204
+ ttl?: number;
205
+ }
206
+ export interface AccountLockoutOptions {
207
+ duration?: number;
208
+ threshold?: number;
209
+ unlockOnPasswordReset?: boolean;
210
+ }
211
+ export interface PasswordPolicyOptions {
212
+ validatorPattern?: string;
213
+ validatorCallback?: () => void;
214
+ validationError?: string;
215
+ doNotAllowUsername?: boolean;
216
+ maxPasswordAge?: number;
217
+ maxPasswordHistory?: number;
218
+ resetTokenValidityDuration?: number;
219
+ resetTokenReuseIfValid?: boolean;
220
+ resetPasswordSuccessOnInvalidEmail?: boolean;
221
+ }
222
+ export interface FileUploadOptions {
223
+ fileExtensions?: (string[]);
224
+ enableForAnonymousUser?: boolean;
225
+ enableForAuthenticatedUser?: boolean;
226
+ enableForPublic?: boolean;
227
+ }
228
+ export interface DatabaseOptions {
229
+ enableSchemaHooks?: boolean;
230
+ schemaCacheTtl?: number;
231
+ retryWrites?: boolean;
232
+ maxTimeMS?: number;
233
+ maxStalenessSeconds?: number;
234
+ minPoolSize?: number;
235
+ maxPoolSize?: number;
236
+ connectTimeoutMS?: number;
237
+ socketTimeoutMS?: number;
238
+ autoSelectFamily?: boolean;
239
+ autoSelectFamilyAttemptTimeout?: number;
240
+ }
241
+ export interface AuthAdapter {
242
+ enabled?: boolean;
243
+ }
244
+ export interface LogLevels {
245
+ triggerAfter?: string;
246
+ triggerBeforeSuccess?: string;
247
+ triggerBeforeError?: string;
248
+ cloudFunctionSuccess?: string;
249
+ cloudFunctionError?: string;
250
+ }
251
+ export {};
@@ -0,0 +1,60 @@
1
+ import { ParseServerOptions, LiveQueryServerOptions } from './Options';
2
+ import { ParseLiveQueryServer } from './LiveQuery/ParseLiveQueryServer';
3
+ declare class ParseServer {
4
+ _app: any;
5
+ config: any;
6
+ server: any;
7
+ expressApp: any;
8
+ liveQueryServer: any;
9
+ /**
10
+ * @constructor
11
+ * @param {ParseServerOptions} options the parse server initialization options
12
+ */
13
+ constructor(options: ParseServerOptions);
14
+ /**
15
+ * Starts Parse Server as an express app; this promise resolves when Parse Server is ready to accept requests.
16
+ */
17
+ start(): Promise<this>;
18
+ get app(): any;
19
+ /**
20
+ * Stops the parse server, cancels any ongoing requests and closes all connections.
21
+ *
22
+ * Currently, express doesn't shut down immediately after receiving SIGINT/SIGTERM
23
+ * if it has client connections that haven't timed out.
24
+ * (This is a known issue with node - https://github.com/nodejs/node/issues/2642)
25
+ *
26
+ * @returns {Promise<void>} a promise that resolves when the server is stopped
27
+ */
28
+ handleShutdown(): Promise<void>;
29
+ /**
30
+ * @static
31
+ * Create an express app for the parse server
32
+ * @param {Object} options let you specify the maxUploadSize when creating the express app */
33
+ static app(options: any): any;
34
+ static promiseRouter({ appId }: {
35
+ appId: any;
36
+ }): any;
37
+ /**
38
+ * starts the parse server's express app
39
+ * @param {ParseServerOptions} options to use to start the server
40
+ * @returns {ParseServer} the parse server instance
41
+ */
42
+ startApp(options: ParseServerOptions): Promise<this>;
43
+ /**
44
+ * Creates a new ParseServer and starts it.
45
+ * @param {ParseServerOptions} options used to start the server
46
+ * @returns {ParseServer} the parse server instance
47
+ */
48
+ static startApp(options: ParseServerOptions): Promise<ParseServer>;
49
+ /**
50
+ * Helper method to create a liveQuery server
51
+ * @static
52
+ * @param {Server} httpServer an optional http server to pass
53
+ * @param {LiveQueryServerOptions} config options for the liveQueryServer
54
+ * @param {ParseServerOptions} options options for the ParseServer
55
+ * @returns {Promise<ParseLiveQueryServer>} the live query server instance
56
+ */
57
+ static createLiveQueryServer(httpServer: any, config: LiveQueryServerOptions, options: ParseServerOptions): Promise<ParseLiveQueryServer>;
58
+ static verifyServerUrl(): any;
59
+ }
60
+ export default ParseServer;
@@ -0,0 +1,30 @@
1
+ import eslint from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import expectType from 'eslint-plugin-expect-type/configs/recommended';
4
+
5
+ export default tseslint.config({
6
+ files: ['**/*.js', '**/*.ts'],
7
+ extends: [
8
+ expectType,
9
+ eslint.configs.recommended,
10
+ ...tseslint.configs.recommended,
11
+ ...tseslint.configs.recommendedTypeChecked,
12
+ ],
13
+ plugins: {
14
+ '@typescript-eslint': tseslint.plugin,
15
+ },
16
+ rules: {
17
+ '@typescript-eslint/no-unused-vars': 'off',
18
+ '@typescript-eslint/no-unused-expressions': 'off',
19
+ '@typescript-eslint/no-unsafe-call': 'off',
20
+ "@typescript-eslint/no-explicit-any": "off",
21
+ "@typescript-eslint/no-unsafe-return": "off",
22
+ },
23
+ languageOptions: {
24
+ parser: tseslint.parser,
25
+ parserOptions: {
26
+ projectService: true,
27
+ tsconfigRootDir: import.meta.dirname,
28
+ },
29
+ },
30
+ });
package/types/index.d.ts CHANGED
@@ -0,0 +1,21 @@
1
+ import ParseServer from './ParseServer';
2
+ import FileSystemAdapter from '@parse/fs-files-adapter';
3
+ import InMemoryCacheAdapter from './Adapters/Cache/InMemoryCacheAdapter';
4
+ import NullCacheAdapter from './Adapters/Cache/NullCacheAdapter';
5
+ import RedisCacheAdapter from './Adapters/Cache/RedisCacheAdapter';
6
+ import LRUCacheAdapter from './Adapters/Cache/LRUCache.js';
7
+ import * as TestUtils from './TestUtils';
8
+ import * as SchemaMigrations from './SchemaMigrations/Migrations';
9
+ import AuthAdapter from './Adapters/Auth/AuthAdapter';
10
+ import { PushWorker } from './Push/PushWorker';
11
+ import { ParseServerOptions } from './Options';
12
+ import { ParseGraphQLServer } from './GraphQL/ParseGraphQLServer';
13
+ declare const _ParseServer: {
14
+ (options: ParseServerOptions): ParseServer;
15
+ createLiveQueryServer: typeof ParseServer.createLiveQueryServer;
16
+ startApp: typeof ParseServer.startApp;
17
+ };
18
+ declare const S3Adapter: any;
19
+ declare const GCSAdapter: any;
20
+ export default ParseServer;
21
+ export { S3Adapter, GCSAdapter, FileSystemAdapter, InMemoryCacheAdapter, NullCacheAdapter, RedisCacheAdapter, LRUCacheAdapter, TestUtils, PushWorker, ParseGraphQLServer, _ParseServer as ParseServer, SchemaMigrations, AuthAdapter, };
package/types/tests.ts ADDED
@@ -0,0 +1,44 @@
1
+ import ParseServer, { FileSystemAdapter } from 'parse-server';
2
+
3
+ async function server() {
4
+ // $ExpectType ParseServer
5
+ const parseServer = await ParseServer.startApp({});
6
+
7
+ // $ExpectType void
8
+ await parseServer.handleShutdown();
9
+
10
+ // $ExpectType any
11
+ parseServer.app;
12
+
13
+ // $ExpectType any
14
+ ParseServer.app({});
15
+
16
+ // $ExpectType any
17
+ ParseServer.promiseRouter({ appId: 'appId' });
18
+
19
+ // $ExpectType ParseLiveQueryServer
20
+ await ParseServer.createLiveQueryServer({}, {}, {});
21
+
22
+ // $ExpectType any
23
+ ParseServer.verifyServerUrl();
24
+
25
+ // $ExpectError
26
+ await ParseServer.startApp();
27
+
28
+ // $ExpectError
29
+ ParseServer.promiseRouter();
30
+
31
+ // $ExpectError
32
+ await ParseServer.createLiveQueryServer();
33
+
34
+ // $ExpectType ParseServer
35
+ const parseServer2 = new ParseServer({});
36
+
37
+ // $ExpectType ParseServer
38
+ await parseServer2.start();
39
+ }
40
+
41
+ function exports() {
42
+ // $ExpectType any
43
+ FileSystemAdapter;
44
+ }
@@ -13,6 +13,12 @@
13
13
  // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index".
14
14
  // If the library is global (cannot be imported via `import` or `require`), leave this out.
15
15
  "baseUrl": ".",
16
- "paths": { "parse": ["."] }
17
- }
16
+ "paths": {
17
+ "parse-server": ["."],
18
+ "@parse/fs-files-adapter": ["./@types/@parse/fs-files-adapter"],
19
+ }
20
+ },
21
+ "include": [
22
+ "tests.ts"
23
+ ]
18
24
  }