@intlayer/api 6.1.6 → 7.0.0-canary.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 (117) hide show
  1. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  2. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +18 -55
  3. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  4. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +20 -58
  5. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  6. package/dist/cjs/distantDictionary/index.cjs +5 -25
  7. package/dist/cjs/fetcher.cjs +113 -89
  8. package/dist/cjs/fetcher.cjs.map +1 -1
  9. package/dist/cjs/getIntlayerAPI/ai.cjs +163 -188
  10. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  11. package/dist/cjs/getIntlayerAPI/dictionary.cjs +69 -117
  12. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  13. package/dist/cjs/getIntlayerAPI/editor.cjs +37 -74
  14. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  15. package/dist/cjs/getIntlayerAPI/index.cjs +27 -49
  16. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  17. package/dist/cjs/getIntlayerAPI/newsletter.cjs +40 -77
  18. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/oAuth.cjs +26 -65
  20. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/organization.cjs +93 -130
  22. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  23. package/dist/cjs/getIntlayerAPI/project.cjs +109 -154
  24. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  25. package/dist/cjs/getIntlayerAPI/search.cjs +22 -58
  26. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/stripe.cjs +38 -77
  28. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/tag.cjs +47 -86
  30. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/user.cjs +79 -106
  32. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +30 -49
  34. package/dist/cjs/proxy.cjs +90 -115
  35. package/dist/cjs/proxy.cjs.map +1 -1
  36. package/dist/cjs/types.cjs +0 -17
  37. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +17 -20
  38. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  39. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +19 -23
  40. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  41. package/dist/esm/distantDictionary/index.mjs +4 -3
  42. package/dist/esm/fetcher.mjs +111 -64
  43. package/dist/esm/fetcher.mjs.map +1 -1
  44. package/dist/esm/getIntlayerAPI/ai.mjs +160 -153
  45. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  46. package/dist/esm/getIntlayerAPI/dictionary.mjs +66 -82
  47. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  48. package/dist/esm/getIntlayerAPI/editor.mjs +34 -39
  49. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  50. package/dist/esm/getIntlayerAPI/index.mjs +16 -14
  51. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  52. package/dist/esm/getIntlayerAPI/newsletter.mjs +37 -42
  53. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  54. package/dist/esm/getIntlayerAPI/oAuth.mjs +23 -30
  55. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  56. package/dist/esm/getIntlayerAPI/organization.mjs +90 -95
  57. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  58. package/dist/esm/getIntlayerAPI/project.mjs +106 -119
  59. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  60. package/dist/esm/getIntlayerAPI/search.mjs +19 -23
  61. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  62. package/dist/esm/getIntlayerAPI/stripe.mjs +35 -42
  63. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  64. package/dist/esm/getIntlayerAPI/tag.mjs +44 -51
  65. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  66. package/dist/esm/getIntlayerAPI/user.mjs +76 -71
  67. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  68. package/dist/esm/index.mjs +16 -15
  69. package/dist/esm/proxy.mjs +89 -90
  70. package/dist/esm/proxy.mjs.map +1 -1
  71. package/dist/esm/types.mjs +0 -1
  72. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +8 -3
  73. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  74. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +8 -3
  75. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  76. package/dist/types/distantDictionary/index.d.ts +3 -3
  77. package/dist/types/fetcher.d.ts +14 -11
  78. package/dist/types/fetcher.d.ts.map +1 -1
  79. package/dist/types/getIntlayerAPI/ai.d.ts +22 -18
  80. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  81. package/dist/types/getIntlayerAPI/dictionary.d.ts +16 -12
  82. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  83. package/dist/types/getIntlayerAPI/editor.d.ts +11 -7
  84. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  85. package/dist/types/getIntlayerAPI/index.d.ts +30 -27
  86. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  87. package/dist/types/getIntlayerAPI/newsletter.d.ts +11 -7
  88. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  89. package/dist/types/getIntlayerAPI/oAuth.d.ts +8 -5
  90. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  91. package/dist/types/getIntlayerAPI/organization.d.ts +18 -13
  92. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  93. package/dist/types/getIntlayerAPI/project.d.ts +19 -15
  94. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  95. package/dist/types/getIntlayerAPI/search.d.ts +9 -5
  96. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  97. package/dist/types/getIntlayerAPI/stripe.d.ts +11 -7
  98. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  99. package/dist/types/getIntlayerAPI/tag.d.ts +12 -8
  100. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  101. package/dist/types/getIntlayerAPI/user.d.ts +16 -12
  102. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  103. package/dist/types/index.d.ts +16 -15
  104. package/dist/types/proxy.d.ts +10 -5
  105. package/dist/types/proxy.d.ts.map +1 -1
  106. package/dist/types/types.d.ts +13 -12
  107. package/dist/types/types.d.ts.map +1 -1
  108. package/package.json +29 -38
  109. package/LICENSE +0 -202
  110. package/dist/cjs/distantDictionary/index.cjs.map +0 -1
  111. package/dist/cjs/index.cjs.map +0 -1
  112. package/dist/cjs/types.cjs.map +0 -1
  113. package/dist/esm/distantDictionary/index.mjs.map +0 -1
  114. package/dist/esm/index.mjs.map +0 -1
  115. package/dist/esm/types.mjs.map +0 -1
  116. package/dist/types/distantDictionary/index.d.ts.map +0 -1
  117. package/dist/types/index.d.ts.map +0 -1
