@tailor-platform/sdk 1.32.1 → 1.33.1

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/dist/{application-p2GujXmg.mjs → application-CYPU-WIc.mjs} +58 -43
  3. package/dist/application-CYPU-WIc.mjs.map +1 -0
  4. package/dist/application-dnB8CQiT.mjs +4 -0
  5. package/dist/cli/index.d.mts +2 -2
  6. package/dist/cli/index.mjs +28 -35
  7. package/dist/cli/index.mjs.map +1 -1
  8. package/dist/cli/lib.d.mts +104 -12
  9. package/dist/cli/lib.mjs +7 -13
  10. package/dist/cli/lib.mjs.map +1 -1
  11. package/dist/cli/skills.mjs +0 -1
  12. package/dist/cli/skills.mjs.map +1 -1
  13. package/dist/{client-D5P1myz0.mjs → client-CYGsf3Zl.mjs} +91 -27
  14. package/dist/client-CYGsf3Zl.mjs.map +1 -0
  15. package/dist/{client-gpRgZl1b.mjs → client-ea1w8SmG.mjs} +1 -4
  16. package/dist/configure/index.d.mts +5 -5
  17. package/dist/configure/index.mjs +81 -12
  18. package/dist/configure/index.mjs.map +1 -1
  19. package/dist/crash-report-CbueUPaP.mjs +4 -0
  20. package/dist/{crash-report-DnwITWeV.mjs → crash-report-OXafT1iS.mjs} +3 -3
  21. package/dist/{crash-report-DnwITWeV.mjs.map → crash-report-OXafT1iS.mjs.map} +1 -1
  22. package/dist/{enum-constants-CkKARYb7.mjs → enum-constants-DI85-fPE.mjs} +2 -1
  23. package/dist/{enum-constants-CkKARYb7.mjs.map → enum-constants-DI85-fPE.mjs.map} +1 -1
  24. package/dist/{env-BZLTIlIo.d.mts → env-BvIWsJxg.d.mts} +2 -2
  25. package/dist/{file-utils-D2TxR_kj.mjs → file-utils-C4rXlOVt.mjs} +2 -1
  26. package/dist/{file-utils-D2TxR_kj.mjs.map → file-utils-C4rXlOVt.mjs.map} +1 -1
  27. package/dist/{index-CgMytw2A.d.mts → index-0H-YH8Ya.d.mts} +3 -2
  28. package/dist/{index-vVGamLOw.d.mts → index-BM2SqNfO.d.mts} +3 -2
  29. package/dist/{index-CoReoodF.d.mts → index-BU6fmwJC.d.mts} +3 -2
  30. package/dist/{index-BYk_9R3S.d.mts → index-DlivLpTN.d.mts} +145 -32
  31. package/dist/{index-BQKAzTPA.d.mts → index-mAV9kYJA.d.mts} +3 -2
  32. package/dist/{interceptor-1LL1gBsF.mjs → interceptor-f7slMkCC.mjs} +1 -2
  33. package/dist/{interceptor-1LL1gBsF.mjs.map → interceptor-f7slMkCC.mjs.map} +1 -1
  34. package/dist/kysely/index.d.mts +5 -1
  35. package/dist/kysely/index.mjs +0 -1
  36. package/dist/kysely/index.mjs.map +1 -1
  37. package/dist/{kysely-type-BK0b4Rqt.mjs → kysely-type-BwMqaL3z.mjs} +18 -7
  38. package/dist/kysely-type-BwMqaL3z.mjs.map +1 -0
  39. package/dist/{package-json-VqyFvGiP.mjs → package-json-CfUqjJaQ.mjs} +1 -1
  40. package/dist/{package-json-VqyFvGiP.mjs.map → package-json-CfUqjJaQ.mjs.map} +1 -1
  41. package/dist/package-json-D5Km1jjt.mjs +4 -0
  42. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  43. package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
  44. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  45. package/dist/plugin/builtin/file-utils/index.mjs +1 -2
  46. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  47. package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
  48. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  49. package/dist/plugin/builtin/seed/index.mjs +1 -2
  50. package/dist/plugin/index.d.mts +2 -2
  51. package/dist/plugin/index.mjs +0 -1
  52. package/dist/plugin/index.mjs.map +1 -1
  53. package/dist/{plugin-IIDZW9GG.d.mts → plugin-DQqzlulP.d.mts} +46 -33
  54. package/dist/{runtime-7DOyTTxR.mjs → runtime-CDvdBV66.mjs} +1032 -306
  55. package/dist/runtime-CDvdBV66.mjs.map +1 -0
  56. package/dist/{schema-BITbkmq3.mjs → schema-D27cW0Ca.mjs} +2 -1
  57. package/dist/schema-D27cW0Ca.mjs.map +1 -0
  58. package/dist/seed/index.mjs +0 -1
  59. package/dist/seed/index.mjs.map +1 -1
  60. package/dist/{seed-BXrSEJbv.mjs → seed-BZIFDG27.mjs} +11 -3
  61. package/dist/seed-BZIFDG27.mjs.map +1 -0
  62. package/dist/telemetry-C508zIi1.mjs +4 -0
  63. package/dist/{telemetry-B4sp-dD2.mjs → telemetry-CREcGK8y.mjs} +2 -2
  64. package/dist/{telemetry-B4sp-dD2.mjs.map → telemetry-CREcGK8y.mjs.map} +1 -1
  65. package/dist/utils/test/index.d.mts +2 -2
  66. package/dist/utils/test/index.mjs +0 -2
  67. package/dist/utils/test/index.mjs.map +1 -1
  68. package/dist/{workflow.generated-C2A5Ye0m.d.mts → workflow.generated-u9MgzqbM.d.mts} +14 -3
  69. package/docs/cli/application.md +17 -0
  70. package/docs/cli/auth.md +1 -1
  71. package/docs/cli/crash-report.md +1 -1
  72. package/docs/cli/executor.md +2 -2
  73. package/docs/cli/secret.md +3 -3
  74. package/docs/cli/staticwebsite.md +1 -1
  75. package/docs/cli/tailordb.md +4 -2
  76. package/docs/cli/user.md +2 -2
  77. package/docs/cli-reference.md +116 -100
  78. package/docs/generator/builtin.md +1 -1
  79. package/docs/services/executor.md +54 -0
  80. package/docs/services/idp.md +22 -0
  81. package/package.json +20 -20
  82. package/dist/application-Cwt_ifTT.mjs +0 -12
  83. package/dist/application-p2GujXmg.mjs.map +0 -1
  84. package/dist/chunk-COzJYswC.mjs +0 -9
  85. package/dist/client-D5P1myz0.mjs.map +0 -1
  86. package/dist/crash-report-Cm9vFmTN.mjs +0 -7
  87. package/dist/kysely-type-BK0b4Rqt.mjs.map +0 -1
  88. package/dist/package-json-88x7bPKC.mjs +0 -5
  89. package/dist/runtime-7DOyTTxR.mjs.map +0 -1
  90. package/dist/schema-BITbkmq3.mjs.map +0 -1
  91. package/dist/seed-BXrSEJbv.mjs.map +0 -1
  92. package/dist/telemetry-DXIGGa6A.mjs +0 -5
