New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@casual-simulation/aux-records

Package Overview
Dependencies
Maintainers
2
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@casual-simulation/aux-records - npm Package Compare versions

Comparing version 3.2.2-alpha.5675659631 to 3.2.2-alpha.5685728183

AIGenerateSkyboxInterface.d.ts

58

AIController.d.ts
import { InvalidSubscriptionTierError, NotLoggedInError, NotSubscribedError, NotSupportedError, ServerError } from './Errors';
import { AIChatInterface, AIChatMessage } from './AIChatInterface';
import { AIGenerateSkyboxInterface, AIGenerateSkyboxInterfaceBlockadeLabsOptions } from './AIGenerateSkyboxInterface';
export interface AIConfiguration {
chat: AIChatConfiguration | null;
generateSkybox: AIGenerateSkyboxConfiguration | null;
}

@@ -21,5 +23,21 @@ export interface AIChatConfiguration {

* The list of subscription tiers that are allowed to be used for chat.
*
* - `true` indicates that all users are allowed, regardless of their subscription tier or if they are even subscribed.
* - An array of strings indicates that only users with the given subscription tiers are allowed.
*/
allowedChatSubscriptionTiers: true | string[];
}
export interface AIGenerateSkyboxConfiguration {
interface: AIGenerateSkyboxInterface;
options: AIGenerateSkyboxOptions;
}
export interface AIGenerateSkyboxOptions {
/**
* The list of subscription tiers that are allowed to be used for generate skybox.
*
* - `true` indicates that all users are allowed, regardless of their subscription tier or if they are even subscribed.
* - An array of strings indicates that only users with the given subscription tiers are allowed.
*/
allowedSubscriptionTiers: true | string[];
}
/**

@@ -31,6 +49,10 @@ * Defines a class that is able to handle AI requests.

private _chatOptions;
private _generateSkybox;
private _allowedChatModels;
private _allowedChatSubscriptionTiers;
private _allowedGenerateSkyboxSubscriptionTiers;
constructor(configuration: AIConfiguration);
chat(request: AIChatRequest): Promise<AIChatResponse>;
generateSkybox(request: AIGenerateSkyboxRequest): Promise<AIGenerateSkyboxResponse>;
private _matchesSubscriptionTiers;
}

@@ -97,2 +119,38 @@ /**

}
export interface AIGenerateSkyboxRequest {
/**
* The prompt that should be used to generate the skybox.
*/
prompt: string;
/**
* The ID of the user that is currently logged in.
*/
userId: string;
/**
* The subscription tier of the user.
* Should be null if the user is not logged in or if they do not have a subscription.
*/
userSubscriptionTier: string;
/**
* The negative prompt for the skybox.
*/
negativePrompt?: string;
/**
* Options specific to blockade labs.
*/
blockadeLabs?: AIGenerateSkyboxInterfaceBlockadeLabsOptions;
}
export type AIGenerateSkyboxResponse = AIGenerateSkyboxSuccess | AIGenerateSkyboxFailure;
export interface AIGenerateSkyboxSuccess {
success: true;
fileUrl: string;
thumbnailUrl: string;
}
export interface AIGenerateSkyboxFailure {
success: false;
errorCode: ServerError | NotLoggedInError | NotSubscribedError | InvalidSubscriptionTierError | NotSupportedError;
errorMessage: string;
allowedSubscriptionTiers?: string[];
currentSubscriptionTier?: string;
}
//# sourceMappingURL=AIController.d.ts.map

88

AIController.js

@@ -26,2 +26,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
if (configuration.generateSkybox) {
this._generateSkybox = configuration.generateSkybox.interface;
const options = configuration.generateSkybox.options;
this._allowedGenerateSkyboxSubscriptionTiers =
typeof options.allowedSubscriptionTiers === 'boolean'
? options.allowedSubscriptionTiers
: new Set(options.allowedSubscriptionTiers);
}
}

