twenty-sdk 2.19.0 → 2.21.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.
Files changed (42) hide show
  1. package/dist/billing/index.cjs.map +1 -1
  2. package/dist/billing/index.mjs.map +1 -1
  3. package/dist/catalog-sync-CjqZ81jv.mjs +18 -0
  4. package/dist/{catalog-sync-DHopgolZ.js → catalog-sync-DoBWDnCd.js} +1 -1
  5. package/dist/cli/utilities/api/api-service.d.ts +10 -0
  6. package/dist/cli/utilities/api/application-api.d.ts +10 -0
  7. package/dist/cli/utilities/auth/build-app-token-pair-fetcher.d.ts +5 -0
  8. package/dist/cli/utilities/auth/ensure-app-access-token-is-valid-or-refresh.d.ts +11 -4
  9. package/dist/cli/utilities/auth/ensure-app-registration.d.ts +1 -1
  10. package/dist/cli/utilities/build/common/esbuild-result-processor.d.ts +2 -2
  11. package/dist/cli/utilities/dev/orchestrator/dev-mode-orchestrator.d.ts +1 -0
  12. package/dist/cli/utilities/dev/orchestrator/steps/generate-api-client-orchestrator-step.d.ts +2 -4
  13. package/dist/cli/utilities/dev/orchestrator/steps/register-app-orchestrator-step.d.ts +1 -1
  14. package/dist/cli/utilities/version/get-server-version-from-api.d.ts +1 -0
  15. package/dist/cli.cjs +25 -32
  16. package/dist/cli.mjs +39604 -39589
  17. package/dist/define/index.cjs +19 -19
  18. package/dist/define/index.cjs.map +1 -1
  19. package/dist/define/index.d.ts +102 -18
  20. package/dist/define/index.mjs +5363 -5306
  21. package/dist/define/index.mjs.map +1 -1
  22. package/dist/front-component/index.cjs.map +1 -1
  23. package/dist/front-component/index.d.ts +1 -0
  24. package/dist/front-component/index.mjs +1 -1
  25. package/dist/front-component/index.mjs.map +1 -1
  26. package/dist/front-component-renderer/build.cjs +1 -1
  27. package/dist/front-component-renderer/build.mjs +6 -2
  28. package/dist/{get-front-component-build-plugins-Dqpyup2W.js → get-front-component-build-plugins-C7h3DVdC.js} +2 -2
  29. package/dist/{get-front-component-build-plugins-taotEFOp.mjs → get-front-component-build-plugins-klRAsPTE.mjs} +39 -32
  30. package/dist/get-function-input-schema-GNk3NRLJ-C4DmUxTK.mjs +77 -0
  31. package/dist/logic-function/index.cjs.map +1 -1
  32. package/dist/logic-function/index.mjs.map +1 -1
  33. package/dist/{login-Dasbw3em.mjs → login-CIXRVsRD.mjs} +6728 -6700
  34. package/dist/{login-eEfUoaiV.js → login-CZP9z64V.js} +60 -47
  35. package/dist/operations.cjs +1 -1
  36. package/dist/operations.mjs +8 -4
  37. package/dist/utils/index.cjs.map +1 -1
  38. package/dist/utils/index.mjs.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/catalog-sync-COKCJ_xf.mjs +0 -14
  41. package/dist/cli/utilities/build/manifest/utils/get-default-object-fields.d.ts +0 -6
  42. package/dist/get-function-input-schema-GNk3NRLJ-BoFRwEYV.mjs +0 -73
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["e","t","e","t"],"sources":["../../../twenty-shared/dist/ViewKey-YV4NySfb.mjs","../../../twenty-shared/dist/get-field-universal-identifier.util-CK9_m9RQ.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({}), t = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as n, t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { n, t as r, r as t };\n","import { n as e, t } from \"./ViewKey-YV4NySfb.mjs\";\nimport { n, r, t as i } from \"./get-field-universal-identifier.util-CK9_m9RQ.mjs\";\n//#region src/application/applicationVariablesType.ts\nvar a = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], o = \"public\", s = \"TWENTY_API_KEY\", c = \"TWENTY_API_URL\", l = \"TWENTY_APP_ACCESS_TOKEN\", u = \"TWENTY_FUNCTIONS_URL\", d = \"generated\", f = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, p = \".twenty/output\", m = \"Standard\", h = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), g = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), _ = \"navigation\", v = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), y = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), b = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${r ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), x = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${_}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, componentName: t }) => n({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, link: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, nameSingular: t }) => n({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), P = \"RECORD_PAGE\", F = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${r}` : r,\n\tapplicationUniversalIdentifier: e\n}), I = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${P}`,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: r }) => n({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, label: t }) => n({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => n({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: r }) => n({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r, operand: i, subFieldName: a }) => n({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${r}:${i}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: r }) => n({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${r}:${t.INDEX}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => n({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), Q = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), $ = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ee = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { a as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, o as ASSETS_DIR, s as DEFAULT_API_KEY_NAME, c as DEFAULT_API_URL_NAME, l as DEFAULT_APP_ACCESS_TOKEN_NAME, u as DEFAULT_FUNCTIONS_URL_NAME, d as GENERATED_DIR, f as NODE_ESM_CJS_BANNER, p as OUTPUT_DIR, Q as SyncableEntity, m as TWENTY_STANDARD_APPLICATION_NAME, r as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, n as computeDeterministicUuid, ee as deserializeApplicationVariableValue, h as getAgentUniversalIdentifier, g as getApplicationVariableUniversalIdentifier, S as getConnectionProviderUniversalIdentifier, C as getFieldPermissionUniversalIdentifier, i as getFieldUniversalIdentifier, Z as getFieldsWidgetViewUniversalIdentifier, D as getFolderNavigationMenuItemUniversalIdentifier, w as getFrontComponentUniversalIdentifier, v as getGlobalCommandMenuItemUniversalIdentifier, y as getGlobalObjectContextCommandMenuItemUniversalIdentifier, T as getIndexUniversalIdentifier, X as getIndexViewUniversalIdentifier, A as getLinkNavigationMenuItemUniversalIdentifier, E as getLogicFunctionUniversalIdentifier, x as getNavigationCommandUniversalIdentifier, O as getObjectNavigationMenuItemUniversalIdentifier, j as getObjectPermissionUniversalIdentifier, M as getObjectUniversalIdentifier, N as getPageLayoutTabUniversalIdentifier, F as getPageLayoutUniversalIdentifier, L as getPageLayoutWidgetUniversalIdentifier, R as getPermissionFlagUniversalIdentifier, I as getRecordPageLayoutUniversalIdentifier, b as getRecordSelectionCommandMenuItemUniversalIdentifier, z as getRolePermissionFlagUniversalIdentifier, B as getRoleUniversalIdentifier, V as getSearchFieldUniversalIdentifier, H as getSelectOptionUniversalIdentifier, U as getSkillUniversalIdentifier, W as getViewFieldGroupUniversalIdentifier, G as getViewFieldUniversalIdentifier, K as getViewFilterUniversalIdentifier, q as getViewGroupUniversalIdentifier, k as getViewNavigationMenuItemUniversalIdentifier, J as getViewSortUniversalIdentifier, Y as getViewUniversalIdentifier, $ as serializeApplicationVariableValue };\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"],"mappings":"mFACA,IAAIA,EAAoB,SAAS,EAAG,CACnC,MAAO,GAAE,MAAQ,QAAS,EAAE,QAAU,UAAW,EAAE,MAAQ,QAAS,EAAE,QAAU,UAAW,EAAE,SAAW,WAAY,EAAE,KAAO,OAAQ,EAAE,UAAY,YAAa,EAAE,OAAS,SAAU,EAAE,MAAQ,QAAS,EAAE,UAAY,YAAa,EAAE,MAAQ,QAAS,EAAE,eAAiB,iBAAkB,EAAE,aAAe,eAAgB,EAAE,OAAS,SAAU,EAAE,QAAU,UAAW,EAAE,OAAS,SAAU,EAAE,SAAW,WAAY,EAAE,OAAS,SAAU,EAAE,SAAW,WAAY,EAAE,SAAW,WAAY,EAAE,UAAY,YAAa,EAAE,OAAS,SAAU,EAAE,KAAO,OAAQ,EAAE,UAAY,YAAa,EAAE,KAAO,OAAQ,CAC3kB,EAAE,CAAC,CAAC,EECHE,EAAE,KACFA,EAAE,MACFA,EAAE,QACFA,EAAE,KACFA,EAAE,UACFA,EAAE,OACFA,EAAE,QACFA,EAAE,SACFA,EAAE,UACFA,EAAE,OACFA,EAAE,aAXH,IAYuC,EAAI,iBAAkB,EAAI,0BCV3D,EAA4B,IAerB,EAAgB,MAAO,CAClC,mBACA,gBACA,WAAW,EACX,qBACwC,CACxC,IAAM,EAAS,QAAQ,IAAI,GACrB,EAAQ,QAAQ,IAAI,GAEtB,MAAC,GAAU,CAAC,GAIhB,GAAI,CACF,IAAM,EAAW,MAAM,MACrB,GAAG,EAAO,QAAQ,MAAO,EAAE,EAAE,qBAC7B,CACE,OAAQ,OACR,QAAS,CACP,cAAe,UAAU,IACzB,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAU,CACnB,mBACA,WACA,gBACA,iBACF,CAAC,EACD,OAAQ,YAAY,QAAQ,CAAyB,CACvD,CACF,EAEA,GAAI,CAAC,EAAS,GAAI,CAChB,IAAM,EAAO,MAAM,EAAS,KAAK,EAAE,UAAY,EAAE,EAEjD,QAAQ,MACN,kBAAkB,EAAS,OAAO,GAAG,EAAS,WAAW,IAAI,GAC/D,CACF,CACF,OAAS,EAAO,CACd,QAAQ,MACN,kBAAkB,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,GACzE,CACF,CACF"}
1
+ {"version":3,"file":"index.cjs","names":["e","t","e","t"],"sources":["../../../twenty-shared/dist/ViewKey-YV4NySfb.mjs","../../../twenty-shared/dist/get-field-universal-identifier.util-CK9_m9RQ.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({}), t = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as n, t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { n, t as r, r as t };\n","import { n as e, t } from \"./ViewKey-YV4NySfb.mjs\";\nimport { n, r, t as i } from \"./get-field-universal-identifier.util-CK9_m9RQ.mjs\";\n//#region src/application/applicationCategoryType.ts\nvar a = [\n\t\"Communication\",\n\t\"Productivity\",\n\t\"Product management\",\n\t\"Sales\",\n\t\"Marketing\",\n\t\"Enrichment\",\n\t\"Data\",\n\t\"Search\",\n\t\"Other\"\n], o = (e) => a.includes(e), s = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], c = \"public\", l = \"TWENTY_API_KEY\", u = \"TWENTY_API_URL\", d = \"TWENTY_APP_ACCESS_TOKEN\", f = \"TWENTY_FUNCTIONS_URL\", p = \"generated\", m = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, h = \".twenty/output\", g = \"Standard\", _ = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), v = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), y = \"navigation\", b = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), x = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${r ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${y}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, componentName: t }) => n({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), ee = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, link: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, nameSingular: t }) => n({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), P = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), F = \"RECORD_PAGE\", I = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${r}` : r,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${F}`,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: r }) => n({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, label: t }) => n({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => n({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: r }) => n({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r, operand: i, subFieldName: a }) => n({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${r}:${i}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: r }) => n({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${r}:${t.INDEX}`,\n\tapplicationUniversalIdentifier: e\n}), Q = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => n({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), $ = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), te = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ne = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { a as APPLICATION_CATEGORIES, s as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, c as ASSETS_DIR, l as DEFAULT_API_KEY_NAME, u as DEFAULT_API_URL_NAME, d as DEFAULT_APP_ACCESS_TOKEN_NAME, f as DEFAULT_FUNCTIONS_URL_NAME, p as GENERATED_DIR, m as NODE_ESM_CJS_BANNER, h as OUTPUT_DIR, $ as SyncableEntity, g as TWENTY_STANDARD_APPLICATION_NAME, r as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, n as computeDeterministicUuid, ne as deserializeApplicationVariableValue, _ as getAgentUniversalIdentifier, v as getApplicationVariableUniversalIdentifier, w as getConnectionProviderUniversalIdentifier, T as getFieldPermissionUniversalIdentifier, i as getFieldUniversalIdentifier, Q as getFieldsWidgetViewUniversalIdentifier, k as getFolderNavigationMenuItemUniversalIdentifier, E as getFrontComponentUniversalIdentifier, b as getGlobalCommandMenuItemUniversalIdentifier, x as getGlobalObjectContextCommandMenuItemUniversalIdentifier, D as getIndexUniversalIdentifier, Z as getIndexViewUniversalIdentifier, j as getLinkNavigationMenuItemUniversalIdentifier, O as getLogicFunctionUniversalIdentifier, C as getNavigationCommandUniversalIdentifier, A as getObjectNavigationMenuItemUniversalIdentifier, M as getObjectPermissionUniversalIdentifier, N as getObjectUniversalIdentifier, P as getPageLayoutTabUniversalIdentifier, I as getPageLayoutUniversalIdentifier, R as getPageLayoutWidgetUniversalIdentifier, z as getPermissionFlagUniversalIdentifier, L as getRecordPageLayoutUniversalIdentifier, S as getRecordSelectionCommandMenuItemUniversalIdentifier, B as getRolePermissionFlagUniversalIdentifier, V as getRoleUniversalIdentifier, H as getSearchFieldUniversalIdentifier, U as getSelectOptionUniversalIdentifier, W as getSkillUniversalIdentifier, G as getViewFieldGroupUniversalIdentifier, K as getViewFieldUniversalIdentifier, q as getViewFilterUniversalIdentifier, J as getViewGroupUniversalIdentifier, ee as getViewNavigationMenuItemUniversalIdentifier, Y as getViewSortUniversalIdentifier, X as getViewUniversalIdentifier, o as isKnownApplicationCategory, te as serializeApplicationVariableValue };\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"],"mappings":"mFACA,IAAIA,EAAoB,SAAS,EAAG,CACnC,MAAO,GAAE,MAAQ,QAAS,EAAE,QAAU,UAAW,EAAE,MAAQ,QAAS,EAAE,QAAU,UAAW,EAAE,SAAW,WAAY,EAAE,KAAO,OAAQ,EAAE,UAAY,YAAa,EAAE,OAAS,SAAU,EAAE,MAAQ,QAAS,EAAE,UAAY,YAAa,EAAE,MAAQ,QAAS,EAAE,eAAiB,iBAAkB,EAAE,aAAe,eAAgB,EAAE,OAAS,SAAU,EAAE,QAAU,UAAW,EAAE,OAAS,SAAU,EAAE,SAAW,WAAY,EAAE,OAAS,SAAU,EAAE,SAAW,WAAY,EAAE,SAAW,WAAY,EAAE,UAAY,YAAa,EAAE,OAAS,SAAU,EAAE,KAAO,OAAQ,EAAE,UAAY,YAAa,EAAE,KAAO,OAAQ,CAC3kB,EAAE,CAAC,CAAC,EEWHE,EAAE,KACFA,EAAE,MACFA,EAAE,QACFA,EAAE,KACFA,EAAE,UACFA,EAAE,OACFA,EAAE,QACFA,EAAE,SACFA,EAAE,UACFA,EAAE,OACFA,EAAE,aArBH,IAsBuC,EAAI,iBAAkB,EAAI,0BCpB3D,EAA4B,IAerB,EAAgB,MAAO,CAClC,mBACA,gBACA,WAAW,EACX,qBACwC,CACxC,IAAM,EAAS,QAAQ,IAAI,GACrB,EAAQ,QAAQ,IAAI,GAEtB,MAAC,GAAU,CAAC,GAIhB,GAAI,CACF,IAAM,EAAW,MAAM,MACrB,GAAG,EAAO,QAAQ,MAAO,EAAE,EAAE,qBAC7B,CACE,OAAQ,OACR,QAAS,CACP,cAAe,UAAU,IACzB,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAU,CACnB,mBACA,WACA,gBACA,iBACF,CAAC,EACD,OAAQ,YAAY,QAAQ,CAAyB,CACvD,CACF,EAEA,GAAI,CAAC,EAAS,GAAI,CAChB,IAAM,EAAO,MAAM,EAAS,KAAK,EAAE,UAAY,EAAE,EAEjD,QAAQ,MACN,kBAAkB,EAAS,OAAO,GAAG,EAAS,WAAW,IAAI,GAC/D,CACF,CACF,OAAS,EAAO,CACd,QAAQ,MACN,kBAAkB,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,GACzE,CACF,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["t","e","t"],"sources":["../../../twenty-shared/dist/ViewKey-YV4NySfb.mjs","../../../twenty-shared/dist/get-field-universal-identifier.util-CK9_m9RQ.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({}), t = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as n, t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { n, t as r, r as t };\n","import { n as e, t } from \"./ViewKey-YV4NySfb.mjs\";\nimport { n, r, t as i } from \"./get-field-universal-identifier.util-CK9_m9RQ.mjs\";\n//#region src/application/applicationVariablesType.ts\nvar a = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], o = \"public\", s = \"TWENTY_API_KEY\", c = \"TWENTY_API_URL\", l = \"TWENTY_APP_ACCESS_TOKEN\", u = \"TWENTY_FUNCTIONS_URL\", d = \"generated\", f = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, p = \".twenty/output\", m = \"Standard\", h = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), g = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), _ = \"navigation\", v = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), y = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), b = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${r ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), x = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${_}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, componentName: t }) => n({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, link: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, nameSingular: t }) => n({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), P = \"RECORD_PAGE\", F = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${r}` : r,\n\tapplicationUniversalIdentifier: e\n}), I = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${P}`,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: r }) => n({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, label: t }) => n({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => n({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: r }) => n({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r, operand: i, subFieldName: a }) => n({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${r}:${i}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: r }) => n({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${r}:${t.INDEX}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => n({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), Q = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), $ = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ee = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { a as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, o as ASSETS_DIR, s as DEFAULT_API_KEY_NAME, c as DEFAULT_API_URL_NAME, l as DEFAULT_APP_ACCESS_TOKEN_NAME, u as DEFAULT_FUNCTIONS_URL_NAME, d as GENERATED_DIR, f as NODE_ESM_CJS_BANNER, p as OUTPUT_DIR, Q as SyncableEntity, m as TWENTY_STANDARD_APPLICATION_NAME, r as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, n as computeDeterministicUuid, ee as deserializeApplicationVariableValue, h as getAgentUniversalIdentifier, g as getApplicationVariableUniversalIdentifier, S as getConnectionProviderUniversalIdentifier, C as getFieldPermissionUniversalIdentifier, i as getFieldUniversalIdentifier, Z as getFieldsWidgetViewUniversalIdentifier, D as getFolderNavigationMenuItemUniversalIdentifier, w as getFrontComponentUniversalIdentifier, v as getGlobalCommandMenuItemUniversalIdentifier, y as getGlobalObjectContextCommandMenuItemUniversalIdentifier, T as getIndexUniversalIdentifier, X as getIndexViewUniversalIdentifier, A as getLinkNavigationMenuItemUniversalIdentifier, E as getLogicFunctionUniversalIdentifier, x as getNavigationCommandUniversalIdentifier, O as getObjectNavigationMenuItemUniversalIdentifier, j as getObjectPermissionUniversalIdentifier, M as getObjectUniversalIdentifier, N as getPageLayoutTabUniversalIdentifier, F as getPageLayoutUniversalIdentifier, L as getPageLayoutWidgetUniversalIdentifier, R as getPermissionFlagUniversalIdentifier, I as getRecordPageLayoutUniversalIdentifier, b as getRecordSelectionCommandMenuItemUniversalIdentifier, z as getRolePermissionFlagUniversalIdentifier, B as getRoleUniversalIdentifier, V as getSearchFieldUniversalIdentifier, H as getSelectOptionUniversalIdentifier, U as getSkillUniversalIdentifier, W as getViewFieldGroupUniversalIdentifier, G as getViewFieldUniversalIdentifier, K as getViewFilterUniversalIdentifier, q as getViewGroupUniversalIdentifier, k as getViewNavigationMenuItemUniversalIdentifier, J as getViewSortUniversalIdentifier, Y as getViewUniversalIdentifier, $ as serializeApplicationVariableValue };\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"],"mappings":";;AACA,IAAI,IAAoB,yBAAS,GAAG;CACnC,OAAO,EAAE,QAAQ,SAAS,EAAE,UAAU,WAAW,EAAE,QAAQ,SAAS,EAAE,UAAU,WAAW,EAAE,WAAW,YAAY,EAAE,OAAO,QAAQ,EAAE,YAAY,aAAa,EAAE,SAAS,UAAU,EAAE,QAAQ,SAAS,EAAE,YAAY,aAAa,EAAE,QAAQ,SAAS,EAAE,iBAAiB,kBAAkB,EAAE,eAAe,gBAAgB,EAAE,SAAS,UAAU,EAAE,UAAU,WAAW,EAAE,SAAS,UAAU,EAAE,WAAW,YAAY,EAAE,SAAS,UAAU,EAAE,WAAW,YAAY,EAAE,WAAW,YAAY,EAAE,YAAY,aAAa,EAAE,SAAS,UAAU,EAAE,OAAO,QAAQ,EAAE,YAAY,aAAa,EAAE,OAAO,QAAQ;AAC3kB,EAAE,CAAC,CAAC;AECH,EAAE,MACF,EAAE,OACF,EAAE,SACF,EAAE,MACF,EAAE,WACF,EAAE,QACF,EAAE,SACF,EAAE,UACF,EAAE,WACF,EAAE,QACF,EAAE;;;AAXH,IAYuC,IAAI,kBAAkB,IAAI,2BCV3D,IAA4B,KAerB,IAAgB,OAAO,EAClC,qBACA,kBACA,cAAW,GACX,yBACwC;CACxC,IAAM,IAAS,QAAQ,IAAI,IACrB,IAAQ,QAAQ,IAAI;CAEtB,OAAC,KAAU,CAAC,IAIhB,IAAI;EACF,IAAM,IAAW,MAAM,MACrB,GAAG,EAAO,QAAQ,OAAO,EAAE,EAAE,sBAC7B;GACE,QAAQ;GACR,SAAS;IACP,eAAe,UAAU;IACzB,gBAAgB;GAClB;GACA,MAAM,KAAK,UAAU;IACnB;IACA;IACA;IACA;GACF,CAAC;GACD,QAAQ,YAAY,QAAQ,CAAyB;EACvD,CACF;EAEA,IAAI,CAAC,EAAS,IAAI;GAChB,IAAM,IAAO,MAAM,EAAS,KAAK,EAAE,YAAY,EAAE;GAEjD,QAAQ,MACN,kBAAkB,EAAS,OAAO,GAAG,EAAS,WAAW,IAAI,GAC/D;EACF;CACF,SAAS,GAAO;EACd,QAAQ,MACN,kBAAkB,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK,GACzE;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["t","e","t"],"sources":["../../../twenty-shared/dist/ViewKey-YV4NySfb.mjs","../../../twenty-shared/dist/get-field-universal-identifier.util-CK9_m9RQ.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/billing/charge-credits.ts"],"sourcesContent":["//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({}), t = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as n, t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { n, t as r, r as t };\n","import { n as e, t } from \"./ViewKey-YV4NySfb.mjs\";\nimport { n, r, t as i } from \"./get-field-universal-identifier.util-CK9_m9RQ.mjs\";\n//#region src/application/applicationCategoryType.ts\nvar a = [\n\t\"Communication\",\n\t\"Productivity\",\n\t\"Product management\",\n\t\"Sales\",\n\t\"Marketing\",\n\t\"Enrichment\",\n\t\"Data\",\n\t\"Search\",\n\t\"Other\"\n], o = (e) => a.includes(e), s = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], c = \"public\", l = \"TWENTY_API_KEY\", u = \"TWENTY_API_URL\", d = \"TWENTY_APP_ACCESS_TOKEN\", f = \"TWENTY_FUNCTIONS_URL\", p = \"generated\", m = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, h = \".twenty/output\", g = \"Standard\", _ = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), v = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), y = \"navigation\", b = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), x = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${r ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${y}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, componentName: t }) => n({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), ee = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, link: t }) => n({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, nameSingular: t }) => n({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), P = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), F = \"RECORD_PAGE\", I = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${r}` : r,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => n({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${F}`,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: r }) => n({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, key: t }) => n({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: r }) => n({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, label: t }) => n({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => n({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: r }) => n({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, name: t }) => n({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r, operand: i, subFieldName: a }) => n({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${r}:${i}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: r }) => n({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${r}:${t.INDEX}`,\n\tapplicationUniversalIdentifier: e\n}), Q = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => n({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), $ = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), te = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ne = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { a as APPLICATION_CATEGORIES, s as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, c as ASSETS_DIR, l as DEFAULT_API_KEY_NAME, u as DEFAULT_API_URL_NAME, d as DEFAULT_APP_ACCESS_TOKEN_NAME, f as DEFAULT_FUNCTIONS_URL_NAME, p as GENERATED_DIR, m as NODE_ESM_CJS_BANNER, h as OUTPUT_DIR, $ as SyncableEntity, g as TWENTY_STANDARD_APPLICATION_NAME, r as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, n as computeDeterministicUuid, ne as deserializeApplicationVariableValue, _ as getAgentUniversalIdentifier, v as getApplicationVariableUniversalIdentifier, w as getConnectionProviderUniversalIdentifier, T as getFieldPermissionUniversalIdentifier, i as getFieldUniversalIdentifier, Q as getFieldsWidgetViewUniversalIdentifier, k as getFolderNavigationMenuItemUniversalIdentifier, E as getFrontComponentUniversalIdentifier, b as getGlobalCommandMenuItemUniversalIdentifier, x as getGlobalObjectContextCommandMenuItemUniversalIdentifier, D as getIndexUniversalIdentifier, Z as getIndexViewUniversalIdentifier, j as getLinkNavigationMenuItemUniversalIdentifier, O as getLogicFunctionUniversalIdentifier, C as getNavigationCommandUniversalIdentifier, A as getObjectNavigationMenuItemUniversalIdentifier, M as getObjectPermissionUniversalIdentifier, N as getObjectUniversalIdentifier, P as getPageLayoutTabUniversalIdentifier, I as getPageLayoutUniversalIdentifier, R as getPageLayoutWidgetUniversalIdentifier, z as getPermissionFlagUniversalIdentifier, L as getRecordPageLayoutUniversalIdentifier, S as getRecordSelectionCommandMenuItemUniversalIdentifier, B as getRolePermissionFlagUniversalIdentifier, V as getRoleUniversalIdentifier, H as getSearchFieldUniversalIdentifier, U as getSelectOptionUniversalIdentifier, W as getSkillUniversalIdentifier, G as getViewFieldGroupUniversalIdentifier, K as getViewFieldUniversalIdentifier, q as getViewFilterUniversalIdentifier, J as getViewGroupUniversalIdentifier, ee as getViewNavigationMenuItemUniversalIdentifier, Y as getViewSortUniversalIdentifier, X as getViewUniversalIdentifier, o as isKnownApplicationCategory, te as serializeApplicationVariableValue };\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"],"mappings":";;AACA,IAAI,IAAoB,yBAAS,GAAG;CACnC,OAAO,EAAE,QAAQ,SAAS,EAAE,UAAU,WAAW,EAAE,QAAQ,SAAS,EAAE,UAAU,WAAW,EAAE,WAAW,YAAY,EAAE,OAAO,QAAQ,EAAE,YAAY,aAAa,EAAE,SAAS,UAAU,EAAE,QAAQ,SAAS,EAAE,YAAY,aAAa,EAAE,QAAQ,SAAS,EAAE,iBAAiB,kBAAkB,EAAE,eAAe,gBAAgB,EAAE,SAAS,UAAU,EAAE,UAAU,WAAW,EAAE,SAAS,UAAU,EAAE,WAAW,YAAY,EAAE,SAAS,UAAU,EAAE,WAAW,YAAY,EAAE,WAAW,YAAY,EAAE,YAAY,aAAa,EAAE,SAAS,UAAU,EAAE,OAAO,QAAQ,EAAE,YAAY,aAAa,EAAE,OAAO,QAAQ;AAC3kB,EAAE,CAAC,CAAC;AEWH,EAAE,MACF,EAAE,OACF,EAAE,SACF,EAAE,MACF,EAAE,WACF,EAAE,QACF,EAAE,SACF,EAAE,UACF,EAAE,WACF,EAAE,QACF,EAAE;;;AArBH,IAsBuC,IAAI,kBAAkB,IAAI,2BCpB3D,IAA4B,KAerB,IAAgB,OAAO,EAClC,qBACA,kBACA,cAAW,GACX,yBACwC;CACxC,IAAM,IAAS,QAAQ,IAAI,IACrB,IAAQ,QAAQ,IAAI;CAEtB,OAAC,KAAU,CAAC,IAIhB,IAAI;EACF,IAAM,IAAW,MAAM,MACrB,GAAG,EAAO,QAAQ,OAAO,EAAE,EAAE,sBAC7B;GACE,QAAQ;GACR,SAAS;IACP,eAAe,UAAU;IACzB,gBAAgB;GAClB;GACA,MAAM,KAAK,UAAU;IACnB;IACA;IACA;IACA;GACF,CAAC;GACD,QAAQ,YAAY,QAAQ,CAAyB;EACvD,CACF;EAEA,IAAI,CAAC,EAAS,IAAI;GAChB,IAAM,IAAO,MAAM,EAAS,KAAK,EAAE,YAAY,EAAE;GAEjD,QAAQ,MACN,kBAAkB,EAAS,OAAO,GAAG,EAAS,WAAW,IAAI,GAC/D;EACF;CACF,SAAS,GAAO;EACd,QAAQ,MACN,kBAAkB,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK,GACzE;CACF;AACF"}
@@ -0,0 +1,18 @@
1
+ import { createRequire as e } from "node:module";
2
+ import { fileURLToPath as t } from "node:url";
3
+ import { dirname as n } from "node:path";
4
+ e(import.meta.url), n(t(import.meta.url));
5
+ import { U as r, z as i } from "./login-CIXRVsRD.mjs";
6
+ import a from "chalk";
7
+ //#region src/cli/commands/dev/catalog-sync.ts
8
+ var o = class {
9
+ async execute(e) {
10
+ e.remote && r.setActiveRemote(e.remote);
11
+ let t = r.getActiveRemote();
12
+ console.log(a.blue(`Syncing marketplace catalog on ${t}...`));
13
+ let n = await new i().syncMarketplaceCatalog();
14
+ n.success || (console.error(a.red(`Catalog sync failed: ${n.error instanceof Error ? n.error.message : String(n.error)}`)), process.exit(1)), console.log(a.green("✓ Marketplace catalog synced successfully"));
15
+ }
16
+ };
17
+ //#endregion
18
+ export { o as CatalogSyncCommand };
@@ -1 +1 @@
1
- const e=require("./get-front-component-build-plugins-Dqpyup2W.js"),t=require("./login-eEfUoaiV.js");let n=require("chalk");n=e.i(n);var r=class{async execute(e){e.remote&&t.U.setActiveRemote(e.remote);let r=t.U.getActiveRemote();console.log(n.default.blue(`Syncing marketplace catalog on ${r}...`));let i=await new t.z().syncMarketplaceCatalog();i.success||(console.error(n.default.red(`Catalog sync failed: ${i.error instanceof Error?i.error.message:String(i.error)}`)),process.exit(1)),console.log(n.default.green(`✓ Marketplace catalog synced successfully`))}};exports.CatalogSyncCommand=r;
1
+ const e=require("./get-front-component-build-plugins-C7h3DVdC.js"),t=require("./login-CZP9z64V.js");let n=require("chalk");n=e.i(n);var r=class{async execute(e){e.remote&&t.U.setActiveRemote(e.remote);let r=t.U.getActiveRemote();console.log(n.default.blue(`Syncing marketplace catalog on ${r}...`));let i=await new t.z().syncMarketplaceCatalog();i.success||(console.error(n.default.red(`Catalog sync failed: ${i.error instanceof Error?i.error.message:String(i.error)}`)),process.exit(1)),console.log(n.default.green(`✓ Marketplace catalog synced successfully`))}};exports.CatalogSyncCommand=r;
@@ -44,6 +44,16 @@ export declare class ApiService {
44
44
  id: string;
45
45
  universalIdentifier: string;
46
46
  }>>;