@@ -1,15 +1,15 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { C as TailorDBType, Ct as IncomingWebhookTrigger, Et as ScheduleTriggerInput, Mt as IdProvider, Nt as OAuth2ClientInput, mt as Resolver, n as Plugin, r as PluginAttachment, vt as Executor, w as TypeSourceInfoEntry } from "../plugin-IIDZW9GG.mjs";
3
- import { n as AppConfig } from "../workflow.generated-C2A5Ye0m.mjs";
4
- import { n as kyselyTypePlugin } from "../index-CgMytw2A.mjs";
5
- import { n as enumConstantsPlugin } from "../index-vVGamLOw.mjs";
6
- import { n as fileUtilsPlugin } from "../index-BQKAzTPA.mjs";
7
- import { n as seedPlugin } from "../index-CoReoodF.mjs";
2
+ import { C as TailorDBType, Ct as IncomingWebhookTrigger, Mt as IdProvider, Nt as OAuth2ClientInput, Tt as ScheduleTriggerInput, mt as Resolver, n as Plugin, r as PluginAttachment, vt as Executor, w as TypeSourceInfoEntry } from "../plugin-DQqzlulP.mjs";
3
+ import { n as AppConfig } from "../workflow.generated-u9MgzqbM.mjs";
4
+ import { n as kyselyTypePlugin } from "../index-0H-YH8Ya.mjs";
5
+ import { n as enumConstantsPlugin } from "../index-BM2SqNfO.mjs";
6
+ import { n as fileUtilsPlugin } from "../index-mAV9kYJA.mjs";
7
+ import { n as seedPlugin } from "../index-BU6fmwJC.mjs";
8
8
  import { z } from "zod";
9
9
  import { OAuth2Client } from "@badgateway/oauth2-client";
10
10
  import { Duration, FieldMask, Timestamp, Value } from "@bufbuild/protobuf/wkt";
11
11
  import { Client } from "@connectrpc/connect";
12
- import * as _bufbuild_protobuf_codegenv20 from "@bufbuild/protobuf/codegenv2";
12
+ import * as _$_bufbuild_protobuf_codegenv20 from "@bufbuild/protobuf/codegenv2";
13
13
  import { GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
14
14
  import { JsonObject, Message } from "@bufbuild/protobuf";
15
15
  import { Jsonifiable } from "type-fest";
@@ -4922,6 +4922,10 @@ declare type AuthConnection = Message<"tailor.v1.AuthConnection"> & {
4922
4922
  * @generated from field: google.protobuf.Timestamp created_at = 5;
4923
4923
  */
4924
4924
  createdAt?: Timestamp;
4925
+ /**
4926
+ * @generated from field: tailor.v1.AuthConnection.Status status = 6;
4927
+ */
4928
+ status: AuthConnection_Status;
4925
4929
  };
4926
4930
  /**
4927
4931
  * @generated from message tailor.v1.AuthConnection.AuthConnectionOAuth2Config
@@ -4973,6 +4977,23 @@ declare enum AuthConnection_Type {
4973
4977
  */
4974
4978
  OAUTH2 = 1
4975
4979
  }
4980
+ /**
4981
+ * @generated from enum tailor.v1.AuthConnection.Status
4982
+ */
4983
+ declare enum AuthConnection_Status {
4984
+ /**
4985
+ * @generated from enum value: STATUS_UNSPECIFIED = 0;
4986
+ */
4987
+ UNSPECIFIED = 0,
4988
+ /**
4989
+ * @generated from enum value: STATUS_UNAUTHORIZED = 1;
4990
+ */
4991
+ UNAUTHORIZED = 1,
4992
+ /**
4993
+ * @generated from enum value: STATUS_AUTHORIZED = 2;
4994
+ */
4995
+ AUTHORIZED = 2
4996
+ }
4976
4997
  /**
4977
4998
  * @generated from message tailor.v1.AuthOAuth2Client
4978
4999
  */
@@ -9785,6 +9806,10 @@ declare type FunctionExecution = Message<"tailor.v1.FunctionExecution"> & {
9785
9806
  * @generated from field: tailor.v1.FunctionErrorInfo error = 10;
9786
9807
  */
9787
9808
  error?: FunctionErrorInfo;
9809
+ /**
9810
+ * @generated from field: tailor.v1.FunctionErrorKind error_kind = 11;
9811
+ */
9812
+ errorKind: FunctionErrorKind;
9788
9813
  };
9789
9814
  /**
9790
9815
  * @generated from enum tailor.v1.FunctionExecution.Status
@@ -9824,6 +9849,31 @@ declare enum FunctionExecution_Type {
9824
9849
  */
9825
9850
  JOB = 2
9826
9851
  }
