@tailor-platform/sdk 0.8.6 → 0.10.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,69 @@
1
1
  # @tailor-platform/sdk
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#25](https://github.com/tailor-platform/sdk/pull/25) [`50069ae`](https://github.com/tailor-platform/sdk/commit/50069aeebeb1c0e09cf66f660367cd26cc565f29) Thanks [@haru0017](https://github.com/haru0017)! - Define environment variables in `defineConfig()` and access them in resolvers and executors via the `env` parameter.
8
+
9
+ ```typescript
10
+ export default defineConfig({
11
+ name: "my-app",
12
+ env: { logLevel: "debug", cacheTtl: 3600 },
13
+ });
14
+
15
+ // Access in resolver
16
+ body: ({ input, env }) => {
17
+ // env.logLevel, env.cacheTtl available with full type safety
18
+ };
19
+ ```
20
+
21
+ ### Patch Changes
22
+
23
+ - [#33](https://github.com/tailor-platform/sdk/pull/33) [`1f73bd1`](https://github.com/tailor-platform/sdk/commit/1f73bd1d7abaa0a55358086a0d1b7f7c00cccbf3) Thanks [@remiposo](https://github.com/remiposo)! - Confirm important resource deletion
24
+
25
+ Added a confirmation prompt when attempting to delete resources that would result in data loss (tailordb and staticwebsite).
26
+ This can be skipped with the `--yes` flag.
27
+
28
+ - [#31](https://github.com/tailor-platform/sdk/pull/31) [`5fc5594`](https://github.com/tailor-platform/sdk/commit/5fc5594e0b7b1cdf72dadce505aa58a8ae2e5f4a) Thanks [@remiposo](https://github.com/remiposo)! - Make appName for the Executor's GraphQL target optional
29
+
30
+ The default value is its own application name.
31
+
32
+ ## 0.9.0
33
+
34
+ ### Minor Changes
35
+
36
+ - [#16](https://github.com/tailor-platform/sdk/pull/16) [`7bb9d3a`](https://github.com/tailor-platform/sdk/commit/7bb9d3ae0b1568075867ddf2c2027a636037ee09) Thanks [@remiposo](https://github.com/remiposo)! - Set labels for resource management
37
+
38
+ Previously, apply operations targeted all resources in the workspace, so any resources not listed in the config were deleted during apply. This made it practically impossible to create resources managed by Terraform or other SDK applications in the same workspace.
39
+
40
+ With this change, resources generated by the SDK are now automatically labeled. By only targeting resources with appropriate labels for deletion, coexistence with resources managed elsewhere is now possible. While this label is currently internal, it should become visible in the console in the future.
41
+
42
+ **Breaking Changes:**
43
+
44
+ Existing applications are not labeled, so the following warning will appear when you apply for the first time after updating.
45
+ Please confirm or pass the `--yes` flag.
46
+
47
+ ```
48
+ WARN Unmanaged resources detected:
49
+
50
+ Resources:
51
+ • TailorDB service "my-db"
52
+ • Auth service "my-auth"
53
+ ...
54
+
55
+ These resources are not managed by any application.
56
+
57
+ ❯ Add these resources to "my-app"?
58
+ ○ Yes / ● No
59
+ ```
60
+
61
+ ### Patch Changes
62
+
63
+ - [#16](https://github.com/tailor-platform/sdk/pull/16) [`7bb9d3a`](https://github.com/tailor-platform/sdk/commit/7bb9d3ae0b1568075867ddf2c2027a636037ee09) Thanks [@remiposo](https://github.com/remiposo)! - Load resolver and executor files only once
64
+
65
+ By reusing the results when files have already been loaded, file loading logs are no longer displayed multiple times during apply.
66
+
3
67
  ## 0.8.6
4
68
 
5
69
  ### Patch Changes
@@ -1,22 +1,12 @@
1
1
  /// <reference path="./../plugin-generated.d.ts" />
2
2
 
3
- import { AppConfig, CodeGeneratorBase, Executor, Generator, Resolver, TailorDBTypeConfig } from "../types-CPcmGK_X.mjs";
3
+ import { AppConfig, CodeGeneratorBase, Executor, Generator, Resolver, TailorDBTypeConfig } from "../types-DcpYyMM2.mjs";
4
4
  import "citty";
5
5
  import "zod";
6
6
  import "@bufbuild/protobuf/wkt";
7
7
  import "@bufbuild/protobuf/codegenv2";
8
8
  import "@bufbuild/protobuf";
9
9
 
10
- //#region src/cli/apply/index.d.ts
11
- interface ApplyOptions {
12
- workspaceId?: string;
13
- profile?: string;
14
- configPath?: string;
15
- dryRun?: boolean;
16
- buildOnly?: boolean;
17
- }
18
- declare function apply(options?: ApplyOptions): Promise<void>;
19
- //#endregion
20
10
  //#region src/parser/service/tailordb/types.d.ts
21
11
  /**
22
12
  * Parsed and normalized TailorDB field information
@@ -59,6 +49,17 @@ interface ParsedTailorDBType {
59
49
  files?: TailorDBTypeConfig["schema"]["files"];
60
50
  }
61
51
  //#endregion
52
+ //#region src/cli/apply/index.d.ts
53
+ interface ApplyOptions {
54
+ workspaceId?: string;
55
+ profile?: string;
56
+ configPath?: string;
57
+ dryRun?: boolean;
58
+ yes?: boolean;
59
+ buildOnly?: boolean;
60
+ }
61
+ declare function apply(options?: ApplyOptions): Promise<void>;
62
+ //#endregion
62
63
  //#region src/cli/generator/types.d.ts
63
64
  interface GeneratedFile {
64
65
  path: string;
package/dist/cli/api.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, show, workspaceCreate, workspaceDelete, workspaceList } from "../token-Cbs_El75.mjs";
1
+ import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, show, workspaceCreate, workspaceDelete, workspaceList } from "../token-BD9c1mlS.mjs";
2
2
  import "../auth-Di3vQUrT.mjs";
3
3
 
4
4
  export { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, show, workspaceCreate, workspaceDelete, workspaceList };
@@ -1,17 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, formatArgs, generateCommand, initOperatorClient, listCommand as listCommand$4, listCommand$1 as listCommand, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, parseFormat, printWithFormat, readPlatformConfig, showCommand, tokenCommand, userAgent, withCommonArgs, writePlatformConfig } from "../token-Cbs_El75.mjs";
2
+ import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, formatArgs, generateCommand, initOperatorClient, listCommand as listCommand$4, listCommand$1 as listCommand, loadAccessToken, loadConfig, loadConfigPath, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, showCommand, tokenCommand, userAgent, withCommonArgs, writePlatformConfig } from "../token-BD9c1mlS.mjs";
3
3
  import "../auth-Di3vQUrT.mjs";
4
4
  import { register } from "node:module";
5
5
  import { defineCommand, runCommand, runMain } from "citty";
6
6
  import { z } from "zod";
7
- import { readPackageJSON } from "pkg-types";
8
7
  import ml from "multiline-ts";
9
8
  import { consola } from "consola";
9
+ import chalk from "chalk";
10
10
  import { spawnSync } from "node:child_process";
11
11
  import * as crypto from "node:crypto";
12
12
  import * as http from "node:http";
13
13
  import open from "open";
14
- import chalk from "chalk";
15
14
 
16
15
  //#region src/cli/init.ts
17
16
  const detectPackageManager = () => {
@@ -46,7 +45,7 @@ const initCommand = defineCommand({
46
45
  }
47
46
  },
48
47
  run: withCommonArgs(async (args) => {
49
- const packageJson$1 = await readPackageJSON(import.meta.url);
48
+ const packageJson$1 = await readPackageJson();
50
49
  const version = packageJson$1.version && packageJson$1.version !== "0.0.0" ? packageJson$1.version : "latest";
51
50
  let packageManager = detectPackageManager();
52
51
  if (!packageManager) {
@@ -969,7 +968,7 @@ const workspaceCommand = defineCommand({
969
968
  //#endregion
970
969
  //#region src/cli/index.ts
971
970
  register("tsx", import.meta.url, { data: {} });
972
- const packageJson = await readPackageJSON(import.meta.url);
971
+ const packageJson = await readPackageJson();
973
972
  const mainCommand = defineCommand({
974
973
  meta: {
975
974
  name: packageJson.name,
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./../plugin-generated.d.ts" />
2
2
 
3
- import { AuthConfig, AuthServiceInput, BuiltinIdP, ExecutorServiceConfig, ExecutorServiceInput, IDToken, IdPConfig, IdProviderConfig, OAuth2Client, OAuth2ClientGrantType, OIDC, PermissionCondition, QueryType, Resolver, ResolverServiceConfig, ResolverServiceInput, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, StaticWebsiteConfig, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProviderConfig, UserAttributeKey, UserAttributeListKey, UserAttributeMap, UsernameFieldKey, ValueOperand, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, unauthenticatedTailorUser } from "../types-CPcmGK_X.mjs";
4
- import { FunctionOperation, GqlOperation, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookTrigger, Operation, RecordCreatedArgs, RecordDeletedArgs, RecordTrigger, RecordUpdatedArgs, ResolverExecutedArgs, ResolverExecutedTrigger, ScheduleTrigger, Trigger, WebhookOperation, createExecutor, createResolver, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t } from "../index-DHpKRtq3.mjs";
3
+ import { AuthConfig, AuthServiceInput, BuiltinIdP, ExecutorServiceConfig, ExecutorServiceInput, IDToken, IdPConfig, IdProviderConfig, OAuth2Client, OAuth2ClientGrantType, OIDC, PermissionCondition, QueryType, Resolver, ResolverServiceConfig, ResolverServiceInput, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, StaticWebsiteConfig, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProviderConfig, UserAttributeKey, UserAttributeListKey, UserAttributeMap, UsernameFieldKey, ValueOperand, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, unauthenticatedTailorUser } from "../types-DcpYyMM2.mjs";
4
+ import { FunctionOperation, GqlOperation, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookTrigger, Operation, RecordCreatedArgs, RecordDeletedArgs, RecordTrigger, RecordUpdatedArgs, ResolverExecutedArgs, ResolverExecutedTrigger, ScheduleTrigger, Trigger, WebhookOperation, createExecutor, createResolver, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t } from "../index-DxmBZtRb.mjs";
5
5
  export { AuthConfig, AuthServiceInput, BuiltinIdP, ExecutorServiceConfig, ExecutorServiceInput, FunctionOperation, GqlOperation, IDToken, IdPConfig, IdProviderConfig, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookTrigger, OAuth2Client, OAuth2ClientGrantType, OIDC, Operation, PermissionCondition, QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordTrigger, RecordUpdatedArgs, Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, ResolverServiceConfig, ResolverServiceInput, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, ScheduleTrigger, StaticWebsiteConfig, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProviderConfig, Trigger, UserAttributeKey, UserAttributeListKey, UserAttributeMap, UsernameFieldKey, ValueOperand, WebhookOperation, createExecutor, createResolver, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser };
@@ -1,14 +1,25 @@
1
1
  /// <reference path="./plugin-generated.d.ts" />
2
2
 
3
- import { AllowedValues, AllowedValuesOutput, ArrayFieldOutput, ExecutorInput, FieldMetadata, FieldOptions, FieldOutput, FunctionOperation, GqlOperation, IncomingWebhookTrigger as IncomingWebhookTrigger$1, InferFieldsOutput, RecordTrigger as RecordTrigger$1, ResolverExecutedTrigger as ResolverExecutedTrigger$1, ResolverInput, ScheduleTriggerInput, TailorDBType, TailorField, TailorUser, WebhookOperation, output as output$1 } from "./types-CPcmGK_X.mjs";
3
+ import { AllowedValues, AllowedValuesOutput, ArrayFieldOutput, ExecutorInput, FieldMetadata, FieldOptions, FieldOutput, FunctionOperation, GqlOperation, IncomingWebhookTrigger as IncomingWebhookTrigger$1, InferFieldsOutput, RecordTrigger as RecordTrigger$1, ResolverExecutedTrigger as ResolverExecutedTrigger$1, ResolverInput, ScheduleTriggerInput, TailorDBType, TailorField, TailorUser, WebhookOperation, output as output$1 } from "./types-DcpYyMM2.mjs";
4
4
  import { EmptyObject } from "type-fest";
5
5
  import { Client } from "@urql/core";
6
6
  import { StandardCRON } from "ts-cron-validator";
7
7
 
8
+ //#region src/configure/types/env.d.ts
9
+ declare global {
10
+ namespace TailorSDK {
11
+ interface Env {}
12
+ }
13
+ }
14
+ type InferredEnv = keyof TailorSDK.Env extends never ? Record<string, string> : TailorSDK.Env;
15
+ /** Represents environment variables in the Tailor platform. */
16
+ type TailorEnv = InferredEnv;
17
+ //#endregion
8
18
  //#region src/configure/services/resolver/resolver.d.ts
9
19
  type Context<Input extends Record<string, TailorField<any>> | undefined> = {
10
20
  input: Input extends Record<string, TailorField<any>> ? InferFieldsOutput<Input> : never;
11
21
  user: TailorUser;
22
+ env: TailorEnv;
12
23
  };
13
24
  type OutputType<O> = O extends TailorField<any> ? output$1<O> : O extends Record<string, TailorField<any>> ? InferFieldsOutput<O> : never;
14
25
  declare function createResolver<Input extends Record<string, TailorField<any>> | undefined = undefined, Output extends TailorField<any> | Record<string, TailorField<any>> = TailorField<any>>(config: Omit<ResolverInput, "input" | "output" | "body"> & Readonly<{
@@ -30,7 +41,9 @@ type ResolverConfig = ReturnType<typeof createResolver<any, any>>;
30
41
  //#endregion
31
42
  //#region src/configure/services/executor/operation.d.ts
32
43
  type FunctionOperation$1<Args> = Omit<FunctionOperation, "body"> & {
33
- body: (args: Args) => void | Promise<void>;
44
+ body: (args: Args & {
45
+ env: TailorEnv;
46
+ }) => void | Promise<void>;
34
47
  };
35
48
  type UrqlOperationArgs = Parameters<Client["query"] | Client["mutation"]>;
36
49
  type GqlOperation$1<Args> = Omit<GqlOperation, "query" | "variables"> & {