twenty-sdk 2.0.0 → 2.1.0-canary.1
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/dist/billing/index.cjs +2 -0
- package/dist/billing/index.cjs.map +1 -0
- package/dist/billing/index.d.ts +10 -0
- package/dist/billing/index.mjs +43 -0
- package/dist/billing/index.mjs.map +1 -0
- package/dist/cli/commands/add.d.ts +3 -1
- package/dist/cli/utilities/build/common/plugins/stub-twenty-sdk-define.plugin.d.ts +7 -0
- package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +4 -2
- package/dist/cli/utilities/entity/entity-page-layout-tab-template.d.ts +3 -0
- package/dist/cli/utilities/entity/entity-record-page-layout-template.d.ts +5 -0
- package/dist/cli/utilities/entity/entity-view-template.d.ts +9 -3
- package/dist/cli.cjs +123 -55
- package/dist/cli.mjs +2183 -2020
- package/dist/define/index.cjs +13 -13
- package/dist/define/index.cjs.map +1 -1
- package/dist/define/index.d.ts +29 -4
- package/dist/define/index.mjs +995 -978
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs +9 -9
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.d.ts +6 -2
- package/dist/front-component/index.mjs +44 -42
- package/dist/front-component/index.mjs.map +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-0e9upvLV.mjs → get-function-input-schema-BZ7_XyUh-CKgoFzji.mjs} +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-CoN3o7CS.js → get-function-input-schema-BZ7_XyUh-D38OurwZ.js} +1 -1
- package/dist/logic-function/index.cjs +2 -0
- package/dist/logic-function/index.cjs.map +1 -0
- package/dist/logic-function/index.d.ts +215 -0
- package/dist/logic-function/index.mjs +2 -0
- package/dist/logic-function/index.mjs.map +1 -0
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +2 -2
- package/dist/{uninstall-CsGNVq-c.mjs → uninstall-Bw-TK4rL.mjs} +3955 -3701
- package/dist/{uninstall-CV3Frzv-.js → uninstall-CYiYoBPe.js} +70 -45
- package/package.json +15 -2
- package/dist/cli/utilities/build/manifest/utils/generate-default-field-universal-identifier.d.ts +0 -5
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="TWENTY_API_URL",g="TWENTY_APP_ACCESS_TOKEN",l=5e3,T=async({creditsUsedMicro:o,operationType:s,quantity:n=1,resourceContext:a})=>{const t=process.env[i],r=process.env[g];if(!(!t||!r))try{const e=await fetch(`${t.replace(/\/$/,"")}/app/billing/charge`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({creditsUsedMicro:o,quantity:n,operationType:s,resourceContext:a}),signal:AbortSignal.timeout(l)});if(!e.ok){const c=await e.text().catch(()=>"");console.error(`chargeCredits: ${e.status} ${e.statusText}: ${c}`)}}catch(e){console.error(`chargeCredits: ${e instanceof Error?e.message:String(e)}`)}};exports.chargeCredits=T;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["const _ = \"public\", A = \"TWENTY_API_KEY\", T = \"TWENTY_API_URL\", t = \"TWENTY_APP_ACCESS_TOKEN\", N = \"generated\", r = {\n js: `import { createRequire as __createRequire } from 'module';\nconst require = __createRequire(import.meta.url);`\n}, u = \".twenty/output\", E = \"Standard\", I = \"20202020-64aa-4b6f-b003-9c74b97cee20\";\nvar e = /* @__PURE__ */ ((o) => (o.Object = \"object\", o.Field = \"field\", o.LogicFunction = \"logicFunction\", o.FrontComponent = \"frontComponent\", o.Role = \"role\", o.Skill = \"skill\", o.Agent = \"agent\", o.View = \"view\", o.NavigationMenuItem = \"navigationMenuItem\", o.PageLayout = \"pageLayout\", o.PageLayoutTab = \"pageLayoutTab\", o))(e || {});\nexport {\n _ as ASSETS_DIR,\n A as DEFAULT_API_KEY_NAME,\n T as DEFAULT_API_URL_NAME,\n t as DEFAULT_APP_ACCESS_TOKEN_NAME,\n N as GENERATED_DIR,\n r as NODE_ESM_CJS_BANNER,\n u as OUTPUT_DIR,\n e as SyncableEntity,\n E as TWENTY_STANDARD_APPLICATION_NAME,\n I as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER\n};\n","import {\n DEFAULT_API_URL_NAME,\n DEFAULT_APP_ACCESS_TOKEN_NAME,\n} from 'twenty-shared/application';\n\nconst BILLING_CHARGE_TIMEOUT_MS = 5_000;\n\nexport type ChargeCreditsParams = {\n creditsUsedMicro: number;\n operationType: string;\n quantity?: number;\n resourceContext?: string;\n};\n\n// Records credit usage against the running application via the Twenty\n// server's `/app/billing/charge` endpoint. Reads `TWENTY_API_URL` and\n// `TWENTY_APP_ACCESS_TOKEN` from the execution env (injected by the\n// logic-function runtime). No-ops silently when either is missing so\n// local/test runs don't crash. Failures are non-fatal — a billing error\n// never surfaces as a tool failure.\nexport const chargeCredits = async ({\n creditsUsedMicro,\n operationType,\n quantity = 1,\n resourceContext,\n}: ChargeCreditsParams): Promise<void> => {\n const apiUrl = process.env[DEFAULT_API_URL_NAME];\n const token = process.env[DEFAULT_APP_ACCESS_TOKEN_NAME];\n\n if (!apiUrl || !token) {\n return;\n }\n\n try {\n const response = await fetch(\n `${apiUrl.replace(/\\/$/, '')}/app/billing/charge`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n creditsUsedMicro,\n quantity,\n operationType,\n resourceContext,\n }),\n signal: AbortSignal.timeout(BILLING_CHARGE_TIMEOUT_MS),\n },\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => '');\n\n console.error(\n `chargeCredits: ${response.status} ${response.statusText}: ${body}`,\n );\n }\n } catch (error) {\n console.error(\n `chargeCredits: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n};\n"],"names":["T","t","BILLING_CHARGE_TIMEOUT_MS","chargeCredits","creditsUsedMicro","operationType","quantity","resourceContext","apiUrl","DEFAULT_API_URL_NAME","token","DEFAULT_APP_ACCESS_TOKEN_NAME","response","body","error"],"mappings":"gFAAK,MAAqCA,EAAI,iBAAkBC,EAAI,0BCK9DC,EAA4B,IAerBC,EAAgB,MAAO,CAClC,iBAAAC,EACA,cAAAC,EACA,SAAAC,EAAW,EACX,gBAAAC,CACF,IAA0C,CACxC,MAAMC,EAAS,QAAQ,IAAIC,CAAoB,EACzCC,EAAQ,QAAQ,IAAIC,CAA6B,EAEvD,GAAI,GAACH,GAAU,CAACE,GAIhB,GAAI,CACF,MAAME,EAAW,MAAM,MACrB,GAAGJ,EAAO,QAAQ,MAAO,EAAE,CAAC,sBAC5B,CACE,OAAQ,OACR,QAAS,CACP,cAAe,UAAUE,CAAK,GAC9B,eAAgB,kBAAA,EAElB,KAAM,KAAK,UAAU,CACnB,iBAAAN,EACA,SAAAE,EACA,cAAAD,EACA,gBAAAE,CAAA,CACD,EACD,OAAQ,YAAY,QAAQL,CAAyB,CAAA,CACvD,EAGF,GAAI,CAACU,EAAS,GAAI,CAChB,MAAMC,EAAO,MAAMD,EAAS,OAAO,MAAM,IAAM,EAAE,EAEjD,QAAQ,MACN,kBAAkBA,EAAS,MAAM,IAAIA,EAAS,UAAU,KAAKC,CAAI,EAAA,CAErE,CACF,OAASC,EAAO,CACd,QAAQ,MACN,kBAAkBA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAA,CAE5E,CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type ChargeCreditsParams = {
|
|
2
|
+
creditsUsedMicro: number;
|
|
3
|
+
operationType: string;
|
|
4
|
+
quantity?: number;
|
|
5
|
+
resourceContext?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const chargeCredits: ({ creditsUsedMicro, operationType, quantity, resourceContext, }: ChargeCreditsParams) => Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { chargeCredits };
|
|
10
|
+
export type { ChargeCreditsParams };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const i = "TWENTY_API_URL", T = "TWENTY_APP_ACCESS_TOKEN";
|
|
2
|
+
const p = async ({
|
|
3
|
+
creditsUsedMicro: o,
|
|
4
|
+
operationType: s,
|
|
5
|
+
quantity: n = 1,
|
|
6
|
+
resourceContext: a
|
|
7
|
+
}) => {
|
|
8
|
+
const e = process.env[i], r = process.env[T];
|
|
9
|
+
if (!(!e || !r))
|
|
10
|
+
try {
|
|
11
|
+
const t = await fetch(
|
|
12
|
+
`${e.replace(/\/$/, "")}/app/billing/charge`,
|
|
13
|
+
{
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${r}`,
|
|
17
|
+
"Content-Type": "application/json"
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
creditsUsedMicro: o,
|
|
21
|
+
quantity: n,
|
|
22
|
+
operationType: s,
|
|
23
|
+
resourceContext: a
|
|
24
|
+
}),
|
|
25
|
+
signal: AbortSignal.timeout(5e3)
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
if (!t.ok) {
|
|
29
|
+
const c = await t.text().catch(() => "");
|
|
30
|
+
console.error(
|
|
31
|
+
`chargeCredits: ${t.status} ${t.statusText}: ${c}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
} catch (t) {
|
|
35
|
+
console.error(
|
|
36
|
+
`chargeCredits: ${t instanceof Error ? t.message : String(t)}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
p as chargeCredits
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["const _ = \"public\", A = \"TWENTY_API_KEY\", T = \"TWENTY_API_URL\", t = \"TWENTY_APP_ACCESS_TOKEN\", N = \"generated\", r = {\n js: `import { createRequire as __createRequire } from 'module';\nconst require = __createRequire(import.meta.url);`\n}, u = \".twenty/output\", E = \"Standard\", I = \"20202020-64aa-4b6f-b003-9c74b97cee20\";\nvar e = /* @__PURE__ */ ((o) => (o.Object = \"object\", o.Field = \"field\", o.LogicFunction = \"logicFunction\", o.FrontComponent = \"frontComponent\", o.Role = \"role\", o.Skill = \"skill\", o.Agent = \"agent\", o.View = \"view\", o.NavigationMenuItem = \"navigationMenuItem\", o.PageLayout = \"pageLayout\", o.PageLayoutTab = \"pageLayoutTab\", o))(e || {});\nexport {\n _ as ASSETS_DIR,\n A as DEFAULT_API_KEY_NAME,\n T as DEFAULT_API_URL_NAME,\n t as DEFAULT_APP_ACCESS_TOKEN_NAME,\n N as GENERATED_DIR,\n r as NODE_ESM_CJS_BANNER,\n u as OUTPUT_DIR,\n e as SyncableEntity,\n E as TWENTY_STANDARD_APPLICATION_NAME,\n I as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER\n};\n","import {\n DEFAULT_API_URL_NAME,\n DEFAULT_APP_ACCESS_TOKEN_NAME,\n} from 'twenty-shared/application';\n\nconst BILLING_CHARGE_TIMEOUT_MS = 5_000;\n\nexport type ChargeCreditsParams = {\n creditsUsedMicro: number;\n operationType: string;\n quantity?: number;\n resourceContext?: string;\n};\n\n// Records credit usage against the running application via the Twenty\n// server's `/app/billing/charge` endpoint. Reads `TWENTY_API_URL` and\n// `TWENTY_APP_ACCESS_TOKEN` from the execution env (injected by the\n// logic-function runtime). No-ops silently when either is missing so\n// local/test runs don't crash. Failures are non-fatal — a billing error\n// never surfaces as a tool failure.\nexport const chargeCredits = async ({\n creditsUsedMicro,\n operationType,\n quantity = 1,\n resourceContext,\n}: ChargeCreditsParams): Promise<void> => {\n const apiUrl = process.env[DEFAULT_API_URL_NAME];\n const token = process.env[DEFAULT_APP_ACCESS_TOKEN_NAME];\n\n if (!apiUrl || !token) {\n return;\n }\n\n try {\n const response = await fetch(\n `${apiUrl.replace(/\\/$/, '')}/app/billing/charge`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n creditsUsedMicro,\n quantity,\n operationType,\n resourceContext,\n }),\n signal: AbortSignal.timeout(BILLING_CHARGE_TIMEOUT_MS),\n },\n );\n\n if (!response.ok) {\n const body = await response.text().catch(() => '');\n\n console.error(\n `chargeCredits: ${response.status} ${response.statusText}: ${body}`,\n );\n }\n } catch (error) {\n console.error(\n `chargeCredits: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n};\n"],"names":["T","t","chargeCredits","creditsUsedMicro","operationType","quantity","resourceContext","apiUrl","DEFAULT_API_URL_NAME","token","DEFAULT_APP_ACCESS_TOKEN_NAME","response","body","error"],"mappings":"AAAK,MAAqCA,IAAI,kBAAkBC,IAAI;ACoB7D,MAAMC,IAAgB,OAAO;AAAA,EAClC,kBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,iBAAAC;AACF,MAA0C;AACxC,QAAMC,IAAS,QAAQ,IAAIC,CAAoB,GACzCC,IAAQ,QAAQ,IAAIC,CAA6B;AAEvD,MAAI,GAACH,KAAU,CAACE;AAIhB,QAAI;AACF,YAAME,IAAW,MAAM;AAAA,QACrB,GAAGJ,EAAO,QAAQ,OAAO,EAAE,CAAC;AAAA,QAC5B;AAAA,UACE,QAAQ;AAAA,UACR,SAAS;AAAA,YACP,eAAe,UAAUE,CAAK;AAAA,YAC9B,gBAAgB;AAAA,UAAA;AAAA,UAElB,MAAM,KAAK,UAAU;AAAA,YACnB,kBAAAN;AAAA,YACA,UAAAE;AAAA,YACA,eAAAD;AAAA,YACA,iBAAAE;AAAA,UAAA,CACD;AAAA,UACD,QAAQ,YAAY,QAAQ,GAAyB;AAAA,QAAA;AAAA,MACvD;AAGF,UAAI,CAACK,EAAS,IAAI;AAChB,cAAMC,IAAO,MAAMD,EAAS,OAAO,MAAM,MAAM,EAAE;AAEjD,gBAAQ;AAAA,UACN,kBAAkBA,EAAS,MAAM,IAAIA,EAAS,UAAU,KAAKC,CAAI;AAAA,QAAA;AAAA,MAErE;AAAA,IACF,SAASC,GAAO;AACd,cAAQ;AAAA,QACN,kBAAkBA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC;AAAA,MAAA;AAAA,IAE5E;AACF;"}
|
|
@@ -2,9 +2,11 @@ import { SyncableEntity } from 'twenty-shared/application';
|
|
|
2
2
|
export declare class EntityAddCommand {
|
|
3
3
|
private lastObjectUniversalIdentifier;
|
|
4
4
|
private lastNameFieldUniversalIdentifier;
|
|
5
|
+
private lastObjectLabelSingular;
|
|
5
6
|
execute(entityType?: SyncableEntity, path?: string): Promise<void>;
|
|
6
7
|
private getEntityData;
|
|
7
|
-
private
|
|
8
|
+
private promptAndCreateObjectCompanions;
|
|
9
|
+
private buildRecordPageFieldsViewFields;
|
|
8
10
|
private getEntity;
|
|
9
11
|
private handleFileExist;
|
|
10
12
|
private getEntityName;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as esbuild from 'esbuild';
|
|
2
|
+
export declare const isDefineFactoryExportName: (name: string) => boolean;
|
|
3
|
+
export declare const TWENTY_SDK_DEFINE_STUBBED_EXPORTS: {
|
|
4
|
+
factories: readonly string[];
|
|
5
|
+
any: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const createStubTwentySdkDefinePlugin: () => esbuild.Plugin;
|
|
@@ -11,7 +11,8 @@ export declare enum TargetFunction {
|
|
|
11
11
|
DefineFrontComponent = "defineFrontComponent",
|
|
12
12
|
DefineView = "defineView",
|
|
13
13
|
DefineNavigationMenuItem = "defineNavigationMenuItem",
|
|
14
|
-
DefinePageLayout = "definePageLayout"
|
|
14
|
+
DefinePageLayout = "definePageLayout",
|
|
15
|
+
DefinePageLayoutTab = "definePageLayoutTab"
|
|
15
16
|
}
|
|
16
17
|
export declare enum ManifestEntityKey {
|
|
17
18
|
Application = "application",
|
|
@@ -25,7 +26,8 @@ export declare enum ManifestEntityKey {
|
|
|
25
26
|
PublicAssets = "publicAssets",
|
|
26
27
|
Views = "views",
|
|
27
28
|
NavigationMenuItems = "navigationMenuItems",
|
|
28
|
-
PageLayouts = "pageLayouts"
|
|
29
|
+
PageLayouts = "pageLayouts",
|
|
30
|
+
PageLayoutTabs = "pageLayoutTabs"
|
|
29
31
|
}
|
|
30
32
|
export type EntityFilePaths = Record<ManifestEntityKey, string[]>;
|
|
31
33
|
export declare const TARGET_FUNCTION_TO_ENTITY_KEY_MAPPING: Record<TargetFunction, ManifestEntityKey>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getRecordPageLayoutBaseFile: ({ objectLabelSingular, objectUniversalIdentifier, fieldsWidgetViewUniversalIdentifier, }: {
|
|
2
|
+
objectLabelSingular: string;
|
|
3
|
+
objectUniversalIdentifier: string;
|
|
4
|
+
fieldsWidgetViewUniversalIdentifier: string;
|
|
5
|
+
}) => string;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
type
|
|
1
|
+
import { type ViewType } from 'twenty-shared/types';
|
|
2
|
+
type ViewFieldTemplateBase = {
|
|
2
3
|
universalIdentifier?: string;
|
|
3
|
-
fieldMetadataUniversalIdentifier: string;
|
|
4
4
|
position: number;
|
|
5
5
|
isVisible?: boolean;
|
|
6
6
|
size?: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type ViewFieldTemplate = (ViewFieldTemplateBase & {
|
|
9
|
+
fieldMetadataUniversalIdentifier: string;
|
|
10
|
+
}) | (ViewFieldTemplateBase & {
|
|
11
|
+
defaultFieldName: string;
|
|
12
|
+
});
|
|
13
|
+
export declare const getViewBaseFile: ({ name, universalIdentifier, objectUniversalIdentifier, fields, type, }: {
|
|
9
14
|
name: string;
|
|
10
15
|
universalIdentifier?: string | undefined;
|
|
11
16
|
objectUniversalIdentifier?: string | undefined;
|
|
12
17
|
fields?: ViewFieldTemplate[] | undefined;
|
|
18
|
+
type?: ViewType | undefined;
|
|
13
19
|
}) => string;
|
|
14
20
|
export {};
|