@@ -46,4 +54,3 @@ chat(request) {

}
if (this._allowedChatSubscriptionTiers !== true &&
!this._allowedChatSubscriptionTiers.has(request.userSubscriptionTier)) {
if (!this._matchesSubscriptionTiers(request.userSubscriptionTier, this._allowedChatSubscriptionTiers)) {
if (!request.userSubscriptionTier) {

@@ -55,3 +62,4 @@ return {

allowedSubscriptionTiers: [
...this._allowedChatSubscriptionTiers,
...this
._allowedChatSubscriptionTiers,
],

@@ -66,3 +74,4 @@ };

allowedSubscriptionTiers: [
...this._allowedChatSubscriptionTiers,
...this
._allowedChatSubscriptionTiers,
],

@@ -106,3 +115,74 @@ currentSubscriptionTier: request.userSubscriptionTier,

}
generateSkybox(request) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (!this._generateSkybox) {
return {
success: false,
errorCode: 'not_supported',
errorMessage: 'This operation is not supported.',
};
}
if (!request.userId) {
return {
success: false,
errorCode: 'not_logged_in',
errorMessage: 'The user must be logged in. Please provide a sessionKey or a recordKey.',
};
}
if (!this._matchesSubscriptionTiers(request.userSubscriptionTier, this._allowedGenerateSkyboxSubscriptionTiers)) {
if (!request.userSubscriptionTier) {
return {
success: false,
errorCode: 'not_subscribed',
errorMessage: 'The user must be subscribed in order to use this operation.',
allowedSubscriptionTiers: [
...this
._allowedGenerateSkyboxSubscriptionTiers,
],
};
}
else {
return {
success: false,
errorCode: 'invalid_subscription_tier',
errorMessage: 'This operation is not available to the user at their current subscription tier.',
allowedSubscriptionTiers: [
...this
._allowedGenerateSkyboxSubscriptionTiers,
],
currentSubscriptionTier: request.userSubscriptionTier,
};
}
}
const result = yield this._generateSkybox.generateSkybox({
prompt: request.prompt,
negativePrompt: request.negativePrompt,
blockadeLabs: request.blockadeLabs,
});
if (result.success === true) {
return {
success: true,
fileUrl: result.fileUrl,
thumbnailUrl: result.thumbnailUrl,
};
}
else {
return result;
}
}
catch (err) {
console.error('[AIController] Error handling generate skybox request:', err);
return {
success: false,
errorCode: 'server_error',
errorMessage: 'A server error occurred.',
};
}
});
}
_matchesSubscriptionTiers(tier, allowedTiers) {
return allowedTiers === true || allowedTiers.has(tier);
}
}
//# sourceMappingURL=AIController.js.map

@@ -27,2 +27,4 @@ export * from './AuthController';

export * from './OpenAIChatInterface';
export * from './AIGenerateSkyboxInterface';
export * from './BlockadeLabsGenerateSkyboxInterface';
//# sourceMappingURL=index.d.ts.map

@@ -27,2 +27,4 @@ export * from './AuthController';

export * from './OpenAIChatInterface';
export * from './AIGenerateSkyboxInterface';
export * from './BlockadeLabsGenerateSkyboxInterface';
//# sourceMappingURL=index.js.map

4

package.json
{
"name": "@casual-simulation/aux-records",
"version": "3.2.2-alpha.5675659631",
"version": "3.2.2-alpha.5685728183",
"description": "Helpers and managers used by the CasualOS records system.",

@@ -47,3 +47,3 @@ "keywords": [],

},
"gitHead": "11752fc6d7af2882a30999a71e5baa86fa3b5c4b"
"gitHead": "cf7f0341f31d208cd3dd4d1c95f4a11917eea22a"
}

@@ -120,2 +120,3 @@ import { AuthController } from './AuthController';

private _aiChat;
private _aiSkybox;
private _listData;

@@ -122,0 +123,0 @@ private _handleRecordFileOptions;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc