@posty5/social-publisher-workspace 1.0.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.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @posty5/social-publisher-workspace
2
+
3
+ Values Social Publisher Organization management SDK for Posty5 API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @posty5/core @posty5/social-publisher-workspace
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Setup
14
+
15
+ ```typescript
16
+ import { HttpClient } from '@posty5/core';
17
+ import { SocialPublisherWorkspaceClient } from '@posty5/social-publisher-workspace';
18
+
19
+ // Create HTTP client
20
+ const http = new HttpClient({
21
+ baseUrl: 'https://api.posty5.com',
22
+ apiKey: 'your-api-key',
23
+ });
24
+
25
+ // Create client
26
+ const orgClient = new SocialPublisherWorkspaceClient(http);
27
+ ```
28
+
29
+ ### Create Organization
30
+
31
+ ```typescript
32
+ const orgId = await orgClient.create({
33
+ name: 'My Organization',
34
+ description: 'Marketing Team'
35
+ });
36
+ console.log('Created Organization ID:', orgId);
37
+ ```
38
+
39
+ ### Get Organization
40
+
41
+ ```typescript
42
+ const org = await orgClient.get('org-id');
43
+ console.log('Organization:', org.name);
44
+ ```
45
+
46
+ ### Update Organization
47
+
48
+ ```typescript
49
+ await orgClient.update('org-id', {
50
+ name: 'Updated Name',
51
+ description: 'Updated Description'
52
+ });
53
+ ```
54
+
55
+ ### Delete Organization
56
+
57
+ ```typescript
58
+ await orgClient.delete('org-id');
59
+ ```
60
+
61
+ ### Search Organizations
62
+
63
+ ```typescript
64
+ const results = await orgClient.search({
65
+ name: 'Marketing'
66
+ });
67
+
68
+ console.log('Found:', results.pagination.totalItems);
69
+ ```
70
+
71
+ ## License
72
+
73
+ MIT
@@ -0,0 +1,156 @@
1
+ import { IPaginationResponse, HttpClient, IPaginationParams } from '@posty5/core';
2
+
3
+ interface IWorkspaceRequest {
4
+ name: string;
5
+ description: string;
6
+ /**
7
+ * Tag (optional)
8
+ * Use this field to filter workspaces by tag.
9
+ * You can pass any custom value from your system.
10
+ */
11
+ tag?: string;
12
+ /**
13
+ * Reference ID (optional)
14
+ * Use this field to filter workspaces by reference ID.
15
+ * You can pass any custom identifier from your system.
16
+ */
17
+ refId?: string;
18
+ }
19
+ type ICreateWorkspaceRequest = IWorkspaceRequest;
20
+ type IUpdateWorkspaceRequest = IWorkspaceRequest;
21
+ interface IListParams {
22
+ name?: string;
23
+ description?: string;
24
+ /**
25
+ * API Key ID (optional)
26
+ * You can use this field to filter workspaces by API key
27
+ */
28
+ apiKeyId?: string;
29
+ /**
30
+ * Tag (optional)
31
+ * You can use this field to filter workspaces by tag
32
+ */
33
+ tag?: string;
34
+ /**
35
+ * Reference ID (optional)
36
+ * You can use this field to filter workspaces by reference ID
37
+ */
38
+ refId?: string;
39
+ }
40
+
41
+ type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
42
+ interface IAccountSampleDetails {
43
+ link: string;
44
+ name: string;
45
+ thumbnail: string;
46
+ platformAccountId: string;
47
+ status: SocialPublisherAccountStatusType;
48
+ }
49
+ interface IWorkspaceAccount {
50
+ youtube?: IAccountSampleDetails | any;
51
+ facebook?: IAccountSampleDetails | any;
52
+ instagram?: IAccountSampleDetails | any;
53
+ tiktok?: IAccountSampleDetails | any;
54
+ facebookPlatformPageId?: string;
55
+ instagramPlatformAccountId?: string;
56
+ }
57
+ interface IWorkspaceResponse {
58
+ _id: string;
59
+ name: string;
60
+ account: IWorkspaceAccount;
61
+ }
62
+ interface IWorkspaceSampleDetails {
63
+ _id: string;
64
+ name: string;
65
+ description: string;
66
+ imageUrl?: string;
67
+ createdAt?: string;
68
+ }
69
+ /**
70
+ * Upload image configuration returned by API
71
+ */
72
+ interface IUploadImageConfig {
73
+ uploadUrl: string;
74
+ imageUrl: string;
75
+ }
76
+ /**
77
+ * Workspace details with upload config
78
+ */
79
+ interface IWorkspaceWithUploadConfig {
80
+ workspaceId: string;
81
+ uploadImageConfig: IUploadImageConfig | null;
82
+ }
83
+ type ISearchWorkspaceResponse = IPaginationResponse<IWorkspaceSampleDetails>;
84
+ type ICreateWorkspaceResponse = IWorkspaceWithUploadConfig;
85
+ type IUpdateWorkspaceResponse = IWorkspaceWithUploadConfig;
86
+ interface IDeleteWorkspaceResponse {
87
+ message?: string;
88
+ }
89
+
90
+ /**
91
+ * Social Publisher Workspace Client
92
+ */
93
+ declare class SocialPublisherWorkspaceClient {
94
+ private http;
95
+ private basePath;
96
+ /**
97
+ * Create client
98
+ * @param http - HttpClient instance
99
+ */
100
+ constructor(http: HttpClient);
101
+ /**
102
+ * Search workspaces
103
+ * @param params - Search filters
104
+ * @param pagination - Pagination options
105
+ */
106
+ list(params?: IListParams, pagination?: IPaginationParams): Promise<ISearchWorkspaceResponse>;
107
+ /**
108
+ * Get workspace by ID
109
+ * @param id - Workspace ID
110
+ */
111
+ get(id: string): Promise<IWorkspaceResponse>;
112
+ /**
113
+ * Create workspace with optional image upload
114
+ * @param data - Workspace data
115
+ * @param logo - Optional image file (File or Blob)
116
+ * @returns Workspace details
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Create without image
121
+ * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });
122
+ *
123
+ * // Create with image
124
+ * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });
125
+ * const workspace = await client.create(
126
+ * { name: 'My Workspace', description: 'Description' },
127
+ * file
128
+ * );
129
+ */
130
+ create(data: ICreateWorkspaceRequest, logo?: File | Blob): Promise<string>;
131
+ /**
132
+ * Update workspace with optional image upload
133
+ * @param id - Workspace ID
134
+ * @param data - Workspace data
135
+ * @param logo - Optional new image file (File or Blob)
136
+ * @returns Workspace details
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * // Update without changing image
141
+ * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });
142
+ *
143
+ * // Update with new image
144
+ * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });
145
+ * await client.update(
146
+ * 'workspace-id',
147
+ */
148
+ update(id: string, data: IUpdateWorkspaceRequest, logo?: File | Blob): Promise<void>;
149
+ /**
150
+ * Delete workspace
151
+ * @param id - Workspace ID
152
+ */
153
+ delete(id: string): Promise<void>;
154
+ }
155
+
156
+ export { type IAccountSampleDetails, type ICreateWorkspaceRequest, type ICreateWorkspaceResponse, type IDeleteWorkspaceResponse, type IListParams, type ISearchWorkspaceResponse, type IUpdateWorkspaceRequest, type IUpdateWorkspaceResponse, type IUploadImageConfig, type IWorkspaceAccount, type IWorkspaceRequest, type IWorkspaceResponse, type IWorkspaceSampleDetails, type IWorkspaceWithUploadConfig, type SocialPublisherAccountStatusType, SocialPublisherWorkspaceClient };
@@ -0,0 +1,156 @@
1
+ import { IPaginationResponse, HttpClient, IPaginationParams } from '@posty5/core';
2
+
3
+ interface IWorkspaceRequest {
4
+ name: string;
5
+ description: string;
6
+ /**
7
+ * Tag (optional)
8
+ * Use this field to filter workspaces by tag.
9
+ * You can pass any custom value from your system.
10
+ */
11
+ tag?: string;
12
+ /**
13
+ * Reference ID (optional)
14
+ * Use this field to filter workspaces by reference ID.
15
+ * You can pass any custom identifier from your system.
16
+ */
17
+ refId?: string;
18
+ }
19
+ type ICreateWorkspaceRequest = IWorkspaceRequest;
20
+ type IUpdateWorkspaceRequest = IWorkspaceRequest;
21
+ interface IListParams {
22
+ name?: string;
23
+ description?: string;
24
+ /**
25
+ * API Key ID (optional)
26
+ * You can use this field to filter workspaces by API key
27
+ */
28
+ apiKeyId?: string;
29
+ /**
30
+ * Tag (optional)
31
+ * You can use this field to filter workspaces by tag
32
+ */
33
+ tag?: string;
34
+ /**
35
+ * Reference ID (optional)
36
+ * You can use this field to filter workspaces by reference ID
37
+ */
38
+ refId?: string;
39
+ }
40
+
41
+ type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
42
+ interface IAccountSampleDetails {
43
+ link: string;
44
+ name: string;
45
+ thumbnail: string;
46
+ platformAccountId: string;
47
+ status: SocialPublisherAccountStatusType;
48
+ }
49
+ interface IWorkspaceAccount {
50
+ youtube?: IAccountSampleDetails | any;
51
+ facebook?: IAccountSampleDetails | any;
52
+ instagram?: IAccountSampleDetails | any;
53
+ tiktok?: IAccountSampleDetails | any;
54
+ facebookPlatformPageId?: string;
55
+ instagramPlatformAccountId?: string;
56
+ }
57
+ interface IWorkspaceResponse {
58
+ _id: string;
59
+ name: string;
60
+ account: IWorkspaceAccount;
61
+ }
62
+ interface IWorkspaceSampleDetails {
63
+ _id: string;
64
+ name: string;
65
+ description: string;
66
+ imageUrl?: string;
67
+ createdAt?: string;
68
+ }
69
+ /**
70
+ * Upload image configuration returned by API
71
+ */
72
+ interface IUploadImageConfig {
73
+ uploadUrl: string;
74
+ imageUrl: string;
75
+ }
76
+ /**
77
+ * Workspace details with upload config
78
+ */
79
+ interface IWorkspaceWithUploadConfig {
80
+ workspaceId: string;
81
+ uploadImageConfig: IUploadImageConfig | null;
82
+ }
83
+ type ISearchWorkspaceResponse = IPaginationResponse<IWorkspaceSampleDetails>;
84
+ type ICreateWorkspaceResponse = IWorkspaceWithUploadConfig;
85
+ type IUpdateWorkspaceResponse = IWorkspaceWithUploadConfig;
86
+ interface IDeleteWorkspaceResponse {
87
+ message?: string;
88
+ }
89
+
90
+ /**
91
+ * Social Publisher Workspace Client
92
+ */
93
+ declare class SocialPublisherWorkspaceClient {
94
+ private http;
95
+ private basePath;
96
+ /**
97
+ * Create client
98
+ * @param http - HttpClient instance
99
+ */
100
+ constructor(http: HttpClient);
101
+ /**
102
+ * Search workspaces
103
+ * @param params - Search filters
104
+ * @param pagination - Pagination options
105
+ */
106
+ list(params?: IListParams, pagination?: IPaginationParams): Promise<ISearchWorkspaceResponse>;
107
+ /**
108
+ * Get workspace by ID
109
+ * @param id - Workspace ID
110
+ */
111
+ get(id: string): Promise<IWorkspaceResponse>;
112
+ /**
113
+ * Create workspace with optional image upload
114
+ * @param data - Workspace data
115
+ * @param logo - Optional image file (File or Blob)
116
+ * @returns Workspace details
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Create without image
121
+ * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });
122
+ *
123
+ * // Create with image
124
+ * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });
125
+ * const workspace = await client.create(
126
+ * { name: 'My Workspace', description: 'Description' },
127
+ * file
128
+ * );
129
+ */
130
+ create(data: ICreateWorkspaceRequest, logo?: File | Blob): Promise<string>;
131
+ /**
132
+ * Update workspace with optional image upload
133
+ * @param id - Workspace ID
134
+ * @param data - Workspace data
135
+ * @param logo - Optional new image file (File or Blob)
136
+ * @returns Workspace details
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * // Update without changing image
141
+ * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });
142
+ *
143
+ * // Update with new image
144
+ * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });
145
+ * await client.update(
146
+ * 'workspace-id',
147
+ */
148
+ update(id: string, data: IUpdateWorkspaceRequest, logo?: File | Blob): Promise<void>;
149
+ /**
150
+ * Delete workspace
151
+ * @param id - Workspace ID
152
+ */
153
+ delete(id: string): Promise<void>;
154
+ }
155
+
156
+ export { type IAccountSampleDetails, type ICreateWorkspaceRequest, type ICreateWorkspaceResponse, type IDeleteWorkspaceResponse, type IListParams, type ISearchWorkspaceResponse, type IUpdateWorkspaceRequest, type IUpdateWorkspaceResponse, type IUploadImageConfig, type IWorkspaceAccount, type IWorkspaceRequest, type IWorkspaceResponse, type IWorkspaceSampleDetails, type IWorkspaceWithUploadConfig, type SocialPublisherAccountStatusType, SocialPublisherWorkspaceClient };
package/dist/index.js ADDED
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ var core = require('@posty5/core');
4
+
5
+ // src/social-publisher-workspace.client.ts
6
+ var SocialPublisherWorkspaceClient = class {
7
+ /**
8
+ * Create client
9
+ * @param http - HttpClient instance
10
+ */
11
+ constructor(http) {
12
+ this.basePath = "/api/social-publisher-workspace";
13
+ this.http = http;
14
+ }
15
+ /**
16
+ * Search workspaces
17
+ * @param params - Search filters
18
+ * @param pagination - Pagination options
19
+ */
20
+ async list(params, pagination) {
21
+ const response = await this.http.get(this.basePath, {
22
+ params: {
23
+ ...params,
24
+ ...pagination
25
+ }
26
+ });
27
+ return response.result;
28
+ }
29
+ /**
30
+ * Get workspace by ID
31
+ * @param id - Workspace ID
32
+ */
33
+ async get(id) {
34
+ const response = await this.http.get(`${this.basePath}/${id}`);
35
+ return response.result;
36
+ }
37
+ /**
38
+ * Create workspace with optional image upload
39
+ * @param data - Workspace data
40
+ * @param logo - Optional image file (File or Blob)
41
+ * @returns Workspace details
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Create without image
46
+ * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });
47
+ *
48
+ * // Create with image
49
+ * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });
50
+ * const workspace = await client.create(
51
+ * { name: 'My Workspace', description: 'Description' },
52
+ * file
53
+ * );
54
+ */
55
+ async create(data, logo) {
56
+ const response = await this.http.post(this.basePath, {
57
+ ...data,
58
+ hasImage: !!logo,
59
+ createdFrom: "npmPackage"
60
+ });
61
+ if (logo && response.result?.uploadImageConfig) {
62
+ var res = await core.uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {
63
+ contentType: (
64
+ /*logo instanceof File ? logo.type : 'image/png'*/
65
+ "image/png"
66
+ )
67
+ });
68
+ console.log(res);
69
+ }
70
+ return response.result?.workspaceId;
71
+ }
72
+ /**
73
+ * Update workspace with optional image upload
74
+ * @param id - Workspace ID
75
+ * @param data - Workspace data
76
+ * @param logo - Optional new image file (File or Blob)
77
+ * @returns Workspace details
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Update without changing image
82
+ * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });
83
+ *
84
+ * // Update with new image
85
+ * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });
86
+ * await client.update(
87
+ * 'workspace-id',
88
+ */
89
+ async update(id, data, logo) {
90
+ const response = await this.http.put(`${this.basePath}/${id}`, {
91
+ ...data,
92
+ hasImage: !!logo
93
+ });
94
+ if (logo && response.result?.uploadImageConfig) {
95
+ await core.uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {
96
+ contentType: logo instanceof File ? logo.type : "image/png"
97
+ });
98
+ }
99
+ }
100
+ /**
101
+ * Delete workspace
102
+ * @param id - Workspace ID
103
+ */
104
+ async delete(id) {
105
+ await this.http.delete(`${this.basePath}/${id}`);
106
+ }
107
+ };
108
+
109
+ exports.SocialPublisherWorkspaceClient = SocialPublisherWorkspaceClient;
110
+ //# sourceMappingURL=index.js.map
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/social-publisher-workspace.client.ts"],"names":["uploadToR2"],"mappings":";;;;;AAeO,IAAM,iCAAN,MAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxC,YAAY,IAAA,EAAkB;AAN9B,IAAA,IAAA,CAAQ,QAAA,GAAW,iCAAA;AAOf,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,IAAA,CAAK,MAAA,EAAsB,UAAA,EAAmE;AAChG,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,IAAA,CAAK,GAAA,CAA8B,KAAK,QAAA,EAAU;AAAA,MAC1E,MAAA,EAAQ;AAAA,QACJ,GAAG,MAAA;AAAA,QACH,GAAG;AAAA;AACP,KACH,CAAA;AACD,IAAA,OAAO,QAAA,CAAS,MAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,IAAI,EAAA,EAAyC;AAC/C,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,IAAA,CAAK,GAAA,CAAwB,GAAG,IAAA,CAAK,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAA;AACjF,IAAA,OAAO,QAA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AA,CAAO,iBAAA,CAAkB,WAAW,IAAA,EAAM;AAAA,QAChE,WAAA,EAAa,IAAA,YAAgB,IAAA,GAAO,IAAA,CAAK,IAAA,GAAO;AAAA,OACnD,CAAA;AAAA,IACL;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,EAAA,EAA2B;AACpC,IAAA,MAAM,IAAA,CAAK,KAAK,MAAA,CAAiC,CAAA,EAAG,KAAK,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAA;AAAA,EAC7E;AACJ","file":"index.js","sourcesContent":["import { HttpClient, IPaginationParams, uploadToR2 } from '@posty5/core';\r\nimport {\r\n ICreateWorkspaceRequest,\r\n IUpdateWorkspaceRequest,\r\n IListParams,\r\n ISearchWorkspaceResponse,\r\n ICreateWorkspaceResponse,\r\n IUpdateWorkspaceResponse,\r\n IDeleteWorkspaceResponse,\r\n IWorkspaceResponse\r\n} from './interfaces';\r\n\r\n/**\r\n * Social Publisher Workspace Client\r\n */\r\nexport class SocialPublisherWorkspaceClient {\r\n private http: HttpClient;\r\n private basePath = '/api/social-publisher-workspace';\r\n\r\n /**\r\n * Create client\r\n * @param http - HttpClient instance\r\n */\r\n constructor(http: HttpClient) {\r\n this.http = http;\r\n }\r\n\r\n /**\r\n * Search workspaces\r\n * @param params - Search filters\r\n * @param pagination - Pagination options\r\n */\r\n async list(params?: IListParams, pagination?: IPaginationParams): Promise<ISearchWorkspaceResponse> {\r\n const response = await this.http.get<ISearchWorkspaceResponse>(this.basePath, {\r\n params: {\r\n ...params,\r\n ...pagination\r\n }\r\n });\r\n return response.result!;\r\n }\r\n\r\n /**\r\n * Get workspace by ID\r\n * @param id - Workspace ID\r\n */\r\n async get(id: string): Promise<IWorkspaceResponse> {\r\n const response = await this.http.get<IWorkspaceResponse>(`${this.basePath}/${id}`);\r\n return response.result!;\r\n }\r\n\r\n /**\r\n * Create workspace with optional image upload\r\n * @param data - Workspace data\r\n * @param logo - Optional image file (File or Blob)\r\n * @returns Workspace details\r\n * \r\n * @example\r\n * ```typescript\r\n * // Create without image\r\n * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });\r\n * \r\n * // Create with image\r\n * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });\r\n * const workspace = await client.create(\r\n * { name: 'My Workspace', description: 'Description' },\r\n * file\r\n * );\r\n */\r\n async create(data: ICreateWorkspaceRequest, logo?: File | Blob): Promise<string> {\r\n // Step 1: Create workspace and get upload config\r\n const response = await this.http.post<ICreateWorkspaceResponse>(this.basePath, {\r\n ...data,\r\n hasImage: !!logo,\r\n createdFrom: \"npmPackage\"\r\n });\r\n\r\n\r\n // Step 2: Upload image if provided\r\n if (logo && response.result?.uploadImageConfig) {\r\n var res = await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {\r\n contentType: /*logo instanceof File ? logo.type : 'image/png'*/ \"image/png\"\r\n });\r\n console.log(res);\r\n }\r\n\r\n return response.result?.workspaceId!;\r\n }\r\n\r\n /**\r\n * Update workspace with optional image upload\r\n * @param id - Workspace ID\r\n * @param data - Workspace data\r\n * @param logo - Optional new image file (File or Blob)\r\n * @returns Workspace details\r\n * \r\n * @example\r\n * ```typescript\r\n * // Update without changing image\r\n * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });\r\n * \r\n * // Update with new image\r\n * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });\r\n * await client.update(\r\n * 'workspace-id',\r\n */\r\n async update(id: string, data: IUpdateWorkspaceRequest, logo?: File | Blob): Promise<void> {\r\n // Step 1: Update workspace and get upload config\r\n const response = await this.http.put<IUpdateWorkspaceResponse>(`${this.basePath}/${id}`, {\r\n ...data,\r\n hasImage: !!logo\r\n });\r\n\r\n\r\n // Step 2: Upload image if provided\r\n if (logo && response.result?.uploadImageConfig) {\r\n await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {\r\n contentType: logo instanceof File ? logo.type : 'image/png'\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Delete workspace\r\n * @param id - Workspace ID\r\n */\r\n async delete(id: string): Promise<void> {\r\n await this.http.delete<IDeleteWorkspaceResponse>(`${this.basePath}/${id}`);\r\n }\r\n}\r\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,109 @@
1
+ import { uploadToR2 } from '@posty5/core';
2
+
3
+ // src/social-publisher-workspace.client.ts
4
+ var SocialPublisherWorkspaceClient = class {
5
+ /**
6
+ * Create client
7
+ * @param http - HttpClient instance
8
+ */
9
+ constructor(http) {
10
+ this.basePath = "/api/social-publisher-workspace";
11
+ this.http = http;
12
+ }
13
+ /**
14
+ * Search workspaces
15
+ * @param params - Search filters
16
+ * @param pagination - Pagination options
17
+ */
18
+ async list(params, pagination) {
19
+ const response = await this.http.get(this.basePath, {
20
+ params: {
21
+ ...params,
22
+ ...pagination
23
+ }
24
+ });
25
+ return response.result;
26
+ }
27
+ /**
28
+ * Get workspace by ID
29
+ * @param id - Workspace ID
30
+ */
31
+ async get(id) {
32
+ const response = await this.http.get(`${this.basePath}/${id}`);
33
+ return response.result;
34
+ }
35
+ /**
36
+ * Create workspace with optional image upload
37
+ * @param data - Workspace data
38
+ * @param logo - Optional image file (File or Blob)
39
+ * @returns Workspace details
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Create without image
44
+ * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });
45
+ *
46
+ * // Create with image
47
+ * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });
48
+ * const workspace = await client.create(
49
+ * { name: 'My Workspace', description: 'Description' },
50
+ * file
51
+ * );
52
+ */
53
+ async create(data, logo) {
54
+ const response = await this.http.post(this.basePath, {
55
+ ...data,
56
+ hasImage: !!logo,
57
+ createdFrom: "npmPackage"
58
+ });
59
+ if (logo && response.result?.uploadImageConfig) {
60
+ var res = await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {
61
+ contentType: (
62
+ /*logo instanceof File ? logo.type : 'image/png'*/
63
+ "image/png"
64
+ )
65
+ });
66
+ console.log(res);
67
+ }
68
+ return response.result?.workspaceId;
69
+ }
70
+ /**
71
+ * Update workspace with optional image upload
72
+ * @param id - Workspace ID
73
+ * @param data - Workspace data
74
+ * @param logo - Optional new image file (File or Blob)
75
+ * @returns Workspace details
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Update without changing image
80
+ * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });
81
+ *
82
+ * // Update with new image
83
+ * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });
84
+ * await client.update(
85
+ * 'workspace-id',
86
+ */
87
+ async update(id, data, logo) {
88
+ const response = await this.http.put(`${this.basePath}/${id}`, {
89
+ ...data,
90
+ hasImage: !!logo
91
+ });
92
+ if (logo && response.result?.uploadImageConfig) {
93
+ await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {
94
+ contentType: logo instanceof File ? logo.type : "image/png"
95
+ });
96
+ }
97
+ }
98
+ /**
99
+ * Delete workspace
100
+ * @param id - Workspace ID
101
+ */
102
+ async delete(id) {
103
+ await this.http.delete(`${this.basePath}/${id}`);
104
+ }
105
+ };
106
+
107
+ export { SocialPublisherWorkspaceClient };
108
+ //# sourceMappingURL=index.mjs.map
109
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/social-publisher-workspace.client.ts"],"names":[],"mappings":";;;AAeO,IAAM,iCAAN,MAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,EAQxC,YAAY,IAAA,EAAkB;AAN9B,IAAA,IAAA,CAAQ,QAAA,GAAW,iCAAA;AAOf,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,IAAA,CAAK,MAAA,EAAsB,UAAA,EAAmE;AAChG,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,IAAA,CAAK,GAAA,CAA8B,KAAK,QAAA,EAAU;AAAA,MAC1E,MAAA,EAAQ;AAAA,QACJ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,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,IAAA,CAAK,GAAA,CAA8B,GAAG,IAAA,CAAK,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,EAAI;AAAA,MACrF,GAAG,IAAA;AAAA,MACH,QAAA,EAAU,CAAC,CAAC;AAAA,KACf,CAAA;AAID,IAAA,IAAI,IAAA,IAAQ,QAAA,CAAS,MAAA,EAAQ,iBAAA,EAAmB;AAC5C,MAAA,MAAM,UAAA,CAAW,QAAA,CAAS,MAAA,CAAO,iBAAA,CAAkB,WAAW,IAAA,EAAM;AAAA,QAChE,WAAA,EAAa,IAAA,YAAgB,IAAA,GAAO,IAAA,CAAK,IAAA,GAAO;AAAA,OACnD,CAAA;AAAA,IACL;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,EAAA,EAA2B;AACpC,IAAA,MAAM,IAAA,CAAK,KAAK,MAAA,CAAiC,CAAA,EAAG,KAAK,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAA;AAAA,EAC7E;AACJ","file":"index.mjs","sourcesContent":["import { HttpClient, IPaginationParams, uploadToR2 } from '@posty5/core';\r\nimport {\r\n ICreateWorkspaceRequest,\r\n IUpdateWorkspaceRequest,\r\n IListParams,\r\n ISearchWorkspaceResponse,\r\n ICreateWorkspaceResponse,\r\n IUpdateWorkspaceResponse,\r\n IDeleteWorkspaceResponse,\r\n IWorkspaceResponse\r\n} from './interfaces';\r\n\r\n/**\r\n * Social Publisher Workspace Client\r\n */\r\nexport class SocialPublisherWorkspaceClient {\r\n private http: HttpClient;\r\n private basePath = '/api/social-publisher-workspace';\r\n\r\n /**\r\n * Create client\r\n * @param http - HttpClient instance\r\n */\r\n constructor(http: HttpClient) {\r\n this.http = http;\r\n }\r\n\r\n /**\r\n * Search workspaces\r\n * @param params - Search filters\r\n * @param pagination - Pagination options\r\n */\r\n async list(params?: IListParams, pagination?: IPaginationParams): Promise<ISearchWorkspaceResponse> {\r\n const response = await this.http.get<ISearchWorkspaceResponse>(this.basePath, {\r\n params: {\r\n ...params,\r\n ...pagination\r\n }\r\n });\r\n return response.result!;\r\n }\r\n\r\n /**\r\n * Get workspace by ID\r\n * @param id - Workspace ID\r\n */\r\n async get(id: string): Promise<IWorkspaceResponse> {\r\n const response = await this.http.get<IWorkspaceResponse>(`${this.basePath}/${id}`);\r\n return response.result!;\r\n }\r\n\r\n /**\r\n * Create workspace with optional image upload\r\n * @param data - Workspace data\r\n * @param logo - Optional image file (File or Blob)\r\n * @returns Workspace details\r\n * \r\n * @example\r\n * ```typescript\r\n * // Create without image\r\n * const workspace = await client.create({ name: 'My Workspace', description: 'Description' });\r\n * \r\n * // Create with image\r\n * const file = new File([imageBlob], 'logo.png', { type: 'image/png' });\r\n * const workspace = await client.create(\r\n * { name: 'My Workspace', description: 'Description' },\r\n * file\r\n * );\r\n */\r\n async create(data: ICreateWorkspaceRequest, logo?: File | Blob): Promise<string> {\r\n // Step 1: Create workspace and get upload config\r\n const response = await this.http.post<ICreateWorkspaceResponse>(this.basePath, {\r\n ...data,\r\n hasImage: !!logo,\r\n createdFrom: \"npmPackage\"\r\n });\r\n\r\n\r\n // Step 2: Upload image if provided\r\n if (logo && response.result?.uploadImageConfig) {\r\n var res = await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {\r\n contentType: /*logo instanceof File ? logo.type : 'image/png'*/ \"image/png\"\r\n });\r\n console.log(res);\r\n }\r\n\r\n return response.result?.workspaceId!;\r\n }\r\n\r\n /**\r\n * Update workspace with optional image upload\r\n * @param id - Workspace ID\r\n * @param data - Workspace data\r\n * @param logo - Optional new image file (File or Blob)\r\n * @returns Workspace details\r\n * \r\n * @example\r\n * ```typescript\r\n * // Update without changing image\r\n * await client.update('workspace-id', { name: 'New Name', description: 'New Description' });\r\n * \r\n * // Update with new image\r\n * const file = new File([imageBlob], 'new-logo.png', { type: 'image/png' });\r\n * await client.update(\r\n * 'workspace-id',\r\n */\r\n async update(id: string, data: IUpdateWorkspaceRequest, logo?: File | Blob): Promise<void> {\r\n // Step 1: Update workspace and get upload config\r\n const response = await this.http.put<IUpdateWorkspaceResponse>(`${this.basePath}/${id}`, {\r\n ...data,\r\n hasImage: !!logo\r\n });\r\n\r\n\r\n // Step 2: Upload image if provided\r\n if (logo && response.result?.uploadImageConfig) {\r\n await uploadToR2(response.result.uploadImageConfig.uploadUrl, logo, {\r\n contentType: logo instanceof File ? logo.type : 'image/png'\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Delete workspace\r\n * @param id - Workspace ID\r\n */\r\n async delete(id: string): Promise<void> {\r\n await this.http.delete<IDeleteWorkspaceResponse>(`${this.basePath}/${id}`);\r\n }\r\n}\r\n"]}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@posty5/social-publisher-workspace",
3
+ "version": "1.0.0",
4
+ "description": "Social Publisher Organization management SDK for Posty5 API",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-workspace"
11
+ },
12
+ "homepage": "https://github.com/Posty5/npm-sdk#readme",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.js",
20
+ "types": "./dist/index.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "dev": "tsup --watch",
31
+ "test": "jest",
32
+ "test:watch": "jest --watch",
33
+ "typecheck": "tsc --noEmit",
34
+ "lint": "eslint src --ext .ts",
35
+ "prepublishOnly": "npm run build"
36
+ },
37
+ "keywords": [
38
+ "posty5",
39
+ "social-publisher",
40
+ "organization",
41
+ "sdk",
42
+ "api",
43
+ "typescript"
44
+ ],
45
+ "author": "Posty5",
46
+ "license": "MIT",
47
+ "peerDependencies": {
48
+ "@posty5/core": "^1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@posty5/core": "file:../posty5-core",
52
+ "@types/node": "^20.0.0",
53
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
54
+ "@typescript-eslint/parser": "^6.0.0",
55
+ "eslint": "^8.0.0",
56
+ "typescript": "^5.3.0",
57
+ "tsup": "^8.0.0"
58
+ },
59
+ "engines": {
60
+ "node": ">=16.0.0"
61
+ }
62
+ }