twenty-sdk 0.6.1 → 0.6.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 (61) hide show
  1. package/README.md +5 -1
  2. package/dist/{HtmlTagToRemoteComponent-DvFlyCDv.js → HtmlTagToRemoteComponent-CgtwxDeH.js} +1 -1
  3. package/dist/{HtmlTagToRemoteComponent-CALlgbCB.mjs → HtmlTagToRemoteComponent-D_EW5OLu.mjs} +1498 -1447
  4. package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +2 -0
  5. package/dist/cli/utilities/client/client-service.d.ts +0 -1
  6. package/dist/cli/utilities/client/twenty-client-template.d.ts +42 -0
  7. package/dist/cli.cjs +138 -89
  8. package/dist/cli.mjs +2570 -2490
  9. package/dist/front-component-renderer/index.cjs +8 -8
  10. package/dist/front-component-renderer/index.mjs +588 -479
  11. package/dist/front-component-renderer/remote/generated/remote-components.d.ts +42 -2
  12. package/dist/front-component-renderer/remote/generated/remote-elements.d.ts +52 -2
  13. package/dist/{get-function-input-schema-BZ7_XyUh-CzwPUwwE.js → get-function-input-schema-BZ7_XyUh-CCSi0u_q.js} +1 -1
  14. package/dist/{get-function-input-schema-BZ7_XyUh-C9RBS5oC.mjs → get-function-input-schema-BZ7_XyUh-DAPandzB.mjs} +1 -1
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.mjs +122 -89
  17. package/dist/sdk/application/application-config.d.ts +1 -1
  18. package/dist/sdk/front-component-api/constants/AllowedHtmlElements.d.ts +1 -0
  19. package/dist/sdk/front-component-api/constants/AllowedHtmlElements.js +57 -6
  20. package/dist/sdk/front-component-api/constants/AllowedHtmlElements.js.map +1 -1
  21. package/dist/sdk/front-component-api/constants/EventToReact.js +22 -3
  22. package/dist/sdk/front-component-api/constants/EventToReact.js.map +1 -1
  23. package/dist/sdk/front-component-api/constants/SerializedEventData.d.ts +7 -0
  24. package/dist/sdk/index.d.ts +3 -0
  25. package/dist/sdk/index.js +70 -66
  26. package/dist/sdk/index.js.map +1 -1
  27. package/dist/sdk/logic-functions/define-post-install-logic-function.d.ts +6 -0
  28. package/dist/sdk/logic-functions/define-post-install-logic-function.js +12 -0
  29. package/dist/sdk/logic-functions/define-post-install-logic-function.js.map +1 -0
  30. package/dist/sdk/logic-functions/define-pre-install-logic-function.d.ts +6 -0
  31. package/dist/sdk/logic-functions/define-pre-install-logic-function.js +12 -0
  32. package/dist/sdk/logic-functions/define-pre-install-logic-function.js.map +1 -0
  33. package/dist/sdk/logic-functions/install-logic-function-payload-type.d.ts +4 -0
  34. package/generated/core/index.ts +406 -0
  35. package/generated/core/runtime/batcher.ts +265 -0
  36. package/generated/core/runtime/createClient.ts +68 -0
  37. package/generated/core/runtime/error.ts +29 -0
  38. package/generated/core/runtime/fetcher.ts +98 -0
  39. package/generated/core/runtime/generateGraphqlOperation.ts +225 -0
  40. package/generated/core/runtime/index.ts +13 -0
  41. package/generated/core/runtime/linkTypeMap.ts +139 -0
  42. package/generated/core/runtime/typeSelection.ts +98 -0
  43. package/generated/core/runtime/types.ts +69 -0
  44. package/generated/core/schema.graphql +36745 -0
  45. package/generated/core/schema.ts +39341 -0
  46. package/generated/core/types.ts +45860 -0
  47. package/generated/index.ts +2 -0
  48. package/generated/metadata/index.ts +469 -0
  49. package/generated/metadata/runtime/batcher.ts +265 -0
  50. package/generated/metadata/runtime/createClient.ts +68 -0
  51. package/generated/metadata/runtime/error.ts +29 -0
  52. package/generated/metadata/runtime/fetcher.ts +98 -0
  53. package/generated/metadata/runtime/generateGraphqlOperation.ts +225 -0
  54. package/generated/metadata/runtime/index.ts +13 -0
  55. package/generated/metadata/runtime/linkTypeMap.ts +139 -0
  56. package/generated/metadata/runtime/typeSelection.ts +98 -0
  57. package/generated/metadata/runtime/types.ts +69 -0
  58. package/generated/metadata/schema.graphql +3971 -0
  59. package/generated/metadata/schema.ts +8357 -0
  60. package/generated/metadata/types.ts +10044 -0
  61. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"EventToReact.js","sources":["../../../../src/sdk/front-component-api/constants/EventToReact.ts"],"sourcesContent":["export const EVENT_TO_REACT: Record<string, string> = {\n click: 'onClick',\n dblclick: 'onDoubleClick',\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mouseover: 'onMouseOver',\n mouseout: 'onMouseOut',\n mouseenter: 'onMouseEnter',\n mouseleave: 'onMouseLeave',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n keypress: 'onKeyPress',\n focus: 'onFocus',\n blur: 'onBlur',\n change: 'onChange',\n input: 'onInput',\n submit: 'onSubmit',\n scroll: 'onScroll',\n wheel: 'onWheel',\n contextmenu: 'onContextMenu',\n drag: 'onDrag',\n};\n"],"names":["EVENT_TO_REACT"],"mappings":"AAAO,MAAMA,IAAyC;AAAA,EACpD,OAAO;AAAA,EACP,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AACR;"}
