@tailor-platform/sdk 1.78.0 → 1.79.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 (46) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/application-BB6BlUfk.mjs +3 -0
  3. package/dist/{application-CUxVA7Fs.mjs → application-fjqb-Gh8.mjs} +50 -3
  4. package/dist/application-fjqb-Gh8.mjs.map +1 -0
  5. package/dist/cli/index.mjs +13 -35
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.mjs +2 -2
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/index.mjs +7 -6
  10. package/dist/configure/index.mjs.map +1 -1
  11. package/dist/configure/services/tailordb/schema.d.mts +1 -7
  12. package/dist/configure/services/workflow/execution-policy.d.mts +2 -2
  13. package/dist/configure/types/type.d.mts +1 -9
  14. package/dist/{globals-CvizbGLY.mjs → globals-B-n_3uYu.mjs} +11 -5
  15. package/dist/globals-B-n_3uYu.mjs.map +1 -0
  16. package/dist/{registry-CYBRvfaU.mjs → registry-CXi7rJq7.mjs} +3 -2
  17. package/dist/registry-CXi7rJq7.mjs.map +1 -0
  18. package/dist/runtime/field-parse.d.mts +11 -0
  19. package/dist/runtime/globals.d.mts +4 -1
  20. package/dist/runtime/index.mjs +1 -1
  21. package/dist/runtime/workflow.d.mts +79 -15
  22. package/dist/runtime/workflow.mjs +2 -2
  23. package/dist/{runtime-BD2vYJFT.mjs → runtime-CjMeYuPA.mjs} +4 -4
  24. package/dist/{runtime-BD2vYJFT.mjs.map → runtime-CjMeYuPA.mjs.map} +1 -1
  25. package/dist/{schema-U6DxoZ8D.mjs → schema-CYrle8JZ.mjs} +42 -24
  26. package/dist/schema-CYrle8JZ.mjs.map +1 -0
  27. package/dist/vitest/environment.mjs +1 -1
  28. package/dist/vitest/index.mjs +36 -10
  29. package/dist/vitest/index.mjs.map +1 -1
  30. package/dist/vitest/mocks/workflow.d.mts +29 -15
  31. package/dist/vitest/setup.mjs +1 -1
  32. package/dist/workflow-CkIDJpdg.mjs +69 -0
  33. package/dist/workflow-CkIDJpdg.mjs.map +1 -0
  34. package/docs/runtime.md +2 -2
  35. package/docs/services/tailordb.md +2 -0
  36. package/docs/services/workflow.md +2 -2
  37. package/docs/testing.md +2 -2
  38. package/package.json +1 -1
  39. package/dist/application-CUxVA7Fs.mjs.map +0 -1
  40. package/dist/application-Dp_-ioiP.mjs +0 -3
  41. package/dist/configure/types/field-runtime.d.mts +0 -17
  42. package/dist/globals-CvizbGLY.mjs.map +0 -1
  43. package/dist/registry-CYBRvfaU.mjs.map +0 -1
  44. package/dist/schema-U6DxoZ8D.mjs.map +0 -1
  45. package/dist/workflow-DSwnYPPP.mjs +0 -45
  46. package/dist/workflow-DSwnYPPP.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 1.79.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1768](https://github.com/tailor-platform/sdk/pull/1768) [`813f86e`](https://github.com/tailor-platform/sdk/commit/813f86eb0b0df1a768db5de6a39a550d6633749a) Thanks [@k1LoW](https://github.com/k1LoW)! - Add canonical `tailor.workflow.*` names that mirror the public `tailor.v1` RPC vocabulary. The `startWorkflow`, `startJobFunction`, and `resumeWorkflowExecution` methods are now available on `tailor.workflow`, alongside `workflow.startWorkflow` / `workflow.startJobFunction` / `workflow.resumeWorkflowExecution` from `@tailor-platform/sdk/runtime`. The pre-alignment names (`triggerWorkflow`, `triggerJobFunction`, `resumeWorkflow`) continue to work as frozen aliases, but are now marked `@deprecated` so IDEs surface a hint to migrate to the canonical names.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#1769](https://github.com/tailor-platform/sdk/pull/1769) [`9837182`](https://github.com/tailor-platform/sdk/commit/983718288eab23a4c15762c179a67569dd78a287) Thanks [@dqn](https://github.com/dqn)! - Fix `tailor function test-run` crashing with `TypeError: Cannot convert undefined or null to object` when `--arg` is a non-object JSON value such as `null`. The argument is now forwarded to the server, which reports the validation error. Local input validation also runs the same logic as deployed resolvers.
12
+
13
+ - [#1777](https://github.com/tailor-platform/sdk/pull/1777) [`322b69c`](https://github.com/tailor-platform/sdk/commit/322b69c843953551ccb4b32d7cbd528ae2b0e10c) Thanks [@toiroakr](https://github.com/toiroakr)! - Fail fast at `generate`/`deploy` time when a TailorDB type is missing `.permission()`, or missing `.gqlPermission()` while GraphQL operations are enabled for it (`.gqlPermission()` is not required when GraphQL exposure is fully disabled via `gqlOperations`). Previously these omissions deployed silently and only surfaced later as an opaque `internal error` on insert.
14
+
3
15
  ## 1.78.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,3 @@
1
+ import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-fjqb-Gh8.mjs";
2
+
3
+ export { defineApplication, generatePluginFilesIfNeeded };
@@ -2491,6 +2491,36 @@ function findOmittedPermitRules(rawPermissions) {
2491
2491
  });
2492
2492
  return locations;
2493
2493
  }
