@palbase/backend 10.1.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.d.cts CHANGED
@@ -808,6 +808,7 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
808
808
  * new_dashboard: flag({ type: "boolean", default: false, description: "Roll out the new dashboard" }),
809
809
  * max_uploads: flag({ type: "number", default: 10 }),
810
810
  * theme: flag({ type: "string", default: "light", variants: ["light", "dark", "system"] }),
811
+ * limits: flag({ type: "json", default: { daily: 10, burst: 50 } }),
811
812
  * },
812
813
  * });
813
814
  *
@@ -816,47 +817,80 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
816
817
  * { __config: "flags", flags: { <key>: { type, default, variants, description }, ... } }
817
818
  * `variants` is the allowed-values list for a string flag, or `null` (any
818
819
  * string). `description` is the doc string, or `null`. The apply step maps the
819
- * author-facing `type` ("boolean") to PalFlags' `value_type` ("bool").
820
+ * author-facing `type` to PalFlags' `value_type`: "boolean" → "bool" and
821
+ * "json" → "object"; "number"/"string" pass through.
820
822
  */
821
823
  /** The `__config` discriminant the eval/apply reads to confirm a config/*.ts is
822
824
  * a flags config. Flags is `"flags"`. */
823
825
  declare const FLAGS_CONFIG_KIND: "flags";
824
826
  /**
825
827
  * A flag's type. The author-facing vocabulary is `"boolean" | "number" |
826
- * "string"`. (The br-pod maps `"boolean"` to PalFlags' `value_type: "bool"` on
827
- * apply — the SDK keeps the JS-natural `"boolean"` so the DSL reads cleanly.)
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.
828
831
  *
829
- * PalFlags also supports an `object` value type, but config-as-code flags are
830
- * deliberately scoped to the three SCALAR types — an object default is awkward
831
- * to author on the CLI and rare for a feature flag, so it is intentionally
832
- * 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.
833
835
  */
834
- 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
+ };
835
849
  /** The runtime JSON value a flag's `default` may hold (matches {@link FlagType}). */
836
- type FlagValue = boolean | number | string;
850
+ type FlagValue = boolean | number | string | FlagJsonObject;
837
851
  /**
838
- * 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.
839
855
  *
840
- * - `type`: the flag's type — `"boolean" | "number" | "string"`.
856
+ * - `type`: the flag's type — `"boolean" | "number" | "string" | "json"`.
841
857
  * - `default`: the project-wide default value. MUST match `type` (a `number`
842
- * default with `type: "boolean"` throws).
858
+ * default with `type: "boolean"` is a type error, and throws at runtime).
843
859
  * - `variants`: ONLY valid for `type: "string"` — the allowed values the string
844
860
  * flag may take (a DEFINITION, not a per-user assignment). When given, the
845
- * `default` MUST be one of the variants. Supplying `variants` on a non-string
846
- * 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.)
847
865
  * - `description`: an optional human description of what the flag controls.
848
866
  */
849
- interface FlagOptions {
850
- type: FlagType;
851
- default: FlagValue;
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;
852
880
  variants?: string[];
853
881
  description?: string;
854
- }
882
+ } | {
883
+ type: "json";
884
+ default: FlagJsonObject;
885
+ variants?: never;
886
+ description?: string;
887
+ };
855
888
  /**
856
889
  * The compiled, serializable flag definition — the EXACT shape emitted to JSON
857
890
  * and consumed by the Go apply step.
858
891
  *
859
- * - `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`.
860
894
  * - `default`: the default value (matches `type`).
861
895
  * - `variants`: the allowed-values list for a string flag, or `null` (any).
862
896
  * - `description`: the doc string, or `null`.
@@ -885,12 +919,12 @@ interface FlagsInput {
885
919
  * options.
886
920
  *
887
921
  * Validates eagerly (at config-author time):
888
- * - `type` is one of `"boolean" | "number" | "string"`.
922
+ * - `type` is one of `"boolean" | "number" | "string" | "json"`.
889
923
  * - `default` matches `type` (e.g. a `number` default with `type: "boolean"`
890
- * throws).
891
- * - `variants` is ONLY allowed for a string flag (variants on a non-string
892
- * type throws); each entry is a non-empty string; the `default` must be one
893
- * of the variants.
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.
894
928
  *
895
929
  * Returns a normalized {@link FlagDef}: `variants` deduped-or-null,
896
930
  * `description` trimmed-or-null.
@@ -1620,4 +1654,4 @@ declare const documents: {
1620
1654
  onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
1621
1655
  };
1622
1656
 
1623
- 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
@@ -808,6 +808,7 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
808
808
  * new_dashboard: flag({ type: "boolean", default: false, description: "Roll out the new dashboard" }),
809
809
  * max_uploads: flag({ type: "number", default: 10 }),
810
810
  * theme: flag({ type: "string", default: "light", variants: ["light", "dark", "system"] }),
811
+ * limits: flag({ type: "json", default: { daily: 10, burst: 50 } }),
811
812
  * },
812
813
  * });
813
814
  *
@@ -816,47 +817,80 @@ declare function defineTestUsers(input: TestUsersInput): TestUsersConfig;
816
817
  * { __config: "flags", flags: { <key>: { type, default, variants, description }, ... } }
817
818
  * `variants` is the allowed-values list for a string flag, or `null` (any
818
819
  * string). `description` is the doc string, or `null`. The apply step maps the
819
- * author-facing `type` ("boolean") to PalFlags' `value_type` ("bool").
820
+ * author-facing `type` to PalFlags' `value_type`: "boolean" → "bool" and
821
+ * "json" → "object"; "number"/"string" pass through.
820
822
  */
