motia 0.8.2-beta.140-073201 → 0.8.2-beta.140-930160

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.
@@ -9,6 +9,7 @@ export declare class Archiver {
9
9
  private uncompressedSize;
10
10
  constructor(filePath: string);
11
11
  appendDirectory(sourcePath: string, targetPath: string): void;
12
- append(stream: fs.ReadStream | string, filePath: string): void;
12
+ private calculateDirectorySize;
13
+ append(stream: fs.ReadStream | string | Buffer, filePath: string): void;
13
14
  finalize(): Promise<ArchiveResult>;
14
15
  }
@@ -16,39 +16,50 @@ class Archiver {
16
16
  }
17
17
  appendDirectory(sourcePath, targetPath) {
18
18
  try {
19
- const items = fs_1.default.readdirSync(sourcePath);
19
+ const stat = fs_1.default.statSync(sourcePath);
20
+ if (!stat.isDirectory()) {
21
+ return;
22
+ }
23
+ this.uncompressedSize += this.calculateDirectorySize(sourcePath);
24
+ this.archive.directory(sourcePath, targetPath === '/' ? false : targetPath);
25
+ }
26
+ catch (_error) { }
27
+ }
28
+ calculateDirectorySize(dirPath) {
29
+ let totalSize = 0;
30
+ try {
31
+ const items = fs_1.default.readdirSync(dirPath);
20
32
  for (const item of items) {
21
- const fullPath = path_1.default.join(sourcePath, item);
33
+ const fullPath = path_1.default.join(dirPath, item);
22
34
  try {
23
35
  const stat = fs_1.default.statSync(fullPath);
24
36
  if (stat.isDirectory()) {
25
- this.appendDirectory(fullPath, path_1.default.join(targetPath, item));
37
+ totalSize += this.calculateDirectorySize(fullPath);
26
38
  }
27
39
  else {
28
- this.append(fs_1.default.createReadStream(fullPath), targetPath ? path_1.default.join(targetPath, item) : item);
40
+ totalSize += stat.size;
29
41
  }
30
42
  }
31
- catch (_error) {
32
- // Ignore individual file errors
33
- }
43
+ catch (_error) { }
34
44
  }
35
45
  }
36
- catch (_error) {
37
- // Ignore directory read errors
38
- }
46
+ catch (_error) { }
47
+ return totalSize;
39
48
  }
40
49
  append(stream, filePath) {
41
- // Track uncompressed size
42
50
  if (typeof stream === 'string') {
43
- // String content
44
51
  this.uncompressedSize += Buffer.byteLength(stream, 'utf8');
52
+ this.archive.append(stream, { name: filePath });
53
+ }
54
+ else if (Buffer.isBuffer(stream)) {
55
+ this.uncompressedSize += stream.length;
56
+ this.archive.append(stream, { name: filePath });
45
57
  }
46
58
  else {
47
- // ReadStream - get file stats
48
59
  const stats = fs_1.default.statSync(stream.path);
49
60
  this.uncompressedSize += stats.size;
61
+ this.archive.append(stream, { name: filePath });
50
62
  }
51
- this.archive.append(stream, { name: filePath });
52
63
  }