1
+ {"version":3,"file":"EventToReact.js","sources":["../../../../src/sdk/front-component-api/constants/EventToReact.ts"],"sourcesContent":["export const EVENT_TO_REACT: Record<string, string> = {\n click: 'onClick',\n dblclick: 'onDoubleClick',\n mousedown: 'onMouseDown',\n mouseup: 'onMouseUp',\n mouseover: 'onMouseOver',\n mouseout: 'onMouseOut',\n mouseenter: 'onMouseEnter',\n mouseleave: 'onMouseLeave',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n keypress: 'onKeyPress',\n focus: 'onFocus',\n blur: 'onBlur',\n change: 'onChange',\n input: 'onInput',\n submit: 'onSubmit',\n scroll: 'onScroll',\n wheel: 'onWheel',\n contextmenu: 'onContextMenu',\n drag: 'onDrag',\n timeupdate: 'onTimeUpdate',\n play: 'onPlay',\n pause: 'onPause',\n ended: 'onEnded',\n loadedmetadata: 'onLoadedMetadata',\n loadeddata: 'onLoadedData',\n volumechange: 'onVolumeChange',\n seeking: 'onSeeking',\n seeked: 'onSeeked',\n error: 'onError',\n canplay: 'onCanPlay',\n canplaythrough: 'onCanPlayThrough',\n waiting: 'onWaiting',\n progress: 'onProgress',\n durationchange: 'onDurationChange',\n ratechange: 'onRateChange',\n stalled: 'onStalled',\n suspend: 'onSuspend',\n emptied: 'onEmptied',\n};\n"],"names":["EVENT_TO_REACT"],"mappings":"AAAO,MAAMA,IAAyC;AAAA,EACpD,OAAO;AAAA,EACP,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;"}
@@ -23,4 +23,11 @@ export type SerializedEventData = {
23
23
  deltaY?: number;
24
24
  deltaZ?: number;
25
25
  deltaMode?: number;
26
+ currentTime?: number;
27
+ duration?: number;
28
+ paused?: boolean;
29
+ ended?: boolean;
30
+ volume?: number;
31
+ muted?: boolean;
32
+ playbackRate?: number;
26
33
  };
@@ -12,6 +12,9 @@ export { RelationType } from './fields/relation-type';
12
12
  export { validateFields } from './fields/validate-fields';
13
13
  export type { FrontComponentCommandConfig, FrontComponentConfig, FrontComponentType, } from './front-component-config';
14
14
  export { defineLogicFunction } from './logic-functions/define-logic-function';
15
+ export type { InstallLogicFunctionPayload, InstallLogicFunctionHandler, } from './logic-functions/install-logic-function-payload-type';
16
+ export { definePreInstallLogicFunction } from './logic-functions/define-pre-install-logic-function';
17
+ export { definePostInstallLogicFunction } from './logic-functions/define-post-install-logic-function';
15
18
  export type { LogicFunctionConfig, LogicFunctionHandler, } from './logic-functions/logic-function-config';
16
19
  export type { CronPayload } from './logic-functions/triggers/cron-payload-type';
17
20
  export type { DatabaseEventPayload, ObjectRecordBaseEvent, ObjectRecordCreateEvent, ObjectRecordDeleteEvent, ObjectRecordDestroyEvent, ObjectRecordEvent, ObjectRecordRestoreEvent, ObjectRecordUpdateEvent, ObjectRecordUpsertEvent, } from './logic-functions/triggers/database-event-payload-type';
package/dist/sdk/index.js CHANGED
@@ -1,79 +1,83 @@
1
1
  import { defineApplication as r } from "./application/define-application.js";
2
2
  import { createValidationResult as n } from "./common/utils/create-validation-result.js";
3
3
  import { defineFrontComponent as i } from "./define-front-component.js";
