Reference

Utilities

Helpers, constants and types the package exports.

catchError

The error convention throughout the library — a rejected promise becomes a tuple rather than a try/catch around every await.

import {
  catchError, importFiles, getUserRoles, getUsersRoles, roleKey,
} from 'parse-server-kit';

const [err, saved] = await catchError(product.save(null, { sessionToken }));
if (err) throw err;

importFiles

importFiles(dir);                                    // .js only
importFiles(dir, { extensions: ['.js', '.ts'] });      // ts-node / tsx
importFiles(dir, { verbose: false });

Defaults to .js, the compiled output a production server runs. Importing nothing produces a server that starts perfectly with no models and no routes, so since 3.0 it warns when it finds a directory of .ts files and was told to load .js.

Never point it at a tree holding both compiled and source copies — every class would register twice, and which one wins depends on directory order. That now warns too.

Roles

await getUserRoles(user);      // string[]
await getUsersRoles(users);    // Map

roleKey('Editor');             // 'role:Editor', typed as that literal

getUsersRoles costs one query per role rather than per user, so a page of 500 users costs the same as a page of five.

Everything else

syncImageAcl(parent, fields, acl?)Copies a parent's ACL onto nested image pointers
cloneAcl(acl)Deep copy of a Parse.ACL
validateObject(object){valid, errors[]} against the declared field rules
validateOrThrow(object)Throws a Parse VALIDATION_ERROR listing every failure
generateRandomString(n)Not cryptographic — do not use for secrets
generateRandomPassword(…)A placeholder password, same caveat
sleep(ms)
formatCount(n, locale?)Compact notation — 1.2K
MAX_QUERY_LIMIT10000

Deprecated

Still exported so existing imports resolve; to be removed in the next major.

UserRolesTwo example role names from one project. Declare your own enum and pass it to roleKey, which accepts any string
AuthRole, FilterApplication types that describe nothing this library does
MultiLangsHardcodes Arabic and English. Prefer Record<string, string>
applyUniqueIndexesA permanent alias for applyAllIndexes, which now applies every index kind