@domino-sdk/relay 1.1.0 → 1.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.
@@ -3,8 +3,8 @@ import { O as OpenIdentityKind, a1 as TrackerDataSchema, a9 as TrackerQuery, bV
3
3
  export { aS as entitlementSchema, b4 as memberIdentitySchema } from '../schema-DfJzH2ci.js';
4
4
  import { z } from 'zod';
5
5
  import { r as collectionBeginSchema, z as counterHistoryQuerySchema, E as counterModerationSchema, o as automaticSchedulingQuerySchema, p as automaticSchedulingRetrySchema, l as automaticOutcomeQuerySchema, g as automaticCatchUpInputSchema, f as automaticCatchUpConfirmSchema } from '../automatic-outcomes-B1xrETxm.js';
6
- import { n as projectDeploymentSchema, q as publishDeploymentSchema, v as submitDeploymentSchema, t as rejectDeploymentSchema, o as promoteDeploymentSchema, u as rollbackDeploymentSchema, k as projectCalendarInputSchema } from '../activity-B8k9Sa_a.js';
7
- export { c as activityTypeSchema, d as activityTypes } from '../activity-B8k9Sa_a.js';
6
+ import { n as projectDeploymentSchema, q as publishDeploymentSchema, v as submitDeploymentSchema, t as rejectDeploymentSchema, o as promoteDeploymentSchema, u as rollbackDeploymentSchema, k as projectCalendarInputSchema } from '../activity-o1E-Hqyt.js';
7
+ export { c as activityTypeSchema, d as activityTypes } from '../activity-o1E-Hqyt.js';
8
8
  import { O as engagementChangePreviewInputSchema, S as engagementChangeSchema, a1 as engagementVersionQuerySchema, V as engagementPageQuerySchema, X as engagementPublishSchema, ax as pointLedgerSchema, aA as pointsMutationSchema, aK as referralControlSchema, ac as leaderboardQuerySchema, a5 as leaderboardExclusionSchema, p as ProjectGroupReference, a6 as leaderboardGroupSchema, am as memberCampaignEnrollmentInputSchema, an as memberCampaignWithdrawalInputSchema, F as createPointLedgerSchema, ae as leaderboardSettlementApprovalSchema } from '../groups-Ck-OxzjD.js';
9
9
  import { h as offerControlSchema, m as redemptionCancellationSchema } from '../offers-Cy-e4o5x.js';
10
10
  import { C as profileSettingsInputSchema, z as profileModerationSchema } from '../profiles-D2aFcOxu.js';
@@ -369,6 +369,11 @@ declare const appRoutingSchema: z.ZodDefault<z.ZodEnum<{
369
369
  }>>;
370
370
  /** Most app secrets a project environment can hold. */
371
371
  declare const APP_SECRET_LIMIT = 50;
372
+ declare const APP_KV_LIMIT = 5;
373
+ declare const APP_SQL_LIMIT = 5;
374
+ declare const APP_MIGRATION_LIMIT = 100;
375
+ declare const APP_MIGRATION_FILE_BYTES = 90000;
376
+ declare const APP_MIGRATION_TOTAL_BYTES = 1000000;
372
377
  /**
373
378
  * An app secret's name: the Worker binding it becomes. `DOMINO_` names and `ASSETS` are the
374
379
  * platform's own bindings.
@@ -423,6 +428,84 @@ declare const hostedAppSecretsSchema: z.ZodObject<{
423
428
  secrets: z.ZodRecord<z.ZodString, z.ZodString>;
424
429
  }, z.core.$strict>;
425
430
  type HostedAppSecrets = z.infer<typeof hostedAppSecretsSchema>;
431
+ declare const appStorageSchema: z.ZodObject<{
432
+ kv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
433
+ description: z.ZodString;
434
+ }, z.core.$strict>>>;
435
+ sql: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
436
+ description: z.ZodString;
437
+ migrations: z.ZodOptional<z.ZodString>;
438
+ }, z.core.$strict>>>;
439
+ }, z.core.$strict>;
440
+ type AppStorage = z.infer<typeof appStorageSchema>;
441
+ declare const appStorageKindSchema: z.ZodEnum<{
442
+ kv: "kv";
443
+ sql: "sql";
444
+ }>;
445
+ type AppStorageKind = z.infer<typeof appStorageKindSchema>;
446
+ declare const appStorageListSchema: z.ZodObject<{
447
+ stores: z.ZodArray<z.ZodObject<{
448
+ kind: z.ZodString;
449
+ name: z.ZodString;
450
+ createdAt: z.ZodNullable<z.ZodNumber>;
451
+ declared: z.ZodBoolean;
452
+ description: z.ZodOptional<z.ZodString>;
453
+ }, z.core.$strip>>;
454
+ }, z.core.$strip>;
455
+ type AppStorageList = z.infer<typeof appStorageListSchema>;
456
+ /** Rows per page when browsing a SQL store's table. */
457
+ declare const APP_STORAGE_ROW_LIMIT = 50;
458
+ /** Longest text a browsed cell or KV value shows; longer values end in `truncated`. */
459
+ declare const APP_STORAGE_PREVIEW_CHARACTERS = 2000;
460
+ /**
461
+ * A browsed SQL value. Text longer than the preview is cut and flagged; a BLOB shows only its
462
+ * size in bytes.
463
+ */
464
+ declare const appStorageCellSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull, z.ZodObject<{
465
+ text: z.ZodString;
466
+ truncated: z.ZodLiteral<true>;
467
+ }, z.core.$strip>, z.ZodObject<{
468
+ blob: z.ZodNumber;
469
+ }, z.core.$strip>]>;
470
+ type AppStorageCell = z.infer<typeof appStorageCellSchema>;
471
+ declare const appStorageTablesSchema: z.ZodObject<{
472
+ tables: z.ZodArray<z.ZodObject<{
473
+ name: z.ZodString;
474
+ kind: z.ZodString;
475
+ }, z.core.$strip>>;
476
+ }, z.core.$strip>;
477
+ type AppStorageTables = z.infer<typeof appStorageTablesSchema>;
478
+ declare const appStorageRowsSchema: z.ZodObject<{
479
+ table: z.ZodString;
480
+ columns: z.ZodArray<z.ZodString>;
481
+ rows: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull, z.ZodObject<{
482
+ text: z.ZodString;
483
+ truncated: z.ZodLiteral<true>;
484
+ }, z.core.$strip>, z.ZodObject<{
485
+ blob: z.ZodNumber;
486
+ }, z.core.$strip>]>>>;
487
+ offset: z.ZodNumber;
488
+ total: z.ZodNumber;
489
+ }, z.core.$strip>;
490
+ type AppStorageRows = z.infer<typeof appStorageRowsSchema>;
491
+ declare const appStorageKeysSchema: z.ZodObject<{
492
+ keys: z.ZodArray<z.ZodObject<{
493
+ name: z.ZodString;
494
+ expiration: z.ZodNullable<z.ZodNumber>;
495
+ }, z.core.$strip>>;
496
+ cursor: z.ZodNullable<z.ZodString>;
497
+ }, z.core.$strip>;
498
+ type AppStorageKeys = z.infer<typeof appStorageKeysSchema>;
499
+ declare const appStorageValueSchema: z.ZodObject<{
500
+ key: z.ZodString;
501
+ size: z.ZodNumber;
502
+ text: z.ZodNullable<z.ZodString>;
503
+ truncated: z.ZodBoolean;
504
+ }, z.core.$strip>;
505
+ type AppStorageValue = z.infer<typeof appStorageValueSchema>;
506
+ declare const appMigrationNameSchema: z.ZodString;
507
+ /** Wrangler compares the leading number first, then the filename (workers-sdk d1/migrations/helpers.ts). */
508
+ declare function compareAppMigrations(a: string, b: string): number;
426
509
  declare const hostedAppSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
