@tailor-platform/sdk 1.6.3 → 1.8.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/{application-4cO5Zvfo.mjs → application-HIu5peO4.mjs} +111 -46
  3. package/dist/application-HIu5peO4.mjs.map +1 -0
  4. package/dist/application-ViV4dYwI.mjs +4 -0
  5. package/dist/cli/index.mjs +65 -53
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +134 -25
  8. package/dist/cli/lib.mjs +3 -4
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/configure/index.d.mts +3 -3
  11. package/dist/configure/index.mjs +778 -2
  12. package/dist/configure/index.mjs.map +1 -1
  13. package/dist/{index-DRFnAgt_.d.mts → index-BwJ7-efr.d.mts} +74 -30
  14. package/dist/{index-BqMqXRal.d.mts → index-Dkm2qwmF.d.mts} +153 -191
  15. package/dist/{jiti-SMSW3TA0.mjs → jiti-ygK9KoRA.mjs} +1 -1
  16. package/dist/{jiti-SMSW3TA0.mjs.map → jiti-ygK9KoRA.mjs.map} +1 -1
  17. package/dist/{job-8XfvLyxH.mjs → job-l-pIR9IY.mjs} +1 -1
  18. package/dist/{job-8XfvLyxH.mjs.map → job-l-pIR9IY.mjs.map} +1 -1
  19. package/dist/{list-DFvkudMF.mjs → list-D1K7WwpV.mjs} +3084 -2362
  20. package/dist/list-D1K7WwpV.mjs.map +1 -0
  21. package/dist/{src-qLXX6nub.mjs → src-CG8kJBI9.mjs} +1 -1
  22. package/dist/{src-qLXX6nub.mjs.map → src-CG8kJBI9.mjs.map} +1 -1
  23. package/dist/utils/test/index.d.mts +2 -2
  24. package/dist/utils/test/index.mjs +1 -1
  25. package/docs/cli/application.md +114 -35
  26. package/docs/cli/auth.md +101 -44
  27. package/docs/cli/executor.md +149 -0
  28. package/docs/cli/secret.md +133 -51
  29. package/docs/cli/staticwebsite.md +78 -41
  30. package/docs/cli/tailordb.md +227 -155
  31. package/docs/cli/user.md +164 -66
  32. package/docs/cli/workflow.md +132 -73
  33. package/docs/cli/workspace.md +126 -45
  34. package/docs/cli-reference.md +9 -0
  35. package/docs/generator/custom.md +2 -2
  36. package/docs/services/auth.md +88 -1
  37. package/package.json +3 -1
  38. package/dist/application-3rIUD7cq.mjs +0 -5
  39. package/dist/application-4cO5Zvfo.mjs.map +0 -1
  40. package/dist/auth-0Zh4xp4z.mjs +0 -772
  41. package/dist/auth-0Zh4xp4z.mjs.map +0 -1
  42. package/dist/list-DFvkudMF.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#515](https://github.com/tailor-platform/sdk/pull/515) [`fce8058`](https://github.com/tailor-platform/sdk/commit/fce80580d49d784feb232918341c5643da2d96dc) Thanks [@toiroakr](https://github.com/toiroakr)! - Add Kysely utility types (Transaction, Insertable, Selectable, Updateable) to generated code
