@palbase/backend 20.0.0 → 21.0.1
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/index.cjs +10 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -42
- package/dist/index.d.ts +1 -42
- package/dist/index.js +8 -39
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.cjs +23 -2
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +23 -2
- package/dist/openapi/index.js.map +1 -1
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.d.cts +3 -3
- package/dist/test/index.d.ts +3 -3
- package/dist/test/index.js.map +1 -1
- package/package.json +2 -2
- package/template/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1401,47 +1401,6 @@ interface FileDeletedEvent {
|
|
|
1401
1401
|
bucket: string;
|
|
1402
1402
|
path: string;
|
|
1403
1403
|
}
|
|
1404
|
-
/** The record the removed helpers returned. Nothing ever read it.
|
|
1405
|
-
* @deprecated Declare hooks with `@Hook` / `@On` in `hooks/*.ts`. Removed in the next major. */
|
|
1406
|
-
interface ResolvedHook<TEvent = unknown> {
|
|
1407
|
-
module: string;
|
|
1408
|
-
event: string;
|
|
1409
|
-
handler: (event: TEvent, meta: HookMeta) => Promise<void>;
|
|
1410
|
-
}
|
|
1411
|
-
/** @deprecated Declare hooks with `@Hook` / `@On` in `hooks/*.ts`. Removed in the next major. */
|
|
1412
|
-
type HookHandler<TEvent> = (event: TEvent, meta: HookMeta) => Promise<void>;
|
|
1413
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1414
|
-
type UserCreatedEvent = AuthHookEvent;
|
|
1415
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1416
|
-
type SignInEvent = AuthHookEvent;
|
|
1417
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1418
|
-
type SignOutEvent = AuthHookEvent;
|
|
1419
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1420
|
-
type PasswordResetEvent = AuthHookEvent;
|
|
1421
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1422
|
-
type DocumentCreatedEvent = DocumentHookEvent;
|
|
1423
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1424
|
-
type DocumentUpdatedEvent = DocumentHookEvent;
|
|
1425
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1426
|
-
type DocumentDeletedEvent = DocumentHookEvent;
|
|
1427
|
-
/** @deprecated Declare auth hooks with `@Hook("before.…")` or `@On("after.…")` in `hooks/*.ts`. */
|
|
1428
|
-
declare const auth: {
|
|
1429
|
-
onUserCreated: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1430
|
-
onSignIn: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1431
|
-
onSignOut: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1432
|
-
onPasswordReset: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1433
|
-
};
|
|
1434
|
-
/** @deprecated Declare file hooks with `@On("file.uploaded")` / `@On("file.deleted")` in `hooks/*.ts`. */
|
|
1435
|
-
declare const storage: {
|
|
1436
|
-
onFileUploaded: (_h: HookHandler<FileUploadedEvent>) => ResolvedHook<FileUploadedEvent>;
|
|
1437
|
-
onFileDeleted: (_h: HookHandler<FileDeletedEvent>) => ResolvedHook<FileDeletedEvent>;
|
|
1438
|
-
};
|
|
1439
|
-
/** @deprecated Declare document hooks with `@On("document.…")` in `hooks/*.ts`. */
|
|
1440
|
-
declare const documents: {
|
|
1441
|
-
onDocumentCreated: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1442
|
-
onDocumentUpdated: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1443
|
-
onDocumentDeleted: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1444
|
-
};
|
|
1445
1404
|
|
|
1446
1405
|
/** A hook handler. Returning quietly ALLOWS; throwing DENIES (blocking hooks). */
|
|
1447
1406
|
type HookFn = (event: unknown, meta: HookMeta) => Promise<unknown>;
|
|
@@ -1725,4 +1684,4 @@ declare function __runResourceBoot(envMap: Record<string, string>): Promise<void
|
|
|
1725
1684
|
*/
|
|
1726
1685
|
declare function __shutdownResources(): Promise<void>;
|
|
1727
1686
|
|
|
1728
|
-
export { type AcsOptions, type ApnsOptions, type AuthHookEvent, Body, Client, type ColumnJSON, Controller, type ControllerOptions, DEFAULT_TEMPLATE_LOCALE, type DefinedError, type DefinedErrorWithData, Delete, Deny, type
|
|
1687
|
+
export { type AcsOptions, type ApnsOptions, type AuthHookEvent, Body, Client, type ColumnJSON, Controller, type ControllerOptions, DEFAULT_TEMPLATE_LOCALE, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, EGRESS_CONFIG_KIND, EGRESS_TIMEOUT_DEFAULT_MS, EGRESS_TIMEOUT_MAX_MS, EGRESS_TIMEOUT_MIN_MS, type EgressConfig, type EgressInput, type EmailTemplateContent, type EmailTemplateDef, type EmailTemplateOptions, EntitlementKey, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, type FlagsConfig, type FlagsInput, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, LimitKey, type ModuleClientsConfig, type ModuleTransport, NOTIFICATIONS_CONFIG_KIND, type NotificationsConfig, type NotificationsInput, On, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderName, type ProviderOptions, type PurchasesManifest, Put, Query, QueryParams, RESERVED_SECRET_PREFIX, type RegisteredError, Req, RequestId, type RequestOptions, RequireEntitlement, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, Resource, type ResourceEnv, RouteOptions, SECRETS_CONFIG_KIND, SchemaDef, type SchemaJSON, type SecretDef, type SecretOptions, type SecretsConfig, type SecretsInput, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignatureSpec, type SmsTemplateContent, type SmsTemplateDef, type SmsTemplateOptions, type SmtpOptions, Spend, type SpendMeta, TEST_USERS_CONFIG_KIND, type TableGraph, type TableJSON, TableTypes, Tables, type TemplatesConfig, type TemplatesInput, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, TraceId, type TransportConfig, type TwilioOptions, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __registerResource, __resetRegisteredControllers, __runResourceBoot, __shutdownResources, buildModuleClients, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineSecrets, defineTestUsers, entitlementFor, extractVariables, flag, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makePurchasesDts, reservedSecretKey, secret, spendFor, testUser, toSchemaJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -1401,47 +1401,6 @@ interface FileDeletedEvent {
|
|
|
1401
1401
|
bucket: string;
|
|
1402
1402
|
path: string;
|
|
1403
1403
|
}
|
|
1404
|
-
/** The record the removed helpers returned. Nothing ever read it.
|
|
1405
|
-
* @deprecated Declare hooks with `@Hook` / `@On` in `hooks/*.ts`. Removed in the next major. */
|
|
1406
|
-
interface ResolvedHook<TEvent = unknown> {
|
|
1407
|
-
module: string;
|
|
1408
|
-
event: string;
|
|
1409
|
-
handler: (event: TEvent, meta: HookMeta) => Promise<void>;
|
|
1410
|
-
}
|
|
1411
|
-
/** @deprecated Declare hooks with `@Hook` / `@On` in `hooks/*.ts`. Removed in the next major. */
|
|
1412
|
-
type HookHandler<TEvent> = (event: TEvent, meta: HookMeta) => Promise<void>;
|
|
1413
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1414
|
-
type UserCreatedEvent = AuthHookEvent;
|
|
1415
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1416
|
-
type SignInEvent = AuthHookEvent;
|
|
1417
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1418
|
-
type SignOutEvent = AuthHookEvent;
|
|
1419
|
-
/** @deprecated Use {@link AuthHookEvent} — this shape was never on the wire. */
|
|
1420
|
-
type PasswordResetEvent = AuthHookEvent;
|
|
1421
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1422
|
-
type DocumentCreatedEvent = DocumentHookEvent;
|
|
1423
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1424
|
-
type DocumentUpdatedEvent = DocumentHookEvent;
|
|
1425
|
-
/** @deprecated Use {@link DocumentHookEvent} — this shape was never on the wire. */
|
|
1426
|
-
type DocumentDeletedEvent = DocumentHookEvent;
|
|
1427
|
-
/** @deprecated Declare auth hooks with `@Hook("before.…")` or `@On("after.…")` in `hooks/*.ts`. */
|
|
1428
|
-
declare const auth: {
|
|
1429
|
-
onUserCreated: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1430
|
-
onSignIn: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1431
|
-
onSignOut: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1432
|
-
onPasswordReset: (_h: HookHandler<AuthHookEvent>) => ResolvedHook<AuthHookEvent>;
|
|
1433
|
-
};
|
|
1434
|
-
/** @deprecated Declare file hooks with `@On("file.uploaded")` / `@On("file.deleted")` in `hooks/*.ts`. */
|
|
1435
|
-
declare const storage: {
|
|
1436
|
-
onFileUploaded: (_h: HookHandler<FileUploadedEvent>) => ResolvedHook<FileUploadedEvent>;
|
|
1437
|
-
onFileDeleted: (_h: HookHandler<FileDeletedEvent>) => ResolvedHook<FileDeletedEvent>;
|
|
1438
|
-
};
|
|
1439
|
-
/** @deprecated Declare document hooks with `@On("document.…")` in `hooks/*.ts`. */
|
|
1440
|
-
declare const documents: {
|
|
1441
|
-
onDocumentCreated: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1442
|
-
onDocumentUpdated: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1443
|
-
onDocumentDeleted: (_h: HookHandler<DocumentHookEvent>) => ResolvedHook<DocumentHookEvent>;
|
|
1444
|
-
};
|
|
1445
1404
|
|
|
1446
1405
|
/** A hook handler. Returning quietly ALLOWS; throwing DENIES (blocking hooks). */
|
|
1447
1406
|
type HookFn = (event: unknown, meta: HookMeta) => Promise<unknown>;
|
|
@@ -1725,4 +1684,4 @@ declare function __runResourceBoot(envMap: Record<string, string>): Promise<void
|
|
|
1725
1684
|
*/
|
|
1726
1685
|
declare function __shutdownResources(): Promise<void>;
|
|
1727
1686
|
|
|
1728
|
-
export { type AcsOptions, type ApnsOptions, type AuthHookEvent, Body, Client, type ColumnJSON, Controller, type ControllerOptions, DEFAULT_TEMPLATE_LOCALE, type DefinedError, type DefinedErrorWithData, Delete, Deny, type
|
|
1687
|
+
export { type AcsOptions, type ApnsOptions, type AuthHookEvent, Body, Client, type ColumnJSON, Controller, type ControllerOptions, DEFAULT_TEMPLATE_LOCALE, type DefinedError, type DefinedErrorWithData, Delete, Deny, type DocumentHookEvent, EGRESS_CONFIG_KIND, EGRESS_TIMEOUT_DEFAULT_MS, EGRESS_TIMEOUT_MAX_MS, EGRESS_TIMEOUT_MIN_MS, type EgressConfig, type EgressInput, type EmailTemplateContent, type EmailTemplateDef, type EmailTemplateOptions, EntitlementKey, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, type FlagsConfig, type FlagsInput, Get, Headers, Hook, type HookFn, type HookMeta, HttpError, Job, type JobMeta, type JobOptions, LimitKey, type ModuleClientsConfig, type ModuleTransport, NOTIFICATIONS_CONFIG_KIND, type NotificationsConfig, type NotificationsInput, On, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseModuleError, PalbaseResult, Param, Patch, type PolicyJSON, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderName, type ProviderOptions, type PurchasesManifest, Put, Query, QueryParams, RESERVED_SECRET_PREFIX, type RegisteredError, Req, RequestId, type RequestOptions, RequireEntitlement, type ResolvedHookClass, type ResolvedJob, type ResolvedWebhook, Resource, type ResourceEnv, RouteOptions, SECRETS_CONFIG_KIND, SchemaDef, type SchemaJSON, type SecretDef, type SecretOptions, type SecretsConfig, type SecretsInput, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignatureSpec, type SmsTemplateContent, type SmsTemplateDef, type SmsTemplateOptions, type SmtpOptions, Spend, type SpendMeta, TEST_USERS_CONFIG_KIND, type TableGraph, type TableJSON, TableTypes, Tables, type TemplatesConfig, type TemplatesInput, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, TraceId, type TransportConfig, type TwilioOptions, User, Webhook, type WebhookEventHandler, type WebhookMeta, type WebhookOptions, type WebhookProvider, type WebhookRequest, __registerResource, __resetRegisteredControllers, __runResourceBoot, __shutdownResources, buildModuleClients, buildProvider, defineEgress, defineError, defineFlags, defineNotifications, defineSecrets, defineTestUsers, entitlementFor, extractVariables, flag, getErrorRegistry, getHookConfig, getJobConfig, getRegisteredControllers, getWebhookConfig, makeEnvDts, makeHttpClient, makePurchasesDts, reservedSecretKey, secret, spendFor, testUser, toSchemaJSON };
|
package/dist/index.js
CHANGED
|
@@ -940,13 +940,13 @@ function buildBucketClient(http, bucketName) {
|
|
|
940
940
|
},
|
|
941
941
|
async remove(paths) {
|
|
942
942
|
for (const p of paths) validateStoragePath(p);
|
|
943
|
-
const
|
|
943
|
+
const removed = [];
|
|
944
944
|
for (const p of paths) {
|
|
945
945
|
const res = await http.request("DELETE", objectPath(p));
|
|
946
946
|
if (res.error) return { data: null, error: res.error, status: res.status };
|
|
947
|
-
|
|
947
|
+
removed.push(toFileObject(bucketName, { path: p }));
|
|
948
948
|
}
|
|
949
|
-
return { data:
|
|
949
|
+
return { data: removed, error: null, status: 200 };
|
|
950
950
|
},
|
|
951
951
|
async move(from, to) {
|
|
952
952
|
validateStoragePath(from);
|
|
@@ -2034,11 +2034,11 @@ function getHookConfig(ctor) {
|
|
|
2034
2034
|
|
|
2035
2035
|
// src/decorators/upload.ts
|
|
2036
2036
|
function Upload(subpath, config) {
|
|
2037
|
-
const { auth
|
|
2037
|
+
const { auth, rateLimit, ...uploadConfig } = config;
|
|
2038
2038
|
validateUploadConfigShape(uploadConfig);
|
|
2039
2039
|
const options = {
|
|
2040
2040
|
uploadConfig,
|
|
2041
|
-
...
|
|
2041
|
+
...auth !== void 0 ? { auth } : {},
|
|
2042
2042
|
...rateLimit !== void 0 ? { rateLimit } : {}
|
|
2043
2043
|
};
|
|
2044
2044
|
return function(target, propertyKey) {
|
|
@@ -2064,10 +2064,10 @@ function validateUploadConfigShape(c) {
|
|
|
2064
2064
|
throw new Error("@Upload config.pathTemplate must be a non-empty key template");
|
|
2065
2065
|
}
|
|
2066
2066
|
}
|
|
2067
|
-
function validateUploadAgainstStorage(uploadConfig,
|
|
2068
|
-
const def =
|
|
2067
|
+
function validateUploadAgainstStorage(uploadConfig, storage, routeLabel) {
|
|
2068
|
+
const def = storage.buckets[uploadConfig.bucket];
|
|
2069
2069
|
if (def === void 0) {
|
|
2070
|
-
const known = Object.keys(
|
|
2070
|
+
const known = Object.keys(storage.buckets);
|
|
2071
2071
|
throw new Error(
|
|
2072
2072
|
`@Upload route ${routeLabel} targets bucket "${uploadConfig.bucket}" which is not declared in defineStorage(...). ` + (known.length ? `Known buckets: ${known.join(", ")}.` : "No buckets are declared.")
|
|
2073
2073
|
);
|
|
@@ -2294,34 +2294,6 @@ async function __shutdownResources() {
|
|
|
2294
2294
|
registry.length = 0;
|
|
2295
2295
|
}
|
|
2296
2296
|
|
|
2297
|
-
// src/hooks.ts
|
|
2298
|
-
function removed(helper, decorator, event) {
|
|
2299
|
-
throw new Error(
|
|
2300
|
-
`${helper}() does not register anything and never did \u2014 nothing in the runtime or the bundler reads what it returns, so the handler you passed would never run. Declare it instead in hooks/<name>.ts:
|
|
2301
|
-
|
|
2302
|
-
export default class MyHooks {
|
|
2303
|
-
${decorator}("${event}")
|
|
2304
|
-
async handle(event, meta) { /* \u2026 */ }
|
|
2305
|
-
}
|
|
2306
|
-
`
|
|
2307
|
-
);
|
|
2308
|
-
}
|
|
2309
|
-
var auth = {
|
|
2310
|
-
onUserCreated: (_h) => removed("auth.onUserCreated", "@Hook", "before.user.create"),
|
|
2311
|
-
onSignIn: (_h) => removed("auth.onSignIn", "@Hook", "before.login"),
|
|
2312
|
-
onSignOut: (_h) => removed("auth.onSignOut", "@On", "after.session.revoke"),
|
|
2313
|
-
onPasswordReset: (_h) => removed("auth.onPasswordReset", "@Hook", "before.password.reset")
|
|
2314
|
-
};
|
|
2315
|
-
var storage = {
|
|
2316
|
-
onFileUploaded: (_h) => removed("storage.onFileUploaded", "@On", "file.uploaded"),
|
|
2317
|
-
onFileDeleted: (_h) => removed("storage.onFileDeleted", "@On", "file.deleted")
|
|
2318
|
-
};
|
|
2319
|
-
var documents = {
|
|
2320
|
-
onDocumentCreated: (_h) => removed("documents.onDocumentCreated", "@On", "document.created"),
|
|
2321
|
-
onDocumentUpdated: (_h) => removed("documents.onDocumentUpdated", "@On", "document.updated"),
|
|
2322
|
-
onDocumentDeleted: (_h) => removed("documents.onDocumentDeleted", "@On", "document.deleted")
|
|
2323
|
-
};
|
|
2324
|
-
|
|
2325
2297
|
// src/index.ts
|
|
2326
2298
|
import { z } from "zod";
|
|
2327
2299
|
export {
|
|
@@ -2396,7 +2368,6 @@ export {
|
|
|
2396
2368
|
__runWithRuntime,
|
|
2397
2369
|
__setRuntime,
|
|
2398
2370
|
__shutdownResources,
|
|
2399
|
-
auth,
|
|
2400
2371
|
bigint,
|
|
2401
2372
|
boolean,
|
|
2402
2373
|
bucket,
|
|
@@ -2412,7 +2383,6 @@ export {
|
|
|
2412
2383
|
defineSecrets,
|
|
2413
2384
|
defineStorage,
|
|
2414
2385
|
defineTestUsers,
|
|
2415
|
-
documents,
|
|
2416
2386
|
entitlementFor,
|
|
2417
2387
|
enumType,
|
|
2418
2388
|
extractVariables,
|
|
@@ -2440,7 +2410,6 @@ export {
|
|
|
2440
2410
|
reservedSecretKey,
|
|
2441
2411
|
secret,
|
|
2442
2412
|
spendFor,
|
|
2443
|
-
storage,
|
|
2444
2413
|
testUser,
|
|
2445
2414
|
text,
|
|
2446
2415
|
timestamp,
|