4
- import { defineField as m } from "./fields/define-field.js";
5
- import { AggregateOperations as x, AppPath as T, CommandMenuPages as d, FieldMetadataType as l, ObjectRecordGroupByDateGranularity as E, RelationOnDeleteAction as s, PageLayoutTabLayoutMode as A, RelationType as O } from "twenty-shared/types";
6
- import { validateFields as _ } from "./fields/validate-fields.js";
7
- import { defineLogicFunction as c } from "./logic-functions/define-logic-function.js";
8
- import { defineNavigationMenuItem as C } from "./navigation-menu-items/define-navigation-menu-item.js";
9
- import { defineObject as R } from "./objects/define-object.js";
10
- import { STANDARD_OBJECTS as N, STANDARD_OBJECTS as P } from "twenty-shared/metadata";
11
- import { definePageLayout as L } from "./page-layouts/define-page-layout.js";
12
- import { defineRole as I } from "./roles/define-role.js";
13
- import { PermissionFlagType as b } from "twenty-shared/constants";
14
- import { defineSkill as G } from "./skills/define-skill.js";
15
- import { defineView as J } from "./views/define-view.js";
16
- import { Action as v } from "./action/Action.js";
17
- import { ActionLink as U } from "./action/ActionLink.js";
18
- import { ActionOpenSidePanelPage as q } from "./action/ActionOpenSidePanelPage.js";
19
- import { closeSidePanel as K } from "./front-component-api/functions/closeSidePanel.js";
20
- import { enqueueSnackbar as z } from "./front-component-api/functions/enqueueSnackbar.js";
21
- import { navigate as X } from "./front-component-api/functions/navigate.js";
22
- import { openSidePanelPage as Z } from "./front-component-api/functions/openSidePanelPage.js";
23
- import { unmountFrontComponent as ee } from "./front-component-api/functions/unmountFrontComponent.js";
24
- import { useFrontComponentExecutionContext as re } from "./front-component-api/hooks/useFrontComponentExecutionContext.js";
25
- import { useFrontComponentId as ne } from "./front-component-api/hooks/useFrontComponentId.js";
26
- import { useUserId as ie } from "./front-component-api/hooks/useUserId.js";
27
- import { getFrontComponentActionErrorDedupeKey as me } from "./front-component-api/utils/getFrontComponentActionErrorDedupeKey.js";
28
- import { ALLOWED_HTML_ELEMENTS as xe } from "./front-component-api/constants/AllowedHtmlElements.js";
29
- import { COMMON_HTML_EVENTS as de } from "./front-component-api/constants/CommonHtmlEvents.js";
30
- import { EVENT_TO_REACT as Ee } from "./front-component-api/constants/EventToReact.js";
31
- import { HTML_COMMON_PROPERTIES as Ae } from "./front-component-api/constants/HtmlCommonProperties.js";
32
- import { HTML_TAG_TO_REMOTE_COMPONENT as ue } from "./front-component-api/constants/HtmlTagToRemoteComponent.js";
33
- import { installStyleBridge as Se } from "./front-component-renderer/polyfills/installStyleBridge.js";
34
- import { exposeGlobals as ge } from "./front-component-renderer/remote/utils/exposeGlobals.js";
4
+ import { defineField as a } from "./fields/define-field.js";
5
+ import { AggregateOperations as x, AppPath as l, CommandMenuPages as d, FieldMetadataType as T, ObjectRecordGroupByDateGranularity as s, RelationOnDeleteAction as E, PageLayoutTabLayoutMode as A, RelationType as O } from "twenty-shared/types";
6
+ import { validateFields as u } from "./fields/validate-fields.js";
7
+ import { defineLogicFunction as g } from "./logic-functions/define-logic-function.js";
8
+ import { definePreInstallLogicFunction as P } from "./logic-functions/define-pre-install-logic-function.js";
9
+ import { definePostInstallLogicFunction as F } from "./logic-functions/define-post-install-logic-function.js";
10
+ import { defineNavigationMenuItem as M } from "./navigation-menu-items/define-navigation-menu-item.js";
11
+ import { defineObject as D } from "./objects/define-object.js";
12
+ import { STANDARD_OBJECTS as y, STANDARD_OBJECTS as I } from "twenty-shared/metadata";
13
+ import { definePageLayout as b } from "./page-layouts/define-page-layout.js";
14
+ import { defineRole as G } from "./roles/define-role.js";
15
+ import { PermissionFlagType as J } from "twenty-shared/constants";
16
+ import { defineSkill as v } from "./skills/define-skill.js";
17
+ import { defineView as U } from "./views/define-view.js";
18
+ import { Action as q } from "./action/Action.js";
19
+ import { ActionLink as K } from "./action/ActionLink.js";
20
+ import { ActionOpenSidePanelPage as z } from "./action/ActionOpenSidePanelPage.js";
21
+ import { closeSidePanel as X } from "./front-component-api/functions/closeSidePanel.js";
22
+ import { enqueueSnackbar as Z } from "./front-component-api/functions/enqueueSnackbar.js";
23
+ import { navigate as ee } from "./front-component-api/functions/navigate.js";
24
+ import { openSidePanelPage as re } from "./front-component-api/functions/openSidePanelPage.js";
25
+ import { unmountFrontComponent as ne } from "./front-component-api/functions/unmountFrontComponent.js";
26
+ import { useFrontComponentExecutionContext as ie } from "./front-component-api/hooks/useFrontComponentExecutionContext.js";
27
+ import { useFrontComponentId as ae } from "./front-component-api/hooks/useFrontComponentId.js";
28
+ import { useUserId as xe } from "./front-component-api/hooks/useUserId.js";
29
+ import { getFrontComponentActionErrorDedupeKey as de } from "./front-component-api/utils/getFrontComponentActionErrorDedupeKey.js";
30
+ import { ALLOWED_HTML_ELEMENTS as se } from "./front-component-api/constants/AllowedHtmlElements.js";
31
+ import { COMMON_HTML_EVENTS as Ae } from "./front-component-api/constants/CommonHtmlEvents.js";
32
+ import { EVENT_TO_REACT as ce } from "./front-component-api/constants/EventToReact.js";
33
+ import { HTML_COMMON_PROPERTIES as _e } from "./front-component-api/constants/HtmlCommonProperties.js";
34
+ import { HTML_TAG_TO_REMOTE_COMPONENT as Se } from "./front-component-api/constants/HtmlTagToRemoteComponent.js";
35
+ import { installStyleBridge as Ce } from "./front-component-renderer/polyfills/installStyleBridge.js";
36
+ import { exposeGlobals as Le } from "./front-component-renderer/remote/utils/exposeGlobals.js";
35
37
  export {
36
- xe as ALLOWED_HTML_ELEMENTS,
37
- v as Action,
38
- U as ActionLink,
39
- q as ActionOpenSidePanelPage,
38
+ se as ALLOWED_HTML_ELEMENTS,
39
+ q as Action,
40
+ K as ActionLink,
41
+ z as ActionOpenSidePanelPage,
40
42
  x as AggregateOperations,
41
- T as AppPath,
42
- de as COMMON_HTML_EVENTS,
43
+ l as AppPath,
44
+ Ae as COMMON_HTML_EVENTS,
43
45
  d as CommandMenuPages,
44
- Ee as EVENT_TO_REACT,
45
- l as FieldType,
46
- Ae as HTML_COMMON_PROPERTIES,
47
- ue as HTML_TAG_TO_REMOTE_COMPONENT,
48
- E as ObjectRecordGroupByDateGranularity,
49
- s as OnDeleteAction,
46
+ ce as EVENT_TO_REACT,
47
+ T as FieldType,
48
+ _e as HTML_COMMON_PROPERTIES,
49
+ Se as HTML_TAG_TO_REMOTE_COMPONENT,
50
+ s as ObjectRecordGroupByDateGranularity,
51
+ E as OnDeleteAction,
50
52
  A as PageLayoutTabLayoutMode,
51
- b as PermissionFlag,
53
+ J as PermissionFlag,
52
54
  O as RelationType,
53
- N as STANDARD_OBJECT,
54
- P as STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
55
- K as closeSidePanel,
55
+ y as STANDARD_OBJECT,
56
+ I as STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
57
+ X as closeSidePanel,
56
58
  n as createValidationResult,
57
59
  r as defineApplication,
58
- m as defineField,
60
+ a as defineField,
59
61
  i as defineFrontComponent,
60
- c as defineLogicFunction,
61
- C as defineNavigationMenuItem,
62
- R as defineObject,
63
- L as definePageLayout,
64
- I as defineRole,
65
- G as defineSkill,
66
- J as defineView,
67
- z as enqueueSnackbar,
68
- ge as exposeGlobals,
69
- me as getFrontComponentActionErrorDedupeKey,
70
- Se as installStyleBridge,
71
- X as navigate,
72
- Z as openSidePanelPage,
73
- ee as unmountFrontComponent,
74
- re as useFrontComponentExecutionContext,
75
- ne as useFrontComponentId,
76
- ie as useUserId,
77
- _ as validateFields
62
+ g as defineLogicFunction,
63
+ M as defineNavigationMenuItem,
64
+ D as defineObject,
65
+ b as definePageLayout,
66
+ F as definePostInstallLogicFunction,
67
+ P as definePreInstallLogicFunction,
68
+ G as defineRole,
69
+ v as defineSkill,
70
+ U as defineView,
71
+ Z as enqueueSnackbar,
72
+ Le as exposeGlobals,
73
+ de as getFrontComponentActionErrorDedupeKey,
74
+ Ce as installStyleBridge,
75
+ ee as navigate,
76
+ re as openSidePanelPage,
77
+ ne as unmountFrontComponent,
78
+ ie as useFrontComponentExecutionContext,
79
+ ae as useFrontComponentId,
80
+ xe as useUserId,
81
+ u as validateFields
78
82
  };
