@tailor-platform/sdk 1.6.2 → 1.7.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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#503](https://github.com/tailor-platform/sdk/pull/503) [`d6d16e2`](https://github.com/tailor-platform/sdk/commit/d6d16e26f329088926eb07d89d0c7dbbefc0bcd5) Thanks [@r253hmdryou](https://github.com/r253hmdryou)! - reject configs with both userProfile and machineUserAttributes
8
+
9
+ ### Patch Changes
10
+
11
+ - [#512](https://github.com/tailor-platform/sdk/pull/512) [`8cf6a9b`](https://github.com/tailor-platform/sdk/commit/8cf6a9b52075dd511f691709eb5779e9b05ce767) Thanks [@toiroakr](https://github.com/toiroakr)! - Improve CLI table output formatting: humanize Date fields, pretty-print JSON objects, and output empty array in JSON mode for list commands
12
+
13
+ - [#502](https://github.com/tailor-platform/sdk/pull/502) [`080053f`](https://github.com/tailor-platform/sdk/commit/080053fb56fcc9fd28bcd1b1400094a8c35d4d17) Thanks [@riku99](https://github.com/riku99)! - Add workspace info to show command'
14
+
15
+ - [#509](https://github.com/tailor-platform/sdk/pull/509) [`502050f`](https://github.com/tailor-platform/sdk/commit/502050f0946a1c314ef4c8d2a79ce924973b0daa) Thanks [@riku99](https://github.com/riku99)! - Delete profile when deleting workspace
16
+
17
+ ## 1.6.3
18
+
19
+ ### Patch Changes
20
+
21
+ - [#505](https://github.com/tailor-platform/sdk/pull/505) [`c3329a9`](https://github.com/tailor-platform/sdk/commit/c3329a991ab7fc2f60dc4558ba33ea60ed18394e) Thanks [@k1LoW](https://github.com/k1LoW)! - Add actor field to executor event trigger args
22
+
23
+ - Added `TailorActor` type to represent actors in event triggers
24
+ - Added `actor` field to `EventArgs` interface (nullable)
25
+ - Field names are aligned with `TailorUser` for consistency (`attributes`, `attributeList`)
26
+ - Added transformation in executor bundler to convert server field names to SDK field names
27
+
28
+ - [#489](https://github.com/tailor-platform/sdk/pull/489) [`2f17481`](https://github.com/tailor-platform/sdk/commit/2f17481f26577249c8dd0ac93d1b04b0f91cb377) Thanks [@riku99](https://github.com/riku99)! - Moved executor service config types to parser and updated CLI imports
29
+
3
30
  ## 1.6.2
4
31
 
5
32
  ### Patch Changes
@@ -83,6 +83,40 @@ const TYPE_COLORS = {
83
83
  log: (text) => text
84
84
  };
85
85
  /**
86
+ * Parses a log tag in "mode:indent" format
87
+ * @param tag - Tag string (e.g., "default:4", "stream:2", "plain:0")
88
+ * @returns Parsed mode and indent values
89
+ */
90
+ function parseLogTag(tag) {
91
+ const [mode, indentStr] = (tag || "default:0").split(":");
92
+ return {
93
+ mode,
94
+ indent: Number(indentStr) || 0
95
+ };
96
+ }
97
+ /**
98
+ * Builds a log tag from LogOptions
99
+ * @param opts - Log options
100
+ * @returns Tag string in "mode:indent" format
101
+ */
102
+ function buildLogTag(opts) {
103
+ return `${opts?.mode ?? "default"}:${opts?.indent ?? 0}`;
104
+ }
105
+ /**
106
+ * Formats a log line with the appropriate prefix and indentation
107
+ * @param opts - Formatting options
108
+ * @returns Formatted log line
109
+ */
110
+ function formatLogLine(opts) {
111
+ const { mode, indent, type, message, timestamp } = opts;
112
+ const indentPrefix = indent > 0 ? " ".repeat(indent) : "";
113
+ const colorFn = TYPE_COLORS[type] || ((text) => text);
114
+ if (mode === "plain") return `${indentPrefix}${colorFn(message)}\n`;
115
+ const icon = TYPE_ICONS[type] || "";
116
+ const coloredOutput = colorFn(`${icon ? `${icon} ` : ""}${message}`);
117
+ return `${indentPrefix}${timestamp ?? ""}${coloredOutput}\n`;
118
+ }
119
+ /**
86
120
  * Creates a reporter that handles all log output modes.
87
121
  *
88
122
  * Supports three modes controlled via logObj.tag:
@@ -93,7 +127,7 @@ const TYPE_COLORS = {
93
127
  */
94
128
  function createReporter() {
95
129
  return { log(logObj, ctx) {
96
- const mode = logObj.tag || "default";
130
+ const { mode, indent } = parseLogTag(logObj.tag);
97
131
  const stdout = ctx.options.stdout || process.stdout;
98
132
  const stderr = ctx.options.stderr || process.stderr;
99
133
  const formatOptions = ctx.options.formatOptions;
@@ -101,15 +135,15 @@ function createReporter() {
101
135
  breakLength: stdout.columns || 80,
102
136
  compact: formatOptions.compact
103
137
  }, ...logObj.args);
104
- const colorFn = TYPE_COLORS[logObj.type] || ((text) => text);
105
- if (mode === "plain") {
106
- stderr.write(`${colorFn(message)}\n`);
107
- return;
108
- }
109
- const icon = TYPE_ICONS[logObj.type] || "";
110
- const coloredOutput = colorFn(`${icon ? `${icon} ` : ""}${message}`);
111
138
  const timestamp = mode === "stream" && logObj.date ? `${logObj.date.toLocaleTimeString()} ` : "";
112
- stderr.write(`${timestamp}${coloredOutput}\n`);
139
+ const output = formatLogLine({
140
+ mode,
141
+ indent,
142
+ type: logObj.type,
143
+ message,
144
+ timestamp
145
+ });
146
+ stderr.write(output);
113
147
  } };
114
148
  }
115
149
  const consola = createConsola({
@@ -124,20 +158,16 @@ const logger = {
124
158
  _jsonMode = value;
125
159
  },
126
160
  info(message, opts) {
127
- const mode = opts?.mode ?? "default";
128
- consola.withTag(mode).info(message);
161
+ consola.withTag(buildLogTag(opts)).info(message);
129
162
  },
130
163
  success(message, opts) {
131
- const mode = opts?.mode ?? "default";
132
- consola.withTag(mode).success(message);
164
+ consola.withTag(buildLogTag(opts)).success(message);
133
165
  },
134
166
  warn(message, opts) {
135
- const mode = opts?.mode ?? "default";
136
- consola.withTag(mode).warn(message);
167
+ consola.withTag(buildLogTag(opts)).warn(message);
137
168
  },
138
169
  error(message, opts) {
139
- const mode = opts?.mode ?? "default";
140
- consola.withTag(mode).error(message);
170
+ consola.withTag(buildLogTag(opts)).error(message);
141
171
  },
142
172
  log(message) {
143
173
  consola.withTag("plain").log(message);
@@ -148,7 +178,7 @@ const logger = {
148
178
  debug(message) {
149
179
  if (process.env.DEBUG === "true") consola.withTag("plain").log(styles.dim(message));
150
180
  },
151
- out(data$1) {
181
+ out(data$1, options) {
152
182
  if (typeof data$1 === "string") {
153
183
  process.stdout.write(data$1.endsWith("\n") ? data$1 : data$1 + "\n");
154
184
  return;
@@ -157,26 +187,23 @@ const logger = {
157
187
  console.log(JSON.stringify(data$1));
158
188
  return;
159
189
  }
190
+ const formatValue = (value, pretty = false) => {
191
+ if (value === null || value === void 0) return "N/A";
192
+ if (value instanceof Date) return formatDistanceToNowStrict(value, { addSuffix: true });
193
+ if (typeof value === "object") return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
194
+ return String(value);
195
+ };
160
196
  if (!Array.isArray(data$1)) {
161
- const t$1 = table(Object.entries(data$1), {
162
- singleLine: true,
197
+ const t$1 = table(Object.entries(data$1).filter(([key]) => !options?.excludeFields?.includes(key)).map(([key, value]) => [key, formatValue(value, true)]), {
198
+ singleLine: false,
163
199
  border: getBorderCharacters("norc")
164
200
  });
165
201
  process.stdout.write(t$1);
166
202
  return;
167
203
  }
168
204
  if (data$1.length === 0) return;
169
- const headers = Array.from(new Set(data$1.flatMap((item) => Object.keys(item))));
170
- const t = table([headers, ...data$1.map((item) => headers.map((header) => {
171
- const value = item[header];
172
- if (value === null || value === void 0) return "";
173
- if ((header === "createdAt" || header === "updatedAt") && typeof value === "string") {
174
- const date = new Date(value);
175
- if (Number.isNaN(date.getTime())) return value;
176
- return formatDistanceToNowStrict(date, { addSuffix: true });
177
- }
178
- return String(value);
179
- }))], {
205
+ const headers = Array.from(new Set(data$1.flatMap((item) => Object.keys(item)))).filter((h) => !options?.excludeFields?.includes(h));
206
+ const t = table([headers, ...data$1.map((item) => headers.map((header) => formatValue(item[header])))], {
180
207
  border: getBorderCharacters("norc"),
181
208
  drawHorizontalLine: (lineIndex, rowCount) => {
182
209
  return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
@@ -97823,17 +97850,25 @@ const MachineUserSchema = z.object({
97823
97850
  attributes: z.record(z.string(), ValueOperandSchema).optional(),
97824
97851
  attributeList: z.array(z.uuid()).optional()
97825
97852
  });
97826
- const AuthConfigSchema = z.object({
97853
+ const AuthConfigBaseSchema = z.object({
97827
97854
  name: z.string(),
97828
- userProfile: UserProfileSchema.optional(),
97829
- machineUserAttributes: z.record(z.string(), TailorFieldSchema).optional(),
97830
97855
  machineUsers: z.record(z.string(), MachineUserSchema).optional(),
97831
97856
  oauth2Clients: z.record(z.string(), OAuth2ClientSchema).optional(),
97832
97857
  idProvider: IdProviderSchema.optional(),
97833
97858
  scim: SCIMSchema.optional(),
97834
97859
  tenantProvider: TenantProviderSchema.optional(),
97835
97860
  publishSessionEvents: z.boolean().optional()
97836
- }).brand("AuthConfig");
97861
+ });
97862
+ const AuthConfigSchema = z.union([AuthConfigBaseSchema.extend({
97863
+ userProfile: z.undefined().optional(),
97864
+ machineUserAttributes: z.undefined().optional()
97865
+ }), z.xor([AuthConfigBaseSchema.extend({
97866
+ userProfile: UserProfileSchema,
97867
+ machineUserAttributes: z.undefined().optional()
97868
+ }), AuthConfigBaseSchema.extend({
97869
+ userProfile: z.undefined().optional(),
97870
+ machineUserAttributes: z.record(z.string(), TailorFieldSchema)
97871
+ })])]).brand("AuthConfig");
97837
97872
 
97838
97873
  //#endregion
97839
97874
  //#region src/cli/application/auth/service.ts
@@ -98261,4 +98296,4 @@ function defineApplication(config) {
98261
98296
 
98262
98297
  //#endregion
98263
98298
  export { OAuth2ClientSchema as a, tailorUserMap as c, styles as d, symbols as f, ExecutorSchema as i, loadFilesWithIgnores as l, WorkflowJobSchema as n, ResolverSchema as o, WorkflowSchema as r, stringifyFunction as s, defineApplication as t, logger as u };
98264
- //# sourceMappingURL=application-4cO5Zvfo.mjs.map
98299
+ //# sourceMappingURL=application-Ba2B5A-w.mjs.map