53
64
  async finalize() {
54
65
  return new Promise((resolve, reject) => {
@@ -18,7 +18,8 @@ const includeStaticFiles = (steps, builder, archive) => {
18
18
  const matches = (0, glob_1.globSync)(file, { cwd: path_1.default.dirname(step.filePath), absolute: true });
19
19
  matches.forEach((filePath) => {
20
20
  const relativeFilePath = path_1.default.relative(builder.projectDir, filePath);
21
- archive.append(fs_1.default.createReadStream(filePath), relativeFilePath);
21
+ const content = fs_1.default.readFileSync(filePath);
22
+ archive.append(content, relativeFilePath);
22
23
  });
23
24
  });
24
25
  }
@@ -94,8 +94,8 @@ class NodeBuilder {
94
94
  const archiver = new archiver_1.Archiver(path_1.default.join(constants_1.distDir, zipName));
95
95
  const routerJs = path_1.default.join(constants_1.distDir, 'router.js');
96
96
  const routerMap = path_1.default.join(constants_1.distDir, 'router.js.map');
97
- archiver.append(fs_1.default.createReadStream(routerJs), 'router.js');
98
- archiver.append(fs_1.default.createReadStream(routerMap), 'router.js.map');
97
+ archiver.append(fs_1.default.readFileSync(routerJs), 'router.js');
98
+ archiver.append(fs_1.default.readFileSync(routerMap), 'router.js.map');
99
99
  (0, include_static_files_1.includeStaticFiles)(steps, this.builder, archiver);
100
100
  const { compressedSize, uncompressedSize } = await archiver.finalize();
101
101
  fs_1.default.unlinkSync(tsRouter);
@@ -123,8 +123,8 @@ class NodeBuilder {
123
123
  };
124
124
  await esbuild.build(userConfig ? { ...defaultConfig, ...userConfig } : defaultConfig);
125
125
  const archiver = new archiver_1.Archiver(path_1.default.join(constants_1.distDir, bundlePath));
126
- archiver.append(fs_1.default.createReadStream(outputJsFile), entrypointPath);
127
- archiver.append(fs_1.default.createReadStream(outputMapFile), entrypointMapPath);
126
+ archiver.append(fs_1.default.readFileSync(outputJsFile), entrypointPath);
127
+ archiver.append(fs_1.default.readFileSync(outputMapFile), entrypointMapPath);
128
128
  (0, include_static_files_1.includeStaticFiles)([step], this.builder, archiver);
129
129
  const { compressedSize, uncompressedSize } = await archiver.finalize();
130
130
  fs_1.default.unlinkSync(outputJsFile);
@@ -9,6 +9,7 @@ export declare class Archiver {
9
9
  private uncompressedSize;
10
10
  constructor(filePath: string);
11
11
  appendDirectory(sourcePath: string, targetPath: string): void;
12
- append(stream: fs.ReadStream | string, filePath: string): void;
12
+ private calculateDirectorySize;
13
+ append(stream: fs.ReadStream | string | Buffer, filePath: string): void;
13
14
  finalize(): Promise<ArchiveResult>;
14
15
  }
@@ -10,39 +10,50 @@ export class Archiver {
10
10
  }
11
11
  appendDirectory(sourcePath, targetPath) {
12
12
  try {
13
- const items = fs.readdirSync(sourcePath);
13
+ const stat = fs.statSync(sourcePath);
14
+ if (!stat.isDirectory()) {
15
+ return;
16
+ }
17
+ this.uncompressedSize += this.calculateDirectorySize(sourcePath);
18
+ this.archive.directory(sourcePath, targetPath === '/' ? false : targetPath);
19
+ }
20
+ catch (_error) { }
21
+ }
22
+ calculateDirectorySize(dirPath) {
23
+ let totalSize = 0;
24
+ try {
25
+ const items = fs.readdirSync(dirPath);
14
26
  for (const item of items) {
15
- const fullPath = path.join(sourcePath, item);
27
+ const fullPath = path.join(dirPath, item);
16
28
  try {
17
29
  const stat = fs.statSync(fullPath);
18
30
  if (stat.isDirectory()) {
19
- this.appendDirectory(fullPath, path.join(targetPath, item));
31
+ totalSize += this.calculateDirectorySize(fullPath);
20
32
  }
21
33
  else {
22
- this.append(fs.createReadStream(fullPath), targetPath ? path.join(targetPath, item) : item);
34
+ totalSize += stat.size;
23
35
  }
24
36
  }
25
- catch (_error) {
26
- // Ignore individual file errors
27
- }
37
+ catch (_error) { }
28
38
  }
29
39
  }
30
- catch (_error) {
31
- // Ignore directory read errors
32
- }
40
+ catch (_error) { }
41
+ return totalSize;
33
42
  }
34
43
  append(stream, filePath) {
35
- // Track uncompressed size
36
44
  if (typeof stream === 'string') {
37
- // String content
38
45
  this.uncompressedSize += Buffer.byteLength(stream, 'utf8');
46
+ this.archive.append(stream, { name: filePath });
47
+ }
48
+ else if (Buffer.isBuffer(stream)) {
49
+ this.uncompressedSize += stream.length;
50
+ this.archive.append(stream, { name: filePath });
39
51
  }
40
52
  else {
41
- // ReadStream - get file stats
42
53
  const stats = fs.statSync(stream.path);
43
54
  this.uncompressedSize += stats.size;
55
+ this.archive.append(stream, { name: filePath });
44
56
  }
45
- this.archive.append(stream, { name: filePath });
46
57
  }
47
58
  async finalize() {
48
59
  return new Promise((resolve, reject) => {
@@ -12,7 +12,8 @@ export const includeStaticFiles = (steps, builder, archive) => {
12
12
  const matches = globSync(file, { cwd: path.dirname(step.filePath), absolute: true });
13
13
  matches.forEach((filePath) => {
14
14
  const relativeFilePath = path.relative(builder.projectDir, filePath);
15
- archive.append(fs.createReadStream(filePath), relativeFilePath);
15
+ const content = fs.readFileSync(filePath);
16
+ archive.append(content, relativeFilePath);
16
17
  });
17
18
  });
18
19
  }
@@ -55,8 +55,8 @@ export class NodeBuilder {
55
55
  const archiver = new Archiver(path.join(distDir, zipName));
56
56
  const routerJs = path.join(distDir, 'router.js');
57
57
  const routerMap = path.join(distDir, 'router.js.map');
58
- archiver.append(fs.createReadStream(routerJs), 'router.js');
59
- archiver.append(fs.createReadStream(routerMap), 'router.js.map');
58
+ archiver.append(fs.readFileSync(routerJs), 'router.js');
59
+ archiver.append(fs.readFileSync(routerMap), 'router.js.map');
60
60
  includeStaticFiles(steps, this.builder, archiver);
61
61
  const { compressedSize, uncompressedSize } = await archiver.finalize();
62
62
  fs.unlinkSync(tsRouter);
@@ -84,8 +84,8 @@ export class NodeBuilder {
84
84
  };
85
85
  await esbuild.build(userConfig ? { ...defaultConfig, ...userConfig } : defaultConfig);
86
86
  const archiver = new Archiver(path.join(distDir, bundlePath));
87
- archiver.append(fs.createReadStream(outputJsFile), entrypointPath);
88
- archiver.append(fs.createReadStream(outputMapFile), entrypointMapPath);
87
+ archiver.append(fs.readFileSync(outputJsFile), entrypointPath);
88
+ archiver.append(fs.readFileSync(outputMapFile), entrypointMapPath);
89
89
  includeStaticFiles([step], this.builder, archiver);
90
90
  const { compressedSize, uncompressedSize } = await archiver.finalize();
91
91
  fs.unlinkSync(outputJsFile);
@@ -9,6 +9,7 @@ export declare class Archiver {
9
9
  private uncompressedSize;
10
10
  constructor(filePath: string);
11
11
  appendDirectory(sourcePath: string, targetPath: string): void;
12
- append(stream: fs.ReadStream | string, filePath: string): void;
12
+ private calculateDirectorySize;
13
+ append(stream: fs.ReadStream | string | Buffer, filePath: string): void;
13
14
  finalize(): Promise<ArchiveResult>;
14
15
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motia",
3
3
  "description": "A Modern Unified Backend Framework for APIs, Events and Agents",
4
- "version": "0.8.2-beta.140-073201",
4
+ "version": "0.8.2-beta.140-930160",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -46,9 +46,9 @@
46
46
  "python-ast": "^0.1.0",
47
47
  "table": "^6.9.0",
48
48
  "ts-node": "^10.9.2",
49
- "@motiadev/core": "0.8.2-beta.140-073201",
50
- "@motiadev/workbench": "0.8.2-beta.140-073201",
51
- "@motiadev/stream-client-node": "0.8.2-beta.140-073201"
49
+ "@motiadev/stream-client-node": "0.8.2-beta.140-930160",
50
+ "@motiadev/workbench": "0.8.2-beta.140-930160",
51
+ "@motiadev/core": "0.8.2-beta.140-930160"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@amplitude/analytics-types": "^2.9.2",