@tuturuuu/internal-api 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/ai.d.ts +43 -0
  2. package/dist/ai.d.ts.map +1 -0
  3. package/dist/ai.js +57 -0
  4. package/dist/auth.d.ts +46 -0
  5. package/dist/auth.d.ts.map +1 -0
  6. package/dist/auth.js +47 -0
  7. package/dist/calendar.d.ts +99 -0
  8. package/dist/calendar.d.ts.map +1 -0
  9. package/dist/calendar.js +94 -0
  10. package/dist/chat.d.ts +46 -0
  11. package/dist/chat.d.ts.map +1 -0
  12. package/dist/chat.js +67 -0
  13. package/dist/client.d.ts +35 -0
  14. package/dist/client.d.ts.map +1 -0
  15. package/dist/client.js +216 -0
  16. package/dist/education.d.ts +167 -0
  17. package/dist/education.d.ts.map +1 -0
  18. package/dist/education.js +288 -0
  19. package/dist/external-projects.d.ts +425 -0
  20. package/dist/external-projects.d.ts.map +1 -0
  21. package/dist/external-projects.js +466 -0
  22. package/dist/finance.d.ts +109 -0
  23. package/dist/finance.d.ts.map +1 -0
  24. package/dist/finance.js +143 -0
  25. package/dist/habit-trackers.d.ts +25 -0
  26. package/dist/habit-trackers.d.ts.map +1 -0
  27. package/dist/habit-trackers.js +108 -0
  28. package/dist/index.d.ts +34 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +280 -0
  31. package/dist/infrastructure.d.ts +354 -0
  32. package/dist/infrastructure.d.ts.map +1 -0
  33. package/dist/infrastructure.js +100 -0
  34. package/dist/inquiries.d.ts +12 -0
  35. package/dist/inquiries.d.ts.map +1 -0
  36. package/dist/inquiries.js +28 -0
  37. package/dist/mail.d.ts +19 -0
  38. package/dist/mail.d.ts.map +1 -0
  39. package/dist/mail.js +12 -0
  40. package/dist/nova.d.ts +5 -0
  41. package/dist/nova.d.ts.map +1 -0
  42. package/dist/nova.js +10 -0
  43. package/dist/posts.d.ts +9 -0
  44. package/dist/posts.d.ts.map +1 -0
  45. package/dist/posts.js +15 -0
  46. package/dist/promotions.d.ts +11 -0
  47. package/dist/promotions.d.ts.map +1 -0
  48. package/dist/promotions.js +15 -0
  49. package/dist/reports.d.ts +42 -0
  50. package/dist/reports.d.ts.map +1 -0
  51. package/dist/reports.js +48 -0
  52. package/dist/roles.d.ts +45 -0
  53. package/dist/roles.d.ts.map +1 -0
  54. package/dist/roles.js +96 -0
  55. package/dist/settings.d.ts +48 -0
  56. package/dist/settings.d.ts.map +1 -0
  57. package/dist/settings.js +66 -0
  58. package/dist/storage.d.ts +187 -0
  59. package/dist/storage.d.ts.map +1 -0
  60. package/dist/storage.js +371 -0
  61. package/dist/tasks-scheduling.d.ts +14 -0
  62. package/dist/tasks-scheduling.d.ts.map +1 -0
  63. package/dist/tasks-scheduling.js +14 -0
  64. package/dist/tasks.d.ts +311 -0
  65. package/dist/tasks.d.ts.map +1 -0
  66. package/dist/tasks.js +396 -0
  67. package/dist/templates.d.ts +48 -0
  68. package/dist/templates.d.ts.map +1 -0
  69. package/dist/templates.js +19 -0
  70. package/dist/time-tracking.d.ts +88 -0
  71. package/dist/time-tracking.d.ts.map +1 -0
  72. package/dist/time-tracking.js +101 -0
  73. package/dist/users-feedbacks.d.ts +66 -0
  74. package/dist/users-feedbacks.d.ts.map +1 -0
  75. package/dist/users-feedbacks.js +46 -0
  76. package/dist/users.d.ts +89 -0
  77. package/dist/users.d.ts.map +1 -0
  78. package/dist/users.js +139 -0
  79. package/dist/workspace-configs.d.ts +24 -0
  80. package/dist/workspace-configs.d.ts.map +1 -0
  81. package/dist/workspace-configs.js +76 -0
  82. package/dist/workspace-user-audit.d.ts +66 -0
  83. package/dist/workspace-user-audit.d.ts.map +1 -0
  84. package/dist/workspace-user-audit.js +23 -0
  85. package/dist/workspaces.d.ts +59 -0
  86. package/dist/workspaces.d.ts.map +1 -0
  87. package/dist/workspaces.js +131 -0
  88. package/package.json +141 -0
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listWorkspaces = listWorkspaces;
4
+ exports.listCmsWorkspaces = listCmsWorkspaces;
5
+ exports.getWorkspace = getWorkspace;
6
+ exports.getWorkspaceExternalProjectMembersContext = getWorkspaceExternalProjectMembersContext;
7
+ exports.listWorkspaceMembers = listWorkspaceMembers;
8
+ exports.listEnhancedWorkspaceMembers = listEnhancedWorkspaceMembers;
9
+ exports.inviteWorkspaceMembers = inviteWorkspaceMembers;
10
+ exports.inviteWorkspaceMember = inviteWorkspaceMember;
11
+ exports.acceptWorkspaceInvite = acceptWorkspaceInvite;
12
+ exports.declineWorkspaceInvite = declineWorkspaceInvite;
13
+ exports.removeWorkspaceMember = removeWorkspaceMember;
14
+ const client_1 = require("./client");
15
+ async function parseAndThrowInternalApiError(response) {
16
+ const fallbackMessage = `Internal API request failed: ${response.status}`;
17
+ let data = null;
18
+ try {
19
+ data = (await response.json());
20
+ }
21
+ catch {
22
+ data = null;
23
+ }
24
+ const error = new Error(data?.message || data?.error || fallbackMessage);
25
+ error.errorCode = data?.errorCode;
26
+ throw error;
27
+ }
28
+ async function listWorkspaces(options) {
29
+ const client = (0, client_1.getInternalApiClient)(options);
30
+ return client.json('/api/v1/workspaces', {
31
+ cache: 'no-store',
32
+ });
33
+ }
34
+ async function listCmsWorkspaces(options) {
35
+ const client = (0, client_1.getInternalApiClient)(options);
36
+ return client.json('/api/v1/cms/workspaces', {
37
+ cache: 'no-store',
38
+ });
39
+ }
40
+ async function getWorkspace(workspaceId, options) {
41
+ const client = (0, client_1.getInternalApiClient)(options);
42
+ return client.json(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}`, {
43
+ cache: 'no-store',
44
+ });
45
+ }
46
+ async function getWorkspaceExternalProjectMembersContext(workspaceId, options) {
47
+ const client = (0, client_1.getInternalApiClient)(options);
48
+ return client.json(`/api/v1/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/external-projects/members`, {
49
+ cache: 'no-store',
50
+ });
51
+ }
52
+ async function listWorkspaceMembers(workspaceId, options) {
53
+ const client = (0, client_1.getInternalApiClient)(options);
54
+ const payload = await client.json(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/members`, {
55
+ cache: 'no-store',
56
+ });
57
+ return payload.members ?? [];
58
+ }
59
+ async function listEnhancedWorkspaceMembers(workspaceId, status, options) {
60
+ const client = (0, client_1.getInternalApiClient)(options);
61
+ const searchParams = new URLSearchParams();
62
+ if (status && status !== 'all') {
63
+ searchParams.set('status', status);
64
+ }
65
+ const suffix = searchParams.toString();
66
+ return client.json(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/members/enhanced${suffix ? `?${suffix}` : ''}`, {
67
+ cache: 'no-store',
68
+ });
69
+ }
70
+ async function inviteWorkspaceMembers(workspaceId, emails, options) {
71
+ const client = (0, client_1.getInternalApiClient)(options);
72
+ return client.json(`/api/v1/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/members/batch-invite`, {
73
+ body: JSON.stringify({ emails }),
74
+ cache: 'no-store',
75
+ headers: {
76
+ 'Content-Type': 'application/json',
77
+ },
78
+ method: 'POST',
79
+ });
80
+ }
81
+ async function inviteWorkspaceMember(workspaceId, payload, options) {
82
+ const client = (0, client_1.getInternalApiClient)(options);
83
+ const response = await client.fetch(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/members/invite`, {
84
+ body: JSON.stringify(payload),
85
+ cache: 'no-store',
86
+ headers: {
87
+ 'Content-Type': 'application/json',
88
+ },
89
+ method: 'POST',
90
+ });
91
+ if (!response.ok) {
92
+ await parseAndThrowInternalApiError(response);
93
+ }
94
+ return (await response.json());
95
+ }
96
+ async function acceptWorkspaceInvite(workspaceId, options) {
97
+ const client = (0, client_1.getInternalApiClient)(options);
98
+ const response = await client.fetch(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/accept-invite`, {
99
+ cache: 'no-store',
100
+ method: 'POST',
101
+ });
102
+ if (!response.ok) {
103
+ await parseAndThrowInternalApiError(response);
104
+ }
105
+ return (await response.json().catch(() => ({})));
106
+ }
107
+ async function declineWorkspaceInvite(workspaceId, options) {
108
+ const client = (0, client_1.getInternalApiClient)(options);
109
+ const response = await client.fetch(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/decline-invite`, {
110
+ cache: 'no-store',
111
+ method: 'POST',
112
+ });
113
+ if (!response.ok) {
114
+ await parseAndThrowInternalApiError(response);
115
+ }
116
+ return (await response.json().catch(() => ({})));
117
+ }
118
+ async function removeWorkspaceMember(workspaceId, payload, options) {
119
+ const client = (0, client_1.getInternalApiClient)(options);
120
+ const searchParams = new URLSearchParams();
121
+ if (payload.userId) {
122
+ searchParams.set('id', payload.userId);
123
+ }
124
+ if (payload.email) {
125
+ searchParams.set('email', payload.email);
126
+ }
127
+ return client.json(`/api/workspaces/${(0, client_1.encodePathSegment)(workspaceId)}/members?${searchParams.toString()}`, {
128
+ cache: 'no-store',
129
+ method: 'DELETE',
130
+ });
131
+ }
package/package.json ADDED
@@ -0,0 +1,141 @@
1
+ {
2
+ "name": "@tuturuuu/internal-api",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": ["dist", "README.md"],
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc --project tsconfig.build.json",
13
+ "clean": "rm -rf dist .turbo tsconfig.build.tsbuildinfo",
14
+ "prepack": "bun run clean && bun run build",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
17
+ "type-check": "tsgo --project tsconfig.typecheck.json"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.js"
24
+ },
25
+ "./ai": {
26
+ "types": "./dist/ai.d.ts",
27
+ "import": "./dist/ai.js",
28
+ "require": "./dist/ai.js"
29
+ },
30
+ "./auth": {
31
+ "types": "./dist/auth.d.ts",
32
+ "import": "./dist/auth.js",
33
+ "require": "./dist/auth.js"
34
+ },
35
+ "./calendar": {
36
+ "types": "./dist/calendar.d.ts",
37
+ "import": "./dist/calendar.js",
38
+ "require": "./dist/calendar.js"
39
+ },
40
+ "./client": {
41
+ "types": "./dist/client.d.ts",
42
+ "import": "./dist/client.js",
43
+ "require": "./dist/client.js"
44
+ },
45
+ "./education": {
46
+ "types": "./dist/education.d.ts",
47
+ "import": "./dist/education.js",
48
+ "require": "./dist/education.js"
49
+ },
50
+ "./finance": {
51
+ "types": "./dist/finance.d.ts",
52
+ "import": "./dist/finance.js",
53
+ "require": "./dist/finance.js"
54
+ },
55
+ "./infrastructure": {
56
+ "types": "./dist/infrastructure.d.ts",
57
+ "import": "./dist/infrastructure.js",
58
+ "require": "./dist/infrastructure.js"
59
+ },
60
+ "./mail": {
61
+ "types": "./dist/mail.d.ts",
62
+ "import": "./dist/mail.js",
63
+ "require": "./dist/mail.js"
64
+ },
65
+ "./promotions": {
66
+ "types": "./dist/promotions.d.ts",
67
+ "import": "./dist/promotions.js",
68
+ "require": "./dist/promotions.js"
69
+ },
70
+ "./reports": {
71
+ "types": "./dist/reports.d.ts",
72
+ "import": "./dist/reports.js",
73
+ "require": "./dist/reports.js"
74
+ },
75
+ "./roles": {
76
+ "types": "./dist/roles.d.ts",
77
+ "import": "./dist/roles.js",
78
+ "require": "./dist/roles.js"
79
+ },
80
+ "./settings": {
81
+ "types": "./dist/settings.d.ts",
82
+ "import": "./dist/settings.js",
83
+ "require": "./dist/settings.js"
84
+ },
85
+ "./storage": {
86
+ "types": "./dist/storage.d.ts",
87
+ "import": "./dist/storage.js",
88
+ "require": "./dist/storage.js"
89
+ },
90
+ "./tasks": {
91
+ "types": "./dist/tasks.d.ts",
92
+ "import": "./dist/tasks.js",
93
+ "require": "./dist/tasks.js"
94
+ },
95
+ "./tasks-scheduling": {
96
+ "types": "./dist/tasks-scheduling.d.ts",
97
+ "import": "./dist/tasks-scheduling.js",
98
+ "require": "./dist/tasks-scheduling.js"
99
+ },
100
+ "./templates": {
101
+ "types": "./dist/templates.d.ts",
102
+ "import": "./dist/templates.js",
103
+ "require": "./dist/templates.js"
104
+ },
105
+ "./time-tracking": {
106
+ "types": "./dist/time-tracking.d.ts",
107
+ "import": "./dist/time-tracking.js",
108
+ "require": "./dist/time-tracking.js"
109
+ },
110
+ "./users": {
111
+ "types": "./dist/users.d.ts",
112
+ "import": "./dist/users.js",
113
+ "require": "./dist/users.js"
114
+ },
115
+ "./users-feedbacks": {
116
+ "types": "./dist/users-feedbacks.d.ts",
117
+ "import": "./dist/users-feedbacks.js",
118
+ "require": "./dist/users-feedbacks.js"
119
+ },
120
+ "./workspace-configs": {
121
+ "types": "./dist/workspace-configs.d.ts",
122
+ "import": "./dist/workspace-configs.js",
123
+ "require": "./dist/workspace-configs.js"
124
+ },
125
+ "./workspaces": {
126
+ "types": "./dist/workspaces.d.ts",
127
+ "import": "./dist/workspaces.js",
128
+ "require": "./dist/workspaces.js"
129
+ }
130
+ },
131
+ "devDependencies": {
132
+ "@tuturuuu/typescript-config": "0.1.0",
133
+ "@types/node": "^25.6.0",
134
+ "typescript": "^6.0.3",
135
+ "vitest": "^4.1.5"
136
+ },
137
+ "packageManager": "bun@1.3.13",
138
+ "dependencies": {
139
+ "@tuturuuu/types": "0.2.4"
140
+ }
141
+ }