47
+ generateApplicationToken(...args: Parameters<ApplicationApi['generateApplicationToken']>): Promise<ApiResponse<{
48
+ applicationAccessToken: {
49
+ token: string;
50
+ expiresAt: string;
51
+ };
52
+ applicationRefreshToken: {
53
+ token: string;
54
+ expiresAt: string;
55
+ };
56
+ }>>;
47
57
  syncApplication(manifest: Manifest, options?: {
48
58
  dryRun?: boolean;
49
59
  }): Promise<ApiResponse<{
@@ -26,6 +26,16 @@ export declare class ApplicationApi {
26
26
  rotateApplicationRegistrationClientSecret(id: string): Promise<ApiResponse<{
27
27
  clientSecret: string;
28
28
  }>>;
29
+ generateApplicationToken(applicationId: string): Promise<ApiResponse<{
30
+ applicationAccessToken: {
31
+ token: string;
32
+ expiresAt: string;
33
+ };
34
+ applicationRefreshToken: {
35
+ token: string;
36
+ expiresAt: string;
37
+ };
38
+ }>>;
29
39
  createDevelopmentApplication(input: {
30
40
  universalIdentifier: string;
31
41
  name: string;
@@ -0,0 +1,5 @@
1
+ import { type ApiService } from '../../../cli/utilities/api/api-service';
2
+ export declare const buildAppTokenPairFetcher: (apiService: ApiService, applicationId: string) => () => Promise<{
3
+ accessToken: string;
4
+ refreshToken?: string | undefined;
5
+ } | undefined>;
@@ -1,5 +1,12 @@
1
1
  import { type ConfigService } from '../../../cli/utilities/config/config-service';
2
- export declare const ensureAppAccessTokenIsValidOrRefresh: (configService: ConfigService, credentials?: {
3
- clientId: string;
4
- clientSecret: string;
5
- } | undefined) => Promise<string | undefined>;
2
+ export type AppTokenSources = {
3
+ credentials?: {
4
+ clientId: string;
5
+ clientSecret: string;
6
+ };
7
+ fetchTokenPair?: () => Promise<{
8
+ accessToken: string;
9
+ refreshToken?: string;
10
+ } | undefined>;
11
+ };
12
+ export declare const ensureAppAccessTokenIsValidOrRefresh: (configService: ConfigService, tokenSources?: AppTokenSources | undefined) => Promise<string | undefined>;
@@ -5,6 +5,6 @@ export declare const ensureAppRegistration: (apiService: ApiService, configServi
5
5
  universalIdentifier: string;
6
6
  }) => Promise<{
7
7
  clientId: string;
8
- clientSecret: string;
8
+ clientSecret?: string | undefined;
9
9
  isNewRegistration: boolean;
10
10
  }>;
@@ -1,6 +1,6 @@
1
- import type * as esbuild from 'esbuild';
2
1
  import { type OnFileBuiltCallback } from '../../../../cli/utilities/build/common/restartable-watcher-interface';
3
- import { type FileFolder } from 'twenty-shared/types';
2
+ import type * as esbuild from 'esbuild';
3
+ import { FileFolder } from 'twenty-shared/types';
4
4
  export type ProcessEsbuildResultParams = {
5
5
  result: esbuild.BuildResult;
6
6
  appPath: string;
@@ -35,5 +35,6 @@ export declare class DevModeOrchestrator {
35
35
  private scheduleSync;
36
36
  private performSync;
37
37
  private runSyncPipeline;
38
+ private buildAppTokenSources;
38
39
  private initializePipeline;
39
40
  }
@@ -1,3 +1,4 @@
1
+ import { type AppTokenSources } from '../../../../../cli/utilities/auth/ensure-app-access-token-is-valid-or-refresh';
1
2
  import { type ClientService } from '../../../../../cli/utilities/client/client-service';
2
3
  import { type ConfigService } from '../../../../../cli/utilities/config/config-service';
3
4
  import { type OrchestratorState } from '../../../../../cli/utilities/dev/orchestrator/dev-mode-orchestrator-state';
@@ -14,9 +15,6 @@ export declare class GenerateApiClientOrchestratorStep {
14
15
  });
15
16
  execute(input: {
16
17
  appPath: string;
17
- credentials?: {
18
- clientId: string;
19
- clientSecret: string;
20
- };
18
+ tokenSources?: AppTokenSources;
21
19
  }): Promise<void>;
22
20
  }
@@ -9,7 +9,7 @@ export declare class RegisterAppOrchestratorStep {
9
9
  private notify;
10
10
  registrationCredentials: {
11
11
  clientId: string;
12
- clientSecret: string;
12
+ clientSecret?: string;
13
13
  } | undefined;
14
14
  constructor({ apiService, configService, state, notify }: {
15
15
  apiService: ApiService;
@@ -0,0 +1 @@
1
+ export declare const getServerVersionFromApi: (apiUrl?: string | undefined) => Promise<string | null>;