@liquidmetal-ai/raindrop 0.4.4 → 0.4.7

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.
@@ -66,42 +66,24 @@ Upload myfile.txt to my-bucket with key 'my-key'
66
66
  if (!this.flags.bucket && !this.flags.moduleId) {
67
67
  this.error('Either --bucket or --moduleId flag must be specified.');
68
68
  }
69
- const { args, flags } = await this.parse(ObjectPut);
70
- let moduleId = this.flags.moduleId || '';
71
- let bucket;
72
- const { client: catalogService, userId, organizationId } = await this.catalogService();
73
- if (!moduleId && this.flags.bucket) {
74
- // If moduleId is not provided and bucket is specified, we need to fetch the moduleId from the catalog service
75
- //string split on # to get bucket name and version
76
- const [bucketName, version] = this.flags.bucket.split('#');
77
- bucket = (await catalogService.resolveBucketLocationToModuleId({
78
- userId,
79
- organizationId,
69
+ const bucketLocation = this.flags.bucket
70
+ ? {
80
71
  bucketLocation: {
81
- bucketLocation: {
82
- case: 'bucket',
83
- value: {
84
- name: bucketName,
85
- version: version || '',
86
- },
72
+ case: 'bucket',
73
+ value: {
74
+ name: this.flags.bucket,
75
+ version: '',
87
76
  },
88
77
  },
89
- })).bucket;
90
- if (!bucket || !bucket.moduleId) {
91
- this.error(`Bucket "${this.flags.bucket}" not found or does not belong to any module.`);
92
78
  }
93
- moduleId = bucket.moduleId;
94
- }
95
- else {
96
- // query for the bucket if moduleId is provided
97
- bucket = (await catalogService.resolveModuleIdToBucketLocation({
98
- userId,
99
- organizationId,
100
- moduleId,
101
- })).bucket;
102
- }
103
- console.log(`Using moduleId: ${moduleId}`);
104
- const { client: objectService } = await this.objectService(moduleId);
79
+ : {
80
+ bucketLocation: {
81
+ case: 'moduleId',
82
+ value: this.flags.moduleId,
83
+ },
84
+ };
85
+ const { args, flags } = await this.parse(ObjectPut);
86
+ const { client: objectService, userId, organizationId } = await this.objectService();
105
87
  // Read the file
106
88
  const fileContent = await fs.readFile(args.file);
107
89
  // Get content type if not specified
@@ -109,19 +91,17 @@ Upload myfile.txt to my-bucket with key 'my-key'
109
91
  const response = await objectService.putObject({
110
92
  userId,
111
93
  organizationId,
112
- moduleId,
94
+ bucketLocation,
113
95
  key: args.key,
114
96
  content: fileContent,
115
97
  contentType,
116
98
  });
117
- //attach the bucket to the response
118
- response.bucket = bucket;
119
99
  if (flags.output === 'json') {
120
100
  console.log(toJsonString(PutObjectResponseSchema, response, { prettySpaces: 2 }));
121
101
  }
122
102
  else {
123
103
  console.log('Successfully uploaded file:');
124
- console.log(`Bucket: ${response.bucket.bucketName}`);
104
+ console.log(`Bucket: ${response.bucket?.bucketName}`);
125
105
  console.log(`Key: ${response.key}`);
126
106
  }
127
107
  }