79
83
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,6 @@
1
+ import { type LogicFunctionConfig } from '../../sdk/logic-functions/logic-function-config';
2
+ import { type InstallLogicFunctionHandler } from '../../sdk/logic-functions/install-logic-function-payload-type';
3
+ import type { DefineEntity } from '../../sdk/common/types/define-entity.type';
4
+ export declare const definePostInstallLogicFunction: DefineEntity<Omit<LogicFunctionConfig, 'cronTriggerSettings' | 'databaseEventTriggerSettings' | 'httpRouteTriggerSettings' | 'isTool' | 'handler'> & {
5
+ handler: InstallLogicFunctionHandler;
6
+ }>;
@@ -0,0 +1,12 @@
1
+ import { createValidationResult as i } from "../common/utils/create-validation-result.js";
2
+ const s = (t) => {
3
+ const n = [];
4
+ return t.universalIdentifier || n.push("Post install logic function must have a universalIdentifier"), t.handler || n.push("Post install logic function must have a handler"), typeof t.handler != "function" && n.push("Post install logic function handler must be a function"), i({
5
+ config: t,
6
+ errors: n
7
+ });
8
+ };
9
+ export {
10
+ s as definePostInstallLogicFunction
11
+ };
12
+ //# sourceMappingURL=define-post-install-logic-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-post-install-logic-function.js","sources":["../../../src/sdk/logic-functions/define-post-install-logic-function.ts"],"sourcesContent":["import { type LogicFunctionConfig } from '@/sdk/logic-functions/logic-function-config';\nimport { type InstallLogicFunctionHandler } from '@/sdk/logic-functions/install-logic-function-payload-type';\nimport { createValidationResult } from '@/sdk/common/utils/create-validation-result';\nimport type { DefineEntity } from '@/sdk/common/types/define-entity.type';\n\nexport const definePostInstallLogicFunction: DefineEntity<\n Omit<\n LogicFunctionConfig,\n | 'cronTriggerSettings'\n | 'databaseEventTriggerSettings'\n | 'httpRouteTriggerSettings'\n | 'isTool'\n | 'handler'\n > & {\n handler: InstallLogicFunctionHandler;\n }\n> = (config) => {\n const errors = [];\n\n if (!config.universalIdentifier) {\n errors.push('Post install logic function must have a universalIdentifier');\n }\n\n if (!config.handler) {\n errors.push('Post install logic function must have a handler');\n }\n\n if (typeof config.handler !== 'function') {\n errors.push('Post install logic function handler must be a function');\n }\n\n return createValidationResult({\n config,\n errors,\n });\n};\n"],"names":["definePostInstallLogicFunction","config","errors","createValidationResult"],"mappings":";AAKO,MAAMA,IAWT,CAACC,MAAW;AACd,QAAMC,IAAS,CAAA;AAEf,SAAKD,EAAO,uBACVC,EAAO,KAAK,6DAA6D,GAGtED,EAAO,WACVC,EAAO,KAAK,iDAAiD,GAG3D,OAAOD,EAAO,WAAY,cAC5BC,EAAO,KAAK,wDAAwD,GAG/DC,EAAuB;AAAA,IAC5B,QAAAF;AAAA,IACA,QAAAC;AAAA,EAAA,CACD;AACH;"}
@@ -0,0 +1,6 @@
1
+ import { type LogicFunctionConfig } from '../../sdk/logic-functions/logic-function-config';
2
+ import { type InstallLogicFunctionHandler } from '../../sdk/logic-functions/install-logic-function-payload-type';
3
+ import type { DefineEntity } from '../../sdk/common/types/define-entity.type';
4
+ export declare const definePreInstallLogicFunction: DefineEntity<Omit<LogicFunctionConfig, 'cronTriggerSettings' | 'databaseEventTriggerSettings' | 'httpRouteTriggerSettings' | 'isTool' | 'handler'> & {
5
+ handler: InstallLogicFunctionHandler;
6
+ }>;
@@ -0,0 +1,12 @@
1
+ import { createValidationResult as t } from "../common/utils/create-validation-result.js";
2
+ const r = (e) => {
3
+ const n = [];
4
+ return e.universalIdentifier || n.push("Pre install logic function must have a universalIdentifier"), e.handler || n.push("Pre install logic function must have a handler"), typeof e.handler != "function" && n.push("Pre install logic function handler must be a function"), t({
5
+ config: e,
6
+ errors: n
7
+ });
8
+ };
9
+ export {
10
+ r as definePreInstallLogicFunction
11
+ };
12
+ //# sourceMappingURL=define-pre-install-logic-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-pre-install-logic-function.js","sources":["../../../src/sdk/logic-functions/define-pre-install-logic-function.ts"],"sourcesContent":["import { type LogicFunctionConfig } from '@/sdk/logic-functions/logic-function-config';\nimport { type InstallLogicFunctionHandler } from '@/sdk/logic-functions/install-logic-function-payload-type';\nimport { createValidationResult } from '@/sdk/common/utils/create-validation-result';\nimport type { DefineEntity } from '@/sdk/common/types/define-entity.type';\n\nexport const definePreInstallLogicFunction: DefineEntity<\n Omit<\n LogicFunctionConfig,\n | 'cronTriggerSettings'\n | 'databaseEventTriggerSettings'\n | 'httpRouteTriggerSettings'\n | 'isTool'\n | 'handler'\n > & {\n handler: InstallLogicFunctionHandler;\n }\n> = (config) => {\n const errors = [];\n\n if (!config.universalIdentifier) {\n errors.push('Pre install logic function must have a universalIdentifier');\n }\n\n if (!config.handler) {\n errors.push('Pre install logic function must have a handler');\n }\n\n if (typeof config.handler !== 'function') {\n errors.push('Pre install logic function handler must be a function');\n }\n\n return createValidationResult({\n config,\n errors,\n });\n};\n"],"names":["definePreInstallLogicFunction","config","errors","createValidationResult"],"mappings":";AAKO,MAAMA,IAWT,CAACC,MAAW;AACd,QAAMC,IAAS,CAAA;AAEf,SAAKD,EAAO,uBACVC,EAAO,KAAK,4DAA4D,GAGrED,EAAO,WACVC,EAAO,KAAK,gDAAgD,GAG1D,OAAOD,EAAO,WAAY,cAC5BC,EAAO,KAAK,uDAAuD,GAG9DC,EAAuB;AAAA,IAC5B,QAAAF;AAAA,IACA,QAAAC;AAAA,EAAA,CACD;AACH;"}
@@ -0,0 +1,4 @@
1
+ export type InstallLogicFunctionPayload = {
2
+ previousVersion: string;
3
+ };
4
+ export type InstallLogicFunctionHandler = (payload: InstallLogicFunctionPayload) => any | Promise<any>;
@@ -0,0 +1,406 @@
1
+ // @ts-nocheck
2
+ import type {
3
+ QueryGenqlSelection,
4
+ Query,
5
+ MutationGenqlSelection,
6
+ Mutation,
7
+ } from './schema'
8
+ import {
9
+ linkTypeMap,
10
+ createClient as createClientOriginal,
11
+ generateGraphqlOperation,
12
+ type FieldsSelection,
13
+ type GraphqlOperation,
14
+ type ClientOptions,
15
+ GenqlError,
16
+ } from './runtime'
17
+ export type { FieldsSelection } from './runtime'
18
+ export { GenqlError }
19
+
20
+ import types from './types'
21
+ export * from './schema'
22
+ const typeMap = linkTypeMap(types as any)
23
+
24
+ export interface Client {
25
+ query<R extends QueryGenqlSelection>(
26
+ request: R & { __name?: string },
27
+ ): Promise<FieldsSelection<Query, R>>
28
+
29
+ mutation<R extends MutationGenqlSelection>(
30
+ request: R & { __name?: string },
31
+ ): Promise<FieldsSelection<Mutation, R>>
32
+ }
33
+
34
+ export const createClient = function (options?: ClientOptions): Client {
35
+ return createClientOriginal({
36
+ url: undefined,
37
+
38
+ ...options,
39
+ queryRoot: typeMap.Query!,
40
+ mutationRoot: typeMap.Mutation!,
41
+ subscriptionRoot: typeMap.Subscription!,
42
+ }) as any
43
+ }
44
+
45
+ export const everything = {
46
+ __scalar: true,
47
+ }
48
+
49
+ export type QueryResult<fields extends QueryGenqlSelection> = FieldsSelection<
50
+ Query,
51
+ fields
52
+ >
53
+ export const generateQueryOp: (
54
+ fields: QueryGenqlSelection & { __name?: string },
55
+ ) => GraphqlOperation = function (fields) {
56
+ return generateGraphqlOperation('query', typeMap.Query!, fields as any)
57
+ }
58
+
59
+ export type MutationResult<fields extends MutationGenqlSelection> =
60
+ FieldsSelection<Mutation, fields>
61
+ export const generateMutationOp: (
62
+ fields: MutationGenqlSelection & { __name?: string },
63
+ ) => GraphqlOperation = function (fields) {
64
+ return generateGraphqlOperation('mutation', typeMap.Mutation!, fields as any)
65
+ }
66
+
67
+
68
+ // ----------------------------------------------------
69
+ // CoreApiClient (auto-injected)
70
+ // ----------------------------------------------------
71
+
72
+ const APP_ACCESS_TOKEN_ENV_KEY = 'TWENTY_APP_ACCESS_TOKEN';
73
+ const API_KEY_ENV_KEY = 'TWENTY_API_KEY';
74
+
75
+ type CoreApiClientOptions = ClientOptions
76
+
77
+ type ProcessEnvironment = Record<string, string | undefined>
78
+
79
+ type GraphqlError = {
80
+ message?: string;
81
+ extensions?: { code?: string };
82
+ }
83
+
84
+ type GraphqlResponsePayload = {
85
+ data?: Record<string, unknown>
86
+ errors?: GraphqlError[];
87
+ }
88
+
89
+ type GraphqlResponse = {
90
+ status: number;
91
+ statusText: string;
92
+ payload: GraphqlResponsePayload | null;
93
+ rawBody: string;
94
+ }
95
+
96
+ const getProcessEnvironment = (): ProcessEnvironment => {
97
+ const processObject = (globalThis as { process?: { env?: ProcessEnvironment } })
98
+ .process;
99
+
100
+ return processObject?.env ?? {};
101
+ }
102
+
103
+ const getTokenFromAuthorizationHeader = (
104
+ authorizationHeader: string | undefined,
105
+ ): string | null => {
106
+ if (typeof authorizationHeader !== 'string') {
107
+ return null;
108
+ }
109
+
110
+ const trimmedAuthorizationHeader = authorizationHeader.trim();
111
+
112
+ if (trimmedAuthorizationHeader.length === 0) {
113
+ return null;
114
+ }
115
+
116
+ if (trimmedAuthorizationHeader === 'Bearer') {
117
+ return null;
118
+ }
119
+
120
+ if (trimmedAuthorizationHeader.startsWith('Bearer ')) {
121
+ return trimmedAuthorizationHeader.slice('Bearer '.length).trim();
122
+ }
123
+
124
+ return trimmedAuthorizationHeader;
125
+ }
126
+
127
+ const getTokenFromHeaders = (headers: HeadersInit | undefined): string | null => {
128
+ if (!headers) {
129
+ return null;
130
+ }
131
+
132
+ if (headers instanceof Headers) {
133
+ return getTokenFromAuthorizationHeader(headers.get('Authorization') ?? undefined);
134
+ }
135
+
136
+ if (Array.isArray(headers)) {
137
+ const matchedAuthorizationHeader = headers.find(
138
+ ([headerName]) => headerName.toLowerCase() === 'authorization',
139
+ );
140
+
141
+ return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);
142
+ }
143
+
144
+ const headersRecord = headers as Record<string, string | undefined>;
145
+
146
+ return getTokenFromAuthorizationHeader(
147
+ headersRecord.Authorization ?? headersRecord.authorization,
148
+ );
149
+ }
150
+
151
+ const hasAuthenticationErrorInGraphqlPayload = (
152
+ payload: GraphqlResponsePayload | null,
153
+ ): boolean => {
154
+ if (!payload?.errors) {
155
+ return false;
156
+ }
157
+
158
+ return payload.errors.some((error) => {
159
+ return (
160
+ error.extensions?.code === 'UNAUTHENTICATED' ||
161
+ error.message?.toLowerCase() === 'unauthorized'
162
+ );
163
+ });
164
+ }
165
+
166
+ const defaultOptions: CoreApiClientOptions = {
167
+ url: `${process.env.TWENTY_API_URL}/graphql`,
168
+ headers: {
169
+ 'Content-Type': 'application/json',
170
+ },
171
+ }
172
+
173
+ export class CoreApiClient {
174
+ private client: Client;
175
+ private url: string;
176
+ private requestOptions: RequestInit;
177
+ private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
178
+ private fetchImplementation: typeof globalThis.fetch | null;
179
+ private authorizationToken: string | null;
180
+ private refreshAccessTokenPromise: Promise<string | null> | null = null;
181
+
182
+ constructor(options?: CoreApiClientOptions) {
183
+ const merged: CoreApiClientOptions = {
184
+ ...defaultOptions,
185
+ ...options,
186
+ }
187
+
188
+ const {
189
+ url,
190
+ headers,
191
+ fetch: customFetchImplementation,
192
+ fetcher: _fetcher,
193
+ batch: _batch,
194
+ ...requestOptions
195
+ } = merged;
196
+
197
+ this.url = url ?? '';
198
+ this.requestOptions = requestOptions;
199
+ this.headers = headers ?? {};
200
+ this.fetchImplementation = customFetchImplementation ?? globalThis.fetch ?? null;
201
+
202
+ const processEnvironment = getProcessEnvironment();
203
+ const tokenFromHeaders = getTokenFromHeaders(
204
+ typeof headers === 'function' ? undefined : headers,
205
+ );
206
+
207
+ // Priority: explicit header > TWENTY_APP_ACCESS_TOKEN > TWENTY_API_KEY (legacy fallback).
208
+ this.authorizationToken =
209
+ tokenFromHeaders ??
210
+ processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] ??
211
+ processEnvironment[API_KEY_ENV_KEY] ??
212
+ null;
213
+
214
+ this.client = createClient({
215
+ ...merged,
216
+ headers: undefined,
217
+ fetcher: async (operation) =>
218
+ this.executeGraphqlRequestWithOptionalRefresh({
219
+ operation,
220
+ }),
221
+ });
222
+ }
223
+
224
+ query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {
225
+ return this.client.query(request);
226
+ }
227
+
228
+ mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {
229
+ return this.client.mutation(request);
230
+ }
231
+
232
+ private async executeGraphqlRequestWithOptionalRefresh({
233
+ operation,
234
+ headers,
235
+ requestInit,
236
+ }: {
237
+ operation: GraphqlOperation | GraphqlOperation[] | FormData;
238
+ headers?: HeadersInit;
239
+ requestInit?: RequestInit;
240
+ }) {
241
+ const firstResponse = await this.executeGraphqlRequest({
242
+ operation,
243
+ headers,
244
+ requestInit,
245
+ token: this.authorizationToken,
246
+ });
247
+
248
+ if (this.shouldRefreshToken(firstResponse)) {
249
+ const refreshedAccessToken = await this.requestRefreshedAccessToken();
250
+
251
+ if (refreshedAccessToken) {
252
+ const retryResponse = await this.executeGraphqlRequest({
253
+ operation,
254
+ headers,
255
+ requestInit,
256
+ token: refreshedAccessToken,
257
+ });
258
+
259
+ return this.assertResponseIsSuccessful(retryResponse);
260
+ }
261
+ }
262
+
263
+ return this.assertResponseIsSuccessful(firstResponse);
264
+ }
265
+
266
+ private async executeGraphqlRequest({
267
+ operation,
268
+ headers,
269
+ requestInit,
270
+ token,
271
+ }: {
272
+ operation: GraphqlOperation | GraphqlOperation[] | FormData;
273
+ headers?: HeadersInit;
274
+ requestInit?: RequestInit;
275
+ token: string | null;
276
+ }): Promise<GraphqlResponse> {
277
+ if (!this.fetchImplementation) {
278
+ throw new Error(
279
+ 'Global `fetch` function is not available, pass a fetch implementation to the Twenty client',
280
+ );
281
+ }
282
+
283
+ const resolvedHeaders = await this.resolveHeaders();
284
+ const requestHeaders = new Headers(resolvedHeaders);
285
+
286
+ if (headers) {
287
+ new Headers(headers).forEach((value, key) => requestHeaders.set(key, value));
288
+ }
289
+
290
+ if (operation instanceof FormData) {
291
+ requestHeaders.delete('Content-Type');
292
+ } else {
293
+ requestHeaders.set('Content-Type', 'application/json');
294
+ }
295
+
296
+ if (token) {
297
+ requestHeaders.set('Authorization', `Bearer ${token}`);
298
+ } else {
299
+ requestHeaders.delete('Authorization');
300
+ }
301
+
302
+ const response = await this.fetchImplementation.call(globalThis, this.url, {
303
+ ...this.requestOptions,
304
+ ...requestInit,
305
+ method: requestInit?.method ?? 'POST',
306
+ headers: requestHeaders,
307
+ body: operation instanceof FormData ? operation : JSON.stringify(operation),
308
+ });
309
+
310
+ const rawBody = await response.text();
311
+ let payload: GraphqlResponsePayload | null = null;
312
+
313
+ if (rawBody.trim().length > 0) {
314
+ try {
315
+ payload = JSON.parse(rawBody) as GraphqlResponsePayload;
316
+ } catch {
317
+ payload = null;
318
+ }
319
+ }
320
+
321
+ return {
322
+ status: response.status,
323
+ statusText: response.statusText,
324
+ payload,
325
+ rawBody,
326
+ }
327
+ }
328
+
329
+ private async resolveHeaders(): Promise<HeadersInit> {
330
+ if (typeof this.headers === 'function') {
331
+ return (await this.headers()) ?? {};
332
+ }
333
+
334
+ return this.headers ?? {};
335
+ }
336
+
337
+ private shouldRefreshToken(response: GraphqlResponse): boolean {
338
+ if (response.status === 401) {
339
+ return true;
340
+ }
341
+
342
+ return hasAuthenticationErrorInGraphqlPayload(response.payload);
343
+ }
344
+
345
+ private assertResponseIsSuccessful(response: GraphqlResponse) {
346
+ if (response.status < 200 || response.status >= 300) {
347
+ throw new Error(`${response.statusText}: ${response.rawBody}`);
348
+ }
349
+
350
+ if (response.payload === null) {
351
+ throw new Error('Invalid JSON response');
352
+ }
353
+
354
+ return response.payload;
355
+ }
356
+
357
+ private async requestRefreshedAccessToken(): Promise<string | null> {
358
+ const refreshAccessTokenFunction = (
359
+ globalThis as {
360
+ frontComponentHostCommunicationApi?: {
361
+ requestAccessTokenRefresh?: () => Promise<string>
362
+ }
363
+ }
364
+ ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;
365
+
366
+ if (typeof refreshAccessTokenFunction !== 'function') {
367
+ return null;
368
+ }
369
+
370
+ if (!this.refreshAccessTokenPromise) {
371
+ this.refreshAccessTokenPromise = refreshAccessTokenFunction()
372
+ .then((refreshedAccessToken) => {
373
+ if (
374
+ typeof refreshedAccessToken !== 'string' ||
375
+ refreshedAccessToken.length === 0
376
+ ) {
377
+ return null;
378
+ }
379
+
380
+ this.setAuthorizationToken(refreshedAccessToken);
381
+
382
+ return refreshedAccessToken;
383
+ })
384
+ .catch((error) => {
385
+ console.error('Twenty client: token refresh failed', error);
386
+
387
+ return null;
388
+ })
389
+ .finally(() => {
390
+ this.refreshAccessTokenPromise = null;
391
+ });
392
+ }
393
+
394
+ return this.refreshAccessTokenPromise;
395
+ }
396
+
397
+ private setAuthorizationToken(token: string) {
398
+ this.authorizationToken = token;
399
+
400
+ const processEnvironment = getProcessEnvironment();
401
+
402
+ processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;
403
+ processEnvironment[API_KEY_ENV_KEY] = token;
404
+ }
405
+ }
406
+