@refleet/refleet-sdk-ts 0.1.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/dist/client.js +195 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/config.js +7 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/errors.js +96 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.js +18 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/proto/api/shared/error_pb.js +7 -0
  12. package/dist/proto/api/shared/error_pb.js.map +1 -0
  13. package/dist/proto/api/shared/user_pb.js +7 -0
  14. package/dist/proto/api/shared/user_pb.js.map +1 -0
  15. package/dist/proto/api/v1/auth_pb.js +12 -0
  16. package/dist/proto/api/v1/auth_pb.js.map +1 -0
  17. package/dist/proto/api/v1/hello_pb.js +9 -0
  18. package/dist/proto/api/v1/hello_pb.js.map +1 -0
  19. package/dist/proto/api/v1/libraries_pb.js +10 -0
  20. package/dist/proto/api/v1/libraries_pb.js.map +1 -0
  21. package/dist/proto/api/v1/teams_pb.js +10 -0
  22. package/dist/proto/api/v1/teams_pb.js.map +1 -0
  23. package/dist/proto/buf/validate/validate_pb.js +7 -0
  24. package/dist/proto/buf/validate/validate_pb.js.map +1 -0
  25. package/dist/proto/google/api/annotations_pb.js +8 -0
  26. package/dist/proto/google/api/annotations_pb.js.map +1 -0
  27. package/dist/proto/google/api/http_pb.js +6 -0
  28. package/dist/proto/google/api/http_pb.js.map +1 -0
  29. package/dist/services/ai.js +217 -0
  30. package/dist/services/ai.js.map +1 -0
  31. package/dist/services/auth.js +105 -0
  32. package/dist/services/auth.js.map +1 -0
  33. package/dist/services/base.js +27 -0
  34. package/dist/services/base.js.map +1 -0
  35. package/dist/services/collections.js +208 -0
  36. package/dist/services/collections.js.map +1 -0
  37. package/dist/services/files.js +82 -0
  38. package/dist/services/files.js.map +1 -0
  39. package/dist/services/libraries.js +162 -0
  40. package/dist/services/libraries.js.map +1 -0
  41. package/dist/services/runtime-vars.js +84 -0
  42. package/dist/services/runtime-vars.js.map +1 -0
  43. package/dist/services/subscriptions.js +178 -0
  44. package/dist/services/subscriptions.js.map +1 -0
  45. package/dist/services/teams.js +194 -0
  46. package/dist/services/teams.js.map +1 -0
  47. package/dist/services/users.js +65 -0
  48. package/dist/services/users.js.map +1 -0
  49. package/dist/transports/grpc.js +194 -0
  50. package/dist/transports/grpc.js.map +1 -0
  51. package/dist/transports/http.js +169 -0
  52. package/dist/transports/http.js.map +1 -0
  53. package/dist/transports/service-registry.js +49 -0
  54. package/dist/transports/service-registry.js.map +1 -0
  55. package/package.json +67 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sources":["../../src/services/collections.ts"],"sourcesContent":["/**\n * CollectionRecordsService implementation\n * Handles collection record operations\n */\n\nimport type { Transport } from '../transports/base'\nimport { BaseService } from './base'\nimport type {\n Record as CollectionRecord,\n CreateRecordRequest,\n GetRecordRequest,\n ListRecordsRequest,\n ListRecordsResponse,\n UpdateRecordRequest,\n DeleteRecordRequest,\n DeleteRecordResponse,\n BatchCreateRecordsRequest,\n BatchCreateRecordsResponse,\n} from '../proto/api/v1/collections_pb'\n\n/**\n * Constructor options for CollectionRecordsService\n */\nexport interface CollectionRecordsServiceOptions {\n transport: Transport\n}\n\n/**\n * Simplified create record options\n */\nexport interface CreateRecordOptions {\n collectionId: string\n data: { [key: string]: unknown }\n teamId?: string\n projectId?: string\n}\n\n/**\n * Simplified list records options\n */\nexport interface ListRecordsOptions {\n collectionId: string\n teamId?: string\n projectId?: string\n filter?: string\n orderBy?: string\n pageSize?: number\n pageToken?: string\n expand?: string\n}\n\n/**\n * CollectionRecordsService - Collection record CRUD operations\n *\n * @example\n * ```typescript\n * const records = new CollectionRecordsService({ transport })\n *\n * // Create a record\n * const record = await records.createRecord({\n * collectionId: 'posts',\n * data: { title: 'Hello', content: 'World' },\n * teamId: 'team-123'\n * })\n *\n * // List records\n * const list = await records.listRecords({\n * collectionId: 'posts',\n * teamId: 'team-123',\n * pageSize: 10\n * })\n *\n * // Update a record\n * const updated = await records.updateRecord({\n * collectionId: 'posts',\n * recordId: 'record-123',\n * data: { title: 'Updated Title' }\n * })\n * ```\n */\nexport class CollectionRecordsService extends BaseService {\n constructor(options: CollectionRecordsServiceOptions) {\n super(options.transport)\n }\n\n /**\n * Create a new record in a collection\n *\n * @param request - Create record request\n * @returns Created record\n *\n * @example\n * ```typescript\n * const record = await records.createRecord({\n * collectionId: 'posts',\n * data: { title: 'My Post', content: 'Hello World' },\n * teamId: 'team-123',\n * projectId: 'project-456'\n * })\n * ```\n */\n async createRecord(request: CreateRecordRequest): Promise<CollectionRecord> {\n return this.request<CollectionRecord>('CollectionRecordsService', 'CreateRecord', request)\n }\n\n /**\n * Get a single record by ID\n *\n * @param request - Get record request\n * @returns Record\n *\n * @example\n * ```typescript\n * const record = await records.getRecord({\n * collectionId: 'posts',\n * recordId: 'record-123',\n * teamId: 'team-123',\n * expand: 'author,category'\n * })\n * ```\n */\n async getRecord(request: GetRecordRequest): Promise<CollectionRecord> {\n return this.request<CollectionRecord>('CollectionRecordsService', 'GetRecord', request)\n }\n\n /**\n * List records in a collection with pagination\n *\n * @param request - List records request\n * @returns List of records with pagination info\n *\n * @example\n * ```typescript\n * const response = await records.listRecords({\n * collectionId: 'posts',\n * teamId: 'team-123',\n * filter: 'status == \"published\"',\n * orderBy: 'created_at desc',\n * pageSize: 20,\n * expand: 'author'\n * })\n *\n * // Iterate through pages\n * let pageToken = ''\n * do {\n * const response = await records.listRecords({\n * collectionId: 'posts',\n * teamId: 'team-123',\n * pageToken\n * })\n * pageToken = response.nextPageToken\n * } while (pageToken)\n * ```\n */\n async listRecords(request: ListRecordsRequest): Promise<ListRecordsResponse> {\n return this.request<ListRecordsResponse>('CollectionRecordsService', 'ListRecords', request)\n }\n\n /**\n * Update a record\n *\n * @param request - Update record request\n * @returns Updated record\n *\n * @example\n * ```typescript\n * const updated = await records.updateRecord({\n * collectionId: 'posts',\n * recordId: 'record-123',\n * data: { title: 'Updated Title' },\n * teamId: 'team-123'\n * })\n * ```\n */\n async updateRecord(request: UpdateRecordRequest): Promise<CollectionRecord> {\n return this.request<CollectionRecord>('CollectionRecordsService', 'UpdateRecord', request)\n }\n\n /**\n * Delete a record\n *\n * @param request - Delete record request\n * @returns Delete response\n *\n * @example\n * ```typescript\n * const result = await records.deleteRecord({\n * collectionId: 'posts',\n * recordId: 'record-123',\n * teamId: 'team-123'\n * })\n * if (result.success) {\n * console.log('Record deleted')\n * }\n * ```\n */\n async deleteRecord(request: DeleteRecordRequest): Promise<DeleteRecordResponse> {\n return this.request<DeleteRecordResponse>('CollectionRecordsService', 'DeleteRecord', request)\n }\n\n /**\n * Batch create multiple records\n *\n * @param request - Batch create records request\n * @returns Batch create response with created records\n *\n * @example\n * ```typescript\n * const result = await records.batchCreateRecords({\n * collectionId: 'posts',\n * records: [\n * { title: 'Post 1', content: 'Content 1' },\n * { title: 'Post 2', content: 'Content 2' }\n * ],\n * teamId: 'team-123'\n * })\n * console.log(`Created ${result.items.length} records`)\n * ```\n */\n async batchCreateRecords(request: BatchCreateRecordsRequest): Promise<BatchCreateRecordsResponse> {\n return this.request<BatchCreateRecordsResponse>('CollectionRecordsService', 'BatchCreateRecords', request)\n }\n\n // ========== Helper methods ==========\n\n /**\n * Create a record with simplified options\n *\n * @param options - Create options\n * @returns Created record\n */\n async create(options: CreateRecordOptions): Promise<CollectionRecord> {\n return this.createRecord({\n collectionId: options.collectionId,\n data: options.data,\n teamId: options.teamId ?? '',\n projectId: options.projectId ?? '',\n } as CreateRecordRequest)\n }\n\n /**\n * List records with simplified options\n *\n * @param options - List options\n * @returns List response\n */\n async list(options: ListRecordsOptions): Promise<ListRecordsResponse> {\n return this.listRecords({\n collectionId: options.collectionId,\n teamId: options.teamId ?? '',\n projectId: options.projectId ?? '',\n filter: options.filter ?? '',\n orderBy: options.orderBy ?? '',\n pageSize: options.pageSize ?? 20,\n pageToken: options.pageToken ?? '',\n expand: options.expand ?? '',\n } as ListRecordsRequest)\n }\n\n /**\n * Get a record by ID with simplified parameters\n *\n * @param collectionId - Collection ID\n * @param recordId - Record ID\n * @param options - Additional options\n * @returns Record\n */\n async get(\n collectionId: string,\n recordId: string,\n options?: { teamId?: string; projectId?: string; expand?: string }\n ): Promise<CollectionRecord> {\n return this.getRecord({\n collectionId,\n recordId,\n teamId: options?.teamId ?? '',\n projectId: options?.projectId ?? '',\n expand: options?.expand ?? '',\n } as GetRecordRequest)\n }\n\n /**\n * Delete a record by ID with simplified parameters\n *\n * @param collectionId - Collection ID\n * @param recordId - Record ID\n * @param options - Additional options\n * @returns Delete response\n */\n async delete(\n collectionId: string,\n recordId: string,\n options?: { teamId?: string; projectId?: string }\n ): Promise<DeleteRecordResponse> {\n return this.deleteRecord({\n collectionId,\n recordId,\n teamId: options?.teamId ?? '',\n projectId: options?.projectId ?? '',\n } as DeleteRecordRequest)\n }\n}\n"],"names":[],"mappings":";;AAgFO,MAAM,iCAAiC,WAAA,CAAY;AAAA,EACxD,YAAY,OAAA,EAA0C;AACpD,IAAA,KAAA,CAAM,QAAQ,SAAS,CAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,aAAa,OAAA,EAAyD;AAC1E,IAAA,OAAO,IAAA,CAAK,OAAA,CAA0B,0BAAA,EAA4B,cAAA,EAAgB,OAAO,CAAA;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,UAAU,OAAA,EAAsD;AACpE,IAAA,OAAO,IAAA,CAAK,OAAA,CAA0B,0BAAA,EAA4B,WAAA,EAAa,OAAO,CAAA;AAAA,EACxF;AAAA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,MAC3B,SAAA,EAAW,SAAS,SAAA,IAAa;AAAA,KACX,CAAA;AAAA,EAC1B;AACF;;;;"}
@@ -0,0 +1,82 @@
1
+ import { BaseService } from './base.js';
2
+
3
+ class FilesService extends BaseService {
4
+ constructor(options) {
5
+ super(options.transport);
6
+ }
7
+ /**
8
+ * Get a presigned URL for file upload
9
+ *
10
+ * @param request - Presigned URL request
11
+ * @returns Presigned URL response with upload URL and public URL
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const response = await files.getPresignedURL({
16
+ * category: 'document',
17
+ * mimeType: 'application/pdf',
18
+ * filename: 'report.pdf'
19
+ * })
20
+ *
21
+ * console.log('Upload URL:', response.presignedUrl)
22
+ * console.log('Public URL:', response.exposedUrl)
23
+ * console.log('File path:', response.filePath)
24
+ * console.log('File ID:', response.fileId)
25
+ * ```
26
+ */
27
+ async getPresignedURL(request) {
28
+ return this.request("FilesService", "GetPresignedURL", request);
29
+ }
30
+ // ========== Helper methods ==========
31
+ /**
32
+ * Get presigned URL with simplified options
33
+ *
34
+ * @param options - Presigned URL options
35
+ * @returns Presigned URL response
36
+ */
37
+ async getUploadURL(options) {
38
+ return this.getPresignedURL({
39
+ category: options.category,
40
+ mimeType: options.mimeType,
41
+ filename: options.filename,
42
+ filePath: options.filePath ?? "",
43
+ fileId: options.fileId ?? ""
44
+ });
45
+ }
46
+ /**
47
+ * Upload a file using presigned URL
48
+ * Combines getting presigned URL and uploading in one step
49
+ *
50
+ * @param options - Upload options
51
+ * @param content - File content (Blob, ArrayBuffer, or string)
52
+ * @returns Upload result with public URL
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const result = await files.upload({
57
+ * category: 'avatar',
58
+ * mimeType: 'image/png',
59
+ * filename: 'profile.png'
60
+ * }, fileBlob)
61
+ *
62
+ * console.log('Uploaded to:', result.exposedUrl)
63
+ * ```
64
+ */
65
+ async upload(options, content) {
66
+ const urlResponse = await this.getUploadURL(options);
67
+ const response = await fetch(urlResponse.presignedUrl, {
68
+ method: "PUT",
69
+ body: content,
70
+ headers: {
71
+ "Content-Type": options.mimeType
72
+ }
73
+ });
74
+ if (!response.ok) {
75
+ throw new Error(`Upload failed: ${response.status} ${response.statusText}`);
76
+ }
77
+ return urlResponse;
78
+ }
79
+ }
80
+
81
+ export { FilesService };
82
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sources":["../../src/services/files.ts"],"sourcesContent":["/**\n * FilesService implementation\n * Handles file upload operations via presigned URLs\n */\n\nimport type { Transport } from '../transports/base'\nimport { BaseService } from './base'\nimport type {\n GetPresignedURLRequest,\n GetPresignedURLResponse,\n} from '../proto/api/v1/files_pb'\n\n/**\n * Constructor options for FilesService\n */\nexport interface FilesServiceOptions {\n transport: Transport\n}\n\n/**\n * Simplified presigned URL options\n */\nexport interface PresignedURLOptions {\n /** File category (e.g., 'avatar', 'document', 'image') */\n category: string\n /** MIME type of the file (e.g., 'image/png', 'application/pdf') */\n mimeType: string\n /** Original filename */\n filename: string\n /** Optional: specify file path */\n filePath?: string\n /** Optional: specify file ID */\n fileId?: string\n}\n\n/**\n * FilesService - File upload operations\n *\n * @example\n * ```typescript\n * const files = new FilesService({ transport })\n *\n * // Get a presigned URL for file upload\n * const result = await files.getPresignedURL({\n * category: 'avatar',\n * mimeType: 'image/png',\n * filename: 'profile.png'\n * })\n *\n * // Upload file to the presigned URL\n * await fetch(result.presignedUrl, {\n * method: 'PUT',\n * body: fileContent,\n * headers: {\n * 'Content-Type': 'image/png'\n * }\n * })\n *\n * // Use the exposed URL in your application\n * console.log('File URL:', result.exposedUrl)\n * ```\n */\nexport class FilesService extends BaseService {\n constructor(options: FilesServiceOptions) {\n super(options.transport)\n }\n\n /**\n * Get a presigned URL for file upload\n *\n * @param request - Presigned URL request\n * @returns Presigned URL response with upload URL and public URL\n *\n * @example\n * ```typescript\n * const response = await files.getPresignedURL({\n * category: 'document',\n * mimeType: 'application/pdf',\n * filename: 'report.pdf'\n * })\n *\n * console.log('Upload URL:', response.presignedUrl)\n * console.log('Public URL:', response.exposedUrl)\n * console.log('File path:', response.filePath)\n * console.log('File ID:', response.fileId)\n * ```\n */\n async getPresignedURL(request: GetPresignedURLRequest): Promise<GetPresignedURLResponse> {\n return this.request<GetPresignedURLResponse>('FilesService', 'GetPresignedURL', request)\n }\n\n // ========== Helper methods ==========\n\n /**\n * Get presigned URL with simplified options\n *\n * @param options - Presigned URL options\n * @returns Presigned URL response\n */\n async getUploadURL(options: PresignedURLOptions): Promise<GetPresignedURLResponse> {\n return this.getPresignedURL({\n category: options.category,\n mimeType: options.mimeType,\n filename: options.filename,\n filePath: options.filePath ?? '',\n fileId: options.fileId ?? '',\n } as GetPresignedURLRequest)\n }\n\n /**\n * Upload a file using presigned URL\n * Combines getting presigned URL and uploading in one step\n *\n * @param options - Upload options\n * @param content - File content (Blob, ArrayBuffer, or string)\n * @returns Upload result with public URL\n *\n * @example\n * ```typescript\n * const result = await files.upload({\n * category: 'avatar',\n * mimeType: 'image/png',\n * filename: 'profile.png'\n * }, fileBlob)\n *\n * console.log('Uploaded to:', result.exposedUrl)\n * ```\n */\n async upload(\n options: PresignedURLOptions,\n content: Blob | ArrayBuffer | string\n ): Promise<GetPresignedURLResponse> {\n // Get presigned URL\n const urlResponse = await this.getUploadURL(options)\n\n // Upload to presigned URL\n const response = await fetch(urlResponse.presignedUrl, {\n method: 'PUT',\n body: content,\n headers: {\n 'Content-Type': options.mimeType,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Upload failed: ${response.status} ${response.statusText}`)\n }\n\n return urlResponse\n }\n}\n"],"names":[],"mappings":";;AA8DO,MAAM,qBAAqB,WAAA,CAAY;AAAA,EAC5C,YAAY,OAAA,EAA8B;AACxC,IAAA,KAAA,CAAM,QAAQ,SAAS,CAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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esService extends BaseService {
4
+ constructor(options) {
5
+ super(options.transport);
6
+ }
7
+ /**
8
+ * Get a library by ID
9
+ *
10
+ * @param request - Get library request
11
+ * @returns Library response
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const response = await libraries.getLibrary({
16
+ * libraryId: 'lib-123'
17
+ * })
18
+ * console.log(response.library)
19
+ * ```
20
+ */
21
+ async getLibrary(request) {
22
+ return this.request("LibrariesService", "GetLibrary", request);
23
+ }
24
+ /**
25
+ * List libraries with pagination
26
+ *
27
+ * @param request - List libraries request
28
+ * @returns List of libraries with pagination info
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const response = await libraries.listLibraries({
33
+ * pageSize: 20,
34
+ * filter: 'type == "document"',
35
+ * orderBy: 'name asc'
36
+ * })
37
+ * ```
38
+ */
39
+ async listLibraries(request) {
40
+ return this.request("LibrariesService", "ListLibraries", request);
41
+ }
42
+ /**
43
+ * Create a new library
44
+ *
45
+ * @param request - Create library request
46
+ * @returns Created library response
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const response = await libraries.createLibrary({
51
+ * library: {
52
+ * name: 'docs',
53
+ * displayName: 'Documentation',
54
+ * description: 'Project documentation',
55
+ * type: 'document',
56
+ * teamId: 'team-123'
57
+ * }
58
+ * })
59
+ * ```
60
+ */
61
+ async createLibrary(request) {
62
+ return this.request("LibrariesService", "CreateLibrary", request);
63
+ }
64
+ /**
65
+ * Update a library
66
+ *
67
+ * @param request - Update library request
68
+ * @returns Updated library response
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const response = await libraries.updateLibrary({
73
+ * library: {
74
+ * id: 'lib-123',
75
+ * displayName: 'New Display Name'
76
+ * },
77
+ * updateMask: {
78
+ * paths: ['display_name']
79
+ * }
80
+ * })
81
+ * ```
82
+ */
83
+ async updateLibrary(request) {
84
+ return this.request("LibrariesService", "UpdateLibrary", request);
85
+ }
86
+ /**
87
+ * Delete a library
88
+ *
89
+ * @param request - Delete library request
90
+ * @returns Delete response
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * await libraries.deleteLibrary({
95
+ * libraryId: 'lib-123'
96
+ * })
97
+ * ```
98
+ */
99
+ async deleteLibrary(request) {
100
+ return this.request("LibrariesService", "DeleteLibrary", request);
101
+ }
102
+ // ========== Helper methods ==========
103
+ /**
104
+ * Get a library by ID (simplified)
105
+ *
106
+ * @param libraryId - Library ID
107
+ * @returns Library or undefined if not found
108
+ */
109
+ async get(libraryId) {
110
+ const response = await this.getLibrary({
111
+ libraryId
112
+ });
113
+ return response.library;
114
+ }
115
+ /**
116
+ * List all libraries (simplified)
117
+ *
118
+ * @param options - List options
119
+ * @returns List of libraries
120
+ */
121
+ async list(options) {
122
+ return this.listLibraries({
123
+ pageSize: options?.pageSize ?? 50,
124
+ pageToken: options?.pageToken ?? "",
125
+ filter: options?.filter ?? "",
126
+ orderBy: options?.orderBy ?? ""
127
+ });
128
+ }
129
+ /**
130
+ * Create a library (simplified)
131
+ *
132
+ * @param options - Create options
133
+ * @returns Created library
134
+ */
135
+ async create(options) {
136
+ const response = await this.createLibrary({
137
+ library: {
138
+ name: options.name,
139
+ displayName: options.displayName,
140
+ description: options.description ?? "",
141
+ type: options.type,
142
+ teamId: options.teamId
143
+ }
144
+ });
145
+ return response.library;
146
+ }
147
+ /**
148
+ * Delete a library by ID (simplified)
149
+ *
150
+ * @param libraryId - Library ID
151
+ * @param allowMissing - If true, don't error if library doesn't exist
152
+ */
153
+ async delete(libraryId, allowMissing) {
154
+ await this.deleteLibrary({
155
+ libraryId,
156
+ allowMissing: allowMissing ?? false
157
+ });
158
+ }
159
+ }
160
+
161
+ export { LibrariesService };
162
+ //# sourceMappingURL=libraries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libraries.js","sources":["../../src/services/libraries.ts"],"sourcesContent":["/**\n * LibrariesService implementation\n * Handles library management operations\n */\n\nimport type { Transport } from '../transports/base'\nimport { BaseService } from './base'\nimport type {\n Library,\n GetLibraryRequest,\n GetLibraryResponse,\n ListLibrariesRequest,\n ListLibrariesResponse,\n CreateLibraryRequest,\n CreateLibraryResponse,\n UpdateLibraryRequest,\n UpdateLibraryResponse,\n DeleteLibraryRequest,\n DeleteLibraryResponse,\n} from '../proto/api/v1/libraries_pb'\n\n/**\n * Constructor options for LibrariesService\n */\nexport interface LibrariesServiceOptions {\n transport: Transport\n}\n\n/**\n * Simplified create library options\n */\nexport interface CreateLibraryOptions {\n name: string\n displayName: string\n description?: string\n type: string\n teamId: string\n}\n\n/**\n * LibrariesService - Library management operations\n *\n * @example\n * ```typescript\n * const libraries = new LibrariesService({ transport })\n *\n * // Create a library\n * const lib = await libraries.createLibrary({\n * library: {\n * name: 'my-library',\n * displayName: 'My Library',\n * type: 'document',\n * teamId: 'team-123'\n * }\n * })\n *\n * // List libraries\n * const list = await libraries.listLibraries({\n * pageSize: 20\n * })\n *\n * // Get a library\n * const library = await libraries.getLibrary({\n * libraryId: 'lib-123'\n * })\n * ```\n */\nexport class LibrariesService extends BaseService {\n constructor(options: LibrariesServiceOptions) {\n super(options.transport)\n }\n\n /**\n * Get a library by ID\n *\n * @param request - Get library request\n * @returns Library response\n *\n * @example\n * ```typescript\n * const response = await libraries.getLibrary({\n * libraryId: 'lib-123'\n * })\n * console.log(response.library)\n * ```\n */\n async getLibrary(request: GetLibraryRequest): Promise<GetLibraryResponse> {\n return this.request<GetLibraryResponse>('LibrariesService', 'GetLibrary', request)\n }\n\n /**\n * List libraries with pagination\n *\n * @param request - List libraries request\n * @returns List of libraries with pagination info\n *\n * @example\n * ```typescript\n * const response = await libraries.listLibraries({\n * pageSize: 20,\n * filter: 'type == \"document\"',\n * orderBy: 'name asc'\n * })\n * ```\n */\n async listLibraries(request: ListLibrariesRequest): Promise<ListLibrariesResponse> {\n return this.request<ListLibrariesResponse>('LibrariesService', 'ListLibraries', request)\n }\n\n /**\n * Create a new library\n *\n * @param request - Create library request\n * @returns Created library response\n *\n * @example\n * ```typescript\n * const response = await libraries.createLibrary({\n * library: {\n * name: 'docs',\n * displayName: 'Documentation',\n * description: 'Project documentation',\n * type: 'document',\n * teamId: 'team-123'\n * }\n * })\n * ```\n */\n async createLibrary(request: CreateLibraryRequest): Promise<CreateLibraryResponse> {\n return this.request<CreateLibraryResponse>('LibrariesService', 'CreateLibrary', request)\n }\n\n /**\n * Update a library\n *\n * @param request - Update library request\n * @returns Updated library response\n *\n * @example\n * ```typescript\n * const response = await libraries.updateLibrary({\n * library: {\n * id: 'lib-123',\n * displayName: 'New Display Name'\n * },\n * updateMask: {\n * paths: ['display_name']\n * }\n * })\n * ```\n */\n async updateLibrary(request: UpdateLibraryRequest): Promise<UpdateLibraryResponse> {\n return this.request<UpdateLibraryResponse>('LibrariesService', 'UpdateLibrary', request)\n }\n\n /**\n * Delete a library\n *\n * @param request - Delete library request\n * @returns Delete response\n *\n * @example\n * ```typescript\n * await libraries.deleteLibrary({\n * libraryId: 'lib-123'\n * })\n * ```\n */\n async deleteLibrary(request: DeleteLibraryRequest): Promise<DeleteLibraryResponse> {\n return this.request<DeleteLibraryResponse>('LibrariesService', 'DeleteLibrary', request)\n }\n\n // ========== Helper methods ==========\n\n /**\n * Get a library by ID (simplified)\n *\n * @param libraryId - Library ID\n * @returns Library or undefined if not found\n */\n async get(libraryId: string): Promise<Library | undefined> {\n const response = await this.getLibrary({\n libraryId,\n } as GetLibraryRequest)\n return response.library\n }\n\n /**\n * List all libraries (simplified)\n *\n * @param options - List options\n * @returns List of libraries\n */\n async list(options?: {\n pageSize?: number\n pageToken?: string\n filter?: string\n orderBy?: string\n }): Promise<ListLibrariesResponse> {\n return this.listLibraries({\n pageSize: options?.pageSize ?? 50,\n pageToken: options?.pageToken ?? '',\n filter: options?.filter ?? '',\n orderBy: options?.orderBy ?? '',\n } as ListLibrariesRequest)\n }\n\n /**\n * Create a library (simplified)\n *\n * @param options - Create options\n * @returns Created library\n */\n async create(options: CreateLibraryOptions): Promise<Library | undefined> {\n const response = await this.createLibrary({\n library: {\n name: options.name,\n displayName: options.displayName,\n description: options.description ?? '',\n type: options.type,\n teamId: options.teamId,\n },\n } as CreateLibraryRequest)\n return response.library\n }\n\n /**\n * Delete a library by ID (simplified)\n *\n * @param libraryId - Library ID\n * @param allowMissing - If true, don't error if library doesn't exist\n */\n async delete(libraryId: string, allowMissing?: boolean): Promise<void> {\n await this.deleteLibrary({\n libraryId,\n allowMissing: allowMissing ?? false,\n } as DeleteLibraryRequest)\n }\n}\n"],"names":[],"mappings":";;AAmEO,MAAM,yBAAyB,WAAA,CAAY;AAAA,EAChD,YAAY,OAAA,EAAkC;AAC5C,IAAA,KAAA,CAAM,QAAQ,SAAS,CAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,WAAW,OAAA,EAAyD;AACxE,IAAA,OAAO,IAAA,CAAK,OAAA,CAA4B,kBAAA,EAAoB,YAAA,EAAc,OAAO,CAAA;AAAA,EACnF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,MAAM,cAAc,OAAA,EAA+D;AACjF,IAAA,OAAO,IAAA,CAAK,OAAA,CAA+B,kBAAA,EAAoB,eAAA,EAAiB,OAAO,CAAA;AAAA,EACzF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,MAAM,cAAc,OAAA,EAA+D;AACjF,IAAA,OAAO,IAAA,CAAK,OAAA,CAA+B,kBAAA,EAAoB,eAAA,EAAiB,OAAO,CAAA;AAAA,EACzF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,MAAM,cAAc,OAAA,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AACzB,IAAA,OAAO,QAAA,CAAS,OAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,MAAA,CAAO,SAAA,EAAmB,YAAA,EAAuC;AACrE,IAAA,MAAM,KAAK,aAAA,CAAc;AAAA,MACvB,SAAA;AAAA,MACA,cAAc,YAAA,IAAgB;AAAA,KACP,CAAA;AAAA,EAC3B;AACF;;;;"}
@@ -0,0 +1,84 @@
1
+ import { BaseService } from './base.js';
2
+
3
+ class RuntimeVarsService extends BaseService {
4
+ constructor(options) {
5
+ super(options.transport);
6
+ }
7
+ /**
8
+ * Get multiple runtime variables by keys
9
+ *
10
+ * @param request - Batch get request
11
+ * @returns Struct containing variable values
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const response = await runtimeVars.batchGetRuntimeVars({
16
+ * keys: ['app.name', 'app.version', 'feature.enabled']
17
+ * })
18
+ * ```
19
+ */
20
+ async batchGetRuntimeVars(request) {
21
+ return this.request("RuntimeVarsService", "BatchGetRuntimeVars", request);
22
+ }
23
+ // ========== Helper methods ==========
24
+ /**
25
+ * Get multiple runtime variables by keys (simplified)
26
+ *
27
+ * @param keys - Array of variable keys
28
+ * @returns Object with key-value pairs
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const vars = await runtimeVars.batchGet([
33
+ * 'app.name',
34
+ * 'app.version',
35
+ * 'feature.flags'
36
+ * ])
37
+ * console.log(vars['app.name'])
38
+ * ```
39
+ */
40
+ async batchGet(keys) {
41
+ return this.batchGetRuntimeVars({
42
+ keys
43
+ });
44
+ }
45
+ /**
46
+ * Get a single runtime variable
47
+ *
48
+ * @param key - Variable key
49
+ * @returns Variable value or undefined if not found
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const theme = await runtimeVars.get('config.theme')
54
+ * ```
55
+ */
56
+ async get(key) {
57
+ const result = await this.batchGet([key]);
58
+ return result[key];
59
+ }
60
+ /**
61
+ * Get runtime variables with a common prefix
62
+ *
63
+ * @param prefix - Key prefix
64
+ * @param keys - Suffix keys to append to prefix
65
+ * @returns Object with full keys and their values
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const config = await runtimeVars.getWithPrefix('config.', [
70
+ * 'theme',
71
+ * 'locale',
72
+ * 'timezone'
73
+ * ])
74
+ * // Returns { 'config.theme': '...', 'config.locale': '...', ... }
75
+ * ```
76
+ */
77
+ async getWithPrefix(prefix, keys) {
78
+ const fullKeys = keys.map((k) => `${prefix}${k}`);
79
+ return this.batchGet(fullKeys);
80
+ }
81
+ }
82
+
83
+ export { RuntimeVarsService };
84
+ //# sourceMappingURL=runtime-vars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-vars.js","sources":["../../src/services/runtime-vars.ts"],"sourcesContent":["/**\n * RuntimeVarsService implementation\n * Handles runtime variables operations\n */\n\nimport type { Transport } from '../transports/base'\nimport { BaseService } from './base'\nimport type { JsonObject, Message } from '@bufbuild/protobuf'\nimport type {\n BatchGetRuntimeVarsRequest,\n} from '../proto/api/v1/runtime_vars_pb'\n\n/**\n * Constructor options for RuntimeVarsService\n */\nexport interface RuntimeVarsServiceOptions {\n transport: Transport\n}\n\n/**\n * RuntimeVarsService - Runtime variables operations\n *\n * @example\n * ```typescript\n * const runtimeVars = new RuntimeVarsService({ transport })\n *\n * // Get multiple runtime variables\n * const vars = await runtimeVars.batchGet(['config.theme', 'config.locale'])\n * console.log(vars) // { 'config.theme': 'dark', 'config.locale': 'en' }\n * ```\n */\nexport class RuntimeVarsService extends BaseService {\n constructor(options: RuntimeVarsServiceOptions) {\n super(options.transport)\n }\n\n /**\n * Get multiple runtime variables by keys\n *\n * @param request - Batch get request\n * @returns Struct containing variable values\n *\n * @example\n * ```typescript\n * const response = await runtimeVars.batchGetRuntimeVars({\n * keys: ['app.name', 'app.version', 'feature.enabled']\n * })\n * ```\n */\n async batchGetRuntimeVars(request: BatchGetRuntimeVarsRequest): Promise<JsonObject> {\n return this.request<JsonObject & Message>('RuntimeVarsService', 'BatchGetRuntimeVars', request)\n }\n\n // ========== Helper methods ==========\n\n /**\n * Get multiple runtime variables by keys (simplified)\n *\n * @param keys - Array of variable keys\n * @returns Object with key-value pairs\n *\n * @example\n * ```typescript\n * const vars = await runtimeVars.batchGet([\n * 'app.name',\n * 'app.version',\n * 'feature.flags'\n * ])\n * console.log(vars['app.name'])\n * ```\n */\n async batchGet(keys: string[]): Promise<JsonObject> {\n return this.batchGetRuntimeVars({\n keys,\n } as BatchGetRuntimeVarsRequest)\n }\n\n /**\n * Get a single runtime variable\n *\n * @param key - Variable key\n * @returns Variable value or undefined if not found\n *\n * @example\n * ```typescript\n * const theme = await runtimeVars.get('config.theme')\n * ```\n */\n async get(key: string): Promise<unknown> {\n const result = await this.batchGet([key])\n return result[key]\n }\n\n /**\n * Get runtime variables with a common prefix\n *\n * @param prefix - Key prefix\n * @param keys - Suffix keys to append to prefix\n * @returns Object with full keys and their values\n *\n * @example\n * ```typescript\n * const config = await runtimeVars.getWithPrefix('config.', [\n * 'theme',\n * 'locale',\n * 'timezone'\n * ])\n * // Returns { 'config.theme': '...', 'config.locale': '...', ... }\n * ```\n */\n async getWithPrefix(prefix: string, keys: string[]): Promise<JsonObject> {\n const fullKeys = keys.map(k => `${prefix}${k}`)\n return this.batchGet(fullKeys)\n }\n}\n"],"names":[],"mappings":";;AA+BO,MAAM,2BAA2B,WAAA,CAAY;AAAA,EAClD,YAAY,OAAA,EAAoC;AAC9C,IAAA,KAAA,CAAM,QAAQ,SAAS,CAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,oBAAoB,OAAA,EAA0D;AAClF,IAAA,OAAO,IAAA,CAAK,OAAA,CAA8B,oBAAA,EAAsB,qBAAA,EAAuB,OAAO,CAAA;AAAA,EAChG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,MAAM,SAAS,IAAA,EAAqC;AAClD,IAAA,OAAO,KAAK,mBAAA,CAAoB;AAAA,MAC9B;AAAA,KAC6B,CAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,MAAM,IAAI,GAAA,EAA+B;AACvC,IAAA,MAAM,SAAS,MAAM,IAAA,CAAK,QAAA,CAAS,CAAC,GAAG,CAAC,CAAA;AACxC,IAAA,OAAO,OAAO,GAAG,CAAA;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBA,MAAM,aAAA,CAAc,MAAA,EAAgB,IAAA,EAAqC;AACvE,IAAA,MAAM,QAAA,GAAW,KAAK,GAAA,CAAI,CAAA,CAAA,KAAK,GAAG,MAAM,CAAA,EAAG,CAAC,CAAA,CAAE,CAAA;AAC9C,IAAA,OAAO,IAAA,CAAK,SAAS,QAAQ,CAAA;AAAA,EAC/B;AACF;;;;"}
@@ -0,0 +1,178 @@
1
+ import { BaseService } from './base.js';
2
+
3
+ class SubscriptionService extends BaseService {
4
+ constructor(options) {
5
+ super(options.transport);
6
+ }
7
+ /**
8
+ * List subscriptions
9
+ *
10
+ * @param request - List subscriptions request
11
+ * @returns List of subscriptions
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const response = await subscriptions.listSubscriptions({
16
+ * accountType: 'user',
17
+ * subscriptionGroup: 'premium',
18
+ * includeExpired: false,
19
+ * pageSize: 20
20
+ * })
21
+ * ```
22
+ */
23
+ async listSubscriptions(request) {
24
+ return this.request("SubscriptionService", "ListSubscriptions", request);
25
+ }
26
+ /**
27
+ * Get a subscription by ID
28
+ *
29
+ * @param request - Get subscription request
30
+ * @returns Subscription
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const subscription = await subscriptions.getSubscription({
35
+ * subscriptionId: 'sub-123'
36
+ * })
37
+ * ```
38
+ */
39
+ async getSubscription(request) {
40
+ return this.request("SubscriptionService", "GetSubscription", request);
41
+ }
42
+ /**
43
+ * Create a new subscription
44
+ *
45
+ * @param request - Create subscription request
46
+ * @returns Created subscription
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const subscription = await subscriptions.createSubscription({
51
+ * subscriptionTypeId: 'pro-monthly',
52
+ * accountId: 'user-123', // optional, defaults to current user
53
+ * accountType: 'user', // optional, defaults to 'user'
54
+ * autoRenew: true,
55
+ * metadata: { source: 'web' }
56
+ * })
57
+ * ```
58
+ */
59
+ async createSubscription(request) {
60
+ return this.request("SubscriptionService", "CreateSubscription", request);
61
+ }
62
+ /**
63
+ * Renew a subscription
64
+ *
65
+ * @param request - Renew subscription request
66
+ * @returns Renewed subscription
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const subscription = await subscriptions.renewSubscription({
71
+ * subscriptionId: 'sub-123',
72
+ * durationDays: 30 // optional, uses default if not specified
73
+ * })
74
+ * ```
75
+ */
76
+ async renewSubscription(request) {
77
+ return this.request("SubscriptionService", "RenewSubscription", request);
78
+ }
79
+ /**
80
+ * Cancel a subscription
81
+ *
82
+ * @param request - Cancel subscription request
83
+ * @returns Cancelled subscription
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const subscription = await subscriptions.cancelSubscription({
88
+ * subscriptionId: 'sub-123'
89
+ * })
90
+ * ```
91
+ */
92
+ async cancelSubscription(request) {
93
+ return this.request("SubscriptionService", "CancelSubscription", request);
94
+ }
95
+ // ========== Helper methods ==========
96
+ /**
97
+ * Get subscription by ID (simplified)
98
+ *
99
+ * @param subscriptionId - Subscription ID
100
+ * @returns Subscription
101
+ */
102
+ async get(subscriptionId) {
103
+ return this.getSubscription({
104
+ subscriptionId
105
+ });
106
+ }
107
+ /**
108
+ * List user subscriptions (simplified)
109
+ *
110
+ * @param options - List options
111
+ * @returns List of subscriptions
112
+ */
113
+ async list(options) {
114
+ return this.listSubscriptions({
115
+ accountType: options?.accountType ?? "user",
116
+ subscriptionGroup: options?.subscriptionGroup ?? "",
117
+ includeExpired: options?.includeExpired ?? false,
118
+ pageSize: options?.pageSize ?? 50,
119
+ pageToken: options?.pageToken ?? ""
120
+ });
121
+ }
122
+ /**
123
+ * Create a subscription (simplified)
124
+ *
125
+ * @param subscriptionTypeId - Subscription type ID
126
+ * @param options - Additional options
127
+ * @returns Created subscription
128
+ */
129
+ async create(subscriptionTypeId, options) {
130
+ return this.createSubscription({
131
+ subscriptionTypeId,
132
+ accountId: options?.accountId ?? "",
133
+ accountType: options?.accountType ?? "user",
134
+ autoRenew: options?.autoRenew ?? false,
135
+ metadata: options?.metadata
136
+ });
137
+ }
138
+ /**
139
+ * Renew a subscription (simplified)
140
+ *
141
+ * @param subscriptionId - Subscription ID
142
+ * @param durationDays - Optional duration in days
143
+ * @returns Renewed subscription
144
+ */
145
+ async renew(subscriptionId, durationDays) {
146
+ return this.renewSubscription({
147
+ subscriptionId,
148
+ durationDays: durationDays ?? 0
149
+ });
150
+ }
151
+ /**
152
+ * Cancel a subscription (simplified)
153
+ *
154
+ * @param subscriptionId - Subscription ID
155
+ * @returns Cancelled subscription
156
+ */
157
+ async cancel(subscriptionId) {
158
+ return this.cancelSubscription({
159
+ subscriptionId
160
+ });
161
+ }
162
+ /**
163
+ * Check if user has an active subscription
164
+ *
165
+ * @param subscriptionGroup - Optional subscription group to check
166
+ * @returns True if has active subscription
167
+ */
168
+ async hasActiveSubscription(subscriptionGroup) {
169
+ const response = await this.list({
170
+ subscriptionGroup,
171
+ includeExpired: false
172
+ });
173
+ return response.subscriptions.some((sub) => sub.status === "active");
174
+ }
175
+ }
176
+
177
+ export { SubscriptionService };
178
+ //# sourceMappingURL=subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.js","sources":["../../src/services/subscriptions.ts"],"sourcesContent":["/**\n * SubscriptionService implementation\n * Handles subscription management operations\n */\n\nimport type { Transport } from '../transports/base'\nimport { BaseService } from './base'\nimport type {\n Subscription,\n ListSubscriptionsRequest,\n ListSubscriptionsResponse,\n GetSubscriptionRequest,\n CreateSubscriptionRequest,\n RenewSubscriptionRequest,\n CancelSubscriptionRequest,\n} from '../proto/api/v1/subscription_pb'\n\n/**\n * Constructor options for SubscriptionService\n */\nexport interface SubscriptionServiceOptions {\n transport: Transport\n}\n\n/**\n * SubscriptionService - Subscription management operations\n *\n * @example\n * ```typescript\n * const subscriptions = new SubscriptionService({ transport })\n *\n * // List subscriptions\n * const list = await subscriptions.listSubscriptions({\n * accountType: 'user',\n * includeExpired: false\n * })\n *\n * // Get a subscription\n * const sub = await subscriptions.getSubscription({\n * subscriptionId: 'sub-123'\n * })\n *\n * // Create a subscription\n * const newSub = await subscriptions.createSubscription({\n * subscriptionTypeId: 'pro-monthly',\n * autoRenew: true\n * })\n *\n * // Renew a subscription\n * const renewed = await subscriptions.renewSubscription({\n * subscriptionId: 'sub-123',\n * durationDays: 30\n * })\n *\n * // Cancel a subscription\n * const cancelled = await subscriptions.cancelSubscription({\n * subscriptionId: 'sub-123'\n * })\n * ```\n */\nexport class SubscriptionService extends BaseService {\n constructor(options: SubscriptionServiceOptions) {\n super(options.transport)\n }\n\n /**\n * List subscriptions\n *\n * @param request - List subscriptions request\n * @returns List of subscriptions\n *\n * @example\n * ```typescript\n * const response = await subscriptions.listSubscriptions({\n * accountType: 'user',\n * subscriptionGroup: 'premium',\n * includeExpired: false,\n * pageSize: 20\n * })\n * ```\n */\n async listSubscriptions(request: ListSubscriptionsRequest): Promise<ListSubscriptionsResponse> {\n return this.request<ListSubscriptionsResponse>('SubscriptionService', 'ListSubscriptions', request)\n }\n\n /**\n * Get a subscription by ID\n *\n * @param request - Get subscription request\n * @returns Subscription\n *\n * @example\n * ```typescript\n * const subscription = await subscriptions.getSubscription({\n * subscriptionId: 'sub-123'\n * })\n * ```\n */\n async getSubscription(request: GetSubscriptionRequest): Promise<Subscription> {\n return this.request<Subscription>('SubscriptionService', 'GetSubscription', request)\n }\n\n /**\n * Create a new subscription\n *\n * @param request - Create subscription request\n * @returns Created subscription\n *\n * @example\n * ```typescript\n * const subscription = await subscriptions.createSubscription({\n * subscriptionTypeId: 'pro-monthly',\n * accountId: 'user-123', // optional, defaults to current user\n * accountType: 'user', // optional, defaults to 'user'\n * autoRenew: true,\n * metadata: { source: 'web' }\n * })\n * ```\n */\n async createSubscription(request: CreateSubscriptionRequest): Promise<Subscription> {\n return this.request<Subscription>('SubscriptionService', 'CreateSubscription', request)\n }\n\n /**\n * Renew a subscription\n *\n * @param request - Renew subscription request\n * @returns Renewed subscription\n *\n * @example\n * ```typescript\n * const subscription = await subscriptions.renewSubscription({\n * subscriptionId: 'sub-123',\n * durationDays: 30 // optional, uses default if not specified\n * })\n * ```\n */\n async renewSubscription(request: RenewSubscriptionRequest): Promise<Subscription> {\n return this.request<Subscription>('SubscriptionService', 'RenewSubscription', request)\n }\n\n /**\n * Cancel a subscription\n *\n * @param request - Cancel subscription request\n * @returns Cancelled subscription\n *\n * @example\n * ```typescript\n * const subscription = await subscriptions.cancelSubscription({\n * subscriptionId: 'sub-123'\n * })\n * ```\n */\n async cancelSubscription(request: CancelSubscriptionRequest): Promise<Subscription> {\n return this.request<Subscription>('SubscriptionService', 'CancelSubscription', request)\n }\n\n // ========== Helper methods ==========\n\n /**\n * Get subscription by ID (simplified)\n *\n * @param subscriptionId - Subscription ID\n * @returns Subscription\n */\n async get(subscriptionId: string): Promise<Subscription> {\n return this.getSubscription({\n subscriptionId,\n } as GetSubscriptionRequest)\n }\n\n /**\n * List user subscriptions (simplified)\n *\n * @param options - List options\n * @returns List of subscriptions\n */\n async list(options?: {\n accountType?: string\n subscriptionGroup?: string\n includeExpired?: boolean\n pageSize?: number\n pageToken?: string\n }): Promise<ListSubscriptionsResponse> {\n return this.listSubscriptions({\n accountType: options?.accountType ?? 'user',\n subscriptionGroup: options?.subscriptionGroup ?? '',\n includeExpired: options?.includeExpired ?? false,\n pageSize: options?.pageSize ?? 50,\n pageToken: options?.pageToken ?? '',\n } as ListSubscriptionsRequest)\n }\n\n /**\n * Create a subscription (simplified)\n *\n * @param subscriptionTypeId - Subscription type ID\n * @param options - Additional options\n * @returns Created subscription\n */\n async create(\n subscriptionTypeId: string,\n options?: {\n autoRenew?: boolean\n accountId?: string\n accountType?: string\n metadata?: Record<string, unknown>\n }\n ): Promise<Subscription> {\n return this.createSubscription({\n subscriptionTypeId,\n accountId: options?.accountId ?? '',\n accountType: options?.accountType ?? 'user',\n autoRenew: options?.autoRenew ?? false,\n metadata: options?.metadata,\n } as CreateSubscriptionRequest)\n }\n\n /**\n * Renew a subscription (simplified)\n *\n * @param subscriptionId - Subscription ID\n * @param durationDays - Optional duration in days\n * @returns Renewed subscription\n */\n async renew(subscriptionId: string, durationDays?: number): Promise<Subscription> {\n return this.renewSubscription({\n subscriptionId,\n durationDays: durationDays ?? 0,\n } as RenewSubscriptionRequest)\n }\n\n /**\n * Cancel a subscription (simplified)\n *\n * @param subscriptionId - Subscription ID\n * @returns Cancelled subscription\n */\n async cancel(subscriptionId: string): Promise<Subscription> {\n return this.cancelSubscription({\n subscriptionId,\n } as CancelSubscriptionRequest)\n }\n\n /**\n * Check if user has an active subscription\n *\n * @param subscriptionGroup - Optional subscription group to check\n * @returns True if has active subscription\n */\n async hasActiveSubscription(subscriptionGroup?: string): Promise<boolean> {\n const response = await this.list({\n subscriptionGroup,\n includeExpired: false,\n })\n return response.subscriptions.some(sub => sub.status === 'active')\n }\n}\n"],"names":[],"mappings":";;AA4DO,MAAM,4BAA4B,WAAA,CAAY;AAAA,EACnD,YAAY,OAAA,EAAqC;AAC/C,IAAA,KAAA,CAAM,QAAQ,SAAS,CAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,kBAAkB,OAAA,EAAu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