427
510
  routing: z.ZodDefault<z.ZodEnum<{
428
511
  legacy: "legacy";
@@ -443,6 +526,15 @@ declare const hostedAppSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
443
526
  description: z.ZodString;
444
527
  required: z.ZodDefault<z.ZodBoolean>;
445
528
  }, z.core.$strict>>>;
529
+ storage: z.ZodOptional<z.ZodObject<{
530
+ kv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
531
+ description: z.ZodString;
532
+ }, z.core.$strict>>>;
533
+ sql: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
534
+ description: z.ZodString;
535
+ migrations: z.ZodOptional<z.ZodString>;
536
+ }, z.core.$strict>>>;
537
+ }, z.core.$strict>>;
446
538
  routing: z.ZodDefault<z.ZodEnum<{
447
539
  legacy: "legacy";
448
540
  transparent: "transparent";
@@ -802,6 +894,10 @@ declare const buildArtifactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
802
894
  transparent: "transparent";
803
895
  }>>;
804
896
  worker: z.ZodOptional<z.ZodObject<{
897
+ migrations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
898
+ name: z.ZodString;
899
+ sql: z.ZodString;
900
+ }, z.core.$strict>>>>;
805
901
  modules: z.ZodArray<z.ZodObject<{
806
902
  path: z.ZodString;
807
903
  type: z.ZodEnum<{
@@ -821,6 +917,15 @@ declare const buildArtifactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
821
917
  description: z.ZodString;
822
918
  required: z.ZodDefault<z.ZodBoolean>;
823
919
  }, z.core.$strict>>>;
920
+ storage: z.ZodOptional<z.ZodObject<{
921
+ kv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
922
+ description: z.ZodString;
923
+ }, z.core.$strict>>>;
924
+ sql: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
925
+ description: z.ZodString;
926
+ migrations: z.ZodOptional<z.ZodString>;
927
+ }, z.core.$strict>>>;
928
+ }, z.core.$strict>>;
824
929
  }, z.core.$strict>>;
825
930
  assets: z.ZodArray<z.ZodObject<{
826
931
  path: z.ZodString;
@@ -846,6 +951,10 @@ declare const buildArtifactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
846
951
  transparent: "transparent";
847
952
  }>>;