2494
+ /**
2495
+ * Check whether GraphQL exposure is fully disabled for a type, given its
2496
+ * effective gqlOperations (the type's own setting, falling back to the
2497
+ * TailorDB namespace default). `undefined` means the default of all
2498
+ * operations enabled, so it is never considered fully disabled.
2499
+ * @param gqlOperations - Effective, normalized gqlOperations configuration
2500
+ * @returns Whether create, update, delete, and read are all explicitly disabled
2501
+ */
2502
+ function isGqlOperationsFullyDisabled(gqlOperations) {
2503
+ if (!gqlOperations) return false;
2504
+ return gqlOperations.create === false && gqlOperations.update === false && gqlOperations.delete === false && gqlOperations.read === false;
2505
+ }
2506
+ /**
2507
+ * Find missing permission configuration for a TailorDB type.
2508
+ *
2509
+ * Record-level permission is always required: TailorDB denies all record
2510
+ * operations for a type without it, regardless of whether the type is
2511
+ * exposed via GraphQL. GraphQL permission is required whenever GraphQL
2512
+ * exposure is enabled for the type (the default, unless every operation is
2513
+ * explicitly disabled via `gqlOperations`).
2514
+ * @param rawPermissions - Raw permissions definition for the type
2515
+ * @param effectiveGqlOperations - The type's own gqlOperations, falling back to the namespace default
2516
+ * @returns Which permission configuration, if any, is missing
2517
+ */
2518
+ function findMissingPermissionConfig(rawPermissions, effectiveGqlOperations) {
2519
+ return {
2520
+ missingPermission: !rawPermissions.record,
2521
+ missingGqlPermission: !rawPermissions.gql && !isGqlOperationsFullyDisabled(effectiveGqlOperations)
2522
+ };
2523
+ }
2494
2524
 
2495
2525
  //#endregion
2496
2526
  //#region src/parser/service/tailordb/relation.ts
@@ -3533,6 +3563,19 @@ function createTailorDBService(params) {
3533
3563
  if (locations.length > 0) logger.warn(`TailorDB type "${typeName}" has permission rule(s) ${locations.join(", ")} in object form without an explicit "permit"; they default to "deny". Set permit: true (allow) or permit: false (deny) to silence this warning.`);
3534
3564
  }
3535
3565
  };