8
+
9
+ - [#521](https://github.com/tailor-platform/sdk/pull/521) [`fa17d60`](https://github.com/tailor-platform/sdk/commit/fa17d601d8e3a13e593eb5f1da6cbf5c6802a034) Thanks [@toiroakr](https://github.com/toiroakr)! - Add `display` option to `logger.out` for field transformation and exclusion in non-JSON mode
10
+
11
+ ### Patch Changes
12
+
13
+ - [#519](https://github.com/tailor-platform/sdk/pull/519) [`3124bb2`](https://github.com/tailor-platform/sdk/commit/3124bb2bd755fe9fe9f781b6dadc28472d11969b) Thanks [@riku99](https://github.com/riku99)! - Normalized packages/sdk/src/cli/application/index.ts imports to use parser and enabled the ESLint/Oxlint rule blocking cli → configure imports (tests excluded).
14
+
15
+ - [#508](https://github.com/tailor-platform/sdk/pull/508) [`49d3fd5`](https://github.com/tailor-platform/sdk/commit/49d3fd5a255607145ce28c895dbdd2d94bea80b7) Thanks [@haru0017](https://github.com/haru0017)! - Transform webhook args `raw_body` to `rawBody` in executor bundler
16
+
17
+ - [#484](https://github.com/tailor-platform/sdk/pull/484) [`56ee4ff`](https://github.com/tailor-platform/sdk/commit/56ee4ff2dc23bd275ef9556c47363315e9d4e981) Thanks [@riku99](https://github.com/riku99)! - Updated imports of confgure tailordb and resolver in cli
18
+
19
+ ## 1.7.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#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
24
+
25
+ ### Patch Changes
26
+
27
+ - [#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
28
+
29
+ - [#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'
30
+
31
+ - [#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
32
+
3
33
  ## 1.6.3
4
34
 
5
35
  ### 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,34 @@ const logger = {
157
187
  console.log(JSON.stringify(data$1));
158
188
  return;
159
189
  }
190
+ const display = options?.display;
191
+ const formatValue = (value, pretty = false) => {
192
+ if (value === null || value === void 0) return "N/A";
193
+ if (value instanceof Date) return formatDistanceToNowStrict(value, { addSuffix: true });
194
+ if (typeof value === "object") return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
195
+ return String(value);
196
+ };
197
+ const isExcluded = (key) => {
198
+ return display !== void 0 && key in display && display[key] === null;
199
+ };
200
+ const transformValue = (key, value, item, pretty = false) => {
201
+ if (display && key in display) {
202
+ const transformer = display[key];
203
+ if (transformer) return transformer(value, item);
204
+ }
205
+ return formatValue(value, pretty);
206
+ };
160
207
  if (!Array.isArray(data$1)) {
161
- const t$1 = table(Object.entries(data$1), {
162
- singleLine: true,
208
+ const t$1 = table(Object.entries(data$1).filter(([key]) => !isExcluded(key)).map(([key, value]) => [key, transformValue(key, value, data$1, true)]), {
209
+ singleLine: false,
163
210
  border: getBorderCharacters("norc")
164
211
  });
165
212
  process.stdout.write(t$1);
166
213
  return;
167
214
  }
168
215
  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
- }))], {
216
+ const headers = Array.from(new Set(data$1.flatMap((item) => Object.keys(item)))).filter((h) => !isExcluded(h));
217
+ const t = table([headers, ...data$1.map((item) => headers.map((header) => transformValue(header, item[header], item)))], {
180
218
  border: getBorderCharacters("norc"),
181
219
  drawHorizontalLine: (lineIndex, rowCount) => {
182
220
  return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
@@ -411,6 +449,7 @@ const relationTypes = {
411
449
  "N-1": "n-1",
412
450
  keyOnly: "keyOnly"
413
451
  };
452
+ const relationTypesKeys = Object.keys(relationTypes);
414
453
  function fieldRef(context) {
415
454
  return `Field "${context.fieldName}" on type "${context.typeName}"`;
416
455
  }
@@ -420,8 +459,8 @@ function fieldRef(context) {
420
459
  * @param context - Context information for the relation (type name, field name, all type names)
421
460
  */
422
461
  function validateRelationConfig(rawRelation, context) {
423
- if (!rawRelation.type) throw new Error(`${fieldRef(context)} has a relation but is missing the required 'type' property. Valid values: ${Object.keys(relationTypes).join(", ")}.`);
424
- if (!(rawRelation.type in relationTypes)) throw new Error(`${fieldRef(context)} has invalid relation type '${rawRelation.type}'. Valid values: ${Object.keys(relationTypes).join(", ")}.`);
462
+ if (!rawRelation.type) throw new Error(`${fieldRef(context)} has a relation but is missing the required 'type' property. Valid values: ${relationTypesKeys.join(", ")}.`);
463
+ if (!(rawRelation.type in relationTypes)) throw new Error(`${fieldRef(context)} has invalid relation type '${rawRelation.type}'. Valid values: ${relationTypesKeys.join(", ")}.`);
425
464
  if (rawRelation.toward.type !== "self" && !context.allTypeNames.has(rawRelation.toward.type)) throw new Error(`${fieldRef(context)} references unknown type "${rawRelation.toward.type}".`);
426
465
  }
427
466
  /**
@@ -86211,7 +86250,7 @@ var require_config_loader = /* @__PURE__ */ __commonJSMin(((exports, module) =>
86211
86250
  * @returns {Promise<{createJiti: Function|undefined, version: string;}>} A promise that fulfills with an object containing the jiti module's createJiti function and version.
86212
86251
  */
86213
86252
  static async loadJiti() {
86214
- const { createJiti } = await import("./jiti-SMSW3TA0.mjs");
86253
+ const { createJiti } = await import("./jiti-ygK9KoRA.mjs");
86215
86254
  return {
86216
86255
  createJiti,
86217
86256
  version: require_package$1().version
@@ -86553,7 +86592,7 @@ var require_eslint_helpers = /* @__PURE__ */ __commonJSMin(((exports, module) =>
86553
86592
  */
86554
86593
  async function globMatch({ basePath, pattern }) {
86555
86594
  let found = false;
86556
- const { hfs } = await import("./src-qLXX6nub.mjs");
86595
+ const { hfs } = await import("./src-CG8kJBI9.mjs");
86557
86596
  const matcher = new Minimatch(normalizeToPosix(path$9.relative(basePath, pattern)), MINIMATCH_OPTIONS);
86558
86597
  const walkSettings = {
86559
86598
  directoryFilter(entry) {
@@ -86600,7 +86639,7 @@ var require_eslint_helpers = /* @__PURE__ */ __commonJSMin(((exports, module) =>
86600
86639
  return new Minimatch(patternToUse, MINIMATCH_OPTIONS);
86601
86640
  });
86602
86641
  const unmatchedPatterns = new Set([...relativeToPatterns.keys()]);
86603
- const { hfs } = await import("./src-qLXX6nub.mjs");
86642
+ const { hfs } = await import("./src-CG8kJBI9.mjs");
86604
86643
  const walk = hfs.walk(basePath, {
86605
86644
  async directoryFilter(entry) {
86606
86645
  if (!matchers.some((matcher) => matcher.match(entry.path, true))) return false;
@@ -97324,7 +97363,7 @@ function parseTypes(rawTypes, namespace, typeSourceInfo) {
97324
97363
  return types$2;
97325
97364
  }
97326
97365
  /**
97327
- * Parse a TailorDBType into a ParsedTailorDBType.
97366
+ * Parse a TailorDBTypeSchemaOutput into a TailorDBType.
97328
97367
  * @param type - TailorDB type to parse
97329
97368
  * @param allTypeNames - Set of all TailorDB type names
97330
97369
  * @param rawTypes - All raw TailorDB types keyed by name
@@ -97522,6 +97561,9 @@ const DBFieldMetadataSchema = z.object({
97522
97561
  index: z.boolean().optional(),
97523
97562
  unique: z.boolean().optional(),
97524
97563
  vector: z.boolean().optional(),
97564
+ foreignKey: z.boolean().optional(),
97565
+ foreignKeyType: z.string().optional(),
97566
+ foreignKeyField: z.string().optional(),
97525
97567
  hooks: z.object({
97526
97568
  create: functionSchema.optional(),
97527
97569
  update: functionSchema.optional()
@@ -97533,10 +97575,21 @@ const DBFieldMetadataSchema = z.object({
97533
97575
  format: z.string().optional()
97534
97576
  }).optional()
97535
97577
  });
97578
+ const RelationTypeSchema = z.enum(relationTypesKeys);
97579
+ const RawRelationConfigSchema = z.object({
97580
+ type: RelationTypeSchema,
97581
+ toward: z.object({
97582
+ type: z.string(),
97583
+ as: z.string().optional(),
97584
+ key: z.string().optional()
97585
+ }),
97586
+ backward: z.string().optional()
97587
+ });
97536
97588
  const TailorDBFieldSchema = z.lazy(() => z.object({
97537
97589
  type: TailorFieldTypeSchema$1,
97538
97590
  fields: z.record(z.string(), TailorDBFieldSchema).optional(),
97539
- _metadata: DBFieldMetadataSchema
97591
+ metadata: DBFieldMetadataSchema,
97592
+ rawRelation: RawRelationConfigSchema.optional()
97540
97593
  }));
97541
97594
  const TailorDBTypeSchema = z.object({
97542
97595
  name: z.string(),
@@ -97544,7 +97597,11 @@ const TailorDBTypeSchema = z.object({
97544
97597
  metadata: z.object({
97545
97598
  name: z.string(),
97546
97599
  description: z.string().optional(),
97547
- settings: z.unknown().optional(),
97600
+ settings: z.object({
97601
+ pluralForm: z.string().optional(),
97602
+ aggregation: z.boolean().optional(),
97603
+ bulkUpsert: z.boolean().optional()
97604
+ }).optional(),
97548
97605
  permissions: z.unknown(),
97549
97606
  files: z.record(z.string(), z.string()),
97550
97607
  indexes: z.record(z.string(), z.object({
@@ -97582,8 +97639,8 @@ function createTailorDBService(namespace, config) {
97582
97639
  if (!result.success) continue;
97583
97640
  const relativePath = path$20.relative(process.cwd(), typeFile);
97584
97641
  logger.log(`Type: ${styles.successBright(`"${result.data.name}"`)} loaded from ${styles.path(relativePath)}`);
97585
- rawTypes[typeFile][result.data.name] = exportedValue;
97586
- loadedTypes[result.data.name] = exportedValue;
97642
+ rawTypes[typeFile][result.data.name] = result.data;
97643
+ loadedTypes[result.data.name] = result.data;
97587
97644
  typeSourceInfo[result.data.name] = {
97588
97645
  filePath: typeFile,
97589
97646
  exportName
@@ -97823,17 +97880,25 @@ const MachineUserSchema = z.object({
97823
97880
  attributes: z.record(z.string(), ValueOperandSchema).optional(),
97824
97881
  attributeList: z.array(z.uuid()).optional()
97825
97882
  });
97826
- const AuthConfigSchema = z.object({
97883
+ const AuthConfigBaseSchema = z.object({
97827
97884
  name: z.string(),
97828
- userProfile: UserProfileSchema.optional(),
97829
- machineUserAttributes: z.record(z.string(), TailorFieldSchema).optional(),
97830
97885
  machineUsers: z.record(z.string(), MachineUserSchema).optional(),
97831
97886
  oauth2Clients: z.record(z.string(), OAuth2ClientSchema).optional(),
97832
97887
  idProvider: IdProviderSchema.optional(),
97833
97888
  scim: SCIMSchema.optional(),
97834
97889
  tenantProvider: TenantProviderSchema.optional(),
97835
97890
  publishSessionEvents: z.boolean().optional()
97836
- }).brand("AuthConfig");
97891
+ });
97892
+ const AuthConfigSchema = z.union([AuthConfigBaseSchema.extend({
97893
+ userProfile: z.undefined().optional(),
97894
+ machineUserAttributes: z.undefined().optional()
97895
+ }), z.xor([AuthConfigBaseSchema.extend({
97896
+ userProfile: UserProfileSchema,
97897
+ machineUserAttributes: z.undefined().optional()
97898
+ }), AuthConfigBaseSchema.extend({
97899
+ userProfile: z.undefined().optional(),
97900
+ machineUserAttributes: z.record(z.string(), TailorFieldSchema)
97901
+ })])]).brand("AuthConfig");
97837
97902
 
97838
97903
  //#endregion
97839
97904
  //#region src/cli/application/auth/service.ts
@@ -98261,4 +98326,4 @@ function defineApplication(config) {
98261
98326
 
98262
98327
  //#endregion
98263
98328
  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
98329
+ //# sourceMappingURL=application-HIu5peO4.mjs.map