playcademy 0.14.3 → 0.14.4-alpha.2
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/constants.d.ts +61 -1
- package/dist/constants.js +148 -0
- package/dist/db.js +118 -0
- package/dist/edge-play/src/entry/middleware.ts +102 -5
- package/dist/edge-play/src/entry/session.ts +44 -0
- package/dist/edge-play/src/entry.ts +33 -1
- package/dist/edge-play/src/index.ts +3 -1
- package/dist/edge-play/src/register-routes.ts +0 -4
- package/dist/edge-play/src/types.ts +7 -5
- package/dist/index.d.ts +122 -90
- package/dist/index.js +2663 -1751
- package/dist/templates/api/sample-protected.ts.template +34 -0
- package/dist/templates/auth/auth-catch-all.ts.template +18 -0
- package/dist/templates/auth/auth-schema.ts.template +62 -0
- package/dist/templates/auth/auth.ts.template +55 -0
- package/dist/templates/config/integrations-config.js.template +1 -1
- package/dist/templates/playcademy-env.d.ts.template +12 -3
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +764 -1028
- package/dist/version.d.ts +3 -0
- package/dist/version.js +82 -0
- package/package.json +10 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { UserInfo, ApiKey
|
|
1
|
+
import { UserInfo, ApiKey } from '@playcademy/data/types';
|
|
2
2
|
import { SchemaInfo } from '@playcademy/cloudflare';
|
|
3
3
|
import { OrganizationConfig, CourseConfig, ComponentConfig, ResourceConfig, ComponentResourceConfig } from '@playcademy/timeback/types';
|
|
4
4
|
export { ComponentConfig, ComponentResourceConfig, CourseConfig, DerivedComponentConfig, DerivedComponentResourceConfig, DerivedCourseConfig, DerivedOrganizationConfig, DerivedResourceConfig, DerivedTimebackConfig, OrganizationConfig, ResourceConfig, TimebackGrade, TimebackSourcedIds, TimebackSubject } from '@playcademy/timeback/types';
|
|
5
5
|
import { PlaycademyClient } from '@playcademy/sdk';
|
|
6
6
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Authentication strategies for Better Auth integration
|
|
10
|
+
*/
|
|
11
|
+
type AuthStrategy = 'email' | 'github' | 'google' | 'platform';
|
|
8
12
|
/**
|
|
9
13
|
* Type of authentication token
|
|
10
14
|
* Duplicated from SDK to avoid circular dependency
|
|
@@ -288,6 +292,8 @@ interface IntegrationsConfig {
|
|
|
288
292
|
kv?: boolean;
|
|
289
293
|
/** Bucket storage (optional) */
|
|
290
294
|
bucket?: boolean;
|
|
295
|
+
/** Authentication (optional) */
|
|
296
|
+
auth?: boolean;
|
|
291
297
|
}
|
|
292
298
|
/**
|
|
293
299
|
* Unified Playcademy configuration
|
|
@@ -459,8 +465,8 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
459
465
|
identity: undefined;
|
|
460
466
|
generated: undefined;
|
|
461
467
|
}, {}, {}>;
|
|
462
|
-
|
|
463
|
-
name: "
|
|
468
|
+
deploymentUrl: drizzle_orm_pg_core.PgColumn<{
|
|
469
|
+
name: "deployment_url";
|
|
464
470
|
tableName: "games";
|
|
465
471
|
dataType: "string";
|
|
466
472
|
columnType: "PgText";
|
|
@@ -584,19 +590,82 @@ declare const games: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
|
584
590
|
dialect: "pg";
|
|
585
591
|
}>;
|
|
586
592
|
type GameRow = typeof games.$inferSelect;
|
|
587
|
-
type BaseGame = Omit<GameRow, 'gameType' | '
|
|
593
|
+
type BaseGame = Omit<GameRow, 'gameType' | 'deploymentUrl' | 'externalUrl'>;
|
|
588
594
|
type HostedGame = BaseGame & {
|
|
589
595
|
gameType: 'hosted';
|
|
590
|
-
|
|
596
|
+
deploymentUrl: string;
|
|
591
597
|
externalUrl: null;
|
|
592
598
|
};
|
|
593
599
|
type ExternalGame = BaseGame & {
|
|
594
600
|
gameType: 'external';
|
|
595
|
-
|
|
601
|
+
deploymentUrl: null;
|
|
596
602
|
externalUrl: string;
|
|
597
603
|
};
|
|
598
604
|
type Game = HostedGame | ExternalGame;
|
|
599
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Integration-related types
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Database integration scaffold options
|
|
612
|
+
*/
|
|
613
|
+
interface DatabaseIntegrationOptions {
|
|
614
|
+
/** Directory for database files (e.g., 'db') */
|
|
615
|
+
directory: string;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Custom API routes integration scaffold options
|
|
619
|
+
*/
|
|
620
|
+
interface CustomRoutesIntegrationOptions {
|
|
621
|
+
/** Directory for custom routes (e.g., 'server/api') */
|
|
622
|
+
directory: string;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Represents a change in integration configuration
|
|
626
|
+
*/
|
|
627
|
+
interface IntegrationConfigChange {
|
|
628
|
+
/** Human-readable label for the change */
|
|
629
|
+
label: string;
|
|
630
|
+
/** Current value */
|
|
631
|
+
current: string;
|
|
632
|
+
/** New value */
|
|
633
|
+
next: string;
|
|
634
|
+
/** Field path (e.g., 'course.title') */
|
|
635
|
+
field: string;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Interface for integration change detectors
|
|
639
|
+
* Each integration can implement this to detect configuration changes
|
|
640
|
+
*/
|
|
641
|
+
interface IntegrationChangeDetector<TConfig = unknown> {
|
|
642
|
+
/**
|
|
643
|
+
* Detect changes between current and new configuration
|
|
644
|
+
* @param currentConfig - Currently deployed integration config
|
|
645
|
+
* @param newConfig - New integration config from local file
|
|
646
|
+
* @returns Array of detected changes
|
|
647
|
+
*/
|
|
648
|
+
detectChanges(currentConfig: TConfig, newConfig: TConfig): IntegrationConfigChange[];
|
|
649
|
+
/**
|
|
650
|
+
* Handle configuration changes
|
|
651
|
+
* Called automatically during deployment when metadata has changed
|
|
652
|
+
* Implementation should: fetch current config, detect changes, update if needed
|
|
653
|
+
*
|
|
654
|
+
* @param gameId - The game ID
|
|
655
|
+
* @param client - Playcademy API client
|
|
656
|
+
* @param localConfig - Full local PlaycademyConfig
|
|
657
|
+
* @param verbose - Verbose logging flag
|
|
658
|
+
*/
|
|
659
|
+
onConfigChange?(gameId: string, client: PlaycademyClient, localConfig: unknown, verbose?: boolean): Promise<void>;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Registry of integration change detectors
|
|
663
|
+
* Maps to the same keys as IntegrationsConfig from SDK
|
|
664
|
+
*/
|
|
665
|
+
type IntegrationChangeDetectors = {
|
|
666
|
+
[K in keyof IntegrationsConfig]: IntegrationChangeDetector;
|
|
667
|
+
};
|
|
668
|
+
|
|
600
669
|
/**
|
|
601
670
|
* Deployed game tracking - maps project directories to game IDs
|
|
602
671
|
*/
|
|
@@ -618,25 +687,6 @@ interface DeployedGameInfo {
|
|
|
618
687
|
interface GameStore {
|
|
619
688
|
[projectPath: string]: DeployedGameInfo;
|
|
620
689
|
}
|
|
621
|
-
/**
|
|
622
|
-
* Backend deployment response with code hash for change detection
|
|
623
|
-
*/
|
|
624
|
-
interface BackendDeploymentWithHash extends BackendDeploymentResponse {
|
|
625
|
-
/** SHA-256 hash of the custom routes directory */
|
|
626
|
-
customRoutesHash: string | null;
|
|
627
|
-
/** Size of custom routes source files in bytes */
|
|
628
|
-
customRoutesSize: number | null;
|
|
629
|
-
/** Size of the deployed backend bundle in bytes */
|
|
630
|
-
backendSize: number;
|
|
631
|
-
/** Drizzle schema JSON snapshot */
|
|
632
|
-
schemaSnapshot?: unknown;
|
|
633
|
-
/** List of enabled integration keys (e.g., ['timeback', 'auth']) */
|
|
634
|
-
integrationKeys: string[];
|
|
635
|
-
/** Hash of integrations config (for detecting metadata changes) */
|
|
636
|
-
integrationsHash: string | null;
|
|
637
|
-
/** Secret keys that have been deployed */
|
|
638
|
-
deployedSecrets?: string[];
|
|
639
|
-
}
|
|
640
690
|
/**
|
|
641
691
|
* Deployment context containing all information needed for deployment
|
|
642
692
|
*/
|
|
@@ -674,6 +724,10 @@ interface DeploymentChanges {
|
|
|
674
724
|
backend: boolean | undefined;
|
|
675
725
|
customRoutes: boolean | undefined;
|
|
676
726
|
integrations: boolean | undefined;
|
|
727
|
+
integrationsMetadata?: Array<{
|
|
728
|
+
name: string;
|
|
729
|
+
changes: IntegrationConfigChange[];
|
|
730
|
+
}>;
|
|
677
731
|
schema?: boolean;
|
|
678
732
|
secrets?: boolean;
|
|
679
733
|
}
|
|
@@ -689,12 +743,34 @@ interface DeploymentPlan {
|
|
|
689
743
|
currentCustomRoutesSize?: number;
|
|
690
744
|
currentBackendSize?: number;
|
|
691
745
|
}
|
|
746
|
+
/**
|
|
747
|
+
* Backend deployment metadata for tracking changes
|
|
748
|
+
* This is what we need to save for next deployment's change detection
|
|
749
|
+
*/
|
|
750
|
+
interface BackendDeploymentMetadata {
|
|
751
|
+
/** SHA-256 hash of the custom routes directory */
|
|
752
|
+
customRoutesHash: string | null;
|
|
753
|
+
/** Size of custom routes source files in bytes */
|
|
754
|
+
customRoutesSize: number | null;
|
|
755
|
+
/** Size of the deployed backend bundle in bytes */
|
|
756
|
+
backendSize: number;
|
|
757
|
+
/** Drizzle schema JSON snapshot */
|
|
758
|
+
schemaSnapshot?: unknown;
|
|
759
|
+
/** List of enabled integration keys (e.g., ['timeback', 'auth']) */
|
|
760
|
+
integrationKeys: string[];
|
|
761
|
+
/** Hash of integrations config (for detecting metadata changes) */
|
|
762
|
+
integrationsHash: string | null;
|
|
763
|
+
/** Secret keys that have been deployed */
|
|
764
|
+
deployedSecrets?: string[];
|
|
765
|
+
/** When this backend was deployed */
|
|
766
|
+
deployedAt: string;
|
|
767
|
+
}
|
|
692
768
|
/**
|
|
693
769
|
* Result of a deployment
|
|
694
770
|
*/
|
|
695
771
|
interface DeploymentResult {
|
|
696
772
|
game: Game;
|
|
697
|
-
|
|
773
|
+
backendMetadata?: BackendDeploymentMetadata;
|
|
698
774
|
}
|
|
699
775
|
/**
|
|
700
776
|
* Deployment configuration
|
|
@@ -783,6 +859,14 @@ interface EmbeddedSourcePaths {
|
|
|
783
859
|
cliNodeModules: string;
|
|
784
860
|
}
|
|
785
861
|
|
|
862
|
+
/**
|
|
863
|
+
* Logger interface for embedding in other tools (e.g., vite plugin)
|
|
864
|
+
*/
|
|
865
|
+
interface PluginLogger {
|
|
866
|
+
info: (msg: string) => void;
|
|
867
|
+
warn: (msg: string) => void;
|
|
868
|
+
error: (msg: string) => void;
|
|
869
|
+
}
|
|
786
870
|
interface DevServerOptions {
|
|
787
871
|
port: number;
|
|
788
872
|
/** Playcademy config. If not provided, will attempt to load from playcademy.config.js */
|
|
@@ -797,6 +881,8 @@ interface DevServerOptions {
|
|
|
797
881
|
onReload?: (restart: () => Promise<void>) => void;
|
|
798
882
|
/** URL for Playcademy platform/sandbox API (defaults to localhost:5174 platform) */
|
|
799
883
|
platformUrl?: string;
|
|
884
|
+
/** Custom logger for embedding (e.g., from vite plugin) */
|
|
885
|
+
customLogger?: PluginLogger;
|
|
800
886
|
}
|
|
801
887
|
|
|
802
888
|
/**
|
|
@@ -852,69 +938,6 @@ interface PreviewResponse {
|
|
|
852
938
|
qrCode?: string;
|
|
853
939
|
}
|
|
854
940
|
|
|
855
|
-
/**
|
|
856
|
-
* Integration-related types
|
|
857
|
-
*/
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* Database integration scaffold options
|
|
861
|
-
*/
|
|
862
|
-
interface DatabaseIntegrationOptions {
|
|
863
|
-
/** Directory for database files (e.g., 'db') */
|
|
864
|
-
directory: string;
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Custom API routes integration scaffold options
|
|
868
|
-
*/
|
|
869
|
-
interface CustomRoutesIntegrationOptions {
|
|
870
|
-
/** Directory for custom routes (e.g., 'server/api') */
|
|
871
|
-
directory: string;
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Represents a change in integration configuration
|
|
875
|
-
*/
|
|
876
|
-
interface IntegrationConfigChange {
|
|
877
|
-
/** Human-readable label for the change */
|
|
878
|
-
label: string;
|
|
879
|
-
/** Current value */
|
|
880
|
-
current: string;
|
|
881
|
-
/** New value */
|
|
882
|
-
next: string;
|
|
883
|
-
/** Field path (e.g., 'course.title') */
|
|
884
|
-
field: string;
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Interface for integration change detectors
|
|
888
|
-
* Each integration can implement this to detect configuration changes
|
|
889
|
-
*/
|
|
890
|
-
interface IntegrationChangeDetector<TConfig = unknown> {
|
|
891
|
-
/**
|
|
892
|
-
* Detect changes between current and new configuration
|
|
893
|
-
* @param currentConfig - Currently deployed integration config
|
|
894
|
-
* @param newConfig - New integration config from local file
|
|
895
|
-
* @returns Array of detected changes
|
|
896
|
-
*/
|
|
897
|
-
detectChanges(currentConfig: TConfig, newConfig: TConfig): IntegrationConfigChange[];
|
|
898
|
-
/**
|
|
899
|
-
* Handle configuration changes
|
|
900
|
-
* Called automatically during deployment when metadata has changed
|
|
901
|
-
* Implementation should: fetch current config, detect changes, update if needed
|
|
902
|
-
*
|
|
903
|
-
* @param gameId - The game ID
|
|
904
|
-
* @param client - Playcademy API client
|
|
905
|
-
* @param localConfig - Full local PlaycademyConfig
|
|
906
|
-
* @param verbose - Verbose logging flag
|
|
907
|
-
*/
|
|
908
|
-
onConfigChange?(gameId: string, client: PlaycademyClient, localConfig: unknown, verbose?: boolean): Promise<void>;
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* Registry of integration change detectors
|
|
912
|
-
* Maps to the same keys as IntegrationsConfig from SDK
|
|
913
|
-
*/
|
|
914
|
-
type IntegrationChangeDetectors = {
|
|
915
|
-
[K in keyof IntegrationsConfig]: IntegrationChangeDetector;
|
|
916
|
-
};
|
|
917
|
-
|
|
918
941
|
/**
|
|
919
942
|
* Configuration differences between existing and new game state
|
|
920
943
|
*/
|
|
@@ -967,6 +990,15 @@ interface BackendDiff {
|
|
|
967
990
|
interface IntegrationsDiff {
|
|
968
991
|
previousKeys?: string[];
|
|
969
992
|
currentKeys?: string[];
|
|
993
|
+
metadata?: Array<{
|
|
994
|
+
name: string;
|
|
995
|
+
changes: Array<{
|
|
996
|
+
label: string;
|
|
997
|
+
current: string;
|
|
998
|
+
next: string;
|
|
999
|
+
field: string;
|
|
1000
|
+
}>;
|
|
1001
|
+
}>;
|
|
970
1002
|
}
|
|
971
1003
|
/**
|
|
972
1004
|
* Secret changes
|
|
@@ -1022,4 +1054,4 @@ interface KeyMetadata {
|
|
|
1022
1054
|
valueType?: 'json' | 'string';
|
|
1023
1055
|
}
|
|
1024
1056
|
|
|
1025
|
-
export type { ApiConfig, ApiErrorResponse, ApiKeyListItem, ApiKeyWithSecret, ApiRequestOptions, AuthProfile, AuthStore, BackendBundle,
|
|
1057
|
+
export type { ApiConfig, ApiErrorResponse, ApiKeyListItem, ApiKeyWithSecret, ApiRequestOptions, AuthProfile, AuthStore, AuthStrategy, BackendBundle, BackendDeploymentMetadata, BackendDiff, BackendFeatures, BucketBulkOptions, BucketDeleteOptions, BucketGetOptions, BucketListOptions, BucketPutOptions, BuildDiff, BulkCollectionResult, BundleOptions, CallbackServerResult, CollectedFile, ConfigDiff, CreateApiKeyResponse, CustomRoutesIntegrationOptions, DatabaseIntegrationOptions, DeployConfig, DeployNewGameOptions, DeployedGameInfo, DeploymentChanges, DeploymentContext, DeploymentDiffOptions, DeploymentPlan, DeploymentResult, DevServerOptions, EmbeddedSourcePaths, EnvironmentAuthProfiles, GameStore, IntegrationChangeDetector, IntegrationChangeDetectors, IntegrationConfigChange, IntegrationsConfig, IntegrationsDiff, KeyMetadata, KeyStats, LoginCredentials, LoginResponse, PlaycademyConfig, PluginLogger, PreviewOptions, PreviewResponse, SecretsDiff, SignInResponse, SsoCallbackData, TimebackIntegrationConfig, TokenType, UpdateExistingGameOptions };
|