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.
- package/README.md +1 -1
- package/dist/_commonjsHelpers-DKOUU3wS.js +1 -0
- package/dist/_commonjsHelpers-DaMA6jEr.mjs +8 -0
- package/dist/application/application-config.d.ts +0 -2
- package/dist/application/field-metadata/composite-fields.d.ts +0 -1
- package/dist/application/field-metadata/field-type.d.ts +0 -1
- package/dist/application/field-metadata/field.decorator.d.ts +1 -3
- package/dist/application/field-metadata/on-delete-action.d.ts +0 -1
- package/dist/application/field-metadata/relation-type.d.ts +0 -1
- package/dist/application/field-metadata/relation.decorator.d.ts +1 -3
- package/dist/application/function-config.d.ts +0 -2
- package/dist/application/index.d.ts +0 -1
- package/dist/application/object-metadata/object.decorator.d.ts +0 -2
- package/dist/application/object-metadata/standard-object-ids.d.ts +0 -1
- package/dist/application/syncable-entity-options.type.d.ts +0 -1
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/commands/app-add.command.d.ts +12 -0
- package/dist/cli/commands/app-dev.command.d.ts +10 -0
- package/dist/cli/commands/app-generate.command.d.ts +4 -0
- package/dist/cli/commands/app-sync.command.d.ts +7 -0
- package/dist/cli/commands/app-uninstall.command.d.ts +9 -0
- package/dist/cli/commands/app.command.d.ts +9 -0
- package/dist/cli/commands/auth.command.d.ts +9 -0
- package/dist/cli/constants/current-execution-directory.d.ts +1 -0
- package/dist/cli/services/api.service.d.ts +14 -0
- package/dist/cli/services/config.service.d.ts +14 -0
- package/dist/cli/services/generate.service.d.ts +7 -0
- package/dist/cli/types/config.types.d.ts +99 -0
- package/dist/cli/utils/convert-to-label.d.ts +1 -0
- package/dist/cli/utils/find-path-file.d.ts +1 -0
- package/dist/cli/utils/format-and-warn-ts-diagnostics.d.ts +4 -0
- package/dist/cli/utils/format-path.d.ts +1 -0
- package/dist/cli/utils/get-function-base-file.d.ts +4 -0
- package/dist/cli/utils/get-object-decorated-class.d.ts +4 -0
- package/dist/cli/utils/get-ts-program-and-diagnostics.d.ts +7 -0
- package/dist/cli/utils/jsonc-parser.d.ts +17 -0
- package/dist/cli/utils/load-env-variables.d.ts +2 -0
- package/dist/cli/utils/load-manifest.d.ts +9 -0
- package/dist/cli.cjs +242 -0
- package/dist/cli.mjs +9506 -0
- package/dist/index.cjs +11 -11
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +300 -302
- package/package.json +19 -15
- package/dist/application/application-config.d.ts.map +0 -1
- package/dist/application/field-metadata/composite-fields.d.ts.map +0 -1
- package/dist/application/field-metadata/field-type.d.ts.map +0 -1
- package/dist/application/field-metadata/field.decorator.d.ts.map +0 -1
- package/dist/application/field-metadata/on-delete-action.d.ts.map +0 -1
- package/dist/application/field-metadata/relation-type.d.ts.map +0 -1
- package/dist/application/field-metadata/relation.decorator.d.ts.map +0 -1
- package/dist/application/function-config.d.ts.map +0 -1
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/object-metadata/object.decorator.d.ts.map +0 -1
- package/dist/application/object-metadata/standard-object-ids.d.ts.map +0 -1
- package/dist/application/syncable-entity-options.type.d.ts.map +0 -1
- package/dist/cli/cli.js +0 -39
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/commands/app-add.command.js +0 -143
- package/dist/cli/commands/app-add.command.js.map +0 -1
- package/dist/cli/commands/app-dev.command.js +0 -60
- package/dist/cli/commands/app-dev.command.js.map +0 -1
- package/dist/cli/commands/app-generate.command.js +0 -18
- package/dist/cli/commands/app-generate.command.js.map +0 -1
- package/dist/cli/commands/app-sync.command.js +0 -48
- package/dist/cli/commands/app-sync.command.js.map +0 -1
- package/dist/cli/commands/app-uninstall.command.js +0 -46
- package/dist/cli/commands/app-uninstall.command.js.map +0 -1
- package/dist/cli/commands/app.command.js +0 -99
- package/dist/cli/commands/app.command.js.map +0 -1
- package/dist/cli/commands/auth.command.js +0 -128
- package/dist/cli/commands/auth.command.js.map +0 -1
- package/dist/cli/constants/current-execution-directory.js +0 -2
- package/dist/cli/constants/current-execution-directory.js.map +0 -1
- package/dist/cli/services/api.service.js +0 -171
- package/dist/cli/services/api.service.js.map +0 -1
- package/dist/cli/services/config.service.js +0 -83
- package/dist/cli/services/config.service.js.map +0 -1
- package/dist/cli/services/generate.service.js +0 -45
- package/dist/cli/services/generate.service.js.map +0 -1
- package/dist/cli/types/config.types.js +0 -2
- package/dist/cli/types/config.types.js.map +0 -1
- package/dist/cli/utils/convert-to-label.js +0 -6
- package/dist/cli/utils/convert-to-label.js.map +0 -1
- package/dist/cli/utils/find-path-file.js +0 -10
- package/dist/cli/utils/find-path-file.js.map +0 -1
- package/dist/cli/utils/format-and-warn-ts-diagnostics.js +0 -12
- package/dist/cli/utils/format-and-warn-ts-diagnostics.js.map +0 -1
- package/dist/cli/utils/format-path.js +0 -8
- package/dist/cli/utils/format-path.js.map +0 -1
- package/dist/cli/utils/get-function-base-file.js +0 -28
- package/dist/cli/utils/get-function-base-file.js.map +0 -1
- package/dist/cli/utils/get-object-decorated-class.js +0 -16
- package/dist/cli/utils/get-object-decorated-class.js.map +0 -1
- package/dist/cli/utils/get-ts-program-and-diagnostics.js +0 -35
- package/dist/cli/utils/get-ts-program-and-diagnostics.js.map +0 -1
- package/dist/cli/utils/jsonc-parser.js +0 -45
- package/dist/cli/utils/jsonc-parser.js.map +0 -1
- package/dist/cli/utils/load-env-variables.js +0 -15
- package/dist/cli/utils/load-env-variables.js.map +0 -1
- package/dist/cli/utils/load-manifest.js +0 -377
- package/dist/cli/utils/load-manifest.js.map +0 -1
- 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
|
|
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,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,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
|
|
@@ -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,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 @@
|
|
|
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,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 @@
|
|
|
1
|
+
export declare const formatPath: (appPath?: string) => string | undefined;
|
|
@@ -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,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
|
+
}>;
|