848
953
  worker: z.ZodOptional<z.ZodObject<{
954
+ migrations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
955
+ name: z.ZodString;
956
+ sql: z.ZodString;
957
+ }, z.core.$strict>>>>;
849
958
  modules: z.ZodArray<z.ZodObject<{
850
959
  path: z.ZodString;
851
960
  type: z.ZodEnum<{
@@ -865,6 +974,15 @@ declare const buildArtifactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
865
974
  description: z.ZodString;
866
975
  required: z.ZodDefault<z.ZodBoolean>;
867
976
  }, z.core.$strict>>>;
977
+ storage: z.ZodOptional<z.ZodObject<{
978
+ kv: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
979
+ description: z.ZodString;
980
+ }, z.core.$strict>>>;
981
+ sql: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
982
+ description: z.ZodString;
983
+ migrations: z.ZodOptional<z.ZodString>;
984
+ }, z.core.$strict>>>;
985
+ }, z.core.$strict>>;
868
986
  }, z.core.$strict>>;
869
987
  assets: z.ZodArray<z.ZodObject<{
870
988
  path: z.ZodString;
@@ -39248,6 +39366,54 @@ declare function hostedManagementClient(env: HostedManagementEnv): {
39248
39366
  }>;
39249
39367
  delete: (name: string, call?: ManagementCallOptions) => Promise<void>;
39250
39368
  };