9852
+ /**
9853
+ * @generated from enum tailor.v1.FunctionErrorKind
9854
+ */
9855
+ declare enum FunctionErrorKind {
9856
+ /**
9857
+ * @generated from enum value: FUNCTION_ERROR_KIND_UNSPECIFIED = 0;
9858
+ */
9859
+ UNSPECIFIED = 0,
9860
+ /**
9861
+ * @generated from enum value: FUNCTION_ERROR_KIND_NONE = 1;
9862
+ */
9863
+ NONE = 1,
9864
+ /**
9865
+ * @generated from enum value: FUNCTION_ERROR_KIND_USER_RUNTIME = 2;
9866
+ */
9867
+ USER_RUNTIME = 2,
9868
+ /**
9869
+ * @generated from enum value: FUNCTION_ERROR_KIND_USER_NON_RUNTIME = 3;
9870
+ */
9871
+ USER_NON_RUNTIME = 3,
9872
+ /**
9873
+ * @generated from enum value: FUNCTION_ERROR_KIND_PLATFORM = 4;
9874
+ */
9875
+ PLATFORM = 4
9876
+ }
9827
9877
  //#endregion
9828
9878
  //#region ../tailor-proto/src/tailor/v1/function_pb.d.ts
9829
9879
  /**
@@ -10664,6 +10714,10 @@ declare type IdPService = Message<"tailor.v1.IdPService"> & {
10664
10714
  * @generated from field: tailor.v1.IdPDisableGqlOperations disable_gql_operations = 7;
10665
10715
  */
10666
10716
  disableGqlOperations?: IdPDisableGqlOperations;
10717
+ /**
10718
+ * @generated from field: tailor.v1.IdPEmailConfig email_config = 8;
10719
+ */
10720
+ emailConfig?: IdPEmailConfig;
10667
10721
  };
10668
10722
  /**
10669
10723
  * IdPDisableGqlOperations controls which IdP-related GraphQL operations are disabled.
@@ -10702,6 +10756,25 @@ declare type IdPDisableGqlOperations = Message<"tailor.v1.IdPDisableGqlOperation
10702
10756
  */
10703
10757
  sendPasswordResetEmail: boolean;
10704
10758
  };
10759
+ /**
10760
+ * IdPEmailConfig holds namespace-level email configuration defaults.
10761
+ *
10762
+ * @generated from message tailor.v1.IdPEmailConfig
10763
+ */
10764
+ declare type IdPEmailConfig = Message<"tailor.v1.IdPEmailConfig"> & {
10765
+ /**
10766
+ * from_name is the default sender display name for emails. Empty means use mailer default.
10767
+ *
10768
+ * @generated from field: string from_name = 1;
10769
+ */
10770
+ fromName: string;
10771
+ /**
10772
+ * password_reset_subject is the default subject for password reset emails. Empty means use localized default.
10773
+ *
10774
+ * @generated from field: string password_reset_subject = 2;
10775
+ */
10776
+ passwordResetSubject: string;
10777
+ };
10705
10778
  /**
10706
10779
  * @generated from message tailor.v1.IdPClient
10707
10780
  */
@@ -10902,6 +10975,10 @@ declare type CreateIdPServiceRequest = Message<"tailor.v1.CreateIdPServiceReques
10902
10975
  * @generated from field: tailor.v1.IdPDisableGqlOperations disable_gql_operations = 7;
10903
10976
  */
10904
10977
  disableGqlOperations?: IdPDisableGqlOperations;
10978
+ /**
10979
+ * @generated from field: tailor.v1.IdPEmailConfig email_config = 8;
10980
+ */
10981
+ emailConfig?: IdPEmailConfig;
10905
10982
  };
10906
10983
  /**
10907
10984
  * Describes the message tailor.v1.CreateIdPServiceRequest.
@@ -10959,6 +11036,10 @@ declare type UpdateIdPServiceRequest = Message<"tailor.v1.UpdateIdPServiceReques
10959
11036
  * @generated from field: tailor.v1.IdPDisableGqlOperations disable_gql_operations = 7;
10960
11037
  */
10961
11038
  disableGqlOperations?: IdPDisableGqlOperations;
11039
+ /**
11040
+ * @generated from field: tailor.v1.IdPEmailConfig email_config = 8;
11041
+ */
11042
+ emailConfig?: IdPEmailConfig;
10962
11043
  };
10963
11044
  /**
10964
11045
  * Describes the message tailor.v1.UpdateIdPServiceRequest.
@@ -11657,7 +11738,11 @@ declare enum WorkflowJobExecution_Status {
11657
11738
  /**
11658
11739
  * @generated from enum value: STATUS_FAILED = 4;
11659
11740
  */
11660
- FAILED = 4
11741
+ FAILED = 4,
11742
+ /**
11743
+ * @generated from enum value: STATUS_WAITING = 5;
11744
+ */
11745
+ WAITING = 5
11661
11746
  }
11662
11747
  /**
11663
11748
  * @generated from message tailor.v1.WorkflowExecution
@@ -11727,7 +11812,11 @@ declare enum WorkflowExecution_Status {
11727
11812
  /**
11728
11813
  * @generated from enum value: STATUS_PENDING_RETRY = 6;
11729
11814
  */
11730
- PENDING_RETRY = 6
11815
+ PENDING_RETRY = 6,
11816
+ /**
11817
+ * @generated from enum value: STATUS_WAITING = 7;
11818
+ */
11819
+ WAITING = 7
11731
11820
  }
11732
11821
  //#endregion
11733
11822
  //#region ../tailor-proto/src/tailor/v1/workflow_pb.d.ts
