@salsita-ai/sdk 0.49.0-develop.d4bea2382c → 0.49.0-develop.fc391028c9
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/application-spec/generate-application/code/templates/env-example.js +1 -0
- package/dist/application-spec/generate-application/code/templates/phoenix-skill.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +6 -3
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +32 -32
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/docs/index.json +1 -1
- package/dist/docs/phoenix/csp.mdx +6 -2
- package/dist/docs/phoenix/phoenix-cli.mdx +19 -17
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +9 -5
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant-mutations.d.ts +1 -1
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
- package/dist/legacy/domain-cli/utils/cache.js +1 -1
- package/dist/legacy/phoenix-cli/commands/dev.d.ts +2 -0
- package/dist/legacy/phoenix-cli/commands/dev.js +5 -5
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/env-example.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/env-example.js +1 -0
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
- package/dist/phoenix/application-spec/project-files.js +1 -1
- package/dist/phoenix/cli.js +1 -1
- package/dist/phoenix/commands/deploy.js +2 -2
- package/dist/phoenix/commands/dev.js +4 -4
- package/dist/phoenix/commands/init.d.ts +2 -1
- package/dist/phoenix/commands/init.js +1 -1
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/phoenix/commands/sync.js +1 -1
- package/dist/phoenix/services/cli-credentials.d.ts +3 -0
- package/dist/phoenix/services/cli-credentials.js +1 -1
- package/dist/phoenix/utils/index.d.ts +1 -1
- package/dist/phoenix/utils/index.js +1 -1
- package/dist/phoenix/utils/package-info.d.ts +9 -0
- package/dist/phoenix/utils/package-info.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import{createHash as t,randomBytes as r}from"node:crypto";import{createServer as o}from"node:http";import{hostname as n}from"node:os";import{createApiBaseClient as i}from"#package/client";import{getServerCredentials as s,saveServerCredentials as a}from"../services/index.js";let l=(e,t)=>`<!doctype html><html><head><meta charset="utf-8"><title>${e}</title></head><body style="font-family:system-ui,sans-serif;display:grid;place-items:center;height:100vh;margin:0"><main style="text-align:center"><h1>${e}</h1><p>${t}</p></main></body></html>`;export const startLoginCallbackListener=async e=>{let t=null,r=new Promise((e,r)=>{t={resolve:e,reject:r}}),n=o((r,o)=>{let n=new URL(r.url??"/","http://127.0.0.1"),i=n.searchParams.get("code");if("/callback"!==n.pathname)return void o.writeHead(404).end();if(n.searchParams.get("state")!==e||!i){o.writeHead(400,{"content-type":"text/html"}),o.end(l("Sign-in failed","This response does not belong to the waiting CLI. Run phoenix login again.")),t?.reject(Error("The sign-in response did not match this CLI session. Run `phoenix login` again."));return}o.writeHead(200,{"content-type":"text/html"}),o.end(l("Phoenix CLI signed in","You can close this tab and return to the terminal.")),t?.resolve(i)}),i=await new Promise((e,t)=>{n.once("error",t),n.listen(0,"127.0.0.1",()=>{let r=n.address();null===r||"string"==typeof r?t(Error("The login callback listener did not get a port. Run `phoenix login` again.")):e(r.port)})}),s=setTimeout(()=>{t?.reject(Error("Nobody approved the sign-in within 5 minutes. Run `phoenix login` again."))},3e5);return{port:i,code:r,close:()=>{clearTimeout(s),n.close()}}};let c=async(e,t)=>{try{let{error:r,response:o}=await i(e).DELETE("/auth/token",{headers:{authorization:`Bearer ${t}`,"content-type":null}});return r&&401!==o.status?r.message:null}catch(e){return e instanceof Error?e.message:String(e)}};export const runLoginCommand=async(o,{logger:l})=>{let d=r(32).toString("base64url"),h=t("sha256").update(d).digest("base64url"),
|
|
1
|
+
import{spawn as e}from"node:child_process";import{createHash as t,randomBytes as r}from"node:crypto";import{createServer as o}from"node:http";import{hostname as n}from"node:os";import{createApiBaseClient as i}from"#package/client";import{getServerCredentials as s,saveServerCredentials as a}from"../services/index.js";let l=(e,t)=>`<!doctype html><html><head><meta charset="utf-8"><title>${e}</title></head><body style="font-family:system-ui,sans-serif;display:grid;place-items:center;height:100vh;margin:0"><main style="text-align:center"><h1>${e}</h1><p>${t}</p></main></body></html>`;export const startLoginCallbackListener=async e=>{let t=null,r=new Promise((e,r)=>{t={resolve:e,reject:r}}),n=o((r,o)=>{let n=new URL(r.url??"/","http://127.0.0.1"),i=n.searchParams.get("code");if("/callback"!==n.pathname)return void o.writeHead(404).end();if(n.searchParams.get("state")!==e||!i){o.writeHead(400,{"content-type":"text/html"}),o.end(l("Sign-in failed","This response does not belong to the waiting CLI. Run phoenix login again.")),t?.reject(Error("The sign-in response did not match this CLI session. Run `phoenix login` again."));return}o.writeHead(200,{"content-type":"text/html"}),o.end(l("Phoenix CLI signed in","You can close this tab and return to the terminal.")),t?.resolve(i)}),i=await new Promise((e,t)=>{n.once("error",t),n.listen(0,"127.0.0.1",()=>{let r=n.address();null===r||"string"==typeof r?t(Error("The login callback listener did not get a port. Run `phoenix login` again.")):e(r.port)})}),s=setTimeout(()=>{t?.reject(Error("Nobody approved the sign-in within 5 minutes. Run `phoenix login` again."))},3e5);return{port:i,code:r,close:()=>{clearTimeout(s),n.close()}}};let c=async(e,t)=>{try{let{error:r,response:o}=await i(e).DELETE("/auth/token",{headers:{authorization:`Bearer ${t}`,"content-type":null}});return r&&401!==o.status?r.message:null}catch(e){return e instanceof Error?e.message:String(e)}};export const runLoginCommand=async(o,{logger:l})=>{let d=r(32).toString("base64url"),h=t("sha256").update(d).digest("base64url"),u=r(16).toString("base64url"),m=await startLoginCallbackListener(u);try{let t=new URL("/builder/cli-login",o.studioUrl);t.searchParams.set("customer",o.customer),t.searchParams.set("port",String(m.port)),t.searchParams.set("state",u),t.searchParams.set("challenge",h),l.step(`Signing in to workspace "${o.customer}" on ${o.serverUrl}`),l.info(`Approve the CLI in your browser:
|
|
2
2
|
|
|
3
3
|
${t.toString()}
|
|
4
|
-
`),o.open&&(t=>{let[r,o]="darwin"===process.platform?["open",[t]]:"win32"===process.platform?["rundll32",["url.dll,FileProtocolHandler",t]]:["xdg-open",[t]];e(r,o,{stdio:"ignore",detached:!0}).on("error",()=>void 0).unref()})(t.toString());let r=await
|
|
4
|
+
`),o.open&&(t=>{let[r,o]="darwin"===process.platform?["open",[t]]:"win32"===process.platform?["rundll32",["url.dll,FileProtocolHandler",t]]:["xdg-open",[t]];e(r,o,{stdio:"ignore",detached:!0}).on("error",()=>void 0).unref()})(t.toString());let r=await m.code,{data:p,error:g}=await i(o.serverUrl).POST("/auth/token",{body:{code:r,codeVerifier:d,port:m.port,name:`phoenix CLI on ${n()}`}});if(g||!p)throw Error(`The server did not accept the sign-in: ${g?.message??"no response"}`);if(p.customer.slug!==o.customer)throw await c(o.serverUrl,p.token),Error(`The sign-in was approved in workspace "${p.customer.slug}", not "${o.customer}". Check --region or --studioUrl and run \`phoenix login ${o.customer}\` again.`);let w=await s(o.serverUrl),y=await a(o.serverUrl,{token:p.token,userId:p.userId,customerSlug:p.customer.slug,customerName:p.customer.name,studioUrl:o.studioUrl,createdAt:new Date().toISOString()}),f=w?await c(o.serverUrl,w.token):null;f&&l.warn(`The server did not revoke the token this sign-in replaces (${f}). It stays valid on the server. Contact Phoenix support to revoke it.`),l.success(`Signed in to ${p.customer.name}. The token is stored in ${y}; revoke it with phoenix logout.`)}finally{m.close()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runCommand as
|
|
1
|
+
import{ensureWorkspaceInstallSettings as e,runCommand as s}from"../utils/index.js";import{generateProjectFilesAndInstallDependencies as c}from"./generate-project-files.js";export const runSyncCommand=async(t,i)=>{let{logger:r}=i,{sdkVersion:n,projectSlug:o,environmentSlug:l,cliUseWorkspace:a,enableEditor:p,force:m=!1,analyze:u=!1}=t;try{r.step("Syncing Phoenix project files"),e(process.cwd()),await s({command:"pnpm",args:["install"],description:"Installing packages",quiet:!0},{logger:r}),r.step("Building project files"),await c({sdkVersion:n,projectSlug:o,environmentSlug:l,cliUseWorkspace:a,enableEditor:p,inlineTemplates:!0,force:m,analyze:u},i),r.success("Project files built successfully"),r.success("Sync completed successfully!")}catch(e){r.error(`Sync failed: ${e instanceof Error?e.message:String(e)}`,e),process.exit(1)}};
|
|
@@ -7,18 +7,21 @@ declare const ServerCredentials: z.ZodObject<{
|
|
|
7
7
|
userId: z.ZodString;
|
|
8
8
|
customerSlug: z.ZodString;
|
|
9
9
|
customerName: z.ZodString;
|
|
10
|
+
studioUrl: z.ZodOptional<z.ZodString>;
|
|
10
11
|
createdAt: z.ZodString;
|
|
11
12
|
}, "strip", z.ZodTypeAny, {
|
|
12
13
|
token: string;
|
|
13
14
|
userId: string;
|
|
14
15
|
customerSlug: string;
|
|
15
16
|
customerName: string;
|
|
17
|
+
studioUrl?: string | undefined;
|
|
16
18
|
createdAt: string;
|
|
17
19
|
}, {
|
|
18
20
|
token: string;
|
|
19
21
|
userId: string;
|
|
20
22
|
customerSlug: string;
|
|
21
23
|
customerName: string;
|
|
24
|
+
studioUrl?: string | undefined;
|
|
22
25
|
createdAt: string;
|
|
23
26
|
}>;
|
|
24
27
|
export type ServerCredentials = z.infer<typeof ServerCredentials>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{chmod as e,mkdir as r,readFile as t,writeFile as s}from"node:fs/promises";import{homedir as n}from"node:os";import{dirname as a,join as i}from"node:path";import{z as o}from"zod";let l=o.object({token:o.string().min(1),userId:o.string(),customerSlug:o.string(),customerName:o.string(),createdAt:o.string()}),c=o.object({version:o.literal(1),servers:o.record(o.string(),l)}),d={version:1,servers:{}};export const getCredentialsPath=()=>process.env.PHOENIX_CREDENTIALS_FILE??i(n(),".phoenix","credentials.json");let u=e=>new URL(e).origin,g=async()=>{let e;try{e=await t(getCredentialsPath(),"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return d;throw e}let r=c.safeParse((e=>{try{return JSON.parse(e)}catch{return null}})(e));if(!r.success)throw Error(`The credentials file ${getCredentialsPath()} is not valid. Delete it and run \`phoenix login\` again.`);return r.data},m=async t=>{let n=getCredentialsPath();return await r(a(n),{recursive:!0,mode:448}),await s(n,`${JSON.stringify(t,null,2)}
|
|
1
|
+
import{chmod as e,mkdir as r,readFile as t,writeFile as s}from"node:fs/promises";import{homedir as n}from"node:os";import{dirname as a,join as i}from"node:path";import{z as o}from"zod";let l=o.object({token:o.string().min(1),userId:o.string(),customerSlug:o.string(),customerName:o.string(),studioUrl:o.string().optional(),createdAt:o.string()}),c=o.object({version:o.literal(1),servers:o.record(o.string(),l)}),d={version:1,servers:{}};export const getCredentialsPath=()=>process.env.PHOENIX_CREDENTIALS_FILE??i(n(),".phoenix","credentials.json");let u=e=>new URL(e).origin,g=async()=>{let e;try{e=await t(getCredentialsPath(),"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return d;throw e}let r=c.safeParse((e=>{try{return JSON.parse(e)}catch{return null}})(e));if(!r.success)throw Error(`The credentials file ${getCredentialsPath()} is not valid. Delete it and run \`phoenix login\` again.`);return r.data},m=async t=>{let n=getCredentialsPath();return await r(a(n),{recursive:!0,mode:448}),await s(n,`${JSON.stringify(t,null,2)}
|
|
2
2
|
`,{mode:384}),await e(n,384),n};export const getServerCredentials=async e=>(await g()).servers[u(e)]??null;export const saveServerCredentials=async(e,r)=>{let t=await g();return m({...t,servers:{...t.servers,[u(e)]:r}})};export const removeServerCredentials=async e=>{let r=await g(),{[u(e)]:t,...s}=r.servers;await m({...r,servers:s})};
|
|
@@ -5,7 +5,7 @@ export { parseChangelog, getLatestVersion, getVersion, paginateVersions, getVers
|
|
|
5
5
|
export { createDirectoryFromYaml, exists, scanFolderForFiles, syncChangedFiles, syncExistingFolders, validateFolders, writeFileIfNotExists, writeFilesIfNotExists, writeRawFiles, } from './file-system.js';
|
|
6
6
|
export { FileLogger } from './file-logger.js';
|
|
7
7
|
export { type Logger, type CreateLoggerOptions, createLogger } from './logger.js';
|
|
8
|
-
export { addWorkspaceOverrides, getLocalOverrides, getSdkPackages, getWorkspaceDir, hasLocalOverrides, readPackageJson, removeWorkspaceOverrides, } from './package-info.js';
|
|
8
|
+
export { addWorkspaceOverrides, ensureWorkspaceInstallSettings, getLocalOverrides, getSdkPackages, getWorkspaceDir, hasLocalOverrides, readPackageJson, removeWorkspaceOverrides, } from './package-info.js';
|
|
9
9
|
export { toPascalCase } from './pascal-case.js';
|
|
10
10
|
export { type RunCommandProps, runCommand } from './run-command.js';
|
|
11
11
|
export { type FileUploadInfo, type UploadLinksData, uploadFilesWithPresignedUrls, readUploadLinks, } from './upload-utils.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{askQuestion}from"./ask-question.js";export{checkBundleSizeBudgets}from"./check-bundle-size-budgets.js";export{formatEnvContent,formatEnvLine}from"./env-file.js";export{parseChangelog,getLatestVersion,getVersion,paginateVersions,getVersionNumbers}from"./changelog-parser.js";export{createDirectoryFromYaml,exists,scanFolderForFiles,syncChangedFiles,syncExistingFolders,validateFolders,writeFileIfNotExists,writeFilesIfNotExists,writeRawFiles}from"./file-system.js";export{FileLogger}from"./file-logger.js";export{createLogger}from"./logger.js";export{addWorkspaceOverrides,getLocalOverrides,getSdkPackages,getWorkspaceDir,hasLocalOverrides,readPackageJson,removeWorkspaceOverrides}from"./package-info.js";export{toPascalCase}from"./pascal-case.js";export{runCommand}from"./run-command.js";export{uploadFilesWithPresignedUrls,readUploadLinks}from"./upload-utils.js";
|
|
1
|
+
export{askQuestion}from"./ask-question.js";export{checkBundleSizeBudgets}from"./check-bundle-size-budgets.js";export{formatEnvContent,formatEnvLine}from"./env-file.js";export{parseChangelog,getLatestVersion,getVersion,paginateVersions,getVersionNumbers}from"./changelog-parser.js";export{createDirectoryFromYaml,exists,scanFolderForFiles,syncChangedFiles,syncExistingFolders,validateFolders,writeFileIfNotExists,writeFilesIfNotExists,writeRawFiles}from"./file-system.js";export{FileLogger}from"./file-logger.js";export{createLogger}from"./logger.js";export{addWorkspaceOverrides,ensureWorkspaceInstallSettings,getLocalOverrides,getSdkPackages,getWorkspaceDir,hasLocalOverrides,readPackageJson,removeWorkspaceOverrides}from"./package-info.js";export{toPascalCase}from"./pascal-case.js";export{runCommand}from"./run-command.js";export{uploadFilesWithPresignedUrls,readUploadLinks}from"./upload-utils.js";
|
|
@@ -10,6 +10,15 @@ export declare const readPackageJson: (path?: string) => PackageJson;
|
|
|
10
10
|
export declare const getWorkspaceDir: () => string;
|
|
11
11
|
export declare const addWorkspaceOverrides: (entries: Record<string, string>) => void;
|
|
12
12
|
export declare const removeWorkspaceOverrides: (names: readonly string[]) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Makes a standalone project installable with pnpm 11: its `pnpm-workspace.yaml` decides the build scripts of the
|
|
15
|
+
* SDK's dependencies and exempts the SDK's own packages from the minimum release age. Only missing answers are
|
|
16
|
+
* added, so a value the project set stays, and the file travels with a deploy so the server-side install follows it.
|
|
17
|
+
*
|
|
18
|
+
* A project inside a monorepo is left alone: the workspace root owns these settings, and a file in the project
|
|
19
|
+
* folder would turn it into a workspace root of its own.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ensureWorkspaceInstallSettings: (projectRoot: string) => void;
|
|
13
22
|
export declare const hasLocalOverrides: () => boolean;
|
|
14
23
|
export declare const getLocalOverrides: () => string[];
|
|
15
24
|
export declare const hasLocalSymlinks: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,lstatSync as t,readFileSync as r,readdirSync as s,writeFileSync as o}from"fs";import{dirname as a,join as i,resolve as
|
|
1
|
+
import{existsSync as e,lstatSync as t,readFileSync as r,readdirSync as s,writeFileSync as o}from"fs";import{dirname as a,join as i,resolve as l}from"path";import{isMap as n,isScalar as c,isSeq as d,parse as p,parseDocument as m}from"yaml";let u="pnpm-workspace.yaml",f="@salsita-ai/";export const readPackageJson=(t=".")=>{let s=l(t,"package.json");if(!e(s))throw Error(`package.json not found at ${s}`);return JSON.parse(r(s,"utf8"))};let g=(t=process.cwd())=>{let r=l(t);for(;;){let t=i(r,u);if(e(t))return t;let s=a(r);if(s===r)return;r=s}},k=()=>g()??i(process.cwd(),u),h=()=>{try{let e=g();if(!e)return{};let t=p(r(e,"utf8"));return t?.overrides??{}}catch{return{}}};export const getWorkspaceDir=()=>a(k());export const addWorkspaceOverrides=t=>{let s=k(),a=m(e(s)?r(s,"utf8"):"");Object.entries(t).forEach(([e,t])=>{a.setIn(["overrides",e],t)}),a.setIn(["optimisticRepeatInstall"],!1),o(s,a.toString())};export const removeWorkspaceOverrides=e=>{let t=g();if(!t)return;let s=m(r(t,"utf8"));e.forEach(e=>{s.deleteIn(["overrides",e])});let a=s.getIn(["overrides"]);n(a)&&0===a.items.length&&s.delete("overrides"),s.delete("optimisticRepeatInstall"),o(t,s.toString())};let x={"@swc/core":!0,esbuild:!0,"es5-ext":!1},y=`${f}*`;export const ensureWorkspaceInstallSettings=t=>{let s=i(t,u);if(!e(s)&&g(t))return;let a=e(s)?r(s,"utf8"):"",l=m(a);n(l.get("allowBuilds"))||l.set("allowBuilds",l.createNode({})),Object.entries(x).forEach(([e,t])=>{"boolean"!=typeof l.getIn(["allowBuilds",e])&&l.setIn(["allowBuilds",e],t)});let p=l.getIn(["minimumReleaseAgeExclude"]);d(p)?p.items.some(e=>c(e)&&e.value===y)||p.add(y):l.setIn(["minimumReleaseAgeExclude"],l.createNode([y]));let f=l.toString();f!==a&&o(s,f)};export const hasLocalOverrides=()=>Object.keys(h()).some(e=>e.startsWith(f));export const getLocalOverrides=()=>Object.keys(h()).filter(e=>e.startsWith(f));let v=["@salsita-ai/common","@salsita-ai/contracts","@salsita-ai/sdk"];export const hasLocalSymlinks=()=>v.some(e=>{let r=l("node_modules",e);try{return t(r).isSymbolicLink()}catch{return!1}});export const isUsingLocalSdk=()=>hasLocalOverrides()||hasLocalSymlinks();export const getSdkPackages=t=>{let r=l(t,"packages/libs");if(!e(r))throw Error(`SDK libs directory not found at ${r}`);return s(r,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).map(e=>{let t=i(r,e),s=readPackageJson(t);if(!s.name)throw Error(`Package at ${t} has no name in package.json`);return{name:s.name,path:t}})};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salsita-ai/sdk",
|
|
3
|
-
"version": "0.49.0-develop.
|
|
3
|
+
"version": "0.49.0-develop.fc391028c9",
|
|
4
4
|
"description": "TypeScript SDK and CLI for building, running, and deploying Phoenix configurator applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"salsita",
|
|
@@ -295,8 +295,8 @@
|
|
|
295
295
|
"yaml": "2.9.0",
|
|
296
296
|
"yargs": "17.7.2",
|
|
297
297
|
"zod": "3.25.76",
|
|
298
|
-
"@salsita-ai/
|
|
299
|
-
"@salsita-ai/
|
|
298
|
+
"@salsita-ai/common": "0.49.0-develop.fc391028c9",
|
|
299
|
+
"@salsita-ai/contracts": "0.49.0-develop.fc391028c9"
|
|
300
300
|
},
|
|
301
301
|
"devDependencies": {
|
|
302
302
|
"@clerk/clerk-react": "5.61.8",
|