39369
+ storage: {
39370
+ list: (call?: ManagementCallOptions) => Promise<{
39371
+ stores: {
39372
+ kind: string;
39373
+ name: string;
39374
+ createdAt: number | null;
39375
+ declared: boolean;
39376
+ description?: string | undefined;
39377
+ }[];
39378
+ }>;
39379
+ tables: (name: string, call?: ManagementCallOptions) => Promise<{
39380
+ tables: {
39381
+ name: string;
39382
+ kind: string;
39383
+ }[];
39384
+ }>;
39385
+ rows: (name: string, table: string, options?: {
39386
+ offset?: number;
39387
+ }, call?: ManagementCallOptions) => Promise<{
39388
+ table: string;
39389
+ columns: string[];
39390
+ rows: (string | number | {
39391
+ text: string;
39392
+ truncated: true;
39393
+ } | {
39394
+ blob: number;
39395
+ } | null)[][];
39396
+ offset: number;
39397
+ total: number;
39398
+ }>;
39399
+ keys: (name: string, options?: {
39400
+ prefix?: string;
39401
+ cursor?: string;
39402
+ }, call?: ManagementCallOptions) => Promise<{
39403
+ keys: {
39404
+ name: string;
39405
+ expiration: number | null;
39406
+ }[];
39407
+ cursor: string | null;
39408
+ }>;
39409
+ value: (name: string, key: string, call?: ManagementCallOptions) => Promise<{
39410
+ key: string;
39411
+ size: number;
39412
+ text: string | null;
39413
+ truncated: boolean;
39414
+ }>;
39415
+ delete: (kind: AppStorageKind, name: string, call?: ManagementCallOptions) => Promise<void>;
39416
+ };
39251
39417
  walletBalanceChains: (call?: ManagementCallOptions) => Promise<{
39252
39418
  chains: {
39253
39419
  chain: `cosmos:${string}` | "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" | `eip155:${number}`;
@@ -42712,8 +42878,9 @@ type ManagementClientOptions = {
42712
42878
  type ManagementRawInit = RequestInit & {
42713
42879
  timeout?: number;
42714
42880
  };
42715
- type ManagementClient = Omit<ReturnType<typeof createManagementClient>, "testMembers"> & {
42881
+ type ManagementClient = Omit<ReturnType<typeof createManagementClient>, "testMembers" | "storage"> & {
42716
42882
  testMembers?: ReturnType<typeof createManagementClient>["testMembers"];
42883
+ storage?: ReturnType<typeof createManagementClient>["storage"];
42717
42884
  };
42718
42885
  declare function createManagementClient(options: ManagementClientOptions): {
42719
42886
  raw: (path: string, init?: ManagementRawInit) => Promise<Response>;
@@ -80983,6 +81150,64 @@ declare function createManagementClient(options: ManagementClientOptions): {
80983
81150
  }>;
80984
81151
  delete: (name: string, call?: ManagementCallOptions) => Promise<void>;
80985
81152
  };
81153
+ /**
81154
+ * The hosted app's KV and SQL stores in test. `list` needs `read`; reading their contents and
81155
+ * deleting a store need `publish`. Reads never change data, and only a store no serving build
81156
+ * declares can be deleted.
81157
+ */
81158
+ storage: {
81159
+ list: (call?: ManagementCallOptions) => Promise<{
81160
+ stores: {
81161
+ kind: string;
81162
+ name: string;
81163
+ createdAt: number | null;
81164
+ declared: boolean;
81165
+ description?: string | undefined;
81166
+ }[];
81167
+ }>;
81168
+ /** A SQL store's tables and views, without SQLite's and D1's own. */
81169
+ tables: (name: string, call?: ManagementCallOptions) => Promise<{
81170
+ tables: {
81171
+ name: string;
81172
+ kind: string;
81173
+ }[];
81174
+ }>;
81175
+ /** One page of 50 rows in the table's storage order, which rows changing in between can shift. */
81176
+ rows: (name: string, table: string, options?: {
81177
+ offset?: number;
81178
+ }, call?: ManagementCallOptions) => Promise<{
81179
+ table: string;
81180
+ columns: string[];
81181
+ rows: (string | number | {
81182
+ text: string;
81183
+ truncated: true;
81184
+ } | {
81185
+ blob: number;
81186
+ } | null)[][];
81187
+ offset: number;
81188
+ total: number;
81189
+ }>;
81190
+ /** One page of a KV store's keys; pass the returned `cursor` for the next. */
81191
+ keys: (name: string, options?: {
81192
+ prefix?: string;
81193
+ cursor?: string;
81194
+ }, call?: ManagementCallOptions) => Promise<{
81195
+ keys: {
81196
+ name: string;
81197
+ expiration: number | null;
81198
+ }[];
81199
+ cursor: string | null;
81200
+ }>;
81201
+ /** A KV value's size and, when it is UTF-8 text, a preview. */
81202
+ value: (name: string, key: string, call?: ManagementCallOptions) => Promise<{
81203
+ key: string;
81204
+ size: number;
81205
+ text: string | null;
81206
+ truncated: boolean;
81207
+ }>;
81208
+ /** Deletes a store no serving build declares, with all of its data. */
81209
+ delete: (kind: AppStorageKind, name: string, call?: ManagementCallOptions) => Promise<void>;
81210
+ };
80986
81211
  /**
80987
81212
  * The chains quest code can read token balances on with `ctx.wallet.balance()`, with their
80988
81213
  * names; requires `read` permission. Any other chain fails the evaluation.
@@ -81719,4 +81944,4 @@ declare function createManagementClient(options: ManagementClientOptions): {
81719
81944
  }>;
81720
81945
  };
81721
81946
 
81722
- export { APP_SECRET_LIMIT, type Access, type AppSecret, type AppSecretDeclaration, type AppSecretInput, type AppSecretList, type AuditRecord, type BalanceCheck, type BuildArtifacts, type BuildIdentity, type BuildSnapshot, type BuildStatus, type CompletionRevocation, type CompletionRevokeInput, DEFAULT_MANAGEMENT_TIMEOUT, type HostedAppSecrets, type HostedBuild, type HostedDeploymentKey, type HostedKey, type HostedKeyPermission, type HostedManagementEnv, type ListQuery, type ManagedMemberIdentity, type ManagedOAuthAccount, type ManagedResource, type ManagedWallet, type ManagementCallOptions, type ManagementClient, type ManagementClientOptions, ManagementError, ManagementErrorCode, type ManagementErrorInit, type ManagementErrorKind, type ManagementPage, type ManagementRawInit, type ParticipantSignIn, type ParticipantSignInInput, type Permission, type Person, type Project, type QuestLifecycle, type QuestLifecycleInput, type ResourceLifecycleInput, RevokedDeliveryOutcome, RevokedEntitlementOutcome, RevokedReferralOutcome, type StagedDeployment, type StagedDeploymentContent, type StagingAccess, type StagingAccessInput, type StagingLink, type StarterId, type StarterTemplate, type TestMember, type TestMemberActionInput, type TestMemberCreateInput, type TestMemberResetInput, type TestMemberResetResult, WEBHOOK_MAX_BYTES, type WalletBalanceChains, type WebhookEvent, accessSchema, accountProfileSchema, appRoutingSchema, appSecretDeclarationSchema, appSecretDeclarationsSchema, appSecretInputSchema, appSecretListSchema, appSecretNameSchema, appSecretSchema, appSecretValueSchema, assetPathSchema, auditRecordSchema, balanceCheckSchema, buildArtifactsSchema, buildIdentitySchema, buildPhaseSchema, buildSnapshotSchema, buildStatusSchema, commitSchema, completionRevocationSchema, completionRevokeSchema, createManagementClient, createRepositorySchema, developmentPreflightSchema, deviceApproveSchema, deviceRedeemSchema, deviceStartSchema, entitlementCorrectionSchema, environmentSchema, grantRecordSchema, grantSchema, hostedAppSchema, hostedAppSecretsSchema, hostedBuildSchema, hostedDeploymentKeySchema, hostedKeyPermissions, hostedKeySchema, hostedKeySecretSchema, hostedManagementBindings, hostedManagementClient, ingestTrackerScopeSchema, inventorySchema, isManagementError, issuedTokenSchema, managedMemberIdentitySchema, managedOAuthAccountSchema, managedResourceSchema, managedWalletSchema, memberAccountSchema, memberDetailSchema, memberIdentityChangeInputSchema, memberLookupSchema, memberOAuthUnlinkInputSchema, memberSchema, memberWalletSignInInputSchema, memberWalletUnlinkInputSchema, metricsSchema, operationInputSchema, operationSchema, pageSchema, participantSignInInputSchema, participantSignInSchema, permissionSchema, personSchema, projectDeletionInputSchema, projectDeletionSchema, projectInputSchema, projectSchema, projectSetupSchema, projectTransferInputSchema, projectTransferSchema, querySchema, questLifecycleInputSchema, questLifecycleSchema, readinessSchema, repositorySchema, resourceLifecycleInputSchema, resourceLifecycleKindSchema, resourceLifecycleResultSchema, rolePermissions, roleSchema, stageRequestSchema, stagedDeploymentContentSchema, stagedDeploymentKey, stagedDeploymentLimits, stagedDeploymentSchema, stagingAccessInputSchema, stagingAccessModeSchema, stagingAccessSchema, stagingLinkSchema, stagingPathSchema, starterIdSchema, starterTemplates, stockAdditionSchema, stockInputSchema, teamSchema, testMemberActionSchema, testMemberCreateSchema, testMemberResetResultSchema, testMemberResetSchema, testMemberSchema, tokenInputSchema, tokenSchema, tokenScopeInputSchema, verifiedPassSchema, verifyWebhook, walletBalanceChainsSchema, webhookDeliveryPageSchema, webhookDeliverySchema, webhookEndpointSchema, webhookEventSchema, webhookInputSchema, webhookQuerySchema, webhookSecretSchema, webhookUpdateSchema };
81947
+ export { APP_KV_LIMIT, APP_MIGRATION_FILE_BYTES, APP_MIGRATION_LIMIT, APP_MIGRATION_TOTAL_BYTES, APP_SECRET_LIMIT, APP_SQL_LIMIT, APP_STORAGE_PREVIEW_CHARACTERS, APP_STORAGE_ROW_LIMIT, type Access, type AppSecret, type AppSecretDeclaration, type AppSecretInput, type AppSecretList, type AppStorage, type AppStorageCell, type AppStorageKeys, type AppStorageKind, type AppStorageList, type AppStorageRows, type AppStorageTables, type AppStorageValue, type AuditRecord, type BalanceCheck, type BuildArtifacts, type BuildIdentity, type BuildSnapshot, type BuildStatus, type CompletionRevocation, type CompletionRevokeInput, DEFAULT_MANAGEMENT_TIMEOUT, type HostedAppSecrets, type HostedBuild, type HostedDeploymentKey, type HostedKey, type HostedKeyPermission, type HostedManagementEnv, type ListQuery, type ManagedMemberIdentity, type ManagedOAuthAccount, type ManagedResource, type ManagedWallet, type ManagementCallOptions, type ManagementClient, type ManagementClientOptions, ManagementError, ManagementErrorCode, type ManagementErrorInit, type ManagementErrorKind, type ManagementPage, type ManagementRawInit, type ParticipantSignIn, type ParticipantSignInInput, type Permission, type Person, type Project, type QuestLifecycle, type QuestLifecycleInput, type ResourceLifecycleInput, RevokedDeliveryOutcome, RevokedEntitlementOutcome, RevokedReferralOutcome, type StagedDeployment, type StagedDeploymentContent, type StagingAccess, type StagingAccessInput, type StagingLink, type StarterId, type StarterTemplate, type TestMember, type TestMemberActionInput, type TestMemberCreateInput, type TestMemberResetInput, type TestMemberResetResult, WEBHOOK_MAX_BYTES, type WalletBalanceChains, type WebhookEvent, accessSchema, accountProfileSchema, appMigrationNameSchema, appRoutingSchema, appSecretDeclarationSchema, appSecretDeclarationsSchema, appSecretInputSchema, appSecretListSchema, appSecretNameSchema, appSecretSchema, appSecretValueSchema, appStorageCellSchema, appStorageKeysSchema, appStorageKindSchema, appStorageListSchema, appStorageRowsSchema, appStorageSchema, appStorageTablesSchema, appStorageValueSchema, assetPathSchema, auditRecordSchema, balanceCheckSchema, buildArtifactsSchema, buildIdentitySchema, buildPhaseSchema, buildSnapshotSchema, buildStatusSchema, commitSchema, compareAppMigrations, completionRevocationSchema, completionRevokeSchema, createManagementClient, createRepositorySchema, developmentPreflightSchema, deviceApproveSchema, deviceRedeemSchema, deviceStartSchema, entitlementCorrectionSchema, environmentSchema, grantRecordSchema, grantSchema, hostedAppSchema, hostedAppSecretsSchema, hostedBuildSchema, hostedDeploymentKeySchema, hostedKeyPermissions, hostedKeySchema, hostedKeySecretSchema, hostedManagementBindings, hostedManagementClient, ingestTrackerScopeSchema, inventorySchema, isManagementError, issuedTokenSchema, managedMemberIdentitySchema, managedOAuthAccountSchema, managedResourceSchema, managedWalletSchema, memberAccountSchema, memberDetailSchema, memberIdentityChangeInputSchema, memberLookupSchema, memberOAuthUnlinkInputSchema, memberSchema, memberWalletSignInInputSchema, memberWalletUnlinkInputSchema, metricsSchema, operationInputSchema, operationSchema, pageSchema, participantSignInInputSchema, participantSignInSchema, permissionSchema, personSchema, projectDeletionInputSchema, projectDeletionSchema, projectInputSchema, projectSchema, projectSetupSchema, projectTransferInputSchema, projectTransferSchema, querySchema, questLifecycleInputSchema, questLifecycleSchema, readinessSchema, repositorySchema, resourceLifecycleInputSchema, resourceLifecycleKindSchema, resourceLifecycleResultSchema, rolePermissions, roleSchema, stageRequestSchema, stagedDeploymentContentSchema, stagedDeploymentKey, stagedDeploymentLimits, stagedDeploymentSchema, stagingAccessInputSchema, stagingAccessModeSchema, stagingAccessSchema, stagingLinkSchema, stagingPathSchema, starterIdSchema, starterTemplates, stockAdditionSchema, stockInputSchema, teamSchema, testMemberActionSchema, testMemberCreateSchema, testMemberResetResultSchema, testMemberResetSchema, testMemberSchema, tokenInputSchema, tokenSchema, tokenScopeInputSchema, verifiedPassSchema, verifyWebhook, walletBalanceChainsSchema, webhookDeliveryPageSchema, webhookDeliverySchema, webhookEndpointSchema, webhookEventSchema, webhookInputSchema, webhookQuerySchema, webhookSecretSchema, webhookUpdateSchema };
@@ -421,6 +421,11 @@ var outputPathSchema = z5.string().min(1).max(512).refine(
421
421
  );
422
422
  var appRoutingSchema = z5.enum(["legacy", "transparent"]).default("legacy");
423
423
  var APP_SECRET_LIMIT = 50;
424
+ var APP_KV_LIMIT = 5;
425
+ var APP_SQL_LIMIT = 5;
426
+ var APP_MIGRATION_LIMIT = 100;
427
+ var APP_MIGRATION_FILE_BYTES = 9e4;
428
+ var APP_MIGRATION_TOTAL_BYTES = 1e6;
424
429
  var appSecretNameSchema = z5.string().regex(
425
430
  /^[A-Z_][A-Z0-9_]{0,63}$/,
426
431
  "Use 1-64 uppercase letters, digits, and underscores, not starting with a digit"
@@ -451,6 +456,110 @@ var appSecretListSchema = z5.object({
451
456
  declared: z5.array(appSecretDeclarationSchema.extend({ name: appSecretNameSchema })).default([])
452
457
  });
453
458
  var hostedAppSecretsSchema = z5.object({ secrets: z5.record(appSecretNameSchema, appSecretValueSchema) }).strict();
459
+ var storageDescription = z5.object({
460
+ description: z5.string().trim().min(1).max(500)
461
+ }).strict();
462
+ var appStorageSchema = z5.object({
463
+ kv: z5.record(appSecretNameSchema, storageDescription).refine(
464
+ (stores) => Object.keys(stores).length <= APP_KV_LIMIT,
465
+ `Declare at most ${APP_KV_LIMIT} KV stores`
466
+ ).default({}),
467
+ sql: z5.record(
468
+ appSecretNameSchema,
469
+ storageDescription.extend({
470
+ migrations: outputPathSchema.optional()
471
+ }).strict()
472
+ ).refine(
473
+ (stores) => Object.keys(stores).length <= APP_SQL_LIMIT,
474
+ `Declare at most ${APP_SQL_LIMIT} SQL stores`
475
+ ).default({})
476
+ }).strict();
477
+ var appStorageKindSchema = z5.enum(["kv", "sql"]);
478
+ var appStorageListSchema = z5.object({
479
+ stores: z5.array(
480
+ z5.object({
481
+ kind: z5.string(),
482
+ name: appSecretNameSchema,
483
+ createdAt: z5.number().nullable(),
484
+ declared: z5.boolean(),
485
+ description: z5.string().optional()
486
+ })
487
+ )
488
+ });
489
+ var APP_STORAGE_ROW_LIMIT = 50;
490
+ var APP_STORAGE_PREVIEW_CHARACTERS = 2e3;
491
+ var appStorageCellSchema = z5.union([
492
+ z5.string(),
493
+ z5.number(),
494
+ z5.null(),
495
+ z5.object({ text: z5.string(), truncated: z5.literal(true) }),
496
+ z5.object({ blob: z5.number().int().min(0) })
497
+ ]);
498
+ var appStorageTablesSchema = z5.object({
499
+ tables: z5.array(
500
+ /** `kind` is SQLite's: `table` or `view`. */
501
+ z5.object({ name: z5.string(), kind: z5.string() })
502
+ )
503
+ });
504
+ var appStorageRowsSchema = z5.object({
505
+ table: z5.string(),
506
+ columns: z5.array(z5.string()),
507
+ rows: z5.array(z5.array(appStorageCellSchema)),
508
+ offset: z5.number().int().min(0),
509
+ total: z5.number().int().min(0)
510
+ });
511
+ var appStorageKeysSchema = z5.object({
512
+ keys: z5.array(
513
+ z5.object({ name: z5.string(), expiration: z5.number().nullable() })
514
+ ),
515
+ /** Pass back to read the next page; null on the last one. */
516
+ cursor: z5.string().nullable()
517
+ });
518
+ var appStorageValueSchema = z5.object({
519
+ key: z5.string(),
520
+ size: z5.number().int().min(0),
521
+ /** Null when the value is not UTF-8 text. */
522
+ text: z5.string().nullable(),
523
+ truncated: z5.boolean()
524
+ });
525
+ var appMigrationNameSchema = z5.string().max(255).regex(/^[\w-][\w.-]*\.sql$/);
526
+ function compareAppMigrations(a, b) {
527
+ const left = Number.parseInt(a.split("_")[0], 10);
528
+ const right = Number.parseInt(b.split("_")[0], 10);
529
+ if (left !== right) {
530
+ if (Number.isFinite(left) && Number.isFinite(right)) {
531
+ return left - right;
532
+ }
533
+ if (Number.isFinite(left)) {
534
+ return -1;
535
+ }
536
+ if (Number.isFinite(right)) {
537
+ return 1;
538
+ }
539
+ }
540
+ return a < b ? -1 : a > b ? 1 : 0;
541
+ }
542
+ var appMigrationsSchema = z5.record(
543
+ appSecretNameSchema,
544
+ z5.array(
545
+ z5.object({
546
+ name: appMigrationNameSchema,
547
+ sql: z5.string().min(1).refine(
548
+ (sql) => new TextEncoder().encode(sql).length <= APP_MIGRATION_FILE_BYTES,
549
+ `A migration file must not exceed ${APP_MIGRATION_FILE_BYTES} bytes`
550
+ )
551
+ }).strict()
552
+ ).max(APP_MIGRATION_LIMIT).refine(
553
+ (files) => new Set(files.map((file) => file.name)).size === files.length,
554
+ "Duplicate migration filenames"
555
+ )
556
+ ).refine(
557
+ (stores) => Object.values(stores).flat().reduce(
558
+ (total, file) => total + new TextEncoder().encode(file.sql).length,
559
+ 0
560
+ ) <= APP_MIGRATION_TOTAL_BYTES,
561
+ `Migrations must not exceed ${APP_MIGRATION_TOTAL_BYTES} bytes in total`
562
+ );
454
563
  var appScripts = {
455
564
  routing: appRoutingSchema,
456
565
  devScript: z5.string().regex(/^[\w:-]+$/),
@@ -469,12 +578,31 @@ var workerSettings = {
469
578
  z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).refine((name) => name !== "ASSETS"),
470
579
  z5.string()
471
580
  ).default({}),
472
- secrets: appSecretDeclarationsSchema.default({})
581
+ secrets: appSecretDeclarationsSchema.default({}),
582
+ storage: appStorageSchema.optional()
473
583
  };
