@tailor-platform/sdk 2.37.0 → 2.38.0
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 +60 -0
- package/dist/{application-83WVdH85.mjs → application-Bz80INH4.mjs} +1 -1
- package/dist/application-CeqD1OK-.mjs +207 -0
- package/dist/application-CeqD1OK-.mjs.map +1 -0
- package/dist/cli/commands/deploy/deploy.d.mts +1 -0
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +2 -0
- package/dist/cli/lib.d.mts +2 -2
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +66 -60
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/args.d.mts +14 -5
- package/dist/cli/shared/client.d.mts +14 -3
- package/dist/cli/shared/error-json.d.mts +12 -26
- package/dist/client-CHXix4LD.mjs +1 -0
- package/dist/client-DOQv-BP8.mjs +2 -0
- package/dist/client-DOQv-BP8.mjs.map +1 -0
- package/dist/completion/zsh-worker.zsh +133 -69
- package/dist/configure/services/executor/operation.d.mts +5 -4
- package/dist/configure/services/http-adapter/http-adapter.d.mts +1 -1
- package/dist/configure/services/index.d.mts +0 -1
- package/dist/configure/services/tailordb/types.d.mts +9 -0
- package/dist/context-DSi5kfqr.mjs +23 -0
- package/dist/context-DSi5kfqr.mjs.map +1 -0
- package/dist/context-OOASEQLA.mjs +1 -0
- package/dist/{crashreport-D_wf4GZh.mjs → crashreport-CQTAlnbA.mjs} +2 -2
- package/dist/{crashreport-D_wf4GZh.mjs.map → crashreport-CQTAlnbA.mjs.map} +1 -1
- package/dist/crashreport-GRnWyDnF.mjs +1 -0
- package/dist/{errors-Dmdnq0zi.mjs → errors-9OOL3xOM.mjs} +6 -5
- package/dist/errors-9OOL3xOM.mjs.map +1 -0
- package/dist/field_behavior_pb-B196sUx6.mjs +2 -0
- package/dist/field_behavior_pb-B196sUx6.mjs.map +1 -0
- package/dist/{kysely-type-DVL90_oX.mjs → kysely-type-DhAZqdQg.mjs} +14 -10
- package/dist/kysely-type-DhAZqdQg.mjs.map +1 -0
- package/dist/notification_resource_pb-BZ0hCA01.mjs +1 -0
- package/dist/notification_resource_pb-Dwzah7gO.mjs +2 -0
- package/dist/notification_resource_pb-Dwzah7gO.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/register-ts-hook-CXYYYgCl.mjs +1094 -0
- package/dist/register-ts-hook-CXYYYgCl.mjs.map +1 -0
- package/dist/repl-editor-Bposemei.mjs +2 -0
- package/dist/repl-editor-Bposemei.mjs.map +1 -0
- package/dist/resource_pb-elY668ZB.mjs +2 -0
- package/dist/resource_pb-elY668ZB.mjs.map +1 -0
- package/dist/{secret-file-DiuEcLFP.mjs → secret-file-CSXzcg4c.mjs} +2 -2
- package/dist/{secret-file-DiuEcLFP.mjs.map → secret-file-CSXzcg4c.mjs.map} +1 -1
- package/dist/service-B2vx6CGM.mjs +2 -0
- package/dist/{service-DDrbdyd-.mjs.map → service-B2vx6CGM.mjs.map} +1 -1
- package/dist/service-DB-RHn25.mjs +9 -0
- package/dist/service-DB-RHn25.mjs.map +1 -0
- package/dist/service-DsAWXbVX.mjs +1 -0
- package/dist/service_pb-Bethc2NW.mjs +1 -0
- package/dist/service_pb-CfpSriCy.mjs +2 -0
- package/dist/service_pb-CfpSriCy.mjs.map +1 -0
- package/dist/validation-errors-DqCeUW4L.mjs +3 -0
- package/dist/validation-errors-DqCeUW4L.mjs.map +1 -0
- package/{LICENSE → dist/vendor/graphql/LICENSE} +6 -6
- package/dist/vendor/graphql/language/KindTypeMap.d.mts +3 -0
- package/dist/vendor/graphql/language/ast.d.mts +784 -0
- package/dist/vendor/graphql/language/kinds_.d.mts +203 -0
- package/dist/vendor/graphql/language/source.d.mts +46 -0
- package/dist/vendor/graphql/language/tokenKind.d.mts +35 -0
- package/dist/workspace_resource_pb-Cow7mrJY.mjs +2 -0
- package/dist/workspace_resource_pb-Cow7mrJY.mjs.map +1 -0
- package/docs/cli/application.md +13 -9
- package/docs/cli/notification.md +128 -0
- package/docs/cli/tailordb.md +26 -57
- package/docs/cli/workspace.md +1 -1
- package/docs/cli-reference.md +228 -48
- package/docs/github-actions.md +162 -26
- package/docs/services/tailordb/index.md +6 -2
- package/docs/services/tailordb/migration.md +53 -56
- package/docs/testing.md +0 -1
- package/package.json +14 -10
- package/dist/application-Cida-j1g.mjs +0 -207
- package/dist/application-Cida-j1g.mjs.map +0 -1
- package/dist/configure/services/http-adapter/index.d.mts +0 -2
- package/dist/crashreport-C2AcQNTe.mjs +0 -1
- package/dist/errors-Dmdnq0zi.mjs.map +0 -1
- package/dist/kysely-type-DVL90_oX.mjs.map +0 -1
- package/dist/register-ts-hook-Ht4zCseV.mjs +0 -1115
- package/dist/register-ts-hook-Ht4zCseV.mjs.map +0 -1
- package/dist/repl-editor-DkrCZmmg.mjs +0 -2
- package/dist/repl-editor-DkrCZmmg.mjs.map +0 -1
- package/dist/service-CZ0EdD2-.mjs +0 -10
- package/dist/service-CZ0EdD2-.mjs.map +0 -1
- package/dist/service-DDrbdyd-.mjs +0 -2
- package/dist/service-WhSyhaho.mjs +0 -1
- package/dist/service_pb-BMHhVot2.mjs +0 -1
- package/dist/service_pb-BxMSK0gg.mjs +0 -2
- package/dist/service_pb-BxMSK0gg.mjs.map +0 -1
- package/dist/workspace_resource_pb-7smKERdZ.mjs +0 -2
- package/dist/workspace_resource_pb-7smKERdZ.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# politty-completion-version: 1
|
|
2
|
-
# politty-bin-sig:
|
|
2
|
+
# politty-bin-sig: 1793859874
|
|
3
3
|
# politty-bin-path: /home/runner/work/sdk/sdk/node_modules/.bin/tailor
|
|
4
4
|
# program: tailor
|
|
5
5
|
# shell: zsh
|
|
@@ -669,6 +669,15 @@ __tailor_worker_opt_takes_value() {
|
|
|
669
669
|
machineuser:token:--workspace-id|machineuser:token:--workspaceId|machineuser:token:-w|machineuser:token:--w) return 0 ;;
|
|
670
670
|
machineuser:token:--profile|machineuser:token:-p|machineuser:token:--p) return 0 ;;
|
|
671
671
|
machineuser:token:--config|machineuser:token:-c|machineuser:token:--c) return 0 ;;
|
|
672
|
+
notification:list:--order) return 0 ;;
|
|
673
|
+
notification:list:--limit|notification:list:-l|notification:list:--l) return 0 ;;
|
|
674
|
+
notification:list:--profile|notification:list:-p|notification:list:--p) return 0 ;;
|
|
675
|
+
notification:list:--category) return 0 ;;
|
|
676
|
+
notification:list:--severity) return 0 ;;
|
|
677
|
+
notification:list:--scope-workspace|notification:list:--scopeWorkspace) return 0 ;;
|
|
678
|
+
notification:list:--scope-organization|notification:list:--scopeOrganization) return 0 ;;
|
|
679
|
+
notification:read:--profile|notification:read:-p|notification:read:--p) return 0 ;;
|
|
680
|
+
notification:dismiss:--profile|notification:dismiss:-p|notification:dismiss:--p) return 0 ;;
|
|
672
681
|
oauth2client:list:--workspace-id|oauth2client:list:--workspaceId|oauth2client:list:-w|oauth2client:list:--w) return 0 ;;
|
|
673
682
|
oauth2client:list:--profile|oauth2client:list:-p|oauth2client:list:--p) return 0 ;;
|
|
674
683
|
oauth2client:list:--config|oauth2client:list:-c|oauth2client:list:--c) return 0 ;;
|
|
@@ -794,10 +803,6 @@ __tailor_worker_opt_takes_value() {
|
|
|
794
803
|
tailordb:migration:script:--config|tailordb:migration:script:-c|tailordb:migration:script:--c) return 0 ;;
|
|
795
804
|
tailordb:migration:script:--namespace|tailordb:migration:script:-n|tailordb:migration:script:--n) return 0 ;;
|
|
796
805
|
tailordb:migration:script:--reason) return 0 ;;
|
|
797
|
-
tailordb:migration:set:--workspace-id|tailordb:migration:set:--workspaceId|tailordb:migration:set:-w|tailordb:migration:set:--w) return 0 ;;
|
|
798
|
-
tailordb:migration:set:--profile|tailordb:migration:set:-p|tailordb:migration:set:--p) return 0 ;;
|
|
799
|
-
tailordb:migration:set:--config|tailordb:migration:set:-c|tailordb:migration:set:--c) return 0 ;;
|
|
800
|
-
tailordb:migration:set:--namespace|tailordb:migration:set:-n|tailordb:migration:set:--n) return 0 ;;
|
|
801
806
|
tailordb:migration:status:--workspace-id|tailordb:migration:status:--workspaceId|tailordb:migration:status:-w|tailordb:migration:status:--w) return 0 ;;
|
|
802
807
|
tailordb:migration:status:--profile|tailordb:migration:status:-p|tailordb:migration:status:--p) return 0 ;;
|
|
803
808
|
tailordb:migration:status:--config|tailordb:migration:status:-c|tailordb:migration:status:--c) return 0 ;;
|
|
@@ -822,6 +827,7 @@ __tailor_worker_opt_takes_value() {
|
|
|
822
827
|
tailordb:migration:validate:--profile|tailordb:migration:validate:-p|tailordb:migration:validate:--p) return 0 ;;
|
|
823
828
|
tailordb:migration:validate:--config|tailordb:migration:validate:-c|tailordb:migration:validate:--c) return 0 ;;
|
|
824
829
|
tailordb:migration:validate:--namespace|tailordb:migration:validate:-n|tailordb:migration:validate:--n) return 0 ;;
|
|
830
|
+
tailordb:migration:validate:--migration-skip-steps|tailordb:migration:validate:--migrationSkipSteps) return 0 ;;
|
|
825
831
|
upgrade:--from) return 0 ;;
|
|
826
832
|
upgrade:--path) return 0 ;;
|
|
827
833
|
user:current:--profile|user:current:-p|user:current:--p) return 0 ;;
|
|
@@ -1012,6 +1018,10 @@ __tailor_worker_is_subcmd() {
|
|
|
1012
1018
|
machineuser:list) return 0 ;;
|
|
1013
1019
|
machineuser:token) return 0 ;;
|
|
1014
1020
|
:machineuser) return 0 ;;
|
|
1021
|
+
notification:list) return 0 ;;
|
|
1022
|
+
notification:read) return 0 ;;
|
|
1023
|
+
notification:dismiss) return 0 ;;
|
|
1024
|
+
:notification) return 0 ;;
|
|
1015
1025
|
oauth2client:list) return 0 ;;
|
|
1016
1026
|
oauth2client:get) return 0 ;;
|
|
1017
1027
|
:oauth2client) return 0 ;;
|
|
@@ -1058,7 +1068,6 @@ __tailor_worker_is_subcmd() {
|
|
|
1058
1068
|
tailordb:migration:rebaseline) return 0 ;;
|
|
1059
1069
|
tailordb:migration:resolve) return 0 ;;
|
|
1060
1070
|
tailordb:migration:script) return 0 ;;
|
|
1061
|
-
tailordb:migration:set) return 0 ;;
|
|
1062
1071
|
tailordb:migration:status) return 0 ;;
|
|
1063
1072
|
tailordb:migration:sync) return 0 ;;
|
|
1064
1073
|
tailordb:migration:test) return 0 ;;
|
|
@@ -2298,6 +2307,117 @@ __tailor_worker_complete_machineuser() {
|
|
|
2298
2307
|
__tailor_worker_cdescribe 'subcommands' _subs
|
|
2299
2308
|
}
|
|
2300
2309
|
|
|
2310
|
+
__tailor_worker_complete_notification_list() {
|
|
2311
|
+
local -a _vals=()
|
|
2312
|
+
case "${words[CURRENT-1]}" in
|
|
2313
|
+
--order)
|
|
2314
|
+
_vals=("asc" "desc")
|
|
2315
|
+
__tailor_worker_cdescribe 'completions' _vals
|
|
2316
|
+
return 0 ;;
|
|
2317
|
+
--category)
|
|
2318
|
+
_vals=("alert" "incident" "maintenance" "announcement")
|
|
2319
|
+
__tailor_worker_cdescribe 'completions' _vals
|
|
2320
|
+
return 0 ;;
|
|
2321
|
+
--severity)
|
|
2322
|
+
_vals=("info" "warning" "critical")
|
|
2323
|
+
__tailor_worker_cdescribe 'completions' _vals
|
|
2324
|
+
return 0 ;;
|
|
2325
|
+
esac
|
|
2326
|
+
if __tailor_worker_opt_takes_value "notification:list" "${words[CURRENT-1]}"; then return 0; fi
|
|
2327
|
+
if (( _after_dd )); then return 0; fi
|
|
2328
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
2329
|
+
local -a _opts=()
|
|
2330
|
+
__tailor_worker_not_used "--order" && _opts+=("--order:Sort order (asc or desc)")
|
|
2331
|
+
__tailor_worker_not_used "--limit" "-l" "--l" && _opts+=("--limit:Maximum number of items to return (0\: unlimited)")
|
|
2332
|
+
__tailor_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
2333
|
+
__tailor_worker_not_used "--category" && _opts+=("--category:Only this category (alert, incident, maintenance, announcement)")
|
|
2334
|
+
__tailor_worker_not_used "--severity" && _opts+=("--severity:Only this severity or higher (info, warning, critical)")
|
|
2335
|
+
__tailor_worker_not_used "--unread" && _opts+=("--unread:Only unread notifications")
|
|
2336
|
+
__tailor_worker_not_used "--scope-workspace" "--scopeWorkspace" && _opts+=("--scope-workspace:Only notifications about this workspace ID")
|
|
2337
|
+
__tailor_worker_not_used "--scope-organization" "--scopeOrganization" && _opts+=("--scope-organization:Only notifications about this organization ID")
|
|
2338
|
+
if (( ! _any_opt_used )); then
|
|
2339
|
+
_opts+=("--help:Show help")
|
|
2340
|
+
_opts+=("--help-all:Show help with all subcommand options")
|
|
2341
|
+
_opts+=("--help-json:Show help as JSON")
|
|
2342
|
+
fi
|
|
2343
|
+
__tailor_worker_cdescribe 'options' _opts
|
|
2344
|
+
return 0
|
|
2345
|
+
fi
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
__tailor_worker_complete_notification_read() {
|
|
2349
|
+
local -a _vals=()
|
|
2350
|
+
if __tailor_worker_opt_takes_value "notification:read" "${words[CURRENT-1]}"; then return 0; fi
|
|
2351
|
+
if (( _after_dd )); then
|
|
2352
|
+
case "$_pos_count" in
|
|
2353
|
+
0|*)
|
|
2354
|
+
;;
|
|
2355
|
+
esac
|
|
2356
|
+
return 0
|
|
2357
|
+
fi
|
|
2358
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
2359
|
+
local -a _opts=()
|
|
2360
|
+
__tailor_worker_not_used "--no-mark-read" "--noMarkRead" && _opts+=("--no-mark-read:Show the notification without marking it as read")
|
|
2361
|
+
__tailor_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
2362
|
+
if (( ! _any_opt_used )); then
|
|
2363
|
+
_opts+=("--help:Show help")
|
|
2364
|
+
_opts+=("--help-all:Show help with all subcommand options")
|
|
2365
|
+
_opts+=("--help-json:Show help as JSON")
|
|
2366
|
+
fi
|
|
2367
|
+
__tailor_worker_cdescribe 'options' _opts
|
|
2368
|
+
return 0
|
|
2369
|
+
fi
|
|
2370
|
+
case "$_pos_count" in
|
|
2371
|
+
0|*)
|
|
2372
|
+
;;
|
|
2373
|
+
esac
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
__tailor_worker_complete_notification_dismiss() {
|
|
2377
|
+
local -a _vals=()
|
|
2378
|
+
if __tailor_worker_opt_takes_value "notification:dismiss" "${words[CURRENT-1]}"; then return 0; fi
|
|
2379
|
+
if (( _after_dd )); then
|
|
2380
|
+
case "$_pos_count" in
|
|
2381
|
+
0)
|
|
2382
|
+
;;
|
|
2383
|
+
esac
|
|
2384
|
+
return 0
|
|
2385
|
+
fi
|
|
2386
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
2387
|
+
local -a _opts=()
|
|
2388
|
+
__tailor_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
2389
|
+
if (( ! _any_opt_used )); then
|
|
2390
|
+
_opts+=("--help:Show help")
|
|
2391
|
+
_opts+=("--help-all:Show help with all subcommand options")
|
|
2392
|
+
_opts+=("--help-json:Show help as JSON")
|
|
2393
|
+
fi
|
|
2394
|
+
__tailor_worker_cdescribe 'options' _opts
|
|
2395
|
+
return 0
|
|
2396
|
+
fi
|
|
2397
|
+
case "$_pos_count" in
|
|
2398
|
+
0)
|
|
2399
|
+
;;
|
|
2400
|
+
esac
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
__tailor_worker_complete_notification() {
|
|
2404
|
+
local -a _vals=()
|
|
2405
|
+
if __tailor_worker_opt_takes_value "notification" "${words[CURRENT-1]}"; then return 0; fi
|
|
2406
|
+
if (( _after_dd )); then return 0; fi
|
|
2407
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
2408
|
+
local -a _opts=()
|
|
2409
|
+
if (( ! _any_opt_used )); then
|
|
2410
|
+
_opts+=("--help:Show help")
|
|
2411
|
+
_opts+=("--help-all:Show help with all subcommand options")
|
|
2412
|
+
_opts+=("--help-json:Show help as JSON")
|
|
2413
|
+
fi
|
|
2414
|
+
__tailor_worker_cdescribe 'options' _opts
|
|
2415
|
+
return 0
|
|
2416
|
+
fi
|
|
2417
|
+
local -a _subs=("list:List the notifications in your inbox." "read:Show a notification and mark it as read." "dismiss:Remove a notification from your inbox.")
|
|
2418
|
+
__tailor_worker_cdescribe 'subcommands' _subs
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2301
2421
|
__tailor_worker_complete_oauth2client_list() {
|
|
2302
2422
|
local -a _vals=()
|
|
2303
2423
|
case "${words[CURRENT-1]}" in
|
|
@@ -3683,66 +3803,6 @@ __tailor_worker_complete_tailordb_migration_script() {
|
|
|
3683
3803
|
esac
|
|
3684
3804
|
}
|
|
3685
3805
|
|
|
3686
|
-
__tailor_worker_complete_tailordb_migration_set() {
|
|
3687
|
-
local -a _vals=()
|
|
3688
|
-
case "${words[CURRENT-1]}" in
|
|
3689
|
-
--config|-c|--c)
|
|
3690
|
-
setopt local_options null_glob
|
|
3691
|
-
local _cur="${words[CURRENT]:-}" _dir _prefix _f _out
|
|
3692
|
-
local -a _exts=("ts")
|
|
3693
|
-
if [[ -z "$_cur" || "$_cur" != */* ]]; then
|
|
3694
|
-
_dir="."
|
|
3695
|
-
_prefix="$_cur"
|
|
3696
|
-
elif [[ "$_cur" == */ ]]; then
|
|
3697
|
-
_dir="${_cur%/}"
|
|
3698
|
-
_prefix=""
|
|
3699
|
-
else
|
|
3700
|
-
_dir="${_cur%/*}"
|
|
3701
|
-
_prefix="${_cur##*/}"
|
|
3702
|
-
fi
|
|
3703
|
-
for _f in "$_dir"/"$_prefix"*(N/); do
|
|
3704
|
-
_out="${_f#./}"
|
|
3705
|
-
__tailor_worker_add_path_candidate "$_out"
|
|
3706
|
-
done
|
|
3707
|
-
local _ext
|
|
3708
|
-
for _f in "$_dir"/"$_prefix"*(N.); do
|
|
3709
|
-
_out="${_f#./}"
|
|
3710
|
-
for _ext in "${_exts[@]}"; do
|
|
3711
|
-
[[ -n "$_ext" && "$_out" == *."$_ext" ]] && { __tailor_worker_add_path_candidate "$_out"; break; }
|
|
3712
|
-
done
|
|
3713
|
-
done
|
|
3714
|
-
return 0 ;;
|
|
3715
|
-
esac
|
|
3716
|
-
if __tailor_worker_opt_takes_value "tailordb:migration:set" "${words[CURRENT-1]}"; then return 0; fi
|
|
3717
|
-
if (( _after_dd )); then
|
|
3718
|
-
case "$_pos_count" in
|
|
3719
|
-
0)
|
|
3720
|
-
;;
|
|
3721
|
-
esac
|
|
3722
|
-
return 0
|
|
3723
|
-
fi
|
|
3724
|
-
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
3725
|
-
local -a _opts=()
|
|
3726
|
-
__tailor_worker_not_used "--workspace-id" "--workspaceId" "-w" "--w" && _opts+=("--workspace-id:Workspace ID")
|
|
3727
|
-
__tailor_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
3728
|
-
__tailor_worker_not_used "--config" "-c" "--c" && _opts+=("--config:Path to Tailor config file")
|
|
3729
|
-
__tailor_worker_not_used "--yes" "-y" "--y" && _opts+=("--yes:Skip confirmation prompts")
|
|
3730
|
-
__tailor_worker_not_used "--namespace" "-n" "--n" && _opts+=("--namespace:Target TailorDB namespace (required if multiple namespaces exist)")
|
|
3731
|
-
__tailor_worker_not_used "--force" && _opts+=("--force:Proceed even when the namespace records a migration history ID other than the local one")
|
|
3732
|
-
if (( ! _any_opt_used )); then
|
|
3733
|
-
_opts+=("--help:Show help")
|
|
3734
|
-
_opts+=("--help-all:Show help with all subcommand options")
|
|
3735
|
-
_opts+=("--help-json:Show help as JSON")
|
|
3736
|
-
fi
|
|
3737
|
-
__tailor_worker_cdescribe 'options' _opts
|
|
3738
|
-
return 0
|
|
3739
|
-
fi
|
|
3740
|
-
case "$_pos_count" in
|
|
3741
|
-
0)
|
|
3742
|
-
;;
|
|
3743
|
-
esac
|
|
3744
|
-
}
|
|
3745
|
-
|
|
3746
3806
|
__tailor_worker_complete_tailordb_migration_status() {
|
|
3747
3807
|
local -a _vals=()
|
|
3748
3808
|
case "${words[CURRENT-1]}" in
|
|
@@ -3978,6 +4038,7 @@ __tailor_worker_complete_tailordb_migration_validate() {
|
|
|
3978
4038
|
__tailor_worker_not_used "--config" "-c" "--c" && _opts+=("--config:Path to Tailor config file")
|
|
3979
4039
|
__tailor_worker_not_used "--namespace" "-n" "--n" && _opts+=("--namespace:Target TailorDB namespace (validates all namespaces if not specified)")
|
|
3980
4040
|
__tailor_worker_not_used "--strict" && _opts+=("--strict:Also fail when a pending migration can drop data without an acknowledgment")
|
|
4041
|
+
__tailor_worker_not_used "--migration-skip-steps" "--migrationSkipSteps" && _opts+=("--migration-skip-steps:Also check that 'deploy --migration-skip-steps' can skip these steps of a partially applied multi-step migration, as comma-separated namespace/step entries")
|
|
3981
4042
|
if (( ! _any_opt_used )); then
|
|
3982
4043
|
_opts+=("--help:Show help")
|
|
3983
4044
|
_opts+=("--help-all:Show help with all subcommand options")
|
|
@@ -4002,7 +4063,7 @@ __tailor_worker_complete_tailordb_migration() {
|
|
|
4002
4063
|
__tailor_worker_cdescribe 'options' _opts
|
|
4003
4064
|
return 0
|
|
4004
4065
|
fi
|
|
4005
|
-
local -a _subs=("generate:Generate migration files by detecting schema differences between current local tables and the previous migration snapshot." "rebaseline:Collapse the full migration history into a new 0000 baseline." "resolve:Settle a migration that a failed deploy left partially applied, or whose run a deploy could not confirm." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "
|
|
4066
|
+
local -a _subs=("generate:Generate migration files by detecting schema differences between current local tables and the previous migration snapshot." "rebaseline:Collapse the full migration history into a new 0000 baseline." "resolve:Settle a migration that a failed deploy left partially applied, or whose run a deploy could not confirm." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "status:Show the current migration status for TailorDB namespaces, including applied and pending migrations." "sync:Sync remote TailorDB schema and checkpoint to a local migration snapshot to recover from schema drift or a checkpoint outside the local history." "test:Test pending migrations with seed fixtures or cloned data in a temporary workspace." "validate:Run the migration and schema-drift checks that 'deploy' runs before changing anything, without deploying, and exit with a non-zero code when issues are found.")
|
|
4006
4067
|
__tailor_worker_cdescribe 'subcommands' _subs
|
|
4007
4068
|
}
|
|
4008
4069
|
|
|
@@ -5078,7 +5139,7 @@ __tailor_worker_complete_root() {
|
|
|
5078
5139
|
fi
|
|
5079
5140
|
__tailor_worker_cdescribe 'options' _opts
|
|
5080
5141
|
else
|
|
5081
|
-
local -a _subs=("api:Call Tailor Platform API endpoints directly." "auth:Authentication helpers for scripts and plugins." "authconnection:Manage auth connections." "crashreport:Manage crash reports." "data:Manage application data across workspaces." "deploy:Deploy your application by applying the Tailor configuration." "executor:Manage executors" "function:Manage functions" "generate:Generate files using Tailor configuration." "init:Initialize a new project using create-sdk." "login:Login to Tailor Platform." "logout:Logout from Tailor Platform." "machineuser:Manage machine users in your Tailor Platform application." "oauth2client:Manage OAuth2 clients in your Tailor Platform application." "open:Open Tailor Platform Console." "organization:Manage Tailor Platform organizations." "plugin:Manage and inspect CLI plugins (beta)." "profile:Manage workspace profiles (user + workspace combinations)." "query:Run SQL/GraphQL query." "remove:Remove all resources managed by the application from the workspace." "secret:Manage Secret Manager vaults and secrets." "show:Show information about the deployed application." "staticwebsite:Manage static websites in your workspace." "tailordb:Manage TailorDB tables and data." "upgrade:Run codemods to upgrade your project to a newer SDK version." "user:Manage Tailor Platform users." "workflow:Manage workflows and workflow executions." "workspace:Manage Tailor Platform workspaces." "skills:Manage Tailor SDK agent skills." "completion:Generate shell completion script")
|
|
5142
|
+
local -a _subs=("api:Call Tailor Platform API endpoints directly." "auth:Authentication helpers for scripts and plugins." "authconnection:Manage auth connections." "crashreport:Manage crash reports." "data:Manage application data across workspaces." "deploy:Deploy your application by applying the Tailor configuration." "executor:Manage executors" "function:Manage functions" "generate:Generate files using Tailor configuration." "init:Initialize a new project using create-sdk." "login:Login to Tailor Platform." "logout:Logout from Tailor Platform." "machineuser:Manage machine users in your Tailor Platform application." "notification:Read the platform notifications sent to you." "oauth2client:Manage OAuth2 clients in your Tailor Platform application." "open:Open Tailor Platform Console." "organization:Manage Tailor Platform organizations." "plugin:Manage and inspect CLI plugins (beta)." "profile:Manage workspace profiles (user + workspace combinations)." "query:Run SQL/GraphQL query." "remove:Remove all resources managed by the application from the workspace." "secret:Manage Secret Manager vaults and secrets." "show:Show information about the deployed application." "staticwebsite:Manage static websites in your workspace." "tailordb:Manage TailorDB tables and data." "upgrade:Run codemods to upgrade your project to a newer SDK version." "user:Manage Tailor Platform users." "workflow:Manage workflows and workflow executions." "workspace:Manage Tailor Platform workspaces." "skills:Manage Tailor SDK agent skills." "completion:Generate shell completion script")
|
|
5082
5143
|
__tailor_worker_cdescribe 'subcommands' _subs
|
|
5083
5144
|
fi
|
|
5084
5145
|
}
|
|
@@ -5171,6 +5232,10 @@ _tailor_worker_completions() {
|
|
|
5171
5232
|
machineuser:list) __tailor_worker_complete_machineuser_list ;;
|
|
5172
5233
|
machineuser:token) __tailor_worker_complete_machineuser_token ;;
|
|
5173
5234
|
machineuser) __tailor_worker_complete_machineuser ;;
|
|
5235
|
+
notification:list) __tailor_worker_complete_notification_list ;;
|
|
5236
|
+
notification:read) __tailor_worker_complete_notification_read ;;
|
|
5237
|
+
notification:dismiss) __tailor_worker_complete_notification_dismiss ;;
|
|
5238
|
+
notification) __tailor_worker_complete_notification ;;
|
|
5174
5239
|
oauth2client:list) __tailor_worker_complete_oauth2client_list ;;
|
|
5175
5240
|
oauth2client:get) __tailor_worker_complete_oauth2client_get ;;
|
|
5176
5241
|
oauth2client) __tailor_worker_complete_oauth2client ;;
|
|
@@ -5217,7 +5282,6 @@ _tailor_worker_completions() {
|
|
|
5217
5282
|
tailordb:migration:rebaseline) __tailor_worker_complete_tailordb_migration_rebaseline ;;
|
|
5218
5283
|
tailordb:migration:resolve) __tailor_worker_complete_tailordb_migration_resolve ;;
|
|
5219
5284
|
tailordb:migration:script) __tailor_worker_complete_tailordb_migration_script ;;
|
|
5220
|
-
tailordb:migration:set) __tailor_worker_complete_tailordb_migration_set ;;
|
|
5221
5285
|
tailordb:migration:status) __tailor_worker_complete_tailordb_migration_status ;;
|
|
5222
5286
|
tailordb:migration:sync) __tailor_worker_complete_tailordb_migration_sync ;;
|
|
5223
5287
|
tailordb:migration:test) __tailor_worker_complete_tailordb_migration_test ;;
|
|
@@ -3,7 +3,7 @@ import { MachineUserName } from "../auth/types.mjs";
|
|
|
3
3
|
import { FunctionOperation as FunctionOperation$1, GqlOperation as GqlOperation$1, WebhookOperation as WebhookOperation$1, WorkflowOperation as WorkflowOperation$1 } from "../../../types/executor.generated.mjs";
|
|
4
4
|
import "../../types/machine-user.mjs";
|
|
5
5
|
import { Workflow } from "../workflow/workflow.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { DocumentNode } from "../../../vendor/graphql/language/ast.mjs";
|
|
7
7
|
/** Function-based executor operation. The body receives the trigger args and the `invoker`. */
|
|
8
8
|
export type FunctionOperation<Args> = Omit<FunctionOperation$1, "body" | "invoker"> & {
|
|
9
9
|
body: (args: Args & {
|
|
@@ -11,11 +11,12 @@ export type FunctionOperation<Args> = Omit<FunctionOperation$1, "body" | "invoke
|
|
|
11
11
|
}) => void | Promise<void>;
|
|
12
12
|
invoker?: MachineUserName;
|
|
13
13
|
};
|
|
14
|
-
type UrqlOperationArgs = Parameters<Client["query"] | Client["mutation"]>;
|
|
15
14
|
/** GraphQL-based executor operation. Executes a GraphQL query or mutation. */
|
|
16
15
|
export type GqlOperation<Args> = Omit<GqlOperation$1, "query" | "variables" | "invoker"> & {
|
|
17
|
-
query:
|
|
18
|
-
variables?: (args: Args) =>
|
|
16
|
+
query: string | DocumentNode;
|
|
17
|
+
variables?: (args: Args) => {
|
|
18
|
+
[prop: string]: any;
|
|
19
|
+
} | void | undefined;
|
|
19
20
|
invoker?: MachineUserName;
|
|
20
21
|
};
|
|
21
22
|
type RequestHeader = "A-IM" | "Accept" | "Accept-Additions" | "Accept-CH" | "Accept-Charset" | "Accept-Datetime" | "Accept-Encoding" | "Accept-Features" | "Accept-Language" | "Accept-Patch" | "Accept-Post" | "Accept-Ranges" | "Accept-Signature" | "Access-Control" | "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Access-Control-Request-Headers" | "Access-Control-Request-Method" | "Age" | "Allow" | "ALPN" | "Alt-Svc" | "Alt-Used" | "Alternates" | "AMP-Cache-Transform" | "Apply-To-Redirect-Ref" | "Authentication-Control" | "Authentication-Info" | "Authorization" | "Available-Dictionary" | "C-Ext" | "C-Man" | "C-Opt" | "C-PEP" | "C-PEP-Info" | "Cache-Control" | "Cache-Status" | "Cal-Managed-ID" | "CalDAV-Timezones" | "Capsule-Protocol" | "CDN-Cache-Control" | "CDN-Loop" | "Cert-Not-After" | "Cert-Not-Before" | "Clear-Site-Data" | "Client-Cert" | "Client-Cert-Chain" | "Close" | "CMCD-Object" | "CMCD-Request" | "CMCD-Session" | "CMCD-Status" | "CMSD-Dynamic" | "CMSD-Static" | "Concealed-Auth-Export" | "Configuration-Context" | "Connection" | "Content-Base" | "Content-Digest" | "Content-Disposition" | "Content-Encoding" | "Content-ID" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-MD5" | "Content-Range" | "Content-Script-Type" | "Content-Security-Policy" | "Content-Security-Policy-Report-Only" | "Content-Style-Type" | "Content-Type" | "Content-Version" | "Cookie" | "Cookie2" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Embedder-Policy-Report-Only" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Opener-Policy-Report-Only" | "Cross-Origin-Resource-Policy" | "CTA-Common-Access-Token" | "DASL" | "Date" | "DAV" | "Default-Style" | "Delta-Base" | "Deprecation" | "Depth" | "Derived-From" | "Destination" | "Differential-ID" | "Dictionary-ID" | "Digest" | "DPoP" | "DPoP-Nonce" | "Early-Data" | "EDIINT-Features" | "ETag" | "Expect" | "Expect-CT" | "Expires" | "Ext" | "Forwarded" | "From" | "GetProfile" | "Hobareg" | "Host" | "HTTP2-Settings" | "If" | "If-Match" | "If-Modified-Since" | "If-None-Match" | "If-Range" | "If-Schedule-Tag-Match" | "If-Unmodified-Since" | "IM" | "Include-Referred-Token-Binding-ID" | "Isolation" | "Keep-Alive" | "Label" | "Last-Event-ID" | "Last-Modified" | "Link" | "Link-Template" | "Location" | "Lock-Token" | "Man" | "Max-Forwards" | "Memento-Datetime" | "Meter" | "Method-Check" | "Method-Check-Expires" | "MIME-Version" | "Negotiate" | "NEL" | "OData-EntityId" | "OData-Isolation" | "OData-MaxVersion" | "OData-Version" | "Opt" | "Optional-WWW-Authenticate" | "Ordering-Type" | "Origin" | "Origin-Agent-Cluster" | "OSCORE" | "OSLC-Core-Version" | "Overwrite" | "P3P" | "PEP" | "PEP-Info" | "Permissions-Policy" | "PICS-Label" | "Ping-From" | "Ping-To" | "Position" | "Pragma" | "Prefer" | "Preference-Applied" | "Priority" | "ProfileObject" | "Protocol" | "Protocol-Info" | "Protocol-Query" | "Protocol-Request" | "Proxy-Authenticate" | "Proxy-Authentication-Info" | "Proxy-Authorization" | "Proxy-Features" | "Proxy-Instruction" | "Proxy-Status" | "Public" | "Public-Key-Pins" | "Public-Key-Pins-Report-Only" | "Range" | "Redirect-Ref" | "Referer" | "Referer-Root" | "Referrer-Policy" | "Refresh" | "Repeatability-Client-ID" | "Repeatability-First-Sent" | "Repeatability-Request-ID" | "Repeatability-Result" | "Replay-Nonce" | "Reporting-Endpoints" | "Repr-Digest" | "Retry-After" | "Safe" | "Schedule-Reply" | "Schedule-Tag" | "Sec-GPC" | "Sec-Purpose" | "Sec-Token-Binding" | "Sec-WebSocket-Accept" | "Sec-WebSocket-Extensions" | "Sec-WebSocket-Key" | "Sec-WebSocket-Protocol" | "Sec-WebSocket-Version" | "Security-Scheme" | "Server" | "Server-Timing" | "Set-Cookie" | "Set-Cookie2" | "SetProfile" | "Signature" | "Signature-Input" | "SLUG" | "SoapAction" | "Status-URI" | "Strict-Transport-Security" | "Sunset" | "Surrogate-Capability" | "Surrogate-Control" | "TCN" | "TE" | "Timeout" | "Timing-Allow-Origin" | "Topic" | "Traceparent" | "Tracestate" | "Trailer" | "Transfer-Encoding" | "TTL" | "Upgrade" | "Urgency" | "URI" | "Use-As-Dictionary" | "User-Agent" | "Variant-Vary" | "Vary" | "Via" | "Want-Content-Digest" | "Want-Digest" | "Want-Repr-Digest" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-Frame-Options" | (string & {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpAdapterConfigInput } from "../../../types/http-adapter.generated.mjs";
|
|
2
|
-
import { DocumentNode } from "graphql";
|
|
2
|
+
import { DocumentNode } from "../../../vendor/graphql/language/ast.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Lowercase HTTP method keys accepted in `input`, derived from the config
|
|
5
5
|
* schema via the generated type so they cannot drift.
|
|
@@ -37,5 +37,4 @@ import { defineAIGateway } from "./aigateway/index.mjs";
|
|
|
37
37
|
import { defineIdp } from "./idp/index.mjs";
|
|
38
38
|
import { defineSecretManager } from "./secrets/index.mjs";
|
|
39
39
|
import { HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, createHttpAdapter } from "./http-adapter/http-adapter.mjs";
|
|
40
|
-
import "./http-adapter/index.mjs";
|
|
41
40
|
export { type AIGatewayConfig, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, type AuthConfig, type AuthConnectionConfig, type AuthConnectionOAuth2Config, type AuthConnectionTokenResult, type AuthExternalConfig, type AuthOwnConfig, type AuthServiceInput, type BeforeLoginClaims, type BeforeLoginHookArgs, type BuiltinIdP, type ConcurrencyPolicy, type DefinedAuth, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ExecutorServiceConfig, type ExecutorServiceInput, type FederatedIdentity, type FederatedIdentityClaims, type FederatedIdentityProvider, FunctionOperation, GqlOperation, HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, type IDToken, type IdPConfig, type IdPEmailConfig, type IdPExternalConfig, type IdPGqlOperations, type IdPGqlOperationsInput as IdPGqlOperationsConfig, type IdPPermission, type IdPPermissionCondition, type IdProvider as IdProviderConfig, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, type IsAutoFilledDBField, type IsReadOnlyDBField, type OAuth2ClientInput as OAuth2Client, type OAuth2ClientGrantType, type OIDC, Operation, ParameterizedWaitPointInstance, type PermissionCondition, type QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, type ResolvedExecutionPolicyInstance, type Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, type ResolverExternalConfig, type ResolverPermission, type ResolverPermissionCondition, type ResolverPermissionPolicy, type ResolverServiceConfig, type ResolverServiceInput, type RetryPolicy, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleArgs, ScheduleTrigger, type SecretsConfig, type StaticWebsiteConfig, type TailorAnyDBField, type TailorAnyDBType, type TailorDBField, type TailorDBInstance, TailorDBTrigger, type TailorDBType, type TailorTypeGqlPermission, type TailorTypePermission, type TenantProvider as TenantProviderConfig, Trigger, type UserAttributeKey, type UserAttributeListKey, type UserAttributes, type UsernameFieldKey, type ValueOperand, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowExecutionArgs, WorkflowExecutionCompletedArgs, WorkflowExecutionResumedArgs, WorkflowExecutionRetriedArgs, WorkflowExecutionStartedArgs, WorkflowExecutionTrigger, WorkflowExecutionWaitResolvedArgs, WorkflowExecutionWaitStartedArgs, WorkflowJob, WorkflowJobContext, WorkflowJobExecutionArgs, WorkflowJobExecutionCompletedArgs, WorkflowJobExecutionStartedArgs, WorkflowJobExecutionTrigger, WorkflowJobExecutionWaitResolvedArgs, WorkflowJobExecutionWaitStartedArgs, WorkflowOperation, type WorkflowServiceConfig, type WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineIdp, defineSecretManager, defineStaticWebSite, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission, workflowExecutionCompletedTrigger, workflowExecutionResumedTrigger, workflowExecutionRetriedTrigger, workflowExecutionStartedTrigger, workflowExecutionTrigger, workflowExecutionWaitResolvedTrigger, workflowExecutionWaitStartedTrigger, workflowJobExecutionCompletedTrigger, workflowJobExecutionStartedTrigger, workflowJobExecutionTrigger, workflowJobExecutionWaitResolvedTrigger, workflowJobExecutionWaitStartedTrigger };
|
|
@@ -11,6 +11,15 @@ export type SerialConfig<T extends "string" | "integer" = "string" | "integer">
|
|
|
11
11
|
*/
|
|
12
12
|
gapless?: boolean;
|
|
13
13
|
} & (T extends "string" ? {
|
|
14
|
+
/**
|
|
15
|
+
* printf-style text that the sequence number is written into. It holds
|
|
16
|
+
* exactly one of `%d` (decimal), `%o` (octal), `%x` (lowercase
|
|
17
|
+
* hexadecimal), or `%X` (uppercase hexadecimal), optionally with a
|
|
18
|
+
* width: `%5d` pads with spaces and `%05d` with zeros, to at least 5
|
|
19
|
+
* characters. Write a literal `%` as `%%`. The format is at most 32
|
|
20
|
+
* characters.
|
|
21
|
+
* @example db.string().serial({ start: 1, format: "INV-%05d" }) // INV-00001, INV-00002, ...
|
|
22
|
+
*/
|
|
14
23
|
format?: string;
|
|
15
24
|
} : object)>;
|
|
16
25
|
export interface DBFieldMetadata extends FieldMetadata {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{i as e}from"./resource_pb-elY668ZB.mjs";import{t}from"./assert-WeXvmG4j.mjs";import{l as n}from"./validation-errors-DqCeUW4L.mjs";import{S as r,a as i,f as a,o,p as s,r as c,t as l,u}from"./errors-9OOL3xOM.mjs";import{t as d}from"./multiline-EyzjEwn9.mjs";import{C as f,M as p,T as ee,_ as te,j as m,k as h,u as g,y as _}from"./client-DOQv-BP8.mjs";import{t as v}from"./package-json-C690ceex.mjs";import{n as y,r as b,t as ne}from"./secret-file-CSXzcg4c.mjs";import{AsyncLocalStorage as re}from"node:async_hooks";import{arg as x,extractFields as ie,parseArgv as ae,toCamelCase as oe}from"@politty/zod";import*as S from"pathe";import{z as C}from"zod";import*as w from"node:fs";import{parseEnv as se}from"node:util";import{parseYAML as ce,stringifyYAML as le}from"confbox";import{findUpSync as ue}from"find-up-simple";import{lt as de}from"semver";import{xdgConfig as T}from"xdg-basedir";import*as fe from"node:crypto";import*as pe from"node:os";const me={ms:1,s:1e3,m:6e4},E=/^(\d+)(ms|s|m)$/,he=C.string().refine(e=>E.test(e),{message:`Invalid duration format. Expected format: '3s', '500ms', '1m'`}).refine(e=>{let t=e.match(E);if(!t)return!1;let n=t[1];return n!==void 0&&parseInt(n,10)>0},{message:`Duration must be greater than 0`});function parseDuration(e){let n=t(e.match(E),`invalid duration format: ${e}`),r=parseInt(t(n[1],`duration digits group missing`),10),i=t(n[2],`duration unit group missing`);return r*me[i]}const ge=C.coerce.number().int().positive(),D=C.coerce.number().int().nonnegative(),O=C.enum([`asc`,`desc`]);function toPageDirection(t){if(t!==void 0)return t===`asc`?e.ASC:e.DESC}function optionTokens(e){let t=e.indexOf(`--`);return t===-1?e:e.slice(0,t)}function hasMachineUserFlag(e){return optionTokens(e).some(e=>e===`-m`||e.startsWith(`-m=`)||e===`--machine-user`||e.startsWith(`--machine-user=`)||e===`--machineUser`||e.startsWith(`--machineUser=`)||e===`--machineuser`||e.startsWith(`--machineuser=`))}function resolveMachineUserInputSource(e,t=process.argv.slice(2),n={}){if(e!==void 0)return n.valueIsExplicit||hasMachineUserFlag(t)?`option`:process.env.TAILOR_PLATFORM_MACHINE_USER_NAME===e?`env`:`option`}function loadEnvFiles(e,t){let n=new Set(Object.keys(process.env)),load=(e,t)=>{for(let r of[e??[]].flat()){let e=S.resolve(process.cwd(),r);if(!w.existsSync(e)){if(t)throw Error(`Environment file not found: ${e}`);continue}let i=w.readFileSync(e,`utf-8`),a=se(i);for(let[e,t]of Object.entries(a))n.has(e)||(process.env[e]=t)}};load(e,!0),load(t,!1)}const k=`json`,A=`verbose`,_e={aliasMap:/* @__PURE__ */ new Map([[`j`,k]]),booleanFlags:/* @__PURE__ */ new Set([k,A]),defaultNegationDisabledFields:/* @__PURE__ */ new Set};let j=!1;function globalArgsApplied(){return j}function parseGlobalFlag(e,t){return ae(e,_e).options[t]}function globalFlagValue(e,t,n){let r=e.indexOf(`--`);return parseGlobalFlag((r===-1?e:e.slice(0,r)).filter(e=>{let[r]=e.split(`=`,1);return r===`--${t}`||e===`--no-${t}`||n!==void 0&&r===`-${n}`}),t)}function jsonFlagRequested(e){return globalFlagValue(e,k,`j`)===!0}function requestedJsonModeSource(e){let t=globalFlagValue(e,k,`j`),n=process.env[u],r=n!==void 0&&parseGlobalFlag([`--${k}=${n}`],k)===!0;if(t===!0)return r?`both`:`flag`;if(t===void 0){if(r)return`env`;if(n===void 0&&a()!==void 0)return`agent`}}function resolveEarlyFailure(e,t){let r=globalFlagValue(t,A);typeof r==`boolean`&&(s.verbose=r);let i=requestedJsonModeSource(t);i&&(s.setJsonMode(!0,i),e instanceof Error&&Object.getPrototypeOf(e)===Error.prototype&&!Object.hasOwn(e,`code`)&&n(e,{code:`INVALID_ARGUMENTS`}))}function jsonArgSource(e){return e===`env`?`env`:e==="default"?`agent`:e===`cli`&&r(process.env.TAILOR_JSON_OUTPUT)===!0?`both`:`flag`}function createCommonArgs(e={}){return{"env-file":x(C.array(C.string()).optional(),{alias:`e`,description:`Path to an environment file, repeatable (error if not found)`,completion:{type:`file`,matcher:[`.env.*`,`.env`]}}),"env-file-if-exists":x(C.array(C.string()).optional(),{description:`Path to an environment file, repeatable (ignored if not found)`,completion:{type:`file`,matcher:[`.env.*`,`.env`]},effect:(e,{args:t})=>{loadEnvFiles(t[`env-file`],t[`env-file-if-exists`])}}),[A]:x(C.boolean().default(!1),{...e.verboseAlias===void 0?{}:{alias:e.verboseAlias},description:`Enable verbose logging`,negation:!0,effect:(e,{args:t})=>{s.verbose=t.$source?.(A)===`cli`?e:void 0}}),[k]:x(C.boolean().default(()=>a()!==void 0),{alias:`j`,description:`Output as JSON`,negation:!0,env:u,effect:(e,{args:t})=>{j=!0,s.setJsonMode(e,jsonArgSource(t.$source?.(k)))}})}}const M=createCommonArgs();function flagTokensOf(e){return[e.cliName,...e.alias??[]].flatMap(e=>e.length===1?[`-${e}`]:[`--${e}`,`--${oe(e)}`])}const ve=/* @__PURE__ */ new Map([[`env-file`,`envFiles`],[`env-file-if-exists`,`envFilesIfExists`]]),ye=new Map(ie(C.strictObject(M)).fields.flatMap(e=>{let t=ve.get(e.name);return t===void 0?[]:flagTokensOf(e).map(e=>[e,t])}));function globalBooleanAliases(e){return new Set(ie(C.strictObject(createCommonArgs(e))).fields.filter(e=>e.type===`boolean`).flatMap(e=>e.alias??[]))}function splitOptionToken(e,t){if(e.startsWith(`-`)&&!e.startsWith(`--`)&&e.length>2&&!e.includes(`=`)){let n=Array.from(e.slice(1)),r=n.findIndex(e=>!t.has(e));if(r===-1)return{flag:e,value:void 0};let i=n.slice(r+1).join(``);return{flag:`-${n[r]}`,value:i===``?void 0:i}}let n=e.indexOf(`=`);return n===-1?{flag:e,value:void 0}:{flag:e.slice(0,n),value:e.slice(n+1)}}function readEnvFileArgs(e,t={}){let n={envFiles:[],envFilesIfExists:[]},r=globalBooleanAliases(t),i=optionTokens(e);for(let e=0;e<i.length;e++){let{flag:t,value:a}=splitOptionToken(i[e]??``,r),o=ye.get(t);if(o===void 0)continue;if(a!==void 0){n[o].push(a);continue}let s=i[e+1];s!==void 0&&!s.startsWith(`-`)&&(n[o].push(s),e++)}return n}function loadEnvFilesFromArgv(e,t={}){let{envFiles:n,envFilesIfExists:r}=readEnvFileArgs(e,t);loadEnvFiles(n,r)}const N={"workspace-id":x(C.string().optional(),{alias:`w`,description:`Workspace ID`,env:`TAILOR_PLATFORM_WORKSPACE_ID`,completion:{type:`none`}}),profile:x(C.string().optional(),{alias:`p`,description:`Workspace profile`,env:`TAILOR_PLATFORM_PROFILE`,completion:{type:`none`}})},P=`tailor.config.ts`;function formatConfigArg(e){if(!e)return;let t=S.relative(process.cwd(),e);if(t!==`tailor.config.ts`)return`--config=${t}`}function recoveryContextArgs(e){return[...e.workspaceId?[`--workspace-id=${e.workspaceId}`]:[],...e.profile?[`--profile=${e.profile}`]:[]]}function profileUpdateArgs(e,t){return e.startsWith(`-`)?[`profile`,`update`,...t,`--`,e]:[`profile`,`update`,e,...t]}const F={config:x(C.string().default(P),{alias:`c`,description:`Path to Tailor config file`,env:`TAILOR_CONFIG_PATH`,completion:{type:`file`,extensions:[`ts`]}})},be={config:x(C.string().default(P),{alias:`c`,description:`Path to SDK config file. Use comma-separated paths to deploy multiple apps together.`,env:`TAILOR_CONFIG_PATH`,completion:{type:`file`,extensions:[`ts`]}})};function readDeployConfigPathEnv(){let e=process.env.TAILOR_CONFIG_PATH;if(e)return e;let t=process.env.TAILOR_PLATFORM_SDK_CONFIG_PATH;if(t)return s.warn(`TAILOR_PLATFORM_SDK_CONFIG_PATH is deprecated. Please use TAILOR_CONFIG_PATH instead.`),t}const xe={...N,...F},Se={yes:x(C.boolean().default(!1),{alias:`y`,description:`Skip confirmation prompts`})},Ce=`Pass --yes to skip the confirmation.`,we={"organization-id":x(C.string(),{alias:`o`,description:`Organization ID`,env:`TAILOR_PLATFORM_ORGANIZATION_ID`,completion:{type:`none`}})},paginationArgs=(e=`desc`)=>({order:x(O.default(e),{description:`Sort order (asc or desc)`}),limit:x(D.optional(),{alias:`l`,description:`Maximum number of items to return (0 or omit: unlimited)`})}),Te={order:x(O.default(`desc`),{description:`Sort order (asc or desc)`}),limit:x(D.default(50),{alias:`l`,description:`Maximum number of items to return (0: unlimited)`})},Ee={"folder-id":x(C.string(),{alias:`f`,description:`Folder ID`,env:`TAILOR_PLATFORM_FOLDER_ID`,completion:{type:`none`}})};function locationIds(e){let read=t=>{let n=e[t];return n===``&&e.$source?.(t)===`env`?void 0:n};return{organizationId:read(`organization-id`),folderId:read(`folder-id`)}}const I=`CONFIG_LOCK_TIMEOUT`,L=fe.randomUUID(),De=C.looseObject({pid:C.number().int(),hostname:C.string(),instanceId:C.string(),nonce:C.string(),createdAt:C.number()}),R=new re,z=/* @__PURE__ */ new Map;async function withConfigLock(e,t,n={}){let r=R.getStore();if(r?.has(e))return await t();let i=z.get(e)??Promise.resolve(),releaseLocal=()=>{},a=new Promise(e=>{releaseLocal=e}),o=i.then(()=>a);z.set(e,o),await i;try{let i=await acquireFileLock(e,n.timeoutMs??15e4);try{return await R.run(/* @__PURE__ */ new Set([...r??[],e]),t)}finally{releaseFileLock(e,i)}}finally{releaseLocal(),z.get(e)===o&&z.delete(e)}}function isConfigLockTimeout(e){return i(e)&&e.code===I}async function acquireFileLock(e,t){ne(S.dirname(e));let n=fe.randomUUID(),r=Date.now(),i=!1,a=10;for(;;){if(tryCreateLock(e,n))return n;if(reclaimIfStale(e))continue;let o=Date.now()-r;if(o>=t)throw lockTimeoutError(e);!i&&o>=3e3&&(i=!0,s.info(`Waiting for another tailor command to release ${e}...`)),await new Promise(e=>setTimeout(e,a*(.5+Math.random()))),a=Math.min(a*2,250)}}function tryCreateLock(e,t){let n;try{n=w.openSync(e,`wx`,384)}catch(e){if(e.code===`EEXIST`)return!1;throw e}let r={pid:process.pid,hostname:pe.hostname(),instanceId:L,nonce:t,createdAt:Date.now()};try{w.writeSync(n,JSON.stringify(r))}catch(t){throw w.closeSync(n),w.rmSync(e,{force:!0}),t}return w.closeSync(n),!0}function readLock(e){let t,n;try{t=w.statSync(e),n=w.readFileSync(e,`utf-8`)}catch(e){if(e.code===`ENOENT`)return;throw e}return{content:n,ino:t.ino,mtimeMs:t.mtimeMs,owner:parseOwner(n)}}function parseOwner(e){try{let t=De.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}function isStale(e){let{owner:t}=e,n=Date.now();return t?n-t.createdAt>12e4?!0:t.hostname===pe.hostname()?t.pid===process.pid?t.instanceId===L:!isProcessAlive(t.pid):!1:n-e.mtimeMs>1e4}function isProcessAlive(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function reclaimIfStale(e){let t=readLock(e);if(!t)return!0;if(!isStale(t))return!1;let n=`${e}.reclaim`;if(!tryCreateGuard(n))return!1;try{let n=readLock(e);return n?.ino===t.ino&&n.mtimeMs===t.mtimeMs&&n.content===t.content&&w.rmSync(e,{force:!0}),!0}finally{w.rmSync(n,{force:!0})}}function tryCreateGuard(e){try{return w.closeSync(w.openSync(e,`wx`,384)),!0}catch(e){if(e.code!==`EEXIST`)throw e}try{Date.now()-w.statSync(e).mtimeMs>1e4&&w.rmSync(e,{force:!0})}catch(e){if(e.code!==`ENOENT`)throw e}return!1}function releaseFileLock(e,t){readLock(e)?.owner?.nonce===t&&w.rmSync(e,{force:!0})}function lockTimeoutError(e){return l({code:I,message:`Timed out waiting for another tailor command to release ${e}.`,suggestion:`Wait for the other tailor commands to finish, then retry. If none is running, delete the lock file.`,context:{lockPath:e}})}const B=`tailor-platform-cli`;let V;async function getEntryClass(){if(V!==void 0)return V;try{V=(await import(`@napi-rs/keyring`)).Entry}catch{s.warn(`System keyring is not available. Tokens will be stored in the config file. Set TAILOR_PLATFORM_TOKEN environment variable for CI environments.`),V=!1}return V}async function isKeyringAvailable(){return await getEntryClass()!==!1}async function loadKeyringTokens(e){let t=await getEntryClass();if(!t)throw Error(`System keyring is not available.`);let n=new t(B,e).getPassword();if(n!==null)try{return JSON.parse(n)}catch{return}}async function saveKeyringTokens(e,t){let n=await getEntryClass();if(!n)throw Error(`System keyring is not available.`);new n(B,e).setPassword(JSON.stringify(t))}async function deleteKeyringTokens(e){let t=await getEntryClass();if(t)try{new t(B,e).deletePassword()}catch{}}const H=C.looseObject({user:C.string(),workspace_id:C.string(),readonly:C.boolean().optional(),machine_user:C.string().optional(),machine_user_override:C.enum([`allow`,`deny`]).optional(),platform_url:C.url().optional(),oauth2_client_id:C.string().optional(),console_url:C.url().optional()}),Oe=C.looseObject({access_token:C.string(),refresh_token:C.string().optional(),token_expires_at:C.string()}),U=C.looseObject({storage:C.literal(`keyring`),token_expires_at:C.string()}),W=C.looseObject({storage:C.literal(`file`),token_expires_at:C.string(),access_token:C.string(),refresh_token:C.string().optional()}),ke=C.discriminatedUnion(`storage`,[U,W]),G=C.strictObject({email:C.string().optional()}),K={...G.shape,default_organization_id:C.string().optional(),default_folder_id:C.string().optional()},q=U.extend(K),Ae=W.extend(K),je=C.discriminatedUnion(`storage`,[q,Ae]),Me=C.looseObject({version:C.literal(1),users:C.partialRecord(C.string(),Oe),profiles:C.partialRecord(C.string(),H),current_user:C.string().nullable()}),J=`2.0.0`,Y=C.templateLiteral([C.number().int(),`.`,C.number().int(),`.`,C.number().int()]),Ne=C.looseObject({version:C.literal(2),min_sdk_version:Y,latest_version:C.number().int().optional(),latest_min_sdk_version:Y.optional(),users:C.partialRecord(C.string(),ke),profiles:C.partialRecord(C.string(),H),current_user:C.string().nullable()}),X=C.looseObject({version:C.literal(3),min_sdk_version:Y,latest_version:C.number().int().optional(),latest_min_sdk_version:Y.optional(),users:C.partialRecord(C.string(),je),profiles:C.partialRecord(C.string(),H),current_user:C.string().nullable()});function platformConfigPath(){if(!T)throw Error(`User home directory not found`);return S.join(T,`tailor-platform`,`config.yaml`)}function platformConfigExists(){return T?w.existsSync(platformConfigPath()):!1}function platformConfigFromProfile(e){let t={...e?.platform_url?{platformUrl:e.platform_url}:{},...e?.oauth2_client_id?{oauth2ClientId:e.oauth2_client_id}:{},...e?.console_url?{consoleUrl:e.console_url}:{}};return Object.keys(t).length>0?t:void 0}function platformUserKey(e,t){let n=f(t);return n===h(`https://api.tailor.tech`)?e:`${n}|${e}`}function userFromPlatformUserKey(e,t){let n=`${f(t)}|`;return e.startsWith(n)?e.slice(n.length):e}function canUseLegacyUserKey(e){try{return f()===e}catch{return!1}}function findUserByEmail(e,t,n){let r=f(n),i=`${r}|`,a=r===h(g);return Object.entries(e).find(([e,n])=>n?.email===t?a?!e.includes(`|`):e.startsWith(i):!1)}function findUserEntry(e,t,n,r={}){let i=platformUserKey(t,n),a=e.users[i];if(a)return{userKey:i,userEntry:a};let o=findUserByEmail(e.users,t,n);if(o?.[1])return{userKey:o[0],userEntry:o[1]};let s=f(n);if(i!==t&&(r.allowLegacyUserKey===!1||!canUseLegacyUserKey(s)))return{userKey:i,userEntry:a};let c=e.users[t];return c?{userKey:t,userEntry:c}:{userKey:i,userEntry:a}}function resolveUserTokenKey(e,t,n,r){return findUserEntry(e,t,n,r).userKey}function resolveConfigUser(e,t,n,r){let{userKey:i,userEntry:a}=findUserEntry(e,t,n,r);return a?userFromPlatformUserKey(i,n):void 0}function hasUserTokenEntry(e,t,n,r){return findUserEntry(e,t,n,r).userEntry!==void 0}function hasUserKeyForName(e,t){return e[t]!==void 0||Object.keys(e).some(e=>e.endsWith(`|${t}`))}function hasUserEmailEntry(e,t){return Object.values(e).some(e=>e?.email===t)}function hasAnyUserTokenEntry(e,t){return hasUserKeyForName(e.users,t)||hasUserEmailEntry(e.users,t)}function hasCurrentUserEntry(e,t){return hasUserKeyForName(e,t)}function declaredKeys(...e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}const Z=declaredKeys(Ne),Q=declaredKeys(U,W),Pe=Q.union(declaredKeys(G)),Fe=declaredKeys(H),Ie=Z.difference(declaredKeys(Me)),Le=declaredKeys(X).difference(Z),Re=declaredKeys(q,Ae).difference(Q);function withoutKeys(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>!t.has(e)))}function migrateV1ToV2(e){let t={};for(let[n,r]of Object.entries(e.users))r&&(t[n]={...withoutKeys(r,Re),storage:`file`});return{...withoutKeys(e,Ie),version:2,min_sdk_version:`1.29.0`,users:t}}function inferEmailFromUserId(e){return C.email().safeParse(e).success?e:void 0}function migrateV2ToV3(e){let t={};for(let[n,r]of Object.entries(e.users)){if(!r)continue;let e=inferEmailFromUserId(n);t[n]={...withoutKeys(r,Re),...e?{email:e}:{}}}return{...withoutKeys(e,Le),version:3,min_sdk_version:J,users:t}}function migrateV1ToV3(e){return migrateV2ToV3(migrateV1ToV2(e))}function formatUnknownError(e){return e instanceof Error?e.message:String(e)}async function trySaveTokensInKeyring(e,t){if(!await isKeyringAvailable())return!1;try{return await saveKeyringTokens(e,t),!0}catch(e){return s.warn(`System keyring failed to store credentials. Tokens will be stored in the config file. ${formatUnknownError(e)}`),!1}}let ze=!1;async function warnIfNewerConfigAvailable(e){if(!e.latest_min_sdk_version||ze)return;let t=(await v()).version??`0.0.0`;de(t,e.latest_min_sdk_version)&&(ze=!0,s.warn(d`
|
|
2
|
+
A newer config version (${String(e.latest_version)}) is available.
|
|
3
|
+
Please update your SDK to >= ${e.latest_min_sdk_version}: pnpm update @tailor-platform/sdk
|
|
4
|
+
`))}async function readPlatformConfig(){let e=platformConfigPath();if(!w.existsSync(e)){let e={version:3,min_sdk_version:J,users:{},profiles:{},current_user:null};return writePlatformConfig(e),e}let t=ce(w.readFileSync(e,`utf-8`));y(e);let n=typeof t==`object`&&t&&`version`in t?t.version:void 0;if(typeof n==`number`&&n>3){let e=`min_sdk_version`in t?String(t.min_sdk_version):void 0,r=e?`Please update your SDK to >= ${e}: pnpm update @tailor-platform/sdk`:`Please update your SDK: pnpm update @tailor-platform/sdk`;throw Error(d`
|
|
5
|
+
Config file uses version ${String(n)}, but this SDK only supports up to version ${`3`}.
|
|
6
|
+
${r}
|
|
7
|
+
`)}let r=X.safeParse(t);if(r.success)return await warnIfNewerConfigAvailable(r.data),r.data;let i=Ne.safeParse(t);if(i.success)return await warnIfNewerConfigAvailable(i.data),migrateV2ToV3(i.data);let a=Me.safeParse(t);if(a.success)return migrateV1ToV3(a.data);throw Error(d`
|
|
8
|
+
Failed to parse config file at ${e}.
|
|
9
|
+
The file may be corrupted or created by an incompatible SDK version.
|
|
10
|
+
`)}function toV1ForDisk(e){let t={};for(let[n,r]of Object.entries(e.users))r&&r.storage!==`keyring`&&(t[n]={access_token:r.access_token,refresh_token:r.refresh_token,token_expires_at:r.token_expires_at});let n=e.current_user&&hasCurrentUserEntry(t,e.current_user)?e.current_user:null;return{version:1,users:t,profiles:e.profiles,current_user:n}}function hasProfilePlatformSettings(e){return Object.values(e.profiles).some(e=>e?.platform_url!==void 0||e?.oauth2_client_id!==void 0||e?.console_url!==void 0)}function hasScopedUserKeys(e){return Object.keys(e.users).some(e=>e.includes(`|`))}function hasKeysOutside(e,t){return e!==void 0&&Object.entries(e).some(([e,n])=>n!==void 0&&!t.has(e))}function hasFieldsUnknownToV2(e){return hasKeysOutside(e,Z)||Object.values(e.users).some(e=>hasKeysOutside(e,Q))||Object.values(e.profiles).some(e=>hasKeysOutside(e,Fe))}function toLatestForDisk(e){return{...e.version===1?migrateV1ToV2(e):e,version:3,min_sdk_version:J}}function writePlatformConfig(e){let t=platformConfigPath(),n=e.version!==1&&Object.values(e.users).some(e=>e?.storage===`keyring`),r=e.version===3||hasProfilePlatformSettings(e)||hasScopedUserKeys(e)||hasFieldsUnknownToV2(e)?toLatestForDisk(e):e.version===2&&!n?toV1ForDisk(e):e;b(t,le(r.version===1?r:{...r,users:withoutKeyringFileTokens(r.users)}))}function withoutKeyringFileTokens(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t?.storage!==`keyring`)return[e,t];let{access_token:n,refresh_token:r,...i}=t;return[e,i]}))}function validateUUID(e,t){let n=C.uuid().safeParse(e);if(!n.success)throw Error(`Invalid value from ${t}: must be a valid UUID`);return n.data}async function loadWorkspaceId(e){let t=await tryLoadWorkspaceId(e);if(t)return t;throw Error(d`
|
|
11
|
+
Workspace ID not found.
|
|
12
|
+
Please specify workspace ID via --workspace-id option or TAILOR_PLATFORM_WORKSPACE_ID environment variable.
|
|
13
|
+
`)}async function tryLoadWorkspaceId(e){let t=e?.profile||process.env.TAILOR_PLATFORM_PROFILE;if(e?.workspaceId!==void 0)return validateUUID(e.workspaceId,`--workspace-id option`);if(process.env.TAILOR_PLATFORM_WORKSPACE_ID)return validateUUID(process.env.TAILOR_PLATFORM_WORKSPACE_ID,`TAILOR_PLATFORM_WORKSPACE_ID environment variable`);if(t){let e=(await readPlatformConfig()).profiles[t]?.workspace_id;if(!e)throw o(t);return validateUUID(e,`profile "${t}"`)}}async function loadMachineUserName(e){if(e?.machineUser===``)throw l({code:`MACHINE_USER_NAME_EMPTY`,message:`Machine user name cannot be empty.`,suggestion:`Pass a non-empty machine user name, or omit the option to use the environment variable or profile default.`});let t=process.env.TAILOR_PLATFORM_MACHINE_USER_NAME||void 0,n=e?.machineUser?{source:e.machineUserSource??`option`,value:e.machineUser}:t?{source:`env`,value:t}:void 0,r=n?.value,i=e?.profile||process.env.TAILOR_PLATFORM_PROFILE;if(!i)return r;let a=(await readPlatformConfig()).profiles[i];if(!a){if(r)return r;throw o(i)}if(a.machine_user&&a.machine_user_override===`deny`){if(r&&r!==a.machine_user){let e=n.source===`env`?`The machine user is being set to "${r}" via the TAILOR_PLATFORM_MACHINE_USER_NAME environment variable, which conflicts with this profile's pinned machine user "${a.machine_user}".`:`This profile fixes the machine user to "${a.machine_user}" for application-data commands.`;throw l({code:`PROFILE_MACHINE_USER_OVERRIDE_DENIED`,message:`Profile "${i}" denies overriding the machine user.`,details:e,suggestion:`Omit the machine user option, unset TAILOR_PLATFORM_MACHINE_USER_NAME, or run ${c({command:`tailor`,args:profileUpdateArgs(i,[`--machine-user-override`,`allow`])})}.`})}return a.machine_user}return r||a.machine_user}function readEnvironmentToken(){return process.env.TAILOR_PLATFORM_TOKEN??process.env.TAILOR_TOKEN}async function loadStoredAccessTokenWithoutRefresh(e){let t=e.profile||process.env.TAILOR_PLATFORM_PROFILE,n=await readPlatformConfig(),r=t?n.profiles[t]:void 0;if(t&&!r)return;let i=r?.user??n.current_user;if(!i)return;let a=r?platformConfigFromProfile(r):void 0,o=await readStoredToken(n,i,a,loginFailureFor(t));if(!isDueForRefresh(o))return{accessToken:o.tokens.accessToken,platformConfig:a}}async function loadAccessToken(e){let t=e?.profile||process.env.TAILOR_PLATFORM_PROFILE,n=readEnvironmentToken();if(n&&!process.env.TAILOR_PLATFORM_TOKEN&&s.warn(`TAILOR_TOKEN is deprecated. Please use TAILOR_PLATFORM_TOKEN instead.`),n){s.registerSecret(n);let e=await loadPlatformClientConfig({profile:t,allowMissingProfile:!0});return p(n,e),n}let r=await readPlatformConfig(),i=t?r.profiles[t]:void 0;if(t&&!i)throw o(t);let a=i?.user??r.current_user;if(!a)throw l({code:`AUTH_TOKEN_NOT_FOUND`,message:`Tailor Platform token not found.`,suggestion:`Set TAILOR_PLATFORM_TOKEN or log in using the selected profile.`,next:{command:`tailor`,args:[`login`,...recoveryContextArgs({profile:t})]},context:{profile:t??null}});let c=i?platformConfigFromProfile(i):void 0,u=await resolveLatestToken({config:r,user:a,platformConfig:c,profile:t});return u.refreshable&&m(u.accessToken,createStoredTokenSource({token:u,platformConfig:c,profile:t})),u.accessToken}async function loadAuthStatus(e){let t=e?.profile||process.env.TAILOR_PLATFORM_PROFILE,n=readEnvironmentToken();if(n&&!process.env.TAILOR_PLATFORM_TOKEN&&s.warn(`TAILOR_TOKEN is deprecated. Please use TAILOR_PLATFORM_TOKEN instead.`),n){s.registerSecret(n);let e=await readPlatformConfig().catch(()=>void 0),r=t?e?.profiles[t]:void 0,i=r?platformConfigFromProfile(r):void 0;return{authenticated:!0,identity:null,identitySource:`environment`,profile:t??null,workspaceId:process.env.TAILOR_PLATFORM_WORKSPACE_ID??r?.workspace_id??null,permission:r?.readonly===!0?`read`:`write`,platformUrl:f(i),tokenStatus:`environment`}}let r=await readPlatformConfig(),i=t?r.profiles[t]:void 0;if(t&&!i)throw o(t);let a=i?platformConfigFromProfile(i):void 0,c=f(a),l=process.env.TAILOR_PLATFORM_WORKSPACE_ID??i?.workspace_id??null,u=i?.user??r.current_user,d=i?.user?`profile`:u?`default`:`none`,p=`missing`;if(u){let{userKey:e,userEntry:t}=findUserEntry(r,u,a);if(t){let n=await resolveTokens(t,e,u).catch(()=>void 0);n&&(p=new Date(t.token_expires_at)<=/* @__PURE__ */ new Date?n.refreshToken?`refreshable`:`expired`:`valid`)}}return{authenticated:p===`valid`||p===`refreshable`,identity:u??null,identitySource:d,profile:t??null,workspaceId:l,permission:i?.readonly===!0?`read`:`write`,platformUrl:c,tokenStatus:p}}function resolveSelectedUserEntry(e,t){let n=t?.profile||process.env.TAILOR_PLATFORM_PROFILE,r=n?e.profiles[n]:void 0;if(n&&!r)return;let i=r?.user??e.current_user,a=r?platformConfigFromProfile(r):void 0;return{profile:n,user:i,userEntry:i?findUserEntry(e,i,a,{allowLegacyUserKey:!1}).userEntry:void 0}}async function loadUserWorkspaceDefaults(e){if(readEnvironmentToken())return;let t=resolveSelectedUserEntry(await readPlatformConfig(),e)?.userEntry;if(t?.default_organization_id)return{organizationId:t.default_organization_id,...t.default_folder_id?{folderId:t.default_folder_id}:{}}}async function loadPlatformClientConfig(e){let t=e?.profile||process.env.TAILOR_PLATFORM_PROFILE;if(!t)return;let n;try{n=await readPlatformConfig()}catch(t){if(e?.allowMissingProfile)return;throw t}let r=n.profiles[t];if(!r){if(e?.allowMissingProfile)return;throw o(t)}return platformConfigFromProfile(r)}async function loadConsoleBaseUrl(e){let t=await loadPlatformClientConfig(e);return _(t)}function registerTokenSecrets(e){s.registerSecret(e.accessToken),e.refreshToken&&s.registerSecret(e.refreshToken)}async function resolveTokens(e,t,n=t){if(e.storage===`keyring`){let e;try{e=await loadKeyringTokens(t)}catch(e){throw Error(d`
|
|
14
|
+
Failed to read credentials from OS keyring for "${n}". ${formatUnknownError(e)}
|
|
15
|
+
Restore access to the OS keyring and try again, or run 'tailor login' in this environment to authenticate again.
|
|
16
|
+
For non-interactive environments, set TAILOR_PLATFORM_TOKEN.
|
|
17
|
+
`,{cause:e})}if(!e)throw Error(d`
|
|
18
|
+
Credentials not found in OS keyring for "${n}".
|
|
19
|
+
Credentials may be missing or inaccessible from this environment (for example, due to sandbox restrictions).
|
|
20
|
+
Restore access to the OS keyring and try again, or run 'tailor login' in this environment to authenticate again.
|
|
21
|
+
For non-interactive environments, set TAILOR_PLATFORM_TOKEN.
|
|
22
|
+
`);return registerTokenSecrets(e),e}let r={accessToken:e.access_token,refreshToken:e.refresh_token};return registerTokenSecrets(r),r}function userExtraFields(e){return e?withoutKeys(e,Pe):{}}async function removeUserAlias(e,t,n,r){let i=e.users[t];if(t===n||!i)return;let a=e.users[n];r.carryExtraFields&&a&&(e.users[n]={...userExtraFields(i),...a}),i.storage===`keyring`&&await deleteKeyringTokens(t),delete e.users[t]}async function saveUserTokens(e,t,n,r,i={}){registerTokenSecrets(n);let a=platformUserKey(t,i.platformConfig),o=e.users[a],s=userExtraFields(o),c=i.email??o?.email;await trySaveTokensInKeyring(a,n)?e.users[a]={...s,token_expires_at:r,storage:`keyring`,...c?{email:c}:{}}:(o?.storage===`keyring`&&await deleteKeyringTokens(a),e.users[a]={...s,access_token:n.accessToken,refresh_token:n.refreshToken,token_expires_at:r,storage:`file`,...c?{email:c}:{}})}async function deleteUserTokens(e,t,n,r){let{userKey:i,userEntry:a}=findUserEntry(e,t,n,r);a?.storage===`keyring`&&await deleteKeyringTokens(i),delete e.users[i]}async function loadStoredUserTokens(e,t,n,r){let{userKey:i,userEntry:a}=findUserEntry(e,t,n,r);if(a)return{userEntry:a,...await resolveTokens(a,i,t)}}function updateUserReferences(e,t,n){if(t!==n){e.current_user===t&&(e.current_user=n);for(let r of Object.values(e.profiles))r?.user===t&&(r.user=n)}}async function removeLegacyUserAlias(e,t,n,r){if(t===n)return;updateUserReferences(e,t,n);let i=platformUserKey(n,r);await removeUserAlias(e,platformUserKey(t,r),i,{carryExtraFields:!0}),await removeUserAlias(e,t,i,{carryExtraFields:canUseLegacyUserKey(f(r))})}function shouldResolveSubjectOnRefresh(e,t){return!!(t.email||inferEmailFromUserId(e))}async function withPlatformConfigLock(e,t){return await withConfigLock(`${platformConfigPath()}.lock`,e,t)}const Be=3e5,Ve=1e4;function expiresWithin(e,t){let n=e-Date.now();return Number.isNaN(n)||n<=t}function isExpired(e,t){return e.tokens.accessToken===t||expiresWithin(Date.parse(e.entry.token_expires_at),Ve)}function isDueForRefresh(e,t){return isExpired(e,t)||!!e.tokens.refreshToken&&expiresWithin(Date.parse(e.entry.token_expires_at),Be)}async function readStoredToken(e,t,n,r){let{userKey:i,userEntry:a}=findUserEntry(e,t,n);if(!a)throw r(`AUTH_USER_NOT_FOUND`,`User "${t}" not found.`,`Verify the selected user and use the original login method (browser or --machine-user) on the same platform.`);return{userKey:i,configUser:userFromPlatformUserKey(i,n),entry:a,tokens:await resolveTokens(a,i,t)}}function useStoredToken(e,t){return p(e.tokens.accessToken,t),{accessToken:e.tokens.accessToken,user:e.configUser,expiresAt:Date.parse(e.entry.token_expires_at),refreshable:!!e.tokens.refreshToken}}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function replaceContents(e,t){for(let n of Object.keys(e))Object.hasOwn(t,n)||delete e[n];for(let[n,r]of Object.entries(t)){let t=e[n];isRecord(t)&&isRecord(r)?replaceContents(t,r):e[n]=r}}async function fetchLatestToken(e,t,n,r){let i=await resolveLatestToken({config:e,user:t,platformConfig:n,profile:r});return{accessToken:i.accessToken,user:i.user}}function loginFailureFor(e){let t=e?[`--profile`,e]:[];return(n,r,i)=>l({code:n,message:r,suggestion:i,next:{command:`tailor`,args:[`login`,...t,`--help`]},context:{profile:e??null}})}function tokenExpiredError(e){return e(`AUTH_TOKEN_EXPIRED`,`Token expired.`,`Use the original login method (browser or --machine-user) to authenticate again on the same platform.`)}async function resolveLatestToken(e){let{config:t,user:n,platformConfig:r,profile:i,rejectedToken:a}=e,o=loginFailureFor(i),c=await readStoredToken(t,n,r,o);if(!isDueForRefresh(c,a))return useStoredToken(c,r);let l=isExpired(c,a);try{return await withPlatformConfigLock(async()=>{let n=await readPlatformConfig();try{return await refreshStoredToken({...e,config:n},o)}finally{replaceContents(t,n)}},l?void 0:{timeoutMs:2e3})}catch(t){if(l||!isConfigLockTimeout(t))throw t;return isExpired(c,a)?await resolveLatestToken(e):(s.debug(`Another tailor command is refreshing the token; using the current token.`),useStoredToken(c,r))}}async function refreshStoredToken(e,n){let{config:r,user:i,platformConfig:a,rejectedToken:o}=e,c=await readStoredToken(r,i,a,n);if(!isDueForRefresh(c,o))return useStoredToken(c,a);let{userKey:l,configUser:u,entry:d,tokens:f}=c;if(!f.refreshToken)throw tokenExpiredError(n);let m=ee(a),h;try{h=await m.refreshToken({accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:Date.parse(d.token_expires_at)})}catch(e){if(!isExpired(c,o))return s.debug(`Failed to refresh a token that has not expired yet: ${String(e)}`),useStoredToken(c,a);throw n(`AUTH_TOKEN_REFRESH_FAILED`,`Failed to refresh token. Your session may have expired.`,`Check network connectivity and platform availability, then use the original login method (browser or --machine-user) on the same platform if needed.`)}registerTokenSecrets({accessToken:h.accessToken,refreshToken:h.refreshToken??void 0});let g={accessToken:h.accessToken,refreshToken:h.refreshToken??f.refreshToken},_=new Date(t(h.expiresAt,`token refresh response missing expiresAt`)).toISOString(),v=d.email??inferEmailFromUserId(i)??inferEmailFromUserId(u);await saveUserTokens(r,u,g,_,{platformConfig:a,email:v}),writePlatformConfig(r);let y=u,b=v;if(shouldResolveSubjectOnRefresh(i,d)||shouldResolveSubjectOnRefresh(u,d))try{let e=await te(h.accessToken,a);y=e.sub,b=e.email}catch(e){s.debug(`Failed to resolve refreshed token user info: ${String(e)}`)}return(y!==u||b!==v)&&await saveUserTokens(r,y,g,_,{platformConfig:a,email:b}),await removeLegacyUserAlias(r,i,y,a),await removeUserAlias(r,l,platformUserKey(y,a),{carryExtraFields:!0}),v&&b&&v!==b&&s.info(`Updated local user email from "${v}" to "${b}".`),writePlatformConfig(r),p(h.accessToken,a),{accessToken:h.accessToken,user:y,expiresAt:Date.parse(_),refreshable:!0}}const $=3e4;function createStoredTokenSource(e){let{accessToken:t,expiresAt:n,user:r}=e.token,i,a,o=0,c=-1/0,l=-1/0,u,isUsable=()=>!expiresWithin(n,Ve),isDue=()=>expiresWithin(n,Be)&&(!isUsable()||Date.now()>=o),renew=l=>i??=(async()=>{try{let i=await resolveLatestToken({config:await readPlatformConfig(),user:r,platformConfig:e.platformConfig,profile:e.profile,rejectedToken:l});a=void 0;let s=l!==void 0&&i.accessToken!==l;i.expiresAt>n||s?({accessToken:t,expiresAt:n,user:r}=i,c=Date.now(),m(t,d)):o=Date.now()+$}catch(e){a=e instanceof Error?e:Error(String(e)),o=Date.now()+$,s.debug(`Failed to renew the access token: ${String(e)}`)}finally{i=void 0}})(),d={async current(){if(i&&t===u&&await i,!isDue()||i&&isUsable())return t;if(await renew(),!isUsable())throw a??tokenExpiredError(loginFailureFor(e.profile));return t},async replaceRejected(e){if(t!==e)return t;for(u=e;i;)await i;if(t!==e)return t;if(!(Date.now()-Math.max(c,l)<6e4))return l=Date.now(),await renew(e),t===e?void 0:t}};return d}function loadConfigPath(e){return e||(process.env.TAILOR_CONFIG_PATH?process.env.TAILOR_CONFIG_PATH:ue(`tailor.config.ts`))}export{profileUpdateArgs as $,Ce as A,globalArgsApplied as B,resolveTokens as C,withPlatformConfigLock as D,tryLoadWorkspaceId as E,xe as F,be as G,loadEnvFiles as H,he as I,we as J,D as K,flagTokensOf as L,F as M,Se as N,writePlatformConfig as O,createCommonArgs as P,ge as Q,Ee as R,resolveSelectedUserEntry as S,saveUserTokens as T,loadEnvFilesFromArgv as U,jsonFlagRequested as V,locationIds as W,paginationArgs as X,Te as Y,parseDuration as Z,readEnvironmentToken as _,loadAccessToken as a,resolveMachineUserInputSource as at,removeLegacyUserAlias as b,loadConsoleBaseUrl as c,loadStoredAccessTokenWithoutRefresh as d,readDeployConfigPathEnv as et,loadStoredUserTokens as f,platformConfigFromProfile as g,platformConfigExists as h,hasUserTokenEntry as i,resolveEarlyFailure as it,M as j,P as k,loadMachineUserName as l,loadWorkspaceId as m,fetchLatestToken as n,recoveryContextArgs as nt,loadAuthStatus as o,toPageDirection as ot,loadUserWorkspaceDefaults as p,O as q,hasAnyUserTokenEntry as r,requestedJsonModeSource as rt,loadConfigPath as s,N as st,deleteUserTokens as t,readEnvFileArgs as tt,loadPlatformClientConfig as u,readPlatformConfig as v,resolveUserTokenKey as w,resolveConfigUser as x,registerTokenSecrets as y,formatConfigArg as z};
|
|
23
|
+
//# sourceMappingURL=context-DSi5kfqr.mjs.map
|