3566
+ const validateRequiredPermissions = () => {
3567
+ const errors = [];
3568
+ for (const fileTypes of Object.values(rawTypes)) for (const [typeName, type] of Object.entries(fileTypes)) {
3569
+ const effectiveGqlOperations = type.metadata.settings?.gqlOperations ?? config.gqlOperations;
3570
+ const { missingPermission, missingGqlPermission } = findMissingPermissionConfig(type.metadata.permissions, effectiveGqlOperations);
3571
+ if (!missingPermission && !missingGqlPermission) continue;
3572
+ const source = formatTailorDBTypeSourceInfo(typeSourceInfo[typeName]);
3573
+ const location = source ? ` (${source})` : "";
3574
+ if (missingPermission) errors.push(`TailorDB type "${typeName}"${location} has no .permission() configured. TailorDB denies all record operations for types without permission; call .permission(...) to grant access explicitly.`);
3575
+ if (missingGqlPermission) errors.push(`TailorDB type "${typeName}"${location} has no .gqlPermission() configured, but GraphQL operations are enabled for it. Call .gqlPermission(...) to grant GraphQL access explicitly, or disable GraphQL exposure with .features({ gqlOperations: { create: false, update: false, delete: false, read: false } }).`);
3576
+ }
3577
+ if (errors.length > 0) throw new Error(`TailorDB permission configuration errors in service "${namespace}":\n${errors.map((e) => ` - ${e}`).join("\n")}`);
3578
+ };
3536
3579
  /**
3537
3580
  * Process plugins for a type and add generated types to rawTypes
3538
3581
  * @param rawType - The raw TailorDB type being processed
@@ -3625,6 +3668,7 @@ function createTailorDBService(params) {
3625
3668
  else await Promise.all(typeFiles.map((typeFile) => loadTypeFile(typeFile, tsconfig)));
3626
3669
  doParseTypes();
3627
3670
  warnOmittedPermit();
3671
+ validateRequiredPermissions();
3628
3672
  return types;
3629
3673
  })();
3630
3674
  return loadPromise;
@@ -3666,7 +3710,10 @@ function createTailorDBService(params) {
3666
3710
  hasGeneratedTypes = true;
3667
3711
  logger.log(` Generated: ${styles.success(generatedType.name)} by namespace plugin ${styles.info(pluginId)}`);
3668
3712
  }
3669
- if (hasGeneratedTypes || hadPreviousGeneratedTypes) doParseTypes();
3713
+ if (hasGeneratedTypes || hadPreviousGeneratedTypes) {
3714
+ doParseTypes();
3715
+ validateRequiredPermissions();
3716
+ }
3670
3717
  }
3671
3718
  };
3672
3719
  }
@@ -4819,7 +4866,7 @@ const RetryPolicySchema = z.object({
4819
4866
  });
4820
4867
  const ConcurrencyPolicySchema = z.object({ maxConcurrentExecutions: z.number().int().min(1).max(1e3).describe("Maximum number of concurrent executions (1-1000)") });
4821
4868
  const ExecutionPolicyNameSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/, "Invalid execution policy name: must match [a-z0-9-] (3-63 chars; must start and end with [a-z0-9])").describe("Workspace-unique execution policy name embedded in the resource TRN");
4822
- const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to triggerJobFunction's executionPolicyKey option");
4869
+ const ExecutionPolicyKeySchema = z.string().regex(/^[a-z0-9][a-z0-9_:.-]{0,62}[a-z0-9*]$/, "Invalid execution policy key: must match [a-z0-9_:.-] (2-64 chars; must start with [a-z0-9] and end with [a-z0-9] or a trailing '*')").describe("Execution policy key passed to startJobFunction's (or its frozen alias triggerJobFunction's) executionPolicyKey option");
4823
4870
  const WorkflowJobFunctionExecutionPolicySchema = z.object({
4824
4871
  name: ExecutionPolicyNameSchema,
4825
4872
  key: ExecutionPolicyKeySchema,
@@ -5546,4 +5593,4 @@ async function loadApplication(params) {
5546
5593
 
5547
5594
  //#endregion
5548
5595
  export { fetchAllTolerant as A, initOperatorClient as B, createBundleCache as C, closeConnectionPool as D, hashFile as E, getConsoleBaseUrl as F, byName as G, normalizeBaseUrl as H, getOAuth2ClientId as I, LOG_LEVELS as K, getOrNull as L, fetchPaged as M, fetchPlatformMachineUserToken as N, defaultPlatformBaseUrl as O, fetchUserInfo as P, getPlatformBaseUrl as R, hasGenerationHooks as S, hashContent as T, rememberPlatformConfigForToken as U, isDefaultPlatform as V, resolveStaticWebsiteUrls as W, platformBundleDefinePlugin as _, resolveInlineSourcemap as a, resolveBundleLogLevel as b, ResolverSchema as c, buildExecutorArgsExpr as d, buildResolverOperationHookExpr as f, stringifyFunction as g, TailorDBTypeSchema as h, resolverBundleKey as i, fetchMachineUserToken as j, fetchAll as k, HTTP_METHODS as l, assertUniqueTailorDBTypeNamesWithExternal as m, generatePluginFilesIfNeeded as n, WorkflowJobFunctionExecutionPolicySchema as o, assertUniqueLocalTailorDBTypeNames as p, loadApplication as r, WorkflowJobSchema as s, defineApplication as t, INVOKER_EXPR as u, composeFunctionTreeshakeOptions as v, getDistDir as w, getPluginGenerationDependencies as x, createLogLevelTreeshakeOptions as y, initOAuth2Client as z };
5549
- //# sourceMappingURL=application-CUxVA7Fs.mjs.map
5596
+ //# sourceMappingURL=application-fjqb-Gh8.mjs.map