474
- var distinctBindings = (worker) => !Object.keys(worker.secrets).some((name) => name in worker.vars);
475
- var distinctBindingsMessage = {
476
- message: "A name can't be both an app var and a declared secret",
477
- path: ["secrets"]
584
+ var distinctBindings = (worker, ctx) => {
585
+ const owners = /* @__PURE__ */ new Map();
586
+ const sources = [
587
+ ["vars", "an app var", Object.keys(worker.vars)],
588
+ ["secrets", "a declared secret", Object.keys(worker.secrets)],
589
+ ["storage", "a KV store", Object.keys(worker.storage?.kv ?? {})],
590
+ ["storage", "a SQL store", Object.keys(worker.storage?.sql ?? {})]
591
+ ];
592
+ for (const [path, owner, names] of sources) {
593
+ for (const name of names) {
594
+ const first = owners.get(name);
595
+ if (first) {
596
+ ctx.addIssue({
597
+ code: "custom",
598
+ message: `Binding name ${name} is used by both ${first} and ${owner}`,
599
+ path: [path]
600
+ });
601
+ } else {
602
+ owners.set(name, owner);
603
+ }
604
+ }
605
+ }
478
606
  };
479
607
  var hostedAppSchema = z5.discriminatedUnion("kind", [
480
608
  z5.object({
@@ -488,7 +616,7 @@ var hostedAppSchema = z5.discriminatedUnion("kind", [
488
616
  assetsDirectory: outputPathSchema.optional(),
489
617
  ...appScripts,
490
618
  ...workerSettings
491
- }).strict().refine(distinctBindings, distinctBindingsMessage)
619
+ }).strict().superRefine(distinctBindings)
492
620
  ]);
493
621
  var repositorySchema = z5.object({
494
622
  id: z5.string().uuid(),
@@ -602,6 +730,7 @@ var artifactFields = {
602
730
  routing: appRoutingSchema,
603
731
  worker: z5.object({
604
732
  ...workerSettings,
733
+ migrations: appMigrationsSchema.optional(),
605
734
  modules: z5.array(
606
735
  z5.object({
607
736
  path: outputPathSchema.refine((path) => path !== "metadata"),
@@ -614,7 +743,7 @@ var artifactFields = {
614
743
  content: base64Schema.max(14e6)
615
744
  }).strict()
616
745
  ).min(1).max(500)
617
- }).strict().refine(distinctBindings, distinctBindingsMessage).optional(),
746
+ }).strict().superRefine(distinctBindings).optional(),
618
747
  assets: z5.array(
619
748
  z5.object({
620
749
  path: assetPathSchema,
@@ -639,6 +768,14 @@ var buildArtifactsSchema = z5.discriminatedUnion("format", [
639
768
  ]).superRefine((value, ctx) => {
640
769
  if (value.worker) {
641
770
  const modules = value.worker.modules;
771
+ for (const name of Object.keys(value.worker.migrations ?? {})) {
772
+ if (!value.worker.storage?.sql[name]?.migrations) {
773
+ ctx.addIssue({
774
+ code: "custom",
775
+ message: `Migrations for undeclared SQL store ${name}`
776
+ });
777
+ }
778
+ }
642
779
  if (new Set(modules.map((m) => m.path)).size !== modules.length) {
643
780
  ctx.addIssue({
644
781
  code: "custom",
@@ -2270,6 +2407,49 @@ function createManagementClient(options) {
2270
2407
  });
2271
2408
  }
2272
2409
  },
2410
+ /**
2411
+ * The hosted app's KV and SQL stores in test. `list` needs `read`; reading their contents and
2412
+ * deleting a store need `publish`. Reads never change data, and only a store no serving build
2413
+ * declares can be deleted.
2414
+ */
2415
+ storage: {
2416
+ list: (call) => get("/storage", appStorageListSchema, call),
2417
+ /** A SQL store's tables and views, without SQLite's and D1's own. */
2418
+ tables: (name, call) => get(
2419
+ `/storage/sql/${appSecretNameSchema.parse(name)}/tables`,
2420
+ appStorageTablesSchema,
2421
+ call
2422
+ ),
2423
+ /** One page of 50 rows in the table's storage order, which rows changing in between can shift. */
2424
+ rows: (name, table, options2 = {}, call) => get(
2425
+ `/storage/sql/${appSecretNameSchema.parse(name)}/rows?${new URLSearchParams({ table, offset: String(options2.offset ?? 0) })}`,
2426
+ appStorageRowsSchema,
2427
+ call
2428
+ ),
2429
+ /** One page of a KV store's keys; pass the returned `cursor` for the next. */
2430
+ keys: (name, options2 = {}, call) => get(
2431
+ `/storage/kv/${appSecretNameSchema.parse(name)}/keys?${new URLSearchParams(
2432
+ Object.entries(options2).filter(
2433
+ (entry) => entry[1] !== void 0
2434
+ )
2435
+ )}`,
2436
+ appStorageKeysSchema,
2437
+ call
2438
+ ),
2439
+ /** A KV value's size and, when it is UTF-8 text, a preview. */
2440
+ value: (name, key, call) => get(
2441
+ `/storage/kv/${appSecretNameSchema.parse(name)}/value?${new URLSearchParams({ key })}`,
2442
+ appStorageValueSchema,
2443
+ call
2444
+ ),
2445
+ /** Deletes a store no serving build declares, with all of its data. */
2446
+ delete: async (kind, name, call) => {
2447
+ await raw(`/storage/${kind}/${appSecretNameSchema.parse(name)}`, {
2448
+ ...call,
2449
+ method: "DELETE"
2450
+ });
2451
+ }
2452
+ },
2273
2453
  /**
2274
2454
  * The chains quest code can read token balances on with `ctx.wallet.balance()`, with their
2275
2455
  * names; requires `read` permission. Any other chain fails the evaluation.
@@ -2437,7 +2617,14 @@ function createManagementClient(options) {
2437
2617
  });
2438
2618
  }
2439
2619
  export {
2620
+ APP_KV_LIMIT,
2621
+ APP_MIGRATION_FILE_BYTES,
2622
+ APP_MIGRATION_LIMIT,
2623
+ APP_MIGRATION_TOTAL_BYTES,
2440
2624
  APP_SECRET_LIMIT,
2625
+ APP_SQL_LIMIT,
2626
+ APP_STORAGE_PREVIEW_CHARACTERS,
2627
+ APP_STORAGE_ROW_LIMIT,
2441
2628
  DEFAULT_MANAGEMENT_TIMEOUT,
2442
2629
  ManagementError,
2443
2630
  ManagementErrorCode,
@@ -2449,6 +2636,7 @@ export {
2449
2636
  accountProfileSchema,
2450
2637
  activityTypeSchema,
2451
2638
  activityTypes,
2639
+ appMigrationNameSchema,
2452
2640
  appRoutingSchema,
2453
2641
  appSecretDeclarationSchema,
2454
2642
  appSecretDeclarationsSchema,
@@ -2457,6 +2645,14 @@ export {
2457
2645
  appSecretNameSchema,
2458
2646
  appSecretSchema,
2459
2647
  appSecretValueSchema,
2648
+ appStorageCellSchema,
2649
+ appStorageKeysSchema,
2650
+ appStorageKindSchema,
2651
+ appStorageListSchema,
2652
+ appStorageRowsSchema,
2653
+ appStorageSchema,
2654
+ appStorageTablesSchema,
2655
+ appStorageValueSchema,
2460
2656
  assetPathSchema,
2461
2657
  auditRecordSchema,
2462
2658
  balanceCheckSchema,
@@ -2466,6 +2662,7 @@ export {
2466
2662
  buildSnapshotSchema,
2467
2663
  buildStatusSchema,
2468
2664
  commitSchema,
2665
+ compareAppMigrations,
2469
2666
  completionRevocationSchema,
2470
2667
  completionRevokeSchema,
2471
2668
  createManagementClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domino-sdk/relay",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {