twenty-sdk 0.1.0 → 0.1.2

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/_commonjsHelpers-DKOUU3wS.js +1 -0
  3. package/dist/_commonjsHelpers-DaMA6jEr.mjs +8 -0
  4. package/dist/application/application-config.d.ts +0 -2
  5. package/dist/application/field-metadata/composite-fields.d.ts +0 -1
  6. package/dist/application/field-metadata/field-type.d.ts +0 -1
  7. package/dist/application/field-metadata/field.decorator.d.ts +1 -3
  8. package/dist/application/field-metadata/on-delete-action.d.ts +0 -1
  9. package/dist/application/field-metadata/relation-type.d.ts +0 -1
  10. package/dist/application/field-metadata/relation.decorator.d.ts +1 -3
  11. package/dist/application/function-config.d.ts +0 -2
  12. package/dist/application/index.d.ts +0 -1
  13. package/dist/application/object-metadata/object.decorator.d.ts +0 -2
  14. package/dist/application/object-metadata/standard-object-ids.d.ts +0 -1
  15. package/dist/application/syncable-entity-options.type.d.ts +0 -1
  16. package/dist/cli/cli.d.ts +2 -0
  17. package/dist/cli/commands/app-add.command.d.ts +12 -0
  18. package/dist/cli/commands/app-dev.command.d.ts +10 -0
  19. package/dist/cli/commands/app-generate.command.d.ts +4 -0
  20. package/dist/cli/commands/app-sync.command.d.ts +7 -0
  21. package/dist/cli/commands/app-uninstall.command.d.ts +9 -0
  22. package/dist/cli/commands/app.command.d.ts +9 -0
  23. package/dist/cli/commands/auth.command.d.ts +9 -0
  24. package/dist/cli/constants/current-execution-directory.d.ts +1 -0
  25. package/dist/cli/services/api.service.d.ts +14 -0
  26. package/dist/cli/services/config.service.d.ts +14 -0
  27. package/dist/cli/services/generate.service.d.ts +7 -0
  28. package/dist/cli/types/config.types.d.ts +99 -0
  29. package/dist/cli/utils/convert-to-label.d.ts +1 -0
  30. package/dist/cli/utils/find-path-file.d.ts +1 -0
  31. package/dist/cli/utils/format-and-warn-ts-diagnostics.d.ts +4 -0
  32. package/dist/cli/utils/format-path.d.ts +1 -0
  33. package/dist/cli/utils/get-function-base-file.d.ts +4 -0
  34. package/dist/cli/utils/get-object-decorated-class.d.ts +4 -0
  35. package/dist/cli/utils/get-ts-program-and-diagnostics.d.ts +7 -0
  36. package/dist/cli/utils/jsonc-parser.d.ts +17 -0
  37. package/dist/cli/utils/load-env-variables.d.ts +2 -0
  38. package/dist/cli/utils/load-manifest.d.ts +9 -0
  39. package/dist/cli.cjs +242 -0
  40. package/dist/cli.mjs +9506 -0
  41. package/dist/index.cjs +11 -11
  42. package/dist/index.d.ts +0 -1
  43. package/dist/index.mjs +300 -302
  44. package/package.json +19 -15
  45. package/dist/application/application-config.d.ts.map +0 -1
  46. package/dist/application/field-metadata/composite-fields.d.ts.map +0 -1
  47. package/dist/application/field-metadata/field-type.d.ts.map +0 -1
  48. package/dist/application/field-metadata/field.decorator.d.ts.map +0 -1
  49. package/dist/application/field-metadata/on-delete-action.d.ts.map +0 -1
  50. package/dist/application/field-metadata/relation-type.d.ts.map +0 -1
  51. package/dist/application/field-metadata/relation.decorator.d.ts.map +0 -1
  52. package/dist/application/function-config.d.ts.map +0 -1
  53. package/dist/application/index.d.ts.map +0 -1
  54. package/dist/application/object-metadata/object.decorator.d.ts.map +0 -1
  55. package/dist/application/object-metadata/standard-object-ids.d.ts.map +0 -1
  56. package/dist/application/syncable-entity-options.type.d.ts.map +0 -1
  57. package/dist/cli/cli.js +0 -39
  58. package/dist/cli/cli.js.map +0 -1
  59. package/dist/cli/commands/app-add.command.js +0 -143
  60. package/dist/cli/commands/app-add.command.js.map +0 -1
  61. package/dist/cli/commands/app-dev.command.js +0 -60
  62. package/dist/cli/commands/app-dev.command.js.map +0 -1
  63. package/dist/cli/commands/app-generate.command.js +0 -18
  64. package/dist/cli/commands/app-generate.command.js.map +0 -1
  65. package/dist/cli/commands/app-sync.command.js +0 -48
  66. package/dist/cli/commands/app-sync.command.js.map +0 -1
  67. package/dist/cli/commands/app-uninstall.command.js +0 -46
  68. package/dist/cli/commands/app-uninstall.command.js.map +0 -1
  69. package/dist/cli/commands/app.command.js +0 -99
  70. package/dist/cli/commands/app.command.js.map +0 -1
  71. package/dist/cli/commands/auth.command.js +0 -128
  72. package/dist/cli/commands/auth.command.js.map +0 -1
  73. package/dist/cli/constants/current-execution-directory.js +0 -2
  74. package/dist/cli/constants/current-execution-directory.js.map +0 -1
  75. package/dist/cli/services/api.service.js +0 -171
  76. package/dist/cli/services/api.service.js.map +0 -1
  77. package/dist/cli/services/config.service.js +0 -83
  78. package/dist/cli/services/config.service.js.map +0 -1
  79. package/dist/cli/services/generate.service.js +0 -45
  80. package/dist/cli/services/generate.service.js.map +0 -1
  81. package/dist/cli/types/config.types.js +0 -2
  82. package/dist/cli/types/config.types.js.map +0 -1
  83. package/dist/cli/utils/convert-to-label.js +0 -6
  84. package/dist/cli/utils/convert-to-label.js.map +0 -1
  85. package/dist/cli/utils/find-path-file.js +0 -10
  86. package/dist/cli/utils/find-path-file.js.map +0 -1
  87. package/dist/cli/utils/format-and-warn-ts-diagnostics.js +0 -12
  88. package/dist/cli/utils/format-and-warn-ts-diagnostics.js.map +0 -1
  89. package/dist/cli/utils/format-path.js +0 -8
  90. package/dist/cli/utils/format-path.js.map +0 -1
  91. package/dist/cli/utils/get-function-base-file.js +0 -28
  92. package/dist/cli/utils/get-function-base-file.js.map +0 -1
  93. package/dist/cli/utils/get-object-decorated-class.js +0 -16
  94. package/dist/cli/utils/get-object-decorated-class.js.map +0 -1
  95. package/dist/cli/utils/get-ts-program-and-diagnostics.js +0 -35
  96. package/dist/cli/utils/get-ts-program-and-diagnostics.js.map +0 -1
  97. package/dist/cli/utils/jsonc-parser.js +0 -45
  98. package/dist/cli/utils/jsonc-parser.js.map +0 -1
  99. package/dist/cli/utils/load-env-variables.js +0 -15
  100. package/dist/cli/utils/load-env-variables.js.map +0 -1
  101. package/dist/cli/utils/load-manifest.js +0 -377
  102. package/dist/cli/utils/load-manifest.js.map +0 -1
  103. package/dist/index.d.ts.map +0 -1
package/README.md CHANGED
@@ -19,7 +19,7 @@ A CLI and SDK to develop, build, and publish applications that extend [Twenty CR
19
19
  - Works great with the scaffolder: [create-twenty-app](https://www.npmjs.com/package/create-twenty-app)
20
20
 
21
21
  ## Prerequisites
22
- - Node.js 18+ (recommended) and Yarn 4
22
+ - Node.js 24+ (recommended) and Yarn 4
23
23
  - A Twenty workspace and an API key. Generate one at https://app.twenty.com/settings/api-webhooks
24
24
 
25
25
  ## Installation
@@ -0,0 +1 @@
1
+ "use strict";var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}exports.commonjsGlobal=o;exports.getDefaultExportFromCjs=l;
@@ -0,0 +1,8 @@
1
+ var o = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
+ function l(e) {
3
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
+ }
5
+ export {
6
+ o as c,
7
+ l as g
8
+ };
@@ -1,5 +1,4 @@
1
1
  import { SyncableEntityOptions } from './syncable-entity-options.type';
2
-
3
2
  type ApplicationVariable = SyncableEntityOptions & {
4
3
  value?: string;
5
4
  description?: string;
@@ -12,4 +11,3 @@ export type ApplicationConfig = SyncableEntityOptions & {
12
11
  applicationVariables?: Record<string, ApplicationVariable>;
13
12
  };
14
13
  export {};
15
- //# sourceMappingURL=application-config.d.ts.map
@@ -1,2 +1 @@
1
1
  export type { ActorMetadata as ActorField, AddressMetadata as AddressField, CurrencyMetadata as CurrencyField, EmailsMetadata as EmailsField, FullNameMetadata as FullNameField, LinksMetadata as LinksField, PhonesMetadata as PhonesField, RichTextV2Metadata as RichTextField } from 'twenty-shared/types';
2
- //# sourceMappingURL=composite-fields.d.ts.map
@@ -1,2 +1 @@
1
1
  export { FieldMetadataType as FieldType } from 'twenty-shared/types';
2
- //# sourceMappingURL=field-type.d.ts.map
@@ -1,6 +1,5 @@
1
- import { FieldMetadataType, FieldMetadataSettings, FieldMetadataOptions, FieldMetadataDefaultValue } from 'twenty-shared/types';
2
1
  import { SyncableEntityOptions } from '../syncable-entity-options.type';
3
-
2
+ import { FieldMetadataType, FieldMetadataSettings, FieldMetadataOptions, FieldMetadataDefaultValue } from 'twenty-shared/types';
4
3
  type FieldOptions<T extends FieldMetadataType = Exclude<FieldMetadataType, FieldMetadataType.RELATION>> = SyncableEntityOptions & {
5
4
  type: T;
6
5
  label: string;
@@ -13,4 +12,3 @@ type FieldOptions<T extends FieldMetadataType = Exclude<FieldMetadataType, Field
13
12
  };
14
13
  export declare const Field: <T extends FieldMetadataType>(_: FieldOptions<T>) => PropertyDecorator;
15
14
  export {};
16
- //# sourceMappingURL=field.decorator.d.ts.map
@@ -1,2 +1 @@
1
1
  export { RelationOnDeleteAction as OnDeleteAction } from 'twenty-shared/types';
2
- //# sourceMappingURL=on-delete-action.d.ts.map
@@ -1,2 +1 @@
1
1
  export { RelationType } from 'twenty-shared/types';
2
- //# sourceMappingURL=relation-type.d.ts.map
@@ -1,6 +1,5 @@
1
- import { RelationOnDeleteAction, RelationType } from 'twenty-shared/types';
2
1
  import { SyncableEntityOptions } from '../syncable-entity-options.type';
3
-
2
+ import { RelationOnDeleteAction, RelationType } from 'twenty-shared/types';
4
3
  interface WorkspaceRelationMinimumBaseOptions<TClass> {
5
4
  label: string;
6
5
  description?: string;
@@ -27,4 +26,3 @@ type WorkspaceManyToOneRelationOptions<TClass extends object> = WorkspaceRelatio
27
26
  type RelationOptions<T extends object> = SyncableEntityOptions & (WorkspaceOtherRelationOptions<T> | WorkspaceManyToOneRelationOptions<T>);
28
27
  export declare const Relation: <T extends object>(_: RelationOptions<T>) => PropertyDecorator;
29
28
  export {};
30
- //# sourceMappingURL=relation.decorator.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { SyncableEntityOptions } from './syncable-entity-options.type';
2
-
3
2
  type RouteTrigger = {
4
3
  type: 'route';
5
4
  path: string;
@@ -22,4 +21,3 @@ export type FunctionConfig = SyncableEntityOptions & {
22
21
  triggers?: FunctionTrigger[];
23
22
  };
24
23
  export {};
25
- //# sourceMappingURL=function-config.d.ts.map
@@ -9,4 +9,3 @@ export type { FunctionConfig } from './function-config';
9
9
  export { Object } from './object-metadata/object.decorator';
10
10
  export { STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS } from './object-metadata/standard-object-ids';
11
11
  export type { SyncableEntityOptions } from './syncable-entity-options.type';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { SyncableEntityOptions } from '../syncable-entity-options.type';
2
-
3
2
  type ObjectMetadataOptions = SyncableEntityOptions & {
4
3
  nameSingular: string;
5
4
  namePlural: string;
@@ -10,4 +9,3 @@ type ObjectMetadataOptions = SyncableEntityOptions & {
10
9
  };
11
10
  export declare const Object: (_: ObjectMetadataOptions) => ClassDecorator;
12
11
  export {};
13
- //# sourceMappingURL=object.decorator.d.ts.map
@@ -1,2 +1 @@
1
1
  export { STANDARD_OBJECT_IDS as STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS } from 'twenty-shared/metadata';
2
- //# sourceMappingURL=standard-object-ids.d.ts.map
@@ -1,4 +1,3 @@
1
1
  export type SyncableEntityOptions = {
2
2
  universalIdentifier: string;
3
3
  };
4
- //# sourceMappingURL=syncable-entity-options.type.d.ts.map
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,12 @@
1
+ export declare enum SyncableEntity {
2
+ AGENT = "agent",
3
+ OBJECT = "object",
4
+ FUNCTION = "function"
5
+ }
6
+ export declare const isSyncableEntity: (value: string) => value is SyncableEntity;
7
+ export declare class AppAddCommand {
8
+ execute(entityType?: SyncableEntity, path?: string): Promise<void>;
9
+ private getEntity;
10
+ private getEntityName;
11
+ private getObjectData;
12
+ }
@@ -0,0 +1,10 @@
1
+ export declare class AppDevCommand {
2
+ private syncCommand;
3
+ execute(options: {
4
+ appPath?: string;
5
+ debounce: string;
6
+ }): Promise<void>;
7
+ private logStartupInfo;
8
+ private setupFileWatcher;
9
+ private setupGracefulShutdown;
10
+ }
@@ -0,0 +1,4 @@
1
+ export declare class AppGenerateCommand {
2
+ private generateService;
3
+ execute(appPath?: string): Promise<void>;
4
+ }
@@ -0,0 +1,7 @@
1
+ import { ApiResponse } from '../types/config.types';
2
+ export declare class AppSyncCommand {
3
+ private apiService;
4
+ private generateService;
5
+ execute(appPath?: string): Promise<ApiResponse<any>>;
6
+ private synchronize;
7
+ }
@@ -0,0 +1,9 @@
1
+ import { ApiResponse } from '../types/config.types';
2
+ export declare class AppUninstallCommand {
3
+ private apiService;
4
+ execute({ appPath, askForConfirmation, }: {
5
+ appPath?: string;
6
+ askForConfirmation: boolean;
7
+ }): Promise<ApiResponse<any>>;
8
+ private confirmationPrompt;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ export declare class AppCommand {
3
+ private devCommand;
4
+ private syncCommand;
5
+ private uninstallCommand;
6
+ private addCommand;
7
+ private generateCommand;
8
+ getCommand(): Command;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from 'commander';
2
+ export declare class AuthCommand {
3
+ private configService;
4
+ private apiService;
5
+ getCommand(): Command;
6
+ private login;
7
+ private logout;
8
+ private status;
9
+ }
@@ -0,0 +1 @@
1
+ export declare const CURRENT_EXECUTION_DIRECTORY: string;
@@ -0,0 +1,14 @@
1
+ import { ApiResponse, AppManifest, PackageJson } from '../types/config.types';
2
+ export declare class ApiService {
3
+ private client;
4
+ private configService;
5
+ constructor();
6
+ validateAuth(): Promise<boolean>;
7
+ syncApplication({ packageJson, yarnLock, manifest, }: {
8
+ packageJson: PackageJson;
9
+ yarnLock: string;
10
+ manifest: AppManifest;
11
+ }): Promise<ApiResponse>;
12
+ uninstallApplication(universalIdentifier: string): Promise<ApiResponse>;
13
+ getSchema(): Promise<ApiResponse<string>>;
14
+ }
@@ -0,0 +1,14 @@
1
+ import { TwentyConfig } from '../types/config.types';
2
+ export declare class ConfigService {
3
+ private readonly configPath;
4
+ private static activeWorkspace;
5
+ constructor();
6
+ static setActiveWorkspace(name?: string): void;
7
+ static getActiveWorkspace(): string;
8
+ private getActiveWorkspaceName;
9
+ private readRawConfig;
10
+ getConfig(): Promise<TwentyConfig>;
11
+ setConfig(config: Partial<TwentyConfig>): Promise<void>;
12
+ clearConfig(): Promise<void>;
13
+ private getDefaultConfig;
14
+ }
@@ -0,0 +1,7 @@
1
+ export declare const GENERATED_FOLDER_NAME = "generated";
2
+ export declare class GenerateService {
3
+ private configService;
4
+ private apiService;
5
+ constructor();
6
+ generateClient(appPath: string): Promise<void>;
7
+ }
@@ -0,0 +1,99 @@
1
+ export interface TwentyConfig {
2
+ apiUrl: string;
3
+ apiKey?: string;
4
+ }
5
+ export type PackageJson = {
6
+ name: string;
7
+ license: string;
8
+ engines: {
9
+ node: string;
10
+ npm: string;
11
+ yarn: string;
12
+ };
13
+ packageManager: string;
14
+ version: string;
15
+ dependencies?: object;
16
+ devDependencies?: object;
17
+ };
18
+ type ApplicationVariable = {
19
+ universalIdentifier: string;
20
+ value?: string;
21
+ description?: string;
22
+ isSecret?: boolean;
23
+ };
24
+ export type Application = {
25
+ universalIdentifier: string;
26
+ displayName?: string;
27
+ description?: string;
28
+ icon?: string;
29
+ applicationVariables?: Record<string, ApplicationVariable>;
30
+ };
31
+ export type AppManifest = {
32
+ application: Application;
33
+ objects: ObjectManifest[];
34
+ serverlessFunctions: ServerlessFunctionManifest[];
35
+ sources: Sources;
36
+ };
37
+ export type ServerlessFunctionManifest = {
38
+ universalIdentifier: string;
39
+ name?: string;
40
+ description?: string;
41
+ timeoutSeconds?: number;
42
+ triggers: ServerlessFunctionTriggerManifest[];
43
+ handlerPath: string;
44
+ handlerName: string;
45
+ };
46
+ export type DatabaseEventTrigger = {
47
+ type: 'databaseEvent';
48
+ eventName: string;
49
+ };
50
+ export type CronTrigger = {
51
+ type: 'cron';
52
+ pattern: string;
53
+ };
54
+ export type RouteTrigger = {
55
+ type: 'route';
56
+ path: string;
57
+ httpMethod: string;
58
+ isAuthRequired: boolean;
59
+ };
60
+ export type ServerlessFunctionTriggerManifest = {
61
+ universalIdentifier: string;
62
+ } & (CronTrigger | DatabaseEventTrigger | RouteTrigger);
63
+ export type Sources = {
64
+ [key: string]: string | Sources;
65
+ };
66
+ export type FieldMetadata = {
67
+ universalIdentifier: string;
68
+ type: string;
69
+ label: string;
70
+ description?: string;
71
+ icon?: string;
72
+ defaultValue?: any;
73
+ options?: any;
74
+ settings?: any;
75
+ isNullable?: boolean;
76
+ isFieldUiReadOnly?: boolean;
77
+ };
78
+ export type ObjectManifest = {
79
+ universalIdentifier: string;
80
+ nameSingular: string;
81
+ namePlural: string;
82
+ labelSingular: string;
83
+ labelPlural: string;
84
+ description?: string;
85
+ icon?: string;
86
+ fields: FieldMetadata[];
87
+ };
88
+ export type SuccessfulApiResponse<T = unknown> = {
89
+ success: true;
90
+ data: T;
91
+ message?: string;
92
+ };
93
+ export type FailingApiResponse = {
94
+ success: false;
95
+ error?: unknown;
96
+ message?: string;
97
+ };
98
+ export type ApiResponse<T = unknown> = SuccessfulApiResponse<T> | FailingApiResponse;
99
+ export {};
@@ -0,0 +1 @@
1
+ export declare const convertToLabel: (str: string) => string;
@@ -0,0 +1 @@
1
+ export declare const findPathFile: (appPath: string, fileName: string) => Promise<string>;
@@ -0,0 +1,4 @@
1
+ import { Diagnostic } from 'typescript';
2
+ export declare const formatAndWarnTsDiagnostics: ({ diagnostics, }: {
3
+ diagnostics: Diagnostic[];
4
+ }) => void;
@@ -0,0 +1 @@
1
+ export declare const formatPath: (appPath?: string) => string | undefined;
@@ -0,0 +1,4 @@
1
+ export declare const getFunctionBaseFile: ({ name, universalIdentifier, }: {
2
+ name: string;
3
+ universalIdentifier?: string;
4
+ }) => string;
@@ -0,0 +1,4 @@
1
+ export declare const getObjectDecoratedClass: ({ data, name, }: {
2
+ data: object;
3
+ name: string;
4
+ }) => string;
@@ -0,0 +1,7 @@
1
+ import { Program, Diagnostic } from 'typescript';
2
+ export declare const getTsProgramAndDiagnostics: ({ appPath, }: {
3
+ appPath: string;
4
+ }) => Promise<{
5
+ program: Program;
6
+ diagnostics: Diagnostic[];
7
+ }>;
@@ -0,0 +1,17 @@
1
+ import { ParseError } from 'jsonc-parser';
2
+ export interface JsoncParseOptions {
3
+ allowTrailingComma?: boolean;
4
+ disallowComments?: boolean;
5
+ allowEmptyContent?: boolean;
6
+ }
7
+ export declare class JsoncParseError extends Error {
8
+ readonly parseErrors: ParseError[];
9
+ readonly filePath?: string | undefined;
10
+ constructor(message: string, parseErrors: ParseError[], filePath?: string | undefined);
11
+ }
12
+ export declare const parseJsoncString: (content: string, options?: JsoncParseOptions) => any;
13
+ export declare const parseTextFile: (filePath: string) => Promise<string>;
14
+ export declare const parseJsoncFile: (filePath: string, options?: JsoncParseOptions) => Promise<any>;
15
+ export declare const writeJsoncFile: (filePath: string, data: any, options?: {
16
+ spaces?: number;
17
+ }) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { default as dotenv } from 'dotenv';
2
+ export declare const loadEnvVariables: (appPath: string) => Promise<dotenv.DotenvParseOutput>;
@@ -0,0 +1,9 @@
1
+ import { Program } from 'typescript';
2
+ import { AppManifest, Application, PackageJson } from '../types/config.types';
3
+ export declare const extractTwentyAppConfig: (program: Program) => Application;
4
+ export declare const loadManifest: (appPath: string) => Promise<{
5
+ packageJson: PackageJson;
6
+ yarnLock: string;
7
+ manifest: AppManifest;
8
+ shouldGenerate: boolean;
9
+ }>;