@@ -1,133 +1,96 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var organization_exports = {};
30
- __export(organization_exports, {
31
- getOrganizationAPI: () => getOrganizationAPI
32
- });
33
- module.exports = __toCommonJS(organization_exports);
34
- var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_fetcher = require('../fetcher.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_fetcher = require('../fetcher.cjs');
3
+ let __intlayer_config_built = require("@intlayer/config/built");
4
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
5
+
6
+ //#region src/getIntlayerAPI/organization.ts
36
7
  const getOrganizationAPI = (authAPIOptions = {}, intlayerConfig) => {
37
- const backendURL = intlayerConfig?.editor?.backendURL ?? import_built.default.editor?.backendURL;
38
- if (!backendURL) {
39
- throw new Error(
40
- "Backend URL is not defined in the Intlayer configuration--."
41
- );
42
- }
43
- const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;
44
- const getOrganizations = async (filters, otherOptions = {}) => await (0, import_fetcher.fetcher)(
45
- ORGANIZATION_API_ROUTE,
46
- authAPIOptions,
47
- otherOptions,
48
- {
49
- params: filters
50
- }
51
- );
52
- const getOrganization = async (organizationId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
53
- `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,
54
- authAPIOptions,
55
- otherOptions
56
- );
57
- const addOrganization = async (organization, otherOptions = {}) => await (0, import_fetcher.fetcher)(
58
- ORGANIZATION_API_ROUTE,
59
- authAPIOptions,
60
- otherOptions,
61
- {
62
- method: "POST",
63
- body: organization
64
- }
65
- );
66
- const updateOrganization = async (organization, otherOptions = {}) => (0, import_fetcher.fetcher)(
67
- ORGANIZATION_API_ROUTE,
68
- authAPIOptions,
69
- otherOptions,
70
- {
71
- method: "PUT",
72
- body: organization
73
- }
74
- );
75
- const updateOrganizationMembers = async (body, otherOptions = {}) => (0, import_fetcher.fetcher)(
76
- `${ORGANIZATION_API_ROUTE}/members`,
77
- authAPIOptions,
78
- otherOptions,
79
- {
80
- method: "PUT",
81
- body
82
- }
83
- );
84
- const addOrganizationMember = async (body, otherOptions = {}) => (0, import_fetcher.fetcher)(
85
- `${ORGANIZATION_API_ROUTE}/member`,
86
- authAPIOptions,
87
- otherOptions,
88
- {
89
- method: "POST",
90
- body
91
- }
92
- );
93
- const deleteOrganization = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
94
- ORGANIZATION_API_ROUTE,
95
- authAPIOptions,
96
- otherOptions,
97
- {
98
- method: "DELETE"
99
- }
100
- );
101
- const selectOrganization = async (organizationId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
102
- `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,
103
- authAPIOptions,
104
- otherOptions,
105
- {
106
- method: "PUT"
107
- }
108
- );
109
- const unselectOrganization = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
110
- `${ORGANIZATION_API_ROUTE}/logout`,
111
- authAPIOptions,
112
- otherOptions,
113
- {
114
- method: "POST"
115
- }
116
- );
117
- return {
118
- getOrganizations,
119
- getOrganization,
120
- addOrganization,
121
- addOrganizationMember,
122
- updateOrganization,
123
- updateOrganizationMembers,
124
- deleteOrganization,
125
- selectOrganization,
126
- unselectOrganization
127
- };
8
+ const backendURL = intlayerConfig?.editor?.backendURL ?? __intlayer_config_built.default?.editor?.backendURL;
9
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration--.");
10
+ const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;
11
+ /**
12
+ * Retrieves a list of organizations based on filters and pagination.
13
+ * @param filters - Filters and pagination options.
14
+ */
15
+ const getOrganizations = async (filters, otherOptions = {}) => await require_fetcher.fetcher(ORGANIZATION_API_ROUTE, authAPIOptions, otherOptions, {
16
+ cache: "no-store",
17
+ params: filters
18
+ });
19
+ /**
20
+ * Retrieves an organization by its ID.
21
+ * @param organizationId - Organization ID.
22
+ */
23
+ const getOrganization = async (organizationId, otherOptions = {}) => await require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/${String(organizationId)}`, authAPIOptions, otherOptions);
24
+ /**
25
+ * Adds a new organization to the database.
26
+ * @param organization - Organization data.
27
+ */
28
+ const addOrganization = async (organization, otherOptions = {}) => await require_fetcher.fetcher(ORGANIZATION_API_ROUTE, authAPIOptions, otherOptions, {
29
+ method: "POST",
30
+ body: organization
31
+ });
32
+ /**
33
+ * Updates an existing organization in the database.
34
+ * @param organization - Updated organization data.
35
+ */
36
+ const updateOrganization = async (organization, otherOptions = {}) => require_fetcher.fetcher(ORGANIZATION_API_ROUTE, authAPIOptions, otherOptions, {
37
+ method: "PUT",
38
+ body: organization
39
+ });
40
+ /**
41
+ * Update members to the organization in the database.
42
+ * @param body - Updated organization members data.
43
+ */
44
+ const updateOrganizationMembers = async (body, otherOptions = {}) => require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/members`, authAPIOptions, otherOptions, {
45
+ method: "PUT",
46
+ body
47
+ });
48
+ /**
49
+ * Admin-only: Update members of any organization by ID
50
+ * @param organizationId - Organization ID
51
+ * @param body - Updated organization members data.
52
+ */
53
+ const updateOrganizationMembersById = async (organizationId, body, otherOptions = {}) => require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/${organizationId}/members`, authAPIOptions, otherOptions, {
54
+ method: "PUT",
55
+ body
56
+ });
57
+ /**
58
+ * Add member to the organization in the database.
59
+ * @param body - Updated organization members data.
60
+ */
61
+ const addOrganizationMember = async (body, otherOptions = {}) => require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/member`, authAPIOptions, otherOptions, {
62
+ method: "POST",
63
+ body
64
+ });
65
+ /**
66
+ * Deletes an organization from the database by its ID.
67
+ * @param organizationId - Organization ID.
68
+ */
69
+ const deleteOrganization = async (otherOptions = {}) => await require_fetcher.fetcher(ORGANIZATION_API_ROUTE, authAPIOptions, otherOptions, { method: "DELETE" });
70
+ /**
71
+ * Select an organization from the database by its ID.
72
+ * @param organizationId - Organization ID.
73
+ */
74
+ const selectOrganization = async (organizationId, otherOptions = {}) => await require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/${String(organizationId)}`, authAPIOptions, otherOptions, { method: "PUT" });
75
+ /**
76
+ * Unselect an organization from the database by its ID.
77
+ * @param organizationId - Organization ID.
78
+ */
79
+ const unselectOrganization = async (otherOptions = {}) => await require_fetcher.fetcher(`${ORGANIZATION_API_ROUTE}/logout`, authAPIOptions, otherOptions, { method: "POST" });
80
+ return {
81
+ getOrganizations,
82
+ getOrganization,
83
+ addOrganization,
84
+ addOrganizationMember,
85
+ updateOrganization,
86
+ updateOrganizationMembers,
87
+ updateOrganizationMembersById,
88
+ deleteOrganization,
89
+ selectOrganization,
90
+ unselectOrganization
91
+ };
128
92
  };
129
- // Annotate the CommonJS export names for ESM import in node:
130
- 0 && (module.exports = {
131
- getOrganizationAPI
132
- });
93
+
94
+ //#endregion
95
+ exports.getOrganizationAPI = getOrganizationAPI;
133
96
  //# sourceMappingURL=organization.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationParam,\n GetOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\n} from '../types';\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration--.'\n );\n }\n\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMembers,\n deleteOrganization,\n selectOrganization,\n unselectOrganization,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAE1B,qBAA6C;AAoBtC,MAAM,qBAAqB,CAChC,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,yBAAyB,GAAG,UAAU;AAM5C,QAAM,mBAAmB,OACvB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,kBAAkB,OACtB,gBACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,sBAAsB,IAAI,OAAO,cAAc,CAAC;AAAA,IACnD;AAAA,IACA;AAAA,EACF;AAMF,QAAM,kBAAkB,OACtB,cACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,qBAAqB,OACzB,cACA,eAA+B,CAAC,UAEhC;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,4BAA4B,OAChC,MACA,eAA+B,CAAC,UAEhC;AAAA,IACE,GAAG,sBAAsB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,UAEhC;AAAA,IACE,GAAG,sBAAsB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAMF,QAAM,qBAAqB,OAAO,eAA+B,CAAC,MAChE,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,qBAAqB,OACzB,gBACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,sBAAsB,IAAI,OAAO,cAAc,CAAC;AAAA,IACnD;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,uBAAuB,OAAO,eAA+B,CAAC,MAClE,UAAM;AAAA,IACJ,GAAG,sBAAsB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
1
+ {"version":3,"file":"organization.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/organization.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddOrganizationBody,\n AddOrganizationMemberBody,\n AddOrganizationMemberResult,\n AddOrganizationResult,\n DeleteOrganizationResult,\n GetOrganizationParam,\n GetOrganizationResult,\n GetOrganizationsParams,\n GetOrganizationsResult,\n SelectOrganizationParam,\n SelectOrganizationResult,\n UnselectOrganizationResult,\n UpdateOrganizationBody,\n UpdateOrganizationMembersBody,\n UpdateOrganizationMembersResult,\n UpdateOrganizationResult,\n} from '../types';\n\nexport const getOrganizationAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration--.'\n );\n }\n\n const ORGANIZATION_API_ROUTE = `${backendURL}/api/organization`;\n\n /**\n * Retrieves a list of organizations based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getOrganizations = async (\n filters?: GetOrganizationsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationsResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Retrieves an organization by its ID.\n * @param organizationId - Organization ID.\n */\n const getOrganization = async (\n organizationId: GetOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions\n );\n\n /**\n * Adds a new organization to the database.\n * @param organization - Organization data.\n */\n const addOrganization = async (\n organization: AddOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: organization,\n }\n );\n\n /**\n * Updates an existing organization in the database.\n * @param organization - Updated organization data.\n */\n const updateOrganization = async (\n organization: UpdateOrganizationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: organization,\n }\n );\n\n /**\n * Update members to the organization in the database.\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembers = async (\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Admin-only: Update members of any organization by ID\n * @param organizationId - Organization ID\n * @param body - Updated organization members data.\n */\n const updateOrganizationMembersById = async (\n organizationId: string,\n body: UpdateOrganizationMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<UpdateOrganizationMembersResult>(\n `${ORGANIZATION_API_ROUTE}/${organizationId}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /**\n * Add member to the organization in the database.\n * @param body - Updated organization members data.\n */\n const addOrganizationMember = async (\n body: AddOrganizationMemberBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<AddOrganizationMemberResult>(\n `${ORGANIZATION_API_ROUTE}/member`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Deletes an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const deleteOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteOrganizationResult>(\n ORGANIZATION_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const selectOrganization = async (\n organizationId: SelectOrganizationParam['organizationId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/${String(organizationId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect an organization from the database by its ID.\n * @param organizationId - Organization ID.\n */\n const unselectOrganization = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectOrganizationResult>(\n `${ORGANIZATION_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n return {\n getOrganizations,\n getOrganization,\n addOrganization,\n addOrganizationMember,\n updateOrganization,\n updateOrganizationMembers,\n updateOrganizationMembersById,\n deleteOrganization,\n selectOrganization,\n unselectOrganization,\n };\n};\n"],"mappings":";;;;;;AAsBA,MAAa,sBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,iCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,8DACD;CAGH,MAAM,yBAAyB,GAAG,WAAW;;;;;CAM7C,MAAM,mBAAmB,OACvB,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,wBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,kBAAkB,OACtB,gBACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,uBAAuB,GAAG,OAAO,eAAe,IACnD,gBACA,aACD;;;;;CAMH,MAAM,kBAAkB,OACtB,cACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,wBACA,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,qBAAqB,OACzB,cACA,eAA+B,EAAE,KAEjCA,wBACE,wBACA,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,4BAA4B,OAChC,MACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,uBAAuB,WAC1B,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;;CAOH,MAAM,gCAAgC,OACpC,gBACA,MACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,uBAAuB,GAAG,eAAe,WAC5C,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjCA,wBACE,GAAG,uBAAuB,UAC1B,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;;CAMH,MAAM,qBAAqB,OAAO,eAA+B,EAAE,KACjE,MAAMA,wBACJ,wBACA,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;CAMH,MAAM,qBAAqB,OACzB,gBACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,uBAAuB,GAAG,OAAO,eAAe,IACnD,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;CAMH,MAAM,uBAAuB,OAAO,eAA+B,EAAE,KACnE,MAAMA,wBACJ,GAAG,uBAAuB,UAC1B,gBACA,cACA,EACE,QAAQ,QACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1,157 +1,112 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var project_exports = {};
30
- __export(project_exports, {
31
- getProjectAPI: () => getProjectAPI
32
- });
33
- module.exports = __toCommonJS(project_exports);
34
- var import_built = __toESM(require("@intlayer/config/built"));
35
- var import_fetcher = require('../fetcher.cjs');
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_fetcher = require('../fetcher.cjs');
3
+ let __intlayer_config_built = require("@intlayer/config/built");
4
+ __intlayer_config_built = require_rolldown_runtime.__toESM(__intlayer_config_built);
5
+
6
+ //#region src/getIntlayerAPI/project.ts
36
7
  const getProjectAPI = (authAPIOptions = {}, intlayerConfig) => {
37
- const backendURL = intlayerConfig?.editor?.backendURL ?? import_built.default.editor?.backendURL;
38
- if (!backendURL) {
39
- throw new Error(
40
- "Backend URL is not defined in the Intlayer configuration."
41
- );
42
- }
43
- const PROJECT_API_ROUTE = `${backendURL}/api/project`;
44
- const getProjects = async (filters, otherOptions = {}) => await (0, import_fetcher.fetcher)(
45
- PROJECT_API_ROUTE,
46
- authAPIOptions,
47
- otherOptions,
48
- {
49
- params: filters
50
- }
51
- );
52
- const addProject = async (project, otherOptions = {}) => await (0, import_fetcher.fetcher)(
53
- `${PROJECT_API_ROUTE}`,
54
- authAPIOptions,
55
- otherOptions,
56
- {
57
- method: "POST",
58
- body: project
59
- }
60
- );
61
- const updateProject = async (project, otherOptions = {}) => await (0, import_fetcher.fetcher)(
62
- `${PROJECT_API_ROUTE}`,
63
- authAPIOptions,
64
- otherOptions,
65
- {
66
- method: "PUT",
67
- body: project
68
- }
69
- );
70
- const updateProjectMembers = async (body, otherOptions = {}) => await (0, import_fetcher.fetcher)(
71
- `${PROJECT_API_ROUTE}/members`,
72
- authAPIOptions,
73
- otherOptions,
74
- {
75
- method: "PUT",
76
- body
77
- }
78
- );
79
- const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await (0, import_fetcher.fetcher)(
80
- `${PROJECT_API_ROUTE}/configuration`,
81
- authAPIOptions,
82
- otherOptions,
83
- {
84
- method: "PUT",
85
- body: projectConfiguration
86
- }
87
- );
88
- const deleteProject = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
89
- `${PROJECT_API_ROUTE}`,
90
- authAPIOptions,
91
- otherOptions,
92
- {
93
- method: "DELETE"
94
- }
95
- );
96
- const selectProject = async (projectId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
97
- `${PROJECT_API_ROUTE}/${String(projectId)}`,
98
- authAPIOptions,
99
- otherOptions,
100
- {
101
- method: "PUT"
102
- }
103
- );
104
- const unselectProject = async (otherOptions = {}) => await (0, import_fetcher.fetcher)(
105
- `${PROJECT_API_ROUTE}/logout`,
106
- authAPIOptions,
107
- otherOptions,
108
- {
109
- method: "POST"
110
- }
111
- );
112
- const addNewAccessKey = async (accessKey, otherOptions = {}) => await (0, import_fetcher.fetcher)(
113
- `${PROJECT_API_ROUTE}/access_key`,
114
- authAPIOptions,
115
- otherOptions,
116
- {
117
- method: "POST",
118
- body: accessKey
119
- }
120
- );
121
- const deleteAccessKey = async (clientId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
122
- `${PROJECT_API_ROUTE}/access_key`,
123
- authAPIOptions,
124
- otherOptions,
125
- {
126
- method: "DELETE",
127
- body: { clientId }
128
- }
129
- );
130
- const refreshAccessKey = async (clientId, otherOptions = {}) => await (0, import_fetcher.fetcher)(
131
- `${PROJECT_API_ROUTE}/access_key`,
132
- authAPIOptions,
133
- otherOptions,
134
- {
135
- method: "PATCH",
136
- body: { clientId }
137
- }
138
- );
139
- return {
140
- getProjects,
141
- addProject,
142
- updateProject,
143
- updateProjectMembers,
144
- pushProjectConfiguration,
145
- deleteProject,
146
- selectProject,
147
- unselectProject,
148
- addNewAccessKey,
149
- deleteAccessKey,
150
- refreshAccessKey
151
- };
8
+ const backendURL = intlayerConfig?.editor?.backendURL ?? __intlayer_config_built.default?.editor?.backendURL;
9
+ if (!backendURL) throw new Error("Backend URL is not defined in the Intlayer configuration.");
10
+ const PROJECT_API_ROUTE = `${backendURL}/api/project`;
11
+ /**
12
+ * Retrieves a list of projects based on filters and pagination.
13
+ * @param filters - Filters and pagination options.
14
+ */
15
+ const getProjects = async (filters, otherOptions = {}) => await require_fetcher.fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
16
+ cache: "no-store",
17
+ params: filters
18
+ });
19
+ /**
20
+ * Adds a new project to the database.
21
+ * @param project - Project data.
22
+ */
23
+ const addProject = async (project, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
24
+ method: "POST",
25
+ body: project
26
+ });
27
+ /**
28
+ * Updates an existing project in the database.
29
+ * @param project - Updated project data.
30
+ */
31
+ const updateProject = async (project, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
32
+ method: "PUT",
33
+ body: project
34
+ });
35
+ /**
36
+ * Updates project members in the database.
37
+ * @param project - Updated project data.
38
+ */
39
+ const updateProjectMembers = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/members`, authAPIOptions, otherOptions, {
40
+ method: "PUT",
41
+ body
42
+ });
43
+ /** Pushes a project configuration to the database.
44
+ * @param projectConfiguration - Project configuration data.
45
+ */
46
+ const pushProjectConfiguration = async (projectConfiguration, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/configuration`, authAPIOptions, otherOptions, {
47
+ method: "PUT",
48
+ body: projectConfiguration
49
+ });
50
+ /**
51
+ * Deletes a project from the database by its ID.
52
+ * @param id - Project ID.
53
+ */
54
+ const deleteProject = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, { method: "DELETE" });
55
+ /**
56
+ * Select a project from the database by its ID.
57
+ * @param projectId - Organization ID.
58
+ */
59
+ const selectProject = async (projectId, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${String(projectId)}`, authAPIOptions, otherOptions, { method: "PUT" });
60
+ /**
61
+ * Unselect a project from the database by its ID.
62
+ * @param projectId - Project ID.
63
+ */
64
+ const unselectProject = async (otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/logout`, authAPIOptions, otherOptions, { method: "POST" });
65
+ /**
66
+ * Add a new access key to a project.
67
+ * @param accessKey - Access key data.
68
+ * @param otherOptions - Fetcher options.
69
+ * @returns The new access key.
70
+ */
71
+ const addNewAccessKey = async (accessKey, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
72
+ method: "POST",
73
+ body: accessKey
74
+ });
75
+ /**
76
+ * Delete a project access key.
77
+ * @param clientId - Access key client ID.
78
+ * @param otherOptions - Fetcher options.
79
+ * @returns The deleted project.
80
+ */
81
+ const deleteAccessKey = async (clientId, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
82
+ method: "DELETE",
83
+ body: { clientId }
84
+ });
85
+ /**
86
+ * Refreshes an access key from a project.
87
+ * @param clientId - The ID of the client to refresh.
88
+ * @param projectId - The ID of the project to refresh the access key from.
89
+ * @returns The new access key.
90
+ */
91
+ const refreshAccessKey = async (clientId, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/access_key`, authAPIOptions, otherOptions, {
92
+ method: "PATCH",
93
+ body: { clientId }
94
+ });
95
+ return {
96
+ getProjects,
97
+ addProject,
98
+ updateProject,
99
+ updateProjectMembers,
100
+ pushProjectConfiguration,
101
+ deleteProject,
102
+ selectProject,
103
+ unselectProject,
104
+ addNewAccessKey,
105
+ deleteAccessKey,
106
+ refreshAccessKey
107
+ };
152
108
  };
153
- // Annotate the CommonJS export names for ESM import in node:
154
- 0 && (module.exports = {
155
- getProjectAPI
156
- });
109
+
110
+ //#endregion
111
+ exports.getProjectAPI = getProjectAPI;
157
112
  //# sourceMappingURL=project.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/config/client';\nimport { fetcher, type FetcherOptions } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAE1B,qBAA6C;AAwBtC,MAAM,gBAAgB,CAC3B,iBAAiC,CAAC,GAClC,mBACG;AACH,QAAM,aACJ,gBAAgB,QAAQ,cAAc,aAAAA,QAAc,QAAQ;AAE9D,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,GAAG,UAAU;AAMvC,QAAM,cAAc,OAClB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,aAAa,OACjB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,SACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,uBAAuB,OAC3B,MACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAKF,QAAM,2BAA2B,OAC/B,sBACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAMF,QAAM,gBAAgB,OAAO,eAA+B,CAAC,MAC3D,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,gBAAgB,OACpB,WACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB,IAAI,OAAO,SAAS,CAAC;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAMF,QAAM,kBAAkB,OAAO,eAA+B,CAAC,MAC7D,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAQF,QAAM,kBAAkB,OACtB,WACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AAQF,QAAM,kBAAkB,OACtB,UACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,SAAS;AAAA,IACnB;AAAA,EACF;AAQF,QAAM,mBAAmB,OACvB,UACA,eAA+B,CAAC,MAEhC,UAAM;AAAA,IACJ,GAAG,iBAAiB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,EAAE,SAAS;AAAA,IACnB;AAAA,EACF;AAEF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["configuration"]}
1
+ {"version":3,"file":"project.cjs","names":["configuration","fetcher"],"sources":["../../../src/getIntlayerAPI/project.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { type FetcherOptions, fetcher } from '../fetcher';\nimport type {\n AddNewAccessKeyBody,\n AddNewAccessKeyResponse,\n AddProjectBody,\n AddProjectResult,\n DeleteAccessKeyBody,\n DeleteAccessKeyResponse,\n DeleteProjectResult,\n GetProjectsParams,\n GetProjectsResult,\n PushProjectConfigurationBody,\n PushProjectConfigurationResult,\n RefreshAccessKeyBody,\n RefreshAccessKeyResponse,\n SelectProjectParam,\n SelectProjectResult,\n UnselectProjectResult,\n UpdateProjectBody,\n UpdateProjectMembersBody,\n UpdateProjectMembersResult,\n UpdateProjectResult,\n} from '../types';\n\nexport const getProjectAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? configuration?.editor?.backendURL;\n\n if (!backendURL) {\n throw new Error(\n 'Backend URL is not defined in the Intlayer configuration.'\n );\n }\n\n const PROJECT_API_ROUTE = `${backendURL}/api/project`;\n\n /**\n * Retrieves a list of projects based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getProjects = async (\n filters?: GetProjectsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetProjectsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new project to the database.\n * @param project - Project data.\n */\n const addProject = async (\n project: AddProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: project,\n }\n );\n\n /**\n * Updates an existing project in the database.\n * @param project - Updated project data.\n */\n const updateProject = async (\n project: UpdateProjectBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: project,\n }\n );\n\n /**\n * Updates project members in the database.\n * @param project - Updated project data.\n */\n const updateProjectMembers = async (\n body: UpdateProjectMembersBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateProjectMembersResult>(\n `${PROJECT_API_ROUTE}/members`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body,\n }\n );\n\n /** Pushes a project configuration to the database.\n * @param projectConfiguration - Project configuration data.\n */\n const pushProjectConfiguration = async (\n projectConfiguration: PushProjectConfigurationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<PushProjectConfigurationResult>(\n `${PROJECT_API_ROUTE}/configuration`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: projectConfiguration,\n }\n );\n\n /**\n * Deletes a project from the database by its ID.\n * @param id - Project ID.\n */\n const deleteProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<DeleteProjectResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Select a project from the database by its ID.\n * @param projectId - Organization ID.\n */\n const selectProject = async (\n projectId: SelectProjectParam['projectId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SelectProjectResult>(\n `${PROJECT_API_ROUTE}/${String(projectId)}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n }\n );\n\n /**\n * Unselect a project from the database by its ID.\n * @param projectId - Project ID.\n */\n const unselectProject = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<UnselectProjectResult>(\n `${PROJECT_API_ROUTE}/logout`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Add a new access key to a project.\n * @param accessKey - Access key data.\n * @param otherOptions - Fetcher options.\n * @returns The new access key.\n */\n const addNewAccessKey = async (\n accessKey: AddNewAccessKeyBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AddNewAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: accessKey,\n }\n );\n\n /**\n * Delete a project access key.\n * @param clientId - Access key client ID.\n * @param otherOptions - Fetcher options.\n * @returns The deleted project.\n */\n const deleteAccessKey = async (\n clientId: DeleteAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n body: { clientId },\n }\n );\n\n /**\n * Refreshes an access key from a project.\n * @param clientId - The ID of the client to refresh.\n * @param projectId - The ID of the project to refresh the access key from.\n * @returns The new access key.\n */\n const refreshAccessKey = async (\n clientId: RefreshAccessKeyBody['clientId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<RefreshAccessKeyResponse>(\n `${PROJECT_API_ROUTE}/access_key`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PATCH',\n body: { clientId },\n }\n );\n\n return {\n getProjects,\n addProject,\n updateProject,\n updateProjectMembers,\n pushProjectConfiguration,\n deleteProject,\n selectProject,\n unselectProject,\n addNewAccessKey,\n deleteAccessKey,\n refreshAccessKey,\n };\n};\n"],"mappings":";;;;;;AA0BA,MAAa,iBACX,iBAAiC,EAAE,EACnC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,iCAAe,QAAQ;AAE/D,KAAI,CAAC,WACH,OAAM,IAAI,MACR,4DACD;CAGH,MAAM,oBAAoB,GAAG,WAAW;;;;;CAMxC,MAAM,cAAc,OAClB,SACA,eAA+B,EAAE,KAEjC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,aAAa,OACjB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,SACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,uBAAuB,OAC3B,MACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,WACrB,gBACA,cACA;EACE,QAAQ;EACR;EACD,CACF;;;;CAKH,MAAM,2BAA2B,OAC/B,sBACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,iBACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,gBAAgB,OAAO,eAA+B,EAAE,KAC5D,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;CAMH,MAAM,gBAAgB,OACpB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,OAAO,UAAU,IACzC,gBACA,cACA,EACE,QAAQ,OACT,CACF;;;;;CAMH,MAAM,kBAAkB,OAAO,eAA+B,EAAE,KAC9D,MAAMA,wBACJ,GAAG,kBAAkB,UACrB,gBACA,cACA,EACE,QAAQ,QACT,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,WACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;;CAQH,MAAM,kBAAkB,OACtB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;;;;;;;CAQH,MAAM,mBAAmB,OACvB,UACA,eAA+B,EAAE,KAEjC,MAAMA,wBACJ,GAAG,kBAAkB,cACrB,gBACA,cACA;EACE,QAAQ;EACR,MAAM,EAAE,UAAU;EACnB,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}