@tailor-platform/sdk 0.11.0 → 0.11.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/CHANGELOG.md +28 -0
- package/dist/cli/api.d.mts +10 -2
- package/dist/cli/api.mjs +2 -2
- package/dist/cli/index.mjs +2 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +2 -2
- package/dist/{index-BTj95IAw.d.mts → index-Bx9tHHe8.d.mts} +2 -2
- package/dist/{token-43KGC4QJ.mjs → token-BJq9rpG5.mjs} +133 -22
- package/dist/token-BJq9rpG5.mjs.map +1 -0
- package/dist/{types-U0wDhMcX.d.mts → types-C5oBGPO0.d.mts} +9 -9
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli-reference.md +15 -0
- package/package.json +6 -6
- package/dist/token-43KGC4QJ.mjs.map +0 -1
|
@@ -3144,7 +3144,7 @@ async function applyApplication(client, changeSet, phase = "create-update") {
|
|
|
3144
3144
|
function trn$6(workspaceId, name) {
|
|
3145
3145
|
return `trn:v1:workspace:${workspaceId}:application:${name}`;
|
|
3146
3146
|
}
|
|
3147
|
-
async function planApplication({ client, workspaceId, application }) {
|
|
3147
|
+
async function planApplication({ client, workspaceId, application, forRemoval }) {
|
|
3148
3148
|
const changeSet = new ChangeSet("Applications");
|
|
3149
3149
|
const existingApplications = await fetchAll(async (pageToken) => {
|
|
3150
3150
|
try {
|
|
@@ -3158,6 +3158,17 @@ async function planApplication({ client, workspaceId, application }) {
|
|
|
3158
3158
|
throw error;
|
|
3159
3159
|
}
|
|
3160
3160
|
});
|
|
3161
|
+
if (forRemoval) {
|
|
3162
|
+
if (existingApplications.some((app) => app.name === application.name)) changeSet.deletes.push({
|
|
3163
|
+
name: application.name,
|
|
3164
|
+
request: {
|
|
3165
|
+
workspaceId,
|
|
3166
|
+
applicationName: application.name
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
changeSet.print();
|
|
3170
|
+
return changeSet;
|
|
3171
|
+
}
|
|
3161
3172
|
let authNamespace;
|
|
3162
3173
|
let authIdpConfigName;
|
|
3163
3174
|
if (application.authService && application.authService.config) {
|
|
@@ -3303,8 +3314,8 @@ async function applyIdP(client, result, phase = "create-update") {
|
|
|
3303
3314
|
await Promise.all(changeSet.service.deletes.map((del) => client.deleteIdPService(del.request)));
|
|
3304
3315
|
}
|
|
3305
3316
|
}
|
|
3306
|
-
async function planIdP({ client, workspaceId, application }) {
|
|
3307
|
-
const idps = application.idpServices;
|
|
3317
|
+
async function planIdP({ client, workspaceId, application, forRemoval }) {
|
|
3318
|
+
const idps = forRemoval ? [] : application.idpServices;
|
|
3308
3319
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices$3(client, workspaceId, application.name, idps);
|
|
3309
3320
|
const deletedServices = serviceChangeSet.deletes.map((del) => del.name);
|
|
3310
3321
|
const clientChangeSet = await planClients(client, workspaceId, idps, deletedServices);
|
|
@@ -3516,9 +3527,9 @@ async function applyAuth(client, result, phase = "create-update") {
|
|
|
3516
3527
|
await Promise.all(changeSet.service.deletes.map((del) => client.deleteAuthService(del.request)));
|
|
3517
3528
|
}
|
|
3518
3529
|
}
|
|
3519
|
-
async function planAuth({ client, workspaceId, application }) {
|
|
3530
|
+
async function planAuth({ client, workspaceId, application, forRemoval }) {
|
|
3520
3531
|
const auths = [];
|
|
3521
|
-
if (application.authService) {
|
|
3532
|
+
if (!forRemoval && application.authService) {
|
|
3522
3533
|
await application.authService.resolveNamespaces();
|
|
3523
3534
|
auths.push(application.authService);
|
|
3524
3535
|
}
|
|
@@ -4394,7 +4405,7 @@ async function applyExecutor(client, result, phase = "create-update") {
|
|
|
4394
4405
|
function trn$3(workspaceId, name) {
|
|
4395
4406
|
return `trn:v1:workspace:${workspaceId}:executor:${name}`;
|
|
4396
4407
|
}
|
|
4397
|
-
async function planExecutor({ client, workspaceId, application }) {
|
|
4408
|
+
async function planExecutor({ client, workspaceId, application, forRemoval }) {
|
|
4398
4409
|
const changeSet = new ChangeSet("Executors");
|
|
4399
4410
|
const conflicts = [];
|
|
4400
4411
|
const unmanaged = [];
|
|
@@ -4419,7 +4430,7 @@ async function planExecutor({ client, workspaceId, application }) {
|
|
|
4419
4430
|
label: metadata?.labels[sdkNameLabelKey]
|
|
4420
4431
|
};
|
|
4421
4432
|
}));
|
|
4422
|
-
const executors = await application.executorService?.loadExecutors() ?? {};
|
|
4433
|
+
const executors = forRemoval ? {} : await application.executorService?.loadExecutors() ?? {};
|
|
4423
4434
|
for (const executor of Object.values(executors)) {
|
|
4424
4435
|
const existing = existingExecutors[executor.name];
|
|
4425
4436
|
const metaRequest = await buildMetaRequest(trn$3(workspaceId, executor.name), application.name);
|
|
@@ -4654,13 +4665,13 @@ async function applyPipeline(client, result, phase = "create-update") {
|
|
|
4654
4665
|
await Promise.all(changeSet.service.deletes.map((del) => client.deletePipelineService(del.request)));
|
|
4655
4666
|
}
|
|
4656
4667
|
}
|
|
4657
|
-
async function planPipeline({ client, workspaceId, application }) {
|
|
4668
|
+
async function planPipeline({ client, workspaceId, application, forRemoval }) {
|
|
4658
4669
|
const pipelines = [];
|
|
4659
|
-
for (const pipeline of application.resolverServices) {
|
|
4670
|
+
if (!forRemoval) for (const pipeline of application.resolverServices) {
|
|
4660
4671
|
await pipeline.loadResolvers();
|
|
4661
4672
|
pipelines.push(pipeline);
|
|
4662
4673
|
}
|
|
4663
|
-
const executors = Object.values(await application.executorService?.loadExecutors() ?? {});
|
|
4674
|
+
const executors = forRemoval ? [] : Object.values(await application.executorService?.loadExecutors() ?? {});
|
|
4664
4675
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices$1(client, workspaceId, application.name, pipelines);
|
|
4665
4676
|
const deletedServices = serviceChangeSet.deletes.map((del) => del.name);
|
|
4666
4677
|
const resolverChangeSet = await planResolvers(client, workspaceId, pipelines, executors, deletedServices, application.env);
|
|
@@ -4903,7 +4914,7 @@ async function applyStaticWebsite(client, result, phase = "create-update") {
|
|
|
4903
4914
|
function trn$1(workspaceId, name) {
|
|
4904
4915
|
return `trn:v1:workspace:${workspaceId}:staticwebsite:${name}`;
|
|
4905
4916
|
}
|
|
4906
|
-
async function planStaticWebsite({ client, workspaceId, application }) {
|
|
4917
|
+
async function planStaticWebsite({ client, workspaceId, application, forRemoval }) {
|
|
4907
4918
|
const changeSet = new ChangeSet("StaticWebsites");
|
|
4908
4919
|
const conflicts = [];
|
|
4909
4920
|
const unmanaged = [];
|
|
@@ -4928,7 +4939,8 @@ async function planStaticWebsite({ client, workspaceId, application }) {
|
|
|
4928
4939
|
label: metadata?.labels[sdkNameLabelKey]
|
|
4929
4940
|
};
|
|
4930
4941
|
}));
|
|
4931
|
-
|
|
4942
|
+
const staticWebsiteServices = forRemoval ? [] : application.staticWebsiteServices;
|
|
4943
|
+
for (const websiteService of staticWebsiteServices) {
|
|
4932
4944
|
const config = websiteService;
|
|
4933
4945
|
const name = websiteService.name;
|
|
4934
4946
|
const existing = existingWebsites[name];
|
|
@@ -5006,13 +5018,13 @@ async function applyTailorDB(client, result, phase = "create-update") {
|
|
|
5006
5018
|
await Promise.all(changeSet.service.deletes.map((del) => client.deleteTailorDBService(del.request)));
|
|
5007
5019
|
}
|
|
5008
5020
|
}
|
|
5009
|
-
async function planTailorDB({ client, workspaceId, application }) {
|
|
5021
|
+
async function planTailorDB({ client, workspaceId, application, forRemoval }) {
|
|
5010
5022
|
const tailordbs = [];
|
|
5011
|
-
for (const tailordb of application.tailorDBServices) {
|
|
5023
|
+
if (!forRemoval) for (const tailordb of application.tailorDBServices) {
|
|
5012
5024
|
await tailordb.loadTypes();
|
|
5013
5025
|
tailordbs.push(tailordb);
|
|
5014
5026
|
}
|
|
5015
|
-
const executors = Object.values(await application.executorService?.loadExecutors() ?? {});
|
|
5027
|
+
const executors = forRemoval ? [] : Object.values(await application.executorService?.loadExecutors() ?? {});
|
|
5016
5028
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices(client, workspaceId, application.name, tailordbs);
|
|
5017
5029
|
const deletedServices = serviceChangeSet.deletes.map((del) => del.name);
|
|
5018
5030
|
const typeChangeSet = await planTypes(client, workspaceId, tailordbs, executors, deletedServices);
|
|
@@ -5646,10 +5658,7 @@ async function planWorkflow(client, workspaceId, workflows) {
|
|
|
5646
5658
|
async function loadWorkflowScripts() {
|
|
5647
5659
|
const scripts = /* @__PURE__ */ new Map();
|
|
5648
5660
|
const jobsDir = path.join(getDistDir(), "workflow-jobs");
|
|
5649
|
-
if (!fs.existsSync(jobsDir))
|
|
5650
|
-
console.warn(`Warning: workflow-jobs directory not found at ${jobsDir}`);
|
|
5651
|
-
return scripts;
|
|
5652
|
-
}
|
|
5661
|
+
if (!fs.existsSync(jobsDir)) return scripts;
|
|
5653
5662
|
const files = fs.readdirSync(jobsDir);
|
|
5654
5663
|
for (const file of files) if (file.endsWith(".js") && !file.endsWith(".base.js") && !file.endsWith(".transformed.js") && !file.endsWith(".map")) {
|
|
5655
5664
|
const jobName = file.replace(/\.js$/, "");
|
|
@@ -5693,7 +5702,8 @@ async function apply(options) {
|
|
|
5693
5702
|
const ctx = {
|
|
5694
5703
|
client,
|
|
5695
5704
|
workspaceId,
|
|
5696
|
-
application
|
|
5705
|
+
application,
|
|
5706
|
+
forRemoval: false
|
|
5697
5707
|
};
|
|
5698
5708
|
const tailorDB = await planTailorDB(ctx);
|
|
5699
5709
|
const staticWebsite = await planStaticWebsite(ctx);
|
|
@@ -6616,6 +6626,107 @@ const showCommand = defineCommand({
|
|
|
6616
6626
|
})
|
|
6617
6627
|
});
|
|
6618
6628
|
|
|
6629
|
+
//#endregion
|
|
6630
|
+
//#region src/cli/remove.ts
|
|
6631
|
+
async function loadOptions$1(options) {
|
|
6632
|
+
const accessToken = await loadAccessToken({
|
|
6633
|
+
useProfile: true,
|
|
6634
|
+
profile: options?.profile
|
|
6635
|
+
});
|
|
6636
|
+
const client = await initOperatorClient(accessToken);
|
|
6637
|
+
const workspaceId = loadWorkspaceId({
|
|
6638
|
+
workspaceId: options?.workspaceId,
|
|
6639
|
+
profile: options?.profile
|
|
6640
|
+
});
|
|
6641
|
+
const configPath = loadConfigPath(options?.configPath);
|
|
6642
|
+
const { config } = await loadConfig(configPath);
|
|
6643
|
+
const application = defineApplication(config);
|
|
6644
|
+
return {
|
|
6645
|
+
client,
|
|
6646
|
+
workspaceId,
|
|
6647
|
+
application
|
|
6648
|
+
};
|
|
6649
|
+
}
|
|
6650
|
+
async function execRemove(client, workspaceId, application, confirm) {
|
|
6651
|
+
const ctx = {
|
|
6652
|
+
client,
|
|
6653
|
+
workspaceId,
|
|
6654
|
+
application,
|
|
6655
|
+
forRemoval: true
|
|
6656
|
+
};
|
|
6657
|
+
const tailorDB = await planTailorDB(ctx);
|
|
6658
|
+
const staticWebsite = await planStaticWebsite(ctx);
|
|
6659
|
+
const idp = await planIdP(ctx);
|
|
6660
|
+
const auth = await planAuth(ctx);
|
|
6661
|
+
const pipeline = await planPipeline(ctx);
|
|
6662
|
+
const app = await planApplication(ctx);
|
|
6663
|
+
const executor = await planExecutor(ctx);
|
|
6664
|
+
if (tailorDB.changeSet.service.deletes.length === 0 && staticWebsite.changeSet.deletes.length === 0 && idp.changeSet.service.deletes.length === 0 && auth.changeSet.service.deletes.length === 0 && pipeline.changeSet.service.deletes.length === 0 && app.deletes.length === 0 && executor.changeSet.deletes.length === 0) return;
|
|
6665
|
+
if (confirm) await confirm();
|
|
6666
|
+
await applyExecutor(client, executor, "delete");
|
|
6667
|
+
await applyApplication(client, app, "delete");
|
|
6668
|
+
await applyPipeline(client, pipeline, "delete");
|
|
6669
|
+
await applyAuth(client, auth, "delete");
|
|
6670
|
+
await applyIdP(client, idp, "delete");
|
|
6671
|
+
await applyStaticWebsite(client, staticWebsite, "delete");
|
|
6672
|
+
await applyTailorDB(client, tailorDB, "delete");
|
|
6673
|
+
}
|
|
6674
|
+
async function remove(options) {
|
|
6675
|
+
const { client, workspaceId, application } = await loadOptions$1(options);
|
|
6676
|
+
await execRemove(client, workspaceId, application);
|
|
6677
|
+
}
|
|
6678
|
+
const removeCommand = defineCommand({
|
|
6679
|
+
meta: {
|
|
6680
|
+
name: "remove",
|
|
6681
|
+
description: "Remove all resources managed by the application"
|
|
6682
|
+
},
|
|
6683
|
+
args: {
|
|
6684
|
+
...commonArgs,
|
|
6685
|
+
"workspace-id": {
|
|
6686
|
+
type: "string",
|
|
6687
|
+
description: "Workspace ID",
|
|
6688
|
+
alias: "w"
|
|
6689
|
+
},
|
|
6690
|
+
profile: {
|
|
6691
|
+
type: "string",
|
|
6692
|
+
description: "Workspace profile",
|
|
6693
|
+
alias: "p"
|
|
6694
|
+
},
|
|
6695
|
+
config: {
|
|
6696
|
+
type: "string",
|
|
6697
|
+
description: "Path to SDK config file",
|
|
6698
|
+
alias: "c",
|
|
6699
|
+
default: "tailor.config.ts"
|
|
6700
|
+
},
|
|
6701
|
+
yes: {
|
|
6702
|
+
type: "boolean",
|
|
6703
|
+
description: "Skip confirmation prompt",
|
|
6704
|
+
alias: "y",
|
|
6705
|
+
default: false
|
|
6706
|
+
}
|
|
6707
|
+
},
|
|
6708
|
+
run: withCommonArgs(async (args) => {
|
|
6709
|
+
const { client, workspaceId, application } = await loadOptions$1({
|
|
6710
|
+
workspaceId: args["workspace-id"],
|
|
6711
|
+
profile: args.profile,
|
|
6712
|
+
configPath: args.config
|
|
6713
|
+
});
|
|
6714
|
+
console.log(`Planning removal of resources managed by "${application.name}"...\n`);
|
|
6715
|
+
await execRemove(client, workspaceId, application, async () => {
|
|
6716
|
+
if (!args.yes) {
|
|
6717
|
+
if (!await consola.prompt("Are you sure you want to remove all resources?", {
|
|
6718
|
+
type: "confirm",
|
|
6719
|
+
initial: false
|
|
6720
|
+
})) throw new Error(ml`
|
|
6721
|
+
Remove cancelled. No resources were deleted.
|
|
6722
|
+
To override, run again and confirm, or use --yes flag.
|
|
6723
|
+
`);
|
|
6724
|
+
} else consola.success("Removing all resources (--yes flag specified)...");
|
|
6725
|
+
});
|
|
6726
|
+
consola.success(`Successfully removed all resources managed by "${application.name}".`);
|
|
6727
|
+
})
|
|
6728
|
+
});
|
|
6729
|
+
|
|
6619
6730
|
//#endregion
|
|
6620
6731
|
//#region src/cli/workspace/transform.ts
|
|
6621
6732
|
const workspaceInfo = (workspace) => {
|
|
@@ -6942,5 +7053,5 @@ const tokenCommand = defineCommand({
|
|
|
6942
7053
|
});
|
|
6943
7054
|
|
|
6944
7055
|
//#endregion
|
|
6945
|
-
export { PATScope, apply, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generate, generateCommand, generateUserTypes, initOAuth2Client, initOperatorClient, listCommand, listCommand$1, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, machineUserList, machineUserToken, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, show, showCommand, tokenCommand, withCommonArgs, workspaceCreate, workspaceDelete, workspaceList, writePlatformConfig };
|
|
6946
|
-
//# sourceMappingURL=token-
|
|
7056
|
+
export { PATScope, apply, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generate, generateCommand, generateUserTypes, initOAuth2Client, initOperatorClient, listCommand, listCommand$1, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, machineUserList, machineUserToken, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, remove, removeCommand, show, showCommand, tokenCommand, withCommonArgs, workspaceCreate, workspaceDelete, workspaceList, writePlatformConfig };
|
|
7057
|
+
//# sourceMappingURL=token-BJq9rpG5.mjs.map
|