@squidcloud/cli 1.0.449 → 1.0.450
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.js
CHANGED
|
@@ -29656,6 +29656,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
29656
29656
|
exports.OPEN_AI_CREATE_SPEECH_FORMATS = exports.AI_AUDIO_CREATE_SPEECH_MODEL_NAMES = exports.AI_AUDIO_TRANSCRIPTION_MODEL_NAMES = exports.AI_IMAGE_MODEL_NAMES = exports.FLUX_MODEL_NAMES = exports.STABLE_DIFFUSION_MODEL_NAMES = exports.OPENAI_AUDIO_MODEL_NAMES = exports.OPENAI_AUDIO_CREATE_SPEECH_MODEL_NAMES = exports.OPENAI_AUDIO_TRANSCRIPTION_MODEL_NAMES = exports.OPENAI_IMAGE_MODEL_NAMES = exports.AI_EMBEDDINGS_MODEL_NAMES = exports.BEDROCK_EMBEDDING_MODEL_NAMES = exports.VOYAGE_EMBEDDING_MODEL_NAMES = exports.OPENAI_EMBEDDINGS_MODEL_NAMES = exports.VENDOR_AI_CHAT_MODEL_NAMES = exports.ANTHROPIC_CHAT_MODEL_NAMES = exports.GROK_CHAT_MODEL_NAMES = exports.GEMINI_CHAT_MODEL_NAMES = exports.OPENAI_CHAT_MODEL_NAMES = exports.AI_PROVIDER_TYPES = exports.RERANK_PROVIDERS = void 0;
|
|
29657
29657
|
exports.isVendorAiChatModelName = isVendorAiChatModelName;
|
|
29658
29658
|
exports.isAiEmbeddingsModelName = isAiEmbeddingsModelName;
|
|
29659
|
+
exports.isIntegrationEmbeddingModelSpec = isIntegrationEmbeddingModelSpec;
|
|
29659
29660
|
exports.isIntegrationModelSpec = isIntegrationModelSpec;
|
|
29660
29661
|
/**
|
|
29661
29662
|
* @category AI
|
|
@@ -29742,6 +29743,13 @@ exports.AI_EMBEDDINGS_MODEL_NAMES = [
|
|
|
29742
29743
|
function isAiEmbeddingsModelName(modelName) {
|
|
29743
29744
|
return exports.AI_EMBEDDINGS_MODEL_NAMES.includes(modelName);
|
|
29744
29745
|
}
|
|
29746
|
+
/**
|
|
29747
|
+
* Type guard for `IntegrationEmbeddingModelSpec`.
|
|
29748
|
+
* @category AI
|
|
29749
|
+
*/
|
|
29750
|
+
function isIntegrationEmbeddingModelSpec(model) {
|
|
29751
|
+
return (typeof model === 'object' && model !== null && 'integrationId' in model && 'model' in model && 'dimensions' in model);
|
|
29752
|
+
}
|
|
29745
29753
|
/**
|
|
29746
29754
|
* The supported AI image generation model names.
|
|
29747
29755
|
* @category AI
|
|
@@ -29893,6 +29901,7 @@ exports.INTEGRATION_TYPES = [
|
|
|
29893
29901
|
'legend',
|
|
29894
29902
|
'teams',
|
|
29895
29903
|
'openai_compatible',
|
|
29904
|
+
'openai_compatible_embedding',
|
|
29896
29905
|
];
|
|
29897
29906
|
/**
|
|
29898
29907
|
* @category Database
|
|
@@ -30325,7 +30334,11 @@ function isSquidDebugEnabledByDefault() {
|
|
|
30325
30334
|
}
|
|
30326
30335
|
return param === '1' || param === 'true';
|
|
30327
30336
|
}
|
|
30328
|
-
|
|
30337
|
+
// Auto-initialize debug flag only if not explicitly set already.
|
|
30338
|
+
// This prevents bundled code from overriding the flag set by the host application.
|
|
30339
|
+
if (getGlobal()?.['SQUID_LOG_DEBUG_ENABLED'] === undefined) {
|
|
30340
|
+
enableDebugLogs(isSquidDebugEnabledByDefault());
|
|
30341
|
+
}
|
|
30329
30342
|
/** @internal */
|
|
30330
30343
|
function disableTimestampsInLog() {
|
|
30331
30344
|
const globalObj = getGlobal();
|
|
@@ -31236,6 +31249,7 @@ const process_env_utils_1 = __webpack_require__(9360);
|
|
|
31236
31249
|
const resolve_1 = __webpack_require__(412);
|
|
31237
31250
|
const tsoa_utils_1 = __webpack_require__(1431);
|
|
31238
31251
|
const packageJson = __importStar(__webpack_require__(8330));
|
|
31252
|
+
const update_skills_1 = __webpack_require__(7286);
|
|
31239
31253
|
const logging_1 = __webpack_require__(443);
|
|
31240
31254
|
const process_utils_1 = __webpack_require__(8251);
|
|
31241
31255
|
const resolve_2 = __webpack_require__(3878);
|
|
@@ -31247,15 +31261,6 @@ const version_check_1 = __webpack_require__(4827);
|
|
|
31247
31261
|
// - Default: colors only if TTY (stdout is a terminal).
|
|
31248
31262
|
const isTerminal = process.stdout.isTTY;
|
|
31249
31263
|
const useColorsInOutput = (0, process_env_utils_1.isEnvVarTruthy)('FORCE_COLOR') || (!(0, process_env_utils_1.isEnvVarTruthy)('NO_COLOR') && isTerminal);
|
|
31250
|
-
async function displayVersionWarning(versionCheckPromise) {
|
|
31251
|
-
try {
|
|
31252
|
-
const versionWarning = await versionCheckPromise;
|
|
31253
|
-
if (versionWarning) {
|
|
31254
|
-
console.warn(versionWarning);
|
|
31255
|
-
}
|
|
31256
|
-
}
|
|
31257
|
-
catch (_ignored) { }
|
|
31258
|
-
}
|
|
31259
31264
|
async function build({ verbose, dev, skipVersionCheck }) {
|
|
31260
31265
|
const buildPhaseStart = Date.now();
|
|
31261
31266
|
(0, global_utils_1.enableDebugLogs)(verbose || (0, global_utils_1.isDebugEnabled)());
|
|
@@ -31276,7 +31281,7 @@ async function build({ verbose, dev, skipVersionCheck }) {
|
|
|
31276
31281
|
const isSquidConnector = (0, process_env_utils_1.isEnvVarTruthy)('SQUID_CONNECTOR');
|
|
31277
31282
|
const specsStart = Date.now();
|
|
31278
31283
|
const openApiSpecAndControllers = await tsoa_utils_1.TsoaUtils.generateAllSpecs(verbose, !isSquidConnector);
|
|
31279
|
-
console.debug((0, log_utils_1.timeSince)(specsStart, '
|
|
31284
|
+
console.debug((0, log_utils_1.timeSince)(specsStart, 'OpenAPI specs generation time '));
|
|
31280
31285
|
await fs_1.promises.writeFile(path_1.default.join(distPath, '', 'openapi-spec-and-controllers.json'), JSON.stringify(openApiSpecAndControllers));
|
|
31281
31286
|
const isUserConfigMode = fsSync.existsSync(resolve_2.USER_WEBPACK_CONFIG_PATH);
|
|
31282
31287
|
const webpackConfigPath = isUserConfigMode ? resolve_2.USER_WEBPACK_CONFIG_PATH : resolve_2.BUILT_IN_WEBPACK_CONFIG_PATH;
|
|
@@ -31291,7 +31296,7 @@ async function build({ verbose, dev, skipVersionCheck }) {
|
|
|
31291
31296
|
await new Promise((resolve, reject) => {
|
|
31292
31297
|
(0, webpack_1.default)(webpackConfig, (err, stats) => {
|
|
31293
31298
|
if (err) {
|
|
31294
|
-
console.debug((0, log_utils_1.timeSince)(webpackStart, '
|
|
31299
|
+
console.debug((0, log_utils_1.timeSince)(webpackStart, 'Webpack build time '));
|
|
31295
31300
|
console.error('Build failed a fatal error.');
|
|
31296
31301
|
return reject(err);
|
|
31297
31302
|
}
|
|
@@ -31308,10 +31313,10 @@ async function build({ verbose, dev, skipVersionCheck }) {
|
|
|
31308
31313
|
}));
|
|
31309
31314
|
}
|
|
31310
31315
|
if (stats?.hasErrors()) {
|
|
31311
|
-
console.debug((0, log_utils_1.timeSince)(webpackStart, '
|
|
31316
|
+
console.debug((0, log_utils_1.timeSince)(webpackStart, 'Webpack build time '));
|
|
31312
31317
|
return reject(new Error('Build failed with errors.'));
|
|
31313
31318
|
}
|
|
31314
|
-
console.debug((0, log_utils_1.timeSince)(webpackStart, '
|
|
31319
|
+
console.debug((0, log_utils_1.timeSince)(webpackStart, 'Webpack build time '));
|
|
31315
31320
|
console.log('Build succeeded.');
|
|
31316
31321
|
resolve();
|
|
31317
31322
|
});
|
|
@@ -31321,21 +31326,25 @@ async function build({ verbose, dev, skipVersionCheck }) {
|
|
|
31321
31326
|
console.debug('Generating connector metadata...');
|
|
31322
31327
|
const metadataStart = Date.now();
|
|
31323
31328
|
await generateConnectorMetadata(distPath);
|
|
31324
|
-
console.debug((0, log_utils_1.timeSince)(metadataStart, '
|
|
31329
|
+
console.debug((0, log_utils_1.timeSince)(metadataStart, 'Connector metadata generation time '));
|
|
31325
31330
|
// Add metadata to bundle.zip.
|
|
31331
|
+
const metadataBundleStart = Date.now();
|
|
31326
31332
|
const zipPath = path_1.default.join(distPath, 'bundle.zip');
|
|
31327
31333
|
const zip = new adm_zip_1.default(zipPath);
|
|
31328
31334
|
zip.addLocalFile(path_1.default.join(distPath, connector_types_1.CONNECTOR_METADATA_JSON_FILE));
|
|
31329
31335
|
zip.writeZip(zipPath);
|
|
31330
31336
|
console.debug('Added connector metadata to bundle.zip');
|
|
31337
|
+
console.debug((0, log_utils_1.timeSince)(metadataBundleStart, 'Connector metadata bundling time '));
|
|
31331
31338
|
}
|
|
31332
31339
|
// Show version check warning after successful build.
|
|
31333
|
-
await
|
|
31334
|
-
|
|
31340
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
31341
|
+
(0, update_skills_1.displaySkillsWarningIfOutdated)();
|
|
31342
|
+
console.debug((0, log_utils_1.timeSince)(buildPhaseStart, 'Build time '));
|
|
31335
31343
|
}
|
|
31336
31344
|
catch (e) {
|
|
31337
31345
|
// Show a version check warning even if the build failed.
|
|
31338
|
-
await
|
|
31346
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
31347
|
+
(0, update_skills_1.displaySkillsWarningIfOutdated)();
|
|
31339
31348
|
const errorMessage = (0, assertic_1.getMessageFromError)(e);
|
|
31340
31349
|
console.debug(`Exiting with error: ${errorMessage}`);
|
|
31341
31350
|
(0, process_utils_1.exitWithError)(errorMessage);
|
|
@@ -31443,11 +31452,14 @@ const enable_debug_decorator_utils_1 = __webpack_require__(8700);
|
|
|
31443
31452
|
const global_utils_1 = __webpack_require__(6334);
|
|
31444
31453
|
const http_1 = __webpack_require__(866);
|
|
31445
31454
|
const shell_runner_1 = __webpack_require__(3089);
|
|
31455
|
+
const packageJson = __importStar(__webpack_require__(8330));
|
|
31446
31456
|
const environment_1 = __webpack_require__(722);
|
|
31447
31457
|
const process_utils_1 = __webpack_require__(8251);
|
|
31458
|
+
const version_check_1 = __webpack_require__(4827);
|
|
31448
31459
|
async function deploy(consoleRegion, appId, bundlePath, apiKey, verbose, direct, isUserSpecifiedPath, skipBuild, internalApiKey, environmentId) {
|
|
31449
31460
|
(0, global_utils_1.enableDebugLogs)(verbose || (0, global_utils_1.isDebugEnabled)());
|
|
31450
31461
|
(0, logpipes_1.installConsoleOverrides)(enable_debug_decorator_utils_1.debugLogFilterPipe);
|
|
31462
|
+
const versionCheckPromise = (0, version_check_1.checkCliVersion)(packageJson.version);
|
|
31451
31463
|
if (!direct && !isUserSpecifiedPath && !skipBuild) {
|
|
31452
31464
|
console.log('Building code bundle...');
|
|
31453
31465
|
await (0, shell_runner_1.runInShell)('npm run build');
|
|
@@ -31477,8 +31489,10 @@ async function deploy(consoleRegion, appId, bundlePath, apiKey, verbose, direct,
|
|
|
31477
31489
|
(0, process_utils_1.exitWithError)('Unable to deploy bundle:', await response.text());
|
|
31478
31490
|
}
|
|
31479
31491
|
console.log('Code deployed');
|
|
31492
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
31480
31493
|
}
|
|
31481
31494
|
catch (error) {
|
|
31495
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
31482
31496
|
console.debug('Error deploying bundle:', error);
|
|
31483
31497
|
const errorMessage = (0, assertic_1.getMessageFromError)(error, '');
|
|
31484
31498
|
(0, process_utils_1.exitWithError)('Unable to deploy bundle:', errorMessage || error);
|
|
@@ -31690,6 +31704,7 @@ const init_webpack_1 = __webpack_require__(1134);
|
|
|
31690
31704
|
const sample_1 = __webpack_require__(4328);
|
|
31691
31705
|
const start_1 = __webpack_require__(496);
|
|
31692
31706
|
const undeploy_1 = __webpack_require__(7097);
|
|
31707
|
+
const update_skills_1 = __webpack_require__(7286);
|
|
31693
31708
|
const process_utils_1 = __webpack_require__(8251);
|
|
31694
31709
|
const validate_1 = __webpack_require__(2246);
|
|
31695
31710
|
function setupDotEnv(baseDir) {
|
|
@@ -31714,6 +31729,7 @@ function run() {
|
|
|
31714
31729
|
setupInitWebpackCommand(yargs_1.default);
|
|
31715
31730
|
setupStartCommand(yargs_1.default);
|
|
31716
31731
|
setupUndeployCommand(yargs_1.default);
|
|
31732
|
+
setupUpdateSkillsCommand(yargs_1.default);
|
|
31717
31733
|
yargs_1.default.parse();
|
|
31718
31734
|
}
|
|
31719
31735
|
function setupStartCommand(yargs) {
|
|
@@ -31844,6 +31860,11 @@ function setupBuildCommand(yargs) {
|
|
|
31844
31860
|
await (0, build_1.build)({ verbose: !!argv.verbose, dev: !!argv.dev, skipVersionCheck: !!argv['skip-version-check'] });
|
|
31845
31861
|
});
|
|
31846
31862
|
}
|
|
31863
|
+
function setupUpdateSkillsCommand(yargs) {
|
|
31864
|
+
yargs.command('update-skills', 'Updates Squid Claude skills to the latest version', () => { }, async () => {
|
|
31865
|
+
await (0, update_skills_1.updateSkills)();
|
|
31866
|
+
});
|
|
31867
|
+
}
|
|
31847
31868
|
run();
|
|
31848
31869
|
function attachAppIdOption(yargs, demandOption) {
|
|
31849
31870
|
yargs.option('appId', {
|
|
@@ -31973,6 +31994,39 @@ function getConsoleRegionFromAppRegion(appRegion) {
|
|
|
31973
31994
|
|
|
31974
31995
|
"use strict";
|
|
31975
31996
|
|
|
31997
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
31998
|
+
if (k2 === undefined) k2 = k;
|
|
31999
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32000
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32001
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
32002
|
+
}
|
|
32003
|
+
Object.defineProperty(o, k2, desc);
|
|
32004
|
+
}) : (function(o, m, k, k2) {
|
|
32005
|
+
if (k2 === undefined) k2 = k;
|
|
32006
|
+
o[k2] = m[k];
|
|
32007
|
+
}));
|
|
32008
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32009
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32010
|
+
}) : function(o, v) {
|
|
32011
|
+
o["default"] = v;
|
|
32012
|
+
});
|
|
32013
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32014
|
+
var ownKeys = function(o) {
|
|
32015
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32016
|
+
var ar = [];
|
|
32017
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32018
|
+
return ar;
|
|
32019
|
+
};
|
|
32020
|
+
return ownKeys(o);
|
|
32021
|
+
};
|
|
32022
|
+
return function (mod) {
|
|
32023
|
+
if (mod && mod.__esModule) return mod;
|
|
32024
|
+
var result = {};
|
|
32025
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32026
|
+
__setModuleDefault(result, mod);
|
|
32027
|
+
return result;
|
|
32028
|
+
};
|
|
32029
|
+
})();
|
|
31976
32030
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31977
32031
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31978
32032
|
};
|
|
@@ -31987,14 +32041,18 @@ const utils_1 = __webpack_require__(1215);
|
|
|
31987
32041
|
const enable_debug_decorator_utils_1 = __webpack_require__(8700);
|
|
31988
32042
|
const global_utils_1 = __webpack_require__(6334);
|
|
31989
32043
|
const shell_runner_1 = __webpack_require__(3089);
|
|
32044
|
+
const packageJson = __importStar(__webpack_require__(8330));
|
|
32045
|
+
const update_skills_1 = __webpack_require__(7286);
|
|
31990
32046
|
const git_utils_1 = __webpack_require__(954);
|
|
31991
32047
|
const logging_1 = __webpack_require__(443);
|
|
31992
32048
|
const process_utils_1 = __webpack_require__(8251);
|
|
31993
32049
|
const report_utils_1 = __webpack_require__(3066);
|
|
32050
|
+
const version_check_1 = __webpack_require__(4827);
|
|
31994
32051
|
const ORG = 'squid-cloud-samples';
|
|
31995
32052
|
async function initSample(consoleRegion, isOnPremConsole, dirPath, appId, apiKey, environmentId, squidDeveloperId, region, templateName, verbose = false) {
|
|
31996
32053
|
(0, global_utils_1.enableDebugLogs)(verbose || (0, global_utils_1.isDebugEnabled)());
|
|
31997
32054
|
(0, logpipes_1.installConsoleOverrides)(enable_debug_decorator_utils_1.debugLogFilterPipe);
|
|
32055
|
+
const versionCheckPromise = (0, version_check_1.checkCliVersion)(packageJson.version);
|
|
31998
32056
|
try {
|
|
31999
32057
|
await promises_1.default.stat(path_1.default.resolve(dirPath));
|
|
32000
32058
|
(0, process_utils_1.exitWithError)(`Project already exists: ${dirPath}`);
|
|
@@ -32014,42 +32072,25 @@ async function initSample(consoleRegion, isOnPremConsole, dirPath, appId, apiKey
|
|
|
32014
32072
|
catch {
|
|
32015
32073
|
(0, process_utils_1.exitWithError)(`Unable to download repository: ${templateRepoPath}`);
|
|
32016
32074
|
}
|
|
32017
|
-
// Copy
|
|
32075
|
+
// Copy Squid skills if they don't already exist.
|
|
32018
32076
|
const projectPath = path_1.default.resolve(dirPath);
|
|
32019
32077
|
const skillsDir = path_1.default.join(projectPath, '.claude', 'skills');
|
|
32020
|
-
const
|
|
32021
|
-
|
|
32022
|
-
|
|
32023
|
-
|
|
32024
|
-
|
|
32025
|
-
else {
|
|
32026
|
-
// Skill doesn't exist, copy it.
|
|
32027
|
-
try {
|
|
32028
|
-
await promises_1.default.mkdir(skillsDir, { recursive: true });
|
|
32029
|
-
await promises_1.default.cp(squidSkillSourcePath, squidSkillDestPath, { recursive: true });
|
|
32030
|
-
console.debug('Squid development skill copied successfully');
|
|
32031
|
-
}
|
|
32032
|
-
catch (error) {
|
|
32033
|
-
// Non-fatal: log the error but continue with initialization.
|
|
32034
|
-
console.debug(`Warning: Could not copy Squid development skill: ${(0, assertic_1.getMessageFromError)(error)}`);
|
|
32035
|
-
}
|
|
32036
|
-
}
|
|
32037
|
-
// Copy the squid-react-development skill if it doesn't already exist.
|
|
32038
|
-
const reactSkillSourcePath = path_1.default.join(__dirname, 'resources', 'claude', 'skills', 'squid-react-development');
|
|
32039
|
-
const reactSkillDestPath = path_1.default.join(skillsDir, 'squid-react-development');
|
|
32040
|
-
if (await (0, utils_1.checkFileOrDirExists)(reactSkillDestPath)) {
|
|
32041
|
-
console.debug('Squid React development skill already exists, skipping...');
|
|
32042
|
-
}
|
|
32043
|
-
else {
|
|
32044
|
-
// Skill doesn't exist, copy it.
|
|
32045
|
-
try {
|
|
32046
|
-
await promises_1.default.mkdir(skillsDir, { recursive: true });
|
|
32047
|
-
await promises_1.default.cp(reactSkillSourcePath, reactSkillDestPath, { recursive: true });
|
|
32048
|
-
console.debug('Squid React development skill copied successfully');
|
|
32078
|
+
for (const skillName of update_skills_1.SQUID_SKILLS) {
|
|
32079
|
+
const sourcePath = path_1.default.join(__dirname, 'resources', 'claude', 'skills', skillName);
|
|
32080
|
+
const destPath = path_1.default.join(skillsDir, skillName);
|
|
32081
|
+
if (await (0, utils_1.checkFileOrDirExists)(destPath)) {
|
|
32082
|
+
console.debug(`${skillName} skill already exists, skipping...`);
|
|
32049
32083
|
}
|
|
32050
|
-
|
|
32051
|
-
|
|
32052
|
-
|
|
32084
|
+
else {
|
|
32085
|
+
try {
|
|
32086
|
+
await promises_1.default.mkdir(skillsDir, { recursive: true });
|
|
32087
|
+
await promises_1.default.cp(sourcePath, destPath, { recursive: true });
|
|
32088
|
+
console.debug(`${skillName} skill copied successfully`);
|
|
32089
|
+
}
|
|
32090
|
+
catch (error) {
|
|
32091
|
+
// Non-fatal: log the error but continue with initialization.
|
|
32092
|
+
console.debug(`Warning: Could not copy ${skillName} skill: ${(0, assertic_1.getMessageFromError)(error)}`);
|
|
32093
|
+
}
|
|
32053
32094
|
}
|
|
32054
32095
|
}
|
|
32055
32096
|
console.log('Installing dependencies...');
|
|
@@ -32112,6 +32153,7 @@ ${(0, logging_1.primary)('Done. Next steps:')}
|
|
|
32112
32153
|
npm run start
|
|
32113
32154
|
`);
|
|
32114
32155
|
}
|
|
32156
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
32115
32157
|
}
|
|
32116
32158
|
|
|
32117
32159
|
|
|
@@ -32164,12 +32206,18 @@ const fs = __importStar(__webpack_require__(1943));
|
|
|
32164
32206
|
const path_1 = __importDefault(__webpack_require__(6928));
|
|
32165
32207
|
const resolve_1 = __webpack_require__(412);
|
|
32166
32208
|
const shell_runner_1 = __webpack_require__(3089);
|
|
32209
|
+
const cliPackageJson = __importStar(__webpack_require__(8330));
|
|
32210
|
+
const update_skills_1 = __webpack_require__(7286);
|
|
32167
32211
|
const logging_1 = __webpack_require__(443);
|
|
32168
32212
|
const process_utils_1 = __webpack_require__(8251);
|
|
32169
32213
|
const validate_1 = __webpack_require__(2246);
|
|
32214
|
+
const version_check_1 = __webpack_require__(4827);
|
|
32170
32215
|
async function start() {
|
|
32171
32216
|
const packageJson = await (0, validate_1.validateSquidProject)();
|
|
32217
|
+
const versionCheckPromise = (0, version_check_1.checkCliVersion)(cliPackageJson.version);
|
|
32172
32218
|
console.log((0, logging_1.primary)('Please note:'), 'to debug your application, you need to run the "start" npm script in your IDE in debug mode');
|
|
32219
|
+
await (0, version_check_1.displayVersionWarningIfOutdated)(versionCheckPromise);
|
|
32220
|
+
(0, update_skills_1.displaySkillsWarningIfOutdated)();
|
|
32173
32221
|
console.log((0, logging_1.primary)('Starting...'));
|
|
32174
32222
|
const modulePath = await (0, resolve_1.findModulePath)('@squidcloud/local-backend');
|
|
32175
32223
|
if (!modulePath) {
|
|
@@ -32250,6 +32298,149 @@ async function undeploy(consoleRegion, appId, apiKey, environmentId) {
|
|
|
32250
32298
|
}
|
|
32251
32299
|
|
|
32252
32300
|
|
|
32301
|
+
/***/ },
|
|
32302
|
+
|
|
32303
|
+
/***/ 7286
|
|
32304
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
32305
|
+
|
|
32306
|
+
"use strict";
|
|
32307
|
+
|
|
32308
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
32309
|
+
if (k2 === undefined) k2 = k;
|
|
32310
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32311
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32312
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
32313
|
+
}
|
|
32314
|
+
Object.defineProperty(o, k2, desc);
|
|
32315
|
+
}) : (function(o, m, k, k2) {
|
|
32316
|
+
if (k2 === undefined) k2 = k;
|
|
32317
|
+
o[k2] = m[k];
|
|
32318
|
+
}));
|
|
32319
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32320
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32321
|
+
}) : function(o, v) {
|
|
32322
|
+
o["default"] = v;
|
|
32323
|
+
});
|
|
32324
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32325
|
+
var ownKeys = function(o) {
|
|
32326
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32327
|
+
var ar = [];
|
|
32328
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32329
|
+
return ar;
|
|
32330
|
+
};
|
|
32331
|
+
return ownKeys(o);
|
|
32332
|
+
};
|
|
32333
|
+
return function (mod) {
|
|
32334
|
+
if (mod && mod.__esModule) return mod;
|
|
32335
|
+
var result = {};
|
|
32336
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32337
|
+
__setModuleDefault(result, mod);
|
|
32338
|
+
return result;
|
|
32339
|
+
};
|
|
32340
|
+
})();
|
|
32341
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32342
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32343
|
+
};
|
|
32344
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
32345
|
+
exports.SQUID_SKILLS = void 0;
|
|
32346
|
+
exports.getSkillsNeedingUpdate = getSkillsNeedingUpdate;
|
|
32347
|
+
exports.displaySkillsWarningIfOutdated = displaySkillsWarningIfOutdated;
|
|
32348
|
+
exports.updateSkills = updateSkills;
|
|
32349
|
+
const chalk_1 = __importDefault(__webpack_require__(7459));
|
|
32350
|
+
const fsSync = __importStar(__webpack_require__(9896));
|
|
32351
|
+
const fs = __importStar(__webpack_require__(1943));
|
|
32352
|
+
const path_1 = __importDefault(__webpack_require__(6928));
|
|
32353
|
+
const logging_1 = __webpack_require__(443);
|
|
32354
|
+
const validate_1 = __webpack_require__(2246);
|
|
32355
|
+
/** List of Squid-owned skills that can be copied/updated. */
|
|
32356
|
+
exports.SQUID_SKILLS = ['squid-development', 'squid-react-development'];
|
|
32357
|
+
/**
|
|
32358
|
+
* Gets all files in a directory, sorted for consistent ordering.
|
|
32359
|
+
*/
|
|
32360
|
+
function getFilesSorted(dir) {
|
|
32361
|
+
const files = fsSync.readdirSync(dir, { recursive: true });
|
|
32362
|
+
return files.filter(file => fsSync.statSync(path_1.default.join(dir, file)).isFile()).sort();
|
|
32363
|
+
}
|
|
32364
|
+
/**
|
|
32365
|
+
* Checks if a specific skill needs to be updated.
|
|
32366
|
+
* Returns true if project is missing skill or any CLI file is missing/different.
|
|
32367
|
+
* Extra files in project are ignored
|
|
32368
|
+
*/
|
|
32369
|
+
function skillNeedsUpdate(skillName) {
|
|
32370
|
+
const projectSkillPath = path_1.default.join(process.cwd(), '.claude', 'skills', skillName);
|
|
32371
|
+
const cliSkillPath = path_1.default.join(__dirname, 'resources', 'claude', 'skills', skillName);
|
|
32372
|
+
// If CLI doesn't have this skill bundled, nothing to update.
|
|
32373
|
+
if (!fsSync.existsSync(cliSkillPath)) {
|
|
32374
|
+
return false;
|
|
32375
|
+
}
|
|
32376
|
+
// If project doesn't have this skill but CLI does, it needs to be added.
|
|
32377
|
+
if (!fsSync.existsSync(projectSkillPath)) {
|
|
32378
|
+
return true;
|
|
32379
|
+
}
|
|
32380
|
+
// Check each CLI file exists in project with same content.
|
|
32381
|
+
const cliFiles = getFilesSorted(cliSkillPath);
|
|
32382
|
+
for (const file of cliFiles) {
|
|
32383
|
+
const cliFilePath = path_1.default.join(cliSkillPath, file);
|
|
32384
|
+
const projectFilePath = path_1.default.join(projectSkillPath, file);
|
|
32385
|
+
// Project missing a file that CLI has.
|
|
32386
|
+
if (!fsSync.existsSync(projectFilePath)) {
|
|
32387
|
+
return true;
|
|
32388
|
+
}
|
|
32389
|
+
// Content differs (normalize line endings for cross-platform compatibility).
|
|
32390
|
+
const cliContent = fsSync.readFileSync(cliFilePath, 'utf8').replace(/\r\n/g, '\n');
|
|
32391
|
+
const projectContent = fsSync.readFileSync(projectFilePath, 'utf8').replace(/\r\n/g, '\n');
|
|
32392
|
+
if (cliContent !== projectContent) {
|
|
32393
|
+
return true;
|
|
32394
|
+
}
|
|
32395
|
+
}
|
|
32396
|
+
return false;
|
|
32397
|
+
}
|
|
32398
|
+
/**
|
|
32399
|
+
* Returns a list of skills that need to be updated (missing or outdated).
|
|
32400
|
+
*/
|
|
32401
|
+
function getSkillsNeedingUpdate() {
|
|
32402
|
+
return exports.SQUID_SKILLS.filter(skillNeedsUpdate);
|
|
32403
|
+
}
|
|
32404
|
+
function displaySkillsWarningIfOutdated() {
|
|
32405
|
+
try {
|
|
32406
|
+
const skillsToUpdate = getSkillsNeedingUpdate();
|
|
32407
|
+
if (skillsToUpdate.length > 0) {
|
|
32408
|
+
console.warn(chalk_1.default.yellow(`⚠ Squid skills need updating (${skillsToUpdate.join(', ')}). Run: squid update-skills`));
|
|
32409
|
+
}
|
|
32410
|
+
}
|
|
32411
|
+
catch (_ignored) { }
|
|
32412
|
+
}
|
|
32413
|
+
/**
|
|
32414
|
+
* Updates all Squid-owned skills to the latest version bundled with the CLI.
|
|
32415
|
+
*/
|
|
32416
|
+
async function updateSkills() {
|
|
32417
|
+
await (0, validate_1.validateSquidProject)();
|
|
32418
|
+
const skillsToUpdate = getSkillsNeedingUpdate();
|
|
32419
|
+
if (skillsToUpdate.length === 0) {
|
|
32420
|
+
console.log(chalk_1.default.green('✓ Skills already up to date'));
|
|
32421
|
+
return;
|
|
32422
|
+
}
|
|
32423
|
+
const skillsDir = path_1.default.join(process.cwd(), '.claude', 'skills');
|
|
32424
|
+
let updatedCount = 0;
|
|
32425
|
+
for (const skillName of skillsToUpdate) {
|
|
32426
|
+
const cliSkillPath = path_1.default.join(__dirname, 'resources', 'claude', 'skills', skillName);
|
|
32427
|
+
const projectSkillPath = path_1.default.join(skillsDir, skillName);
|
|
32428
|
+
try {
|
|
32429
|
+
await fs.mkdir(skillsDir, { recursive: true });
|
|
32430
|
+
await fs.cp(cliSkillPath, projectSkillPath, { recursive: true });
|
|
32431
|
+
console.log(`Updated ${(0, logging_1.primary)(skillName)} skill`);
|
|
32432
|
+
updatedCount++;
|
|
32433
|
+
}
|
|
32434
|
+
catch (_error) {
|
|
32435
|
+
console.warn(`Warning: Could not update ${skillName} skill`);
|
|
32436
|
+
}
|
|
32437
|
+
}
|
|
32438
|
+
if (updatedCount > 0) {
|
|
32439
|
+
console.log(chalk_1.default.green(`✓ ${updatedCount} skill(s) updated successfully`));
|
|
32440
|
+
}
|
|
32441
|
+
}
|
|
32442
|
+
|
|
32443
|
+
|
|
32253
32444
|
/***/ },
|
|
32254
32445
|
|
|
32255
32446
|
/***/ 954
|
|
@@ -32505,6 +32696,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32505
32696
|
};
|
|
32506
32697
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
32507
32698
|
exports.checkCliVersion = checkCliVersion;
|
|
32699
|
+
exports.displayVersionWarningIfOutdated = displayVersionWarningIfOutdated;
|
|
32508
32700
|
const assertic_1 = __webpack_require__(3205);
|
|
32509
32701
|
const chalk_1 = __importDefault(__webpack_require__(7459));
|
|
32510
32702
|
const time_units_1 = __webpack_require__(1929);
|
|
@@ -32581,6 +32773,15 @@ function parseVersion(version) {
|
|
|
32581
32773
|
function formatWarningMessage(currentVersion, latestVersion) {
|
|
32582
32774
|
return chalk_1.default.yellow(`⚠ Your @squidcloud/cli (${currentVersion}) is outdated. Latest: ${latestVersion}. Update: npm install -g @squidcloud/cli@latest`);
|
|
32583
32775
|
}
|
|
32776
|
+
async function displayVersionWarningIfOutdated(versionCheckPromise) {
|
|
32777
|
+
try {
|
|
32778
|
+
const versionWarning = await versionCheckPromise;
|
|
32779
|
+
if (versionWarning) {
|
|
32780
|
+
console.warn(versionWarning);
|
|
32781
|
+
}
|
|
32782
|
+
}
|
|
32783
|
+
catch (_ignored) { }
|
|
32784
|
+
}
|
|
32584
32785
|
|
|
32585
32786
|
|
|
32586
32787
|
/***/ },
|
|
@@ -36937,7 +37138,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"seek-bzip","version":"1.0.6",
|
|
|
36937
37138
|
(module) {
|
|
36938
37139
|
|
|
36939
37140
|
"use strict";
|
|
36940
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.
|
|
37141
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@squidcloud/cli","version":"1.0.450","description":"The Squid CLI","main":"dist/index.js","scripts":{"start":"node dist/index.js","start-ts":"ts-node -r tsconfig-paths/register src/index.ts","prebuild":"rimraf dist","build":"webpack --mode=production","build:dev":"webpack --mode=development","lint":"eslint","link":"npm run build && chmod 755 dist/index.js && npm link","watch":"webpack --watch","deploy":"npm run build && npm pack --silent | xargs -I {} mv {} package.tgz && npm install -g package.tgz && rm -rf package.tgz","publish:public":"npm run build && npm publish --access public"},"files":["dist/**/*"],"bin":{"squid":"dist/index.js"},"keywords":[],"author":"","license":"ISC","engines":{"node":">=18.0.0"},"dependencies":{"@squidcloud/local-backend":"^1.0.450","adm-zip":"^0.5.16","copy-webpack-plugin":"^12.0.2","decompress":"^4.2.1","logpipes":"^1.11.0","nodemon":"^3.1.9","terser-webpack-plugin":"^5.3.10","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsconfig-paths":"^4.2.0","tsconfig-paths-webpack-plugin":"^4.1.0","webpack":"^5.101.3","zip-webpack-plugin":"^4.0.1"},"devDependencies":{"@types/adm-zip":"^0.5.7","@types/decompress":"^4.2.7","@types/node":"^20.19.9","terminal-link":"^3.0.0"}}');
|
|
36941
37142
|
|
|
36942
37143
|
/***/ }
|
|
36943
37144
|
|
|
@@ -18,7 +18,7 @@ Squid is a backend-as-a-service platform that provides:
|
|
|
18
18
|
- **[client.md](reference/client.md)** → client SDK, initialization, setup, auth, login, tokens, OAuth, appId, region, environmentId, apiKey, authProvider, getToken, setAuthProvider, Squid client, frontend, collection, executeFunction, executeFunctionWithHeaders, getWebhookUrl, externalAuth, saveAuthCode, getAccessToken, storage, uploadFile, downloadUrl, queues, produce, consume, distributed locks, acquireLock, withLock, web, aiSearch, getUrlContent, createShortUrl, jobs, getJob, awaitJob, observability, metrics, reportMetric, queryMetrics, notifications, publishNotification, observeNotifications
|
|
19
19
|
- **[console.md](reference/console.md)** → Squid Console, web UI, organizations, applications, AI Studio, knowledge bases, integrations, monitoring, logs, API keys, secrets, testing, debugging, profile settings, management API keys
|
|
20
20
|
- **[ai.md](reference/ai.md)** → AI agents, chat, ask, askWithAnnotations, askAsync, askWithVoiceResponse, transcribeAndChat, transcribeAndAsk, knowledge bases, RAG, embeddings, image generation, audio, transcription, text-to-speech, TTS, connectedAgents, connectedIntegrations, connectedKnowledgeBases, @aiFunction, @secureAiAgent, @secureAiQuery, memory, memoryOptions, voiceOptions, OpenAI, Anthropic, Gemini, Grok, DALL-E, Whisper, MCP, @mcpServer, @mcpTool, executeAiQuery, executeAiApiCall, extraction, createPdf, upsert agent, listAgents
|
|
21
|
-
- **[databases.md](reference/databases.md)** → collections, documents, queries, subscriptions, snapshots, insert, update, delete, CRUD, real-time, dereference, pagination, transactions, query operators, eq, neq, gt, gte, lt, lte, like, in, nin, arrayIncludesSome, arrayIncludesAll, sortBy, limit, join queries, OR queries, @trigger, native queries, SQL, MongoDB, Elasticsearch, incrementInPath, decrementInPath, watch changes, doc()
|
|
21
|
+
- **[databases.md](reference/databases.md)** → collections, documents, queries, subscriptions, snapshots, insert, update, delete, CRUD, real-time, dereference, pagination, transactions, query operators, eq, neq, gt, gte, lt, lte, like, in, nin, arrayIncludesSome, arrayIncludesAll, sortBy, limit, join queries, OR queries, @trigger, native queries, SQL, MongoDB, Elasticsearch, incrementInPath, decrementInPath, watch changes, doc(), projectFields, field projection, __docId__, __id
|
|
22
22
|
- **[backend.md](reference/backend.md)** → SquidService, @executable, @webhook, @trigger, TriggerRequest, @scheduler, @limits, rate limiting, quotas, decorators, backend functions, WebhookRequest, CronExpression, cron, file handling, SquidFile, getUserAuth, isAuthenticated, assertIsAuthenticated, createWebhookResponse, this.squid, this.secrets, @clientConnectionStateHandler, CLI, squid init, squid start, squid deploy, squid build, project structure
|
|
23
23
|
- **[security.md](reference/security.md)** → security rules, @secureDatabase, @secureCollection, @secureTopic, @secureStorage, @secureApi, @secureNativeQuery, @secureAiQuery, @secureAiAgent, @secureDistributedLock, @secureGraphQL, QueryContext, MutationContext, isSubqueryOf, affectsPath, permissions, authorization, row-level security, role-based access
|
|
24
24
|
- **[admin.md](reference/admin.md)** → ManagementClient, management API keys, organizations, applications, programmatic management, CI/CD, automation, integrations admin, secrets admin, upsertIntegration, discoverDataConnectionSchema, testDataConnection, createOrganization, createApplication
|
|
@@ -11,6 +11,7 @@ Squid provides database functionality similar to Firestore but more powerful, wi
|
|
|
11
11
|
- OR Queries
|
|
12
12
|
- Join Queries
|
|
13
13
|
- Dereference
|
|
14
|
+
- Field Projection
|
|
14
15
|
- Pagination
|
|
15
16
|
- Watch Changes
|
|
16
17
|
- Transactions
|
|
@@ -314,6 +315,144 @@ const userData = await users.query()
|
|
|
314
315
|
// - You need DocumentReference methods like .update() or .delete()
|
|
315
316
|
```
|
|
316
317
|
|
|
318
|
+
## Field Projection
|
|
319
|
+
|
|
320
|
+
Return only specific fields from queries to reduce bandwidth and improve performance.
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// Basic usage
|
|
324
|
+
const results = await users.query()
|
|
325
|
+
.projectFields(['name', 'email'])
|
|
326
|
+
.dereference()
|
|
327
|
+
.snapshot();
|
|
328
|
+
|
|
329
|
+
// Works with all query methods
|
|
330
|
+
const results = await users.query()
|
|
331
|
+
.eq('status', 'active')
|
|
332
|
+
.sortBy('name')
|
|
333
|
+
.limit(50)
|
|
334
|
+
.projectFields(['name', 'email', 'status'])
|
|
335
|
+
.dereference()
|
|
336
|
+
.snapshot();
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Always-Included Fields
|
|
340
|
+
|
|
341
|
+
These fields are **always** included in results regardless of projection:
|
|
342
|
+
|
|
343
|
+
| Field | Present On | Description |
|
|
344
|
+
|-------|------------|-------------|
|
|
345
|
+
| `__docId__` | All integrations | JSON-stringified document identifier |
|
|
346
|
+
| `__id` | `built_in_db` only | Primary key value |
|
|
347
|
+
|
|
348
|
+
For **composite primary keys**, individual key fields are automatically spread to the top level:
|
|
349
|
+
```typescript
|
|
350
|
+
// Document with composite PK (pk1, pk2)
|
|
351
|
+
// Result includes: { name: 'Alice', __docId__: '{"pk1":"a","pk2":1}', pk1: 'a', pk2: 1 }
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Nested Fields
|
|
355
|
+
|
|
356
|
+
Use dot notation for nested paths:
|
|
357
|
+
```typescript
|
|
358
|
+
const results = await users.query()
|
|
359
|
+
.projectFields(['name', 'address.city', 'address.zip'])
|
|
360
|
+
.dereference()
|
|
361
|
+
.snapshot();
|
|
362
|
+
// Result: { name: 'Alice', address: { city: 'NYC', zip: '10001' } }
|
|
363
|
+
// Other address fields NOT included
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Validation Rules
|
|
367
|
+
|
|
368
|
+
**Filter fields must be projected:**
|
|
369
|
+
```typescript
|
|
370
|
+
// ERROR: Cannot filter by 'email' not in projectFields
|
|
371
|
+
users.query().eq('email', 'test@example.com').projectFields(['name']);
|
|
372
|
+
|
|
373
|
+
// CORRECT: Include filter field
|
|
374
|
+
users.query().eq('email', 'test@example.com').projectFields(['name', 'email']);
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Sort fields must be projected:**
|
|
378
|
+
```typescript
|
|
379
|
+
// ERROR: Cannot sort by 'email' not in projectFields
|
|
380
|
+
users.query().sortBy('email').projectFields(['name']);
|
|
381
|
+
|
|
382
|
+
// CORRECT: Include sort field
|
|
383
|
+
users.query().sortBy('email').projectFields(['name', 'email']);
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
**Exception:** `__docId__` can always be used for filtering/sorting without being in projection:
|
|
387
|
+
```typescript
|
|
388
|
+
// ALLOWED: __docId__ is always available
|
|
389
|
+
users.query().where('__docId__', '>=', 'user_100').projectFields(['name']);
|
|
390
|
+
users.query().sortBy('__docId__').projectFields(['name']);
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Composite conditions must use projected fields:**
|
|
394
|
+
```typescript
|
|
395
|
+
// ERROR: Cannot filter by 'email' not in projectFields
|
|
396
|
+
users.query().projectFields(['name']).addCompositeCondition([{ fieldName: 'email', operator: '>=', value: 'a' }]);
|
|
397
|
+
|
|
398
|
+
// ALLOWED: __docId__ works without projection
|
|
399
|
+
users.query().projectFields(['name']).addCompositeCondition([{ fieldName: '__docId__', operator: '>=', value: 'a' }]);
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Calling projectFields twice:** Second call must be a subset of the first:
|
|
403
|
+
```typescript
|
|
404
|
+
// ALLOWED: ['name'] is subset of ['name', 'age', 'email']
|
|
405
|
+
users.query().projectFields(['name', 'age', 'email']).projectFields(['name']);
|
|
406
|
+
|
|
407
|
+
// ERROR: 'email' was not in first projection
|
|
408
|
+
users.query().projectFields(['name', 'age']).projectFields(['name', 'email']);
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Cloning:** `projectFields` returns a cloned QueryBuilder - original is unmodified:
|
|
412
|
+
```typescript
|
|
413
|
+
const base = collection.query().where('age', '>=', 18);
|
|
414
|
+
const projected = base.projectFields(['name']); // Returns clone
|
|
415
|
+
// base still returns all fields, projected returns only 'name'
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Empty Array Behavior
|
|
419
|
+
|
|
420
|
+
| Integration | Behavior |
|
|
421
|
+
|-------------|----------|
|
|
422
|
+
| `built_in_db` | Returns documents with only `__docId__` and `__id`, no user fields |
|
|
423
|
+
| External DBs | **Throws error** - must specify at least one field |
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
// built_in_db: returns { __docId__: '...', __id: '...' }
|
|
427
|
+
await builtInCollection.query().projectFields([]).snapshot();
|
|
428
|
+
|
|
429
|
+
// External DB: throws error
|
|
430
|
+
await postgresCollection.query().projectFields([]); // Error!
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Edge Cases
|
|
434
|
+
|
|
435
|
+
- **Non-existent fields:** Silently ignored, no error thrown
|
|
436
|
+
- **Duplicate fields:** Handled gracefully, no duplication in results
|
|
437
|
+
- **Including `__id` explicitly:** Not duplicated if already auto-included
|
|
438
|
+
- **Optimistic updates:** Local updates respect the projection - document store only contains projected fields. Multiple subscriptions with different projections maintain isolated views of the same document.
|
|
439
|
+
|
|
440
|
+
### Without dereference()
|
|
441
|
+
|
|
442
|
+
When not using `dereference()`, you get `DocumentReference` objects. Access projected data via `.data`:
|
|
443
|
+
```typescript
|
|
444
|
+
const refs = await users.query().projectFields(['name']).snapshot();
|
|
445
|
+
console.log(refs[0].data.name); // Projected data on .data property
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Works With
|
|
449
|
+
|
|
450
|
+
- One-time queries (`.snapshot()`)
|
|
451
|
+
- Real-time subscriptions (`.snapshots()`)
|
|
452
|
+
- Pagination (`.paginate()`)
|
|
453
|
+
- Join queries
|
|
454
|
+
- All database integrations (MongoDB, PostgreSQL, MySQL, ClickHouse, MS SQL, built_in_db)
|
|
455
|
+
|
|
317
456
|
## Pagination
|
|
318
457
|
|
|
319
458
|
```typescript
|
|
@@ -21,6 +21,15 @@ module.exports = function (env, argv) {
|
|
|
21
21
|
'bufferutil': 'commonjs bufferutil',
|
|
22
22
|
'utf-8-validate': 'commonjs utf-8-validate',
|
|
23
23
|
},
|
|
24
|
+
// Suppress warnings from dependencies that use dynamic requires.
|
|
25
|
+
// These are typically dev dependencies used during build and don't affect runtime.
|
|
26
|
+
ignoreWarnings: [
|
|
27
|
+
{ module: /tsoa/ },
|
|
28
|
+
{ module: /@tsoa\/cli/ },
|
|
29
|
+
{ module: /handlebars/ },
|
|
30
|
+
{ module: /typescript/ },
|
|
31
|
+
{ module: /yargs/ },
|
|
32
|
+
],
|
|
24
33
|
output: {
|
|
25
34
|
path: path.resolve(process.cwd(), 'dist'),
|
|
26
35
|
filename: 'index.js',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squidcloud/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.450",
|
|
4
4
|
"description": "The Squid CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"node": ">=18.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@squidcloud/local-backend": "^1.0.
|
|
31
|
+
"@squidcloud/local-backend": "^1.0.450",
|
|
32
32
|
"adm-zip": "^0.5.16",
|
|
33
33
|
"copy-webpack-plugin": "^12.0.2",
|
|
34
34
|
"decompress": "^4.2.1",
|