@@ -12400,7 +12489,7 @@ declare type GetMetadataResponse = Message<"tailor.v1.GetMetadataResponse"> & {
12400
12489
  */
12401
12490
  declare const GetMetadataResponseSchema: GenMessage<GetMetadataResponse>;
12402
12491
  //#endregion
12403
- //#region ../tailor-proto/src/tailor/v1/telemetry_export_resource_pb.d.ts
12492
+ //#region ../tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.ts
12404
12493
  /**
12405
12494
  * @generated from message tailor.v1.TelemetryExport
12406
12495
  */
@@ -12543,7 +12632,7 @@ declare enum TelemetryExportProtocol {
12543
12632
  HTTP = 2
12544
12633
  }
12545
12634
  //#endregion
12546
- //#region ../tailor-proto/src/tailor/v1/telemetry_export_pb.d.ts
12635
+ //#region ../tailor-proto/src/tailor/v1/telemetryrouter_pb.d.ts
12547
12636
  /**
12548
12637
  * @generated from message tailor.v1.CreateTelemetryExportRequest
12549
12638
  */
@@ -15863,7 +15952,7 @@ type OperatorClient = Client<typeof OperatorService>;
15863
15952
  * @param accessToken - Access token for authentication
15864
15953
  * @returns Configured Operator client
15865
15954
  */
15866
- declare function initOperatorClient(accessToken: string): Promise<Client<_bufbuild_protobuf_codegenv20.GenService<{
15955
+ declare function initOperatorClient(accessToken: string): Promise<Client<_$_bufbuild_protobuf_codegenv20.GenService<{
15867
15956
  ping: {
15868
15957
  methodKind: "unary";
15869
15958
  input: typeof PingRequestSchema;
@@ -18280,8 +18369,11 @@ declare const INITIAL_SCHEMA_NUMBER = 0;
18280
18369
  * Migration file names (used within migration directories)
18281
18370
  */
18282
18371
  declare const SCHEMA_FILE_NAME = "schema.json";
18372
+ /** File name for migration diff metadata. */
18283
18373
  declare const DIFF_FILE_NAME = "diff.json";
18374
+ /** File name for migration script. */
18284
18375
  declare const MIGRATE_FILE_NAME = "migrate.ts";
18376
+ /** File name for generated DB type definitions. */
18285
18377
  declare const DB_TYPES_FILE_NAME = "db.ts";
18286
18378
  /**
18287
18379
  * Hook configuration in schema snapshot
package/dist/cli/lib.mjs CHANGED
@@ -1,17 +1,11 @@
1
1
 
2
- import "../chunk-COzJYswC.mjs";
3
- import "../schema-BITbkmq3.mjs";
4
- import "../brand-0SscafcY.mjs";
5
- import "../logger-qz-Y4sBV.mjs";
6
- import { $ as getFolder, $t as getNextMigrationNumber, A as listWorkflows, Bt as DB_TYPES_FILE_NAME, C as listApps, Et as getWorkflow, F as show, Ft as executeScript, G as listOrganizations, Gt as compareLocalTypesWithSnapshot, H as organizationTree, Ht as INITIAL_SCHEMA_NUMBER, It as waitForExecution, Kt as compareSnapshots, Lt as MIGRATION_LABEL_KEY, N as generate$1, Nt as getExecutor, O as resumeWorkflow, Ot as getWorkflowExecution, Pt as apply, Qt as getMigrationFiles, R as remove, S as createWorkspace, St as watchExecutorJob, T as getAppHealth, Ut as MIGRATE_FILE_NAME, V as updateOrganization, Vt as DIFF_FILE_NAME, Wt as SCHEMA_FILE_NAME, Xt as getMigrationDirPath, Y as updateFolder, Yt as getLatestMigrationNumber, Z as listFolders, Zt as getMigrationFilePath, an as hasChanges, at as listOAuth2Clients, b as deleteWorkspace, c as removeUser, ct as getMachineUserToken, dn as apiCall, dt as listMachineUsers, f as inviteUser, ft as generate, g as listWorkspaces, gt as triggerExecutor, in as formatMigrationDiff, j as truncate, kt as listWorkflowExecutions, m as restoreWorkspace, n as query, nn as reconstructSnapshotFromMigrations, o as updateUser, on as getNamespacesWithMigrations, pt as listWebhookExecutors, q as getOrganization, qt as createSnapshotFromLocalTypes, rn as formatDiffSummary, rt as createFolder, st as getOAuth2Client, t as isNativeTypeScriptRuntime, tt as deleteFolder, u as listUsers, un as generateUserTypes, v as getWorkspace, vt as listExecutors, wt as startWorkflow, xt as listExecutorJobs, yt as getExecutorJob, zt as bundleMigrationScript } from "../runtime-7DOyTTxR.mjs";
7
- import { u as initOperatorClient } from "../client-D5P1myz0.mjs";
8
- import "../package-json-VqyFvGiP.mjs";
9
- import { a as loadConfig, b as loadAccessToken, g as getDistDir, x as loadWorkspaceId } from "../application-p2GujXmg.mjs";
10
- import { n as seedPlugin } from "../seed-BXrSEJbv.mjs";
11
- import { n as enumConstantsPlugin } from "../enum-constants-CkKARYb7.mjs";
12
- import { n as fileUtilsPlugin } from "../file-utils-D2TxR_kj.mjs";
13
- import { n as kyselyTypePlugin } from "../kysely-type-BK0b4Rqt.mjs";
14
- import "../telemetry-B4sp-dD2.mjs";
2
+ import { u as initOperatorClient } from "../client-CYGsf3Zl.mjs";
3
+ import { $ as getFolder, $t as getNextMigrationNumber, A as listWorkflows, Bt as DB_TYPES_FILE_NAME, C as listApps, Et as getWorkflow, F as show, Ft as executeScript, G as listOrganizations, Gt as compareLocalTypesWithSnapshot, H as organizationTree, Ht as INITIAL_SCHEMA_NUMBER, It as waitForExecution, Kt as compareSnapshots, Lt as MIGRATION_LABEL_KEY, N as generate$1, Nt as getExecutor, O as resumeWorkflow, Ot as getWorkflowExecution, Pt as apply, Qt as getMigrationFiles, R as remove, S as createWorkspace, St as watchExecutorJob, T as getAppHealth, Ut as MIGRATE_FILE_NAME, V as updateOrganization, Vt as DIFF_FILE_NAME, Wt as SCHEMA_FILE_NAME, Xt as getMigrationDirPath, Y as updateFolder, Yt as getLatestMigrationNumber, Z as listFolders, Zt as getMigrationFilePath, an as hasChanges, at as listOAuth2Clients, b as deleteWorkspace, c as removeUser, ct as getMachineUserToken, dn as apiCall, dt as listMachineUsers, f as inviteUser, ft as generate, g as listWorkspaces, gt as triggerExecutor, in as formatMigrationDiff, j as truncate, kt as listWorkflowExecutions, m as restoreWorkspace, n as query, nn as reconstructSnapshotFromMigrations, o as updateUser, on as getNamespacesWithMigrations, pt as listWebhookExecutors, q as getOrganization, qt as createSnapshotFromLocalTypes, rn as formatDiffSummary, rt as createFolder, st as getOAuth2Client, t as isNativeTypeScriptRuntime, tt as deleteFolder, u as listUsers, un as generateUserTypes, v as getWorkspace, vt as listExecutors, wt as startWorkflow, xt as listExecutorJobs, yt as getExecutorJob, zt as bundleMigrationScript } from "../runtime-CDvdBV66.mjs";
4
+ import { a as loadConfig, b as loadAccessToken, g as getDistDir, x as loadWorkspaceId } from "../application-CYPU-WIc.mjs";
5
+ import { n as seedPlugin } from "../seed-BZIFDG27.mjs";
6
+ import { n as enumConstantsPlugin } from "../enum-constants-DI85-fPE.mjs";
7
+ import { n as fileUtilsPlugin } from "../file-utils-C4rXlOVt.mjs";
8
+ import { n as kyselyTypePlugin } from "../kysely-type-BwMqaL3z.mjs";
15
9
  import * as fs from "node:fs";
16
10
  import * as path from "pathe";
17
11
  import { resolveTSConfig } from "pkg-types";
@@ -1 +1 @@
1
- {"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => data[type] && data[type].length > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = data[type];\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, number>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<string, number> = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = 0;\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of records) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName] += 1;\n }\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length} (one-by-one)\\`);\n } else {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName] += batch.length;\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length}\\`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n\n // Generate seed script content\n const entryContent = generateSeedScriptContent(namespace);\n fs.writeFileSync(entryPath, entryContent);\n\n let tsconfig: string | undefined;\n try {\n tsconfig = await resolveTSConfig();\n } catch {\n tsconfig = undefined;\n }\n\n // Bundle with tree-shaking (write: false to avoid unnecessary disk I/O)\n const result = await rolldown.build({\n input: entryPath,\n write: false,\n output: {\n format: \"esm\",\n sourcemap: false,\n minify: false,\n codeSplitting: false,\n globals: {\n tailordb: \"tailordb\",\n },\n },\n external: [\"tailordb\"],\n resolve: {\n conditionNames: [\"node\", \"import\"],\n },\n tsconfig,\n treeshake: {\n moduleSideEffects: false,\n annotations: true,\n unknownGlobalSideEffects: false,\n },\n logLevel: \"silent\",\n } as rolldown.BuildOptions);\n\n const bundledCode = result.output[0].code;\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { isNativeTypeScriptRuntime } from \"./shared/runtime\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically.\n// Bun and Deno handle TypeScript natively, so registration is skipped.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"node:module\");\n register(\"tsx\", import.meta.url, { data: {} });\n}\n\nexport { apply } from \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\nexport type { BundledScripts } from \"./commands/apply/function-registry\";\nexport { generate } from \"./commands/generate/service\";\nexport type { GenerateOptions } from \"./commands/generate/options\";\nexport { loadConfig, type LoadedConfig } from \"./shared/config-loader\";\nexport { generateUserTypes } from \"./shared/type-generator\";\nexport type {\n CodeGenerator,\n TailorDBGenerator,\n ResolverGenerator,\n ExecutorGenerator,\n TailorDBResolverGenerator,\n FullCodeGenerator,\n TailorDBInput,\n ResolverInput,\n ExecutorInput,\n FullInput,\n AggregateArgs,\n GeneratorResult,\n DependencyKind,\n PluginAttachment,\n TypeSourceInfoEntry,\n} from \"./commands/generate/types\";\nexport type { TailorDBType } from \"@/types/tailordb\";\nexport type { Resolver } from \"@/types/resolver.generated\";\nexport type { Executor } from \"@/types/executor.generated\";\n\n/** @deprecated Import from '@tailor-platform/sdk/plugin/kysely-type' instead */\nexport { kyselyTypePlugin } from \"@/plugin/builtin/kysely-type\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"@/plugin/builtin/enum-constants\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"@/plugin/builtin/file-utils\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"@/plugin/builtin/seed\";\n\nexport { show, type ShowOptions, type ApplicationInfo } from \"./commands/show\";\nexport { remove, type RemoveOptions } from \"./commands/remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./commands/workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./commands/workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./commands/workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./commands/workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./commands/workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./commands/workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./commands/workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./commands/workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./commands/workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./commands/workspace/user/remove\";\nexport type { UserInfo } from \"./commands/workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./commands/workspace/app/list\";\nexport {\n getAppHealth,\n type HealthOptions as GetAppHealthOptions,\n} from \"./commands/workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./commands/workspace/app/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./commands/machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./commands/machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./commands/oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./commands/oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./commands/oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./commands/workflow/list\";\nexport {\n getWorkflow,\n type GetWorkflowOptions,\n type GetWorkflowTypedOptions,\n} from \"./commands/workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./commands/workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n} from \"./commands/workflow/executions\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./commands/workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./commands/workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./commands/executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type ListExecutorJobsTypedOptions,\n type GetExecutorJobOptions,\n type GetExecutorJobTypedOptions,\n type WatchExecutorJobOptions,\n type WatchExecutorJobTypedOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./commands/executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./commands/executor/list\";\nexport {\n getExecutor,\n type GetExecutorOptions,\n type GetExecutorTypedOptions,\n} from \"./commands/executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./commands/executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./commands/executor/transform\";\nexport { listOrganizations, type ListOrganizationsOptions } from \"./commands/organization/list\";\nexport { getOrganization, type GetOrganizationOptions } from \"./commands/organization/get\";\nexport { updateOrganization, type UpdateOrganizationOptions } from \"./commands/organization/update\";\nexport { organizationTree, type OrganizationTreeOptions } from \"./commands/organization/tree\";\nexport type {\n UserOrganizationInfo,\n OrganizationInfo,\n FolderListInfo,\n FolderInfo,\n} from \"./commands/organization/transform\";\nexport { listFolders, type ListFoldersOptions } from \"./commands/organization/folder/list\";\nexport { getFolder, type GetFolderOptions } from \"./commands/organization/folder/get\";\nexport { createFolder, type CreateFolderOptions } from \"./commands/organization/folder/create\";\nexport { updateFolder, type UpdateFolderOptions } from \"./commands/organization/folder/update\";\nexport { deleteFolder, type DeleteFolderOptions } from \"./commands/organization/folder/delete\";\nexport { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eA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;;;;;;;;;;;;;;6BAcR,UAAU;;;;;;+BAMR,UAAU;;;;;;6BAMZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC,eAAsB,iBACpB,WACA,WAC2B;CAE3B,MAAM,YAAY,KAAK,QAAQ,YAAY,EAAE,OAAO;AACpD,IAAG,UAAU,WAAW,EAAE,WAAW,MAAM,CAAC;CAG5C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,WAAW;CAGpE,MAAM,eAAe,0BAA0B,UAAU;AACzD,IAAG,cAAc,WAAW,aAAa;CAEzC,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,iBAAiB;SAC5B;AACN,aAAW;;AA+Bb,QAAO;EACL;EACA,cA7Ba,MAAM,SAAS,MAAM;GAClC,OAAO;GACP,OAAO;GACP,QAAQ;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,eAAe;IACf,SAAS,EACP,UAAU,YACX;IACF;GACD,UAAU,CAAC,WAAW;GACtB,SAAS,EACP,gBAAgB,CAAC,QAAQ,SAAS,EACnC;GACD;GACA,WAAW;IACT,mBAAmB;IACnB,aAAa;IACb,0BAA0B;IAC3B;GACD,UAAU;GACX,CAA0B,EAEA,OAAO,GAAG;EAKnC,eAAe;EAChB;;;;;AC9JH,IAAI,CAAC,2BAA2B,EAAE;CAChC,MAAM,EAAE,aAAa,MAAM,OAAO;AAClC,UAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => data[type] && data[type].length > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = data[type];\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, number>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<string, number> = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = 0;\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of records) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName] += 1;\n }\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length} (one-by-one)\\`);\n } else {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName] += batch.length;\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length}\\`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n\n // Generate seed script content\n const entryContent = generateSeedScriptContent(namespace);\n fs.writeFileSync(entryPath, entryContent);\n\n let tsconfig: string | undefined;\n try {\n tsconfig = await resolveTSConfig();\n } catch {\n tsconfig = undefined;\n }\n\n // Bundle with tree-shaking (write: false to avoid unnecessary disk I/O)\n const result = await rolldown.build({\n input: entryPath,\n write: false,\n output: {\n format: \"esm\",\n sourcemap: false,\n minify: false,\n codeSplitting: false,\n globals: {\n tailordb: \"tailordb\",\n },\n },\n external: [\"tailordb\"],\n resolve: {\n conditionNames: [\"node\", \"import\"],\n },\n tsconfig,\n treeshake: {\n moduleSideEffects: false,\n annotations: true,\n unknownGlobalSideEffects: false,\n },\n logLevel: \"silent\",\n } as rolldown.BuildOptions);\n\n const bundledCode = result.output[0].code;\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { isNativeTypeScriptRuntime } from \"./shared/runtime\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically.\n// Bun and Deno handle TypeScript natively, so registration is skipped.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"node:module\");\n register(\"tsx\", import.meta.url, { data: {} });\n}\n\nexport { apply } from \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\nexport type { BundledScripts } from \"./commands/apply/function-registry\";\nexport { generate } from \"./commands/generate/service\";\nexport type { GenerateOptions } from \"./commands/generate/options\";\nexport { loadConfig, type LoadedConfig } from \"./shared/config-loader\";\nexport { generateUserTypes } from \"./shared/type-generator\";\nexport type {\n CodeGenerator,\n TailorDBGenerator,\n ResolverGenerator,\n ExecutorGenerator,\n TailorDBResolverGenerator,\n FullCodeGenerator,\n TailorDBInput,\n ResolverInput,\n ExecutorInput,\n FullInput,\n AggregateArgs,\n GeneratorResult,\n DependencyKind,\n PluginAttachment,\n TypeSourceInfoEntry,\n} from \"./commands/generate/types\";\nexport type { TailorDBType } from \"@/types/tailordb\";\nexport type { Resolver } from \"@/types/resolver.generated\";\nexport type { Executor } from \"@/types/executor.generated\";\n\n/** @deprecated Import from '@tailor-platform/sdk/plugin/kysely-type' instead */\nexport { kyselyTypePlugin } from \"@/plugin/builtin/kysely-type\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"@/plugin/builtin/enum-constants\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"@/plugin/builtin/file-utils\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"@/plugin/builtin/seed\";\n\nexport { show, type ShowOptions, type ApplicationInfo } from \"./commands/show\";\nexport { remove, type RemoveOptions } from \"./commands/remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./commands/workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./commands/workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./commands/workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./commands/workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./commands/workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./commands/workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./commands/workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./commands/workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./commands/workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./commands/workspace/user/remove\";\nexport type { UserInfo } from \"./commands/workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./commands/workspace/app/list\";\nexport {\n getAppHealth,\n type HealthOptions as GetAppHealthOptions,\n} from \"./commands/workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./commands/workspace/app/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./commands/machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./commands/machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./commands/oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./commands/oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./commands/oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./commands/workflow/list\";\nexport {\n getWorkflow,\n type GetWorkflowOptions,\n type GetWorkflowTypedOptions,\n} from \"./commands/workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./commands/workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n} from \"./commands/workflow/executions\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./commands/workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./commands/workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./commands/executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type ListExecutorJobsTypedOptions,\n type GetExecutorJobOptions,\n type GetExecutorJobTypedOptions,\n type WatchExecutorJobOptions,\n type WatchExecutorJobTypedOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./commands/executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./commands/executor/list\";\nexport {\n getExecutor,\n type GetExecutorOptions,\n type GetExecutorTypedOptions,\n} from \"./commands/executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./commands/executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./commands/executor/transform\";\nexport { listOrganizations, type ListOrganizationsOptions } from \"./commands/organization/list\";\nexport { getOrganization, type GetOrganizationOptions } from \"./commands/organization/get\";\nexport { updateOrganization, type UpdateOrganizationOptions } from \"./commands/organization/update\";\nexport { organizationTree, type OrganizationTreeOptions } from \"./commands/organization/tree\";\nexport type {\n UserOrganizationInfo,\n OrganizationInfo,\n FolderListInfo,\n FolderInfo,\n} from \"./commands/organization/transform\";\nexport { listFolders, type ListFoldersOptions } from \"./commands/organization/folder/list\";\nexport { getFolder, type GetFolderOptions } from \"./commands/organization/folder/get\";\nexport { createFolder, type CreateFolderOptions } from \"./commands/organization/folder/create\";\nexport { updateFolder, type UpdateFolderOptions } from \"./commands/organization/folder/update\";\nexport { deleteFolder, type DeleteFolderOptions } from \"./commands/organization/folder/delete\";\nexport { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;AAClD,KAAI,aAAa,EACf,OAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,uCAErF;CAIH,MAAM,gBAAgB,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,SAAS,EAAE;AAEjF,KAAI,cAAc,WAAW,EAC3B,QAAO,EAAE;AAKX,KAAI,SADY,KAAK,UAAU;EAAE;EAAM;EAAO,CAAC,CAC1B,IAAI,UACvB,QAAO,CAAC;EAAE;EAAM;EAAO,OAAO;EAAG,OAAO;EAAG,CAAC;CAI9C,MAAM,SAAqC,EAAE;CAC7C,IAAI,cAAwB,EAAE;CAC9B,IAAI,eAAyB,EAAE;AAE/B,MAAK,MAAM,QAAQ,eAAe;EAChC,MAAM,cAAc,KAAK;AAGzB,MAAI,aAAa,SAAS,GAAG;GAC3B,MAAM,WAAW;IAAE,GAAG;KAAc,OAAO;IAAa;GACxD,MAAM,YAAY,CAAC,GAAG,cAAc,KAAK;AACzC,OAAI,SAAS,KAAK,UAAU;IAAE,MAAM;IAAU,OAAO;IAAW,CAAC,CAAC,GAAG,WAAW;AAE9E,WAAO,KAAK;KAAE,MAAM;KAAa,OAAO;KAAc,OAAO,OAAO;KAAQ,CAAC;AAC7E,kBAAc,EAAE;AAChB,mBAAe,EAAE;;;AAKrB,MAAI,SAAS,KAAK,UAAU;GAAE,MAAM,GAAG,OAAO,aAAa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AO;AAClC,UAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "../chunk-COzJYswC.mjs";
4
3
  import { spawn } from "node:child_process";
5
4
 
6
5
  //#region src/cli/shared/skills-installer.ts
@@ -1 +1 @@
1
- {"version":3,"file":"skills.mjs","names":[],"sources":["../../src/cli/shared/skills-installer.ts","../../src/cli/skills.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\n\nexport const SKILL_NAME = \"tailor-sdk\";\nexport const DEFAULT_SKILLS_SOURCE =\n \"https://github.com/tailor-platform/sdk/tree/main/packages/sdk/skills\";\nconst SKILLS_SOURCE_ENV_KEY = \"TAILOR_SDK_SKILLS_SOURCE\";\n\ninterface ChildProcessLike {\n on(event: \"close\", listener: (code: number | null) => void): ChildProcessLike;\n on(event: \"error\", listener: (error: Error) => void): ChildProcessLike;\n}\n\ntype SpawnLike = (\n command: string,\n args: string[],\n options: { stdio: \"inherit\" },\n) => ChildProcessLike;\n\ninterface RunSkillsInstallerOptions {\n additionalArgs?: string[];\n source?: string;\n spawnFn?: SpawnLike;\n}\n\nfunction resolveNpxCommand(platform: NodeJS.Platform = process.platform): string {\n return platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n}\n\nfunction resolveSkillsSource(source?: string): string {\n return source ?? process.env[SKILLS_SOURCE_ENV_KEY] ?? DEFAULT_SKILLS_SOURCE;\n}\n\n/**\n * Build CLI arguments for `skills add` with the fixed tailor-sdk skill target.\n * @param additionalArgs - Additional options to pass through to `skills add`\n * @param source - Optional skill source URL or path\n * @returns CLI arguments for `npx skills add`\n */\nexport function buildSkillsAddArgs(additionalArgs: readonly string[], source?: string): string[] {\n return [\"skills\", \"add\", resolveSkillsSource(source), \"--skill\", SKILL_NAME, ...additionalArgs];\n}\n\n/**\n * Run `npx skills add` to install the tailor-sdk skill.\n * @param options - Runtime options for skill installation\n * @returns Process exit code from the spawned `npx` command\n */\nexport async function runSkillsInstaller(options: RunSkillsInstallerOptions = {}): Promise<number> {\n const args = buildSkillsAddArgs(options.additionalArgs ?? [], options.source);\n const spawnFn =\n options.spawnFn ??\n ((command: string, spawnArgs: string[], spawnOptions: { stdio: \"inherit\" }) =>\n spawn(command, spawnArgs, spawnOptions));\n\n const childProcess = spawnFn(resolveNpxCommand(), args, { stdio: \"inherit\" });\n\n return await new Promise<number>((resolve, reject) => {\n childProcess.on(\"error\", (error) => reject(error));\n childProcess.on(\"close\", (code) => resolve(code ?? 1));\n });\n}\n","#!/usr/bin/env node\n\nimport { runSkillsInstaller } from \"./shared/skills-installer\";\n\nconst exitCode = await runSkillsInstaller({\n additionalArgs: process.argv.slice(2),\n});\n\nprocess.exit(exitCode);\n"],"mappings":";;;;;;AAEA,MAAa,aAAa;AAC1B,MAAa,wBACX;AACF,MAAM,wBAAwB;AAmB9B,SAAS,kBAAkB,WAA4B,QAAQ,UAAkB;AAC/E,QAAO,aAAa,UAAU,YAAY;;AAG5C,SAAS,oBAAoB,QAAyB;AACpD,QAAO,UAAU,QAAQ,IAAI;;;;;;;;AAS/B,SAAgB,mBAAmB,gBAAmC,QAA2B;AAC/F,QAAO;EAAC;EAAU;EAAO,oBAAoB,OAAO;EAAE;EAAW;EAAY,GAAG;EAAe;;;;;;;AAQjG,eAAsB,mBAAmB,UAAqC,EAAE,EAAmB;CACjG,MAAM,OAAO,mBAAmB,QAAQ,kBAAkB,EAAE,EAAE,QAAQ,OAAO;CAM7E,MAAM,gBAJJ,QAAQ,aACN,SAAiB,WAAqB,iBACtC,MAAM,SAAS,WAAW,aAAa,GAEd,mBAAmB,EAAE,MAAM,EAAE,OAAO,WAAW,CAAC;AAE7E,QAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;AACpD,eAAa,GAAG,UAAU,UAAU,OAAO,MAAM,CAAC;AAClD,eAAa,GAAG,UAAU,SAAS,QAAQ,QAAQ,EAAE,CAAC;GACtD;;;;;ACvDJ,MAAM,WAAW,MAAM,mBAAmB,EACxC,gBAAgB,QAAQ,KAAK,MAAM,EAAE,EACtC,CAAC;AAEF,QAAQ,KAAK,SAAS"}
1
+ {"version":3,"file":"skills.mjs","names":[],"sources":["../../src/cli/shared/skills-installer.ts","../../src/cli/skills.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\n\nexport const SKILL_NAME = \"tailor-sdk\";\nexport const DEFAULT_SKILLS_SOURCE =\n \"https://github.com/tailor-platform/sdk/tree/main/packages/sdk/skills\";\nconst SKILLS_SOURCE_ENV_KEY = \"TAILOR_SDK_SKILLS_SOURCE\";\n\ninterface ChildProcessLike {\n on(event: \"close\", listener: (code: number | null) => void): ChildProcessLike;\n on(event: \"error\", listener: (error: Error) => void): ChildProcessLike;\n}\n\ntype SpawnLike = (\n command: string,\n args: string[],\n options: { stdio: \"inherit\" },\n) => ChildProcessLike;\n\ninterface RunSkillsInstallerOptions {\n additionalArgs?: string[];\n source?: string;\n spawnFn?: SpawnLike;\n}\n\nfunction resolveNpxCommand(platform: NodeJS.Platform = process.platform): string {\n return platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n}\n\nfunction resolveSkillsSource(source?: string): string {\n return source ?? process.env[SKILLS_SOURCE_ENV_KEY] ?? DEFAULT_SKILLS_SOURCE;\n}\n\n/**\n * Build CLI arguments for `skills add` with the fixed tailor-sdk skill target.\n * @param additionalArgs - Additional options to pass through to `skills add`\n * @param source - Optional skill source URL or path\n * @returns CLI arguments for `npx skills add`\n */\nexport function buildSkillsAddArgs(additionalArgs: readonly string[], source?: string): string[] {\n return [\"skills\", \"add\", resolveSkillsSource(source), \"--skill\", SKILL_NAME, ...additionalArgs];\n}\n\n/**\n * Run `npx skills add` to install the tailor-sdk skill.\n * @param options - Runtime options for skill installation\n * @returns Process exit code from the spawned `npx` command\n */\nexport async function runSkillsInstaller(options: RunSkillsInstallerOptions = {}): Promise<number> {\n const args = buildSkillsAddArgs(options.additionalArgs ?? [], options.source);\n const spawnFn =\n options.spawnFn ??\n ((command: string, spawnArgs: string[], spawnOptions: { stdio: \"inherit\" }) =>\n spawn(command, spawnArgs, spawnOptions));\n\n const childProcess = spawnFn(resolveNpxCommand(), args, { stdio: \"inherit\" });\n\n return await new Promise<number>((resolve, reject) => {\n childProcess.on(\"error\", (error) => reject(error));\n childProcess.on(\"close\", (code) => resolve(code ?? 1));\n });\n}\n","#!/usr/bin/env node\n\nimport { runSkillsInstaller } from \"./shared/skills-installer\";\n\nconst exitCode = await runSkillsInstaller({\n additionalArgs: process.argv.slice(2),\n});\n\nprocess.exit(exitCode);\n"],"mappings":";;;;;AAEA,MAAa,aAAa;AAC1B,MAAa,wBACX;AACF,MAAM,wBAAwB;AAmB9B,SAAS,kBAAkB,WAA4B,QAAQ,UAAkB;AAC/E,QAAO,aAAa,UAAU,YAAY;;AAG5C,SAAS,oBAAoB,QAAyB;AACpD,QAAO,UAAU,QAAQ,IAAI;;;;;;;;AAS/B,SAAgB,mBAAmB,gBAAmC,QAA2B;AAC/F,QAAO;EAAC;EAAU;EAAO,oBAAoB,OAAO;EAAE;EAAW;EAAY,GAAG;EAAe;;;;;;;AAQjG,eAAsB,mBAAmB,UAAqC,EAAE,EAAmB;CACjG,MAAM,OAAO,mBAAmB,QAAQ,kBAAkB,EAAE,EAAE,QAAQ,OAAO;CAM7E,MAAM,gBAJJ,QAAQ,aACN,SAAiB,WAAqB,iBACtC,MAAM,SAAS,WAAW,aAAa,GAEd,mBAAmB,EAAE,MAAM,EAAE,OAAO,WAAW,CAAC;AAE7E,QAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;AACpD,eAAa,GAAG,UAAU,UAAU,OAAO,MAAM,CAAC;AAClD,eAAa,GAAG,UAAU,SAAS,QAAQ,QAAQ,EAAE,CAAC;GACtD;;;;;ACvDJ,MAAM,WAAW,MAAM,mBAAmB,EACxC,gBAAgB,QAAQ,KAAK,MAAM,EAAE,EACtC,CAAC;AAEF,QAAQ,KAAK,SAAS"}