821
823
  /** The `__config` discriminant the eval/apply reads to confirm a config/*.ts is
822
824
  * a flags config. Flags is `"flags"`. */
823
825
  declare const FLAGS_CONFIG_KIND: "flags";
824
826
  /**
825
827
  * A flag's type. The author-facing vocabulary is `"boolean" | "number" |
826
- * "string"`. (The br-pod maps `"boolean"` to PalFlags' `value_type: "bool"` on
827
- * apply — the SDK keeps the JS-natural `"boolean"` so the DSL reads cleanly.)
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.
828
831
  *
829
- * PalFlags also supports an `object` value type, but config-as-code flags are
830
- * deliberately scoped to the three SCALAR types — an object default is awkward
831
- * to author on the CLI and rare for a feature flag, so it is intentionally
832
- * 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.
833
835
  */
834
- 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
+ };
835
849
  /** The runtime JSON value a flag's `default` may hold (matches {@link FlagType}). */
836
- type FlagValue = boolean | number | string;
850
+ type FlagValue = boolean | number | string | FlagJsonObject;
837
851
  /**
838
- * 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.
839
855
  *
840
- * - `type`: the flag's type — `"boolean" | "number" | "string"`.
856
+ * - `type`: the flag's type — `"boolean" | "number" | "string" | "json"`.
841
857
  * - `default`: the project-wide default value. MUST match `type` (a `number`
842
- * default with `type: "boolean"` throws).
858
+ * default with `type: "boolean"` is a type error, and throws at runtime).
843
859
  * - `variants`: ONLY valid for `type: "string"` — the allowed values the string
844
860
  * flag may take (a DEFINITION, not a per-user assignment). When given, the
845
- * `default` MUST be one of the variants. Supplying `variants` on a non-string
846
- * 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.)
847
865
  * - `description`: an optional human description of what the flag controls.
848
866
  */
849
- interface FlagOptions {
850
- type: FlagType;
851
- default: FlagValue;
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;
852
880
  variants?: string[];
853
881
  description?: string;
854
- }
882
+ } | {
883
+ type: "json";
884
+ default: FlagJsonObject;
885
+ variants?: never;
886
+ description?: string;
887
+ };
855
888
  /**
856
889
  * The compiled, serializable flag definition — the EXACT shape emitted to JSON
857
890
  * and consumed by the Go apply step.
858
891
  *
859
- * - `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`.
860
894
  * - `default`: the default value (matches `type`).
861
895
  * - `variants`: the allowed-values list for a string flag, or `null` (any).
862
896
  * - `description`: the doc string, or `null`.
@@ -885,12 +919,12 @@ interface FlagsInput {
885
919
  * options.
886
920
  *
887
921
  * Validates eagerly (at config-author time):
888
- * - `type` is one of `"boolean" | "number" | "string"`.
922
+ * - `type` is one of `"boolean" | "number" | "string" | "json"`.
889
923
  * - `default` matches `type` (e.g. a `number` default with `type: "boolean"`
890
- * throws).
891
- * - `variants` is ONLY allowed for a string flag (variants on a non-string
892
- * type throws); each entry is a non-empty string; the `default` must be one
893
- * of the variants.
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.
894
928
  *
895
929
  * Returns a normalized {@link FlagDef}: `variants` deduped-or-null,
896
930
  * `description` trimmed-or-null.
@@ -1620,4 +1654,4 @@ declare const documents: {
1620
1654
  onDocumentDeleted(handler: HookHandler<DocumentDeletedEvent>): ResolvedHook<DocumentDeletedEvent>;
1621
1655
  };
1622
1656
 
1623
- 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
@@ -488,6 +488,8 @@ function valueMatchesType(type, value) {
488
488
  return typeof value === "number" && Number.isFinite(value);
489
489
  case "string":
490
490
  return typeof value === "string";
491
+ case "json":
492
+ return typeof value === "object" && value !== null && !Array.isArray(value);
491
493
  }
492
494
  }
493
495
  function flag(opts) {
@@ -495,8 +497,8 @@ function flag(opts) {
495
497
  throw new Error("flag() expects { type, default, variants?, description? }");
496
498
  }
497
499
  const { type } = opts;
498
- if (type !== "boolean" && type !== "number" && type !== "string") {
499
- throw new Error(`flag type must be "boolean", "number", or "string", got ${JSON.stringify(type)}`);
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)}`);
500
502
  }
501
503
  if (!valueMatchesType(type, opts.default)) {
502
504
  throw new Error(
@@ -505,7 +507,7 @@ function flag(opts) {
505
507
  }
506
508
  let variants = null;
507
509
  if (opts.variants !== void 0) {
508
- if (type !== "string") {
510
+ if (opts.type !== "string") {
509
511
  throw new Error(`flag variants are only valid for type "string" (got type "${type}")`);
510
512
  }
511
513
  if (!Array.isArray(opts.variants)) {