@palbase/backend 10.0.0 → 10.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.
- package/dist/index.cjs +33 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -25
- package/dist/index.d.ts +76 -25
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/docs/config.md +7 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -707,6 +707,19 @@ type Seed = [keyof Tables] extends [never] ? SeedJson : SeedFor<Tables>;
|
|
|
707
707
|
interface TestUserOptions {
|
|
708
708
|
email?: string;
|
|
709
709
|
password?: string;
|
|
710
|
+
/**
|
|
711
|
+
* A verified phone for this fixture, E.164 (`+905551112233`). Requires
|
|
712
|
+
* {@link TestUserOptions.otp}: nothing can receive an SMS at a fabricated
|
|
713
|
+
* number, so a phone fixture without a knowable code is one no test could
|
|
714
|
+
* ever sign in as.
|
|
715
|
+
*/
|
|
716
|
+
phone?: string;
|
|
717
|
+
/**
|
|
718
|
+
* The fixed code this fixture's phone accepts. Honoured ONLY for the
|
|
719
|
+
* `is_test` user it belongs to — the real rail is untouched, and no
|
|
720
|
+
* verification is ever sent (or billed) for a fixture.
|
|
721
|
+
*/
|
|
722
|
+
otp?: string;
|
|
710
723
|
seed?: Seed;
|
|
711
724
|
}
|
|
712
725
|
/** The compiled, serializable test-user definition — the EXACT shape emitted to
|
|
@@ -716,6 +729,10 @@ interface TestUserDef {
|
|
|
716
729
|
email: string | null;
|
|
717
730
|
/** Fixed password (fixture), or `null` when the server should generate one. */
|
|
718
731
|
password: string | null;
|
|
732
|
+
/** Verified phone in E.164, or `null` for an e-mail-only fixture. */
|
|
733
|
+
phone: string | null;
|
|
734
|
+
/** The code that phone accepts, or `null` when there is no phone. */
|
|
735
|
+
otp: string | null;
|
|
719
736
|
/** The user's data tree; `{}` when nothing is seeded. */
|
|
720
737
|
seed: SeedJson;
|
|
721
738
|
}
|
|
@@ -791,6 +808,7 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
|
|
|
791
808
|
* new_dashboard: flag({ type: "boolean", default: false, description: "Roll out the new dashboard" }),
|
|
792
809
|
* max_uploads: flag({ type: "number", default: 10 }),
|
|
793
810
|
* theme: flag({ type: "string", default: "light", variants: ["light", "dark", "system"] }),
|
|
811
|
+
* limits: flag({ type: "json", default: { daily: 10, burst: 50 } }),
|
|
794
812
|
* },
|
|
795
813
|
* });
|
|
796
814
|
*
|
|
@@ -799,47 +817,80 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
|
|
|
799
817
|
* { __config: "flags", flags: { <key>: { type, default, variants, description }, ... } }
|
|
800
818
|
* `variants` is the allowed-values list for a string flag, or `null` (any
|
|
801
819
|
* string). `description` is the doc string, or `null`. The apply step maps the
|
|
802
|
-
* author-facing `type`
|
|
820
|
+
* author-facing `type` to PalFlags' `value_type`: "boolean" → "bool" and
|
|
821
|
+
* "json" → "object"; "number"/"string" pass through.
|
|
803
822
|
*/
|
|
804
823
|
/** The `__config` discriminant the eval/apply reads to confirm a config/*.ts is
|
|
805
824
|
* a flags config. Flags is `"flags"`. */
|
|
806
825
|
declare const FLAGS_CONFIG_KIND: "flags";
|
|
807
826
|
/**
|
|
808
827
|
* A flag's type. The author-facing vocabulary is `"boolean" | "number" |
|
|
809
|
-
* "string"
|
|
810
|
-
*
|
|
828
|
+
* "string" | "json"`; the apply step maps it to PalFlags' `value_type` enum —
|
|
829
|
+
* `"boolean"` → `"bool"`, `"json"` → `"object"`, the other two pass through. The
|
|
830
|
+
* SDK keeps the JS-natural names so the DSL reads cleanly.
|
|
811
831
|
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
* omitted here (set an object flag via the Studio / API directly if needed).
|
|
832
|
+
* `"json"` is a structured (object) flag. It is named for what an author types —
|
|
833
|
+
* a JSON object literal — and matches the `--type json` the CLI's per-user
|
|
834
|
+
* override commands already use for this same server type.
|
|
816
835
|
*/
|
|
817
|
-
type FlagType = "boolean" | "number" | "string";
|
|
836
|
+
type FlagType = "boolean" | "number" | "string" | "json";
|
|
837
|
+
/** Any value expressible in JSON — what may appear INSIDE a `"json"` flag's default. */
|
|
838
|
+
type FlagJsonValue = boolean | number | string | null | FlagJsonValue[] | {
|
|
839
|
+
[key: string]: FlagJsonValue;
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* The default of a `"json"` flag: a JSON OBJECT. Not an array and not a scalar —
|
|
843
|
+
* PalFlags' `object` value type accepts a JSON object at the top level only
|
|
844
|
+
* (`validate.ValidateValueTypeMatch`), and it caps nesting depth at 3.
|
|
845
|
+
*/
|
|
846
|
+
type FlagJsonObject = {
|
|
847
|
+
[key: string]: FlagJsonValue;
|
|
848
|
+
};
|
|
818
849
|
/** The runtime JSON value a flag's `default` may hold (matches {@link FlagType}). */
|
|
819
|
-
type FlagValue = boolean | number | string;
|
|
850
|
+
type FlagValue = boolean | number | string | FlagJsonObject;
|
|
820
851
|
/**
|
|
821
|
-
* The author-facing options for a single flag
|
|
852
|
+
* The author-facing options for a single flag — a UNION keyed on `type`, so
|
|
853
|
+
* `default` is checked against the declared type at compile time and `variants`
|
|
854
|
+
* is only accepted where it means something.
|
|
822
855
|
*
|
|
823
|
-
* - `type`: the flag's type — `"boolean" | "number" | "string"`.
|
|
856
|
+
* - `type`: the flag's type — `"boolean" | "number" | "string" | "json"`.
|
|
824
857
|
* - `default`: the project-wide default value. MUST match `type` (a `number`
|
|
825
|
-
* default with `type: "boolean"` throws).
|
|
858
|
+
* default with `type: "boolean"` is a type error, and throws at runtime).
|
|
826
859
|
* - `variants`: ONLY valid for `type: "string"` — the allowed values the string
|
|
827
860
|
* flag may take (a DEFINITION, not a per-user assignment). When given, the
|
|
828
|
-
* `default` MUST be one of the variants. Supplying `variants` on
|
|
829
|
-
* type throws.
|
|
861
|
+
* `default` MUST be one of the variants. Supplying `variants` on any other
|
|
862
|
+
* type is a type error, and throws at runtime. (PalFlags rejects variants for
|
|
863
|
+
* every non-string `value_type`, so accepting them here would only produce a
|
|
864
|
+
* config the server refuses.)
|
|
830
865
|
* - `description`: an optional human description of what the flag controls.
|
|
831
866
|
*/
|
|
832
|
-
|
|
833
|
-
type:
|
|
834
|
-
default:
|
|
867
|
+
type FlagOptions = {
|
|
868
|
+
type: "boolean";
|
|
869
|
+
default: boolean;
|
|
870
|
+
variants?: never;
|
|
871
|
+
description?: string;
|
|
872
|
+
} | {
|
|
873
|
+
type: "number";
|
|
874
|
+
default: number;
|
|
875
|
+
variants?: never;
|
|
876
|
+
description?: string;
|
|
877
|
+
} | {
|
|
878
|
+
type: "string";
|
|
879
|
+
default: string;
|
|
835
880
|
variants?: string[];
|
|
836
881
|
description?: string;
|
|
837
|
-
}
|
|
882
|
+
} | {
|
|
883
|
+
type: "json";
|
|
884
|
+
default: FlagJsonObject;
|
|
885
|
+
variants?: never;
|
|
886
|
+
description?: string;
|
|
887
|
+
};
|
|
838
888
|
/**
|
|
839
889
|
* The compiled, serializable flag definition — the EXACT shape emitted to JSON
|
|
840
890
|
* and consumed by the Go apply step.
|
|
841
891
|
*
|
|
842
|
-
* - `type`: the author-facing type verbatim (`"boolean" | "number" | "string"
|
|
892
|
+
* - `type`: the author-facing type verbatim (`"boolean" | "number" | "string" |
|
|
893
|
+
* "json"`) — the apply step maps it to PalFlags' `value_type`.
|
|
843
894
|
* - `default`: the default value (matches `type`).
|
|
844
895
|
* - `variants`: the allowed-values list for a string flag, or `null` (any).
|
|
845
896
|
* - `description`: the doc string, or `null`.
|
|
@@ -868,12 +919,12 @@ interface FlagsInput {
|
|
|
868
919
|
* options.
|
|
869
920
|
*
|
|
870
921
|
* Validates eagerly (at config-author time):
|
|
871
|
-
* - `type` is one of `"boolean" | "number" | "string"`.
|
|
922
|
+
* - `type` is one of `"boolean" | "number" | "string" | "json"`.
|
|
872
923
|
* - `default` matches `type` (e.g. a `number` default with `type: "boolean"`
|
|
873
|
-
* throws).
|
|
874
|
-
* - `variants` is ONLY allowed for a string flag (variants on
|
|
875
|
-
*
|
|
876
|
-
*
|
|
924
|
+
* throws; a `"json"` default must be a plain object, not an array or scalar).
|
|
925
|
+
* - `variants` is ONLY allowed for a string flag (variants on any other type
|
|
926
|
+
* throws); each entry is a non-empty string; the `default` must be one of the
|
|
927
|
+
* variants.
|
|
877
928
|
*
|
|
878
929
|
* Returns a normalized {@link FlagDef}: `variants` deduped-or-null,
|
|
879
930
|
* `description` trimmed-or-null.
|
|
@@ -1603,4 +1654,4 @@ declare const documents: {
|
|
|
1603
1654
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1604
1655
|
};
|
|
1605
1656
|
|
|
1606
|
-
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, flag, getErrorRegistry, getRoutes, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage, testUser, validateUploadAgainstStorage };
|
|
1657
|
+
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, flag, getErrorRegistry, getRoutes, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage, testUser, validateUploadAgainstStorage };
|
package/dist/index.d.ts
CHANGED
|
@@ -707,6 +707,19 @@ type Seed = [keyof Tables] extends [never] ? SeedJson : SeedFor<Tables>;
|
|
|
707
707
|
interface TestUserOptions {
|
|
708
708
|
email?: string;
|
|
709
709
|
password?: string;
|
|
710
|
+
/**
|
|
711
|
+
* A verified phone for this fixture, E.164 (`+905551112233`). Requires
|
|
712
|
+
* {@link TestUserOptions.otp}: nothing can receive an SMS at a fabricated
|
|
713
|
+
* number, so a phone fixture without a knowable code is one no test could
|
|
714
|
+
* ever sign in as.
|
|
715
|
+
*/
|
|
716
|
+
phone?: string;
|
|
717
|
+
/**
|
|
718
|
+
* The fixed code this fixture's phone accepts. Honoured ONLY for the
|
|
719
|
+
* `is_test` user it belongs to — the real rail is untouched, and no
|
|
720
|
+
* verification is ever sent (or billed) for a fixture.
|
|
721
|
+
*/
|
|
722
|
+
otp?: string;
|
|
710
723
|
seed?: Seed;
|
|
711
724
|
}
|
|
712
725
|
/** The compiled, serializable test-user definition — the EXACT shape emitted to
|
|
@@ -716,6 +729,10 @@ interface TestUserDef {
|
|
|
716
729
|
email: string | null;
|
|
717
730
|
/** Fixed password (fixture), or `null` when the server should generate one. */
|
|
718
731
|
password: string | null;
|
|
732
|
+
/** Verified phone in E.164, or `null` for an e-mail-only fixture. */
|
|
733
|
+
phone: string | null;
|
|
734
|
+
/** The code that phone accepts, or `null` when there is no phone. */
|
|
735
|
+
otp: string | null;
|
|
719
736
|
/** The user's data tree; `{}` when nothing is seeded. */
|
|
720
737
|
seed: SeedJson;
|
|
721
738
|
}
|
|
@@ -791,6 +808,7 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
|
|
|
791
808
|
* new_dashboard: flag({ type: "boolean", default: false, description: "Roll out the new dashboard" }),
|
|
792
809
|
* max_uploads: flag({ type: "number", default: 10 }),
|
|
793
810
|
* theme: flag({ type: "string", default: "light", variants: ["light", "dark", "system"] }),
|
|
811
|
+
* limits: flag({ type: "json", default: { daily: 10, burst: 50 } }),
|
|
794
812
|
* },
|
|
795
813
|
* });
|
|
796
814
|
*
|
|
@@ -799,47 +817,80 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
|
|
|
799
817
|
* { __config: "flags", flags: { <key>: { type, default, variants, description }, ... } }
|
|
800
818
|
* `variants` is the allowed-values list for a string flag, or `null` (any
|
|
801
819
|
* string). `description` is the doc string, or `null`. The apply step maps the
|
|
802
|
-
* author-facing `type`
|
|
820
|
+
* author-facing `type` to PalFlags' `value_type`: "boolean" → "bool" and
|
|
821
|
+
* "json" → "object"; "number"/"string" pass through.
|
|
803
822
|
*/
|
|
804
823
|
/** The `__config` discriminant the eval/apply reads to confirm a config/*.ts is
|
|
805
824
|
* a flags config. Flags is `"flags"`. */
|
|
806
825
|
declare const FLAGS_CONFIG_KIND: "flags";
|
|
807
826
|
/**
|
|
808
827
|
* A flag's type. The author-facing vocabulary is `"boolean" | "number" |
|
|
809
|
-
* "string"
|
|
810
|
-
*
|
|
828
|
+
* "string" | "json"`; the apply step maps it to PalFlags' `value_type` enum —
|
|
829
|
+
* `"boolean"` → `"bool"`, `"json"` → `"object"`, the other two pass through. The
|
|
830
|
+
* SDK keeps the JS-natural names so the DSL reads cleanly.
|
|
811
831
|
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
* omitted here (set an object flag via the Studio / API directly if needed).
|
|
832
|
+
* `"json"` is a structured (object) flag. It is named for what an author types —
|
|
833
|
+
* a JSON object literal — and matches the `--type json` the CLI's per-user
|
|
834
|
+
* override commands already use for this same server type.
|
|
816
835
|
*/
|
|
817
|
-
type FlagType = "boolean" | "number" | "string";
|
|
836
|
+
type FlagType = "boolean" | "number" | "string" | "json";
|
|
837
|
+
/** Any value expressible in JSON — what may appear INSIDE a `"json"` flag's default. */
|
|
838
|
+
type FlagJsonValue = boolean | number | string | null | FlagJsonValue[] | {
|
|
839
|
+
[key: string]: FlagJsonValue;
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* The default of a `"json"` flag: a JSON OBJECT. Not an array and not a scalar —
|
|
843
|
+
* PalFlags' `object` value type accepts a JSON object at the top level only
|
|
844
|
+
* (`validate.ValidateValueTypeMatch`), and it caps nesting depth at 3.
|
|
845
|
+
*/
|
|
846
|
+
type FlagJsonObject = {
|
|
847
|
+
[key: string]: FlagJsonValue;
|
|
848
|
+
};
|
|
818
849
|
/** The runtime JSON value a flag's `default` may hold (matches {@link FlagType}). */
|
|
819
|
-
type FlagValue = boolean | number | string;
|
|
850
|
+
type FlagValue = boolean | number | string | FlagJsonObject;
|
|
820
851
|
/**
|
|
821
|
-
* The author-facing options for a single flag
|
|
852
|
+
* The author-facing options for a single flag — a UNION keyed on `type`, so
|
|
853
|
+
* `default` is checked against the declared type at compile time and `variants`
|
|
854
|
+
* is only accepted where it means something.
|
|
822
855
|
*
|
|
823
|
-
* - `type`: the flag's type — `"boolean" | "number" | "string"`.
|
|
856
|
+
* - `type`: the flag's type — `"boolean" | "number" | "string" | "json"`.
|
|
824
857
|
* - `default`: the project-wide default value. MUST match `type` (a `number`
|
|
825
|
-
* default with `type: "boolean"` throws).
|
|
858
|
+
* default with `type: "boolean"` is a type error, and throws at runtime).
|
|
826
859
|
* - `variants`: ONLY valid for `type: "string"` — the allowed values the string
|
|
827
860
|
* flag may take (a DEFINITION, not a per-user assignment). When given, the
|
|
828
|
-
* `default` MUST be one of the variants. Supplying `variants` on
|
|
829
|
-
* type throws.
|
|
861
|
+
* `default` MUST be one of the variants. Supplying `variants` on any other
|
|
862
|
+
* type is a type error, and throws at runtime. (PalFlags rejects variants for
|
|
863
|
+
* every non-string `value_type`, so accepting them here would only produce a
|
|
864
|
+
* config the server refuses.)
|
|
830
865
|
* - `description`: an optional human description of what the flag controls.
|
|
831
866
|
*/
|
|
832
|
-
|
|
833
|
-
type:
|
|
834
|
-
default:
|
|
867
|
+
type FlagOptions = {
|
|
868
|
+
type: "boolean";
|
|
869
|
+
default: boolean;
|
|
870
|
+
variants?: never;
|
|
871
|
+
description?: string;
|
|
872
|
+
} | {
|
|
873
|
+
type: "number";
|
|
874
|
+
default: number;
|
|
875
|
+
variants?: never;
|
|
876
|
+
description?: string;
|
|
877
|
+
} | {
|
|
878
|
+
type: "string";
|
|
879
|
+
default: string;
|
|
835
880
|
variants?: string[];
|
|
836
881
|
description?: string;
|
|
837
|
-
}
|
|
882
|
+
} | {
|
|
883
|
+
type: "json";
|
|
884
|
+
default: FlagJsonObject;
|
|
885
|
+
variants?: never;
|
|
886
|
+
description?: string;
|
|
887
|
+
};
|
|
838
888
|
/**
|
|
839
889
|
* The compiled, serializable flag definition — the EXACT shape emitted to JSON
|
|
840
890
|
* and consumed by the Go apply step.
|
|
841
891
|
*
|
|
842
|
-
* - `type`: the author-facing type verbatim (`"boolean" | "number" | "string"
|
|
892
|
+
* - `type`: the author-facing type verbatim (`"boolean" | "number" | "string" |
|
|
893
|
+
* "json"`) — the apply step maps it to PalFlags' `value_type`.
|
|
843
894
|
* - `default`: the default value (matches `type`).
|
|
844
895
|
* - `variants`: the allowed-values list for a string flag, or `null` (any).
|
|
845
896
|
* - `description`: the doc string, or `null`.
|
|
@@ -868,12 +919,12 @@ interface FlagsInput {
|
|
|
868
919
|
* options.
|
|
869
920
|
*
|
|
870
921
|
* Validates eagerly (at config-author time):
|
|
871
|
-
* - `type` is one of `"boolean" | "number" | "string"`.
|
|
922
|
+
* - `type` is one of `"boolean" | "number" | "string" | "json"`.
|
|
872
923
|
* - `default` matches `type` (e.g. a `number` default with `type: "boolean"`
|
|
873
|
-
* throws).
|
|
874
|
-
* - `variants` is ONLY allowed for a string flag (variants on
|
|
875
|
-
*
|
|
876
|
-
*
|
|
924
|
+
* throws; a `"json"` default must be a plain object, not an array or scalar).
|
|
925
|
+
* - `variants` is ONLY allowed for a string flag (variants on any other type
|
|
926
|
+
* throws); each entry is a non-empty string; the `default` must be one of the
|
|
927
|
+
* variants.
|
|
877
928
|
*
|
|
878
929
|
* Returns a normalized {@link FlagDef}: `variants` deduped-or-null,
|
|
879
930
|
* `description` trimmed-or-null.
|
|
@@ -1603,4 +1654,4 @@ declare const documents: {
|
|
|
1603
1654
|
onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
|
|
1604
1655
|
};
|
|
1605
1656
|
|
|
1606
|
-
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, flag, getErrorRegistry, getRoutes, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage, testUser, validateUploadAgainstStorage };
|
|
1657
|
+
export { type AcsOptions, type ApnsOptions, type BackoffStrategy, Body, type BucketDef, type BucketOptions, Cache, CacheClient, Client, Controller, type ControllerOptions, type CustomWebhookConfig, DBClient, Database, type DefinedError, type DefinedErrorWithData, Delete, type DocumentCreatedEvent, type DocumentDeletedEvent, type DocumentUpdatedEvent, Documents, EGRESS_CONFIG_KIND, type EgressConfig, type EgressInput, type EnvSecretRef, EnvTypedDatabase, FLAGS_CONFIG_KIND, type FcmOptions, type FileDeletedEvent, type FileUploadedEvent, type FlagDef, type FlagJsonObject, type FlagJsonValue, type FlagOptions, type FlagType, type FlagValue, Flags, type FlagsConfig, type FlagsInput, Get, Headers, type HookHandler, type HookMeta, HttpError, type HttpMethodUpper, type JobConfig, type JobMeta, Log, Logger, NOTIFICATIONS_CONFIG_KIND, Notifications, type NotificationsConfig, type NotificationsInput, OptionalUser, type OwnedTablesOf, PROVIDER_CATALOG, PalbaseDocsClient, PalbaseFlagsClient, PalbaseNotificationsClient, PalbaseRealtimeClient, PalbaseStorageClient, Param, type ParamKind, type ParamMeta, type PasswordResetEvent, Patch, Post, type ProviderCatalogEntry, type ProviderDef, type ProviderEventMap, type ProviderName, type ProviderOptions, type ProviderWebhookConfig, Put, Query, QueryParams, Queue, QueueClient, RESERVED_SECRET_PREFIX, RateLimitConfig, Realtime, type RegisteredError, Req, RequestId, type ResolvedCustomWebhook, type ResolvedHook, type ResolvedJobConfig, type ResolvedProviderWebhook, type ResolvedWebhookConfig, type ResolvedWorkerConfig, Resource, type ResourceEnv, type RouteMeta, type RouteOptions, type RuntimeServices, STORAGE_CONFIG_KIND, SchemaDef, type Seed, type SeedFor, type SeedJson, type SeedRowFor, type SendgridOptions, type SesOptions, type SignInEvent, type SignOutEvent, type SmtpOptions, Storage, type StorageConfig, type StorageInput, TEST_USERS_CONFIG_KIND, type TableGraph, TableTypes, Tables, type TestUserDef, type TestUserOptions, type TestUsersConfig, type TestUsersInput, type ThrowDescriptor, TraceId, type TwilioOptions, Upload, type UploadConfig, UploadedObject, User, type UserCreatedEvent, User$1 as UserT, type WebhookEventHandler, type WebhookMeta, type WebhookProvider, type WebhookRequest, type WorkerConfig, type WorkerMeta, __getRuntime, __registerResource, __requestALS, __runResourceBoot, __runWithRuntime, __setRuntime, __shutdownResources, auth, bucket, buildProvider, defineEgress, defineError, defineFlags, defineJob, defineNotifications, defineStorage, defineTestUsers, defineWebhook, defineWorker, documents, flag, getErrorRegistry, getRoutes, makeEnvDts, parseFileSizeLimit, recordThrows, reservedSecretKey, storage, testUser, validateUploadAgainstStorage };
|
package/dist/index.js
CHANGED
|
@@ -363,6 +363,9 @@ function camelToUpperSnake(s) {
|
|
|
363
363
|
var TEST_USERS_CONFIG_KIND = "test-users";
|
|
364
364
|
var TEST_USER_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
365
365
|
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
366
|
+
var E164_RE = /^\+[1-9]\d{1,14}$/;
|
|
367
|
+
var OTP_LENGTH = 6;
|
|
368
|
+
var OTP_RE = /^\d{6}$/;
|
|
366
369
|
var MIN_PASSWORD_LENGTH = 8;
|
|
367
370
|
function isPlainObject(value) {
|
|
368
371
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -397,7 +400,7 @@ function normalizeSeed(seed, userName) {
|
|
|
397
400
|
}
|
|
398
401
|
function testUser(opts = {}) {
|
|
399
402
|
if (!isPlainObject(opts)) {
|
|
400
|
-
throw new Error("testUser() expects { email?, password?, seed? }");
|
|
403
|
+
throw new Error("testUser() expects { email?, password?, phone?, otp?, seed? }");
|
|
401
404
|
}
|
|
402
405
|
const hasEmail = opts.email !== void 0;
|
|
403
406
|
const hasPassword = opts.password !== void 0;
|
|
@@ -420,7 +423,30 @@ function testUser(opts = {}) {
|
|
|
420
423
|
email = opts.email;
|
|
421
424
|
password = opts.password;
|
|
422
425
|
}
|
|
423
|
-
|
|
426
|
+
const hasPhone = opts.phone !== void 0;
|
|
427
|
+
const hasOTP = opts.otp !== void 0;
|
|
428
|
+
if (hasPhone !== hasOTP) {
|
|
429
|
+
throw new Error(
|
|
430
|
+
"testUser() needs phone AND otp together \u2014 nothing can receive an SMS at a fabricated number, so a phone fixture without its fixed code can never be signed in as"
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
let phone = null;
|
|
434
|
+
let otp = null;
|
|
435
|
+
if (hasPhone) {
|
|
436
|
+
if (typeof opts.phone !== "string" || !E164_RE.test(opts.phone)) {
|
|
437
|
+
throw new Error(
|
|
438
|
+
`testUser phone ${JSON.stringify(opts.phone)} must be E.164, e.g. "+905551112233"`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (typeof opts.otp !== "string" || !OTP_RE.test(opts.otp)) {
|
|
442
|
+
throw new Error(
|
|
443
|
+
`testUser otp ${JSON.stringify(opts.otp)} must be ${OTP_LENGTH} digits`
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
phone = opts.phone;
|
|
447
|
+
otp = opts.otp;
|
|
448
|
+
}
|
|
449
|
+
return { email, password, phone, otp, seed: normalizeSeed(opts.seed, email ?? "<template>") };
|
|
424
450
|
}
|
|
425
451
|
function defineTestUsers(input) {
|
|
426
452
|
if (!isPlainObject(input) || !isPlainObject(input.users)) {
|
|
@@ -462,6 +488,8 @@ function valueMatchesType(type, value) {
|
|
|
462
488
|
return typeof value === "number" && Number.isFinite(value);
|
|
463
489
|
case "string":
|
|
464
490
|
return typeof value === "string";
|
|
491
|
+
case "json":
|
|
492
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
465
493
|
}
|
|
466
494
|
}
|
|
467
495
|
function flag(opts) {
|
|
@@ -469,8 +497,8 @@ function flag(opts) {
|
|
|
469
497
|
throw new Error("flag() expects { type, default, variants?, description? }");
|
|
470
498
|
}
|
|
471
499
|
const { type } = opts;
|
|
472
|
-
if (type !== "boolean" && type !== "number" && type !== "string") {
|
|
473
|
-
throw new Error(`flag type must be "boolean", "number", or "
|
|
500
|
+
if (type !== "boolean" && type !== "number" && type !== "string" && type !== "json") {
|
|
501
|
+
throw new Error(`flag type must be "boolean", "number", "string", or "json", got ${JSON.stringify(type)}`);
|
|
474
502
|
}
|
|
475
503
|
if (!valueMatchesType(type, opts.default)) {
|
|
476
504
|
throw new Error(
|
|
@@ -479,7 +507,7 @@ function flag(opts) {
|
|
|
479
507
|
}
|
|
480
508
|
let variants = null;
|
|
481
509
|
if (opts.variants !== void 0) {
|
|
482
|
-
if (type !== "string") {
|
|
510
|
+
if (opts.type !== "string") {
|
|
483
511
|
throw new Error(`flag variants are only valid for type "string" (got type "${type}")`);
|
|
484
512
|
}
|
|
485
513
|
if (!Array.isArray(opts.variants)) {
|